AuthenticatorResponse
AuthenticatorResponse 介面屬於 Web Authentication API,它是為金鑰對提供加密信任根的介面的基礎介面。子介面包含來自瀏覽器(例如挑戰來源)的資訊,並且都可能由 PublicKeyCredential.response 返回。
基於 AuthenticatorResponse 的介面
以下是基於 AuthenticatorResponse 介面的介面列表。
例項屬性
AuthenticatorResponse.clientDataJSON-
一個
ArrayBuffer中的 JSON 字串,表示傳遞給CredentialsContainer.create()或CredentialsContainer.get()的客戶端資料。
例項方法
無。
示例
獲取 AuthenticatorAssertionResponse
js
const options = {
challenge: new Uint8Array([
/* bytes sent from the server */
]),
};
navigator.credentials
.get({ publicKey: options })
.then((credentialInfoAssertion) => {
const assertionResponse = credentialInfoAssertion.response;
// send assertion response back to the server
// to proceed with the control of the credential
})
.catch((err) => console.error(err));
獲取 AuthenticatorAttestationResponse
js
const publicKey = {
challenge: new Uint8Array([
21, 31, 105 /* 29 more random bytes generated by the server */,
]),
rp: {
name: "Example CORP",
id: "login.example.com",
},
user: {
id: new Uint8Array(16),
name: "msanchez@example.com",
displayName: "Maria Sanchez",
},
pubKeyCredParams: [
{
type: "public-key",
alg: -7,
},
],
};
navigator.credentials
.create({ publicKey })
.then((newCredentialInfo) => {
const attestationResponse = newCredentialInfo.response;
})
.catch((err) => console.error(err));
規範
| 規範 |
|---|
| Web Authentication:訪問公鑰憑證的 API - 第 3 級 # authenticatorresponse |
瀏覽器相容性
載入中…