Miss any of our Open RFC calls?Watch the recordings here! »

node-otp

1.2.2 • 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

Install

npm i node-otp

DownloadsWeekly Downloads

83

Version

1.2.2

License

MIT

Unpacked Size

12.3 kB

Total Files

15

Last publish

Collaborators

  • avatar