3 Simple helper classes for dealing with One-Time Passwords of varying flavor.
8 const { TOTP } = require('@squeep/totp');
10 const key = await TOTP.createKey(); // defaults create a hex-encoded sha1 key
13 secret, // key encoded as base32
14 uri, // key and metadata encoded as an otpauth URI
15 svg, // otpauth URI encoded as QR code
16 } = TOTP.createKeySVG({ accountname: 'test@example.com', issuer: 'Squeep', }, key, 'hex');
18 const totp = new TOTP({
23 const token = totp.generate(); // The current token for the key.
25 const isValid = totp.validate('123456');