otplib API Documentation / @otplib/totp / getTimeStepUsed
Function: getTimeStepUsed()
getTimeStepUsed(
time,period,t0,guardrails):number
Defined in: totp/src/index.ts:380
Get the current TOTP counter value
Parameters
time
number = ...
Current Unix timestamp in seconds (default: now)
period
number = 30
Time step in seconds (default: 30)
t0
number = 0
Initial Unix time to start counting time steps (default: 0)
guardrails
OTPGuardrails = ...
Returns
number
Current counter value
Example
ts
import { getTimeStepUsed } from '@otplib/totp';
const counter = getTimeStepUsed();
// Returns: 12345 (current counter value)