安全上下文
此特征只可用于 安全上下文 (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.
工作草案 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

No compatibility data found. Please contribute data for "api.PublicKeyCredential.id" (depth: 1) to the MDN 兼容性数据存储库 .

另请参阅

元数据

  • 最后修改: