1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-12 14:34:02 +00:00
This commit is contained in:
Bernd Schoolmann
2025-08-28 13:47:55 +02:00
parent 93a5020a63
commit 80c5158108
3 changed files with 23 additions and 30 deletions

View File

@@ -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<void> {
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<void> {}
async deleteBiometricKey(userId: UserId): Promise<void> {
await biometrics.unenroll(this.biometricsSystem, userId);
}
async getBiometricKey(userId: UserId): Promise<SymmetricCryptoKey | null> {
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<boolean> {
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<boolean> {
@@ -102,7 +100,7 @@ export default class OsBiometricsServiceLinux implements OsBiometricService {
}
async getBiometricsFirstUnlockStatusForUser(userId: UserId): Promise<BiometricsStatus> {
return (await biometrics_v2.unlockAvailable(this.biometricsSystem, userId))
return (await biometrics.unlockAvailable(this.biometricsSystem, userId))
? BiometricsStatus.Available
: BiometricsStatus.UnlockNeeded;
}

View File

@@ -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<boolean> {
return await biometrics_v2.authenticateAvailable(this.biometricsSystem);
return await biometrics.authenticateAvailable(this.biometricsSystem);
}
async getBiometricKey(userId: UserId): Promise<SymmetricCryptoKey | null> {
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<void> {
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<void> {
await biometrics_v2.unenroll(this.biometricsSystem, userId);
await biometrics.unenroll(this.biometricsSystem, userId);
}
async authenticateBiometric(): Promise<boolean> {
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<void> {}
async getBiometricsFirstUnlockStatusForUser(userId: UserId): Promise<BiometricsStatus> {
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;
}
}

View File

@@ -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(