From 039aa31f7bfb6703f384385433831d0dd362e5a2 Mon Sep 17 00:00:00 2001 From: Rizwaan Bhikha Date: Tue, 1 Oct 2024 09:25:04 +0100 Subject: [PATCH 1/5] [FIX] OTP type is ignored --- src/models/otp.ts | 3 ++- src/models/storage.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/models/otp.ts b/src/models/otp.ts index cdfa38db..43f6dee2 100644 --- a/src/models/otp.ts +++ b/src/models/otp.ts @@ -3,7 +3,8 @@ import { UserSettings } from "./settings"; import { EntryStorage } from "./storage"; export enum OTPType { - totp = 1, + PLACEHOLDER_DO_NOT_USE, // https://github.com/Authenticator-Extension/Authenticator/pull/1283#issuecomment-2382842440 + totp, hotp, battle, steam, diff --git a/src/models/storage.ts b/src/models/storage.ts index 4b3699fb..84255a21 100644 --- a/src/models/storage.ts +++ b/src/models/storage.ts @@ -478,7 +478,7 @@ export class EntryStorage { algorithm: OTPAlgorithm; pinned: boolean; } = { - type: (parseInt(data[hash].type) as OTPType) || OTPType[OTPType.totp], + type: OTPType[data[hash].type as keyof typeof OTPType] || OTPType.totp, index: data[hash].index || 0, issuer: data[hash].issuer || "", account: data[hash].account || "", From f56defe11702b28086560361ec9140f747005dc9 Mon Sep 17 00:00:00 2001 From: Rizwaan Bhikha Date: Sat, 5 Oct 2024 12:11:04 +0100 Subject: [PATCH 2/5] Use `OTPType` enum everywhere --- src/background.ts | 10 +++++----- src/components/Popup/BackupPage.vue | 17 +++++++++-------- src/content.ts | 3 ++- src/import.ts | 9 +++++---- src/models/migration.ts | 5 +++-- src/models/storage.ts | 12 ++++++------ 6 files changed, 30 insertions(+), 26 deletions(-) diff --git a/src/background.ts b/src/background.ts index bb59a2f9..888f0ae3 100644 --- a/src/background.ts +++ b/src/background.ts @@ -8,7 +8,7 @@ import { getCurrentTab, okToInjectContentScript, } from "./utils"; -import { CodeState } from "./models/otp"; +import { CodeState, OTPType } from "./models/otp"; import { getOTPAuthPerLineFromOPTAuthMigration } from "./models/migration"; import { isChrome, isFirefox } from "./browser"; @@ -193,15 +193,15 @@ async function getTotp(text: string, silent = false) { if ( !/^[2-7a-z]+=*$/i.test(secret) && /^[0-9a-f]+$/i.test(secret) && - type === "totp" + type === OTPType[OTPType.totp] ) { - type = "hex"; + type = OTPType[OTPType.hex]; } else if ( !/^[2-7a-z]+=*$/i.test(secret) && /^[0-9a-f]+$/i.test(secret) && - type === "hotp" + type === OTPType[OTPType.hotp] ) { - type = "hhex"; + type = OTPType[OTPType.hhex]; } const entryData: { [hash: string]: RawOTPStorage } = {}; entryData[hash] = { diff --git a/src/components/Popup/BackupPage.vue b/src/components/Popup/BackupPage.vue index 8e718b46..0983e847 100644 --- a/src/components/Popup/BackupPage.vue +++ b/src/components/Popup/BackupPage.vue @@ -71,6 +71,7 @@