简体   繁体   中英

How to check browser is public-key credentials supported?

I am implementing webauthn using PHP, now I'm facing problem with how to detect browser is public-key credentials supported or not. If browser is supported public-key credentials then I have to start fingerprint registration procedure.

So is there any way we can detect browser public-key credentials .

 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

I found one Google developer article and this JavaScript code work for me.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM