--- title: AuthenticatorResponse slug: Web/API/AuthenticatorResponse translation_of: Web/API/AuthenticatorResponse --- <div>{{APIRef("Web Authentication API")}}{{securecontext_header}}</div> <p>The <code><strong>AuthenticatorResponse</strong></code> interface of the <a href="/en-US/docs/Web/API/Web_Authentication_API">Web Authentication API</a> is the base interface for interfaces that provide a cryptographic root of trust for a key pair. The child interfaces include information from the browser such as the challenge origin and either may be returned from {{domxref("PublicKeyCredential.response")}}.</p> <h2 id="Interfaces_based_on_AuthenticatorResponse">Interfaces based on AuthenticatorResponse</h2> <p>Below is a list of interfaces based on the AuthenticatorResponse interface.</p> <div class="index"> <ul> <li>{{domxref("AuthenticatorAssertionResponse")}}</li> <li>{{domxref("AuthenticatorAttestationResponse")}}</li> </ul> </div> <h2 id="Properties">Properties</h2> <dl> <dt>{{domxref("AuthenticatorResponse.clientDataJSON")}}</dt> <dd>A <a href="/en-US/docs/Learn/JavaScript/Objects/JSON">JSON</a> string in an {{domxref("ArrayBuffer")}}, representing the client data that was passed to {{domxref("CredentialsContainer.create()")}} or {{domxref("CredentialsContainer.get()")}}.</dd> </dl> <h2 id="方法">方法</h2> <p>无</p> <h2 id="示例">示例</h2> <h3 id="Getting_an_AuthenticatorAssertionResponse">Getting an AuthenticatorAssertionResponse</h3> <pre class="brush: js notranslate">var options = { challenge: new Uint8Array([/* bytes sent from the server */]) }; navigator.credentials.get({ "publicKey": options }) .then(function (credentialInfoAssertion) { var assertionResponse = credentialInfoAssertion.response; // send assertion response back to the server // to proceed with the control of the credential }).catch(function (err) { console.error(err); }); </pre> <h3 id="Getting_an_AuthenticatorAttestationResponse">Getting an AuthenticatorAttestationResponse</h3> <pre class="brush: js notranslate">var publicKey = { challenge: /* from the server */, rp: { name: "Example CORP", id : "login.example.com" }, user: { id: new Uint8Array(16), name: "jdoe@example.com", displayName: "John Doe" }, pubKeyCredParams: [ { type: "public-key", alg: -7 } ] }; navigator.credentials.create({ publicKey }) .then(function (newCredentialInfo) { var attestationResponse = newCredentialInfo.response; }).catch(function (err) { console.error(err); });</pre> <h2 id="规范">规范</h2> <table class="standard-table"> <thead> <tr> <th scope="col">Specification</th> <th scope="col">Status</th> <th scope="col">Comment</th> </tr> </thead> <tbody> <tr> <td>{{SpecName('WebAuthn','#authenticatorresponse', 'AuthenticatorResponse interface')}}</td> <td>{{Spec2('WebAuthn')}}</td> <td>Initial definition.</td> </tr> </tbody> </table> <h2 id="浏览器兼容性">浏览器兼容性</h2> <p>{{Compat("api.AuthenticatorResponse")}}</p> <h2 id="参见">参见</h2> <ul> <li>{{domxref("AuthenticatorAttestationResponse")}}</li> <li>{{domxref("AuthenticatorAssertionResponse")}}</li> <li>{{domxref("PublicKeyCredential.response")}}</li> </ul>