Skip to content

Instantly share code, notes, and snippets.

@herrjemand
Created January 1, 2022 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save herrjemand/a4713a75c544b3d0b5f33f5cc2db21be to your computer and use it in GitHub Desktop.
Save herrjemand/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