因此尝试集成WebAuthN。如果平台无关(FIDO2 安全密钥)检查更容易(一般是否支持 webauthN - 我们继续,也许用户稍后插入 USB 密钥),我无法找到一种方法来检查平台相关(Windows Hello、指纹扫描仪)等)验证器。isUserVerifyingPlatformAuthenticatorAvailable()看起来就是我所需要的,但是
window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()
.then(() => true)
.catch(() => false)
.then((x) => console.log(x))
Run Code Online (Sandbox Code Playgroud)
对于我的 MacBook(Chrome、Firefox、Safari),始终返回 true。此外 MacBook 没有任何身份验证器并尝试继续使用参数
"authenticatorSelection": {
"authenticatorAttachment" : "platform",
"requireResidentKey":false,
"userVerification":"preferred"
}
Run Code Online (Sandbox Code Playgroud)
最终显示“此设备不支持此网站请求的安全密钥类型”。消息(我的 MacBook 肯定没有指纹扫描仪,所以这是合理的!)
看到类似的问题,但仅提供使用此的建议isUserVerifyingPlatformAuthenticatorAvailable()。
isUserVerifyingPlatformAuthenticatorAvailable()返回布尔值的 Promise,因此您的代码应该看起来更像:
window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()
.then(isAvailable => isAvailable)
.catch(err => false)
.then(result => console.log("Platform authenticator is available: " + result));
Run Code Online (Sandbox Code Playgroud)
MDN 文章位于: https: //developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredential/isUserVerifyingPlatformAuthenticatorAvailable
| 归档时间: |
|
| 查看次数: |
686 次 |
| 最近记录: |