* Switch sliding sync support to simplified sliding sync
Experimental PR to test js-sdk with simlified sliding sync.
This does not maintain support for regulaer sliding sync.
* Remove txn_id handling, ensure we always resend when req params change
* Fix some tests
* Fix remaining tests
* Mark TODOs on tests which need to die
* Linting
* Make comments lie less
* void
* Always sent full extension request
* Fix test
* Remove usage of deprecated field
* Hopefully fix DM names
* Refactor how heroes are handled in Room
* Fix how heroes work
* Linting
* Ensure that when SSS omits heroes we don't forget we had heroes
Otherwise when the room next appears the name/avatar reset to
'Empty Room' with no avatar.
* Check the right flag when doing timeline trickling
* Also change when the backpagination token is set
* Remove list ops and server-provided sort positions
SSS doesn't have them.
* Linting
* Add Room.bumpStamp
* Update crypto wasm lib
For new functions
* Add performance logging
* Fix breaking change in crypto wasm v8
* Update crypto wasm for breaking changes
See https://github.com/matrix-org/matrix-rust-sdk-crypto-wasm/releases/tag/v8.0.0
for how this was mapped from the previous API.
* Mark all tracked users as dirty on expired SSS connections
See https://github.com/matrix-org/matrix-rust-sdk/pull/3965 for
more information. Requires `Extension.onRequest` to be `async`.
* add ts extension
* Fix typedoc ref
* Add method to interface
* Don't force membership to invite
The membership was set correctly from the stripped state anyway so
this was redundant and was breaking rooms where we'd knocked.
* Missed merge
* Type import
* Make coverage happier
* More test coverage
* Grammar & formatting
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Remove markAllTrackedUsersAsDirty from crypto API
Not sure why this was in there, seems like it just needed to be in
crypto sync callbacks, which it already was.
* Remove I from interface
* API doc
* Move Hero definition to room-summary
* make comment more specific
* Move internal details into room.ts
and make the comment a proper tsdoc comment
* Use terser arrow function syntax
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Move comment to where we do the lookup
* Clarify comment
also prettier says hi
* Add comment
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Add tsdoc
explaining that the summary event will be modified
* more comment
* Remove unrelated changes
* Add docs & make fields optional
* Type import
* Clarify sync versions
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Make tsdoc comment & add info on when it's used.
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Rephrase comment
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Prettier
* Only fetch member for hero in legacy sync mode
* Split out a separate method to set SSS room summary
Rather than trying to fudge up an object that looked enough like the
old one that we could pass it in.
* Type import
* Make link work
* Nope, linter treats it as an unused import
* Add link the other way
* Add more detail to doc
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Remove unnecessary cast
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Remove length > 0 check
as it wasn't really necessary and may cause heroes not to be cleared?
* Doc params
* Remove unnecessary undefined comparison
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Put the comparison back
as it's necessary to stop typescript complaining
* Fix comment
* Fix comment
---------
Co-authored-by: Kegan Dougal <7190048+kegsay@users.noreply.github.com>
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* refactor: sliding sync: swap to lists-as-keys
Update the request/response API shape to match the latest
MSC3575 version, which converts `lists` from being an array
of list objects to being a map of list objects.
* Linting
* prettier
* add extra setListRanges test
* Default to right type
Reverting because the companion matrix-react-sdk change is not ready so
this is breaking our builds.
This reverts commit e04ea02c6208a7d261d6348adaad0f26b7c68c41.
* refactor: sliding sync: swap to lists-as-keys
Update the request/response API shape to match the latest
MSC3575 version, which converts `lists` from being an array
of list objects to being a map of list objects.
* Linting
* prettier
* add extra setListRanges test
* Default to right type
* Install eslint-plugin-jsdoc
* Enable lint rule jsdoc/no-types
* Make tsdoc more valid, add required hyphens and s/return/returns/g
* Stash tsdoc work
* Fix mistypes
* Stash
* Stash
* More tsdoc work
* Remove useless doc params
* Fixup docs
* Apply suggestions from code review
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Update src/crypto/verification/request/ToDeviceChannel.ts
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Update src/client.ts
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Update src/client.ts
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Update src/client.ts
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Apply suggestions from code review
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Iterate
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
This is mostly useful when you need to change the subscription depending
on the room. For example, unencrypted rooms have lazy-loaded members, but
encrypted rooms do not.
In sliding sync, with an empty list, it is possible for the proxy
to send back DELETE 0, INSERT 0 !room which has the net result of
`[!room]`. Previously, the JS SDK would not handle this correctly.
Now it does. With tests.
If you leave a room you can get a lone DELETE op.
If you join a room you can get a lone INSERT op.
Up until now, we've assumed these operations happen at the ends
of the list (e.g [0] or [length-1]) which is not guaranteed as it
depends on the sort order (e.g sort alphabetically and join a room
called 'D'). In this scenario, the indexes would not be tracked
correctly. Fixed with integration tests.
This can happen when you close your laptop overnight,
as the server will not hold onto in-memory resources
for your connection indefinitely. When this happen,
the server will HTTP 400 you with "session expired".
At this point, it is no longer safe to remember anything
and you must forget everything and resend any sticky
parameters. This commit does the sticky parameters and
re-establishes the connection, but it may need additional
work to make the JS SDK forget now invalid data.
This allows clients to know when a request has been applied
on the server. This allows us to change `resend(): void` to
`resend(): Promise<string>` which resolves/rejects with the
transaction ID when it has been applied/not.
* sliding sync: add client function and add stub sliding-sync.ts
Mostly c/p from sync.ts. Define interfaces for MSC3575 sliding
sync types. Complete WIP!
* Add core sliding sync classes
* Add integration tests for sliding sync api basics
* gut unused code; add more types
* Use SlidingSync in MatrixClient; stub functions for Sync
Enough to make ele-web actually load okay with 0 rooms.
* Start feeding through room data to the client
* Bugfixes so it sorta ish works
* Refactor the public API for sliding sync
Still needs some work but it's a start.
* Use EventEmitter for callbacks. Add ability to adjust lists and listen for list updates.
- Have atomic getList/setList operations on SlidingSync to update windows etc
- Add a list callback which is invoked with the list indicies and joined count.
* Add stub tests; add listenUntil to make tests easier to read
* No need to resend now
* Add more sliding sync tests; add new setListRanges function
* build tests upon one another to reduce boilerplate and c/p
* More thorough sliding sync tests
* Dependency inject SlidingSync in Client opts when calling startClient()
* Linting
* Fix crash when opts is undefined
* Fix up docs to make CI happy
* Remove all listeners when stop()d to allow for GC
* Add support for extensions
* Add ExtensionE2EE automatically if opts.crypto is present
* Add ExtensionToDevice automatically
* Bugfixes for to_device message processing
* default events to []
* bugfix: don't tightloop when the server is down
Caused by not detecting abort() correctly
* Return null for bad index positions
* Add getListData to get the initial calculated list response
* Add is_tombstoned
* More comments
* Add support for account data extension; rejig extension interface
* Handle invite_state
* Feed through prev_batch tokens
* Linting
* Fix tests
* Linting
* Iterate PR
* Iterate tests and remove unused code
* Update matrix-mock-request
* Make tests happier
* Remove DEBUG/debuglog and use logger.debug
* Update the API to the latest MSC; fixup tests
* Use undefined not null to make it work with the latest changes
* Don't recreate rooms when initial: true
* Add defensive code when unsigned.transaction_id is missing
We can still pair up events by looking at the event_id. We need
to do this in Sliding Sync because the proxy has limitations that
means it cannot guarantee it will always incude a transaction_id
in unsigned. The main reason why is due to the following race condition:
- A and B are in a DM room.
- Both are using the proxy.
- A says "hello".
- B's sync stream gets "hello" on the proxy. At this point the proxy
knows it needs to deliver it to A. It does so, but this event has
no transaction_id as it came down B's sync stream, not A's.
- If instead, A's sync stream gets "hello" on the proxy, the proxy
will deliver this message with the transaction_id correctly set.
There are no guarantees that A's sync stream will get the event in a
timely manner, hence the decision to just deliver the events as soon
as the proxy gets the event. This will not be an issue for native
Sliding Sync implementations; this is just a proxy issue.
* Linting
* Add additional sliding sync tests
* Begin adding SlidingSyncSdk tests
* Linting
* Add more sliding sync sdk tests
* Prep work for extension tests
* Linting
* Add account data extension tests
* add to-device tests
* Add E2EE extension tests
* Code smell fixes and extra tests
* Add test for no-txn-id local echo
* Add tests for resolveProfilesToInvites
* Add tests for moving entries down as well as up the list
* Remove conn-management.ts
* Actually verify the event was removed from the txn map
* Handle the case when /sync returns before /send without a txn_id
And ensure all the tests actually test the right things.
* Linting
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>