Skip to content
Gerald Yeo edited this page Sep 3, 2017 · 5 revisions

Table of Contents


Deprecations

v2 interface has finally been removed from the package

Compilation Changes

Previously, all files are compiled via babel and directly exported. As such, we have issues such as needing to do var hotp = require('otplib/hotp').default

Following a switch to rollup, all exported modules are by default cjs format and thus, you may just have var hotp = require('otplib/hotp')

Directory changes

In v6, entry points to the modules have been collated and consolidated. As such there are now only 6 main sub-packages and other standalone compiled packages.

i.e.

Entry Packages:

// All libraries
import otplib from 'otplib';
// {
//   Authenticator
//   HOTP
//   TOTP
//   authenticator
//   hotp
//   totp
// }

// Contains all functional interfaces for both HOTP and TOTP
import core from 'otplib/core';
// {
//   hotpCheck,
//   hotpCounter,
//   hotpDigest,
//   hotpOptions,
//   hotpSecret,
//   hotpToken,
//   totpCheck,
//   totpCounter,
//   totpOptions,
//   totpSecret,
//   totpToken
// }

// Contains HOTP Class Instance and HOTP Class
import hotp from 'otplib/hotp';

// Contains TOTP Class Instance and TOTP Class
import totp from 'otplib/totp';

// Contains Authenticator Class Instance and Authenticator Class
// As well as Authenticator functional interfaces as utils
import authenticator from 'otplib/authenticator';

// All utility methods used by the above classes
import utils from 'otplib/utils';
// {
//   hexToInt,
//   intToHex,
//   isSameToken,
//   leftPad,
//   padSecret,
//   removeSpaces,
//   secretKey,
//   setsOf,
//   stringToHex
// }

Standalone Packages:

// Standalone browser package.
import browser from 'otplib/browser';
Clone this wiki locally