diff --git a/apps/desktop/src/auth/lock.component.ts b/apps/desktop/src/auth/lock.component.ts index 43e2b5fd07..df5f7b4238 100644 --- a/apps/desktop/src/auth/lock.component.ts +++ b/apps/desktop/src/auth/lock.component.ts @@ -1,6 +1,5 @@ import { Component, NgZone } from "@angular/core"; import { ActivatedRoute, Router } from "@angular/router"; -import { ipcRenderer } from "electron"; import { LockComponent as BaseLockComponent } from "@bitwarden/angular/auth/components/lock.component"; import { ApiService } from "@bitwarden/common/abstractions/api.service"; @@ -10,7 +9,7 @@ import { PolicyApiServiceAbstraction } from "@bitwarden/common/admin-console/abs import { InternalPolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction"; import { DeviceTrustCryptoServiceAbstraction } from "@bitwarden/common/auth/abstractions/device-trust-crypto.service.abstraction"; import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction"; -import { DeviceType, KeySuffixOptions } from "@bitwarden/common/enums"; +import { DeviceType } from "@bitwarden/common/enums"; import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service"; import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service"; import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service"; @@ -22,7 +21,6 @@ import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/pass import { DialogService } from "@bitwarden/components"; import { ElectronStateService } from "../platform/services/electron-state.service.abstraction"; -import { BiometricAction, BiometricMessage } from "../types/biometric-message"; const BroadcasterSubscriptionId = "LockComponent"; @@ -92,7 +90,7 @@ export class LockComponent extends BaseLockComponent { return; } - if (await ipcRenderer.invoke("windowVisible")) { + if (await ipc.platform.isWindowVisible()) { this.unlockBiometric(); } }, 1000); @@ -132,13 +130,7 @@ export class LockComponent extends BaseLockComponent { private async canUseBiometric() { const userId = await this.stateService.getUserId(); - const val = await ipcRenderer.invoke("biometric", { - action: BiometricAction.EnabledForUser, - key: `${userId}_user_biometric`, - keySuffix: KeySuffixOptions.Biometric, - userId: userId, - } as BiometricMessage); - return val != null ? (JSON.parse(val) as boolean) : null; + return await ipc.platform.biometric.enabled(userId); } private focusInput() { diff --git a/apps/desktop/src/platform/preload.ts b/apps/desktop/src/platform/preload.ts index b796543d85..d8781f1f4b 100644 --- a/apps/desktop/src/platform/preload.ts +++ b/apps/desktop/src/platform/preload.ts @@ -1,6 +1,6 @@ import { ipcRenderer } from "electron"; -import { DeviceType, ThemeType } from "@bitwarden/common/enums"; +import { DeviceType, ThemeType, KeySuffixOptions } from "@bitwarden/common/enums"; import { BiometricMessage, BiometricAction } from "../types/biometric-message"; import { isDev, isWindowsStore } from "../utils"; @@ -29,6 +29,13 @@ const passwords = { }; const biometric = { + enabled: (userId: string): Promise => + ipcRenderer.invoke("biometric", { + action: BiometricAction.EnabledForUser, + key: `${userId}_user_biometric`, + keySuffix: KeySuffixOptions.Biometric, + userId: userId, + } satisfies BiometricMessage), osSupported: (): Promise => ipcRenderer.invoke("biometric", { action: BiometricAction.OsSupported, @@ -58,6 +65,8 @@ export default { ipcRenderer.on("systemThemeUpdated", (_event, theme: ThemeType) => callback(theme)); }, + isWindowVisible: (): Promise => ipcRenderer.invoke("windowVisible"), + getLanguageFile: (formattedLocale: string): Promise => ipcRenderer.invoke("getLanguageFile", formattedLocale),