Skip to content

otplib API Documentation / otplib / class / OTPGenerateOptions

Type Alias: OTPGenerateOptions

OTPGenerateOptions = object

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

Options for generating a token with the OTP class

Properties

algorithm?

optional algorithm: HashAlgorithm

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

Hash algorithm (default: 'sha1')


counter?

optional counter: number

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

Counter value Used by HOTP strategy (required)


digits?

optional digits: Digits

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

Number of digits (default: 6)


epoch?

optional epoch: number

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

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


guardrails?

optional guardrails: OTPGuardrails

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

Validation guardrails


hooks?

optional hooks: OTPHooks

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

Hooks for customizing token encoding and validation


period?

optional period: number

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

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


secret

secret: string | Uint8Array

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

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.


t0?

optional t0: number

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

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

Released under the MIT License.