1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-10 21:50:15 +00:00

Cleanup old class and interface

This commit is contained in:
Alec Rippberger
2025-03-03 11:15:31 -06:00
parent 29d3a4d18e
commit 62fb2cf8fc
3 changed files with 13 additions and 71 deletions

View File

@@ -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";

View File

@@ -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<boolean> {
return from(this.configService.getFeatureFlag(FeatureFlag.PM9115_TwoFactorFormPersistence));
}
async isEnabled(): Promise<boolean> {
return await this.configService.getFeatureFlag(FeatureFlag.PM9115_TwoFactorFormPersistence);
}
formData$(): Observable<TwoFactorFormData | null> {
return this.isEnabled$().pipe(
switchMap((enabled) => {
if (!enabled) {
return of(null);
}
return from(this.storageService.get<TwoFactorFormData>(STORAGE_KEY));
}),
);
}
async saveFormData(data: TwoFactorFormData): Promise<void> {
if (!(await this.isEnabled())) {
return;
}
await this.storageService.save(STORAGE_KEY, data);
}
async getFormData(): Promise<TwoFactorFormData | null> {
if (!(await this.isEnabled())) {
return null;
}
return await this.storageService.get<TwoFactorFormData>(STORAGE_KEY);
}
async clearFormData(): Promise<void> {
await this.storageService.remove(STORAGE_KEY);
}
}

View File

@@ -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