Web/API/AuthenticatorResponse/clientDataJSON

From Get docs

Secure contextThis feature is available only in secure contexts (HTTPS), in some or all supporting browsers.


The clientDataJSON property of the AuthenticatorResponse interface stores a [[../../../../Learn/JavaScript/Objects/JSON|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.

Syntax

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

Value

An ArrayBuffer.

Properties

After the 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
The 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 Optional

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.

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

Specifications

Specification Status Comment
Web Authentication: An API for accessing Public Key Credentials Level 1The definition of 'clientDataJSON' in that specification. Recommendation Initial definition.

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
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 Full support 67


Full support 67


Full support 65

Notes' Disabled'

Notes' Only supports USB U2F tokens. Disabled' From version 65: this feature is behind the Web Authentication API preference (needs to be set to Enabled). To change preferences in Chrome, visit chrome://flags.

Edge

Full support 18

Firefox Full support 60

Notes'

Full support 60

Notes'

Notes' Only supports USB U2F tokens.

IE

No support No

Opera

No support No

Safari

Full support 13

WebView Android

Full support 70

Chrome Android

Full support 70

Firefox Android Full support 60

Notes'

Full support 60

Notes'

Notes' Only supports USB U2F tokens.

Opera Android

No support No

Safari iOS

Full support 13.3

Samsung Internet Android

No support No

Legend

Full support  
Full support
No support  
No support
See implementation notes.'
See implementation notes.
User must explicitly enable this feature.'
User must explicitly enable this feature.