安全上下文
此特征只可用于 安全上下文 (HTTPS),在某些或所有 支持浏览器 .

clientDataJSON 特性为 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 .

句法

var arrayBuffer = AuthenticatorAttestationResponse.clientDataJSON;
var arrayBuffer = AuthenticatorAssertionResponse.clientDataJSON;
					

ArrayBuffer .

特性

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

type
A string which is either "webauthn.get" when an existing credential is retrieved or "webauthn.create" when a new credential is created.
challenge
base64url encoded version of the cryptographic challenge sent from the relying party's server. The original value is passed via PublicKeyCredentialRequestOptions.challenge or PublicKeyCredentialCreationOptions.challenge .
origin
The fully qualified origin of the requester 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.
tokenBindingId 可选

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 DOMString 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.

范例

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
var clientDataStr = arrayBufferToStr(pk.clientDataJSON);
var 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
					

规范

规范 状态 注释
Web Authentication: An API for accessing Public Key Credentials Level 1
The definition of 'clientDataJSON' 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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
clientDataJSON Chrome 67
67
65 Disabled
Only supports USB U2F tokens.
Disabled ). To change preferences in Chrome, visit
Edge 18 Firefox 60
60
Only supports USB U2F tokens.
IE No Opera No Safari 13 WebView Android 70 Chrome Android 70 Firefox Android 60
60
Only supports USB U2F tokens.
Opera Android No Safari iOS 13.3 Samsung Internet Android No

图例

完整支持

完整支持

不支持

不支持

见实现注意事项。

用户必须明确启用此特征。

用户必须明确启用此特征。

元数据

  • 最后修改:
  1. Web 身份验证 API
  2. AuthenticatorResponse
  3. 特性
    1. clientDataJSON
  4. Related pages for Web Authentication API
    1. AuthenticatorAssertionResponse
    2. AuthenticatorAttestationResponse
    3. CredentialsContainer
    4. PublicKeyCredential

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1