Skip to content

Commit

Permalink
Add context logs for native messaging (#11690)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* Update apps/desktop/src/services/native-message-handler.service.ts

Co-authored-by: Maciej Zieniuk <[email protected]>

* Rename channel key to desktop ipc channel key

---------

Co-authored-by: Maciej Zieniuk <[email protected]>
  • Loading branch information
quexten and mzieniukbw authored Nov 5, 2024
1 parent 8bee0ad commit 48bd438
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion apps/browser/src/background/nativeMessaging.background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,11 @@ export default class NativeMessageService {
key: string,
): Promise<DecryptedCommandData> {
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/services/native-messaging.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
),
);

Expand Down

0 comments on commit 48bd438

Please sign in to comment.