diff --git a/apps/desktop/src/key-management/biometrics/os-biometrics-linux.service.ts b/apps/desktop/src/key-management/biometrics/os-biometrics-linux.service.ts index 71bbcb3e976..a93e7593070 100644 --- a/apps/desktop/src/key-management/biometrics/os-biometrics-linux.service.ts +++ b/apps/desktop/src/key-management/biometrics/os-biometrics-linux.service.ts @@ -2,7 +2,7 @@ import { spawn } from "child_process"; import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key"; import { UserId } from "@bitwarden/common/types/guid"; -import { biometrics, biometrics_v2, passwords } from "@bitwarden/desktop-napi"; +import { biometrics, passwords } from "@bitwarden/desktop-napi"; import { BiometricsStatus } from "@bitwarden/key-management"; import { isFlatpak, isLinux, isSnapStore } from "../../utils"; @@ -29,27 +29,25 @@ const policyFileName = "com.bitwarden.Bitwarden.policy"; const policyPath = "/usr/share/polkit-1/actions/"; export default class OsBiometricsServiceLinux implements OsBiometricService { - private biometricsSystem = biometrics_v2.initBiometricSystem(); + private biometricsSystem = biometrics.initBiometricSystem(); constructor() {} async setBiometricKey(userId: UserId, key: SymmetricCryptoKey): Promise { - await biometrics_v2.provideKey( - this.biometricsSystem, - userId, - Buffer.from(key.toEncoded().buffer), - ); + await biometrics.provideKey(this.biometricsSystem, userId, Buffer.from(key.toEncoded().buffer)); } - async deleteBiometricKey(userId: UserId): Promise {} + async deleteBiometricKey(userId: UserId): Promise { + await biometrics.unenroll(this.biometricsSystem, userId); + } async getBiometricKey(userId: UserId): Promise { - const result = await biometrics_v2.unlock(this.biometricsSystem, userId, Buffer.from("")); + const result = await biometrics.unlock(this.biometricsSystem, userId, Buffer.from("")); return result ? new SymmetricCryptoKey(Uint8Array.from(result)) : null; } async authenticateBiometric(): Promise { - return await biometrics_v2.authenticate( + return await biometrics.authenticate( this.biometricsSystem, Buffer.from(""), "Authenticate to unlock", @@ -72,7 +70,7 @@ export default class OsBiometricsServiceLinux implements OsBiometricService { } // check whether the polkit policy is loaded via dbus call to polkit - return !(await biometrics.available()); + return !(await biometrics.authenticateAvailable(this.biometricsSystem)); } async canAutoSetup(): Promise { @@ -102,7 +100,7 @@ export default class OsBiometricsServiceLinux implements OsBiometricService { } async getBiometricsFirstUnlockStatusForUser(userId: UserId): Promise { - return (await biometrics_v2.unlockAvailable(this.biometricsSystem, userId)) + return (await biometrics.unlockAvailable(this.biometricsSystem, userId)) ? BiometricsStatus.Available : BiometricsStatus.UnlockNeeded; } diff --git a/apps/desktop/src/key-management/biometrics/os-biometrics-windows.service.ts b/apps/desktop/src/key-management/biometrics/os-biometrics-windows.service.ts index 5a8390f5844..41f2a8eca3c 100644 --- a/apps/desktop/src/key-management/biometrics/os-biometrics-windows.service.ts +++ b/apps/desktop/src/key-management/biometrics/os-biometrics-windows.service.ts @@ -1,7 +1,7 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key"; import { UserId } from "@bitwarden/common/types/guid"; -import { biometrics, biometrics_v2 } from "@bitwarden/desktop-napi"; +import { biometrics } from "@bitwarden/desktop-napi"; import { BiometricsStatus } from "@bitwarden/key-management"; import { WindowMain } from "../../main/window.main"; @@ -9,7 +9,7 @@ import { WindowMain } from "../../main/window.main"; import { OsBiometricService } from "./os-biometrics.service"; export default class OsBiometricsServiceWindows implements OsBiometricService { - private biometricsSystem = biometrics_v2.initBiometricSystem(); + private biometricsSystem = biometrics.initBiometricSystem(); constructor( private i18nService: I18nService, @@ -17,11 +17,11 @@ export default class OsBiometricsServiceWindows implements OsBiometricService { ) {} async supportsBiometrics(): Promise { - return await biometrics_v2.authenticateAvailable(this.biometricsSystem); + return await biometrics.authenticateAvailable(this.biometricsSystem); } async getBiometricKey(userId: UserId): Promise { - const key = await biometrics_v2.unlock( + const key = await biometrics.unlock( this.biometricsSystem, userId, this.windowMain.win.getNativeWindowHandle(), @@ -30,20 +30,16 @@ export default class OsBiometricsServiceWindows implements OsBiometricService { } async setBiometricKey(userId: UserId, key: SymmetricCryptoKey): Promise { - await biometrics_v2.provideKey( - this.biometricsSystem, - userId, - Buffer.from(key.toEncoded().buffer), - ); + await biometrics.provideKey(this.biometricsSystem, userId, Buffer.from(key.toEncoded().buffer)); } async deleteBiometricKey(userId: UserId): Promise { - await biometrics_v2.unenroll(this.biometricsSystem, userId); + await biometrics.unenroll(this.biometricsSystem, userId); } async authenticateBiometric(): Promise { const hwnd = this.windowMain.win.getNativeWindowHandle(); - return await biometrics_v2.authenticate( + return await biometrics.authenticate( this.biometricsSystem, hwnd, this.i18nService.t("windowsHelloConsentMessage"), @@ -61,6 +57,9 @@ export default class OsBiometricsServiceWindows implements OsBiometricService { async runSetup(): Promise {} async getBiometricsFirstUnlockStatusForUser(userId: UserId): Promise { - return (await biometrics_v2.hasPersistent(this.biometricsSystem, userId) || await biometrics_v2.unlockAvailable(this.biometricsSystem, userId)) ? BiometricsStatus.Available : BiometricsStatus.UnlockNeeded; + return (await biometrics.hasPersistent(this.biometricsSystem, userId)) || + (await biometrics.unlockAvailable(this.biometricsSystem, userId)) + ? BiometricsStatus.Available + : BiometricsStatus.UnlockNeeded; } } diff --git a/apps/desktop/src/services/biometric-message-handler.service.ts b/apps/desktop/src/services/biometric-message-handler.service.ts index 38f7e331312..04cebbfc93d 100644 --- a/apps/desktop/src/services/biometric-message-handler.service.ts +++ b/apps/desktop/src/services/biometric-message-handler.service.ts @@ -10,6 +10,7 @@ import { EncString } from "@bitwarden/common/key-management/crypto/models/enc-st import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service"; +import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { Utils } from "@bitwarden/common/platform/misc/utils"; import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key"; import { UserId } from "@bitwarden/common/types/guid"; @@ -25,9 +26,6 @@ import { import { BrowserSyncVerificationDialogComponent } from "../app/components/browser-sync-verification-dialog.component"; import { LegacyMessage, LegacyMessageWrapper } from "../models/native-messaging"; import { DesktopSettingsService } from "../platform/services/desktop-settings.service"; -import { isWindows } from "../utils"; -import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; -import { DeviceType } from "@bitwarden/common/enums"; const MessageValidTimeout = 10 * 1000; const HashAlgorithmForAsymmetricEncryption = "sha1"; @@ -92,7 +90,7 @@ export class BiometricMessageHandlerService { private authService: AuthService, private ngZone: NgZone, private i18nService: I18nService, - private platformUtilsService: PlatformUtilsService + private platformUtilsService: PlatformUtilsService, ) { combineLatest([ this.desktopSettingService.browserIntegrationEnabled$, @@ -351,8 +349,6 @@ export class BiometricMessageHandlerService { appId, ); } - // FIXME: Remove when updating file. Eslint update - // eslint-disable-next-line @typescript-eslint/no-unused-vars } catch (e) { this.logService.error("[Native Messaging IPC] Biometric unlock failed", e); await this.send(