Page MenuHomePhabricator

[lib] Send logout message to primary device in useSecondaryDeviceLogOut
ClosedPublic

Authored by bartek on May 28 2024, 4:27 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jun 28, 2:06 PM
Unknown Object (File)
Thu, Jun 27, 11:18 AM
Unknown Object (File)
Thu, Jun 27, 11:18 AM
Unknown Object (File)
Thu, Jun 27, 11:18 AM
Unknown Object (File)
Fri, Jun 21, 10:38 PM
Unknown Object (File)
Fri, Jun 21, 4:07 AM
Unknown Object (File)
Thu, Jun 20, 2:20 PM
Unknown Object (File)
Sat, Jun 15, 2:53 PM
Subscribers

Details

Summary
  • Added Tunnelbroker message types, the same way as in D12133
  • Extend useSecondaryDeviceLogOut() to send Olm-encrypted TB message to the primary device before performing actual logout

Depends on D12223, D12240

Test Plan

Pressing "Secondary device logout" dev button makes primary device print a log:

LOG  Decrypted message from device mJc0HgRtPM1WTp+SWy/VE4C+243IznJPf2TGvriZ4A4: {"type":"LOG_OUT_SECONDARY_DEVICE"}

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bartek held this revision as a draft.
bartek edited the test plan for this revision. (Show Details)
bartek retitled this revision from [DRAFT] Send logout message to primary device to [lib] Send logout message to primary device in useSecondaryDeviceLogOut.May 29 2024, 9:55 AM
bartek published this revision for review.May 29 2024, 10:14 AM
bartek added inline comments.
lib/actions/user-actions.js
263–273 ↗(On Diff #40754)

Not sure about this part but it works. I took it from the stack of D12133.

I used olmAPI.encrypt instead of encryptAndPersist because we're about to log out so there's no point in persisting this. Correct me if I'm wrong

lib/actions/user-actions.js
64–65 ↗(On Diff #40754)

can be merged

246 ↗(On Diff #40754)

debug leftover?

263–273 ↗(On Diff #40754)

Not sure about this part but it works. I took it from the stack of D12133.

I used olmAPI.encrypt instead of encryptAndPersist because we're about to log out so there's no point in persisting this. Correct me if I'm wrong

makes sense

However, in that case, you should first attempt to encrypt, and only if the session does not exist call createOlmSessionWithPeer - if there is a session this code will overwrite the existing one and use the new session to encrypt which could cause some issues, and is not what we want.

279–282 ↗(On Diff #40754)

what if the user e.g. has no internet connection but logs out anyway and his device cannot send messages through TB?

lib/actions/user-actions.js
263–273 ↗(On Diff #40754)

Good to know, I'll add a try-catch

279–282 ↗(On Diff #40754)

Review feedback, add try-catch before creating a new Olm session

This revision is now accepted and ready to land.Thu, Jun 6, 1:26 AM