yeojz / otplib

:key: One Time Password (OTP) / 2FA for Node.js and Browser - Supports HOTP, TOTP and Google Authenticator

Home Page:https://otplib.yeojz.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

totp timer not reseting upon creating a new token ?

rollerman111 opened this issue · comments

Each user has its own secret stored in a database. When a user logs in for 2FA I run totp.generate(secret); on the user's secret. I set step to 5 minutes

const { totp } = require('otplib');
totp.options = { step: 300 }; // 5 minutes

How do I ensure everytime I generate a token it will start from 0 seconds? Currently its randomly [0, 300] depending on the time I generate. Is totp not what I want to use ?

Edit: A word