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 |
瀏覽器相容性
載入中…