mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 13:53:34 +00:00
[PM-26778] Make VaultTimeoutService use LogoutService (#16820)
* Make vaulttimeoutservice use logoutservice * Fix browser build * Fix mv3 build * Fix lint
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { firstValueFrom } from "rxjs";
|
||||
|
||||
import { LogoutService } from "@bitwarden/auth/common";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import {
|
||||
VaultTimeoutAction,
|
||||
@@ -8,6 +9,7 @@ import {
|
||||
VaultTimeoutStringType,
|
||||
} from "@bitwarden/common/key-management/vault-timeout";
|
||||
import { ServerNotificationsService } from "@bitwarden/common/platform/server-notifications";
|
||||
import { UserId } from "@bitwarden/user-core";
|
||||
|
||||
const IdleInterval = 60 * 5; // 5 minutes
|
||||
|
||||
@@ -21,6 +23,7 @@ export default class IdleBackground {
|
||||
private serverNotificationsService: ServerNotificationsService,
|
||||
private accountService: AccountService,
|
||||
private vaultTimeoutSettingsService: VaultTimeoutSettingsService,
|
||||
private logoutService: LogoutService,
|
||||
) {
|
||||
this.idle = chrome.idle || (browser != null ? browser.idle : null);
|
||||
}
|
||||
@@ -61,7 +64,7 @@ export default class IdleBackground {
|
||||
this.vaultTimeoutSettingsService.getVaultTimeoutActionByUserId$(userId),
|
||||
);
|
||||
if (action === VaultTimeoutAction.LogOut) {
|
||||
await this.vaultTimeoutService.logOut(userId);
|
||||
await this.logoutService.logout(userId as UserId, "vaultTimeout");
|
||||
} else {
|
||||
await this.vaultTimeoutService.lock(userId);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
AuthRequestServiceAbstraction,
|
||||
DefaultAuthRequestApiService,
|
||||
DefaultLockService,
|
||||
DefaultLogoutService,
|
||||
InternalUserDecryptionOptionsServiceAbstraction,
|
||||
LoginEmailServiceAbstraction,
|
||||
LogoutReason,
|
||||
@@ -976,6 +977,7 @@ export default class MainBackground {
|
||||
this.restrictedItemTypesService,
|
||||
);
|
||||
|
||||
const logoutService = new DefaultLogoutService(this.messagingService);
|
||||
this.vaultTimeoutService = new VaultTimeoutService(
|
||||
this.accountService,
|
||||
this.masterPasswordService,
|
||||
@@ -994,7 +996,7 @@ export default class MainBackground {
|
||||
this.logService,
|
||||
this.biometricsService,
|
||||
lockedCallback,
|
||||
logoutCallback,
|
||||
logoutService,
|
||||
);
|
||||
this.containerService = new ContainerService(this.keyService, this.encryptService);
|
||||
|
||||
@@ -1386,6 +1388,7 @@ export default class MainBackground {
|
||||
this.serverNotificationsService,
|
||||
this.accountService,
|
||||
this.vaultTimeoutSettingsService,
|
||||
logoutService,
|
||||
);
|
||||
|
||||
this.usernameGenerationService = legacyUsernameGenerationServiceFactory(
|
||||
|
||||
@@ -13,8 +13,4 @@ export class ForegroundVaultTimeoutService implements BaseVaultTimeoutService {
|
||||
async lock(userId?: UserId): Promise<void> {
|
||||
this.messagingService.send("lockVault", { userId });
|
||||
}
|
||||
|
||||
async logOut(userId?: string): Promise<void> {
|
||||
this.messagingService.send("logout", { userId });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user