PublicKeyCredential: authenticatorAttachment 属性
PublicKeyCredential 接口的只读属性 authenticatorAttachment 是一个字符串,用于指示在关联的 navigator.credentials.create() 或 navigator.credentials.get() 调用期间使用的认证器的通用类别。
值
一个字符串,其值将是以下值之一:
"platform"-
认证器是 WebAuthn 运行的设备的一部分(称为平台认证器),因此 WebAuthn 将使用该平台可用的传输与其通信,例如特定于平台的 API。绑定到平台认证器的公钥凭证称为平台凭证。
"cross-platform"-
认证器不是 WebAuthn 运行的设备的一部分(称为漫游认证器,因为它可以在不同设备之间漫游),因此 WebAuthn 将使用跨平台传输协议(如蓝牙或 NFC)与其通信。绑定到漫游认证器的公钥凭证称为漫游凭证。
示例
js
const options = {
challenge: new Uint8Array(26) /* from the server */,
rp: {
name: "Example CORP",
id: "login.example.com",
},
user: {
id: new Uint8Array(26) /* To be changed for each user */,
name: "canand@example.com",
displayName: "Carina Anand",
},
pubKeyCredParams: [
{
type: "public-key",
alg: -7,
},
],
};
navigator.credentials
.create({ publicKey: options })
.then((pubKeyCredential) => {
const attachment = pubKeyCredential.authenticatorAttachment;
// Do something with authenticatorAttachment
})
.catch((err) => {
// Deal with any error
});
规范
| 规范 |
|---|
| Web Authentication:访问公钥凭证的 API - 第 3 级 # dom-publickeycredential-authenticatorattachment |
浏览器兼容性
加载中…