Skip to content
Gerald Yeo edited this page Jun 17, 2018 · 7 revisions

Table of Contents


Deprecations

otplib/core default exports

When importing the root module, i.e. import otplib from 'otplib', the classes for Authenticator, TOTP, HOTP are no longer exported. Only their instances are exported.

# original
export default {
  Authenticator,
  TOTP,
  HOTP,
  authenticator,
  totp,
  hotp
}

# new 
export default {
  authenticator,
  totp,
  hotp
}

This is to minimise confusion as well as simplify the TypeScript definitions.

The classes are still available via the instances. i.e.

# before
const HOTP = otplib.HOTP
const TOTP = otplib.TOTP
const Authenticator = otplib.Authenticator

# after
const HOTP = otplib.hotp.HOTP
const TOTP = otplib.totp.TOTP
const Authenticator = otplib.authenticator.Authenticator