大网数据广告活动
Web 标准与前端开发

AuthenticatorResponse: clientDataJSON property

· 52CE 我爱测

The **`clientDataJSON`** property of the AuthenticatorResponse interface stores a JSON string in an ArrayBuffer, representing the client data that was passed to CredentialsContainer.create() or CredentialsContainer.get(). This property is only accessed on one of the child objects

Web Authentication API

The clientDataJSON property of the AuthenticatorResponse interface stores a JSON string in an ArrayBuffer, representing the client data that was passed to CredentialsContainer.create() or CredentialsContainer.get(). This property is only accessed on one of the child objects of AuthenticatorResponse, specifically AuthenticatorAttestationResponse or AuthenticatorAssertionResponse.

Value

An ArrayBuffer.

Instance properties

After the clientDataJSON object is converted from an ArrayBuffer to a JavaScript object, it will have the following properties:

  • challenge

    • : The base64url encoded version of the cryptographic challenge sent from the relying party's server. The original value are passed as the challenge option in CredentialsContainer.get() or CredentialsContainer.create().
  • crossOrigin

    • : A boolean. If set to true, it means that the calling context is an iframe that is not same origin with its ancestor frames.
  • origin

    • : The fully qualified origin of the relying party which has been given by the client/browser to the authenticator. We should expect the relying party's id to be a suffix of this value.
  • tokenBinding

    • : An object describing the state of the token binding protocol for the communication with the relying party. It has two properties:

      • status: A string which is either "supported" which indicates the client support token binding but did not negotiate with the relying party or "present" when token binding was used already
      • id: A string which is the base64url encoding of the token binding ID which was used for the communication.

      Should this property be absent, it would indicate that the client does not support token binding.

      [!NOTE] tokenBinding is deprecated as of Level 3 of the spec, but the field is reserved so that it won't be reused for a different purpose.

  • topOrigin

    • : Contains the fully qualified top-level origin of the relying party. It is set only if it crossOrigin is true.
  • type

    • : A string which is either "webauthn.get" when an existing credential is retrieved or "webauthn.create" when a new credential is created.

Examples

function arrayBufferToStr(buf) {
  return String.fromCharCode.apply(null, new Uint8Array(buf));
}

// pk is a PublicKeyCredential that is the result of a create() or get() Promise
const clientDataStr = arrayBufferToStr(pk.response.clientDataJSON);
const clientDataObj = JSON.parse(clientDataStr);

console.log(clientDataObj.type); // "webauthn.create" or "webauthn.get"
console.log(clientDataObj.challenge); // base64 encoded String containing the original challenge
console.log(clientDataObj.origin); // the window.origin

Specifications

Browser compatibility

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。