From 05e9419d658c014a31ac2f374a62c4e80cec4bd9 Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Mon, 7 Jun 2021 17:16:45 -0400 Subject: [PATCH] Request biometrically secured stored key --- src/main.ts | 3 ++- src/services/nativeMessaging.service.ts | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index 01e044e6f8..aff61bc02a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -109,7 +109,6 @@ export class Main { this.messagingMain.onMessage(message); }); - this.keytarStorageListener = new KeytarStorageListener('Bitwarden'); if (process.platform === 'win32') { const BiometricWindowsMain = require('jslib-electron/biometric.windows.main').default; @@ -119,6 +118,8 @@ export class Main { this.biometricMain = new BiometricDarwinMain(this.storageService, this.i18nService); } + this.keytarStorageListener = new KeytarStorageListener('Bitwarden', this.biometricMain); + this.nativeMessagingMain = new NativeMessagingMain(this.logService, this.windowMain, app.getPath('userData'), app.getPath('exe')); } diff --git a/src/services/nativeMessaging.service.ts b/src/services/nativeMessaging.service.ts index 6e0d6b4585..b63f5695da 100644 --- a/src/services/nativeMessaging.service.ts +++ b/src/services/nativeMessaging.service.ts @@ -102,11 +102,12 @@ export class NativeMessagingService { }); } - const response = await this.platformUtilService.authenticateBiometric(); - if (response) { - this.send({command: 'biometricUnlock', response: 'unlocked', keyB64: (await this.cryptoService.getKey()).keyB64}, appId); + const keyB64 = await (await this.cryptoService.getKey('biometric')).keyB64; + + if (keyB64 != null) { + this.send({ command: 'biometricUnlock', response: 'unlocked', keyB64: keyB64 }, appId); } else { - this.send({command: 'biometricUnlock', response: 'canceled'}, appId); + this.send({ command: 'biometricUnlock', response: 'canceled' }, appId); } break;