1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-06 10:33:57 +00:00

[PM-5537] Remove Unecessary Biometric State (#7762)

* Create state for biometric client key halves

* Move enc string util to central utils

* Provide biometric state through service

* Use biometric state to track client key half

* Create migration for client key half

* Ensure client key half is removed on logout

* Remove account data for client key half

* Remove unnecessary key definition likes

* Remove moved state from account

* Fix null-conditional operator failure

* Simplify migration

* Remove lame test

* Fix test type

* Add migrator

* Remove state that is never read.

* Remove unnecessary biometric state

We don't need to determine platform in desktop background, it can be done in the UI at any time.

* Fix merge

* Use platform utils to identify OS desktop type
This commit is contained in:
Matt Gibson
2024-02-15 15:29:29 -05:00
committed by GitHub
parent fae12cd0e6
commit c8c1ed42ba
14 changed files with 36 additions and 109 deletions

View File

@@ -1,21 +1,12 @@
import { systemPreferences } from "electron";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import { passwords } from "@bitwarden/desktop-native";
import { OsBiometricService } from "./biometrics.service.abstraction";
export default class BiometricDarwinMain implements OsBiometricService {
constructor(
private i18nservice: I18nService,
private stateService: StateService,
) {}
async init() {
await this.stateService.setBiometricText("unlockWithTouchId");
await this.stateService.setNoAutoPromptBiometricsText("autoPromptTouchId");
}
constructor(private i18nservice: I18nService) {}
async osSupportsBiometric(): Promise<boolean> {
return systemPreferences.canPromptTouchID();

View File

@@ -5,7 +5,6 @@ import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/sym
import { biometrics, passwords } from "@bitwarden/desktop-native";
import { WindowMain } from "../../../main/window.main";
import { ElectronStateService } from "../../services/electron-state.service.abstraction";
import { OsBiometricService } from "./biometrics.service.abstraction";
@@ -21,15 +20,9 @@ export default class BiometricWindowsMain implements OsBiometricService {
constructor(
private i18nService: I18nService,
private windowMain: WindowMain,
private stateService: ElectronStateService,
private logService: LogService,
) {}
async init() {
await this.stateService.setBiometricText("unlockWithWindowsHello");
await this.stateService.setNoAutoPromptBiometricsText("autoPromptWindowsHello");
}
async osSupportsBiometric(): Promise<boolean> {
return await biometrics.available();
}

View File

@@ -1,5 +1,4 @@
export abstract class BiometricsServiceAbstraction {
init: () => Promise<void>;
osSupportsBiometric: () => Promise<boolean>;
canAuthBiometric: ({
service,
@@ -26,7 +25,6 @@ export abstract class BiometricsServiceAbstraction {
}
export interface OsBiometricService {
init: () => Promise<void>;
osSupportsBiometric: () => Promise<boolean>;
authenticateBiometric: () => Promise<boolean>;
getBiometricKey: (

View File

@@ -43,13 +43,7 @@ describe("biometrics tests", function () {
const mockService = mock<OsBiometricService>();
(sut as any).platformSpecificService = mockService;
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
sut.init();
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
sut.setEncryptionKeyHalf({ service: "test", key: "test", value: "test" });
expect(mockService.init).toBeCalled();
await sut.setEncryptionKeyHalf({ service: "test", key: "test", value: "test" });
await sut.canAuthBiometric({ service: "test", key: "test", userId });
expect(mockService.osSupportsBiometric).toBeCalled();
@@ -111,9 +105,6 @@ describe("biometrics tests", function () {
innerService = mock();
(sut as any).platformSpecificService = innerService;
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
sut.init();
});
it("should return false if client key half is required and not provided", async () => {
@@ -128,7 +119,6 @@ describe("biometrics tests", function () {
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
sut.setEncryptionKeyHalf({ service: "test", key: "test", value: "test" });
expect(innerService.init).toBeCalled();
await sut.canAuthBiometric({ service: "test", key: "test", userId });
expect(innerService.osSupportsBiometric).toBeCalled();

View File

@@ -58,10 +58,6 @@ export class BiometricsService implements BiometricsServiceAbstraction {
this.platformSpecificService = new NoopBiometricsService();
}
async init() {
return await this.platformSpecificService.init();
}
async osSupportsBiometric() {
return await this.platformSpecificService.osSupportsBiometric();
}