* 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
* `matrix-client-crypto.spec.ts` only tested a very specific bit of crypto (olm
encryption). It goes back to the very early days, before Megolm was invented.
I've renamed it to `olm-encryption-spec.ts`.
* `megolm-integ.spec.ts` is more of a general crypto test; it was just called
`megolm` to distinguish it from the Olm tests above. Renamed to
`crypto.spec.ts`.
This test seemed to be testing the behaviour of decrypting redacted events, but
that seems... strange. A redaction event cannot be encrypted (at least, there
is no spec for it), and it should be impossible to decrypt a (correctly)
redacted event, because such an event will lack a `ciphertext` property.
This test is just sticking a "redacted_because" property into a regular event,
which is a bit of a nonsense.
The megolm tests were making a few assumptions which they really shouldn't; in
particular:
* They were creating mock events with event_ids not starting `$`, and lacking
`sender`, `origin_server_ts` and `unsigned` properties
* They were not including the (now) required `keys.ed25519` property inside
the ciphertext of an olm message.
These work ok currently, but they aren't really correct, and they cause
problems when testing the new rust implementation.
* Remove extensible events v1 field population on legacy events
With extensible events v2, affected events are now gated by a room version, so we don't need this code anymore.
The proposal has generally moved away from mixing m.room.message with extensible fields as well.
* Run prettier
* Remove unstable identifier from tests too
* Run prettier again
I need to start calling back into the new rust crypto implementation from the /sync loops, so I need to pass it into SyncApi. To reduce the coupling, I've defined a new interface specifying the methods which exist for that purpose. Currently it's only onSyncCompleted.
There are a couple of callback interfaces which are currently stuffed into
`IStoredClientOpts` to make it easier to pass them into the `SyncApi`
constructor.
Before we add more fields to this, let's separate it out to a separate object.
`Room` and `Crypto` currently have some tight coupling in the form of a call to
`trackRoomDevices` when out-of-band members are loaded. We can improve this by
instead having Crypto listen out for a `RoomSateEvent.Update` notification.
This PR introduces MatrixClient.initRustCrypto, which is similar to initCrypto, except that it will use the Rust crypto SDK instead of the old libolm-based implementation.
This is very much not something you want to use in production code right now, because the integration with the rust sdk is extremely skeletal and almost everything crypto-related will raise an exception rather than doing anything useful.
It is, however, enough to demonstrate the loading of the wasmified rust sdk in element web, and a react sdk with light modifications can successfully log in and out.
Part of vector-im/element-web#21972.
Part of https://github.com/vector-im/element-web/issues/21972. Eventually I want to replace the whole of the current `Crypto` implementation with an alternative implementation, but in order to get from here to there, I'm factoring out a common interface which will be implemented by both implementations.
I'm also determined to fix the problem where the innards of the crypto implementation are exposed to applications via the `MatrixClient.crypto` property.
It's not (yet) entirely clear what shape this interface should be, so I'm going with a minimal approach and adding things as we know we need them. This means that we need to keep the old `client.crypto` property around as well as a new `client.cryptoBackend` property. Eventually `client.crypto` will go away, but that will be a breaking change in the js-sdk.
* Fix issue where the root event of a thread had to be loaded in a complicated way
* Fix issue where edits to the last event of a thread would get lost
* Fix issue where thread reply count would desync
* Refactor relations pagination mocking for tests
Rather than waiting for the application to call `.startClient`, upload the
device keys during `initCrypto()`. Element-R is going to approach this slightly
differently (it wants to manage the decision on key uploads itself), so this
lays some groundwork by collecting the libolm-specific bits together.
* bugfix: sliding sync initial room timelines shouldn't notify
Flag timeline events as `fromCache` when `initial: true` rooms
are received. This stops notifications appearing inappropriately
when you scroll the room list or spider the room list, as it
causes `liveEvent=false`.
* Use num_live to detect liveness; with jest test
* Linting
* jsdoc
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
vector-im/element-web#23819 is an intermittent failure to correctly initiate a user verification process. The
root cause is as follows:
* In matrix-react-sdk, ensureDMExists tries to create an encrypted DM room, and assumes it is ready for use
(including sending encrypted events) as soon as it receives a RoomStateEvent.NewMember notification
indicating that the other user has been invited or joined.
* However, in sync.ts, we process the membership events in a /sync response (including emitting
RoomStateEvent.NewMember notifications), which is long before we process any m.room.encryption event.
* The upshot is that we can end up trying to send an encrypted event in the new room before processing
the m.room.encryption event, which causes the crypto layer to blow up with an error of "Room was
previously configured to use encryption, but is no longer".
Strictly speaking, ensureDMExists probably ought to be listening for ClientEvent.Room as well as RoomStateEvent.NewMember; but that doesn't help us, because ClientEvent.Room is also emitted
before we process the crypto event.
So, we need to process the crypto event before we start emitting these other events; but a corollary of that
is that we need to do so before we store the new room in the client's store. That makes things tricky, because
currently the crypto layer expects the room to have been stored in the client first.
So... we have to rearrange everything to pass the newly-created Room object into the crypto layer, rather than
just the room id, so that it doesn't need to rely on getting the Room from the client's store.
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.
* Fix bug where undefined vs null in pagination tokens wasn't correctly handled
* Fix bug where thread list results were sorted incorrectly
* Allow removing the relationship of an event to a thread
* Implement feature detection for new threads MSCs and specs
* Prefix dir parameter for threads pagination if necessary
* Make threads conform to the same timeline APIs as any other timeline
* Extract thread timeline loading out of thread class
* fix thread roots not being updated correctly
* fix jumping to events by link
* implement new thread timeline loading
* Fix fetchRoomEvent incorrect return type
Co-authored-by: Germain <germains@element.io>
Co-authored-by: Germain <germain@souquet.com>