otplib API Documentation / @otplib/totp / VerifyResultValid
Type Alias: VerifyResultValid
VerifyResultValid =
object
Defined in: totp/src/types.ts:126
Successful verification result with delta offset
Properties
delta
readonlydelta:number
Defined in: totp/src/types.ts:135
The offset from the current time step where the token matched.
- 0: Token matched at current time step (no drift)
- Negative: Token matched in a past time step (client clock behind)
- Positive: Token matched in a future time step (client clock ahead)
epoch
readonlyepoch:number
Defined in: totp/src/types.ts:152
The exact epoch timestamp (in seconds) of the period start where the token matched.
This provides the precise Unix timestamp for the beginning of the time period in which the token was valid. Useful for logging, debugging, and advanced time drift analysis.
Example
typescript
const result = await verify({ secret, token, epochTolerance: 30 });
if (result.valid) {
console.log(`Token matched at epoch: ${result.epoch}`);
console.log(`Token was ${result.delta} periods away`);
}valid
readonlyvalid:true
Defined in: totp/src/types.ts:128
Token is valid