Time-based passwords
Generate fixed-width codes with a 30-second default period and verify a configurable clock-drift window.
Generate and verify TOTP and HOTP in Node.js. Set up authenticators with secure random secrets and a small, focused API.
import genTOTP, { generateSecretKey, verifyTOTP } from 'gen-totp';
const secret = generateSecretKey();
const options = { encoding: 'base32' as const };
const token = genTOTP(secret, options);
const valid = verifyTOTP(secret, token, options);Start with authenticator setup to enroll a user, or open the API reference for every function and option.