npm / otplib
otplib
What changed in otplib 12 to 13, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
6 breaking11 security6 new APIs and options1 performance2 behavior and defaults1 tooling3 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initotplib 1327 changes
Breaking changes 5
The CLI build target was raised to Node 22, which may affect the Node.js versions that can run it.
All crypto plugins now reject unsupported hash algorithm strings instead of silently substituting a different digest; accepted algorithms and aliases are documented.
Unsupported hash algorithms now throw AlgorithmUnsupportedError, giving callers a specific error to handle instead of plugin-dependent errors or silent fallback.
HOTP counterTolerance now uses tuple semantics with type [number, number] and a look-ahead default; check existing HOTP tolerance values.
Secrets now require a minimum of 16 bytes; override MIN_SECRET_BYTES to interoperate with shorter existing secrets.
Security 11
URI errors no longer expose secrets, and generate parameters are validated.
The CLI enforces 0600 permissions on vault and key files and gitignores them.
An ajv override was added to address a moderate ReDoS vulnerability.
A markdown-it ReDoS vulnerability was resolved.
An undici override was added to address a security alert.
OTP validation was hardened.
Security improvements were made; the notes do not specify their details.
An HOTP update-counter command was added.
URI parsing was hardened.
Adds the afterTimeStep parameter for TOTP replay protection.
The guardrails parameter now propagates through HOTP and TOTP call chains.
New APIs and options 5
otplib adds IIFE and CDN build support, enabling those build formats.
OTPHooks were added for custom token encoding and validation.
Adds hex and base64 bypass plugins.
Adds a plugin for bypassing Base32 encoding.
Guardrails can now be overridden.
Behavior and default changes 2
TOTP replay controls are now bubbled up through otplib.
generateURI now supports HOTP as well as TOTP strategies.
Tooling 1
An otplib CLI application was added for developers to use.
Fixes and other changes 3
generateSync now passes hooks through, allowing callers to use hooks when generating synchronously.
Adapters now honour base64, latin1 and ascii key encodings.
Subpath exports were fixed to resolve Node 10 compatibility failures.
otplib 123 changes
Breaking changes 1
The library was split into core, plugin and preset packages, changing its package structure.
New APIs and options 1
The library adds async support.
Performance 1
The browser bundle output is smaller.