* Implement Sticky Events MSC
* Renames
* lint
* some review work
* Update for support for 4-ples
* fix lint
* pull through method
* Fix the mistake
* More tests to appease SC
* Cleaner code
* Review cleanup
* Refactors based on review.
* lint
* Add sticky event support to the js-sdk
Signed-off-by: Timo K <toger5@hotmail.de>
* use sticky events for matrixRTC
Signed-off-by: Timo K <toger5@hotmail.de>
* make sticky events a non breaking change (default to state events. use joinConfig to use sticky events)
Signed-off-by: Timo K <toger5@hotmail.de>
* review
- fix types (`msc4354_sticky:number` -> `msc4354_sticky?: { duration_ms: number };`)
- add `MultiKeyMap`
Signed-off-by: Timo K <toger5@hotmail.de>
* Refactor all of this away to it's own accumulator and class.
* Add tests
* tidyup
* more test cleaning
* lint
* Updates and tests
* fix filter
* fix filter with lint
* Add timer tests
* Add tests for MatrixRTCSessionManager
* Listen for sticky events on MatrixRTCSessionManager
* fix logic on filtering out state events
* lint
* more lint
* tweaks
* Add logging in areas
* more debugging
* much more logging
* remove more logging
* Finish supporting new MSC
* a line
* reconnect the bits to RTC
* fixup more bits
* fixup testrs
* Ensure consistent order
* lint
* fix log line
* remove extra bit of code
* revert changes to room-sticky-events.ts
* fixup mocks again
* lint
* fix
* cleanup
* fix paths
* tweak test
* fixup
* Add more tests for coverage
* Small improvements
Signed-off-by: Timo K <toger5@hotmail.de>
* review
Signed-off-by: Timo K <toger5@hotmail.de>
* Document better
* fix sticky event type
Signed-off-by: Timo K <toger5@hotmail.de>
* fix demo
Signed-off-by: Timo K <toger5@hotmail.de>
* fix tests
Signed-off-by: Timo K <toger5@hotmail.de>
* Update src/matrixrtc/CallMembership.ts
Co-authored-by: Robin <robin@robin.town>
* cleanup
* lint
* fix ci
Signed-off-by: Timo K <toger5@hotmail.de>
---------
Signed-off-by: Timo K <toger5@hotmail.de>
Co-authored-by: Half-Shot <will@half-shot.uk>
Co-authored-by: Robin <robin@robin.town>
* add parseCallNotificationContent
Signed-off-by: Timo K <toger5@hotmail.de>
* add tests
Signed-off-by: Timo K <toger5@hotmail.de>
* remove decline reason and better m.mentions check
Signed-off-by: Timo K <toger5@hotmail.de>
* cap ring duration to EX value (90s)
Signed-off-by: Timo K <toger5@hotmail.de>
---------
Signed-off-by: Timo K <toger5@hotmail.de>
* WIP
* temp
Signed-off-by: Timo K <toger5@hotmail.de>
* Fix imports
* Fix checkSessionsMembershipData thinking foci_preferred is required
* incorporate CallMembership changes
- rename Focus -> Transport
- add RtcMembershipData (next to `sessionMembershipData`)
- make `new CallMembership` initializable with both
- move oldest member calculation into CallMembership
Signed-off-by: Timo K <toger5@hotmail.de>
* use correct event type
Signed-off-by: Timo K <toger5@hotmail.de>
* fix sonar cube conerns
Signed-off-by: Timo K <toger5@hotmail.de>
* callMembership tests
Signed-off-by: Timo K <toger5@hotmail.de>
* make test correct
Signed-off-by: Timo K <toger5@hotmail.de>
* make sonar cube happy (it does not know about the type constraints...)
Signed-off-by: Timo K <toger5@hotmail.de>
* remove created_ts from RtcMembership
Signed-off-by: Timo K <toger5@hotmail.de>
* fix imports
Signed-off-by: Timo K <toger5@hotmail.de>
* Update src/matrixrtc/IMembershipManager.ts
Co-authored-by: Robin <robin@robin.town>
* rename LivekitFocus.ts -> LivekitTransport.ts
Signed-off-by: Timo K <toger5@hotmail.de>
* add details to `getTransport`
Signed-off-by: Timo K <toger5@hotmail.de>
* review
Signed-off-by: Timo K <toger5@hotmail.de>
* use DEFAULT_EXPIRE_DURATION in tests
Signed-off-by: Timo K <toger5@hotmail.de>
* fix test `does not provide focus if the selection method is unknown`
Signed-off-by: Timo K <toger5@hotmail.de>
* Update src/matrixrtc/CallMembership.ts
Co-authored-by: Robin <robin@robin.town>
* Move `m.call.intent` into the `application` section for rtc member events.
Signed-off-by: Timo K <toger5@hotmail.de>
* review on rtc object validation code.
Signed-off-by: Timo K <toger5@hotmail.de>
* user id check
Signed-off-by: Timo K <toger5@hotmail.de>
* review: Refactor RTC membership handling and improve error handling
Signed-off-by: Timo K <toger5@hotmail.de>
* docstring updates
Signed-off-by: Timo K <toger5@hotmail.de>
* add back deprecated `getFocusInUse` & `getActiveFocus`
Signed-off-by: Timo K <toger5@hotmail.de>
* ci
Signed-off-by: Timo K <toger5@hotmail.de>
* Update src/matrixrtc/CallMembership.ts
Co-authored-by: Robin <robin@robin.town>
* lint
Signed-off-by: Timo K <toger5@hotmail.de>
* make test less strict for ew tests
Signed-off-by: Timo K <toger5@hotmail.de>
* Typescript downstream test adjustments
Signed-off-by: Timo K <toger5@hotmail.de>
* err
Signed-off-by: Timo K <toger5@hotmail.de>
---------
Signed-off-by: Timo K <toger5@hotmail.de>
Co-authored-by: Robin <robin@robin.town>
- rename Focus -> Transport
- add RtcMembershipData (next to `sessionMembershipData`)
- make `new CallMembership` initializable with both
- move oldest member calculation into CallMembership
Signed-off-by: Timo K <toger5@hotmail.de>
* Add media hint specifier
* Refactor to use m.call.intent and to apply to membership
* lint
* Add a mechanism to get the consensus of a call.
* Update tests
* Expose option to update the call intent.
* Better docs
* Add tests
* lint
* Expose the StatusChanged event through the RTCSession
Signed-off-by: Timo K <toger5@hotmail.de>
* add membershipManagerStatus public get field
Signed-off-by: Timo K <toger5@hotmail.de>
* add probably left as a getter
Signed-off-by: Timo K <toger5@hotmail.de>
* add tests for coverage
Signed-off-by: Timo K <toger5@hotmail.de>
---------
Signed-off-by: Timo K <toger5@hotmail.de>
* Add probablyLeft emission to the MatrixRTCSession
Signed-off-by: Timo K <toger5@hotmail.de>
* add docstring
Signed-off-by: Timo K <toger5@hotmail.de>
* Review: add additional test + fix pending promises issue.
Signed-off-by: Timo K <toger5@hotmail.de>
* review: `Pick` only a subset of membership manager events
Signed-off-by: Timo K <toger5@hotmail.de>
* reveiw: update probablyLeft logic to be more straight forward
Signed-off-by: Timo K <toger5@hotmail.de>
* fix test
Signed-off-by: Timo K <toger5@hotmail.de>
* make test not wait for 5s
Signed-off-by: Timo K <toger5@hotmail.de>
* review
Signed-off-by: Timo K <toger5@hotmail.de>
* fix linter (rebase)
Signed-off-by: Timo K <toger5@hotmail.de>
* fix import
Signed-off-by: Timo K <toger5@hotmail.de>
---------
Signed-off-by: Timo K <toger5@hotmail.de>
* Introduce sessionDescription
Signed-off-by: Timo K <toger5@hotmail.de>
* Make sessionDescription part of a MatrixRTCSession
Signed-off-by: Timo K <toger5@hotmail.de>
* Make session manager only menage session for one sessionDescription
Signed-off-by: Timo K <toger5@hotmail.de>
* make membership manager aware about session (application + id)
Before this was just hardcoded to a call session
Signed-off-by: Timo K <toger5@hotmail.de>
* update tests
Signed-off-by: Timo K <toger5@hotmail.de>
* fix doc comments
Signed-off-by: Timo K <toger5@hotmail.de>
* Make fields private, improve comments, improve whitespace, don't use deprecated fields
Signed-off-by: Timo K <toger5@hotmail.de>
* add test for other application end event
Signed-off-by: Timo K <toger5@hotmail.de>
* rename call -> session
Signed-off-by: Timo K <toger5@hotmail.de>
* fix tests
Signed-off-by: Timo K <toger5@hotmail.de>
* remove id check since its already part of `deepCompare(membership.sessionDescription, sessionDescription)`
Signed-off-by: Timo K <toger5@hotmail.de>
* remove scope related tests. The id should be the only thing that scopes sessions. everything else is application (session type) specific
Signed-off-by: Timo K <toger5@hotmail.de>
* review
Signed-off-by: Timo K <toger5@hotmail.de>
* add test for custom sessionDescription
Signed-off-by: Timo K <toger5@hotmail.de>
* callMembershipsForRoom to default to call
Signed-off-by: Timo K <toger5@hotmail.de>
* roomSessionForRoom backwards compatible (And deprecate the call specific method)
Signed-off-by: Timo K <toger5@hotmail.de>
---------
Signed-off-by: Timo K <toger5@hotmail.de>
* RTCEncryptionManager: Joiner key rotation grace period
* Test to clarify useKeyDelay and keyRotationGracePeriodMs interference
* make test more configurable
* rename delayRolloutTimeMillis to useKeyDelay same as config option
* rename skipRotationGracePeriod to keyRotationGracePeriodMs
* clarify that oldMemberships is not used by RTCEncryptionManager
* improve doc
* cleanup test
* more comment in test
* comment additions
* cleanup runOnlyPendingTimers
---------
Co-authored-by: Timo <toger5@hotmail.de>
* Make it easier to mock call memberships for specific user IDs
* Allow sending notification events when starting a call
* rename notify -> notification
* replace `joining` concept with `ownMembership`
* introduce new `m.rtc.notification` event alongside `m.call.notify`
* send new notification event alongside the deprecated one
* Test for new notification event type
* update relation string to match msc
* review
* fix doc errors
* fix tests + format
* remove anything decline related
---------
Co-authored-by: Timo <toger5@hotmail.de>
* refactor: New encryption manager BasicEncryptionManager for todevice
fixup: bad do not commit
* fix: ToDevice transport not setting the sent_ts
* test: BasicEncryptionManager add statistics tests
* code review
* feat: Encryption manager just reshare on new joiner
* refactor: Rename BasicEncryptionManger to RTCEncryptionManager
* fixup: RTC experimental todevice should use new encryption mgr
* fixup: use proper logger hierarchy
* fixup: RTC rollout first key asap even if no members to send to
* fixup: RTC add test for first key use
* fixup! emitting outbound key before anyone registered
* fix: quick patch for transport switch, need test
* test: RTC encryption manager, add test for transport switch
* post rebase fix
* Remove bad corepack commit
* review: cleaning, renaming
* review: cleaning and renaming
* stop using root logger in favor of a parent logger
* post merge fix broken test
* remove corepack again
* fix reverted changes after a merge
* review: Properly deprecate getEncryptionKeys
* review: rename ensureMediaKeyDistribution to ensureKeyDistribution
* review: use OutdatedKeyFilter instead of KeyBuffer
* Remove `LegacyMemberhsipManager`
* remove tests from rtc session
Those tests were only run with the legacy membership manager and are redundant with the memberhsip manager test spec.
* fix tests
* dont use non existing TestManager anymore
* remove fails for legacy
* fix another test
* Check for `unknown variant` on to-device sending and fallback to room event encryption.
* fix tests
* fix error js-sdk api type
* Change logger from debug to warn for unsupported to-device transport and improve error message comments
* also add case for not supported
This will be send by the driver in case we sent an encrypted to-device but do not have support of that.
---------
Co-authored-by: Robin <robin@robin.town>
* Remove redundant sendDelayedEventAction
We do already have the state `hasMemberEvent` that allows to distinguish the two cases. No need to create two dedicated actions.
* fix missing return
* Make membership manager an event emitter to inform about status updates.
- deprecate isJoined (replaced by isActivated)
- move Interface types to types.ts
* add tests for status updates.
* lint
* test "reschedules delayed leave event" in case the delayed event gets canceled
* review
* fix types
* prettier
* fix legacy membership manager
* remove deprecated jitter.
* use non deprecated config fields (keep deprecated fields as fallback)
* update tests to test non deprecated names
* make local NewMembershipManager variable names consistent with config
* make LegacyMembershipManger local variables consistent with config
* comments and rename `networkErrorLocalRetryMs` -> `networkErrorRetryMs`
* review
* Switch from defer to Promise.withResolvers
As supported by the outgoing LTS version (v22) which has 99% support of ES2024
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
* delint
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
* Deprecate defer instead of killing it
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
* Knip
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
* Iterate based on review
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
* Iterate based on review
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
* Iterate based on review
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
* Improve coverage
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---------
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
* 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>
* Remove redundant sendDelayedEventAction
We do already have the state `hasMemberEvent` that allows to distinguish the two cases. No need to create two dedicated actions.
* fix missing return
* Make membership manager an event emitter to inform about status updates.
- deprecate isJoined (replaced by isActivated)
- move Interface types to types.ts
* add tests for status updates.
* lint
* test "reschedules delayed leave event" in case the delayed event gets canceled
* review
* fix types
* prettier
* fix legacy membership manager
* 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
* temp
* fix wrong mocked meberhsip template
* rename MembershipManager -> LegacyMembershipManager
And remove the IMembershipManager from it
* Add new memberhsip manager
* fix tests to be compatible with old and new membership manager
* Comment cleanup
* Allow join to throw
- Add tests for throwing cases
- Fixs based on tests
* introduce membershipExpiryTimeoutSlack
* more detailed comments and cleanup
* warn if slack is misconfigured and use default values instead
* fix action resets.
* flatten MembershipManager.spec.ts
* rename testEnvironment to memberManagerTestEnvironment
* allow configuring Legacy manager in the matrixRTC session
* deprecate LegacyMembershipManager
* remove usage of waitForExpect
* flatten tests and add comments
* clean up leave logic branch
* add more leave test cases
* use defer
* review ("Some minor tidying things for now.")
* add onError for join method and cleanup
* use pop instead of filter
* fixes
* simplify error handling and MembershipAction
Only use one membership action enum
* Add diagram
* fix new error api in rtc session
* fix up retry counter
* fix lints
* make unrecoverable errors more explicit
* fix tests
* Allow multiple retries on the rtc state event http requests.
* use then catch for startup
* no try catch 1
* update expire headroom logic
transition from try catch to .then .catch
* replace flushPromise with advanceTimersByTimeAsync
* fix leaving special cases
* more unrecoverable errors special cases
* move to MatrixRTCSessionManager logger
* add state reset and add another unhandleable error
The error occurs if we want to cancel the delayed event we still have an id for but get a non expected error.
* missed review fixes
* 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
* fix not recreating default state on reset
This broke all tests since we only created the state once and than passed by ref
* Use per action rate limit and retry counter
There can be multiple retries at once so we need to store counters per action
e.g. the send update membership and the restart delayed could be rate limited at the same time.
* add linting to matrixrtc tests
* Add fix async lints and use matrix rtc logger for test environment.
* prettier
* review step 1
* change to MatrixRTCSession logger
* review step 2
* make LoopHandler Private
* update config to use NewManager wording
* emit error on rtc session if the membership manager encounters one
* network error and throw refactor
* make accessing the full room deprecated
* remove deprecated usage of full room
* Clean up the deprecation
* add network error handler and cleanup
* better logging, another test, make maximumNetworkErrorRetryCount configurable
* more logging & refactor leave promise
* add ConnectionError as possible retry cause
* Make it work in embedded mode with a server that does not support delayed events
* review iteration 1
* review iteration 2
* first step in improving widget error handling
* make the embedded client throw ConnectionErrors where desired.
* fix tests
* delayed event sending widget mode stop gap fix.
* improve comment
* fix unrecoverable error joinState (and add JoinStateChanged) emission.
* check that we do not add multipe sendFirstDelayed Events
* also check insertions queue
* always log "Missing own membership: force re-join"
* Do not update the membership if we are in any (a later) state of sending our own state.
The scheduled states MembershipActionType.SendFirstDelayedEvent and MembershipActionType.SendJoinEvent both imply that we are already trying to send our own membership state event.
* make leave reset actually stop the manager.
The reset case was not covered properly. There are cases where it is not allowed to add additional events after a reset and cases where we want to add more events after the reset. We need to allow this as a reset property.
* fix tests (and implementation)
* Allow MembershipManger to be set at runtime via JoinConfig.membershipManagerFactory
* Map actions into status as a sanity check
* Log status change after applying actions
* Add todo
* Cleanup
* Log transition from earlier status
* remove redundant status implementation
also add TODO comment to not forget about this.
* More cleanup
* Consider insertions in status()
* Log duration for emitting MatrixRTCSessionEvent.MembershipsChanged
* add another valid condition for connected
* some TODO cleanup
* review add warning when using addAction while the scheduler is not running.
* es lint
* refactor to return based handler approach (remove insertions array)
* refactor: Move action scheduler
* refactor: move different handler cases into separate functions
* linter
* review: delayed events endpoint error
* review
* Suggestions from pair review
* resetState is actually only used internally
* Revert "resetState is actually only used internally"
This reverts commit 6af4730919.
* refactor: running is part of the scheduler (not state)
* refactor: move everything state related from schduler to manager.
* review
* Update src/matrixrtc/NewMembershipManager.ts
Co-authored-by: Hugh Nimmo-Smith <hughns@users.noreply.github.com>
* review
* public -> private + missed review fiexes (comment typos)
---------
Co-authored-by: Hugh Nimmo-Smith <hughns@matrix.org>
Co-authored-by: Hugh Nimmo-Smith <hughns@users.noreply.github.com>
* 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>