[PM-11593] Fix backgroundbrowserbiometricservice initialization (#10861)

* Fix backgroundbrowserbiometricservice initialization

* Cleanup according to review
This commit is contained in:
Bernd Schoolmann 2024-09-03 16:56:55 +02:00 committed by GitHub
parent 60fca9c118
commit 5f5e4498e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View File

@ -401,6 +401,8 @@ export default class MainBackground {
const logoutCallback = async (logoutReason: LogoutReason, userId?: UserId) =>
await this.logout(logoutReason, userId);
const runtimeNativeMessagingBackground = () => this.nativeMessagingBackground;
const refreshAccessTokenErrorCallback = () => {
// Send toast to popup
this.messagingService.send("showToast", {
@ -616,7 +618,9 @@ export default class MainBackground {
this.i18nService = new I18nService(BrowserApi.getUILanguage(), this.globalStateProvider);
this.biometricsService = new BackgroundBrowserBiometricsService(this.nativeMessagingBackground);
this.biometricsService = new BackgroundBrowserBiometricsService(
runtimeNativeMessagingBackground,
);
this.kdfConfigService = new KdfConfigService(this.stateProvider);

View File

@ -6,20 +6,20 @@ import { BrowserBiometricsService } from "./browser-biometrics.service";
@Injectable()
export class BackgroundBrowserBiometricsService extends BrowserBiometricsService {
constructor(private nativeMessagingBackground: NativeMessagingBackground) {
constructor(private nativeMessagingBackground: () => NativeMessagingBackground) {
super();
}
async authenticateBiometric(): Promise<boolean> {
const responsePromise = this.nativeMessagingBackground.getResponse();
await this.nativeMessagingBackground.send({ command: "biometricUnlock" });
const responsePromise = this.nativeMessagingBackground().getResponse();
await this.nativeMessagingBackground().send({ command: "biometricUnlock" });
const response = await responsePromise;
return response.response === "unlocked";
}
async isBiometricUnlockAvailable(): Promise<boolean> {
const responsePromise = this.nativeMessagingBackground.getResponse();
await this.nativeMessagingBackground.send({ command: "biometricUnlockAvailable" });
const responsePromise = this.nativeMessagingBackground().getResponse();
await this.nativeMessagingBackground().send({ command: "biometricUnlockAvailable" });
const response = await responsePromise;
return response.response === "available";
}