diff --git a/apps/browser/src/background/main.background.ts b/apps/browser/src/background/main.background.ts index 011c4e9b3dd5..617acc2bf788 100644 --- a/apps/browser/src/background/main.background.ts +++ b/apps/browser/src/background/main.background.ts @@ -9,7 +9,6 @@ import { SearchService as SearchServiceAbstraction } from "@bitwarden/common/abs import { SettingsService as SettingsServiceAbstraction } from "@bitwarden/common/abstractions/settings.service"; import { TotpService as TotpServiceAbstraction } from "@bitwarden/common/abstractions/totp.service"; import { VaultTimeoutSettingsService as VaultTimeoutSettingsServiceAbstraction } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout-settings.service"; -import { VaultTimeoutService as VaultTimeoutServiceAbstraction } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout.service"; import { InternalOrganizationServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; import { PolicyApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/policy/policy-api.service.abstraction"; import { InternalPolicyService as InternalPolicyServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction"; @@ -164,7 +163,7 @@ export default class MainBackground { cipherService: CipherServiceAbstraction; folderService: InternalFolderServiceAbstraction; collectionService: CollectionServiceAbstraction; - vaultTimeoutService: VaultTimeoutServiceAbstraction; + vaultTimeoutService: VaultTimeoutService; vaultTimeoutSettingsService: VaultTimeoutSettingsServiceAbstraction; syncService: SyncServiceAbstraction; passwordGenerationService: PasswordGenerationServiceAbstraction; @@ -436,6 +435,15 @@ export default class MainBackground { this.authRequestCryptoService ); + this.userVerificationApiService = new UserVerificationApiService(this.apiService); + + this.userVerificationService = new UserVerificationService( + this.stateService, + this.cryptoService, + this.i18nService, + this.userVerificationApiService + ); + this.vaultTimeoutSettingsService = new VaultTimeoutSettingsService( this.cryptoService, this.tokenService, @@ -503,15 +511,6 @@ export default class MainBackground { ); this.totpService = new TotpService(this.cryptoFunctionService, this.logService); - this.userVerificationApiService = new UserVerificationApiService(this.apiService); - - this.userVerificationService = new UserVerificationService( - this.stateService, - this.cryptoService, - this.i18nService, - this.userVerificationApiService - ); - this.autofillService = new AutofillService( this.cipherService, this.stateService, @@ -682,7 +681,7 @@ export default class MainBackground { await this.stateService.init(); - await (this.vaultTimeoutService as VaultTimeoutService).init(true); + await this.vaultTimeoutService.init(true); await (this.i18nService as BrowserI18nService).init(); await (this.eventUploadService as EventUploadService).init(true); await this.runtimeBackground.init(); diff --git a/apps/cli/src/bw.ts b/apps/cli/src/bw.ts index 4c6ad6fec520..1bcaa1a2acf6 100644 --- a/apps/cli/src/bw.ts +++ b/apps/cli/src/bw.ts @@ -358,7 +358,7 @@ export class Main { this.authRequestCryptoService ); - const lockedCallback = async () => + const lockedCallback = async (userId?: string) => await this.cryptoService.clearStoredUserKey(KeySuffixOptions.Auto); this.userVerificationService = new UserVerificationService( diff --git a/apps/web/src/app/core/init.service.ts b/apps/web/src/app/core/init.service.ts index 8fce0350bdc2..3437c4f3e937 100644 --- a/apps/web/src/app/core/init.service.ts +++ b/apps/web/src/app/core/init.service.ts @@ -4,7 +4,6 @@ import { WINDOW } from "@bitwarden/angular/services/injection-tokens"; import { AbstractThemingService } from "@bitwarden/angular/services/theming/theming.service.abstraction"; import { EventUploadService as EventUploadServiceAbstraction } from "@bitwarden/common/abstractions/event/event-upload.service"; import { NotificationsService as NotificationsServiceAbstraction } from "@bitwarden/common/abstractions/notifications.service"; -import { VaultTimeoutService as VaultTimeoutServiceAbstraction } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout.service"; import { TwoFactorService as TwoFactorServiceAbstraction } from "@bitwarden/common/auth/abstractions/two-factor.service"; import { CryptoService as CryptoServiceAbstraction } from "@bitwarden/common/platform/abstractions/crypto.service"; import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service"; @@ -16,7 +15,7 @@ import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/platfor import { StateService as StateServiceAbstraction } from "@bitwarden/common/platform/abstractions/state.service"; import { ContainerService } from "@bitwarden/common/platform/services/container.service"; import { EventUploadService } from "@bitwarden/common/services/event/event-upload.service"; -import { VaultTimeoutService as VaultTimeoutService } from "@bitwarden/common/services/vault-timeout/vault-timeout.service"; +import { VaultTimeoutService } from "@bitwarden/common/services/vault-timeout/vault-timeout.service"; import { I18nService } from "../core/i18n.service"; @@ -26,7 +25,7 @@ export class InitService { @Inject(WINDOW) private win: Window, private environmentService: EnvironmentServiceAbstraction, private notificationsService: NotificationsServiceAbstraction, - private vaultTimeoutService: VaultTimeoutServiceAbstraction, + private vaultTimeoutService: VaultTimeoutService, private i18nService: I18nServiceAbstraction, private eventUploadService: EventUploadServiceAbstraction, private twoFactorService: TwoFactorServiceAbstraction, @@ -48,7 +47,7 @@ export class InitService { this.environmentService.initialized = true; setTimeout(() => this.notificationsService.init(), 3000); - await (this.vaultTimeoutService as VaultTimeoutService).init(true); + await this.vaultTimeoutService.init(true); const locale = await this.stateService.getLocale(); await (this.i18nService as I18nService).init(locale); (this.eventUploadService as EventUploadService).init(true); diff --git a/libs/angular/src/services/injection-tokens.ts b/libs/angular/src/services/injection-tokens.ts index 270a5dfdf0c7..b87b239e1622 100644 --- a/libs/angular/src/services/injection-tokens.ts +++ b/libs/angular/src/services/injection-tokens.ts @@ -11,10 +11,12 @@ export const MEMORY_STORAGE = new InjectionToken(" export const SECURE_STORAGE = new InjectionToken("SECURE_STORAGE"); export const STATE_FACTORY = new InjectionToken("STATE_FACTORY"); export const STATE_SERVICE_USE_CACHE = new InjectionToken("STATE_SERVICE_USE_CACHE"); -export const LOGOUT_CALLBACK = new InjectionToken<(expired: boolean, userId?: string) => void>( - "LOGOUT_CALLBACK" +export const LOGOUT_CALLBACK = new InjectionToken< + (expired: boolean, userId?: string) => Promise +>("LOGOUT_CALLBACK"); +export const LOCKED_CALLBACK = new InjectionToken<(userId?: string) => Promise>( + "LOCKED_CALLBACK" ); -export const LOCKED_CALLBACK = new InjectionToken<() => void>("LOCKED_CALLBACK"); export const CLIENT_TYPE = new InjectionToken("CLIENT_TYPE"); export const LOCALES_DIRECTORY = new InjectionToken("LOCALES_DIRECTORY"); export const SYSTEM_LANGUAGE = new InjectionToken("SYSTEM_LANGUAGE"); diff --git a/libs/angular/src/services/jslib-services.module.ts b/libs/angular/src/services/jslib-services.module.ts index b5574b69fd0a..e292617a90b5 100644 --- a/libs/angular/src/services/jslib-services.module.ts +++ b/libs/angular/src/services/jslib-services.module.ts @@ -463,8 +463,8 @@ import { AbstractThemingService } from "./theming/theming.service.abstraction"; stateService: StateServiceAbstraction, authService: AuthServiceAbstraction, vaultTimeoutSettingsService: VaultTimeoutSettingsServiceAbstraction, - lockedCallback: any, - logoutCallback: any + lockedCallback: (userId?: string) => Promise, + logoutCallback: (expired: boolean, userId?: string) => Promise ) => { return new VaultTimeoutService( cipherService,