Skip to content

Commit

Permalink
9.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorm committed May 5, 2024
1 parent ffeabc6 commit f4a5356
Show file tree
Hide file tree
Showing 19 changed files with 104 additions and 68 deletions.
15 changes: 12 additions & 3 deletions dist/otpauth.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@ const globalScope = (() => {
});
try {
// @ts-ignore
// eslint-disable-next-line no-undef
if (typeof __GLOBALTHIS__ !== "undefined") return __GLOBALTHIS__;
} finally {
// @ts-ignore
Expand Down Expand Up @@ -1253,7 +1254,7 @@ class HOTP {
// Return early if the token length does not match the digit number.
if (token.length !== digits) return null;
let delta = null;
for (let i = counter - window; i <= counter + window; ++i) {
const check = ( /** @type {number} */i) => {
const generatedToken = HOTP.generate({
secret,
algorithm,
Expand All @@ -1263,6 +1264,13 @@ class HOTP {
if (timingSafeEqual(token, generatedToken)) {
delta = i - counter;
}
};
check(counter);
for (let i = 1; i <= window && delta === null; ++i) {
check(counter - i);
if (delta !== null) break;
check(counter + i);
if (delta !== null) break;
}
return delta;
}
Expand Down Expand Up @@ -1538,7 +1546,8 @@ class URI {
let uriGroups;
try {
uriGroups = uri.match(OTPURI_REGEX);
} catch (error) {
// eslint-disable-next-line no-unused-vars
} catch (_) {
/* Handled below */
}
if (!Array.isArray(uriGroups)) {
Expand Down Expand Up @@ -1649,6 +1658,6 @@ class URI {
* Library version.
* @type {string}
*/
const version = "9.2.3";
const version = "9.2.4";

export { HOTP, Secret, TOTP, URI, version };
2 changes: 1 addition & 1 deletion dist/otpauth.esm.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/otpauth.esm.min.js.map

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions dist/otpauth.node.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const globalScope = (() => {
});
try {
// @ts-ignore
// eslint-disable-next-line no-undef
if (typeof __GLOBALTHIS__ !== "undefined") return __GLOBALTHIS__;
} finally {
// @ts-ignore
Expand Down Expand Up @@ -562,7 +563,7 @@ class HOTP {
// Return early if the token length does not match the digit number.
if (token.length !== digits) return null;
let delta = null;
for (let i = counter - window; i <= counter + window; ++i) {
const check = ( /** @type {number} */i) => {
const generatedToken = HOTP.generate({
secret,
algorithm,
Expand All @@ -572,6 +573,13 @@ class HOTP {
if (timingSafeEqual(token, generatedToken)) {
delta = i - counter;
}
};
check(counter);
for (let i = 1; i <= window && delta === null; ++i) {
check(counter - i);
if (delta !== null) break;
check(counter + i);
if (delta !== null) break;
}
return delta;
}
Expand Down Expand Up @@ -847,7 +855,8 @@ class URI {
let uriGroups;
try {
uriGroups = uri.match(OTPURI_REGEX);
} catch (error) {
// eslint-disable-next-line no-unused-vars
} catch (_) {
/* Handled below */
}
if (!Array.isArray(uriGroups)) {
Expand Down Expand Up @@ -958,7 +967,7 @@ class URI {
* Library version.
* @type {string}
*/
const version = "9.2.3";
const version = "9.2.4";

exports.HOTP = HOTP;
exports.Secret = Secret;
Expand Down
2 changes: 1 addition & 1 deletion dist/otpauth.node.min.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/otpauth.node.min.cjs.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/otpauth.node.min.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/otpauth.node.min.mjs.map

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions dist/otpauth.node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const globalScope = (() => {
});
try {
// @ts-ignore
// eslint-disable-next-line no-undef
if (typeof __GLOBALTHIS__ !== "undefined") return __GLOBALTHIS__;
} finally {
// @ts-ignore
Expand Down Expand Up @@ -541,7 +542,7 @@ class HOTP {
// Return early if the token length does not match the digit number.
if (token.length !== digits) return null;
let delta = null;
for (let i = counter - window; i <= counter + window; ++i) {
const check = ( /** @type {number} */i) => {
const generatedToken = HOTP.generate({
secret,
algorithm,
Expand All @@ -551,6 +552,13 @@ class HOTP {
if (timingSafeEqual(token, generatedToken)) {
delta = i - counter;
}
};
check(counter);
for (let i = 1; i <= window && delta === null; ++i) {
check(counter - i);
if (delta !== null) break;
check(counter + i);
if (delta !== null) break;
}
return delta;
}
Expand Down Expand Up @@ -826,7 +834,8 @@ class URI {
let uriGroups;
try {
uriGroups = uri.match(OTPURI_REGEX);
} catch (error) {
// eslint-disable-next-line no-unused-vars
} catch (_) {
/* Handled below */
}
if (!Array.isArray(uriGroups)) {
Expand Down Expand Up @@ -937,6 +946,6 @@ class URI {
* Library version.
* @type {string}
*/
const version = "9.2.3";
const version = "9.2.4";

export { HOTP, Secret, TOTP, URI, version };
15 changes: 12 additions & 3 deletions dist/otpauth.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,7 @@
});
try {
// @ts-ignore
// eslint-disable-next-line no-undef
if (typeof __GLOBALTHIS__ !== "undefined") return __GLOBALTHIS__;
} finally {
// @ts-ignore
Expand Down Expand Up @@ -1259,7 +1260,7 @@
// Return early if the token length does not match the digit number.
if (token.length !== digits) return null;
let delta = null;
for (let i = counter - window; i <= counter + window; ++i) {
const check = ( /** @type {number} */i) => {
const generatedToken = HOTP.generate({
secret,
algorithm,
Expand All @@ -1269,6 +1270,13 @@
if (timingSafeEqual(token, generatedToken)) {
delta = i - counter;
}
};
check(counter);
for (let i = 1; i <= window && delta === null; ++i) {
check(counter - i);
if (delta !== null) break;
check(counter + i);
if (delta !== null) break;
}
return delta;
}
Expand Down Expand Up @@ -1544,7 +1552,8 @@
let uriGroups;
try {
uriGroups = uri.match(OTPURI_REGEX);
} catch (error) {
// eslint-disable-next-line no-unused-vars
} catch (_) {
/* Handled below */
}
if (!Array.isArray(uriGroups)) {
Expand Down Expand Up @@ -1655,7 +1664,7 @@
* Library version.
* @type {string}
*/
const version = "9.2.3";
const version = "9.2.4";

exports.HOTP = HOTP;
exports.Secret = Secret;
Expand Down
2 changes: 1 addition & 1 deletion dist/otpauth.umd.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/otpauth.umd.min.js.map

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions docs/classes/HOTP.html

Large diffs are not rendered by default.

Loading

0 comments on commit f4a5356

Please sign in to comment.