enroll() function creates a new WebAuthn credential with PRF extension support and derives a deterministic identity key.
Function Signature
Parameters
Relying Party ID - typically your domain (e.g.,
'example.com')Relying Party name displayed to the user during enrollment
Return Value
Returns a Promise that resolves to an identity object:Hex-encoded 32-byte public key derived from PRF output or rawId-HKDF
Hex-encoded credential ID (from
credential.rawId)Unix timestamp (milliseconds) when enrollment occurred
'prf': WebAuthn PRF extension was used (hardware-backed secret)'rawid': Fallback HKDF derivation from credential rawId
How It Works
- PRF Extension: Attempts to use the WebAuthn PRF extension with a fixed salt (
PRF_SALT) - Hardware-Backed Secret: If PRF is supported, the authenticator returns a deterministic 32-byte secret
- Fallback: If PRF is unavailable, derives a key from the credential’s rawId using HKDF-SHA256
- No Server Required: All cryptographic operations happen client-side
Example
WebAuthn Configuration
The function configures WebAuthn credentials with:- Challenge: 32 random bytes
- User ID: 16 random bytes
- Algorithms: ES256 (-7), EdDSA (-8), RS256 (-257)
- Authenticator: Platform authenticator required
- User Verification: Required
- Resident Key: Preferred (for passkey support)
- Timeout: 60 seconds
Source Reference
See/packages/biokey-core/src/enroll.js:9