Skip to content
/ otp Public

Collection of one-time password algorithms. hotp, totp, steamTotp

License

Notifications You must be signed in to change notification settings

MAKS11060/otp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

otp • Collection of one-time password algorithms

JSR CI

Supported Algorithms

Usage

import {otpauth, totp, toptValidate} from "@maks11060/otp"

const secret = crypto.getRandomValues(new Uint8Array(20))

// Generate totp code
const code = await totp({secret}) // 123456

// Validate totp with time window
await toptValidate({secret, code}) // true

// Create otpauth uri
otpauth({secret, issuer: 'App name', label: '@user'}).toString()
// otpauth://totp/lable?secret=00&algorithm=SHA1&issuer=App+name

Use Readable

import {readableTotp} from '@maks11060/otp/readable'

const secret = crypto.getRandomValues(new Uint8Array(20))
for await (const otp of readableTotp({secret})) {
  console.log(otp)
}

Supported apps

Apps Algs Period Digits
Google Authenticator SHA1 30 6
Microsoft Authenticator SHA1 30 6