From 9279d0bf9feca69058217976489c833421b267f1 Mon Sep 17 00:00:00 2001 From: olfek <27283110+olfek@users.noreply.github.com> Date: Tue, 17 Sep 2024 00:58:57 +0100 Subject: [PATCH 1/6] [FIX] Seconds not properly prevented from being negative 0 - 61 + 60 < 0 59 - 120 + 60 < 0 https://github.com/Authenticator-Extension/Authenticator/blob/6511920bac98576e3c97fe2d213b23e9dc899422/src/store/Accounts.ts#L90 --- src/store/Accounts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/Accounts.ts b/src/store/Accounts.ts index 57f6a47e..1744802e 100644 --- a/src/store/Accounts.ts +++ b/src/store/Accounts.ts @@ -90,7 +90,7 @@ export class Accounts implements Module { second += Number(UserSettings.items.offset) + 60; } - second = second % 60; + second = (second < 0) ? (60 - (second * -1) % 60) : (second % 60); state.second = second; let currentlyEncrypted = false; From 9480784187d02986abb8a089cda99babc7c00624 Mon Sep 17 00:00:00 2001 From: olfek <27283110+olfek@users.noreply.github.com> Date: Tue, 17 Sep 2024 10:15:28 +0100 Subject: [PATCH 2/6] Remove the now redundant `+ 60` --- src/store/Accounts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/Accounts.ts b/src/store/Accounts.ts index 1744802e..55e2dd1c 100644 --- a/src/store/Accounts.ts +++ b/src/store/Accounts.ts @@ -87,7 +87,7 @@ export class Accounts implements Module { let second = new Date().getSeconds(); if (UserSettings.items.offset) { // prevent second from negative - second += Number(UserSettings.items.offset) + 60; + second += Number(UserSettings.items.offset); } second = (second < 0) ? (60 - (second * -1) % 60) : (second % 60); From 737ac3f2615552866f404060b41bd1d9e85a82c9 Mon Sep 17 00:00:00 2001 From: olfek <27283110+olfek@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:25:17 +0100 Subject: [PATCH 3/6] Move comment --- src/store/Accounts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/Accounts.ts b/src/store/Accounts.ts index 55e2dd1c..b7907b13 100644 --- a/src/store/Accounts.ts +++ b/src/store/Accounts.ts @@ -86,10 +86,10 @@ export class Accounts implements Module { updateCodes(state: AccountsState) { let second = new Date().getSeconds(); if (UserSettings.items.offset) { - // prevent second from negative second += Number(UserSettings.items.offset); } + // prevent second from negative second = (second < 0) ? (60 - (second * -1) % 60) : (second % 60); state.second = second; From 355f8b9c9d4696623ea930002309b4f011247f26 Mon Sep 17 00:00:00 2001 From: olfek <27283110+olfek@users.noreply.github.com> Date: Mon, 21 Oct 2024 01:50:58 +0100 Subject: [PATCH 4/6] verbose is king Co-authored-by: Brendan Early --- src/store/Accounts.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/store/Accounts.ts b/src/store/Accounts.ts index b7907b13..63f177aa 100644 --- a/src/store/Accounts.ts +++ b/src/store/Accounts.ts @@ -89,8 +89,12 @@ export class Accounts implements Module { second += Number(UserSettings.items.offset); } - // prevent second from negative - second = (second < 0) ? (60 - (second * -1) % 60) : (second % 60); + if (second < 0) { + // Handle the situation where offset causes `second` to be negative. #1310 + second = 60 - ((second * -1) % 60) + } else { + second = second % 60 + } state.second = second; let currentlyEncrypted = false; From a36b5d07e4864c521bc61f9ff79292e73de8ec16 Mon Sep 17 00:00:00 2001 From: Rizwaan Bhikha Date: Tue, 22 Oct 2024 12:52:50 +0100 Subject: [PATCH 5/6] .prettierignore --- .prettierignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..8eef1430 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +*.disabled \ No newline at end of file From 802f89a5a124d5b55cdea4a1a614e9a9498dd5ce Mon Sep 17 00:00:00 2001 From: Rizwaan Bhikha Date: Fri, 8 Nov 2024 14:28:28 +0000 Subject: [PATCH 6/6] prettier --- src/store/Accounts.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/store/Accounts.ts b/src/store/Accounts.ts index 63f177aa..e19e926a 100644 --- a/src/store/Accounts.ts +++ b/src/store/Accounts.ts @@ -90,10 +90,10 @@ export class Accounts implements Module { } if (second < 0) { - // Handle the situation where offset causes `second` to be negative. #1310 - second = 60 - ((second * -1) % 60) + // Handle the situation where offset causes `second` to be negative. #1310 + second = 60 - ((second * -1) % 60); } else { - second = second % 60 + second = second % 60; } state.second = second;