2.0.2 • Published 1 year ago

@am92/otp v2.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@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

Resources

License

2.0.2

1 year ago

2.0.1

2 years ago

2.0.0

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.0.19

2 years ago

1.1.0

2 years ago

1.0.18

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.0

3 years ago