AuthenticatorResponse
AuthenticatorResponse
是Web 身份验证 API的接口,它是提供密钥对加密信任根的接口的基础接口。子接口包含来自浏览器的信息,例如挑战来源,并且可能从PublicKeyCredential.response
返回。
基于 AuthenticatorResponse 的接口
以下是基于 AuthenticatorResponse 接口的接口列表。
实例属性
实例方法
无。
示例
获取 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: "[email protected]",
displayName: "John Doe",
},
pubKeyCredParams: [
{
type: "public-key",
alg: -7,
},
],
};
navigator.credentials
.create({ publicKey })
.then((newCredentialInfo) => {
const attestationResponse = newCredentialInfo.response;
})
.catch((err) => console.error(err));
规范
规范 |
---|
Web 身份验证:访问公钥凭据的 API - 3 级 # authenticatorresponse |
浏览器兼容性
BCD 表仅在启用 JavaScript 的浏览器中加载。