Skip to main content

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 check
  • createCredential(options?) โ€” registers a new credential via navigator.credentials.create
  • getCredential(options?) โ€” retrieves an existing credential via navigator.credentials.get

See the API reference for full signatures.