Page MenuHomePhabricator

[web] Add cryptoStore to shared worker
ClosedPublic

Authored by michal on Mar 7 2024, 7:59 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Dec 25, 7:04 PM
Unknown Object (File)
Mon, Dec 23, 11:28 PM
Unknown Object (File)
Mon, Dec 23, 11:28 PM
Unknown Object (File)
Mon, Dec 23, 11:28 PM
Unknown Object (File)
Mon, Dec 23, 11:28 PM
Unknown Object (File)
Mon, Dec 23, 11:28 PM
Unknown Object (File)
Mon, Dec 23, 11:27 PM
Unknown Object (File)
Thu, Dec 19, 1:13 AM
Subscribers

Details

Summary

[ENG-6650 : Add cryptoStore to shared worker](https://linear.app/comm/issue/ENG-6650/add-cryptostore-to-shared-worker)

Part of the work to synchronize data between browser tabs. This diff moves the cryptoStore to the shared worker. This is hidden behind the flag for now and will be enabled after all diffs are landed.

  • The new worker message INITIALIZE_CRYPTO_ACCOUNT also accepts optional cryptoStore which will be used in a future migration
  • OLM wasm path for webworkers extracted from service worker code
NOTE: currently some parts of olm don't work in the shared worker (more info in the linked issue) but updating our fork will be handled by @kamil.

Depends on D11236

Test Plan
  • Made sure that olm wasm is downloaded on both dev and in docker (prod)
  • Tested that initializing crypto account creates and persist new accounts
  • Tested that if there are persisted accounts they are used instead
  • Tested that initialCryptoStore ovverides the existing crypto store

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

michal requested review of this revision.Mar 7 2024, 8:13 AM
kamil requested changes to this revision.Mar 11 2024, 4:39 AM
kamil added inline comments.
web/shared-worker/utils/constants.js
52 ↗(On Diff #37930)

we should rename it, it's confusing with const

web/shared-worker/worker/worker-crypto.js
13 ↗(On Diff #37930)
16 ↗(On Diff #37930)

I am not sure if this is the best approach - I think the option will be to store accounts and sessions unpickled in memory to have direct and easy access to crypto operations and pickle only before persisting. What do do you think?

50–53 ↗(On Diff #37930)

shouldn't these be read-only?

This revision now requires changes to proceed.Mar 11 2024, 4:39 AM
  • Small fixes
  • Keep the olm runtime objects directly in memory instead of the pickled form
  • Create a new separation for olm related requests in worker request types (like in the next diffs for identity client)
  • Use the globals getters introduced in the previous diff
kamil added inline comments.
web/shared-worker/worker/worker-crypto.js
33

I would prefer have more accurate error messages

web/types/worker-types.js
51

this can be removed now

This revision is now accepted and ready to land.Mar 15 2024, 10:10 AM