PublicKeyCredential.getClientExtensionResults()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2021.

安全なコンテキスト用: この機能は一部またはすべての対応しているブラウザーにおいて、安全なコンテキスト (HTTPS) でのみ利用できます。

getClientExtensionResults()PublicKeyCredential インターフェイスのメソッドであり、 ArrayBuffer の形で拡張機能の識別子と、クライアントが処理した後の結果の対応表を返します。

PublicKeyCredential の生成または読み出し中 (それぞれ navigator.credentials.create() および navigator.credentials.get() で実施) に、それぞれ PublicKeyCredentialCreationOptions.extensions および PublicKeyCredentialRequestOptions.extensions によって与えられる別々の拡張機能のために、クライアントが処理する「専用の」処理を持つことができます。

メモ: 拡張機能はオプションであり、ブラウザーによって認識する拡張機能は異なります。すべての拡張機能はクライアントが処理することはオプションです。ブラウザーが指定された拡張機能を知らない場合、失敗としてはいけません。

メモ: このプロパティは最上位のコンテキストでしか使えない可能性があり、例えば <iframe> の中では利用できません。

構文

mapArrayBuffer = publicKeyCredential.getClientExtensionResults()

引数

なし。

返値

ArrayBuffer の形で、クライアントが様々な拡張機能を処理した結果です。拡張子の識別子と、クライアントが処理した後の結果の対応表を返します。このオブジェクトには拡張機能の識別子と処理の結果の対応表が入っています。

警告: 2019 年 3 月時点で、 appId (PublicKeyCredentialRequestOptions.extensions の生成の間に使用される) のみ、 Chrome および Edge が対応しています。 Firefox はどの拡張機能にも対応していないようです。

js
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);
  });

仕様書

Specification
Web Authentication: An API for accessing Public Key Credentials - Level 3
# ref-for-dom-publickeycredential-getclientextensionresults

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
getClientExtensionResults() method

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
See implementation notes.
Has more compatibility info.

関連情報