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 |
浏览器兼容性
加载中…