
Security News
arXiv Is Rate Limiting Authors Following a Flood of AI Slop Submissions
arXiv now limits authors to two submissions a month as AI slop overwhelms moderators, delays good papers, and sparks debate over applying the limit to everyone.
@otplib/totp
Advanced tools
RFC 6238 TOTP implementation for otplib.
npm install @otplib/totp
pnpm install @otplib/totp
yarn add @otplib/totp
import { generate, verify } from "@otplib/totp";
import { NodeCryptoPlugin } from "@otplib/plugin-crypto-node";
import { ScureBase32Plugin } from "@otplib/plugin-base32-scure";
const crypto = new NodeCryptoPlugin();
const base32 = new ScureBase32Plugin();
// Generate a TOTP token
const token = await generate({
secret: "JBSWY3DPEHPK3PXP",
crypto,
base32,
});
// Verify a TOTP token
const result = await verify({
secret: "JBSWY3DPEHPK3PXP",
token: "123456",
crypto,
base32,
});
// result.valid: boolean
// result.delta: number | null
Generate a TOTP code:
import { generate } from '@otplib/totp';
const token = await generate({
secret: new Uint8Array([...]), // Required: secret as bytes
crypto: new NodeCryptoPlugin(), // Required: crypto plugin
base32: new ScureBase32Plugin(), // Optional: base32 plugin (for decoding)
algorithm: 'sha1', // Optional: 'sha1' | 'sha256' | 'sha512'
digits: 6, // Optional: 6 | 7 | 8
period: 30, // Optional: time step in seconds
epoch: Math.floor(Date.now() / 1000), // Optional: current time in seconds
});
Verify a TOTP code:
import { verify } from '@otplib/totp';
const result = await verify({
secret: new Uint8Array([...]), // Required: secret as bytes
token: '123456', // Required: token to verify
crypto: new NodeCryptoPlugin(), // Required: crypto plugin
base32: new ScureBase32Plugin(), // Optional: base32 plugin (for decoding)
algorithm: 'sha1', // Optional: hash algorithm
digits: 6, // Optional: expected digits
period: 30, // Optional: time step
epoch: Math.floor(Date.now() / 1000), // Optional: current time
epochTolerance: 30, // Optional: time tolerance in seconds
});
// Returns: { valid: boolean, delta: number | null }
Get the remaining time before the next TOTP period:
import { getRemainingTime } from "@otplib/totp";
const seconds = getRemainingTime(
Math.floor(Date.now() / 1000), // time
30, // period
0, // t0
);
// Returns: number of seconds remaining
Get the time step used for a specific time:
import { getTimeStepUsed } from "@otplib/totp";
const counter = getTimeStepUsed(
Math.floor(Date.now() / 1000), // time
30, // period
0, // t0
);
// Returns: the counter value
Full documentation available at otplib.yeojz.dev:
MIT © 2026 Gerald Yeo
Speakeasy is a popular package for generating and verifying one-time passwords, including both TOTP and HOTP. It offers similar functionality to @otplib/totp, with a focus on simplicity and ease of use. Speakeasy is widely used for implementing 2FA in Node.js applications.
notp is another package that provides support for TOTP and HOTP. It is a lightweight library that offers basic functionality for generating and verifying OTPs. Compared to @otplib/totp, notp is more minimalistic and may lack some of the advanced configuration options available in otplib.
Authenticator is a package designed for generating and verifying TOTP tokens. It is similar to @otplib/totp in terms of functionality but is designed to be a simple and straightforward solution for adding 2FA to applications. It may not offer as many customization options as otplib.
FAQs
RFC 6238 TOTP implementation for otplib
The npm package @otplib/totp receives a total of 1,526,676 weekly downloads. As such, @otplib/totp popularity was classified as popular.
We found that @otplib/totp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Security News
arXiv now limits authors to two submissions a month as AI slop overwhelms moderators, delays good papers, and sparks debate over applying the limit to everyone.

Research
/Security News
A new GhostAction wave hits hundreds of GitHub repos, expanding CI/CD secret theft to cloud and AI credentials in source code and git history.

Research
/Security News
Tensorlake npm SDK version 0.5.144 was compromised in a ChainDrop / Shai-Hulud attack, delivering credential-stealing malware.