Skip to content

Instantly share code, notes, and snippets.

@yackermann
Created January 1, 2022 13:56
Show Gist options
  • Save yackermann/a4713a75c544b3d0b5f33f5cc2db21be to your computer and use it in GitHub Desktop.
Save yackermann/a4713a75c544b3d0b5f33f5cc2db21be to your computer and use it in GitHub Desktop.
Check if WebAuthn API available, and if platform authenticator is supported
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