@squeep/totp

1.1.4 • Public • Published

@squeep/totp

Simple helper classes for dealing with One-Time Passwords of varying flavor.

API

const { TOTP } = require('@squeep/totp');

const key = await TOTP.createKey(); // defaults create a hex-encoded sha1 key

const {
  secret, // key encoded as base32
  uri, // key and metadata encoded as an otpauth URI
  svg, // otpauth URI encoded as QR code
} = TOTP.createKeySVG({ accountname: 'test@example.com', issuer: 'Squeep', }, key, 'hex');

const totp = new TOTP({
  key,
  keyEncoding: 'hex',
});

const token = totp.generate(); // The current token for the key.

const isValid = totp.validate('123456');

Package Sidebar

Install

npm i @squeep/totp

Weekly Downloads

3

Version

1.1.4

License

ISC

Unpacked Size

138 kB

Total Files

11

Last publish

Collaborators

  • thylacine