如何检查浏览器是否支持 public-key 凭据?

How to check browser is public-key credentials supported?

我正在使用 PHP 实施 webauthn,现在我面临如何检测浏览器是 public-key 的问题凭据 支持与否。如果浏览器支持 public-key credentials 那么我必须开始指纹注册程序。

那么我们有什么方法可以检测浏览器 public-密钥凭据.

 if (typeof(PublicKeyCredential) != "undefined") {
   // Code here
 }

The PublicKeyCredential interface provides information about a public key / private key pair. It inherits from Credential, and was created by the Web Authentication API extension to the Credential Management API. Other interfaces that inherit from Credential are PasswordCredential and FederatedCredential.

https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredential

我找到了一篇 Google 开发人员文章,这个 JavaScript 代码对我有用。

if (window.PublicKeyCredential) {
   // code here
}else{
   alert("public-key credentials not supported");
}

https://developers.google.com/web/updates/2018/03/webauthn-credential-management