Skip to content

Commit 049521e

Browse files
committed
fix: change logic for calc timeout in totp generator
1 parent a5239d0 commit 049521e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libs/feature/two-factor/src/lib/two-factor.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class TwoFactorService {
3535
// Length of the generated tokens.
3636
digits: 6,
3737
// Interval of time for which a token is valid, in seconds.
38-
...(options.timeout ? { period: options.timeout / 1000 } : {}),
38+
...(options.timeout ? { period: Math.floor(options.timeout / 1000) } : {}),
3939
// Arbitrary key encoded in base32 or `OTPAuth.Secret` instance
4040
// (if omitted, a cryptographically secure random secret is generated).
4141
secret: OTPAuth.Secret.fromBase32(options.secret),
@@ -218,7 +218,7 @@ export class TwoFactorService {
218218
const tokenIsValid =
219219
totp.validate({
220220
token: options.code,
221-
window: timeout / 1000 / 30,
221+
window: 1,
222222
}) !== null;
223223

224224
if (!tokenIsValid) {

0 commit comments

Comments
 (0)