Setup
lib/kavach.ts
Trust a device
After the user completes 2FA, calltrust() to mark their device. Pass any stable identifier, a browser fingerprint, a cookie value you control, or a combination:
Trust after 2FA (server)
Verify a trusted device
On sign-in, check whether the device is already trusted before requiring 2FA:Check on sign-in (server)
Revoke a device
Users can revoke specific devices from an account settings page:Revoke one device (server)
Revoke all devices
Revoke all devices (server)
List trusted devices
List devices (server)
Configuration reference
string
required
Secret used to HMAC-sign device fingerprints. Rotate this to invalidate all trusted devices instantly.
number
default:"2592000 (30 days)"
How long a device stays trusted, in seconds.
number
default:"10"
Maximum number of trusted devices per user. Oldest is evicted when exceeded.