Skip to content

otplib API Documentation / otplib / TOTPOptions

Type Alias: TOTPOptions

TOTPOptions = object

Defined in: totp/src/types.ts:22

TOTP configuration options

All properties are optional for flexible class-based configuration. Use TOTPGenerateOptions or TOTPVerifyOptions for function parameters where certain fields are required.

Properties

algorithm?

readonly optional algorithm: HashAlgorithm

Defined in: totp/src/types.ts:39

Hash algorithm to use (default: 'sha1')


base32?

readonly optional base32: Base32Plugin

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

Base32 plugin to decode string secrets (required if secret is a string)


crypto?

readonly optional crypto: CryptoPlugin

Defined in: totp/src/types.ts:43

Crypto plugin to use for HMAC operations


digits?

readonly optional digits: Digits

Defined in: totp/src/types.ts:41

Number of digits in the OTP code (default: 6)


epoch?

readonly optional epoch: number

Defined in: totp/src/types.ts:26

Current Unix epoch timestamp in seconds (default: Date.now() / 1000)


guardrails?

readonly optional guardrails: OTPGuardrails

Defined in: totp/src/types.ts:55

Custom guardrails to override validation limits Must be created via createGuardrails() factory Use this carefully - see danger-zone documentation


issuer?

readonly optional issuer: string

Defined in: totp/src/types.ts:47

Service provider name (for URI generation)


label?

readonly optional label: string

Defined in: totp/src/types.ts:49

User identifier/email/username (for URI generation)


period?

readonly optional period: number

Defined in: totp/src/types.ts:37

Time step in seconds (default: 30)


secret?

readonly optional secret: string | Uint8Array

Defined in: totp/src/types.ts:24

The shared secret key (Base32-encoded string or raw bytes)


t0?

readonly optional t0: number

Defined in: totp/src/types.ts:35

Initial Unix time to start counting time steps (default: 0)

Per RFC 6238, T0 is the Unix time from which to start counting. Most implementations use 0, but some systems may use a different start time.

Formula: counter = floor((epoch - t0) / period)

Released under the MIT License.