[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) =>
|
const logoutCallback = async (logoutReason: LogoutReason, userId?: UserId) =>
|
||||||
await this.logout(logoutReason, userId);
|
await this.logout(logoutReason, userId);
|
||||||
|
|
||||||
|
const runtimeNativeMessagingBackground = () => this.nativeMessagingBackground;
|
||||||
|
|
||||||
const refreshAccessTokenErrorCallback = () => {
|
const refreshAccessTokenErrorCallback = () => {
|
||||||
// Send toast to popup
|
// Send toast to popup
|
||||||
this.messagingService.send("showToast", {
|
this.messagingService.send("showToast", {
|
||||||
|
@ -616,7 +618,9 @@ export default class MainBackground {
|
||||||
|
|
||||||
this.i18nService = new I18nService(BrowserApi.getUILanguage(), this.globalStateProvider);
|
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);
|
this.kdfConfigService = new KdfConfigService(this.stateProvider);
|
||||||
|
|
||||||
|
|
|
@ -6,20 +6,20 @@ import { BrowserBiometricsService } from "./browser-biometrics.service";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class BackgroundBrowserBiometricsService extends BrowserBiometricsService {
|
export class BackgroundBrowserBiometricsService extends BrowserBiometricsService {
|
||||||
constructor(private nativeMessagingBackground: NativeMessagingBackground) {
|
constructor(private nativeMessagingBackground: () => NativeMessagingBackground) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
async authenticateBiometric(): Promise<boolean> {
|
async authenticateBiometric(): Promise<boolean> {
|
||||||
const responsePromise = this.nativeMessagingBackground.getResponse();
|
const responsePromise = this.nativeMessagingBackground().getResponse();
|
||||||
await this.nativeMessagingBackground.send({ command: "biometricUnlock" });
|
await this.nativeMessagingBackground().send({ command: "biometricUnlock" });
|
||||||
const response = await responsePromise;
|
const response = await responsePromise;
|
||||||
return response.response === "unlocked";
|
return response.response === "unlocked";
|
||||||
}
|
}
|
||||||
|
|
||||||
async isBiometricUnlockAvailable(): Promise<boolean> {
|
async isBiometricUnlockAvailable(): Promise<boolean> {
|
||||||
const responsePromise = this.nativeMessagingBackground.getResponse();
|
const responsePromise = this.nativeMessagingBackground().getResponse();
|
||||||
await this.nativeMessagingBackground.send({ command: "biometricUnlockAvailable" });
|
await this.nativeMessagingBackground().send({ command: "biometricUnlockAvailable" });
|
||||||
const response = await responsePromise;
|
const response = await responsePromise;
|
||||||
return response.response === "available";
|
return response.response === "available";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue