Skip to content

A Time-Based (RFC 6238) and HMAC-Based (RFC 4226) One-Time Password Algorithm Implementation in TypeScript. Used by Ordent project I maintain.

License

Notifications You must be signed in to change notification settings

deanrih/totp-ts

Repository files navigation

@deanrih/totp-ts

A Time-Based (RFC 6238) and HMAC-Based (RFC 4226) One-Time Password Algorithm Implementation in TypeScript.

Installation

# Bun
bun add @deanrih/totp-ts
# pnpm
pnpm add @deanrih/totp-ts
# npm
npm install @deanrih/totp-ts

Usage

import { generateTotp } from "@deanrih/totp-ts";

const secret = "super_S3cr37-k3y";
const password = generateTotp(secret);

console.log(`Your One-time Password: [${password}]`);
import { generateTotp } from "@deanrih/totp-ts";

const secret = "super_S3cr37-k3y";

console.log(`Your One-time Password: [${generateTotp(secret)}]`);
await Bun.sleep(30 * 1000); // Wait for 30 seconds to see the new code generated
console.log(`Your One-time Password: [${generateTotp(secret)}]`);

Checkout the example folder.

Credits/Reference

IETF RFC Datatracker

About

A Time-Based (RFC 6238) and HMAC-Based (RFC 4226) One-Time Password Algorithm Implementation in TypeScript. Used by Ordent project I maintain.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published