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

@onedaydevelopers/otp-detector

v1.1.0

Published

A robust, dependency-free OTP (one-time password) detection utility using context-aware heuristics.

Readme

@onedaydevelopers/otp-detector

A robust, dependency-free OTP (one-time password) detection utility using context-aware heuristics.

It intelligently extracts 4-8 digit codes from emails (Subject, Body, HTML) and SMS messages, handling various formats (dashed, spaced) and filtering out false positives like addresses, invoice numbers, and dates.

Try it Live

Check out the playground and test your own messages here: http://od2.in/contributions/otp-detector

Key Features

  • Context-Aware: Detects OTPs even in complex sentences (e.g. "Your verification code is 123456").
  • Smart Filtering: Ignores numbers in addresses (e.g. "1601 Willow Rd"), dates, phone numbers, and invoice IDs.
  • Flexible Formats: Supports standard (123456), dashed (123-456), and spaced (123 456) codes.
  • Transaction Support: Correctly identifies OTPs in transaction messages (e.g. "Use OTP 9999 to authorize payment") while ignoring pure invoice details.
  • Zero Dependencies: Lightweight and fast.

Installation

npm install @onedaydevelopers/otp-detector

Usage

CommonJS

const { extractOTPFromEmail, extractOTP } = require('@onedaydevelopers/otp-detector');

// 1. From an Email Object (Subject + Body + HTML)
const result = extractOTPFromEmail({
  subject: 'Login Verification',
  text: 'Your code is 123-456',
  html: '<div>Your code is <strong>123-456</strong></div>'
});
console.log(result); // '123456'

// 2. From Plain Text / SMS
const smsCode = extractOTP('Your OTP is 987 654. Do not share.');
console.log(smsCode); // '987654'

ES Modules

import { extractOTPFromEmail, extractOTP } from '@onedaydevelopers/otp-detector';

const code = extractOTP('Your verification code is 424242');

API

extractOTP(text, options?)

Extracts an OTP from a plain text string.

Parameters

  • text (string): The input string to analyze.
  • options (object, optional): Configuration object to customize detection.
    • positiveKeywords (string[]): Words that boost detection confidence (e.g., 'otp', 'code'). Default includes common terms like 'verification', 'pin', etc.
    • negativeKeywords (string[]): Words that suppress detection (e.g., 'order', 'invoice'). Default includes address terms, 'tracking', etc.
    • neighborhood (number): Number of characters around a potential match to scan for context. Default is 80.

Returns

  • (string | null): The detected 4-8 digit OTP, or null if none found.

extractOTPFromEmail(emailData, options?)

Specialized extractor for emails that prioritizes the Subject line, then Plain Text, then HTML content.

Parameters

  • emailData (object):
    • subject (string?): The email subject line.
    • text (string?): The plain text body of the email.
    • html (string?): The HTML body of the email.
  • options (object, optional): Same configuration object as extractOTP.

Returns

  • (string | null): The detected OTP, or null.

Looking for more useful tools? Visit us on For more tools, check us out on One Day Developers