authenticator always return invalid token when Window OPTION is set to 0
Describe the bug window option value is set to 0. Now when I try to verify otp using totp.check function, it always returns false.
when I changed value of window from 0 -> 1. Everything starts working.
To Reproduce Steps to reproduce the behavior:
- Set value of window option (TOTP Options) to 0.
- Restart your application. (I removed all node modules and re-installed them)
- generate and send otp using TOTP.
- Try verifying the otp using totp.check.
- It will return false, even when correct OTP is entered.
Expected behavior It should verify and allow the correct otp.
Screenshots If applicable, add screenshots to help explain your problem.
Details (please provide any relevant information):
My use Case I want to allow only latest OTP to be valid. for eg: a) I generated an otp which is valid for 5 mins. (assume it to be 1234) b) After a min I choose resend OTP option. (assume it to be 5678) c) now i have two otp valid for 3 to 4 more minutes. d) I want to allow only latest OTP as valid OTP. (only 5678 should be valid. 1234 should be invalid)
- otplib version: ^12.0.1
- os: linux
- browser: chrom/firefox
- node / yarn: node - 10.14.13
- frameworks (if any): loopback
Additional context Add any other context about the problem here.
@gargbhupinder by default, each OTP is only valid for 1 minute. Did you set the step option to allow for 5 minute intervals?
@yeojz Thanks for getting back.
Current Config Values step value was set to 30. value for window is 0.
Correct me if I am wrong
Should i set:
(I will get different OTP if i choose resend option after 30s. Each otp will be valid for 5 mins) Step = 30; window = 10;
OR
(I will get same OTP if i choose resend option within 5 min of interval. Otp will be valid for 5 mins) Step = 300 window = 0;
@yeojz Can you please help.
I want an OTP valid for 5 mins. If I resend OTP before 5 mins, only the latest OTP should be valid.
Can you please tell me the value for STEP and WINDOW options for the above scenario?