HomePhabricator
Diffusion Comm 7341fa87cd21

Implement main <-> renderer IPC and use it to decrypt notifications

Description

Implement main <-> renderer IPC and use it to decrypt notifications

Summary:
This differential implements main <-> rendered IPC and uses it combined with decryption function from previous differential to decrypt notifications. In
summary notification decryption workflow is as follows:

  1. Desktop code in push-notifications.js receives notification and checks that it is encrypted (encryptedPayload) field.
  2. Sends decrypted payload to renderer process (web app) using onEncryptedNotification IPC.
  3. Renderer receives it in callback registered in push-notifs-handler.js in web code. In this callback it decrypts payload using decryptDesktopNotification

function.

  1. Decrypted notification is sent to main process using showDecryptedNotification IPC.
  2. Main process receives decrypted notification in ipcMain.on('show-decrypted-notification', (...) => {...}) where it shows notification.

Test Plan:

  1. Apply this patch to local keyserver (it basically enables session establishment for desktop device and encrypts notification):

https://gist.github.com/marcinwasowicz/2df9c9bd4491862173241744d54a016f

  1. Send some notifications.
  2. Ensure they are correctly displayed and olm session version for currently logged user in desktop app increments with each notification.

With this differential we can also test large influx of out of order notifications (https://linear.app/comm/issue/ENG-5385/handle-large-number-of-out-of-order-notifications-incoming-afer-long).

  1. Apply this patch on top of first patch to your local keyserver (it artificially calls multiple sendPushNotifs promises on single message): https://gist.github.com/marcinwasowicz/673b62b70998588a7e6f4be31bddd2c8
  2. Send message.
  3. Ensure all notifications that arrive are correctly decrypted.

Reviewers: kamil, michal

Reviewed By: michal

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D9964

Details