[PM-11593] Fix backgroundbrowserbiometricservice initialization (#10861)
* Fix backgroundbrowserbiometricservice initialization * Cleanup according to review
This commit is contained in:
parent
60fca9c118
commit
5f5e4498e8
|
@ -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);
|
||||
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue