This library adopts a monorepo design. It contains both scoped (@otplib/*
) and unscoped
npm packages, all of which are listed in this document.
Only packages found in this repository are officially supported under this project.
The codebase was split out into multiple packages (as plugins) in order to guard against any possible deprecations of 3rd-party dependencies or new platforms which require unique implementations.
Do refer to the Quick Start Guide to get started.
These are usually quick start packages or feature packages that installs and uses
one or many of the @otplib/*
scoped packages.
npm install | description |
---|---|
otplib | Main package for quickly getting started. |
These packages are published under the @otplib/*
namespace.
Packages are for scoped modules fall into 3 categories: core
, plugins
and presets
.
Provides the core functionality of the library. Parts of the logic has been separated out in order to provide flexibility to the library via available plugins.
npm install | description |
---|---|
@otplib/core | Core hotp/totp/authenticator functions + classes |
@otplib/core-async | Provides async helpers in addition to @otplib/core |
import { HOTP, TOTP, Authenticator } from '@otplib/core';
import { HOTPAsync, TOTPAsync, AuthenticatorAsync } from '@otplib/core-async';
npm install | type | uses |
---|---|---|
@otplib/plugin-crypto | sync | crypto (included in Node.js) |
@otplib/plugin-crypto-js | sync | crypto-js |
@otplib/plugin-crypto-async-ronomon | async | @ronomon/crypto-async |
These crypto plugins provides:
{
createDigest, // used for token derivation
createRandomBytes, //used to generate random keys for Google Authenticator
}
npm install | type | uses |
---|---|---|
@otplib/plugin-thirty-two | sync | thirty-two |
@otplib/plugin-base32-enc-dec | sync | base32-encode and base32-decode |
These Base32 plugins provides:
{
keyDecoder, //for decoding Google Authenticator secrets
keyEncoder, // for encoding Google Authenticator secrets.
}
Presets are preconfigured HOTP, TOTP, Authenticator instances to allow you to get started with the library quickly.
Each presets would need the corresponding dependent npm modules to be installed.
npm install | description |
---|---|
@otplib/preset-default | A preset with the base32 and crypto plugins already setup. |
@otplib/preset-default-async | Async version of @otplib/preset-default |
@otplib/preset-browser | Webpack bundle and is a self contained umd bundle. |
@otplib/preset-v11 | Wrapper to adapt the APIs to v11.x compatible format |