# @esthe/totp

> A TOTP / HOTP implementation

Latest version **1.1.0** (published 2024-02-17) · 0 weekly downloads

## Install

```sh
npm install @esthe/totp
pnpm add @esthe/totp
yarn add @esthe/totp
bun add @esthe/totp
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2024-02-17 |
| First published | 2023-03-01 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 6.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | esthe |

## Links

- npm: https://www.npmjs.com/package/@esthe/totp
- npm.io page: https://npm.io/package/@esthe/totp

## Recent versions

- 1.1.0 (latest) — 2024-02-17
- 1.0.0 — 2023-03-01

## README

# @esthe/totp

A TOTP (Time-based one-time password) / HOTP (HMAC-based one-time password) implementation in TypeScript.

ESM-only, no dependencies, browser-first. (but also works in Node.js)

```bash
pnpm install @esthe/totp
```

## Usage

```ts
import { generateSeed, generateTOTP, verifyTOTPLaxed } from "@esthe/totp"

// server, generate a seed/secret
const seed = generateSeed()

// client, generate the one-time password for the current time, using the seed
const totp = await generateTOTP(seed)

// server, verify the one-time password. Allows about 1 minute of drift.
const correct = await verifyTOTPLaxed(seed, totp)

if (!correct) res.status(401).send("Invalid one-time password.") // or whatever
```

---
_Source: https://npm.io/package/@esthe/totp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
