Skip to main content

verifyTOTP

@quik/mfa


@quik/mfa / verifyTOTP

Function: verifyTOTP()

verifyTOTP(code, secret, now?, stepSeconds?, digits?, window?): boolean

Defined in: mfa/src/utils/totp.ts:162

Verifies a TOTP code within the allowed drift window.

Parameters​

code​

string

User-provided code.

secret​

string

Base32 secret.

now?​

number = ...

Reference timestamp in milliseconds.

stepSeconds?​

number = 30

Step interval in seconds.

digits?​

number = 6

Number of digits in the expected code.

window?​

number = 1

Allowed drift window measured in steps.

Returns​

boolean