Skip to content

Commit 8ce1acb

Browse files
committed
fix(import): accept any positive-integer TOTP period
The otpauth importer rejected periods that were > 60 or not a divisor of 60, silently dropping valid values like 45, 90 or 120 and falling back to 30s, which produces wrong codes. Validate as a positive integer instead. Refs Authenticator-Extension#1271, Authenticator-Extension#1508
1 parent ac1501d commit 8ce1acb

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/import.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,10 @@ export async function getEntryDataFromOTPAuthPerLine(importCode: string) {
256256
parameter[0].toLowerCase() === "period"
257257
) {
258258
period = Number(parameter[1]);
259-
period =
260-
isNaN(period) || period < 0 || period > 60 || 60 % period !== 0
261-
? undefined
262-
: period;
259+
// accept any positive integer period; the old "> 60" / "60 % period"
260+
// checks silently dropped valid periods (45, 60, 90, 120...) so those
261+
// OTPs fell back to 30s and produced wrong codes (#1271, #1508)
262+
period = !Number.isInteger(period) || period < 1 ? undefined : period;
263263
} else if (parameter[0].toLowerCase() === "digits") {
264264
digits = Number(parameter[1]);
265265
digits = isNaN(digits) ? 6 : digits;

0 commit comments

Comments
 (0)