PublicKeyCredential.rawId

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) でのみ利用できます。

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

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

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

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

js
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

ブラウザーの互換性

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
rawId

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.