Skip to content

otplib API Documentation / otplib / / OTPFunctionalOptions

Type Alias: OTPFunctionalOptions

OTPFunctionalOptions = object

Defined in: otplib/src/types.ts:45

Common options for OTP generation

These options apply to both TOTP and HOTP strategies.

Properties

algorithm?

optional algorithm: HashAlgorithm

Defined in: otplib/src/types.ts:79

Hash algorithm (default: 'sha1')


base32?

optional base32: Base32Plugin

Defined in: otplib/src/types.ts:69

Base32 plugin to use (default: ScureBase32Plugin)


counter?

optional counter: number

Defined in: otplib/src/types.ts:108

Counter value Used by HOTP strategy (required)


crypto?

optional crypto: CryptoPlugin

Defined in: otplib/src/types.ts:64

Crypto plugin to use (default: NobleCryptoPlugin)


digits?

optional digits: Digits

Defined in: otplib/src/types.ts:84

Number of digits (default: 6)


epoch?

optional epoch: number

Defined in: otplib/src/types.ts:96

Current Unix epoch timestamp in seconds (default: now) Used by TOTP strategy


guardrails?

optional guardrails: OTPGuardrails

Defined in: otplib/src/types.ts:74

Validation guardrails


hooks?

optional hooks: OTPHooks

Defined in: otplib/src/types.ts:115

Hooks for customizing token encoding and validation. Allows non-standard OTP variants (e.g., Steam Guard) to replace the default numeric encoding with custom schemes.


period?

optional period: number

Defined in: otplib/src/types.ts:90

Time step in seconds (default: 30) Used by TOTP strategy


secret

secret: string | Uint8Array

Defined in: otplib/src/types.ts:52

Base32-encoded secret key

Note: By default, strings are assumed to be Base32 encoded. If you have a raw string/passphrase, you must convert it to Uint8Array first.


strategy?

optional strategy: OTPStrategy

Defined in: otplib/src/types.ts:59

OTP strategy to use (default: 'totp')

  • 'totp': Time-based OTP
  • 'hotp': HMAC-based OTP

t0?

optional t0: number

Defined in: otplib/src/types.ts:102

Initial Unix time to start counting time steps (default: 0) Used by TOTP strategy

Released under the MIT License.