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

onethenticator-core

v1.1.1

Published

Environment-agnostic core engine for TOTP, Google Authenticator migration parsing, encoding utilities, and Unicode steganography.

Readme

onethenticator-core

A low-level, high-performance, and environment-agnostic core engine for TOTP (Time-based One-Time Password) and Google Authenticator migration.

onethenticator-core is built to be the reliable, cryptographic foundation for any 2FA application. Whether you're building a browser extension, a mobile app, or a server-side service, this library provides the raw power you need without the bloat.

🌟 Why onethenticator-core?

Most 2FA libraries are either tied to a specific environment (like Node.js) or come with heavy dependencies. onethenticator-core is different:

  • Works Everywhere: From Chrome Extensions to Cloudflare Workers.
  • Zero Dependencies: Keeps your bundle small and your security surface area minimal.
  • Pure & Predictable: No global state, no hidden side-effects, just pure logic.
  • Ready for Everyone: Simple APIs that hide the complexity of RFC 6238 and Protobuf parsing.

🚀 Design Philosophy

This library is a pure engine. It is built with a strict "no side-effects" policy:

  • Stateless: No global state or internal caching.
  • Deterministic: Given the same input, you always get the same output.
  • Environment-Agnostic: Works in Browsers, Node.js, Cloudflare Workers, and Deno (via Web Crypto API).
  • Minimal: Zero external dependencies.

🛠 Features

  • TOTP (RFC 6238): Full implementation with support for custom digits (6 or 8) and time steps.
  • Google Authenticator Migration: Parse binary migration payloads (protobuf) from QR codes.
  • Otpauth URL Parsing: Robust parsing of standard otpauth:// URIs.
  • Encoding Utilities: High-performance Base32 and UTF-8 encoding/decoding.
  • Invisible Steganography: Hide arbitrary UTF-8 strings inside invisible Unicode variation selectors with XOR obfuscation and signature verification.
  • TypeScript Optimized: Strict type safety and clear interfaces.

📦 Installation

npm install onethenticator-core

💻 Usage

Generating TOTP Codes

Generate a 6-digit code from a Base32 secret.

import { generateTOTP } from 'onethenticator-core';

// Simple usage (defaults to 6 digits, 30s step)
const code = await generateTOTP('JBSWY3DPEHPK3PXP');
console.log(`Current Code: ${code}`);

// Custom options for advanced use-cases
const code8 = await generateTOTP('JBSWY3DPEHPK3PXP', {
  digits: 8,
  step: 60,
  timestamp: Date.now()
});

Parsing Migration Payloads

Easily import accounts from Google Authenticator "Transfer Accounts" QR codes.

import { parseMigrationToOtpAccounts } from 'onethenticator-core';

// Binary data captured from a migration QR code
const binaryPayload = new Uint8Array([...]);
const accounts = parseMigrationToOtpAccounts(binaryPayload);

accounts.forEach(acc => {
  console.log(`Imported: ${acc.issuer} (${acc.name})`);
});

Parsing Otpauth URIs

Parse standard OTP URLs into manageable objects.

import { parseOtpAuthURL } from 'onethenticator-core';

const uri = 'otpauth://totp/GitHub:user?secret=JBSWY3DPEHPK3PXP&issuer=GitHub';
const account = parseOtpAuthURL(uri);

console.log(account.issuer); // "GitHub"
console.log(account.secret); // "JBSWY3DPEHPK3PXP"

Encoding Utilities

Fast, memory-efficient encoding for cryptographic operations.

import { encodeBase32, decodeBase32 } from 'onethenticator-core';

const data = new TextEncoder().encode('Hello World');
const base32 = encodeBase32(data); // "JBSWY3DPEBLW64TMMQ======"

const decoded = decodeBase32(base32);

Invisible Steganography

Hide a UTF-8 string inside invisible Unicode characters that can be embedded in any text.

import { Invisible } from 'onethenticator-core';

const invisible = new Invisible('my-secret-seed');

// Encode — returns a string of invisible Unicode characters
const hidden = invisible.encode('Hello World');
console.log(hidden.length); // looks empty when pasted into plain text

// Embed inside visible text
const carrier = `Some visible text${hidden}with hidden data`;

// Decode — extract and verify the hidden string
const result = invisible.decode(hidden);
if ('ok' in result) {
  console.log(result.ok); // "Hello World"
} else {
  console.error(result.error); // 'invalid_signature' | 'invalid_invisible_character' | 'invalid_utf8'
}

🔒 Security Principles

  • No Trusted Environment: Does not assume a secure context (though it requires crypto.subtle).
  • No Persistence: Does not handle storage (localStorage, DB, etc.). Applications must manage secrets securely.
  • No Network: Does not make any external requests.
  • Minimal Protobuf: Implements a custom, minimal Protobuf reader to avoid heavy dependencies and potential attack vectors.

⚖️ License

MIT