otplib API Documentation / @otplib/totp / 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?
readonlyoptionalalgorithm:HashAlgorithm
Defined in: totp/src/types.ts:39
Hash algorithm to use (default: 'sha1')
base32?
readonlyoptionalbase32:Base32Plugin
Defined in: totp/src/types.ts:45
Base32 plugin to decode string secrets (required if secret is a string)
crypto?
readonlyoptionalcrypto:CryptoPlugin
Defined in: totp/src/types.ts:43
Crypto plugin to use for HMAC operations
digits?
readonlyoptionaldigits:Digits
Defined in: totp/src/types.ts:41
Number of digits in the OTP code (default: 6)
epoch?
readonlyoptionalepoch:number
Defined in: totp/src/types.ts:26
Current Unix epoch timestamp in seconds (default: Date.now() / 1000)
guardrails?
readonlyoptionalguardrails: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?
readonlyoptionalissuer:string
Defined in: totp/src/types.ts:47
Service provider name (for URI generation)
label?
readonlyoptionallabel:string
Defined in: totp/src/types.ts:49
User identifier/email/username (for URI generation)
period?
readonlyoptionalperiod:number
Defined in: totp/src/types.ts:37
Time step in seconds (default: 30)
secret?
readonlyoptionalsecret:string|Uint8Array
Defined in: totp/src/types.ts:24
The shared secret key (Base32-encoded string or raw bytes)
t0?
readonlyoptionalt0: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)