* WIP RoomWidgetClient
* Wait for the widget API to become ready before backfilling
* Add support for sending user-defined encrypted to-device messages
This is a port of the same change from the robertlong/group-call branch.
* Fix tests
* Emit an event when the client receives TURN servers
* Expose the method in MatrixClient
* Override the encryptAndSendToDevices method
* Add support for TURN servers in embedded mode and make calls mostly work
* Don't put unclonable objects into VoIP events
RoomWidget clients were unable to send m.call.candidate events, because
the candidate objects were not clonable for use with postMessage.
Converting such objects to their canonical JSON form before attempting
to send them over the wire solves this.
* Fix types
* Fix more types
* Fix lint
* Upgrade matrix-widget-api
* Save lockfile
* Untangle dependencies to fix tests
* Add some preliminary tests
* Fix tests
* Fix indirect export
* Add more tests
* Resolve TODOs
* Add queueToDevice to RoomWidgetClient
* Add basic creation / entering tests for group calls
* Missing space
Co-authored-by: Robin <robin@robin.town>
* Assert more of the group call member event
and also move call leaving to a finally so it doesn't leaving a call
hagning if it fails.
Co-authored-by: Robin <robin@robin.town>
This will be rolled out again later with more accompanying UI adjustments, including clearer error messages and possibly the option to disable it per-room.
* Prepare changelog for v19.2.0-rc.1
* v19.2.0-rc.1
* Sliding sync: add missing filters from latest MSC
* Gracefully handle missing room_ids
* Prepare changelog for v19.2.0
* v19.2.0
* Resetting package fields for development
* Use EventType enum values instead of hardcoded strings (#2557)
* Retry to-device messages (#2549)
* Retry to-device messages
This adds a queueToDevice API alongside sendToDevice which is a
much higher-level API that adds the messages to a queue, stored in
persistent storage, and retries them periodically. Also converts
sending of megolm keys to use the new API.
Other uses of sendToDevice are nopt converted in this PR, but could
be later.
Requires https://github.com/matrix-org/matrix-mock-request/pull/17
* Bump matrix-mock-request
* Add more waits to make indexeddb tests pass
* Switch some test expectations to queueToDevice
* Stop straight away if the client has been stopped
Hopefully will fix tests being flakey and logging after tests have
finished.
* Add return types & fix constant usage
* Fix return type
Co-authored-by: Germain <germains@element.io>
* Fix return type
Co-authored-by: Germain <germains@element.io>
* Fix return type
Co-authored-by: Germain <germains@element.io>
* Stop the client in all test cases
Co-authored-by: Germain <germains@element.io>
* Add support for sending user-defined encrypted to-device messages (#2528)
* Add support for sending user-defined encrypted to-device messages
This is a port of the same change from the robertlong/group-call branch.
* Fix tests
* Expose the method in MatrixClient
* Fix a code smell
* Fix types
* Test the MatrixClient method
* Fix some types in Crypto test suite
* Test the Crypto method
* Fix tests
* Upgrade matrix-mock-request
* Move useRealTimers to afterEach
* Remove stream-replacement (#2551)
* Reintroduce setNewStream method, fix test, update yarn.lock
Co-authored-by: RiotRobot <releases@riot.im>
Co-authored-by: Kegan Dougal <kegan@matrix.org>
Co-authored-by: Germain <germains@element.io>
Co-authored-by: Robin <robin@robin.town>
Co-authored-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Add support for sending user-defined encrypted to-device messages
This is a port of the same change from the robertlong/group-call branch.
* Fix tests
* Expose the method in MatrixClient
* Fix a code smell
* Fix types
* Test the MatrixClient method
* Fix some types in Crypto test suite
* Test the Crypto method
* Fix tests
* Upgrade matrix-mock-request
* Move useRealTimers to afterEach
* Retry to-device messages
This adds a queueToDevice API alongside sendToDevice which is a
much higher-level API that adds the messages to a queue, stored in
persistent storage, and retries them periodically. Also converts
sending of megolm keys to use the new API.
Other uses of sendToDevice are nopt converted in this PR, but could
be later.
Requires https://github.com/matrix-org/matrix-mock-request/pull/17
* Bump matrix-mock-request
* Add more waits to make indexeddb tests pass
* Switch some test expectations to queueToDevice
* Stop straight away if the client has been stopped
Hopefully will fix tests being flakey and logging after tests have
finished.
* Add return types & fix constant usage
* Fix return type
Co-authored-by: Germain <germains@element.io>
* Fix return type
Co-authored-by: Germain <germains@element.io>
* Fix return type
Co-authored-by: Germain <germains@element.io>
* Stop the client in all test cases
Co-authored-by: Germain <germains@element.io>
* Send call version `1` as a string (#2471)
* test typescriptification - backup.spec (#2468)
* renamed: spec/unit/crypto/crypto-utils.js -> spec/unit/crypto/crypto-utils.ts
* ts fixes in crypto-utils
* renamed: spec/unit/crypto/backup.spec.js -> spec/unit/crypto/backup.spec.ts
* ts fixes in backup.spec
* remove fit
* remove debug
* Prepare changelog for v19.0.0-rc.1
* v19.0.0-rc.1
* Update jest monorepo (#2476)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* Update all (#2475)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* Update dependency @types/jest to v28 (#2478)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* Fix call.collectCallStats() (#2480)
Regressed by https://github.com/matrix-org/matrix-js-sdk/pull/2352
(you can just use RTCStatsReport as an iterator directly (which
was was what that code was doing before) which uses entries(
which gives you key/value pairs, but using forEach gives you just
the value.
* Go back to forEach in collectcallstats (#2481)
Older typescript library doesn't know about .values() on the stats
object, so it was failing in react sdk which had an older typescript.
https://github.com/matrix-org/matrix-react-sdk/pull/8935 was an
attempt to upgrade it but did not seem to be helping on CI, despite
being fine locally.
* Update babel monorepo to v7.18.6 (#2477)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* Expose KNOWN_SAFE_ROOM_VERSION (#2474)
* Fix return type on funcs in matrixClient to be optionally null (#2488)
* Update pull_request.yaml (#2490)
* Lock file maintenance (#2491)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* Prepare changelog for v19.0.0
* v19.0.0
* Resetting package fields for development
* Improve VoIP integrations testing (#2495)
* Remove MSC3244 support (#2504)
* Actually store the identity server in the client when given as an option (#2503)
* Actually store the identity server in the client when given as an option
* Update requestRegisterEmailToken to a modern spec version too
* Properly re-insert room ID in bundled thread relation messages from sync (#2505)
Events returned by the `/sync` endpoint, including relations bundled with other events, may have their `room_id`s stripped out. This causes decryption errors if the IDs aren't repopulated.
Fixesvector-im/element-web#22094.
* Remove `setNow` from `realtime-callbacks.ts` (#2509)
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Remove dead code (#2510)
* Don't crash with undefined room in `processBeaconEvents()` (#2500)
* Add a basic PR checklist for all PRs (#2511)
It'll be mildly annoying for core developers who have to constantly remove or edit this, but it'll also serve as a good reminder to do these things.
Note that signoff is not required for core developers.
* Fix tests
Co-authored-by: Šimon Brandner <simon.bra.ag@gmail.com>
Co-authored-by: Kerry <kerrya@element.io>
Co-authored-by: RiotRobot <releases@riot.im>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Weimann <michaelw@matrix.org>
Co-authored-by: texuf <texuf.eth@gmail.com>
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
Co-authored-by: Travis Ralston <travisr@matrix.org>
Co-authored-by: Faye Duxovni <fayed@element.io>
* 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>
* Fix some MatrixCall leaks and use a shared AudioContext
These leaks, combined with the dozens of AudioContexts floating around in memory across different CallFeeds, could cause some really bad performance issues and audio crashes on Chrome.
* Fully release the AudioContext in CallFeed's dispose method
* Fix tests
* Fix test message utils using overload
* Tweak existing tests
* Add test around `MatrixClient::getEventTimeline`
* Fix test to actually exercise the faulty behaviour
* Extract timelineSet thread belongs logic and test it
* tweak method name
* Refactor Relations to not be per-EventTimelineSet
* Fix comment and relations-container init
* Revert timing tweaks
* Fix relations order test
* Add test and simplify thread relations handling
* Fix order of initialising a room object
* Fix test
* Re-add thread handling for relations of unloaded threads
* Ditch confusing experimental getter `MatrixEvent::isThreadRelation`
* Fix room handling in RelationsContainer
* Iterate PR
* Tweak method naming to closer match spec
Inform the client that historical messages were imported in the timeline and they should refresh the timeline in order to see the new events.
Companion `matrix-react-sdk` PR: https://github.com/matrix-org/matrix-react-sdk/pull/8354
The `marker` events are being used as state now because this way they can't be lost in a timeline gap. Regardless of when they were sent, we will still have the latest version of the state to compare against. Any time we see our latest state value change for marker events, prompt the user that the timeline needs to refresh.
> In a [sync meeting with @ara4n](https://docs.google.com/document/d/1KCEmpnGr4J-I8EeaVQ8QJZKBDu53ViI7V62y5BzfXr0/edit#bookmark=id.67nio1ka8znc), we came up with the idea to make the `marker` events as state events. When the client sees that the `m.room.marker` state changed to a different event ID, it can throw away all of the timeline and re-fetch as needed.
>
> For homeservers where the [same problem](https://github.com/matrix-org/matrix-doc/pull/2716#discussion_r782499674) can happen, we probably don't want to throw away the whole timeline but it can go up the `unsigned.replaces_state` chain of the `m.room.marker` state events to get them all.
>
> In terms of state performance, there could be thousands of `marker` events in a room but it's no different than room members joining and leaving over and over like an IRC room.
>
> *-- https://github.com/matrix-org/matrix-spec-proposals/pull/2716#discussion_r782629097*
### Why are we just setting `timlineNeedsRefresh` (and [prompting the user](https://github.com/matrix-org/matrix-react-sdk/pull/8354)) instead of automatically refreshing the timeline for the user?
If we refreshed the timeline automatically, someone could cause your Element client to constantly refresh the timeline by just sending marker events over and over. Granted, you probably want to leave a room like this 🤷. Perhaps also some sort of DOS vector since everyone will be refreshing and hitting the server at the exact same time.
In order to avoid the timeline maybe going blank during the refresh, we could re-fetch the new events first, then replace the timeline. But the points above still stand on why we shouldn't.
* Update jest monorepo
* -w
* Fix guest rooms test to use async/await instead of a done callback
The done callback was never being called because it relies on a `process.nextTick()` deep within the mock. For this test we don't get a "next tick" because the event loop is busy, so we instead cargocult some test infrastructure from surrounding tests and verify the expected API call was cleared from the queue.
* Enable github-actions reporter
* Don't override local reporters
* Stop DeviceLists at end of tests
* stop more clients
* Fix tests and DRY typing
* Fix client/crypto stopping in tests
* Fix Buffer c'tor deprecated warnings
* Fix devicelist-integ test being excluded due to poor naming
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Travis Ralston <travisr@matrix.org>
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
* Update relations after every decryption attempt
If an event is encrypted the aggregation cannot pick up the relation types.
Before this change there was exactly one aggregation retry after decryption.
If the events are being decrypted afterwards (for example on restore
from key backup) the aggregation was not aware of that.
This change adds relation updates after every decryption event if there
has been a decryption error.
Signed-off-by: Michael Weimann <michaelw@matrix.org>