Skip to content

otplib API Documentation / @otplib/core / utils / validateCounter

Function: validateCounter() ​

validateCounter(counter, guardrails?): void

Defined in: packages/core/src/utils.ts:483

Validate counter value

Parameters ​

counter ​

number | bigint

The counter to validate

guardrails? ​

OTPGuardrails = DEFAULT_GUARDRAILS

Validation guardrails (defaults to RFC recommendations)

Returns ​

void

Throws ​

If counter is negative

Throws ​

If counter exceeds safe integer

Released under the MIT License.