aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/authenticatorresponse
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/authenticatorresponse
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/authenticatorresponse')
-rw-r--r--files/zh-cn/web/api/authenticatorresponse/clientdatajson/index.html80
-rw-r--r--files/zh-cn/web/api/authenticatorresponse/index.html110
2 files changed, 190 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/authenticatorresponse/clientdatajson/index.html b/files/zh-cn/web/api/authenticatorresponse/clientdatajson/index.html
new file mode 100644
index 0000000000..f884c53486
--- /dev/null
+++ b/files/zh-cn/web/api/authenticatorresponse/clientdatajson/index.html
@@ -0,0 +1,80 @@
+---
+title: AuthenticatorResponse.clientDataJSON
+slug: Web/API/AuthenticatorResponse/clientDataJSON
+translation_of: Web/API/AuthenticatorResponse/clientDataJSON
+---
+<p>{{APIRef("Web Authentication API")}}{{securecontext_header}}</p>
+
+<p>The <strong><code>clientDataJSON</code></strong> property of the {{domxref("AuthenticatorResponse")}} interface stores 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()")}}. This property is only accessed on one of the child objects of <code>AuthenticatorResponse</code>, specifically {{domxref("AuthenticatorAttestationResponse")}} or {{domxref("AuthenticatorAssertionResponse")}}.</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox notranslate">var arrayBuffer = AuthenticatorAttestationResponse.clientDataJSON;
+var arrayBuffer = AuthenticatorAssertionResponse.clientDataJSON;
+</pre>
+
+<h3 id="Value">Value</h3>
+
+<p>An {{jsxref("ArrayBuffer")}}.</p>
+
+<h2 id="属性">属性</h2>
+
+<p>After the <code>clientDataJSON</code> object is converted from an <code>ArrayBuffer</code> to a JavaScript object, it will have the following properties:</p>
+
+<dl>
+ <dt><code>type</code></dt>
+ <dd>A string which is either <code>"webauthn.get"</code> when an existing credential is retrieved or <code>"webauthn.create"</code> when a new credential is created.</dd>
+ <dt><code>challenge</code></dt>
+ <dd>The <a href="/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding">base64url</a> encoded version of the cryptographic challenge sent from the relying party's server. The original value is passed via {{domxref("PublicKeyCredentialRequestOptions.challenge")}} or {{domxref("PublicKeyCredentialCreationOptions.challenge")}}.</dd>
+ <dt><code>origin</code></dt>
+ <dd>The fully qualified origin of the requester which has been given by the client/browser to the authenticator. We should expect the <a href="/en-US/docs/Web/API/PublicKeyCredentialRequestOptions/rpId">relying party's id</a> to be a suffix of this value.</dd>
+ <dt><code>tokenBindingId</code> {{optional_inline}}</dt>
+ <dd>
+ <p>An object describing the state of <a href="https://tools.ietf.org/html/rfc8471">the token binding protocol</a> for the communication with the relying party. It has two properties:</p>
+
+ <ul>
+ <li><code>status</code>: A string which is either <code>"supported"</code> which indicates the client support token binding but did not negotiate with the relying party or <code>"present"</code> when token binding was used already</li>
+ <li><code>id</code>: A {{domxref("DOMString")}} which is the <a href="/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding">base64url</a> encoding of the token binding ID which was used for the communication.</li>
+ </ul>
+
+ <p>Should this property be absent, it would indicate that the client does not support token binding.</p>
+ </dd>
+</dl>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: js notranslate">function arrayBufferToStr(buf) {
+ return String.fromCharCode.apply(null, new Uint8Array(buf));
+}
+
+// pk is a PublicKeyCredential that is the result of a create() or get() Promise
+var clientDataStr = arrayBufferToStr(pk.clientDataJSON);
+var clientDataObj = JSON.parse(clientDataStr);
+
+console.log(clientDataObj.type); // "webauthn.create" or "webauthn.get"
+console.log(clientDataObj.challenge); // base64 encoded String containing the original challenge
+console.log(clientDataObj.origin); // the window.origin
+</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('WebAuthn','#dom-authenticatorresponse-clientdatajson', 'clientDataJSON')}}</td>
+ <td>{{Spec2('WebAuthn')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+
+
+<p>{{Compat("api.AuthenticatorResponse.clientDataJSON")}}</p>
diff --git a/files/zh-cn/web/api/authenticatorresponse/index.html b/files/zh-cn/web/api/authenticatorresponse/index.html
new file mode 100644
index 0000000000..d682aa678b
--- /dev/null
+++ b/files/zh-cn/web/api/authenticatorresponse/index.html
@@ -0,0 +1,110 @@
+---
+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>