PublicKeyCredential.getClientExtensionResults()

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

getClientExtensionResults() is a method of the PublicKeyCredential interface that returns an ArrayBuffer which contains a map between the extensions identifiers and their results after having being processed by the client.

During the creation or fetching of a PublicKeyCredential (respectively via navigator.credentials.create() and navigator.credentials.get()), it is possible to have "custom" processing by the client for different extensions which are respectively given by PublicKeyCredentialCreationOptions.extensions and PublicKeyCredentialRequestOptions.extensions.

Note: Extensions are optional and different browsers may recognize different extensions. All extensions are optional for the client to process them: if a browser does not know of a given extension, that will not cause any failure.

Note: This method may only be used in top-level contexts and will not be available in an <iframe> for example.

Syntax

mapArrayBuffer = publicKeyCredential.getClientExtensionResults()

Parameters

None.

Return value

An ArrayBuffer containing the result of the processing of the different extensions by the client. This object contains a map between the extensions' identifiers and their results from the processing.

Warning! As of March 2019, only appId (used during creation with PublicKeyCredentialRequestOptions.extensions) is supported by Chrome and Edge. Firefox does not seem to support any extension.

Examples

var publicKey = {
  // Here are the extensions (as "inputs")
  extensions: {
    "loc": true, // This extension has been defined to include location information in attestation
    "uvi": true  // user verification index: how the user was verified
  },
  challenge: new Uint8Array(16) /* from the server */,
  rp: {
    name: "Example CORP",
    id  : "login.example.com"
  },
  user: {
    id: new Uint8Array(16) /* from the server */,
    name: "jdoe@example.com",
    displayName: "John Doe"
  },
  pubKeyCredParams: [
    {
      type: "public-key",
      alg: -7
    }
  ]
};

navigator.credentials.create({ publicKey })
  .then(function (newCredentialInfo) {
    var myBuffer = newCredentialInfo.getClientExtensionResults();
    // myBuffer will contain the result of any of the processing of the "loc" and "uvi" extensions
  }).catch(function (err) {
     console.error(err);
  });

Specifications

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

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
getClientExtensionResultsChrome 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 18Firefox Full support 60
Notes
Full support 60
Notes
Notes Only supports USB U2F tokens.
IE No support NoOpera No support NoSafari No support NoWebView Android Full support 70Chrome Android Full support 70Firefox Android Full support 60
Notes
Full support 60
Notes
Notes Only supports USB U2F tokens.
Opera Android No support NoSafari iOS No support NoSamsung Internet Android ?

Legend

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

See also