Skip to content

TypeScript API / @laikacms/server/oauth2 / verifyTOTPWithStep

Function: verifyTOTPWithStep() ​

ts
function verifyTOTPWithStep(
   secret, 
   code, 
   window?
): Promise<{
  step?: number;
  valid: boolean;
}>;

Verify a TOTP code and return the matched time step. Callers that wish to implement RFC 6238 §5.2 replay protection use the returned step to ensure a code is only accepted once per user.

Parameters ​

ParameterTypeDefault value
secretstringundefined
codestringundefined
windownumber1

Returns ​

Promise<{ step?: number; valid: boolean; }>

Released under the MIT License.