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

@ralalabs/otp-manager-client

v1.0.0

Published

Client for otp-manager — OTP extraction API on Cloudflare Workers.

Readme

@ralalabs/otp-manager-client

TypeScript client for otp-manager — an OTP extraction API running on Cloudflare Workers.

Zero dependencies. Uses global fetch. Works on Node.js 20+, Cloudflare Workers, Deno, Bun, and any edge runtime.

Install

npm install @ralalabs/otp-manager-client
# or
pnpm add @ralalabs/otp-manager-client

Quick start

import { OtpManagerClient } from '@ralalabs/otp-manager-client';

const client = new OtpManagerClient({
  baseUrl: 'https://otp-manager.your-sub.workers.dev',
  token: 'YOUR_API_TOKEN'
});

const { otp } = await client.getLatestOtp({ profile: 'your-profile' });
console.log('OTP:', otp);

Poll for OTP

Wait for an OTP to arrive after triggering a login flow:

const after = new Date().toISOString();

// ... trigger login ...

const result = await client.pollOtp({
  profile: 'your-profile',
  after,
  timeoutMs: 60_000,  // wait up to 60s
  intervalMs: 3_000,  // poll every 3s
  deleteAfter: true    // clean up after retrieval
});

if (result) {
  console.log('OTP:', result.otp);
} else {
  console.log('Timed out');
}

API

Constructor

new OtpManagerClient({
  baseUrl: string;    // Worker URL
  token: string;      // Bearer token
  fetch?: typeof fetch; // Custom fetch (optional, defaults to globalThis.fetch)
})

OTP methods

client.getLatestOtp(params?)    // GET /otp/latest
client.getOtpHistory(params?)   // GET /otp/history
client.extractLatest(params?)   // POST /otp/extract/latest
client.listProfiles()           // GET /otp/profiles
client.getProfile(name)         // GET /otp/profiles/:name
client.pollOtp(params?)         // Poll until OTP arrives or timeout

Email methods

client.listEmails(params?)          // GET /emails
client.getEmail(id)                 // GET /emails/:id
client.getRawEmail(id)              // GET /emails/:id/raw (returns Response)
client.extractFromEmail(id, params?) // POST /emails/:id/extract-otp
client.deleteEmail(id)              // DELETE /emails/:id

Health

client.health()  // GET /health

Parameters

getLatestOtpprofile, from, to, subject, q, after, lang, label, codeLength, sourcePart, strict

getOtpHistorylimit, before, after, from, to, subject, q, profile

extractLatestprofile, lang, codeLength, label, sourcePart, strict, from, to, subject, q, after

listEmailslimit, before, after, from, to, subject, q, hasOtp

pollOtp — all getLatestOtp params plus timeoutMs (default 60000), intervalMs (default 3000), deleteAfter (default false)

Error handling

import { OtpManagerClient, OtpManagerError } from '@ralalabs/otp-manager-client';

try {
  const res = await client.getLatestOtp({ profile: 'your-profile' });
} catch (err) {
  if (err instanceof OtpManagerError) {
    console.log(err.status);       // HTTP status code
    console.log(err.body.message); // Error message from API
  }
}

Custom fetch

Pass a custom fetch for testing or environments without global fetch:

import { OtpManagerClient } from '@ralalabs/otp-manager-client';
import { fetch } from 'undici';

const client = new OtpManagerClient({
  baseUrl: 'https://otp-manager.your-sub.workers.dev',
  token: 'YOUR_TOKEN',
  fetch
});

Responses

All methods return typed responses. Key types:

import type {
  OtpLatestResponse,
  OtpExtraction,
  EmailRecord,
  ExtractionResult
} from '@ralalabs/otp-manager-client';

The getLatestOtp response includes:

  • otp — the code (null if expired)
  • expired — boolean
  • extraction — full extraction record with confidence, matched pattern, context
  • email — email metadata (or null)

Status 410 (expired OTP) is not thrown as an error — it returns normally with expired: true and otp: null.

License

MIT