X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=README.md;fp=README.md;h=98ceeb90026e61d1624ab1a02f95b1aaafff9abf;hb=cbb0261beae6aabbb5e1d6bb2e371a5246604588;hp=0000000000000000000000000000000000000000;hpb=b2ea475512479827a8899b72356f52010a3b4a9c;p=squeep-totp diff --git a/README.md b/README.md new file mode 100644 index 0000000..98ceeb9 --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# @squeep/totp + +Simple helpers for dealing with One-Time Passwords. + +## API + +```javascript +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, // otpauthg 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. +```