Skip to content

otplib API Documentation / otplib / OTPVerifyOptions

Type Alias: OTPVerifyOptions

OTPVerifyOptions = object

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

Options for verifying a token with the OTP class

Properties

algorithm?

optional algorithm: HashAlgorithm

Defined in: otplib/src/class.ts:122

Hash algorithm (default: 'sha1')


counter?

optional counter: number

Defined in: otplib/src/class.ts:151

Counter value Used by HOTP strategy (required)


counterTolerance?

optional counterTolerance: number | number[]

Defined in: otplib/src/class.ts:166

Counter tolerance for HOTP verification (default: 0)

  • Number: symmetric look-ahead window
  • Array: asymmetric window

digits?

optional digits: Digits

Defined in: otplib/src/class.ts:127

Number of digits (default: 6)


epoch?

optional epoch: number

Defined in: otplib/src/class.ts:133

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


epochTolerance?

optional epochTolerance: number | [number, number]

Defined in: otplib/src/class.ts:159

Time tolerance in seconds for TOTP verification (default: 0)

  • Number: symmetric tolerance (same for past and future)
  • Tuple [past, future]: asymmetric tolerance Use [5, 0] for RFC-compliant past-only verification.

guardrails?

optional guardrails: OTPGuardrails

Defined in: otplib/src/class.ts:171

Validation guardrails


period?

optional period: number

Defined in: otplib/src/class.ts:145

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


secret

secret: string

Defined in: otplib/src/class.ts:112

Base32-encoded secret key


t0?

optional t0: number

Defined in: otplib/src/class.ts:139

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


token

token: string

Defined in: otplib/src/class.ts:117

OTP code to verify

Released under the MIT License.