otplib API Documentation / @otplib/totp / Digits
Type Alias: Digits
Digits =
number
Defined in: core/src/types.ts:16
Number of characters in the OTP code.
RFC 4226/6238 specify 6-8 digits. Non-standard variants (e.g., Steam Guard's 5-digit codes) may use different lengths. This is not validated at runtime - it is configuration supplied by the integrator, not external input, and enforcing a range here would break those variants. Callers that accept digits from untrusted input are responsible for validating it themselves, as @otplib/uri and the CLI already do by restricting it to 6-8.