From b5492e95461e52c78fb516ea8639ba11b26e8a84 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Thu, 25 Mar 2021 23:11:31 +0100 Subject: [PATCH] Simplify logic for resolving path to exe for native messaging (#814) --- src/main.ts | 2 +- src/main/nativeMessaging.main.ts | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main.ts b/src/main.ts index 0dc07001..c3d0e1ae 100644 --- a/src/main.ts +++ b/src/main.ts @@ -119,7 +119,7 @@ export class Main { this.biometricMain = new BiometricDarwinMain(this.storageService, this.i18nService); } - this.nativeMessagingMain = new NativeMessagingMain(this.logService, this.windowMain, app.getPath('userData'), app.getAppPath()); + this.nativeMessagingMain = new NativeMessagingMain(this.logService, this.windowMain, app.getPath('userData'), app.getPath('exe')); } bootstrap() { diff --git a/src/main/nativeMessaging.main.ts b/src/main/nativeMessaging.main.ts index 220c48e1..955653ad 100644 --- a/src/main/nativeMessaging.main.ts +++ b/src/main/nativeMessaging.main.ts @@ -12,7 +12,7 @@ export class NativeMessagingMain { private connected = false; private socket: any; - constructor(private logService: LogService, private windowMain: WindowMain, private userPath: string, private appPath: string) {} + constructor(private logService: LogService, private windowMain: WindowMain, private userPath: string, private exePath: string) {} async listen() { ipc.config.id = 'bitwarden'; @@ -182,14 +182,11 @@ export class NativeMessagingMain { } private binaryPath() { - const dir = path.join(this.appPath, '..'); if (process.platform === 'win32') { - return path.join(dir, 'native-messaging.bat'); - } else if (process.platform === 'darwin') { - return '/Applications/Bitwarden.app/Contents/MacOS/Bitwarden'; + return path.join(path.basename(this.exePath), 'resources', 'native-messaging.bat'); } - return path.join(dir, '..', 'bitwarden'); + return this.exePath; } private async createWindowsRegistry(check: string, location: string, jsonFile: string) {