npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bytekit/totp

v1.0.4

Published

A lightweight, promise-based library for generating TOTP and HOTP tokens in Node.js and browser environments. Fully supports standard OTP URI parsing and flexible configuration options.

Readme

@bytekit/totp

A lightweight, promise-based library for generating TOTP and HOTP tokens in Node.js and browser environments. Fully supports standard OTP URI parsing and flexible configuration options.

Features

  • 🔐 Generate Time-based One-Time Passwords (TOTP)
  • 🔢 Generate HMAC-based One-Time Passwords (HOTP)
  • 🌐 Parse and extract OTP configuration from standard otpauth:// URIs
  • 📦 Lightweight and dependency-free

Installation

npm install @bytekit/totp

or

yarn add @bytekit/totp

Usage

Generate a TOTP

import { totp } from "@bytekit/totp";

const token = await totp({
  key: "JBSWY3DPEHPK3PXP", // base32 or Uint8Array
  digits: 6,              // optional, default: 6
  algorithm: "SHA-1",     // optional, default: SHA-1
  period: 30,             // optional, default: 30
  timestamp: Date.now() / 1000,  // optional, default: now (seconds)
});

console.log(token.token); // => "123456"
console.log(token.expires);   // Timestamp when this token expires
console.log(token.next);      // Next valid token
console.log(token.previous);  // Previous valid token

Generate a HOTP

import { hotp } from "@bytekit/totp";

const key = new Uint8Array([/* your binary secret key */]);
const counter = new Uint8Array([/* your counter as binary */]);

const token = await hotp(key, counter, 6, "SHA-1");

console.log(token); // => "654321"

Parse an OTP URI

import { parseOtpUri } from "@bytekit/totp";

const otpAuth = parseOtpUri("otpauth://totp/Example:[email protected]?secret=JBSWY3DPEHPK3PXP&issuer=Example");

console.log(otpAuth);
/*
{
  type: 'totp',
  account: '[email protected]',
  issuer: 'Example',
  key: 'JBSWY3DPEHPK3PXP',
  digits: 6,
  algorithm: 'SHA-1',
  period: 30
}
*/

Types

ITotpOptions

| Option | Type | Default | Description | |------------|--------------------|----------|-----------------------------------------------------| | key | string or Uint8Array | — | Secret key in base32 or binary | | digits | number | 6 | Number of digits in the OTP | | algorithm| string | "SHA-1"| Hashing algorithm (SHA-1, SHA-256, etc.) | | period | number | 30 | Validity period in seconds | | timestamp| number | now | Unix timestamp to calculate OTP for |

ITotpToken

interface ITotpToken {
  token: string;
  expires: number;
  next: string;
  previous: string;
}

IOtpAuth

Returned by parseOtpUri.

interface IOtpAuth {
  type: string;
  account: string;
  issuer?: string;
  key: string | Uint8Array;
  digits?: number;
  algorithm?: string;
  period?: number;
  counter?: number;
}

License

MIT