SocialGouv / e2esdk

SDK to build end-to-end encrypted web applications
https://socialgouv.github.io/e2esdk
Apache License 2.0
20 stars 0 forks source link

Realtime notifications with websockets #8

Closed franky47 closed 1 year ago

franky47 commented 1 year ago

WIP: it works but there are conflicts when multiple clients (eg: tabs, windows, or devtools) are involved as everyone listens to notifications and races to consume incoming shared keys.

~This can be solved by using a SharedWorker where supported, and falling back to polling for older browsers.~ Edit: see comment below.

franky47 commented 1 year ago

Note: the use of a SharedWorker, not only being limited in browser compatibility, would require shipping the worker code along with the client library. Doing so independently of how the client is consumed (using a bundler or not, which one, etc), and while preserving strict Content Security Policies (not loading blobs or requiring the consuming application to allowlist an arbitrary URL) seems like a footgun.

Moreover, using a SharedWorker only allowed having a single WebSocket connection per "context", independent of the number of clients running in parallel (tabs/windows, devtools etc). The problematic of picking a main client to react to notifications (so they wouldn't end up in a data race to process incoming keys) would still have had to be solved, so let's solve it without involving SharedWorkers.

github-actions[bot] commented 1 year ago

:tada: This PR is included in version 1.0.0-beta.1 :tada:

The release is available on npm package (@beta dist-tag)

Your semantic-release bot :package::rocket:

github-actions[bot] commented 1 year ago

:tada: This PR is included in version 1.0.0-beta.1 :tada:

The release is available on npm package (@beta dist-tag)

Your semantic-release bot :package::rocket:

github-actions[bot] commented 1 year ago

:tada: This PR is included in version 1.0.0-beta.1 :tada:

The release is available on npm package (@beta dist-tag)

Your semantic-release bot :package::rocket: