@otp-forge/otp-forge
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

OTP Forge

A simple library for managing OTPs for all your applications. It helps with the generation, storage and verification of OTPs.

Getting Started

These instructions will give you a copy of the project up and running on your local machine for development and testing purposes.

Installing

Requirements:

  • Node.js (version >= 16.0.0)

Install with:

NPM:

npm install @otp-forge/otp-forge

Yarn:

yarn add @otp-forge/otp-forge

PNPM:

pnpm add @otp-forge/otp-forge

pnpm

How To Use

Initialize the OTPManager with the required configuration options:

const OTPManager = require("@otp-forge/otp-forge");

// In memory storage
const passwordResetOTPManager = new OTPManager({
  // Configuration options
  purpose: "password-reset", // Purpose of the OTP
  otpLength: 6, // Length of the OTP
  expirationTime: 300, // Time to live in seconds
});

Generate an OTP:

const otp: number = await passwordResetOTPManager.generateOTP();

Verify an OTP:

const isValid: boolean = await passwordResetOTPManager.verifyOTP(otp);

Warning: The default store is in-memory, which means that the OTPs will be lost when the application is restarted. To use a persistent store, you can use one of the supported stores or build your own.

Versioning

We use Semantic Versioning for versioning.

Authors

License

This project is licensed under the MIT License

Readme

Keywords

Package Sidebar

Install

npm i @otp-forge/otp-forge

Weekly Downloads

2

Version

1.0.5

License

MIT

Unpacked Size

18.6 kB

Total Files

16

Last publish

Collaborators

  • manangandhi1810
  • rushabhhere