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

@nostrbox/otp-zen

v1.1.0

Published

A simple and flexible OTP (One-Time Password) generator with TypeScript support

Readme

OTP Zen

A simple and flexible OTP (One-Time Password) generator with TypeScript support. Generate secure numeric and alphanumeric OTPs for authentication, verification, and security purposes.

Features

  • 🎯 Multiple OTP Types: Numeric, random alphanumeric, and sequenced alphanumeric
  • 🔧 Customizable Length: Generate OTPs of any length
  • 📝 Case Control: Upper, lower, or mixed case options
  • 🚀 TypeScript Support: Full type definitions included
  • 📦 Zero Dependencies: Lightweight with no external dependencies
  • 🛡️ Secure: Uses cryptographically secure random generation

Installation

npm install @nostrbox/otp-zen

Usage

Basic Usage

import { generateOTP } from '@nostrbox/otp-zen';

// Generate a 6-digit numeric OTP
const numericOTP = generateOTP({
  length: 6,
  type: 'numeric',
});
console.log(numericOTP); // e.g., "123456"

// Generate a 8-character random alphanumeric OTP
const randomOTP = generateOTP({
  length: 8,
  type: 'random-alphanumeric',
  case: 'mixed',
});
console.log(randomOTP); // e.g., "A7b2K9mP"

// Generate a 10-character sequenced alphanumeric OTP
const sequencedOTP = generateOTP({
  length: 10,
  type: 'sequenced-alphanumeric',
  case: 'upper',
});
console.log(sequencedOTP); // e.g., "A1B2C3D4E5"

OTP Types

1. Numeric OTP

Generates OTPs using only numbers (0-9).

const otp = generateOTP({
  length: 6,
  type: 'numeric',
});
// Example output: "847392"

2. Random Alphanumeric OTP

Generates OTPs using random combinations of letters and numbers.

const otp = generateOTP({
  length: 8,
  type: 'random-alphanumeric',
  case: 'mixed', // 'upper', 'lower', or 'mixed'
});
// Example output: "K7mN2pQ9"

3. Sequenced Alphanumeric OTP

Generates OTPs with alternating letters and numbers in a specific pattern.

const otp = generateOTP({
  length: 10,
  type: 'sequenced-alphanumeric',
  case: 'upper',
});
// Example output: "A1B2C3D4E5" (letter, number, letter, number...)

Case Options

  • 'upper': All characters in uppercase
  • 'lower': All characters in lowercase
  • 'mixed': Mixed case (default for alphanumeric types)

API Reference

generateOTP(options: OTPOptions): string

Generates an OTP based on the provided options.

Parameters

  • options (OTPOptions): Configuration object for OTP generation
    • length (number): The length of the OTP to generate
    • type (OTPType): The type of OTP to generate
      • 'numeric': Numbers only (0-9)
      • 'random-alphanumeric': Random letters and numbers
      • 'sequenced-alphanumeric': Alternating letters and numbers
    • case (optional): Case formatting
      • 'upper': Uppercase
      • 'lower': Lowercase
      • 'mixed': Mixed case (default)

Returns

  • string: The generated OTP

Examples

Authentication Codes

// 6-digit SMS verification code
const smsCode = generateOTP({
  length: 6,
  type: 'numeric',
});

// 8-character email verification code
const emailCode = generateOTP({
  length: 8,
  type: 'random-alphanumeric',
  case: 'upper',
});

Security Tokens

// 16-character secure token
const secureToken = generateOTP({
  length: 16,
  type: 'random-alphanumeric',
  case: 'mixed',
});

// 12-character API key
const apiKey = generateOTP({
  length: 12,
  type: 'sequenced-alphanumeric',
  case: 'upper',
});

TypeScript Support

This package includes full TypeScript definitions. The main types are:

type OTPType = 'numeric' | 'random-alphanumeric' | 'sequenced-alphanumeric';

interface OTPOptions {
  length: number;
  type: OTPType;
  case?: 'upper' | 'lower' | 'mixed';
}

Development

This project uses semantic release for automated versioning and publishing. See CONTRIBUTING.md for detailed contribution guidelines.

Building

npm run build

Development Mode

npm run dev

Testing

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

Code Quality

# Format code
npm run format

# Lint code
npm run lint

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for details on:

  • Commit message conventions (Conventional Commits)
  • Development workflow
  • Semantic release process
  • Pull request guidelines

Release Process

This project uses semantic-release for automated versioning and publishing:

  • feat: New features trigger minor version bumps
  • fix: Bug fixes trigger patch version bumps
  • feat! or BREAKING CHANGE: Breaking changes trigger major version bumps

Releases are automatically published to npm when changes are pushed to the main branch.

License

MIT License - see LICENSE file for details.