* MatrixRTC: ToDevice distribution for media stream keys
* test: Add RTC to device transport test
* lint
* fix key indexing
* fix indexing take two
- use correct value for: `onEncryptionKeysChanged`
- only update `latestGeneratedKeyIndex` for "this user" key
* test: add test for join config `useExperimentalToDeviceTransport`
* update test to fail without the fixed encryption key index
* review
* review (dave)
---------
Co-authored-by: Timo <toger5@hotmail.de>
* refactor: extract RoomKeyTransport class for key distribution
* refact: Call key transport, pass the target recipients to sendKey
* update IKeyTransport interface to event emitter.
* fix not subscribing to KeyTransportEvents in the EncryptionManager + cleanup
* fix one test and broken bits needed for the test (mostly statistics wrangling)
* fix tests
* add back decryptEventIfNeeded
* move and fix room transport tests
* dedupe isMyMembership
* move type declarations around to be at more reasonable places
* remove deprecated `onMembershipUpdate`
* fix imports
* only start keytransport when session is joined
* use makeKey to reduce test loc
* fix todo comment -> note comment
---------
Co-authored-by: Timo <toger5@hotmail.de>
* WIP doodles on MembershipManager test cases
* .
* initial membership manager test setup.
* Updates from discussion
* revert renaming comments
* remove unused import
* fix leave delayed event resend test.
It was missing a flush.
* comment out and remove unused variables
* es lint
* use jsdom instead of node test environment
* remove unused variables
* remove unused export
* temp
* review
* fixup tests
* more review
* remove wait for expect dependency
* flatten tests and add comments
* add more leave test cases
* use defer
* remove @jest/environment dependency
* Cleanup awaits and Make mock types more correct.
Make every mock return a Promise if the real implementation does return a pormise.
* remove flush promise dependency
* add linting to matrixrtc tests
* Add fix async lints and use matrix rtc logger for test environment.
* prettier
* change to MatrixRTCSession logger
* make accessing the full room deprecated
* remove deprecated usage of full room
* Clean up the deprecation
---------
Co-authored-by: Hugh Nimmo-Smith <hughns@matrix.org>
...and renames them, removing the special lowercase and uppercase
versions and exporting the underlying function instead.
Any apps that use these will either need to take the speed hit from
secure random functions and use the new ones, or write their own
insecure versions.
The lowercase and uppercasde verisons were used exactly once each
in element-web and never in js-sdk itself. The underlying function
is very simple and exporting just this gives more flexibility with
fewer exports.
* update join and leave internal api.
* rename onMembershipUpdate and triggerCallMembershipEventUpdate to onMembershipsUpdate
This makes it more clear that we do not talk about our own membership but all memberships in the session
* cleanup MembershipManager
- add comments and interface how to test this class.
- sort methods by public/private
- make triggerCallMembershipEventUpdate private
* docstrings for getFocusInUse and getActiveFocus
* simplify tests and make them only use MembershipManagerInterface methods.
This allows to exchange the membershipManager with a different implementation.
* convert interface to abstract class.
* review (implement interface, make interface internal, dont change public api.)
* Make the interface an actual interface.
The actual constructor of the class now contains the `Pick` to define what it needs from the client.
* move update condition into MembershipManager
* renaming public api
* Update src/matrixrtc/MatrixRTCSession.ts
Co-authored-by: Hugh Nimmo-Smith <hughns@users.noreply.github.com>
* Update src/matrixrtc/MatrixRTCSession.ts
Co-authored-by: Hugh Nimmo-Smith <hughns@users.noreply.github.com>
---------
Co-authored-by: Hugh Nimmo-Smith <hughns@users.noreply.github.com>
* split joinConfig
- myMembership related properties get moved into its own interface
* Add MyMembershipManager
* Remove methods and functions that are from MatrixRTCSession (they now live in MyMembershipManager)
* Refactor MatrixRTCSession to use myMembershipManager
* fix tests
* review
* get rid of more memberhsip manager usage in tests
* review - fix tests using private membershipManager props
* fix circular import
* remove all legacy call related code and adjust tests.
We actually had a bit of tests just for legacy and not for session events. All those tests got ported over so we do not remove any tests.
* dont adjust tests but remove legacy tests
* Remove deprecated CallMembership.getLocalExpiry()
* Remove references to legacy in test case names
* Clean up SessionMembershipData tsdoc
* Remove CallMembership.expires
* Use correct expire duration.
* make expiration methods not return optional values and update docstring
* add docs to `SessionMembershipData`
* Add new tests for session type member events that before only existed for legacy member events.
This reverts commit 795a3cffb61d672941c49e8139eb1d7b15c87d73.
* remove code we do not need yet.
* Cleanup
---------
Co-authored-by: Hugh Nimmo-Smith <hughns@matrix.org>
* remove all legacy call related code and adjust tests.
We actually had a bit of tests just for legacy and not for session events. All those tests got ported over so we do not remove any tests.
* dont adjust tests but remove legacy tests
* Remove deprecated CallMembership.getLocalExpiry()
* Remove references to legacy in test case names
* Clean up SessionMembershipData tsdoc
* Remove CallMembership.expires
* Use correct expire duration.
* make expiration methods not return optional values and update docstring
* add docs to `SessionMembershipData`
* Use `MSC4143` (instaed of `non-legacy`) wording in comment
Co-authored-by: Hugh Nimmo-Smith <hughns@users.noreply.github.com>
* Incorporate feedback from review
* Fix test name
---------
Co-authored-by: Hugh Nimmo-Smith <hughns@matrix.org>
Co-authored-by: Hugh Nimmo-Smith <hughns@users.noreply.github.com>
* Handle M_MAX_DELAY_EXCEEDED errors
Use a lower delay time if the server rejects a delay as too long.
* Add test
* Lint test
* Update src/matrixrtc/MatrixRTCSession.ts
Co-authored-by: Robin <robin@robin.town>
* Test computed expiry timeout value
---------
Co-authored-by: Robin <robin@robin.town>
* MatrixRTCSession: handle rate limit errors
* Lint
* Handle ratelimiting for non-legacy state setting
Each request must be retried, as the non-legacy flow involves a sequence
of requests that must resolve in order.
* Fix broken test
* Check for MSC3757 instead of the unmerged MSC3779
* Move helper out of beforeEach
* Test ratelimit errors
* Do not rotate MatrixRTC media encryption key when a new member joins a call
This change reverts https://github.com/matrix-org/matrix-js-sdk/pull/4422.
Instead, the rotation when a new member joins will be reintroduced as part of supporting to-device based MatrixRTC encryption key distribution.
* Improve function name
* Refactor/simplify Promises in MatrixRTCSession
* Update src/matrixrtc/MatrixRTCSession.ts
Co-authored-by: Hugh Nimmo-Smith <hughns@users.noreply.github.com>
* Fix+document+test leaveRoomSession's return value
* Throw instead of using expect in teardown
because lint rules forbid using expect outside of test functions
---------
Co-authored-by: Hugh Nimmo-Smith <hughns@users.noreply.github.com>
* Prepare delayed call leave events more reliably
- Try sending call join after preparing delayed leave
- On leave, send delayed leave instead of a new event
* Don't rely on errcodes for retry logic
because they are unavailable in widget mode
* Make arrow method readonly
SonarCloud rule typescript:S2933
* Test coverage for restarting delayed call leave
* Remove unneeded unstable_features mock
It's unneeded because all affected methods are mocked
* Don't share full key history for RTC per-participant encryption
Also record stats for how many keys have been sent/received and age of those received
* Update src/matrixrtc/MatrixRTCSession.ts
Co-authored-by: Robin <robin@robin.town>
* Add comment about why we track total age of events
---------
Co-authored-by: Robin <robin@robin.town>
* Use origin server timestamp for calculating group call membership expiry
* Fix tests
* Docs
* Refactor comments to reflect that the logic hasn't changed
* Make comment maintainable
* Fix up merge
* Fix test
* Handle MatrixRTC encryption keys arriving out of order
* Apply suggestions from code review
Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
* Suggestion from code review
---------
Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
* Resend MatrixRTC encryption keys if a membership has changed
* JSDoc
* Update src/matrixrtc/MatrixRTCSession.ts
Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
* Add note about using Set. symmetricDifference() when available
* Always store latest fingerprints
Should reduce unnecessary retransmits
* Refactor
---------
Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
and use them for more reliable MatrixRTC session membership events.
Also implement "parent" delayed events, which were in a previous version
of the MSC and may be reintroduced or be part of a new MSC later.
NOTE: Still missing is support for sending encrypted delayed events.
* Prefix the user+device state key if needed
No need to prefix it for rooms that use MSC3779.
Otherwise, prefix it to bypass the auth rule for state events with keys
starting with @.
* Use RegExp.exec() method instead
Sonar typescript:S6594
* Split nested ternary operator into method
Sonar typescript:S3358
* Add test coverage
* Use legacy call membership if anyone else is
* Convert nullish to boolean
* Update tests
* Lint
* Use computed decision to use legacy events or not
* Check if discovered legacy sessions are ongoing
* Lint
* Lint again
* Increase test coverage
* Refactor to preferred and active foci.
Signed-off-by: Timo K <toger5@hotmail.de>
* make the sdk compatible with MSC4143 but still be backwards compatible
* comment fixes
* also fallback to legacy if the current member event is legacy
* use XOR types
* use EitherAnd
* make livekit Foucs types simpler
* review
* fix tests
* test work
* more review + more tests
* remove unnecassary await that is in conflict with the comment
* make joinRoomSession sync
* Update src/matrixrtc/MatrixRTCSession.ts
Co-authored-by: Andrew Ferrazzutti <af_0_af@hotmail.com>
* review
* fix
* test
* review
* review
* comment clarification
* typo
---------
Signed-off-by: Timo K <toger5@hotmail.de>
Co-authored-by: Andrew Ferrazzutti <af_0_af@hotmail.com>
* Introduce Membership TS type
* Adapt the Membership TS type to be an enum
* Add docstrings for KnownMembership and Membership
* Move Membership types into a separate file, exported from types.ts
---------
Co-authored-by: Stanislav Demydiuk <s.demydiuk@gmail.com>
* ignore memberships of users that are not in the call
Signed-off-by: Timo K <toger5@hotmail.de>
* recompute memberships on room member change.
Signed-off-by: Timo K <toger5@hotmail.de>
* fix Tests and add test for left member
Signed-off-by: Timo K <toger5@hotmail.de>
* fix event type
Signed-off-by: Timo K <toger5@hotmail.de>
* fix import desaster
Signed-off-by: Timo K <toger5@hotmail.de>
* fix mocks
Signed-off-by: Timo K <toger5@hotmail.de>
---------
Signed-off-by: Timo K <toger5@hotmail.de>
* add expire_ts compatibility to matrixRTC
Signed-off-by: Timo K <toger5@hotmail.de>
* add expire_ts
Signed-off-by: Timo K <toger5@hotmail.de>
* rename expire_ts -> expires_ts
Signed-off-by: Timo K <toger5@hotmail.de>
* allow events without `expires`
Signed-off-by: Timo K <toger5@hotmail.de>
* fix test for expires_ts
Signed-off-by: Timo K <toger5@hotmail.de>
* comment clarification
Signed-off-by: Timo K <toger5@hotmail.de>
* add comment where one needs to use the origin_server_ts
Signed-off-by: Timo K <toger5@hotmail.de>
* add additional expires_ts tests
Signed-off-by: Timo K <toger5@hotmail.de>
* fix fake timer
Signed-off-by: Timo K <toger5@hotmail.de>
* change priority order to favor expires
Signed-off-by: Timo K <toger5@hotmail.de>
---------
Signed-off-by: Timo K <toger5@hotmail.de>
* better fallback to localTimestamp calculation
Signed-off-by: Timo K <toger5@hotmail.de>
* make `isExpired` impl simpler to read
Signed-off-by: Timo K <toger5@hotmail.de>
* update tests
Signed-off-by: Timo K <toger5@hotmail.de>
* refactor to use localTimestamp in the mocks
Signed-off-by: Timo K <toger5@hotmail.de>
* Update src/models/event.ts
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Update src/models/event.ts
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Update and clarify comments.
So that the localTimestamp and localAge behavior is easier to understand.
Signed-off-by: Timo K <toger5@hotmail.de>
* Replace localTimestamp biding
with binding the whole roomState
Signed-off-by: Timo K <toger5@hotmail.de>
---------
Signed-off-by: Timo K <toger5@hotmail.de>
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Add CallNotifyEvent to support matrix rtc ringing
Signed-off-by: Timo K <toger5@hotmail.de>
* test SessionId
Signed-off-by: Timo K <toger5@hotmail.de>
* docs + sessionId->callId
Signed-off-by: Timo K <toger5@hotmail.de>
---------
Signed-off-by: Timo K <toger5@hotmail.de>
* WIP refactor for removing m.call events
* Always remember rtcsessions since we need to only have one instance
* Fix tests
* Fix import loop
* Fix more cyclic imports & tests
* Test session joining
* Attempt to make tests happy
* Always leave calls in the tests to clean up
* comment + desperate attempt to work out what's failing
* More test debugging
* Okay, so these ones are fine?
* Stop more timers and hopefully have happy tests
* Test no rejoin
* Test malformed m.call.member events
* Test event emitting
and also move some code to a more sensible place in the file
* Test getActiveFoci()
* Test event emitting (and also fix it)
* Test membership updating & pruning on join
* Test getOldestMembership()
* Test member event renewal
* Don't start the rtc manager until the client has synced
Then we can initialise from the state once it's completed.
* Fix type
* Remove listeners added in constructor
* Stop the client here too
* Stop the client here also also
* ARGH. Disable tests to work out which one is causing the exception
* Disable everything
* Re-jig to avoid setting listeners in the constructor
and re-enable tests
* No need to rename this anymore
* argh, remove the right listener
* Is it this test???
* Re-enable some tests
* Try mocking getRooms to return something valid
* Re-enable other tests
* Give up trying to get the tests to work sensibly and deal with getRooms() returning nothing
* Oops, don't enable the ones that were skipped before
* One more try at the sensible way
* Didn't work, go back to the hack way.
* Log when we manage to send the member event update
* Support `getOpenIdToken()` in embedded mode (#3676)
* Call `sendContentLoaded()` (#3677)
* Start MatrixRTC in embedded mode (#3679)
* Reschedule the membership event check
* Bump widget api version
* Add mock for sendContentLoaded()
* Embeded mode pre-requisites
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Embeded mode E2EE
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Encryption condition
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Revert "Embeded mode pre-requisites"
This reverts commit 8cd73702052609c995ad754e31f85d0da0be4aa9.
* Get back event type
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
fds
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Change embedded E2EE implementation
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* More log detail
* Fix tests
and also better assert because the tests were passing undefined which
was considered fine because we were only checking for null.
* Simplify updateCallMembershipEvent a bit
* Split up updateCallMembershipEvent some more
* Use `crypto.getRandomValues()`
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Rename to `membershipToUserAndDeviceId()`
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Better error
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Add log line
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Add comment
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Send call ID in enc events
(also a small refactor)
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Revert making `joinRoomSession()` async
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Make `client` `private` again
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Just use `toString()`
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Fix `callId` check
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Fix map
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Fix map compare
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Fix emitting
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Explicit logging
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Refactor
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Make `updateEncryptionKeyEvent()` public
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Only update keys based on others
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Fix call order
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Improve logging
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Avoid races
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Revert "Avoid races"
This reverts commit f65ed72d6eaf71711a61db7f05e04899fb137e2d.
* Add try-catch
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Make `updateEncryptionKeyEvent()` private
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Handle indices and throttling
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Fix merge mistakes
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Mort post-merge fixes
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Split out key generation from key sending
And send all keys in a key event (changes the format of the key event)
rather than just the one we just generated.
* Remember and clear the timeout for the send key event
So we don't schedule more key updates if one is already pending.
Also don't update the last sent time when we didn't actually send the
keys.
* Make key event resends more robust
* Attempt to make tests pass
* crypto wasn't defined at all
* Hopefully get interface right
* Fix key format on the wire to base64
* Add comment
* More standard method order
* Rename encryptMedia
The js-sdk doesn't do media and therefore doesn't do media encryption
* Stop logging encryption keys now
* Use regular base64
It's not going in a URL, so no need
* Re-add base64url
randomstring was using it. Also give it a test.
* Add tests for randomstring
* Switch between either browser or node crypto
Let's see if this will work...
* Obviously crypto has already solved this
* Some tests for MatrixRTCSession key stuff
* Test keys object contents
* Change keys event format
To move away from m. keys
* Test key event retries
* Test onCallEncryption
* Test event sending & spam prevention
* Test event cancelation
* Test onCallEncryption called
* Better before/after member comparison
Only trigger for when members actually join, and just generally
make it a bit more understandable.
* Rotate per-participant keys when a member leaves
With a delay borth before making a new key, to try to batch up multiple
people leaving into a single key change, and a delay before actually
using the new key to allow time for it to arrive.
This increasingly feels like storing our own sender key in the same set
is suboptimal because we're starting to have to treat it more & more
specially.
* Some errors didn't have data
* Fix binary key comparison
& add log line
* Fix compare function with undefined values
* Test key rotation
* Test caught a merge bug!
* The missing word was, 'delay'
* More input validation
---------
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Co-authored-by: Šimon Brandner <simon.bra.ag@gmail.com>
* WIP refactor for removing m.call events
* Always remember rtcsessions since we need to only have one instance
* Fix tests
* Fix import loop
* Fix more cyclic imports & tests
* Test session joining
* Attempt to make tests happy
* Always leave calls in the tests to clean up
* comment + desperate attempt to work out what's failing
* More test debugging
* Okay, so these ones are fine?
* Stop more timers and hopefully have happy tests
* Test no rejoin
* Test malformed m.call.member events
* Test event emitting
and also move some code to a more sensible place in the file
* Test getActiveFoci()
* Test event emitting (and also fix it)
* Test membership updating & pruning on join
* Test getOldestMembership()
* Test member event renewal
* Don't start the rtc manager until the client has synced
Then we can initialise from the state once it's completed.
* Fix type
* Remove listeners added in constructor
* Stop the client here too
* Stop the client here also also
* ARGH. Disable tests to work out which one is causing the exception
* Disable everything
* Re-jig to avoid setting listeners in the constructor
and re-enable tests
* No need to rename this anymore
* argh, remove the right listener
* Is it this test???
* Re-enable some tests
* Try mocking getRooms to return something valid
* Re-enable other tests
* Give up trying to get the tests to work sensibly and deal with getRooms() returning nothing
* Oops, don't enable the ones that were skipped before
* One more try at the sensible way
* Didn't work, go back to the hack way.
* Log when we manage to send the member event update
* Support `getOpenIdToken()` in embedded mode (#3676)
* Call `sendContentLoaded()` (#3677)
* Start MatrixRTC in embedded mode (#3679)
* Reschedule the membership event check
* Bump widget api version
* Add mock for sendContentLoaded()
* Embeded mode pre-requisites
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Embeded mode E2EE
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Encryption condition
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Revert "Embeded mode pre-requisites"
This reverts commit 8cd73702052609c995ad754e31f85d0da0be4aa9.
* Get back event type
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
fds
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Change embedded E2EE implementation
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* More log detail
* Fix tests
and also better assert because the tests were passing undefined which
was considered fine because we were only checking for null.
* Simplify updateCallMembershipEvent a bit
* Split up updateCallMembershipEvent some more
* Use `crypto.getRandomValues()`
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Rename to `membershipToUserAndDeviceId()`
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Better error
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Add log line
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Add comment
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Send call ID in enc events
(also a small refactor)
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Revert making `joinRoomSession()` async
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Make `client` `private` again
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Just use `toString()`
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Fix `callId` check
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Fix map
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Fix map compare
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Fix emitting
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Explicit logging
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Refactor
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Make `updateEncryptionKeyEvent()` public
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Only update keys based on others
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Fix call order
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Improve logging
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Avoid races
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Revert "Avoid races"
This reverts commit f65ed72d6eaf71711a61db7f05e04899fb137e2d.
* Add try-catch
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Make `updateEncryptionKeyEvent()` private
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Handle indices and throttling
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Fix merge mistakes
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Mort post-merge fixes
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Split out key generation from key sending
And send all keys in a key event (changes the format of the key event)
rather than just the one we just generated.
* Remember and clear the timeout for the send key event
So we don't schedule more key updates if one is already pending.
Also don't update the last sent time when we didn't actually send the
keys.
* Make key event resends more robust
* Attempt to make tests pass
* crypto wasn't defined at all
* Hopefully get interface right
* Fix key format on the wire to base64
* Add comment
* More standard method order
* Rename encryptMedia
The js-sdk doesn't do media and therefore doesn't do media encryption
* Stop logging encryption keys now
* Use regular base64
It's not going in a URL, so no need
* Re-add base64url
randomstring was using it. Also give it a test.
* Add tests for randomstring
* Switch between either browser or node crypto
Let's see if this will work...
* Obviously crypto has already solved this
* Some tests for MatrixRTCSession key stuff
* Test keys object contents
* Change keys event format
To move away from m. keys
* Test key event retries
* Test onCallEncryption
* Test event sending & spam prevention
* Test event cancelation
* Test onCallEncryption called
* Some errors didn't have data
* Fix binary key comparison
& add log line
* Fix compare function with undefined values
* Remove more key logging
* Check content.keys is an array
* Check key index & key
* Better function name
* Tests too
---------
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Co-authored-by: David Baker <dave@matrix.org>
Co-authored-by: David Baker <dbkr@users.noreply.github.com>
* Add membershipID to call memberships
This allows us to recognise easily when a membership is from some
previous sessions rather than our own and therefore ignore it
(see comment for more).
This was causing us to see existing, expired membership events and
bump the expiry on them rather than send a new membership. This might
have been okay if we bumped them enough to actually make them un-expired,
but it's a fresh session so semanticly we want to post a fresh membership
rather than resurrecting a previous, expired membership.
* Fix test types
* Fix tests
* Make test coverage happy
---------
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
* Add hacky option to disable the actual calling part of group calls.
So we can try using livekit instead.
* Put LiveKit info into the `m.call` state event (#3522)
* Put LK info into state
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Update to the new way the LK service works
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
---------
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Send 'contentLoaded' event
As per comment, so we can start digging ourselves out of the widget
API hole we're currently in.
* Add comment on updating the livekit service URL
* Appease CI on `livekit` branch (#3566)
* Update codeowners on `livekit` branch (#3567)
* add getOpenIdToken to embedded client backend
Signed-off-by: Timo K <toger5@hotmail.de>
* add test and update comment
Signed-off-by: Timo K <toger5@hotmail.de>
* Merge `develop` into `livekit` (#3569)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: RiotRobot <releases@riot.im>
Co-authored-by: Florian Duros <florianduros@element.io>
Co-authored-by: Kerry <kerrya@element.io>
Co-authored-by: David Baker <dbkr@users.noreply.github.com>
Co-authored-by: Erik Johnston <erik@matrix.org>
Co-authored-by: Valere <bill.carson@valrsoft.com>
Co-authored-by: Hubert Chathi <hubertc@matrix.org>
Close IDB database before deleting it to prevent spurious unexpected close errors (#3478)
Fix export type `GeneratedSecretStorageKey` (#3479)
Fix order of things in `crypto-api.ts` (#3491)
Fix bug where switching media caused media in subsequent calls to fail (#3489)
fixes (#3515)
fix the integ tests, where #3509 etc fix the unit tests.
fix breakage on node 16 (#3527)
Fix an instance of failed to decrypt error when an in flight `/keys/query` fails. (#3486)
Fix `TypedEventEmitter::removeAllListeners(void)` not working (#3561)
* Revert "Merge `develop` into `livekit`" (#3572)
* Don't update calls with no livekit URL & expose method to update it instead
and generally simplify a bit: change it to a single string rather than
an array of structs.
* Fix other instances of passing focusInfo / livekit url
* Add temporary setter
* WIP refactor for removing m.call events
* Always remember rtcsessions since we need to only have one instance
* Fix tests
* Fix import loop
* Fix more cyclic imports & tests
* Test session joining
* Attempt to make tests happy
* Always leave calls in the tests to clean up
* comment + desperate attempt to work out what's failing
* More test debugging
* Okay, so these ones are fine?
* Stop more timers and hopefully have happy tests
* Test no rejoin
* Test malformed m.call.member events
* Test event emitting
and also move some code to a more sensible place in the file
* Test getActiveFoci()
* Test event emitting (and also fix it)
* Test membership updating & pruning on join
* Test getOldestMembership()
* Test member event renewal
* Don't start the rtc manager until the client has synced
Then we can initialise from the state once it's completed.
* Fix type
* Remove listeners added in constructor
* Stop the client here too
* Stop the client here also also
* ARGH. Disable tests to work out which one is causing the exception
* Disable everything
* Re-jig to avoid setting listeners in the constructor
and re-enable tests
* No need to rename this anymore
* argh, remove the right listener
* Is it this test???
* Re-enable some tests
* Try mocking getRooms to return something valid
* Re-enable other tests
* Give up trying to get the tests to work sensibly and deal with getRooms() returning nothing
* Oops, don't enable the ones that were skipped before
* One more try at the sensible way
* Didn't work, go back to the hack way.
* Log when we manage to send the member event update
* Support `getOpenIdToken()` in embedded mode (#3676)
* Call `sendContentLoaded()` (#3677)
* Start MatrixRTC in embedded mode (#3679)
* Reschedule the membership event check
* Bump widget api version
* Add mock for sendContentLoaded()
* More log detail
* Fix tests
and also better assert because the tests were passing undefined which
was considered fine because we were only checking for null.
* Simplify updateCallMembershipEvent a bit
* Split up updateCallMembershipEvent some more
* Typo
Co-authored-by: Daniel Abramov <inetcrack2@gmail.com>
* Expand comment
* Add comment
* More comments
* Better comment
* Sesson
* Rename some variables
* Comment
* Remove unused method
* Wrap updatecallMembershipEvent so it only runs one at a time
* Do another update if another one is triggered while the update happens
* Make triggerCallMembershipEventUpdate async
* Fix test & some missed timer removals
* Mark session manager as unstable
---------
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Signed-off-by: Timo K <toger5@hotmail.de>
Co-authored-by: Šimon Brandner <simon.bra.ag@gmail.com>
Co-authored-by: Timo K <toger5@hotmail.de>
Co-authored-by: Timo <16718859+toger5@users.noreply.github.com>
Co-authored-by: Daniel Abramov <inetcrack2@gmail.com>