1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-10 13:40:06 +00:00

Add web and desktop noop cache services

This commit is contained in:
Alec Rippberger
2025-03-05 12:31:54 -06:00
parent 1e86220e3c
commit d9d910325a
7 changed files with 81 additions and 0 deletions

View File

@@ -27,6 +27,7 @@ import {
SsoComponentService,
DefaultSsoComponentService,
TwoFactorAuthDuoComponentService,
TwoFactorFormCacheService,
} from "@bitwarden/auth/angular";
import {
InternalUserDecryptionOptionsServiceAbstraction,
@@ -107,6 +108,7 @@ import { LockComponentService } from "@bitwarden/key-management-ui";
import { DesktopLoginApprovalComponentService } from "../../auth/login/desktop-login-approval-component.service";
import { DesktopLoginComponentService } from "../../auth/login/desktop-login-component.service";
import { DesktopTwoFactorAuthDuoComponentService } from "../../auth/services/desktop-two-factor-auth-duo-component.service";
import { DesktopTwoFactorFormCacheService } from "../../auth/services/desktop-two-factor-form-cache.service";
import { DesktopAutofillSettingsService } from "../../autofill/services/desktop-autofill-settings.service";
import { DesktopAutofillService } from "../../autofill/services/desktop-autofill.service";
import { DesktopFido2UserInterfaceService } from "../../autofill/services/desktop-fido2-user-interface.service";
@@ -412,6 +414,11 @@ const safeProviders: SafeProvider[] = [
PlatformUtilsServiceAbstraction,
],
}),
safeProvider({
provide: TwoFactorFormCacheService,
useClass: DesktopTwoFactorFormCacheService,
deps: [],
}),
safeProvider({
provide: SdkClientFactory,
useClass: flagEnabled("sdk") ? DefaultSdkClientFactory : NoopSdkClientFactory,

View File

@@ -0,0 +1,30 @@
import { Injectable } from "@angular/core";
import { Observable, of } from "rxjs";
import { TwoFactorFormCacheService, TwoFactorFormData } from "@bitwarden/auth/angular";
/**
* No-op implementation of TwoFactorFormCacheService for desktop
*/
@Injectable()
export class DesktopTwoFactorFormCacheService extends TwoFactorFormCacheService {
constructor() {
super();
}
isEnabled$(): Observable<boolean> {
return of(false);
}
formData$(): Observable<TwoFactorFormData | null> {
return of(null);
}
async saveFormData(): Promise<void> {
// No-op
}
async clearFormData(): Promise<void> {
// No-op
}
}

View File

@@ -29,6 +29,7 @@ import { StateService } from "@bitwarden/common/platform/abstractions/state.serv
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { ToastService } from "@bitwarden/components";
import { DesktopTwoFactorFormCacheService } from "./services/desktop-two-factor-form-cache.service";
import { TwoFactorOptionsComponentV1 } from "./two-factor-options-v1.component";
const BroadcasterSubscriptionId = "TwoFactorComponent";
@@ -69,6 +70,7 @@ export class TwoFactorComponentV1 extends BaseTwoFactorComponent implements OnDe
accountService: AccountService,
toastService: ToastService,
@Inject(WINDOW) protected win: Window,
twoFactorFormCacheService: DesktopTwoFactorFormCacheService,
) {
super(
loginStrategyService,
@@ -90,6 +92,7 @@ export class TwoFactorComponentV1 extends BaseTwoFactorComponent implements OnDe
masterPasswordService,
accountService,
toastService,
twoFactorFormCacheService,
);
this.onSuccessfulLogin = async () => {
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.

View File

@@ -1,2 +1,3 @@
export * from "./web-two-factor-auth-component.service";
export * from "./web-two-factor-auth-duo-component.service";
export * from "./web-two-factor-form-cache.service";

View File

@@ -0,0 +1,30 @@
import { Injectable } from "@angular/core";
import { Observable, of } from "rxjs";
import { TwoFactorFormCacheService, TwoFactorFormData } from "@bitwarden/auth/angular";
/**
* No-op implementation of TwoFactorFormCacheService for web app
*/
@Injectable()
export class WebTwoFactorFormCacheService extends TwoFactorFormCacheService {
constructor() {
super();
}
isEnabled$(): Observable<boolean> {
return of(false);
}
formData$(): Observable<TwoFactorFormData | null> {
return of(null);
}
async saveFormData(): Promise<void> {
// No-op
}
async clearFormData(): Promise<void> {
// No-op
}
}

View File

@@ -7,6 +7,7 @@ import { Subject, takeUntil, lastValueFrom } from "rxjs";
import { TwoFactorComponentV1 as BaseTwoFactorComponent } from "@bitwarden/angular/auth/components/two-factor-v1.component";
import { WINDOW } from "@bitwarden/angular/services/injection-tokens";
import { TwoFactorFormCacheService } from "@bitwarden/auth/angular";
import {
LoginStrategyServiceAbstraction,
LoginEmailServiceAbstraction,
@@ -74,6 +75,7 @@ export class TwoFactorComponentV1 extends BaseTwoFactorComponent implements OnIn
toastService: ToastService,
private formBuilder: FormBuilder,
@Inject(WINDOW) protected win: Window,
twoFactorFormCacheService: TwoFactorFormCacheService,
) {
super(
loginStrategyService,
@@ -95,6 +97,7 @@ export class TwoFactorComponentV1 extends BaseTwoFactorComponent implements OnIn
masterPasswordService,
accountService,
toastService,
twoFactorFormCacheService,
);
this.onSuccessfulLoginNavigate = this.goAfterLogIn;
}

View File

@@ -35,6 +35,7 @@ import {
LoginDecryptionOptionsService,
TwoFactorAuthComponentService,
TwoFactorAuthDuoComponentService,
TwoFactorFormCacheService,
} from "@bitwarden/auth/angular";
import {
InternalUserDecryptionOptionsServiceAbstraction,
@@ -117,6 +118,7 @@ import {
WebTwoFactorAuthDuoComponentService,
} from "../auth";
import { WebSsoComponentService } from "../auth/core/services/login/web-sso-component.service";
import { WebTwoFactorFormCacheService } from "../auth/core/services/two-factor-auth/web-two-factor-form-cache.service";
import { AcceptOrganizationInviteService } from "../auth/organization-invite/accept-organization.service";
import { HtmlStorageService } from "../core/html-storage.service";
import { I18nService } from "../core/i18n.service";
@@ -274,6 +276,11 @@ const safeProviders: SafeProvider[] = [
useClass: WebTwoFactorAuthComponentService,
deps: [],
}),
safeProvider({
provide: TwoFactorFormCacheService,
useClass: WebTwoFactorFormCacheService,
deps: [],
}),
safeProvider({
provide: SetPasswordJitService,
useClass: WebSetPasswordJitService,