PublicKeyCredential: thuộc tính rawId
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2021.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Thuộc tính chỉ đọc rawId của
giao diện PublicKeyCredential là một đối tượng ArrayBuffer
chứa định danh của thông tin xác thực.
Thuộc tính PublicKeyCredential.id là phiên bản được mã hóa base64url của định danh này.
Note:
Thuộc tính này chỉ có thể được sử dụng trong ngữ cảnh cấp cao nhất và
sẽ không có sẵn trong một <iframe> chẳng hạn.
Giá trị
Một ArrayBuffer chứa định danh của thông tin xác thực. Định danh này
được kỳ vọng là duy nhất toàn cầu và được chỉ định cho
PublicKeyCredential hiện tại và
AuthenticatorAssertionResponse liên quan của nó.
Ví dụ
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
});
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| Web Authentication: An API for accessing Public Key Credentials - Level 3> # dom-publickeycredential-rawid> |