Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maks11060/otp
Collection of one-time password algorithms. hotp, totp, steamTotp
https://github.com/maks11060/otp
hotp otp otpauth totp typescript
Last synced: 7 days ago
JSON representation
Collection of one-time password algorithms. hotp, totp, steamTotp
- Host: GitHub
- URL: https://github.com/maks11060/otp
- Owner: MAKS11060
- License: mit
- Created: 2024-04-12T18:05:34.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-07-25T12:57:16.000Z (6 months ago)
- Last Synced: 2024-11-14T06:19:45.843Z (2 months ago)
- Topics: hotp, otp, otpauth, totp, typescript
- Language: TypeScript
- Homepage: https://jsr.io/@maks11060/otp
- Size: 35.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# otp • Collection of one-time password algorithms
[![JSR][JSR badge]][JSR]
[![CI][CI badge]][CI][JSR]: https://jsr.io/@maks11060/otp
[JSR badge]: https://jsr.io/badges/@maks11060/otp
[CI]: https://github.com/MAKS11060/otp/actions/workflows/ci.yml
[CI badge]: https://github.com/maks11060/otp/actions/workflows/ci.yml/badge.svg## Supported Algorithms
- [HOTP](https://datatracker.ietf.org/doc/html/rfc4226)
- [TOTP](https://datatracker.ietf.org/doc/html/rfc6238)
- SteamTOTP## Usage
```ts
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
```ts
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` |