1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-22 11:45:59 +01:00

[PM-5717] Fix calling methods on undefined in biometrics service (#7559)

* Fix calling init() on undefined in biometrics.service.ts

* Add guard on osSupportsBiometric

* Create NoopBiometricsService instead of method guards

---------

Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
This commit is contained in:
Daniel James Smith 2024-01-26 17:15:28 +01:00 committed by GitHub
parent c0e157610e
commit 53be4946de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,34 @@
import { OsBiometricService } from "./biometrics.service.abstraction";
export default class NoopBiometricsService implements OsBiometricService {
constructor() {}
async init() {}
async osSupportsBiometric(): Promise<boolean> {
return false;
}
async getBiometricKey(
service: string,
storageKey: string,
clientKeyHalfB64: string,
): Promise<string | null> {
return null;
}
async setBiometricKey(
service: string,
storageKey: string,
value: string,
clientKeyPartB64: string | undefined,
): Promise<void> {
return;
}
async deleteBiometricKey(service: string, key: string): Promise<void> {}
async authenticateBiometric(): Promise<boolean> {
throw new Error("Not supported on this platform");
}
}

View File

@ -27,6 +27,8 @@ export class BiometricsService implements BiometricsServiceAbstraction {
this.loadWindowsHelloService();
} else if (platform === "darwin") {
this.loadMacOSService();
} else {
this.loadNoopBiometricsService();
}
}
@ -47,6 +49,12 @@ export class BiometricsService implements BiometricsServiceAbstraction {
this.platformSpecificService = new BiometricDarwinMain(this.i18nService, this.stateService);
}
private loadNoopBiometricsService() {
// eslint-disable-next-line
const NoopBiometricsService = require("./biometric.noop.main").default;
this.platformSpecificService = new NoopBiometricsService();
}
async init() {
return await this.platformSpecificService.init();
}