Skip to main content
The BioKey class provides a simple interface for creating and authenticating biometric identities using the WebAuthn API with PRF extension support.

Constructor

const biokey = new BioKey(options)
options
object
Configuration options for the BioKey instance
options.rpId
string
Relying Party ID - defaults to location.hostname
options.rpName
string
Relying Party name - defaults to 'BioKey'

Methods

enroll()

Creates a new biometric identity by registering a WebAuthn credential with PRF extension support.
const identity = await biokey.enroll()
publicKey
string
Hex-encoded public key derived from PRF output or rawId
credentialId
string
Hex-encoded credential ID for future authentication
enrolledAt
number
Unix timestamp of enrollment
method
'prf' | 'rawid'
Derivation method used - 'prf' for hardware-backed PRF extension, 'rawid' for HKDF fallback

authenticate(identity)

Authenticates using a previously enrolled biometric identity.
const result = await biokey.authenticate(identity)
identity
object
required
The identity object returned from enroll()
identity.credentialId
string
required
Hex-encoded credential ID
identity.publicKey
string
required
Hex-encoded public key to verify against
identity.method
'prf' | 'rawid'
required
Derivation method used during enrollment
verified
boolean
Always true if authentication succeeds (throws on failure)
publicKey
string
Re-derived public key (matches enrolled publicKey if verified)
method
'prf' | 'rawid'
Derivation method used for this authentication

Example

import { BioKey } from 'biokey-core'

const biokey = new BioKey({
  rpId: 'example.com',
  rpName: 'Example App'
})

// Enroll new identity
const identity = await biokey.enroll()
localStorage.setItem('identity', JSON.stringify(identity))

// Later: authenticate
const stored = JSON.parse(localStorage.getItem('identity'))
const result = await biokey.authenticate(stored)
console.log('Authenticated:', result.verified)

Source Reference

See /packages/biokey-core/src/index.js:5

Build docs developers (and LLMs) love