node-otp
TypeScript icon, indicating that this package has built-in type declarations

1.2.3 • Public • Published

Node OTP

Travis NPMV

Node.js One-Time Password library

Features

  • Zero Dependency
  • TypeScript Definitions
  • RFC4226 (HMAC One-Time Password)
  • RFC6238 (Time-Based One-Time Password)

Installation

yarn add node-otp

or

npm install --save node-otp

Examples

const { hotp } = require('node-otp')

hotp({
  secret: '12345678901234567890',
})
const { totp } = require('node-otp')

totp({
  secret: '12345678901234567890',
})

APIs

hotp: (parameters: Parameters) => string

Parameters

secret: string | Buffer

movingFactor?: number

Default value of movingFactor is 0

codeDigits?: number

Default value of codeDigits is 6

addChecksum?: boolean

Default value of addChecksum is false

truncationOffset?: number

Default value of truncationOffset is -1

hmacAlgorithm?: 'sha1' | 'sha256' | 'sha512'

Default value of hmacAlgorithm is sha1


totp: (parameters: Parameters) => string

Parameters

secret: string | Buffer

step?: number

Default value of step is 30

time?: number

Default value of time is 6

initialTime?: number

Default value of initialTime is 0

codeDigits?: number

Default value of codeDigits is 6

hmacAlgorithm?: 'sha1' | 'sha256' | 'sha512'

Default value of hmacAlgorithm is sha256

Package Sidebar

Install

npm i node-otp

Weekly Downloads

260

Version

1.2.3

License

MIT

Unpacked Size

13 kB

Total Files

12

Last publish

Collaborators

  • adnsio