JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 705
  • Score
    100M100P100Q96319F
  • License MIT

OTP(One-Time-Password) generator for JavaScript

Package Exports

  • otp-agent
  • otp-agent/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (otp-agent) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

OTP-Agent NPM Version CI status Total Download

OTP(One-Time-Password) generator for JavaScript.

  • Generate OTP using numbers, alphabets and specialChars
  • Generate Custom OTP using specified characters

Installation

This is a Node.js module available through the npm registry.
Installation is done using the npm install command:

$ npm install otp-agent

Example & Usage (with import statement)

import { generateOTP, generateCustomOTP } from "otp-agent";

let otp = generateOTP();
console.log(otp); // 526775

otp = generateOTP({ length: 4, numbers: true, alphabets: true });
console.log(otp); // i5v3

// Custom OTP with specified characters (characters is mandatory field)
const customOTP = generateCustomOTP("Abc@123", { length: 5 });
console.log(customOTP); // 1@c3c

Example & Usage (with require statement)

const { generateOTP, generateCustomOTP } = require("otp-agent");

// Default OTP length is 6 and max is 10
var otp = generateOTP();
console.log(otp); // 543921

otp = generateOTP({ length: 4, upperCaseAlphabets: true, specialChars: true });
console.log(otp); // RNRS

// Custom OTP with specified characters (characters is mandatory field)
const customOTP = generateCustomOTP("Abc@123", { length: 5 });
console.log(customOTP); // 1@c3c

otp = generateOTP({
  length: 8,
  numbers: true,
  alphabets: true,
  upperCaseAlphabets: true,
  specialChars: true,
});
console.log(otp); // NZ9O#akS

Note

  • OTP can be generated with numbers, alphabets, uppercase alphabets, and special characters, and either of them can be chosen.
  • The OTP has a default length of 6 characters and a maximum length of 10.
  • If no choices are passed as a payload, then by default only number options are true.

Author

Rohan Shukla GitHub LinkedIn

License

© Licensed under the MIT License.