W3cubDocs

/DOM

AuthenticatorResponse.clientDataJSON

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The clientDataJSON object is an ArrayBuffer containing a JSON String of the various browser data that was used for the WebAuthn create() or get() call. It is included in both an AuthenticatorAttestationResponse and an AuthenticatorAssertionResponse within a PublicKeyCredential. The reason for storing the data as a ArrayBuffer rather than a String or an actual JavaScript object is that the object is effectively signed over by the authenticator, and if the order of the properties of the JavaScript object were not preserved then the signature verification would fail.

Syntax

TBD

Properties

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

clientDataJSON.type
TBD
clientDataJSON.challenge
TBD
clientDataJSON.origin
TBD
clientDataJSON.tokenBindingId Optional
TBD
clientDataJSON.clientExtensions Optional
TBD
clientDataJSON.authenticatorExtensions Optional
TBD

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 1 Candidate Recommendation Initial definition.

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support 65
Disabled
65
Disabled
Only support USB U2F tokens
Disabled From version 65: this feature is behind the Web Authentication API preference (needs to be set to true). To change preferences in Chrome, visit chrome://flags.
18 60
60
Only support USB U2F tokens
? ? ?
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support ? ? ? ? ? ? ?

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/AuthenticatorResponse/clientDataJSON