Socket
Book a DemoInstallSign in
Socket

@am92/otp

Package Overview
Dependencies
Maintainers
3
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@am92/otp

HOTP Authentication Module

latest
Source
npmnpm
Version
2.1.1
Version published
Weekly downloads
4
-93.94%
Maintainers
3
Weekly downloads
 
Created
Source

@am92/otp

npm version  ECMAScript Module  License: MIT  Vulnerabilities: Snyk  Downloads Bundle Size


Table of Content


Installation

$ npm install --save @am92/otp

Environment Variables

The following environment variables need to be set to work with this package:

##### Redis Config
export OTP_LENGTH='6'
export OTP_EXPIRY_IN_SECS='300'
export OTP_GEN_HALT_IN_SECS='30'
export OTP_GEN_LIMIT='5'
export OTP_GEN_LIMIT_EXPIRY_IN_SEC='1800'
export OTP_REGEN_LIMIT='3'
export OTP_VAL_LIMIT='3'
#
export OTP_DEDICATED_REDIS='false'
export OTP_REDIS_AUTH_ENABLED='false'
export OTP_REDIS_HOST=''
export OTP_REDIS_PORT='6379'
export OTP_REDIS_KEY_PREFIX=''
export OTP_REDIS_AUTH=''

Note:

  • If 'OTP_DEDICATED_REDIS' is set to 'true', 'OTP_REDIS_HOST' and 'OTP_REDIS_PORT' are required
  • If 'OTP_DEDICATED_REDIS' and 'REDIS_AUTH_ENABLED' are set to 'true', 'OTP_REDIS_AUTH' is also required
  • Variables where values have been defined can be omitted from being defined as the mentioned values are internally defaulted.

Creating an OtpSdk Instance

import OtpSdk from '@am92/otp'

const otpSdk = new OtpSdk()
export default otpSdk

If you wish to pass your custom 'config' to OtpSdk Class, then you can build it as follows:

import OtpSdk from '@am92/otp'

const config = {
  OTP_CONFIG: {
    OTP_LENGTH: 6,
    OTP_EXPIRY_IN_SECS: 300,
    OTP_GEN_HALT_IN_SECS: 30,
    OTP_GEN_LIMIT: 5,
    OTP_GEN_LIMIT_EXPIRY_IN_SEC: 1800,
    OTP_REGEN_LIMIT: 3,
    OTP_VAL_LIMIT: 3,
  },
  REDIS_CONFIG: {
    CONNECTION_CONFIG: {
      socket: {
        host: 'localhost',
        port: 6379,
        tls: true
      },
      password: 'password'
    },
    KEY_PREFIX: 'test'
  }
}

const otpSdk = new OtpSdk(config)
export default otpSdk

Contributors

Ankit Gandhi
Ankit Gandhi
Mehul Agarwal
Mehul Agarwal

Resources


License



Keywords

otp

FAQs

Package last updated on 19 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts