Skip to content

A nodejs library that handles the generation, storage and verification of OTPs.

License

Notifications You must be signed in to change notification settings

rushabhhere/otp-mgr

Repository files navigation

OTP Manager

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
  • NPM (Node.js package manager)

Install with:

npm install otp-mgr

How To Use

const otp = require('otp-mgr');

const Purpose = {
  Register: 1,
  Login: 2,
  ResetPassword: 3,
  CricicalAction: 4,
};

const users = [
  { id: 1, email: 'john@gmail.com' },
  { id: 2, email: 'jane@gmail.com' },
  { id: 3, email: 'charles@gmail.com' },
];

const otpForJohnLogin = otp.generate(users[0].id, Purpose.Login);

console.log(otpForJohnLogin); // 4 digit OTP

const isValid = otp.verify(users[0].id, Purpose.Login, otpForJohnLogin);

console.log(isValid); // true

const isValidJane = otp.verify(users[1].id, Purpose.Login, otpForJohnLogin);

console.log(isValidJane); // false

Versioning

We use Semantic Versioning for versioning.

Authors

License

This project is licensed under the MIT License

About

A nodejs library that handles the generation, storage and verification of OTPs.

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •