From 48bd43882447c13631d049fbfafa838c07c95dd4 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Tue, 5 Nov 2024 15:38:23 +0100 Subject: [PATCH] Add context logs for native messaging (#11690) * Add logging to decryption routines * Fix case of uknown encryption type * Add decryption context to log where failures occur * Update log message * Fix linting * Add more context logs * Add context logs for native messaging * Update apps/desktop/native-messaging-test-runner/src/native-message.service.ts Co-authored-by: Maciej Zieniuk <167752252+mzieniukbw@users.noreply.github.com> * Update apps/desktop/src/services/native-message-handler.service.ts Co-authored-by: Maciej Zieniuk <167752252+mzieniukbw@users.noreply.github.com> * Rename channel key to desktop ipc channel key --------- Co-authored-by: Maciej Zieniuk <167752252+mzieniukbw@users.noreply.github.com> --- apps/browser/src/background/nativeMessaging.background.ts | 6 +++++- .../src/native-message.service.ts | 6 +++++- apps/desktop/src/services/native-message-handler.service.ts | 1 + apps/desktop/src/services/native-messaging.service.ts | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/browser/src/background/nativeMessaging.background.ts b/apps/browser/src/background/nativeMessaging.background.ts index 2399afd57b..69f66dfa7c 100644 --- a/apps/browser/src/background/nativeMessaging.background.ts +++ b/apps/browser/src/background/nativeMessaging.background.ts @@ -274,7 +274,11 @@ export class NativeMessagingBackground { let message = rawMessage as ReceiveMessage; if (!this.platformUtilsService.isSafari()) { message = JSON.parse( - await this.encryptService.decryptToUtf8(rawMessage as EncString, this.sharedSecret), + await this.encryptService.decryptToUtf8( + rawMessage as EncString, + this.sharedSecret, + "ipc-desktop-ipc-channel-key", + ), ); } diff --git a/apps/desktop/native-messaging-test-runner/src/native-message.service.ts b/apps/desktop/native-messaging-test-runner/src/native-message.service.ts index 8cc94c9619..cd84504c63 100644 --- a/apps/desktop/native-messaging-test-runner/src/native-message.service.ts +++ b/apps/desktop/native-messaging-test-runner/src/native-message.service.ts @@ -219,7 +219,11 @@ export default class NativeMessageService { key: string, ): Promise { const sharedKey = await this.getSharedKeyForKey(key); - const decrypted = await this.encryptService.decryptToUtf8(payload, sharedKey); + const decrypted = await this.encryptService.decryptToUtf8( + payload, + sharedKey, + "native-messaging-session", + ); return JSON.parse(decrypted); } diff --git a/apps/desktop/src/services/native-message-handler.service.ts b/apps/desktop/src/services/native-message-handler.service.ts index 106dc11e41..a99effce9e 100644 --- a/apps/desktop/src/services/native-message-handler.service.ts +++ b/apps/desktop/src/services/native-message-handler.service.ts @@ -185,6 +185,7 @@ export class NativeMessageHandlerService { let decryptedResult = await this.encryptService.decryptToUtf8( message.encryptedCommand as EncString, this.ddgSharedSecret, + "ddg-shared-key", ); decryptedResult = this.trimNullCharsFromMessage(decryptedResult); diff --git a/apps/desktop/src/services/native-messaging.service.ts b/apps/desktop/src/services/native-messaging.service.ts index c9830030ef..2312bfb2f6 100644 --- a/apps/desktop/src/services/native-messaging.service.ts +++ b/apps/desktop/src/services/native-messaging.service.ts @@ -114,6 +114,7 @@ export class NativeMessagingService { await this.encryptService.decryptToUtf8( rawMessage as EncString, SymmetricCryptoKey.fromString(await ipc.platform.ephemeralStore.getEphemeralValue(appId)), + `native-messaging-session-${appId}`, ), );