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.
This commit is contained in:
Matt Gibson 2022-09-02 21:42:52 -06:00 committed by GitHub
parent ef50055e32
commit 123db002dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 1 deletions

View File

@ -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.");