From 62fb2cf8fc2d6adcbd5a06ddea125967f419bea5 Mon Sep 17 00:00:00 2001 From: Alec Rippberger Date: Mon, 3 Mar 2025 11:15:31 -0600 Subject: [PATCH] Cleanup old class and interface --- ...extension-two-factor-form-cache.service.ts | 13 +++- .../two-factor-form-persistence.service.ts | 66 ------------------- .../src/popup/services/services.module.ts | 5 +- 3 files changed, 13 insertions(+), 71 deletions(-) delete mode 100644 apps/browser/src/auth/services/two-factor-form-persistence.service.ts diff --git a/apps/browser/src/auth/services/extension-two-factor-form-cache.service.ts b/apps/browser/src/auth/services/extension-two-factor-form-cache.service.ts index f86565742c9..dfc2b2a3f00 100644 --- a/apps/browser/src/auth/services/extension-two-factor-form-cache.service.ts +++ b/apps/browser/src/auth/services/extension-two-factor-form-cache.service.ts @@ -1,11 +1,20 @@ import { Observable, from, of, switchMap } from "rxjs"; -import { TwoFactorFormCacheServiceAbstraction, TwoFactorFormData } from "@bitwarden/auth/angular"; +import { TwoFactorFormCacheServiceAbstraction } from "@bitwarden/auth/angular"; +import { TwoFactorProviderType } from "@bitwarden/common/auth/enums/two-factor-provider-type"; import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { AbstractStorageService } from "@bitwarden/common/platform/abstractions/storage.service"; - +/** + * Interface for two-factor form data + */ +interface TwoFactorFormData { + token?: string; + remember?: boolean; + selectedProviderType?: TwoFactorProviderType; + emailSent?: boolean; +} const STORAGE_KEY = "twoFactorFormData"; diff --git a/apps/browser/src/auth/services/two-factor-form-persistence.service.ts b/apps/browser/src/auth/services/two-factor-form-persistence.service.ts deleted file mode 100644 index 5ae95d719b8..00000000000 --- a/apps/browser/src/auth/services/two-factor-form-persistence.service.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { Injectable } from "@angular/core"; -import { Observable, from, of, switchMap } from "rxjs"; - -import { TwoFactorProviderType } from "@bitwarden/common/auth/enums/two-factor-provider-type"; -import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; -import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; -import { AbstractStorageService } from "@bitwarden/common/platform/abstractions/storage.service"; - - -export interface TwoFactorFormData { - token?: string; - remember?: boolean; - selectedProviderType?: TwoFactorProviderType; - emailSent?: boolean; -} - -const STORAGE_KEY = "twoFactorFormData"; - -@Injectable({ - providedIn: "root", -}) -export class ExtensionTwoFactorFormCacheService { - constructor( - private storageService: AbstractStorageService, - private configService: ConfigService, - ) {} - - isEnabled$(): Observable { - return from(this.configService.getFeatureFlag(FeatureFlag.PM9115_TwoFactorFormPersistence)); - } - - async isEnabled(): Promise { - return await this.configService.getFeatureFlag(FeatureFlag.PM9115_TwoFactorFormPersistence); - } - - formData$(): Observable { - return this.isEnabled$().pipe( - switchMap((enabled) => { - if (!enabled) { - return of(null); - } - return from(this.storageService.get(STORAGE_KEY)); - }), - ); - } - - async saveFormData(data: TwoFactorFormData): Promise { - if (!(await this.isEnabled())) { - return; - } - - await this.storageService.save(STORAGE_KEY, data); - } - - async getFormData(): Promise { - if (!(await this.isEnabled())) { - return null; - } - - return await this.storageService.get(STORAGE_KEY); - } - - async clearFormData(): Promise { - await this.storageService.remove(STORAGE_KEY); - } -} diff --git a/apps/browser/src/popup/services/services.module.ts b/apps/browser/src/popup/services/services.module.ts index 07dc4e71e1f..b7c3530b3bb 100644 --- a/apps/browser/src/popup/services/services.module.ts +++ b/apps/browser/src/popup/services/services.module.ts @@ -31,7 +31,7 @@ import { TwoFactorAuthDuoComponentService, TwoFactorAuthWebAuthnComponentService, SsoComponentService, -} from "@bitwarden/auth/angular"; + TwoFactorFormCacheServiceAbstraction } from "@bitwarden/auth/angular"; import { LockService, LoginEmailService, @@ -138,6 +138,7 @@ import { ExtensionTwoFactorAuthComponentService } from "../../auth/services/exte import { ExtensionTwoFactorAuthDuoComponentService } from "../../auth/services/extension-two-factor-auth-duo-component.service"; import { ExtensionTwoFactorAuthEmailComponentService } from "../../auth/services/extension-two-factor-auth-email-component.service"; import { ExtensionTwoFactorAuthWebAuthnComponentService } from "../../auth/services/extension-two-factor-auth-webauthn-component.service"; +import { ExtensionTwoFactorFormCacheService } from "../../auth/services/extension-two-factor-form-cache.service"; import { AutofillService as AutofillServiceAbstraction } from "../../autofill/services/abstractions/autofill.service"; import AutofillService from "../../autofill/services/autofill.service"; import { InlineMenuFieldQualificationService } from "../../autofill/services/inline-menu-field-qualification.service"; @@ -176,8 +177,6 @@ import { VaultFilterService } from "../../vault/services/vault-filter.service"; import { DebounceNavigationService } from "./debounce-navigation.service"; import { InitService } from "./init.service"; import { PopupCloseWarningService } from "./popup-close-warning.service"; -import { TwoFactorFormCacheServiceAbstraction } from "@bitwarden/auth/angular"; -import { ExtensionTwoFactorFormCacheService } from "../../auth/services/extension-two-factor-form-cache.service"; const OBSERVABLE_LARGE_OBJECT_MEMORY_STORAGE = new SafeInjectionToken< AbstractStorageService & ObservableStorageService