otp-mgr
v0.1.0
Published
A nodejs library that handles the generation, storage and verification of OTPs.
Downloads
18
Readme
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: '[email protected]' },
{ id: 2, email: '[email protected]' },
{ id: 3, email: '[email protected]' },
];
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