Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@oslojs/otp

oslo-project48.7kMIT1.1.0TypeScript support: included

One-time passwords with HOTP and TOTP

auth, otp, hotp, totp

readme

@oslojs/otp

Documentation: https://otp.oslojs.dev

A JavaScript library for generating and verifying OTPs by Oslo.

Supports HMAC-based one-time passwords (HOTP) and time-based one-time passwords (TOTP) as defined in RFC 4226 and RFC 6238.

  • Runtime-agnostic
  • No third-party dependencies
  • Fully typed
import { generateTOTP, verifyTOTP } from "@oslojs/otp";

const totp = generateTOTP(key, 30, 6);
const valid = verifyTOTP(totp, key, 30, 6);

Installation

npm i @oslojs/otp