@liam-public/browser-webauthn
v0.1.0
Published
Passwordless passkey (WebAuthn) ceremony client for the browser — register + authenticate against a node-webauthn backend.
Readme
@liam-public/browser-webauthn
Passwordless passkey (WebAuthn) client for the browser — the front half of the base CMS's
passwordless auth. Pairs with @liam-public/node-webauthn on the server.
Exports
isPasskeySupported()— feature-detect WebAuthn before offering passkeys.registerPasskey(flow, context?)— fetch registration options, run thecreate()ceremony, POST the attestation to be verified.authenticateWithPasskey(flow, context?)— fetch options, run theget()ceremony, POST the assertion. No password is ever sent.
flow is { optionsUrl, verifyUrl, fetch? }.
Usage
import { isPasskeySupported, registerPasskey, authenticateWithPasskey } from '@liam-public/browser-webauthn'
if (isPasskeySupported()) {
// Sign up / add a passkey (authenticated session for registration):
await registerPasskey({ optionsUrl: '/auth/passkey/register/options', verifyUrl: '/auth/passkey/register/verify' }, { email })
// Passwordless sign-in:
const { token } = await authenticateWithPasskey({ optionsUrl: '/auth/passkey/login/options', verifyUrl: '/auth/passkey/login/verify' })
}Built on @simplewebauthn/browser.
