@hazae41/pendule
v1.0.0
Published
Mnemonic derivation (BIP-39, Monero) for TypeScript
Readme
Pendule
Time-based one-time passcodes (TOTP) for the web
npm install @hazae41/penduleFeatures
Current features
- 100% TypeScript and ESM
- Minimal dependencies
- SHA-1 TOTP
Usage
SHA-1 TOTP
Parse generator secret
const totp = Sha1Totp.parseOrThrow("JBSWY3DPEHPK3PXP")Parse generator url
const totp = Sha1Totp.parseOrThrow("otpauth://totp/?secret=AAAABBBB22223333YYYYZZZZ66667777")Codes
Generate the current code
const code = await totp.generate()Automatically update code (with a margin of error of 1 second)
setInterval(() => {
code = await totp.generate()
}, 1000)Log codes every time there is a new one
const period = totp.period * 1000
const elapsed = Date.now() % period
const remaining = period - elapsed
setTimeout(() => {
console.log(await totp.generate())
setInterval(() => {
console.log(await totp.generate())
}, period)
// New codes will now be displayed
}, remaining)