PublicKeyCredential.rawId

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

rawIdPublicKeyCredential インターフェイスの読み取り専用プロパティで、資格情報の識別子が入った ArrayBuffer オブジェクトです。

PublicKeyCredential.id プロパティはこの識別子が base64url エンコードされたものです。

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

ArrayBuffer で、資格情報の識別子が入っています。この識別子はグローバルに固有で、現在の PublicKeyCredential および関連する AuthenticatorAssertionResponse を指しています。

const options = {
  challenge: new Uint8Array(26) /* from the server */,
  rp: {
    name: "Example CORP",
    id  : "login.example.com"
  },
  user: {
    id: new Uint8Array(26), /* To be changed for each user */
    name: "canand@example.com",
    displayName: "Carina Anand",
  },
  pubKeyCredParams: [
    {
      type: "public-key",
      alg: -7
    }
  ]
};

navigator.credentials.create({  publicKey: options })
  .then((pubKeyCredential) => {
    const rawId = pubKeyCredential.rawId;
    // Do something with rawId
}).catch((err) => {
  // Deal with any error
});

仕様書

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

ブラウザーの互換性

BCD tables only load in the browser