diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index a5cc4c20b51..3b2d447c165 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -1438,6 +1438,12 @@ "biometricsNotSupportedDesc": { "message": "Browser biometrics is not supported on this device." }, + "nativeMessagingPermissionPromptTitle": { + "message": "Additional Permission required" + }, + "nativeMessagingPermissionPromptDesc": { + "message": "To enable browser biometrics we need to request an additional permission. Once allowed, the browser extension will reload and you may need to unlock your vault again." + }, "nativeMessaginPermissionErrorTitle": { "message": "Permission not provided" }, diff --git a/src/background/nativeMessaging.background.ts b/src/background/nativeMessaging.background.ts index f1bcdf148aa..3ac41756e2b 100644 --- a/src/background/nativeMessaging.background.ts +++ b/src/background/nativeMessaging.background.ts @@ -35,6 +35,11 @@ export class NativeMessagingBackground { private runtimeBackground: RuntimeBackground, private i18nService: I18nService, private userService: UserService, private messagingService: MessagingService, private appIdService: AppIdService) { this.storageService.save(ConstantsService.biometricFingerprintValidated, false); + + // Reload extension to activate nativeMessaging + chrome.permissions.onAdded.addListener((permissions) => { + BrowserApi.reloadExtension(null); + }); } async connect() { diff --git a/src/popup/settings/settings.component.ts b/src/popup/settings/settings.component.ts index 6d5d4733154..cddb5c07f8a 100644 --- a/src/popup/settings/settings.component.ts +++ b/src/popup/settings/settings.component.ts @@ -214,16 +214,26 @@ export class SettingsComponent implements OnInit { // Request permission to use the optional permission for nativeMessaging if (!this.platformUtilsService.isFirefox()) { - const granted = await new Promise((resolve, reject) => { - chrome.permissions.request({permissions: ['nativeMessaging']}, resolve); + const hasPermission = await new Promise((resolve) => { + chrome.permissions.contains({permissions: ['nativeMessaging']}, resolve); }); - if (!granted) { + if (!hasPermission) { await this.platformUtilsService.showDialog( - this.i18nService.t('nativeMessaginPermissionErrorDesc'), this.i18nService.t('nativeMessaginPermissionErrorTitle'), + this.i18nService.t('nativeMessagingPermissionPromptDesc'), this.i18nService.t('nativeMessagingPermissionPromptTitle'), this.i18nService.t('ok'), null); - this.biometric = false; - return; + + const granted = await new Promise((resolve, reject) => { + chrome.permissions.request({permissions: ['nativeMessaging']}, resolve); + }); + + if (!granted) { + await this.platformUtilsService.showDialog( + this.i18nService.t('nativeMessaginPermissionErrorDesc'), this.i18nService.t('nativeMessaginPermissionErrorTitle'), + this.i18nService.t('ok'), null); + this.biometric = false; + return; + } } }