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.
TBD
After the clientDataJSON is converted from an ArrayBuffer to a JavaScript object, it will have the following properties:
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
Specification | Status | Comment |
---|---|---|
Web Authentication: An API for accessing Public Key Credentials Level 1 | Candidate Recommendation | Initial definition. |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 65
|
18 | 60
|
? | ? | ? |
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