PublicKeyCredential.id

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

idPublicKeyCredential インターフェイスの読み取り専用プロパティで、 Credential から継承した文字列であり、現在の PublicKeyCredential インスタンスの識別子を表します。

このプロパティは PublicKeyCredential.rawIdbase64url エンコード版です。

メモ: このプロパティは最上位のコンテキストでのみ使用することができ、例えば <iframe> では使用することができません。

PublicKeyCredential.rawIdbase64url エンコード 版である文字列です。

const publicKey = {
  challenge: new Uint8Array(26) /* this actually is given 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 })
  .then((newCredentialInfo) => {
    const id = newCredentialInfo.id;
    // Do something with the id

    // send attestation response and client extensions
    // to the server to proceed with the registration
    // of the credential
  }).catch((err) => {
     console.error(err);
  });

仕様書

No specification found

No specification data found for api.PublicKeyCredential.id.
Check for problems with this page or contribute a missing spec_url to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.

ブラウザーの互換性

BCD tables only load in the browser

関連情報