mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +00:00
[PM-25206] Inject service instead of passing as param (#16801)
* Inject service instead of passing as param * [PM-25206] Move locking logic to LockService (#16802) * Move locking logic to lock service * Fix tests * Fix CLI * Fix test * FIx safari build * Update call to lock service * Remove locked callback * Clean up lock service logic * Add tests * Fix cli build * Add extension lock service * Fix cli build * Fix build * Undo ac changes * Undo ac changes * Run prettier * Fix build * Remove duplicate call * [PM-25206] Remove VaultTimeoutService lock logic (#16804) * Move consumers off of vaulttimeoutsettingsservice lock * Fix build * Fix build * Fix build * Fix firefox build * Fix test * Fix ts strict errors * Fix ts strict error * Undo AC changes * Cleanup * Fix * Fix missing service
This commit is contained in:
@@ -8,6 +8,7 @@ import { Subject, filter, firstValueFrom, map, timeout } from "rxjs";
|
||||
import { CollectionService } from "@bitwarden/admin-console/common";
|
||||
import { DeviceTrustToastService } from "@bitwarden/angular/auth/services/device-trust-toast.service.abstraction";
|
||||
import { DocumentLangSetter } from "@bitwarden/angular/platform/i18n";
|
||||
import { LockService } from "@bitwarden/auth/common";
|
||||
import { EventUploadService } from "@bitwarden/common/abstractions/event/event-upload.service";
|
||||
import { InternalOrganizationServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
@@ -16,7 +17,6 @@ import { TokenService } from "@bitwarden/common/auth/abstractions/token.service"
|
||||
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||
import { ProcessReloadServiceAbstraction } from "@bitwarden/common/key-management/abstractions/process-reload.service";
|
||||
import { VaultTimeoutService } from "@bitwarden/common/key-management/vault-timeout";
|
||||
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
@@ -58,8 +58,8 @@ export class AppComponent implements OnDestroy, OnInit {
|
||||
private i18nService: I18nService,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private ngZone: NgZone,
|
||||
private vaultTimeoutService: VaultTimeoutService,
|
||||
private keyService: KeyService,
|
||||
private lockService: LockService,
|
||||
private collectionService: CollectionService,
|
||||
private searchService: SearchService,
|
||||
private serverNotificationsService: ServerNotificationsService,
|
||||
@@ -113,11 +113,13 @@ export class AppComponent implements OnDestroy, OnInit {
|
||||
// note: the message.logoutReason isn't consumed anymore because of the process reload clearing any toasts.
|
||||
await this.logOut(message.redirect);
|
||||
break;
|
||||
case "lockVault":
|
||||
await this.vaultTimeoutService.lock();
|
||||
case "lockVault": {
|
||||
const userId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
|
||||
await this.lockService.lock(userId);
|
||||
break;
|
||||
}
|
||||
case "locked":
|
||||
await this.processReloadService.startProcessReload(this.authService);
|
||||
await this.processReloadService.startProcessReload();
|
||||
break;
|
||||
case "lockedUrl":
|
||||
break;
|
||||
@@ -267,7 +269,7 @@ export class AppComponent implements OnDestroy, OnInit {
|
||||
await this.router.navigate(["/"]);
|
||||
}
|
||||
|
||||
await this.processReloadService.startProcessReload(this.authService);
|
||||
await this.processReloadService.startProcessReload();
|
||||
|
||||
// Normally we would need to reset the loading state to false or remove the layout_frontend
|
||||
// class from the body here, but the process reload completely reloads the app so
|
||||
|
||||
@@ -80,6 +80,7 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
|
||||
import { SdkClientFactory } from "@bitwarden/common/platform/abstractions/sdk/sdk-client-factory";
|
||||
import { SdkLoadService } from "@bitwarden/common/platform/abstractions/sdk/sdk-load.service";
|
||||
import { AbstractStorageService } from "@bitwarden/common/platform/abstractions/storage.service";
|
||||
import { SystemService } from "@bitwarden/common/platform/abstractions/system.service";
|
||||
import { IpcService } from "@bitwarden/common/platform/ipc";
|
||||
// eslint-disable-next-line no-restricted-imports -- Needed for DI
|
||||
import {
|
||||
@@ -143,6 +144,7 @@ import { WebEnvironmentService } from "../platform/web-environment.service";
|
||||
import { WebMigrationRunner } from "../platform/web-migration-runner";
|
||||
import { WebSdkLoadService } from "../platform/web-sdk-load.service";
|
||||
import { WebStorageServiceProvider } from "../platform/web-storage-service.provider";
|
||||
import { WebSystemService } from "../platform/web-system.service";
|
||||
|
||||
import { EventService } from "./event.service";
|
||||
import { InitService } from "./init.service";
|
||||
@@ -428,6 +430,11 @@ const safeProviders: SafeProvider[] = [
|
||||
useClass: WebPremiumInterestStateService,
|
||||
deps: [StateProvider],
|
||||
}),
|
||||
safeProvider({
|
||||
provide: SystemService,
|
||||
useClass: WebSystemService,
|
||||
deps: [],
|
||||
}),
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
||||
import { ProcessReloadServiceAbstraction } from "@bitwarden/common/key-management/abstractions/process-reload.service";
|
||||
|
||||
export class WebProcessReloadService implements ProcessReloadServiceAbstraction {
|
||||
constructor(private window: Window) {}
|
||||
|
||||
async startProcessReload(authService: AuthService): Promise<void> {
|
||||
async startProcessReload(): Promise<void> {
|
||||
this.window.location.reload();
|
||||
}
|
||||
|
||||
|
||||
10
apps/web/src/app/platform/web-system.service.ts
Normal file
10
apps/web/src/app/platform/web-system.service.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { SystemService } from "@bitwarden/common/platform/abstractions/system.service";
|
||||
|
||||
/**
|
||||
* Web implementation of SystemService.
|
||||
* The implementation is NOOP since these functions are not supported on web.
|
||||
*/
|
||||
export class WebSystemService extends SystemService {
|
||||
async clearClipboard(clipboardValue: string, timeoutMs?: number): Promise<void> {}
|
||||
async clearPendingClipboard(): Promise<any> {}
|
||||
}
|
||||
Reference in New Issue
Block a user