@otplib/preset-v11
v13.3.0
Published
v11 compatibility preset for otplib
Downloads
4,317,900
Maintainers
Readme
@otplib/preset-v11
Drop-in replacement adapter for migrating
otplibfrom v11 to v13.
This adapter mimics the v11 API while using v13's plugins under the hood. However, some fundamental changes from v13 may carry over.
Note: This is intended as a temporary bridge to help you upgrade to v13 without rewriting your entire application immediately. We strongly recommend fully migrating to the new v13 API when possible.
Installation
npm install @otplib/preset-v11
pnpm add @otplib/preset-v11
yarn add @otplib/preset-v11Usage
This package provides a drop-in replacement for otplib v11, using the v13 core.
import { authenticator, hotp, totp } from "@otplib/preset-v11";
const secret = authenticator.generateSecret();
const token = authenticator.generate(secret);
const isValid = authenticator.check(token, secret);Compatibility Notes
- Epoch: Uses seconds (UNIX timestamp), same as v11.
- Error Handling:
checkandverifymethods swallow errors and returnfalse, matching v11 behavior. - Secret Length: Enforces strict secret length (> 16 bytes) due to v13 core security requirements.
Migration Guide
For a full guide on migrating to v13 refer to the Migration Guide.
