Created
January 1, 2022 13:56
-
-
Save yackermann/a4713a75c544b3d0b5f33f5cc2db21be to your computer and use it in GitHub Desktop.
Check if WebAuthn API available, and if platform authenticator is supported
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isWebAuthnSupported = () => { | |
return !!window.PublicKeyCredential | |
} | |
const isPlatformAuthenticatorSupported = () => { | |
if (!isWebAuthnSupported()) { | |
return Promise.reject(new Error("WebAuthn API is not available")) | |
} | |
if (!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable) { | |
return Promise.resolve(false) | |
} else { | |
return PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment