From 123db002dc3b8f6562887ce0194f962a14aa48b8 Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Fri, 2 Sep 2022 21:42:52 -0600 Subject: [PATCH] Handle special serialization case for native messaging. (#3442) It would be nice to fix this by processing the encString properly in Desktop, but that wouldn't be backwards compatible with existing installs. --- .../src/background/nativeMessaging.background.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/browser/src/background/nativeMessaging.background.ts b/apps/browser/src/background/nativeMessaging.background.ts index 44b4f400fdb..2e410b8e6ce 100644 --- a/apps/browser/src/background/nativeMessaging.background.ts +++ b/apps/browser/src/background/nativeMessaging.background.ts @@ -238,7 +238,18 @@ export class NativeMessagingBackground { private postMessage(message: OuterMessage) { // Wrap in try-catch to when the port disconnected without triggering `onDisconnect`. try { - this.port.postMessage(message); + const msg: any = message; + if (message.message instanceof EncString) { + // Alternative, backwards-compatible serialization of EncString + msg.message = { + encryptedString: message.message.encryptedString, + encryptionType: message.message.encryptionType, + data: message.message.data, + iv: message.message.iv, + mac: message.message.mac, + }; + } + this.port.postMessage(msg); } catch (e) { this.logService.error("NativeMessaging port disconnected, disconnecting.");