安全上下文
此特征只可用于
安全上下文
(HTTPS),在某些或所有
支持浏览器
.
id
只读特性在
PublicKeyCredential
接口是
DOMString
, inherited from
Credential
, which represents the identifier of the current
PublicKeyCredential
实例。
This property is a
base64url encoded
版本的
PublicKeyCredential.rawId
.
注意:
This property may only be used in top-level contexts and will not be available in an
<iframe>
例如。
id = publicKeyCredential.id
A
DOMString
being the
base64url encoded
版本的
PublicKeyCredential.rawId
.
var publicKey = {
challenge: new Uint8Array(26) /* this actually is given from the server */,
rp: {
name: "Example CORP",
id : "login.example.com"
},
user: {
id: new Uint8Array(26), /* To be changed for each user */
name: "jdoe@example.com",
displayName: "John Doe",
},
pubKeyCredParams: [
{
type: "public-key",
alg: -7
}
]
};
navigator.credentials.create({ publicKey })
.then(function (newCredentialInfo) {
var id = newCredentialInfo.id;
// Do something with the id
// send attestation response and client extensions
// to the server to proceed with the registration
// of the credential
}).catch(function (err) {
console.error(err);
});
| 规范 | 状态 | 注释 |
|---|---|---|
|
Web Authentication: An API for accessing Public Key Credentials Level 1
The definition of 'id' in that specification. |
推荐 |
Specified in the context of
PublicKeyCredential
. Overrides the getter defined in
Credential
.
|
|
Credential Management Level 1
The definition of 'id' in that specification. |
工作草案 | 初始定义。 |
No compatibility data found. Please contribute data for "api.PublicKeyCredential.id" (depth: 1) to the MDN 兼容性数据存储库 .
PublicKeyCredential