npm / otplib
otplib
What changed in otplib 13, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-18.
4 breaking9 security5 new APIs and options2 behavior and defaults1 tooling
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initotplib 1321 changes
Breaking changes 4
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 9
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.