We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
11.3.0
Seams like epoch is not taken into consideration when doing TOTP::expiresIn()
TOTP::expiresIn()
$clock = new MockClock('2025-02-24 15:10:33'); $now = $clock->now(); $totp = TOTP::generate($clock); $totp->setPeriod(1000); $totp->setEpoch($now->getTimestamp()); echo $totp->expiresIn()
This returns 167, but since i set the epoch to the current timestamp it should be 1000.
167
1000
The actual expiration is correct though.
$clock->sleep(999); echo $totp->verify($code) ? 'yes' : 'no'; $clock->sleep(1); echo $totp->verify($code) ? 'yes' : 'no';
This returns yes and no on the second echo.
yes
no
I think the correct expiresIn should be (?)
expiresIn
$totp->getPeriod() - (($clock->now()->getTimestamp() - $totp->getEpoch()) % $totp->getPeriod())
No response
The text was updated successfully, but these errors were encountered:
Hello @tomme87,
Indeed the returned value does not consider the epoc parameter. Would you mind to create a PR to fix this (with a test if possible)?
Many thanks. Regards.
Sorry, something went wrong.
Spomky
No branches or pull requests
Version(s) affected
11.3.0
Description
Seams like epoch is not taken into consideration when doing
TOTP::expiresIn()
How to reproduce
This returns
167
, but since i set the epoch to the current timestamp it should be1000
.The actual expiration is correct though.
This returns
yes
andno
on the second echo.Possible Solution
I think the correct
expiresIn
should be (?)Additional Context
No response
The text was updated successfully, but these errors were encountered: