bellstrand/totp-generator

rounding epoch off can lead to totp for next cycle

Codeiffor opened this issue · 3 comments

epoch = Math.round(options.timestamp / 1000.0)

Here in the last 500 ms of current 30 second cycle (or any other period) the totp will be calculated for the next cycle due to rounded off epoch, Shouldn't it be Math.floor?

@Codeiffor You're totally correct.
We should probably write some unit-test with a fake timer and correct this!

@Codeiffor Published as v0.0.14!