mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-24 12:06:15 +01:00
[PM-3681] Remove ipcRenderer from lock.component (#6479)
* [PM-3681] Remove ipcRenderer from lock.component * Break out biometric method into two separate functions
This commit is contained in:
parent
ffd08a6d6d
commit
aae9bdd586
@ -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() {
|
||||
|
@ -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<boolean> =>
|
||||
ipcRenderer.invoke("biometric", {
|
||||
action: BiometricAction.EnabledForUser,
|
||||
key: `${userId}_user_biometric`,
|
||||
keySuffix: KeySuffixOptions.Biometric,
|
||||
userId: userId,
|
||||
} satisfies BiometricMessage),
|
||||
osSupported: (): Promise<boolean> =>
|
||||
ipcRenderer.invoke("biometric", {
|
||||
action: BiometricAction.OsSupported,
|
||||
@ -58,6 +65,8 @@ export default {
|
||||
ipcRenderer.on("systemThemeUpdated", (_event, theme: ThemeType) => callback(theme));
|
||||
},
|
||||
|
||||
isWindowVisible: (): Promise<boolean> => ipcRenderer.invoke("windowVisible"),
|
||||
|
||||
getLanguageFile: (formattedLocale: string): Promise<object> =>
|
||||
ipcRenderer.invoke("getLanguageFile", formattedLocale),
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user