PublicKeyCredential.response
        
        
          
                Baseline
                
                  Widely available
                
                
              
        
        
        
          
                
              
                
              
                
              
        
        
      
      This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2021年9月.
安全なコンテキスト用: この機能は一部またはすべての対応しているブラウザーにおいて、安全なコンテキスト (HTTPS) でのみ利用できます。
response は PublicKeyCredential インターフェイスの読み取り専用プロパティで、このプロパティは AuthenticatorResponse オブジェクトであり、資格情報の作成/取得のために認証先からユーザーエージェントに送信されるものです。このレスポンスに含まれる情報は、要求が正当なものであるかどうかを確認するために、依存している側のサーバーで使用されます。
AuthenticatorResponse は以下のどちらかです。
- AuthenticatorAttestationResponse(- PublicKeyCredentialが- CredentialsContainer.create()で作成された場合)
- AuthenticatorAssertionResponse(- PublicKeyCredentialが- CredentialsContainer.get()から取得された場合)
資格情報の生成を検証するには、依存している側のサーバーは以下の両方を必要とします。
- このレスポンス
- 要求を検証するためのクライアントの拡張機能 (PublicKeyCredential.getClientExtensionResults()で指定されたもの)
メモ:
既存の資格情報の取得を検証する場合、 PublicKeyCredential オブジェクト全体とクライアント拡張機能が依存している側のサーバーに必要です。
メモ:
このプロパティは最上位のコンテキストでのみ使用することができます。例えば <iframe> では使用することができません。
値
作成または取得の要求を検証するために、依存する側のスクリプトが受信し、依存する側がのサーバーに送信されるべきデータを含む AuthenticatorResponse オブジェクトです。このオブジェクトには、クライアントからのデータ (AuthenticatorResponse/clientDataJSON) と認証器からのデータが含まれます。
例
const options = {
  challenge: new Uint8Array(16) /* from the server */,
  rp: {
    name: "Example CORP",
    id: "login.example.com",
  },
  user: {
    id: new Uint8Array(16) /* from the server */,
    name: "canand@example.com",
    displayName: "Carina Anand",
  },
  pubKeyCredParams: [
    {
      type: "public-key",
      alg: -7,
    },
  ],
};
navigator.credentials
  .create({ publicKey: options })
  .then((pubKeyCredential) => {
    const response = pubKeyCredential.response;
    const clientExtResults = pubKeyCredential.getClientExtensionResults();
    // Send response and client extensions to the server so that it can validate
    // and create credentials
  })
  .catch((err) => {
    // Deal with any error
  });
仕様書
| Specification | 
|---|
| Web Authentication: An API for accessing Public Key Credentials - Level 3> # dom-publickeycredential-response> | 
ブラウザーの互換性
Loading…