Page MenuHomePhabricator

Expose major version of desktop code to the keyserver
ClosedPublic

Authored by marcin on Nov 24 2023, 9:02 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, May 14, 3:10 AM
Unknown Object (File)
Thu, May 9, 2:57 PM
Unknown Object (File)
Mon, Apr 22, 12:47 PM
Unknown Object (File)
Mon, Apr 22, 12:47 PM
Unknown Object (File)
Mon, Apr 22, 12:47 PM
Unknown Object (File)
Mon, Apr 22, 12:47 PM
Unknown Object (File)
Mon, Apr 22, 12:47 PM
Unknown Object (File)
Mon, Apr 22, 12:47 PM
Subscribers

Details

Summary

This differential exposes major version of desktop code to the keyserver. It is necessary since ability to decrypt desktop notifications deoends on both web
and desktop code. Those two can be out of sync if user doesn't accept desktop app update.

Test Plan
  1. Apply this patch to the keyserver code: https://gist.github.com/marcinwasowicz/33a1d560f092a38d12ad9fa1e88c9eb1
  2. Log-in from dev build of desktop app.
  3. Use select * from olm_sessions; in MariaDB console.
  4. Ensure that no session was created.
  5. Update NEXT_CODE_VERSION to 0.
  6. Use select * from olm_sessions; in MariaDB console.
  7. Ensure that new session was created for cookie id associated with currently logged in user in desktop app.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fix NEXT_CODE_VERSION accidentally set to 0

michal requested changes to this revision.Nov 28 2023, 2:19 AM
michal added inline comments.
lib/shared/version-utils.js
42–44 ↗(On Diff #33599)

We probably don't want to return here if there is minMajorDesktopVersion specified. Additionally we should check that both minCodeVersion and minMajorDesktopVersion pass if they are both included. Otherwise a client could have a new web version with an older desktop version and still pass this check.

87 ↗(On Diff #33599)

Nit: if we aren't depending on mutating the array, I find [0] much more straightforward than shift

lib/types/device-types.js
29 ↗(On Diff #33599)

Should we use isDesktopPlatform in this?

46 ↗(On Diff #33599)

Is there a reason we don't just type this as +majorDesktopVersion?: number. Currently it would be undefined on native, null on web, and a number on desktop. I don't think we need this distinction between web and native, we already have the platform field.

web/app.react.js
97–99 ↗(On Diff #33599)

Related to my other comment, but I think it would be better to just not pass anything on web instead of null. majorDesktopVersion doesn't apply to the web in the same way as it doesn't apply to native.

This revision now requires changes to proceed.Nov 28 2023, 2:19 AM
lib/shared/version-utils.js
42–44 ↗(On Diff #33599)

We probably don't want to return here if there is minMajorDesktopVersion specified.

I will introduce that.

Additionally we should check that both minCodeVersion and minMajorDesktopVersion pass if they are both included. Otherwise a client could have a new web version with an older desktop version and still pass this check.

This is indeed checked against. This code doesn't allow new web version to pass if desktop version is too old.

lib/shared/version-utils.js
42–44 ↗(On Diff #33599)

This is indeed checked against. This code doesn't allow new web version to pass if desktop version is too old.

Oh right, sorry I got confused!

  1. Enhance hasMinCodeVersion code.
  2. Use [0] instead of shift().
  3. Make majorDeskrtopVersion type optional but not nullable (and resulting changes).
This revision is now accepted and ready to land.Nov 28 2023, 6:38 AM