webauthn
Register and authenticate passkeys via the Credential Management / WebAuthn
API (navigator.credentials).
Import: @rtorcato/browser-common/webauthn
๐ MDN: Web Authentication API ยท ๐ caniuse: webauthn
createCredential/getCredential need a secure context and throw where Credential Management is unsupported โ guard with isWebAuthnAvailable().
Exampleโ
import {
isWebAuthnAvailable,
createCredential,
getCredential,
} from '@rtorcato/browser-common/webauthn'
if (isWebAuthnAvailable()) {
const credential = await createCredential({ publicKey })
const assertion = await getCredential({ publicKey })
}
Exportsโ
isWebAuthnAvailable()โ feature checkcreateCredential(options?)โ registers a new credential vianavigator.credentials.creategetCredential(options?)โ retrieves an existing credential vianavigator.credentials.get
See the API reference for full signatures.