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 compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support651 2 ?601 ? ? ?
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support ? ? ? ? ? ? ?

1. Only support USB U2F tokens

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

Document Tags and Contributors

 Contributors to this page: ExE-Boss, apowers313
 Last updated by: ExE-Boss,