# yeojz/otplib

One Time Password (OTP) / 2FA for Node.js and Browser - Supports HOTP, TOTP and Google Authenticator

Repository: https://github.com/yeojz/otplib
Canonical: https://ross.abutalabs.com/products/otplib
Homepage: https://otplib.yeojz.dev
Language: TypeScript
License: MIT
License Family: permissive
Topics: hotp, hmac, otp, authenticator, 2fa, one-time-passwords, two-factor-authentication, two-factor, google-authenticator, nodejs, browser, cli
Last push: 2026-08-23T16:30:18+00:00

## Health v2 (maintenance only)
Score: 99/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 99, release rhythm 98, longevity 100
- inputs: {"age_days": 4525, "days_push": 10, "days_rel": 12, "gap_med": 10, "n_releases_24m": 10}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 2289, forks 146 (observed 2026-08-28T04:06:34.840949+00:00)

## What it is
otplib is a TypeScript-first library for generating and verifying one-time passwords (HOTP and TOTP) for two-factor authentication, compatible with Google Authenticator and similar apps. It supports multiple runtimes (Node.js, Bun, Deno, browsers) through a pluggable architecture for crypto and Base32 implementations.

## Use cases
- add TOTP two-factor authentication to a Node.js web app
- generate and verify HOTP tokens for hardware tokens
- generate otpauth:// URIs and QR codes for authenticator apps
- implement 2FA login compatible with Google Authenticator and Authy
- generate one-time passwords in the browser or edge runtime
- verify TOTP tokens server-side with counter resync windows
- build a custom OTP flow with pluggable crypto providers

## When to choose
- you need RFC-compliant HOTP/TOTP generation and verification in JavaScript or TypeScript
- you need one library that works across Node.js, Bun, Deno, and browsers
- you want audited cryptographic defaults (@noble/hashes, @scure/base) with a plugin system to swap implementations
- you need Google Authenticator-compatible otpauth URIs and QR code setup flows
- you want a TypeScript-first API with full type definitions and async-first design

## When to avoid
- you need SMS or email-based OTP delivery rather than authenticator-app tokens
- you need a full identity/auth solution with sessions, users, and password management rather than just OTP primitives
- you are on a non-JavaScript stack (Python, Go, etc.)
- you depend on otplib v12's separate authenticator package or legacy crypto adapters, since v13 is a breaking rewrite

## Facets
- artifact type: library
- maturity: active
- function: auth, cryptography, security, sdk
- domain: security, web-development, developer-tools, backend, frontend
- platform: browser, bun, cross-platform
- tags: otp, totp, hotp, two-factor-authentication, 2fa, mfa, google-authenticator, authenticator-apps, rfc-4226, rfc-6238, base32, hmac, qr-code-uri, plugin-architecture, web-crypto, nodejs, deno, typescript

## Member repositories
- yeojz/otplib (main) score 99

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:06:34.840949+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T02:40:49.917414+00:00, confidence not recorded.
  - readme: https://github.com/yeojz/otplib (fetched 2026-08-28T04:06:34.840949+00:00, sha 5c2178c3181c)
  - homepage: https://otplib.yeojz.dev (fetched 2026-08-29T10:21:22.720137+00:00, sha a01487850b0c)
  - site_page: https://otplib.yeojz.dev/guide/getting-started.html (fetched 2026-08-29T10:21:22.729644+00:00, sha e7199165cffd)
  - registry_npm: https://registry.npmjs.org/otplib (fetched 2026-08-29T10:21:22.731968+00:00, sha 35098f30a74b)
- Data as of 2026-08-30T08:39:29.467469+00:00.
