Sync automerge CRDT datastructure via e2e encrypted updates #58
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR sync an automerge document (using a hardcoded ID) via encrypted messages.
Initially I tried to build a automerge-repo-network adapter, but since the protocol is hardcoded and requires two roundtrips I gave up on the idea. Especially it would be very tricky to reverse engineer how to fake the first round-trip on sending/receiving an update. Instead I updated for manual manipulation of the document, but still leveraging the automerge-repo infrastructure so we can added cross-tab communication and the storage adapter from it.
Also switched from
useState
to@xstate/store
for document storage since I needed to access the state (space and it's keys) outside of react. Makes sense anyway since soon we want to move to a solution that's also persisted in IndexedDB.In addition I upgraded to the latest alphas since this maps the
main
repositories and has several simplifications e.g.awaitingNetwork
state has been removed.More info can be found here: https://automerge.org/docs/repositories/
There are several follow up tasks that I added here: #62