此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

AuthenticatorAttestationResponse:getPublicKeyAlgorithm() 方法

Baseline 2023
Newly available

Since ⁨October 2023⁩, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

安全上下文: 此特性仅在一些支持的浏览器安全上下文(HTTPS)中可用。

AuthenticatorAttestationResponse 接口的 getPublicKeyAlgorithm() 方法返回一个等于 COSE 算法标识符的数字,表示用于新凭据的加密算法。

这是一个用于轻松访问算法类型的便捷函数。此信息需要存储起来,以便在未来执行身份验证操作(即使用 navigator.credentials.get())。

语法

js
getPublicKeyAlgorithm()

参数

无。

返回值

一个数字。该数字等于 COSE 算法标识符,表示用于新凭据的加密算法。

示例

参见创建公钥凭据以获取详细示例。

规范

Specification
Web Authentication: An API for accessing Public Key Credentials - Level 3
# dom-authenticatorattestationresponse-getpublickeyalgorithm

浏览器兼容性