PublicKeyCredential: rawId 属性
rawId 是 PublicKeyCredential 接口的一个只读属性,它是一个 ArrayBuffer 对象,包含凭据的标识符。
PublicKeyCredential.id 属性是此标识符的 base64url 编码版本。
注意: 此属性只能用于顶级上下文,在 <iframe> 中不可用。
值
一个 ArrayBuffer,包含凭据的标识符。该标识符预计是全局唯一的,并分配给当前的 PublicKeyCredential 及其相关的 AuthenticatorAssertionResponse。
示例
js
const options = {
challenge: new Uint8Array(26) /* from the server */,
rp: {
name: "Example CORP",
id: "login.example.com",
},
user: {
id: new Uint8Array(26) /* To be changed for each user */,
name: "canand@example.com",
displayName: "Carina Anand",
},
pubKeyCredParams: [
{
type: "public-key",
alg: -7,
},
],
};
navigator.credentials
.create({ publicKey: options })
.then((pubKeyCredential) => {
const rawId = pubKeyCredential.rawId;
// Do something with rawId
})
.catch((err) => {
// Deal with any error
});
规范
| 规范 |
|---|
| Web Authentication:访问公钥凭证的 API - 第 3 级 # dom-publickeycredential-rawid |
浏览器兼容性
加载中…