tempmail-otp-extractor
v1.0.1
Published
Zero-dependency regex and heuristics engine to extract 4, 6, and 8-digit OTP verification codes and magic links from emails.
Maintainers
Readme
tempmail-otp-extractor
High-accuracy, zero-dependency regex and heuristic parser to extract one-time passwords (OTP), verification codes, and confirmation magic links from incoming emails.
Designed for automated QA testing suites (Playwright, Cypress, Puppeteer), ephemeral disposable email listeners, and registration bots that need to parse verification PINs reliably without regex false positives.
Features
- Context-Aware Parsing: Prioritizes codes adjacent to keywords like
verification code,OTP:,security pin,confirmation is. - False-Positive Filtering: Automatically ignores years (
2024,2025,2026), HTTP status codes (404,500), and common network ports. - Magic Link Extraction: Extracts account confirmation, tokenized URLs, and activation endpoints from HTML bodies.
- Dual ESM & CJS: Works seamlessly in Node.js, modern browsers, Bun, and edge runtimes.
- Zero Dependencies: Pure JavaScript logic with 0 external packages.
Installation
npm install tempmail-otp-extractorUsage
CommonJS (Node.js)
const { extractOtp, extractMagicLink } = require('tempmail-otp-extractor');
const emailBody = `
Hello user,
Your 6-digit confirmation code for verification is: 849201.
This code will expire in 5 minutes.
`;
const otp = extractOtp(emailBody);
console.log('Detected OTP:', otp); // "849201"ESM / TypeScript
import { extractOtp, extractMagicLink } from 'tempmail-otp-extractor';
const htmlContent = '<p>Click <a href="https://example.com/verify?token=abc123xyz">here</a> to activate.</p>';
const link = extractMagicLink(htmlContent);
console.log('Activation Link:', link);Recommended Live Testing Utilities
To test this package against live ephemeral inboxes and varying verification queues, use our free disposable email tools:
- 5 Minute Mail (Instant OTP Generator): Rapid 300-second disposable inbox built specifically for fast SMS and OTP verification flows.
- 10 Minute Mail (Standard): Default ephemeral inbox for general verification flows.
- 15 Minute Mail (Extended Queue): 900-second buffer designed for platforms with delayed outbound email delivery.
- 20 Minute Mail (Multi-Stage Testing): 1,200-second session for complex registration flows and team invites.
- 25 Minute Mail (Long Forms): Extended session for complex registrations and surveys.
- 30 Minute Mail (Extended Session): Half-hour temporary inbox for manual QA and exploratory testing.
- OTP Verification Guide: Step-by-step breakdown of OTP regex parsing, delivery delays, and SMS bypass.
- How Ephemeral Mail Works: Technical deep-dive into RAM-only message processing and automatic memory disposal.
- Why Websites Block Disposable Email: Analysis of MX heuristics, greylisting delays, and verification filters.
Author & Maintainer
Maintained by Alfaz Mahmud Rizve • Lead Systems Architect at TempMail10min.
License
MIT © Alfaz Mahmud Rizve
