Skip to content
Gerald Yeo edited this page Aug 20, 2019 · 1 revision

Table of Contents

Method Changes

Google Authenticator

  • otplib.google.[METHOD] -> otplib.authenticator.[METHOD]
  • otplib.google.secret() -> otplib.authenticator.generateSecret()

HOTP

  • otplib.core.hotp() -> otplib.hotp.generate()
  • otplib.core.checkHOTP() -> otplib.hotp.check()

TOTP

  • otplib.core.totp() -> otplib.totp.generate()
  • otplib.core.checkTOTP() -> otplib.totp.check()

Helpers

  • otplib.core.helpers.[METHOD] -> otplib.[hotp|totp].utils.[METHOD]

Secret

  • otplib.core.secret.generate() -> otplib.[hotp|totp].utils.generateSecret()
  • otplib.core.secret.removeSpaces() -> otplib.[hotp|totp].utils.removeSpaces()
  • otplib.core.secret.divideIntoSetsOf() -> otplib.[hotp|totp].utils.setsOf()

Function specific requires

If you want specific functionality, you may do

var totp = require('otplib/lib/totp')

instead of

var otplib = require('otplib');
var totp = otplib.totp;

V2 compatibility layer

In order to ease migration, you may use the v2 API compatible library.

var otplib = require('otplib/v2');
Clone this wiki locally