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?
optionalalgorithm:HashAlgorithm
Defined in: otplib/src/types.ts:79
Hash algorithm (default: 'sha1')
base32?
optionalbase32:Base32Plugin
Defined in: otplib/src/types.ts:69
Base32 plugin to use (default: ScureBase32Plugin)
counter?
optionalcounter:number
Defined in: otplib/src/types.ts:108
Counter value Used by HOTP strategy (required)
crypto?
optionalcrypto:CryptoPlugin
Defined in: otplib/src/types.ts:64
Crypto plugin to use (default: NobleCryptoPlugin)
digits?
optionaldigits:Digits
Defined in: otplib/src/types.ts:84
Number of digits (default: 6)
epoch?
optionalepoch:number
Defined in: otplib/src/types.ts:96
Current Unix epoch timestamp in seconds (default: now) Used by TOTP strategy
guardrails?
optionalguardrails:OTPGuardrails
Defined in: otplib/src/types.ts:74
Validation guardrails
hooks?
optionalhooks: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?
optionalperiod: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?
optionalstrategy:OTPStrategy
Defined in: otplib/src/types.ts:59
OTP strategy to use (default: 'totp')
- 'totp': Time-based OTP
- 'hotp': HMAC-based OTP
t0?
optionalt0:number
Defined in: otplib/src/types.ts:102
Initial Unix time to start counting time steps (default: 0) Used by TOTP strategy