matrix-js-sdk 41.8.0 → 41.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +1 -1
- package/lib/@types/AESEncryptedSecretStoragePayload.js +3 -1
- package/lib/@types/IIdentityServerProvider.js +3 -1
- package/lib/@types/PushRules.js +7 -7
- package/lib/@types/PushRules.js.map +1 -1
- package/lib/@types/auth.js +4 -4
- package/lib/@types/auth.js.map +1 -1
- package/lib/@types/beacon.js +2 -2
- package/lib/@types/beacon.js.map +1 -1
- package/lib/@types/common.js +3 -1
- package/lib/@types/crypto.js +3 -1
- package/lib/@types/event.js +20 -20
- package/lib/@types/event.js.map +1 -1
- package/lib/@types/events.js +3 -1
- package/lib/@types/extensible_events.js +6 -6
- package/lib/@types/extensible_events.js.map +1 -1
- package/lib/@types/global.d.js.map +1 -1
- package/lib/@types/json.js +3 -1
- package/lib/@types/local_notifications.js +3 -1
- package/lib/@types/location.js +4 -4
- package/lib/@types/location.js.map +1 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js +3 -1
- package/lib/@types/media.js +3 -1
- package/lib/@types/membership.js +1 -1
- package/lib/@types/membership.js.map +1 -1
- package/lib/@types/partials.js +6 -6
- package/lib/@types/partials.js.map +1 -1
- package/lib/@types/polls.js +5 -5
- package/lib/@types/polls.js.map +1 -1
- package/lib/@types/read_receipts.js +2 -2
- package/lib/@types/read_receipts.js.map +1 -1
- package/lib/@types/registration.js +3 -1
- package/lib/@types/requests.js +1 -1
- package/lib/@types/requests.js.map +1 -1
- package/lib/@types/retention.js +1 -1
- package/lib/@types/retention.js.map +1 -1
- package/lib/@types/search.js +1 -1
- package/lib/@types/search.js.map +1 -1
- package/lib/@types/signed.js +3 -1
- package/lib/@types/spaces.js +3 -1
- package/lib/@types/state_events.js +3 -1
- package/lib/@types/synapse.js +3 -1
- package/lib/@types/sync.js +1 -1
- package/lib/@types/sync.js.map +1 -1
- package/lib/@types/threepids.js +1 -1
- package/lib/@types/threepids.js.map +1 -1
- package/lib/@types/topic.js +1 -1
- package/lib/@types/topic.js.map +1 -1
- package/lib/@types/uia.js +3 -1
- package/lib/NamespacedValue.js +8 -8
- package/lib/NamespacedValue.js.map +1 -1
- package/lib/ReEmitter.js +9 -16
- package/lib/ReEmitter.js.map +1 -1
- package/lib/ToDeviceMessageQueue.js +49 -57
- package/lib/ToDeviceMessageQueue.js.map +1 -1
- package/lib/autodiscovery.js +232 -247
- package/lib/autodiscovery.js.map +1 -1
- package/lib/base64.js +1 -1
- package/lib/base64.js.map +1 -1
- package/lib/browser-index.d.ts +2 -2
- package/lib/browser-index.d.ts.map +1 -1
- package/lib/browser-index.js +5 -5
- package/lib/browser-index.js.map +1 -1
- package/lib/capabilityPoller.js +19 -22
- package/lib/capabilityPoller.js.map +1 -1
- package/lib/client.d.ts +2 -8
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +2043 -2487
- package/lib/client.js.map +1 -1
- package/lib/common-crypto/CryptoBackend.js +2 -2
- package/lib/common-crypto/CryptoBackend.js.map +1 -1
- package/lib/common-crypto/key-passphrase.js.map +1 -1
- package/lib/content-helpers.js +43 -48
- package/lib/content-helpers.js.map +1 -1
- package/lib/content-repo.js +14 -24
- package/lib/content-repo.js.map +1 -1
- package/lib/crypto/store/base.js +6 -6
- package/lib/crypto/store/base.js.map +1 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.js +190 -238
- package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +1 -1
- package/lib/crypto/store/indexeddb-crypto-store.js +25 -30
- package/lib/crypto/store/indexeddb-crypto-store.js.map +1 -1
- package/lib/crypto/store/localStorage-crypto-store.js +113 -145
- package/lib/crypto/store/localStorage-crypto-store.js.map +1 -1
- package/lib/crypto/store/memory-crypto-store.js +74 -105
- package/lib/crypto/store/memory-crypto-store.js.map +1 -1
- package/lib/crypto-api/CryptoEvent.js +1 -1
- package/lib/crypto-api/CryptoEvent.js.map +1 -1
- package/lib/crypto-api/CryptoEventHandlerMap.js +3 -1
- package/lib/crypto-api/index.d.ts +15 -6
- package/lib/crypto-api/index.d.ts.map +1 -1
- package/lib/crypto-api/index.js +22 -22
- package/lib/crypto-api/index.js.map +1 -1
- package/lib/crypto-api/key-passphrase.js +15 -23
- package/lib/crypto-api/key-passphrase.js.map +1 -1
- package/lib/crypto-api/keybackup.js +3 -1
- package/lib/crypto-api/recovery-key.js +11 -12
- package/lib/crypto-api/recovery-key.js.map +1 -1
- package/lib/crypto-api/verification.js +3 -3
- package/lib/crypto-api/verification.js.map +1 -1
- package/lib/digest.js +7 -14
- package/lib/digest.js.map +1 -1
- package/lib/embedded.d.ts.map +1 -1
- package/lib/embedded.js +380 -505
- package/lib/embedded.js.map +1 -1
- package/lib/errors.js +2 -2
- package/lib/errors.js.map +1 -1
- package/lib/event-mapper.js +10 -12
- package/lib/event-mapper.js.map +1 -1
- package/lib/extensible_events_v1/ExtensibleEvent.js.map +1 -1
- package/lib/extensible_events_v1/InvalidEventError.js.map +1 -1
- package/lib/extensible_events_v1/MessageEvent.js +11 -13
- package/lib/extensible_events_v1/MessageEvent.js.map +1 -1
- package/lib/extensible_events_v1/PollEndEvent.js +3 -4
- package/lib/extensible_events_v1/PollEndEvent.js.map +1 -1
- package/lib/extensible_events_v1/PollResponseEvent.js +5 -6
- package/lib/extensible_events_v1/PollResponseEvent.js.map +1 -1
- package/lib/extensible_events_v1/PollStartEvent.js +8 -10
- package/lib/extensible_events_v1/PollStartEvent.js.map +1 -1
- package/lib/extensible_events_v1/utilities.js.map +1 -1
- package/lib/feature.js +18 -31
- package/lib/feature.js.map +1 -1
- package/lib/filter-component.d.ts.map +1 -1
- package/lib/filter-component.js +20 -26
- package/lib/filter-component.js.map +1 -1
- package/lib/filter.js +14 -17
- package/lib/filter.js.map +1 -1
- package/lib/http-api/errors.js +28 -43
- package/lib/http-api/errors.js.map +1 -1
- package/lib/http-api/fetch.js +141 -159
- package/lib/http-api/fetch.js.map +1 -1
- package/lib/http-api/index.js +17 -20
- package/lib/http-api/index.js.map +1 -1
- package/lib/http-api/interface.js +1 -1
- package/lib/http-api/interface.js.map +1 -1
- package/lib/http-api/method.js +1 -1
- package/lib/http-api/method.js.map +1 -1
- package/lib/http-api/prefix.js +3 -3
- package/lib/http-api/prefix.js.map +1 -1
- package/lib/http-api/refresh.js +74 -94
- package/lib/http-api/refresh.js.map +1 -1
- package/lib/http-api/utils.d.ts +1 -1
- package/lib/http-api/utils.d.ts.map +1 -1
- package/lib/http-api/utils.js +34 -42
- package/lib/http-api/utils.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/indexeddb-helpers.js +3 -3
- package/lib/indexeddb-helpers.js.map +1 -1
- package/lib/indexeddb-worker.js.map +1 -1
- package/lib/interactive-auth.d.ts +5 -5
- package/lib/interactive-auth.d.ts.map +1 -1
- package/lib/interactive-auth.js +172 -204
- package/lib/interactive-auth.js.map +1 -1
- package/lib/logger.js +21 -57
- package/lib/logger.js.map +1 -1
- package/lib/matrix.js +7 -11
- package/lib/matrix.js.map +1 -1
- package/lib/matrixrtc/CallMembership.js +80 -74
- package/lib/matrixrtc/CallMembership.js.map +1 -1
- package/lib/matrixrtc/EncryptionManager.js +1 -1
- package/lib/matrixrtc/EncryptionManager.js.map +1 -1
- package/lib/matrixrtc/IKeyTransport.js +1 -1
- package/lib/matrixrtc/IKeyTransport.js.map +1 -1
- package/lib/matrixrtc/IMembershipManager.js +1 -1
- package/lib/matrixrtc/IMembershipManager.js.map +1 -1
- package/lib/matrixrtc/LivekitTransport.d.ts +1 -1
- package/lib/matrixrtc/LivekitTransport.js +4 -4
- package/lib/matrixrtc/LivekitTransport.js.map +1 -1
- package/lib/matrixrtc/MatrixRTCSession.js +137 -187
- package/lib/matrixrtc/MatrixRTCSession.js.map +1 -1
- package/lib/matrixrtc/MatrixRTCSessionManager.js +36 -41
- package/lib/matrixrtc/MatrixRTCSessionManager.js.map +1 -1
- package/lib/matrixrtc/MembershipManager.js +332 -378
- package/lib/matrixrtc/MembershipManager.js.map +1 -1
- package/lib/matrixrtc/MembershipManagerActionScheduler.js +54 -63
- package/lib/matrixrtc/MembershipManagerActionScheduler.js.map +1 -1
- package/lib/matrixrtc/RTCEncryptionManager.js +119 -143
- package/lib/matrixrtc/RTCEncryptionManager.js.map +1 -1
- package/lib/matrixrtc/ToDeviceKeyTransport.js +53 -58
- package/lib/matrixrtc/ToDeviceKeyTransport.js.map +1 -1
- package/lib/matrixrtc/index.js.map +1 -1
- package/lib/matrixrtc/membershipData/common.js +1 -1
- package/lib/matrixrtc/membershipData/common.js.map +1 -1
- package/lib/matrixrtc/membershipData/index.js.map +1 -1
- package/lib/matrixrtc/membershipData/rtc.js +15 -23
- package/lib/matrixrtc/membershipData/rtc.js.map +1 -1
- package/lib/matrixrtc/membershipData/session.js +4 -5
- package/lib/matrixrtc/membershipData/session.js.map +1 -1
- package/lib/matrixrtc/types.js +4 -6
- package/lib/matrixrtc/types.js.map +1 -1
- package/lib/matrixrtc/utils.js +4 -11
- package/lib/matrixrtc/utils.js.map +1 -1
- package/lib/models/MSC3089Branch.js +91 -116
- package/lib/models/MSC3089Branch.js.map +1 -1
- package/lib/models/MSC3089TreeSpace.js +209 -245
- package/lib/models/MSC3089TreeSpace.js.map +1 -1
- package/lib/models/ToDeviceMessage.js +3 -1
- package/lib/models/beacon.js +14 -13
- package/lib/models/beacon.js.map +1 -1
- package/lib/models/compare-event-ordering.js +13 -13
- package/lib/models/compare-event-ordering.js.map +1 -1
- package/lib/models/device.js +3 -3
- package/lib/models/device.js.map +1 -1
- package/lib/models/event-context.js +5 -8
- package/lib/models/event-context.js.map +1 -1
- package/lib/models/event-status.js +1 -1
- package/lib/models/event-status.js.map +1 -1
- package/lib/models/event-timeline-set.js +88 -94
- package/lib/models/event-timeline-set.js.map +1 -1
- package/lib/models/event-timeline.js +28 -30
- package/lib/models/event-timeline.js.map +1 -1
- package/lib/models/event.js +182 -226
- package/lib/models/event.js.map +1 -1
- package/lib/models/invites-ignorer-types.js +4 -4
- package/lib/models/invites-ignorer-types.js.map +1 -1
- package/lib/models/invites-ignorer.js +159 -179
- package/lib/models/invites-ignorer.js.map +1 -1
- package/lib/models/poll.js +71 -81
- package/lib/models/poll.js.map +1 -1
- package/lib/models/profile-keys.js +2 -2
- package/lib/models/profile-keys.js.map +1 -1
- package/lib/models/read-receipt.js +40 -56
- package/lib/models/read-receipt.js.map +1 -1
- package/lib/models/related-relations.js.map +1 -1
- package/lib/models/relations-container.js +22 -23
- package/lib/models/relations-container.js.map +1 -1
- package/lib/models/relations.js +133 -159
- package/lib/models/relations.js.map +1 -1
- package/lib/models/room-member.js +24 -29
- package/lib/models/room-member.js.map +1 -1
- package/lib/models/room-receipts.js +29 -43
- package/lib/models/room-receipts.js.map +1 -1
- package/lib/models/room-retention.js +74 -83
- package/lib/models/room-retention.js.map +1 -1
- package/lib/models/room-state.js +143 -172
- package/lib/models/room-state.js.map +1 -1
- package/lib/models/room-sticky-events.d.ts +1 -0
- package/lib/models/room-sticky-events.d.ts.map +1 -1
- package/lib/models/room-sticky-events.js +45 -65
- package/lib/models/room-sticky-events.js.map +1 -1
- package/lib/models/room-summary.js.map +1 -1
- package/lib/models/room.d.ts.map +1 -1
- package/lib/models/room.js +765 -909
- package/lib/models/room.js.map +1 -1
- package/lib/models/search-result.js +5 -5
- package/lib/models/search-result.js.map +1 -1
- package/lib/models/thread.js +225 -285
- package/lib/models/thread.js.map +1 -1
- package/lib/models/typed-event-emitter.js +7 -18
- package/lib/models/typed-event-emitter.js.map +1 -1
- package/lib/models/user.js +8 -8
- package/lib/models/user.js.map +1 -1
- package/lib/oidc/authorize.js +208 -241
- package/lib/oidc/authorize.js.map +1 -1
- package/lib/oidc/discovery.js +23 -36
- package/lib/oidc/discovery.js.map +1 -1
- package/lib/oidc/error.js +1 -1
- package/lib/oidc/error.js.map +1 -1
- package/lib/oidc/index.js +1 -0
- package/lib/oidc/index.js.map +1 -1
- package/lib/oidc/register.js +60 -66
- package/lib/oidc/register.js.map +1 -1
- package/lib/oidc/tokenRefresher.js +77 -91
- package/lib/oidc/tokenRefresher.js.map +1 -1
- package/lib/oidc/validate.js +18 -18
- package/lib/oidc/validate.js.map +1 -1
- package/lib/pushprocessor.js +71 -82
- package/lib/pushprocessor.js.map +1 -1
- package/lib/randomstring.js +9 -9
- package/lib/randomstring.js.map +1 -1
- package/lib/realtime-callbacks.js +25 -28
- package/lib/realtime-callbacks.js.map +1 -1
- package/lib/receipt-accumulator.d.ts +2 -0
- package/lib/receipt-accumulator.d.ts.map +1 -1
- package/lib/receipt-accumulator.js +14 -22
- package/lib/receipt-accumulator.js.map +1 -1
- package/lib/rendezvous/MSC4108SignInWithQR.js +271 -302
- package/lib/rendezvous/MSC4108SignInWithQR.js.map +1 -1
- package/lib/rendezvous/RendezvousChannel.js +3 -1
- package/lib/rendezvous/RendezvousCode.js +3 -1
- package/lib/rendezvous/RendezvousError.js.map +1 -1
- package/lib/rendezvous/RendezvousFailureReason.js +2 -2
- package/lib/rendezvous/RendezvousFailureReason.js.map +1 -1
- package/lib/rendezvous/RendezvousIntent.js +1 -1
- package/lib/rendezvous/RendezvousIntent.js.map +1 -1
- package/lib/rendezvous/RendezvousTransport.js +3 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.js +123 -147
- package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +1 -1
- package/lib/rendezvous/index.js +44 -69
- package/lib/rendezvous/index.js.map +1 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +1 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js +134 -152
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +1 -1
- package/lib/retentionPolicy.js +6 -9
- package/lib/retentionPolicy.js.map +1 -1
- package/lib/room-hierarchy.js +52 -60
- package/lib/room-hierarchy.js.map +1 -1
- package/lib/rust-crypto/CrossSigningIdentity.js +94 -104
- package/lib/rust-crypto/CrossSigningIdentity.js.map +1 -1
- package/lib/rust-crypto/DehydratedDeviceManager.js +157 -190
- package/lib/rust-crypto/DehydratedDeviceManager.js.map +1 -1
- package/lib/rust-crypto/KeyClaimManager.js +18 -22
- package/lib/rust-crypto/KeyClaimManager.js.map +1 -1
- package/lib/rust-crypto/OutgoingRequestProcessor.js +109 -139
- package/lib/rust-crypto/OutgoingRequestProcessor.js.map +1 -1
- package/lib/rust-crypto/OutgoingRequestsManager.js +66 -80
- package/lib/rust-crypto/OutgoingRequestsManager.js.map +1 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +1 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +196 -224
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +1 -1
- package/lib/rust-crypto/RoomEncryptor.js +127 -143
- package/lib/rust-crypto/RoomEncryptor.js.map +1 -1
- package/lib/rust-crypto/backup.js +453 -549
- package/lib/rust-crypto/backup.js.map +1 -1
- package/lib/rust-crypto/constants.js +1 -1
- package/lib/rust-crypto/constants.js.map +1 -1
- package/lib/rust-crypto/device-converter.js +15 -28
- package/lib/rust-crypto/device-converter.js.map +1 -1
- package/lib/rust-crypto/index.js +103 -116
- package/lib/rust-crypto/index.js.map +1 -1
- package/lib/rust-crypto/libolm_migration.js +303 -365
- package/lib/rust-crypto/libolm_migration.js.map +1 -1
- package/lib/rust-crypto/rust-crypto.d.ts +5 -1
- package/lib/rust-crypto/rust-crypto.d.ts.map +1 -1
- package/lib/rust-crypto/rust-crypto.js +1067 -1332
- package/lib/rust-crypto/rust-crypto.js.map +1 -1
- package/lib/rust-crypto/secret-storage.js +12 -25
- package/lib/rust-crypto/secret-storage.js.map +1 -1
- package/lib/rust-crypto/verification.js +137 -189
- package/lib/rust-crypto/verification.js.map +1 -1
- package/lib/scheduler.js +44 -19
- package/lib/scheduler.js.map +1 -1
- package/lib/secret-storage.js +179 -213
- package/lib/secret-storage.js.map +1 -1
- package/lib/serverCapabilities.js +6 -9
- package/lib/serverCapabilities.js.map +1 -1
- package/lib/service-types.js +1 -1
- package/lib/service-types.js.map +1 -1
- package/lib/sliding-sync-sdk.d.ts.map +1 -1
- package/lib/sliding-sync-sdk.js +368 -424
- package/lib/sliding-sync-sdk.js.map +1 -1
- package/lib/sliding-sync.js +135 -171
- package/lib/sliding-sync.js.map +1 -1
- package/lib/store/index.js +3 -1
- package/lib/store/indexeddb-backend.js +3 -1
- package/lib/store/indexeddb-local-backend.js +194 -253
- package/lib/store/indexeddb-local-backend.js.map +1 -1
- package/lib/store/indexeddb-remote-backend.js +33 -63
- package/lib/store/indexeddb-remote-backend.js.map +1 -1
- package/lib/store/indexeddb-store-worker.js +22 -23
- package/lib/store/indexeddb-store-worker.js.map +1 -1
- package/lib/store/indexeddb.js +44 -71
- package/lib/store/indexeddb.js.map +1 -1
- package/lib/store/local-storage-events-emitter.js +2 -2
- package/lib/store/local-storage-events-emitter.js.map +1 -1
- package/lib/store/memory.js +34 -57
- package/lib/store/memory.js.map +1 -1
- package/lib/store/stub.js +22 -35
- package/lib/store/stub.js.map +1 -1
- package/lib/sync-accumulator.js +54 -66
- package/lib/sync-accumulator.js.map +1 -1
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +905 -998
- package/lib/sync.js.map +1 -1
- package/lib/testing.js +63 -105
- package/lib/testing.js.map +1 -1
- package/lib/thread-utils.js +1 -4
- package/lib/thread-utils.js.map +1 -1
- package/lib/timeline-window.js +89 -102
- package/lib/timeline-window.js.map +1 -1
- package/lib/types.js +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utils/decryptAESSecretStorageItem.js +14 -25
- package/lib/utils/decryptAESSecretStorageItem.js.map +1 -1
- package/lib/utils/encryptAESSecretStorageItem.js +27 -38
- package/lib/utils/encryptAESSecretStorageItem.js.map +1 -1
- package/lib/utils/internal/deriveKeys.js +25 -32
- package/lib/utils/internal/deriveKeys.js.map +1 -1
- package/lib/utils/roomVersion.js +1 -1
- package/lib/utils/roomVersion.js.map +1 -1
- package/lib/utils.js +83 -135
- package/lib/utils.js.map +1 -1
- package/lib/version-support.js +3 -3
- package/lib/version-support.js.map +1 -1
- package/lib/webrtc/audioContext.js +5 -6
- package/lib/webrtc/audioContext.js.map +1 -1
- package/lib/webrtc/call.js +1081 -1250
- package/lib/webrtc/call.js.map +1 -1
- package/lib/webrtc/callEventHandler.js +202 -214
- package/lib/webrtc/callEventHandler.js.map +1 -1
- package/lib/webrtc/callEventTypes.js +2 -2
- package/lib/webrtc/callEventTypes.js.map +1 -1
- package/lib/webrtc/callFeed.js +18 -20
- package/lib/webrtc/callFeed.js.map +1 -1
- package/lib/webrtc/groupCall.js +513 -602
- package/lib/webrtc/groupCall.js.map +1 -1
- package/lib/webrtc/groupCallEventHandler.js +59 -62
- package/lib/webrtc/groupCallEventHandler.js.map +1 -1
- package/lib/webrtc/mediaHandler.js +198 -232
- package/lib/webrtc/mediaHandler.js.map +1 -1
- package/lib/webrtc/stats/callFeedStatsReporter.js +16 -20
- package/lib/webrtc/stats/callFeedStatsReporter.js.map +1 -1
- package/lib/webrtc/stats/callStatsReportGatherer.js +67 -75
- package/lib/webrtc/stats/callStatsReportGatherer.js.map +1 -1
- package/lib/webrtc/stats/callStatsReportSummary.js +3 -1
- package/lib/webrtc/stats/connectionStats.js.map +1 -1
- package/lib/webrtc/stats/connectionStatsBuilder.js +2 -2
- package/lib/webrtc/stats/connectionStatsBuilder.js.map +1 -1
- package/lib/webrtc/stats/connectionStatsReportBuilder.js +20 -24
- package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +1 -1
- package/lib/webrtc/stats/groupCallStats.js +6 -8
- package/lib/webrtc/stats/groupCallStats.js.map +1 -1
- package/lib/webrtc/stats/media/mediaSsrcHandler.js +7 -8
- package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +1 -1
- package/lib/webrtc/stats/media/mediaTrackHandler.js +7 -9
- package/lib/webrtc/stats/media/mediaTrackHandler.js.map +1 -1
- package/lib/webrtc/stats/media/mediaTrackStats.js +3 -3
- package/lib/webrtc/stats/media/mediaTrackStats.js.map +1 -1
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +7 -7
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +1 -1
- package/lib/webrtc/stats/statsReport.js +1 -1
- package/lib/webrtc/stats/statsReport.js.map +1 -1
- package/lib/webrtc/stats/statsReportEmitter.js.map +1 -1
- package/lib/webrtc/stats/summaryStatsReportGatherer.js +14 -14
- package/lib/webrtc/stats/summaryStatsReportGatherer.js.map +1 -1
- package/lib/webrtc/stats/trackStatsBuilder.js +32 -34
- package/lib/webrtc/stats/trackStatsBuilder.js.map +1 -1
- package/lib/webrtc/stats/transportStats.js +3 -1
- package/lib/webrtc/stats/transportStatsBuilder.js +9 -9
- package/lib/webrtc/stats/transportStatsBuilder.js.map +1 -1
- package/lib/webrtc/stats/valueFormatter.js +1 -1
- package/lib/webrtc/stats/valueFormatter.js.map +1 -1
- package/package.json +18 -33
- package/src/@types/global.d.ts +2 -2
- package/src/ToDeviceMessageQueue.ts +2 -2
- package/src/browser-index.ts +4 -4
- package/src/client.ts +15 -20
- package/src/crypto-api/index.ts +17 -6
- package/src/embedded.ts +4 -6
- package/src/filter-component.ts +1 -0
- package/src/http-api/utils.ts +1 -1
- package/src/interactive-auth.ts +11 -5
- package/src/matrixrtc/LivekitTransport.ts +1 -1
- package/src/matrixrtc/MatrixRTCSession.ts +1 -1
- package/src/models/MSC3089Branch.ts +1 -1
- package/src/models/room-sticky-events.ts +1 -0
- package/src/models/room.ts +9 -11
- package/src/receipt-accumulator.ts +2 -0
- package/src/rendezvous/index.ts +1 -1
- package/src/rendezvous/transports/MSC4108RendezvousSession.ts +2 -2
- package/src/rust-crypto/PerSessionKeyBackupDownloader.ts +1 -1
- package/src/rust-crypto/index.ts +6 -6
- package/src/rust-crypto/rust-crypto.ts +31 -7
- package/src/rust-crypto/verification.ts +1 -1
- package/src/sliding-sync-sdk.ts +5 -7
- package/src/store/indexeddb-local-backend.ts +3 -3
- package/src/sync.ts +6 -8
package/lib/embedded.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
-
function _asyncIterator(r) { var n, t, o, e = 2; for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) { if (t && null != (n = r[t])) return n.call(r); if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r)); t = "@@asyncIterator", o = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
|
|
6
|
-
function AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var n = r.done; return Promise.resolve(r.value).then(function (r) { return { value: r, done: n }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(r) { this.s = r, this.n = r.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, return: function _return(r) { var n = this.s.return; return void 0 === n ? Promise.resolve({ value: r, done: !0 }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); }, throw: function _throw(r) { var n = this.s.return; return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(r); }
|
|
7
3
|
/*
|
|
8
4
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
9
5
|
|
|
@@ -32,7 +28,7 @@ import { ConnectionError, MatrixError } from "./http-api/errors.js";
|
|
|
32
28
|
import { User } from "./models/user.js";
|
|
33
29
|
import { MapWithDefault, recursiveMapToObject } from "./utils.js";
|
|
34
30
|
import { TypedEventEmitter, UnsupportedDelayedEventsEndpointError } from "./matrix.js";
|
|
35
|
-
export
|
|
31
|
+
export let RoomWidgetClientEvent = /*#__PURE__*/function (RoomWidgetClientEvent) {
|
|
36
32
|
RoomWidgetClientEvent["PendingEventsChanged"] = "PendingEvent.pendingEventsChanged";
|
|
37
33
|
return RoomWidgetClientEvent;
|
|
38
34
|
}({});
|
|
@@ -52,13 +48,8 @@ export class RoomWidgetClient extends MatrixClient {
|
|
|
52
48
|
* Set to `false` if the widget uses `waitForIFrameLoad=true` (in this case the client does not expect a content loaded action at all),
|
|
53
49
|
* or if the the widget wants to send the `ContentLoaded` action at a later point in time after the initial setup.
|
|
54
50
|
*/
|
|
55
|
-
constructor(widgetApi, capabilities,
|
|
56
|
-
var _this, _capabilities$receive;
|
|
51
|
+
constructor(widgetApi, capabilities, _roomId, opts, sendContentLoaded) {
|
|
57
52
|
super(opts);
|
|
58
|
-
_this = this;
|
|
59
|
-
this.widgetApi = widgetApi;
|
|
60
|
-
this.capabilities = capabilities;
|
|
61
|
-
this.roomId = roomId;
|
|
62
53
|
_defineProperty(this, "room", void 0);
|
|
63
54
|
_defineProperty(this, "widgetApiReady", void 0);
|
|
64
55
|
_defineProperty(this, "roomStateSynced", void 0);
|
|
@@ -67,180 +58,153 @@ export class RoomWidgetClient extends MatrixClient {
|
|
|
67
58
|
_defineProperty(this, "pendingSendingEventsTxId", []);
|
|
68
59
|
_defineProperty(this, "eventEmitter", new TypedEventEmitter());
|
|
69
60
|
_defineProperty(this, "syncApiResolver", Promise.withResolvers());
|
|
70
|
-
_defineProperty(this, "updateTxId",
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
yield new Promise(resolve => _this.eventEmitter.once(RoomWidgetClientEvent.PendingEventsChanged, () => resolve()));
|
|
93
|
-
matchingTxId = (_this$pendingSendingE2 = _this.pendingSendingEventsTxId.find(p => p.id === event.getId())) === null || _this$pendingSendingE2 === void 0 ? void 0 : _this$pendingSendingE2.txId;
|
|
94
|
-
}
|
|
61
|
+
_defineProperty(this, "updateTxId", async event => {
|
|
62
|
+
// We update the txId for remote echos that originate from this client.
|
|
63
|
+
// This happens with the help of `pendingSendingEventsTxId` where we store all events that are currently sending
|
|
64
|
+
// with their widget txId and once ready the final evId.
|
|
65
|
+
if (
|
|
66
|
+
// This could theoretically be an event send by this device
|
|
67
|
+
// In that case we need to update the txId of the event because the embedded client/widget
|
|
68
|
+
// knows this event with a different transaction Id than what was used by the host client.
|
|
69
|
+
event.getSender() === this.getUserId() &&
|
|
70
|
+
// We optimize by not blocking events from types that we have not send
|
|
71
|
+
// with this client.
|
|
72
|
+
this.pendingSendingEventsTxId.some(p => event.getType() === p.type)) {
|
|
73
|
+
// Compare by event Id if we have a matching pending event where we know the txId.
|
|
74
|
+
let matchingTxId = this.pendingSendingEventsTxId.find(p => p.id === event.getId())?.txId;
|
|
75
|
+
// Block any further processing of this event until we have received the sending response.
|
|
76
|
+
// -> until we know the event id.
|
|
77
|
+
// -> until we have not pending events anymore.
|
|
78
|
+
while (!matchingTxId && this.pendingSendingEventsTxId.length > 0) {
|
|
79
|
+
// Recheck whenever the PendingEventsChanged
|
|
80
|
+
await new Promise(resolve => this.eventEmitter.once(RoomWidgetClientEvent.PendingEventsChanged, () => resolve()));
|
|
81
|
+
matchingTxId = this.pendingSendingEventsTxId.find(p => p.id === event.getId())?.txId;
|
|
82
|
+
}
|
|
95
83
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
84
|
+
// We found the correct txId: we update the event and delete the entry of the pending events.
|
|
85
|
+
if (matchingTxId) {
|
|
86
|
+
event.setTxnId(matchingTxId);
|
|
87
|
+
event.setUnsigned(_objectSpread(_objectSpread({}, event.getUnsigned()), {}, {
|
|
88
|
+
transaction_id: matchingTxId
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
this.pendingSendingEventsTxId = this.pendingSendingEventsTxId.filter(p => p.id !== event.getId());
|
|
104
92
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
93
|
+
// Emit once there are no pending events anymore to release all other events that got
|
|
94
|
+
// awaited in the `while (!matchingTxId && this.pendingSendingEventsTxId.length > 0)` loop
|
|
95
|
+
// but are not send by this client.
|
|
96
|
+
if (this.pendingSendingEventsTxId.length === 0) {
|
|
97
|
+
this.eventEmitter.emit(RoomWidgetClientEvent.PendingEventsChanged);
|
|
111
98
|
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}());
|
|
117
|
-
_defineProperty(this, "onEvent", /*#__PURE__*/function () {
|
|
118
|
-
var _ref2 = _asyncToGenerator(function* (ev) {
|
|
119
|
-
ev.preventDefault();
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
_defineProperty(this, "onEvent", async ev => {
|
|
102
|
+
ev.preventDefault();
|
|
120
103
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
104
|
+
// Verify the room ID matches, since it's possible for the client to
|
|
105
|
+
// send us events from other rooms if this widget is always on screen
|
|
106
|
+
if (ev.detail.data.room_id === this.roomId) {
|
|
107
|
+
const event = new MatrixEvent(ev.detail.data);
|
|
125
108
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
} else {
|
|
133
|
-
// Passing undefined for `stateAfterEventList` will make `injectRoomEvents` run in legacy mode
|
|
134
|
-
// -> state events in `timelineEventList` will update the state.
|
|
135
|
-
yield _this.syncApi.injectRoomEvents(_this.room, [], undefined, [_event]);
|
|
136
|
-
}
|
|
109
|
+
// Only inject once we have update the txId
|
|
110
|
+
await this.updateTxId(event);
|
|
111
|
+
await this.syncApiResolver.promise;
|
|
112
|
+
if (this.syncApi instanceof SyncApi) {
|
|
113
|
+
if (await this.supportUpdateState()) {
|
|
114
|
+
await this.syncApi.injectRoomEvents(this.room, undefined, [], [event]);
|
|
137
115
|
} else {
|
|
138
|
-
//
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
} else {
|
|
142
|
-
logger.error("slididng sync cannot be used in widget mode if the client widget driver does not support the version: 'org.matrix.msc2762_update_state'");
|
|
143
|
-
}
|
|
116
|
+
// Passing undefined for `stateAfterEventList` will make `injectRoomEvents` run in legacy mode
|
|
117
|
+
// -> state events in `timelineEventList` will update the state.
|
|
118
|
+
await this.syncApi.injectRoomEvents(this.room, [], undefined, [event]);
|
|
144
119
|
}
|
|
145
|
-
_this.emit(ClientEvent.Event, _event);
|
|
146
|
-
if (_event.unstableStickyInfo !== undefined) _this.room._unstable_addStickyEvents([_event]);
|
|
147
|
-
_this.setSyncState(SyncState.Syncing);
|
|
148
|
-
logger.info("Received event ".concat(_event.getId(), " ").concat(_event.getType()));
|
|
149
120
|
} else {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
logger.info("Received event ".concat(eventId, " for a different room ").concat(_roomId, "; discarding"));
|
|
154
|
-
}
|
|
155
|
-
yield _this.ack(ev);
|
|
156
|
-
});
|
|
157
|
-
return function (_x2) {
|
|
158
|
-
return _ref2.apply(this, arguments);
|
|
159
|
-
};
|
|
160
|
-
}());
|
|
161
|
-
_defineProperty(this, "onToDevice", /*#__PURE__*/function () {
|
|
162
|
-
var _ref3 = _asyncToGenerator(function* (ev) {
|
|
163
|
-
ev.preventDefault();
|
|
164
|
-
var event = new MatrixEvent({
|
|
165
|
-
type: ev.detail.data.type,
|
|
166
|
-
sender: ev.detail.data.sender,
|
|
167
|
-
content: ev.detail.data.content
|
|
168
|
-
});
|
|
169
|
-
// Mark the event as encrypted if it was, using fake contents and keys since those are unknown to us
|
|
170
|
-
if (ev.detail.data.encrypted) event.makeEncrypted(EventType.RoomMessageEncrypted, {}, "", "");
|
|
171
|
-
_this.emit(ClientEvent.ToDeviceEvent, event);
|
|
172
|
-
_this.setSyncState(SyncState.Syncing);
|
|
173
|
-
yield _this.ack(ev);
|
|
174
|
-
});
|
|
175
|
-
return function (_x3) {
|
|
176
|
-
return _ref3.apply(this, arguments);
|
|
177
|
-
};
|
|
178
|
-
}());
|
|
179
|
-
_defineProperty(this, "onStateUpdate", /*#__PURE__*/function () {
|
|
180
|
-
var _ref4 = _asyncToGenerator(function* (ev) {
|
|
181
|
-
ev.preventDefault();
|
|
182
|
-
if (!(yield _this.supportUpdateState())) {
|
|
183
|
-
logger.warn("received update_state widget action but the widget driver did not claim to support 'org.matrix.msc2762_update_state'");
|
|
184
|
-
}
|
|
185
|
-
yield _this.syncApiResolver.promise;
|
|
186
|
-
for (var rawEvent of ev.detail.data.state) {
|
|
187
|
-
// Verify the room ID matches, since it's possible for the client to
|
|
188
|
-
// send us state updates from other rooms if this widget is always
|
|
189
|
-
// on screen
|
|
190
|
-
if (rawEvent.room_id === _this.roomId) {
|
|
191
|
-
var _event2 = new MatrixEvent(rawEvent);
|
|
192
|
-
if (_this.syncApi instanceof SyncApi) {
|
|
193
|
-
yield _this.syncApi.injectRoomEvents(_this.room, undefined, [_event2]);
|
|
194
|
-
} else {
|
|
195
|
-
// Sliding Sync
|
|
196
|
-
yield _this.syncApi.injectRoomEvents(_this.room, [_event2]);
|
|
197
|
-
}
|
|
198
|
-
logger.debug("Updated state entry ".concat(_event2.getType(), " ").concat(_event2.getStateKey(), " to ").concat(_event2.getId()));
|
|
121
|
+
// Sliding Sync
|
|
122
|
+
if (await this.supportUpdateState()) {
|
|
123
|
+
await this.syncApi.injectRoomEvents(this.room, [], [event]);
|
|
199
124
|
} else {
|
|
200
|
-
|
|
201
|
-
eventId = _ev$detail$data2.event_id,
|
|
202
|
-
_roomId2 = _ev$detail$data2.room_id;
|
|
203
|
-
logger.info("Received state entry ".concat(eventId, " for a different room ").concat(_roomId2, "; discarding"));
|
|
125
|
+
logger.error("slididng sync cannot be used in widget mode if the client widget driver does not support the version: 'org.matrix.msc2762_update_state'");
|
|
204
126
|
}
|
|
205
127
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
128
|
+
this.emit(ClientEvent.Event, event);
|
|
129
|
+
if (event.unstableStickyInfo !== undefined) this.room._unstable_addStickyEvents([event]);
|
|
130
|
+
this.setSyncState(SyncState.Syncing);
|
|
131
|
+
logger.info(`Received event ${event.getId()} ${event.getType()}`);
|
|
132
|
+
} else {
|
|
133
|
+
const {
|
|
134
|
+
event_id: eventId,
|
|
135
|
+
room_id: roomId
|
|
136
|
+
} = ev.detail.data;
|
|
137
|
+
logger.info(`Received event ${eventId} for a different room ${roomId}; discarding`);
|
|
138
|
+
}
|
|
139
|
+
await this.ack(ev);
|
|
140
|
+
});
|
|
141
|
+
_defineProperty(this, "onToDevice", async ev => {
|
|
142
|
+
ev.preventDefault();
|
|
143
|
+
const event = new MatrixEvent({
|
|
144
|
+
type: ev.detail.data.type,
|
|
145
|
+
sender: ev.detail.data.sender,
|
|
146
|
+
content: ev.detail.data.content
|
|
220
147
|
});
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
148
|
+
// Mark the event as encrypted if it was, using fake contents and keys since those are unknown to us
|
|
149
|
+
if (ev.detail.data.encrypted) event.makeEncrypted(EventType.RoomMessageEncrypted, {}, "", "");
|
|
150
|
+
this.emit(ClientEvent.ToDeviceEvent, event);
|
|
151
|
+
this.setSyncState(SyncState.Syncing);
|
|
152
|
+
await this.ack(ev);
|
|
153
|
+
});
|
|
154
|
+
_defineProperty(this, "onStateUpdate", async ev => {
|
|
155
|
+
ev.preventDefault();
|
|
156
|
+
if (!(await this.supportUpdateState())) {
|
|
157
|
+
logger.warn("received update_state widget action but the widget driver did not claim to support 'org.matrix.msc2762_update_state'");
|
|
158
|
+
}
|
|
159
|
+
await this.syncApiResolver.promise;
|
|
160
|
+
for (const rawEvent of ev.detail.data.state) {
|
|
161
|
+
// Verify the room ID matches, since it's possible for the client to
|
|
162
|
+
// send us state updates from other rooms if this widget is always
|
|
163
|
+
// on screen
|
|
164
|
+
if (rawEvent.room_id === this.roomId) {
|
|
165
|
+
const event = new MatrixEvent(rawEvent);
|
|
166
|
+
if (this.syncApi instanceof SyncApi) {
|
|
167
|
+
await this.syncApi.injectRoomEvents(this.room, undefined, [event]);
|
|
168
|
+
} else {
|
|
169
|
+
// Sliding Sync
|
|
170
|
+
await this.syncApi.injectRoomEvents(this.room, [event]);
|
|
171
|
+
}
|
|
172
|
+
logger.debug(`Updated state entry ${event.getType()} ${event.getStateKey()} to ${event.getId()}`);
|
|
173
|
+
} else {
|
|
174
|
+
const {
|
|
175
|
+
event_id: eventId,
|
|
176
|
+
room_id: roomId
|
|
177
|
+
} = ev.detail.data;
|
|
178
|
+
logger.info(`Received state entry ${eventId} for a different room ${roomId}; discarding`);
|
|
232
179
|
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
180
|
+
}
|
|
181
|
+
await this.ack(ev);
|
|
182
|
+
});
|
|
183
|
+
this.widgetApi = widgetApi;
|
|
184
|
+
this.capabilities = capabilities;
|
|
185
|
+
this.roomId = _roomId;
|
|
186
|
+
const transportSend = this.widgetApi.transport.send.bind(this.widgetApi.transport);
|
|
187
|
+
this.widgetApi.transport.send = async (action, data) => {
|
|
188
|
+
try {
|
|
189
|
+
return await transportSend(action, data);
|
|
190
|
+
} catch (error) {
|
|
191
|
+
processAndThrow(error);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
const transportSendComplete = this.widgetApi.transport.sendComplete.bind(this.widgetApi.transport);
|
|
195
|
+
this.widgetApi.transport.sendComplete = async (action, data) => {
|
|
196
|
+
try {
|
|
197
|
+
return await transportSendComplete(action, data);
|
|
198
|
+
} catch (error) {
|
|
199
|
+
processAndThrow(error);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
238
202
|
this.widgetApiReady = new Promise(resolve => this.widgetApi.once("ready", resolve));
|
|
239
|
-
this.roomStateSynced =
|
|
240
|
-
this.requestInitialCapabilities(capabilities,
|
|
241
|
-
widgetApi.on(
|
|
242
|
-
widgetApi.on(
|
|
243
|
-
widgetApi.on(
|
|
203
|
+
this.roomStateSynced = capabilities.receiveState?.length ? new Promise(resolve => this.widgetApi.once(`action:${WidgetApiToWidgetAction.UpdateState}`, resolve)) : Promise.resolve();
|
|
204
|
+
this.requestInitialCapabilities(capabilities, _roomId);
|
|
205
|
+
widgetApi.on(`action:${WidgetApiToWidgetAction.SendEvent}`, this.onEvent);
|
|
206
|
+
widgetApi.on(`action:${WidgetApiToWidgetAction.SendToDevice}`, this.onToDevice);
|
|
207
|
+
widgetApi.on(`action:${WidgetApiToWidgetAction.UpdateState}`, this.onStateUpdate);
|
|
244
208
|
|
|
245
209
|
// Open communication with the host
|
|
246
210
|
widgetApi.start();
|
|
@@ -252,13 +216,12 @@ export class RoomWidgetClient extends MatrixClient {
|
|
|
252
216
|
if (sendContentLoaded) widgetApi.sendContentLoaded();
|
|
253
217
|
}
|
|
254
218
|
requestInitialCapabilities(capabilities, roomId) {
|
|
255
|
-
var _capabilities$sendEve, _capabilities$receive2, _capabilities$sendSta, _capabilities$receive3, _capabilities$sendEve2, _capabilities$receive4, _capabilities$sendSta2, _capabilities$receive5, _capabilities$sendToD, _capabilities$receive6, _capabilities$sendEve3, _capabilities$sendSta3;
|
|
256
219
|
// Request capabilities for the functionality this client needs to support
|
|
257
|
-
if (
|
|
220
|
+
if (capabilities.sendEvent?.length || capabilities.receiveEvent?.length || capabilities.sendMessage === true || Array.isArray(capabilities.sendMessage) && capabilities.sendMessage.length || capabilities.receiveMessage === true || Array.isArray(capabilities.receiveMessage) && capabilities.receiveMessage.length || capabilities.sendState?.length || capabilities.receiveState?.length) {
|
|
258
221
|
this.widgetApi.requestCapabilityForRoomTimeline(roomId);
|
|
259
222
|
}
|
|
260
|
-
|
|
261
|
-
|
|
223
|
+
capabilities.sendEvent?.forEach(eventType => this.widgetApi.requestCapabilityToSendEvent(eventType));
|
|
224
|
+
capabilities.receiveEvent?.forEach(eventType => this.widgetApi.requestCapabilityToReceiveEvent(eventType));
|
|
262
225
|
if (capabilities.sendMessage === true) {
|
|
263
226
|
this.widgetApi.requestCapabilityToSendMessage();
|
|
264
227
|
} else if (Array.isArray(capabilities.sendMessage)) {
|
|
@@ -269,19 +232,17 @@ export class RoomWidgetClient extends MatrixClient {
|
|
|
269
232
|
} else if (Array.isArray(capabilities.receiveMessage)) {
|
|
270
233
|
capabilities.receiveMessage.forEach(msgType => this.widgetApi.requestCapabilityToReceiveMessage(msgType));
|
|
271
234
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
(
|
|
283
|
-
(_capabilities$receive6 = capabilities.receiveToDevice) === null || _capabilities$receive6 === void 0 || _capabilities$receive6.forEach(eventType => this.widgetApi.requestCapabilityToReceiveToDevice(eventType));
|
|
284
|
-
if (capabilities.sendDelayedEvents && ((_capabilities$sendEve3 = capabilities.sendEvent) !== null && _capabilities$sendEve3 !== void 0 && _capabilities$sendEve3.length || capabilities.sendMessage === true || Array.isArray(capabilities.sendMessage) && capabilities.sendMessage.length || (_capabilities$sendSta3 = capabilities.sendState) !== null && _capabilities$sendSta3 !== void 0 && _capabilities$sendSta3.length)) {
|
|
235
|
+
capabilities.sendState?.forEach(({
|
|
236
|
+
eventType,
|
|
237
|
+
stateKey
|
|
238
|
+
}) => this.widgetApi.requestCapabilityToSendState(eventType, stateKey));
|
|
239
|
+
capabilities.receiveState?.forEach(({
|
|
240
|
+
eventType,
|
|
241
|
+
stateKey
|
|
242
|
+
}) => this.widgetApi.requestCapabilityToReceiveState(eventType, stateKey));
|
|
243
|
+
capabilities.sendToDevice?.forEach(eventType => this.widgetApi.requestCapabilityToSendToDevice(eventType));
|
|
244
|
+
capabilities.receiveToDevice?.forEach(eventType => this.widgetApi.requestCapabilityToReceiveToDevice(eventType));
|
|
245
|
+
if (capabilities.sendDelayedEvents && (capabilities.sendEvent?.length || capabilities.sendMessage === true || Array.isArray(capabilities.sendMessage) && capabilities.sendMessage.length || capabilities.sendState?.length)) {
|
|
285
246
|
this.widgetApi.requestCapability(MatrixCapabilities.MSC4157SendDelayedEvent);
|
|
286
247
|
}
|
|
287
248
|
if (capabilities.updateDelayedEvents) {
|
|
@@ -297,189 +258,159 @@ export class RoomWidgetClient extends MatrixClient {
|
|
|
297
258
|
this.widgetApi.requestCapability(MatrixCapabilities.MSC3846TurnServers);
|
|
298
259
|
}
|
|
299
260
|
}
|
|
300
|
-
supportUpdateState() {
|
|
301
|
-
|
|
302
|
-
return _asyncToGenerator(function* () {
|
|
303
|
-
return (yield _this2.widgetApi.getClientVersions()).includes(UnstableApiVersion.MSC2762_UPDATE_STATE);
|
|
304
|
-
})();
|
|
261
|
+
async supportUpdateState() {
|
|
262
|
+
return (await this.widgetApi.getClientVersions()).includes(UnstableApiVersion.MSC2762_UPDATE_STATE);
|
|
305
263
|
}
|
|
306
|
-
startClient() {
|
|
307
|
-
|
|
308
|
-
_this3 = this;
|
|
309
|
-
return _asyncToGenerator(function* () {
|
|
310
|
-
var opts = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : {};
|
|
311
|
-
_this3.lifecycle = new AbortController();
|
|
264
|
+
async startClient(opts = {}) {
|
|
265
|
+
this.lifecycle = new AbortController();
|
|
312
266
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
267
|
+
// Create our own user object artificially (instead of waiting for sync)
|
|
268
|
+
// so it's always available, even if the user is not in any rooms etc.
|
|
269
|
+
const userId = this.getUserId();
|
|
270
|
+
if (userId) {
|
|
271
|
+
this.store.storeUser(new User(userId));
|
|
272
|
+
}
|
|
319
273
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
274
|
+
// Even though we have no access token and cannot sync, the sync class
|
|
275
|
+
// still has some valuable helper methods that we make use of, so we
|
|
276
|
+
// instantiate it anyways
|
|
277
|
+
if (opts.slidingSync) {
|
|
278
|
+
this.syncApi = new SlidingSyncSdk(opts.slidingSync, this, opts, this.buildSyncApiOptions());
|
|
279
|
+
} else {
|
|
280
|
+
this.syncApi = new SyncApi(this, opts, this.buildSyncApiOptions());
|
|
281
|
+
}
|
|
282
|
+
this.syncApiResolver.resolve();
|
|
283
|
+
this.room = this.syncApi.createRoom(this.roomId);
|
|
284
|
+
this.store.storeRoom(this.room);
|
|
285
|
+
await this.widgetApiReady;
|
|
332
286
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
_this3.fetchClientWellKnown();
|
|
369
|
-
}
|
|
370
|
-
_this3.setSyncState(SyncState.Syncing);
|
|
371
|
-
logger.info("Finished initial sync");
|
|
372
|
-
_this3.matrixRTC.start();
|
|
287
|
+
// sync room state:
|
|
288
|
+
if (await this.supportUpdateState()) {
|
|
289
|
+
// This will resolve once the client driver has sent us all the allowed room state.
|
|
290
|
+
await this.roomStateSynced;
|
|
291
|
+
} else {
|
|
292
|
+
// Backfill the requested events
|
|
293
|
+
// We only get the most recent event for every type + state key combo,
|
|
294
|
+
// so it doesn't really matter what order we inject them in
|
|
295
|
+
await Promise.all(this.capabilities.receiveState?.map(async ({
|
|
296
|
+
eventType,
|
|
297
|
+
stateKey
|
|
298
|
+
}) => {
|
|
299
|
+
const rawEvents = await this.widgetApi.readStateEvents(eventType, undefined, stateKey, [this.roomId]);
|
|
300
|
+
const events = rawEvents.map(rawEvent => new MatrixEvent(rawEvent));
|
|
301
|
+
if (this.syncApi instanceof SyncApi) {
|
|
302
|
+
// Passing events as `stateAfterEventList` will update the state.
|
|
303
|
+
await this.syncApi.injectRoomEvents(this.room, undefined, events);
|
|
304
|
+
} else {
|
|
305
|
+
await this.syncApi.injectRoomEvents(this.room, events); // Sliding Sync
|
|
306
|
+
}
|
|
307
|
+
events.forEach(event => {
|
|
308
|
+
this.emit(ClientEvent.Event, event);
|
|
309
|
+
logger.info(`Backfilled event ${event.getId()} ${event.getType()} ${event.getStateKey()}`);
|
|
310
|
+
});
|
|
311
|
+
}) ?? []);
|
|
312
|
+
}
|
|
313
|
+
if (opts.clientWellKnownPollPeriod !== undefined) {
|
|
314
|
+
this.clientWellKnownIntervalID = setInterval(() => {
|
|
315
|
+
this.fetchClientWellKnown();
|
|
316
|
+
}, 1000 * opts.clientWellKnownPollPeriod);
|
|
317
|
+
this.fetchClientWellKnown();
|
|
318
|
+
}
|
|
319
|
+
this.setSyncState(SyncState.Syncing);
|
|
320
|
+
logger.info("Finished initial sync");
|
|
321
|
+
this.matrixRTC.start();
|
|
373
322
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
})();
|
|
323
|
+
// Watch for TURN servers, if requested
|
|
324
|
+
if (this.capabilities.turnServers) this.watchTurnServers();
|
|
377
325
|
}
|
|
378
326
|
stopClient() {
|
|
379
|
-
this.widgetApi.off(
|
|
380
|
-
this.widgetApi.off(
|
|
381
|
-
this.widgetApi.off(
|
|
327
|
+
this.widgetApi.off(`action:${WidgetApiToWidgetAction.SendEvent}`, this.onEvent);
|
|
328
|
+
this.widgetApi.off(`action:${WidgetApiToWidgetAction.SendToDevice}`, this.onToDevice);
|
|
329
|
+
this.widgetApi.off(`action:${WidgetApiToWidgetAction.UpdateState}`, this.onStateUpdate);
|
|
382
330
|
super.stopClient();
|
|
383
331
|
this.lifecycle.abort(); // Signal to other async tasks that the client has stopped
|
|
384
332
|
}
|
|
385
|
-
joinRoom(roomIdOrAlias) {
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
if (roomIdOrAlias === _this4.roomId) return _this4.room;
|
|
389
|
-
throw new Error("Unknown room: ".concat(roomIdOrAlias));
|
|
390
|
-
})();
|
|
333
|
+
async joinRoom(roomIdOrAlias) {
|
|
334
|
+
if (roomIdOrAlias === this.roomId) return this.room;
|
|
335
|
+
throw new Error(`Unknown room: ${roomIdOrAlias}`);
|
|
391
336
|
}
|
|
392
|
-
encryptAndSendEvent(room, event, delayOptsOrQuery, queryDict) {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
// It is not capable of implying the type based on the throw if `stickyDurationMs !== undefined && typeof stickyDurationMs !== "number"`
|
|
410
|
-
// above
|
|
411
|
-
var stickyDurationMsAsNumber = stickyDurationMs;
|
|
337
|
+
async encryptAndSendEvent(room, event, delayOptsOrQuery, queryDict) {
|
|
338
|
+
let queryOpts = queryDict;
|
|
339
|
+
let delayOpts;
|
|
340
|
+
if (delayOptsOrQuery && isSendDelayedEventRequestOpts(delayOptsOrQuery)) {
|
|
341
|
+
delayOpts = delayOptsOrQuery;
|
|
342
|
+
} else if (!queryOpts) {
|
|
343
|
+
queryOpts = delayOptsOrQuery;
|
|
344
|
+
}
|
|
345
|
+
const stickyDurationMs = queryOpts?.["org.matrix.msc4354.sticky_duration_ms"];
|
|
346
|
+
if (stickyDurationMs !== undefined && typeof stickyDurationMs !== "number") {
|
|
347
|
+
throw new Error("Sticky duration must be a number when defined");
|
|
348
|
+
}
|
|
349
|
+
// This is save since we just checked that above
|
|
350
|
+
// We need the additional as assertion for the EW linter to be happy.
|
|
351
|
+
// It is not capable of implying the type based on the throw if `stickyDurationMs !== undefined && typeof stickyDurationMs !== "number"`
|
|
352
|
+
// above
|
|
353
|
+
const stickyDurationMsAsNumber = stickyDurationMs;
|
|
412
354
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
355
|
+
// We need to extend the content with the redacts parameter
|
|
356
|
+
// The js sdk uses event.redacts but the widget api uses event.content.redacts
|
|
357
|
+
// This will be converted back to event.redacts in the widget driver.
|
|
358
|
+
const content = event.event.redacts ? _objectSpread(_objectSpread({}, event.getContent()), {}, {
|
|
359
|
+
redacts: event.event.redacts
|
|
360
|
+
}) : event.getContent();
|
|
419
361
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
362
|
+
// Delayed event special case.
|
|
363
|
+
if (delayOpts) {
|
|
364
|
+
// TODO: updatePendingEvent for delayed events?
|
|
365
|
+
const response = await this.widgetApi.sendRoomEvent(event.getType(), content, room.roomId, "delay" in delayOpts ? delayOpts.delay : undefined, "parent_delay_id" in delayOpts ? delayOpts.parent_delay_id : undefined, stickyDurationMsAsNumber).catch(timeoutToConnectionError);
|
|
366
|
+
return this.validateSendDelayedEventResponse(response);
|
|
367
|
+
}
|
|
368
|
+
const txId = event.getTxnId();
|
|
369
|
+
// Add the txnId to the pending list (still with unknown evID)
|
|
370
|
+
if (txId) this.pendingSendingEventsTxId.push({
|
|
371
|
+
type: event.getType(),
|
|
372
|
+
id: undefined,
|
|
373
|
+
txId
|
|
374
|
+
});
|
|
375
|
+
let response;
|
|
376
|
+
try {
|
|
377
|
+
response = await this.widgetApi.sendRoomEvent(event.getType(), content, room.roomId, undefined, undefined, stickyDurationMsAsNumber).catch(timeoutToConnectionError);
|
|
378
|
+
} catch (e) {
|
|
379
|
+
this.updatePendingEventStatus(room, event, EventStatus.NOT_SENT);
|
|
380
|
+
throw e;
|
|
381
|
+
}
|
|
382
|
+
// This also checks for an event id on the response
|
|
383
|
+
room.updatePendingEvent(event, EventStatus.SENT, response.event_id);
|
|
442
384
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
})();
|
|
385
|
+
// Update the pending events list with the eventId
|
|
386
|
+
this.pendingSendingEventsTxId.forEach(p => {
|
|
387
|
+
if (p.txId === txId) p.id = response.event_id;
|
|
388
|
+
});
|
|
389
|
+
this.eventEmitter.emit(RoomWidgetClientEvent.PendingEventsChanged);
|
|
390
|
+
return {
|
|
391
|
+
event_id: response.event_id
|
|
392
|
+
};
|
|
452
393
|
}
|
|
453
|
-
sendStateEvent(roomId, eventType, content) {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
}
|
|
462
|
-
return {
|
|
463
|
-
event_id: response.event_id
|
|
464
|
-
};
|
|
465
|
-
})();
|
|
394
|
+
async sendStateEvent(roomId, eventType, content, stateKey = "") {
|
|
395
|
+
const response = await this.widgetApi.sendStateEvent(eventType, stateKey, content, roomId).catch(timeoutToConnectionError);
|
|
396
|
+
if (response.event_id === undefined) {
|
|
397
|
+
throw new Error("'event_id' absent from response to an event request");
|
|
398
|
+
}
|
|
399
|
+
return {
|
|
400
|
+
event_id: response.event_id
|
|
401
|
+
};
|
|
466
402
|
}
|
|
467
403
|
|
|
468
404
|
/**
|
|
469
405
|
* @experimental This currently relies on an unstable MSC (MSC4140).
|
|
470
406
|
*/
|
|
471
407
|
// eslint-disable-next-line
|
|
472
|
-
_unstable_sendDelayedStateEvent(roomId, delayOpts, eventType, content) {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
throw new UnsupportedDelayedEventsEndpointError("Server does not support the delayed events API", "sendDelayedStateEvent");
|
|
479
|
-
}
|
|
480
|
-
var response = yield _this7.widgetApi.sendStateEvent(eventType, stateKey, content, roomId, "delay" in delayOpts ? delayOpts.delay : undefined, "parent_delay_id" in delayOpts ? delayOpts.parent_delay_id : undefined).catch(timeoutToConnectionError);
|
|
481
|
-
return _this7.validateSendDelayedEventResponse(response);
|
|
482
|
-
})();
|
|
408
|
+
async _unstable_sendDelayedStateEvent(roomId, delayOpts, eventType, content, stateKey = "") {
|
|
409
|
+
if (!(await this.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
|
|
410
|
+
throw new UnsupportedDelayedEventsEndpointError("Server does not support the delayed events API", "sendDelayedStateEvent");
|
|
411
|
+
}
|
|
412
|
+
const response = await this.widgetApi.sendStateEvent(eventType, stateKey, content, roomId, "delay" in delayOpts ? delayOpts.delay : undefined, "parent_delay_id" in delayOpts ? delayOpts.parent_delay_id : undefined).catch(timeoutToConnectionError);
|
|
413
|
+
return this.validateSendDelayedEventResponse(response);
|
|
483
414
|
}
|
|
484
415
|
validateSendDelayedEventResponse(response) {
|
|
485
416
|
if (response.delay_id === undefined) {
|
|
@@ -498,126 +429,103 @@ export class RoomWidgetClient extends MatrixClient {
|
|
|
498
429
|
* - {@link _unstable_sendScheduledDelayedEvent}
|
|
499
430
|
*/
|
|
500
431
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
501
|
-
_unstable_updateDelayedEvent(delayId, action) {
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
break;
|
|
518
|
-
}
|
|
519
|
-
yield updateDelayedEvent.call(_this8.widgetApi, delayId).catch(timeoutToConnectionError);
|
|
520
|
-
return {};
|
|
521
|
-
})();
|
|
432
|
+
async _unstable_updateDelayedEvent(delayId, action) {
|
|
433
|
+
if (!(await this.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
|
|
434
|
+
throw new UnsupportedDelayedEventsEndpointError("Server does not support the delayed events API", "updateDelayedEvent");
|
|
435
|
+
}
|
|
436
|
+
switch (action) {
|
|
437
|
+
case UpdateDelayedEventAction.Cancel:
|
|
438
|
+
await this.widgetApi.cancelScheduledDelayedEvent(delayId).catch(timeoutToConnectionError);
|
|
439
|
+
break;
|
|
440
|
+
case UpdateDelayedEventAction.Restart:
|
|
441
|
+
await this.widgetApi.restartScheduledDelayedEvent(delayId).catch(timeoutToConnectionError);
|
|
442
|
+
break;
|
|
443
|
+
case UpdateDelayedEventAction.Send:
|
|
444
|
+
await this.widgetApi.sendScheduledDelayedEvent(delayId).catch(timeoutToConnectionError);
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
return {};
|
|
522
448
|
}
|
|
523
449
|
|
|
524
450
|
/**
|
|
525
451
|
* @experimental This currently relies on an unstable MSC (MSC4140).
|
|
526
452
|
*/
|
|
527
453
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
528
|
-
_unstable_cancelScheduledDelayedEvent(delayId) {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
yield _this9.widgetApi.cancelScheduledDelayedEvent(delayId).catch(timeoutToConnectionError);
|
|
535
|
-
return {};
|
|
536
|
-
})();
|
|
454
|
+
async _unstable_cancelScheduledDelayedEvent(delayId) {
|
|
455
|
+
if (!(await this.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
|
|
456
|
+
throw new UnsupportedDelayedEventsEndpointError("Server does not support the delayed events API", "cancelScheduledDelayedEvent");
|
|
457
|
+
}
|
|
458
|
+
await this.widgetApi.cancelScheduledDelayedEvent(delayId).catch(timeoutToConnectionError);
|
|
459
|
+
return {};
|
|
537
460
|
}
|
|
538
461
|
|
|
539
462
|
/**
|
|
540
463
|
* @experimental This currently relies on an unstable MSC (MSC4140).
|
|
541
464
|
*/
|
|
542
465
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
543
|
-
_unstable_restartScheduledDelayedEvent(delayId) {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
yield _this0.widgetApi.restartScheduledDelayedEvent(delayId).catch(timeoutToConnectionError);
|
|
550
|
-
return {};
|
|
551
|
-
})();
|
|
466
|
+
async _unstable_restartScheduledDelayedEvent(delayId) {
|
|
467
|
+
if (!(await this.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
|
|
468
|
+
throw new UnsupportedDelayedEventsEndpointError("Server does not support the delayed events API", "restartScheduledDelayedEvent");
|
|
469
|
+
}
|
|
470
|
+
await this.widgetApi.restartScheduledDelayedEvent(delayId).catch(timeoutToConnectionError);
|
|
471
|
+
return {};
|
|
552
472
|
}
|
|
553
473
|
|
|
554
474
|
/**
|
|
555
475
|
* @experimental This currently relies on an unstable MSC (MSC4140).
|
|
556
476
|
*/
|
|
557
477
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
558
|
-
_unstable_sendScheduledDelayedEvent(delayId) {
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
yield _this1.widgetApi.sendScheduledDelayedEvent(delayId).catch(timeoutToConnectionError);
|
|
565
|
-
return {};
|
|
566
|
-
})();
|
|
478
|
+
async _unstable_sendScheduledDelayedEvent(delayId) {
|
|
479
|
+
if (!(await this.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
|
|
480
|
+
throw new UnsupportedDelayedEventsEndpointError("Server does not support the delayed events API", "sendScheduledDelayedEvent");
|
|
481
|
+
}
|
|
482
|
+
await this.widgetApi.sendScheduledDelayedEvent(delayId).catch(timeoutToConnectionError);
|
|
483
|
+
return {};
|
|
567
484
|
}
|
|
568
485
|
|
|
569
486
|
/**
|
|
570
487
|
* by {@link MatrixClient.encryptAndSendToDevice}.
|
|
571
488
|
*/
|
|
572
|
-
encryptAndSendToDevice(eventType, devices, payload) {
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
yield _this10.widgetApi.sendToDevice(eventType, true, recursiveMapToObject(contentMap)).catch(timeoutToConnectionError);
|
|
583
|
-
})();
|
|
489
|
+
async encryptAndSendToDevice(eventType, devices, payload) {
|
|
490
|
+
// map: user Id → device Id → payload
|
|
491
|
+
const contentMap = new MapWithDefault(() => new Map());
|
|
492
|
+
for (const {
|
|
493
|
+
userId,
|
|
494
|
+
deviceId
|
|
495
|
+
} of devices) {
|
|
496
|
+
contentMap.getOrCreate(userId).set(deviceId, payload);
|
|
497
|
+
}
|
|
498
|
+
await this.widgetApi.sendToDevice(eventType, true, recursiveMapToObject(contentMap)).catch(timeoutToConnectionError);
|
|
584
499
|
}
|
|
585
|
-
sendToDevice(eventType, contentMap) {
|
|
586
|
-
|
|
587
|
-
return
|
|
588
|
-
yield _this11.widgetApi.sendToDevice(eventType, false, recursiveMapToObject(contentMap)).catch(timeoutToConnectionError);
|
|
589
|
-
return {};
|
|
590
|
-
})();
|
|
500
|
+
async sendToDevice(eventType, contentMap) {
|
|
501
|
+
await this.widgetApi.sendToDevice(eventType, false, recursiveMapToObject(contentMap)).catch(timeoutToConnectionError);
|
|
502
|
+
return {};
|
|
591
503
|
}
|
|
592
|
-
getOpenIdToken() {
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
token_type: token.token_type
|
|
603
|
-
};
|
|
604
|
-
})();
|
|
504
|
+
async getOpenIdToken() {
|
|
505
|
+
const token = await this.widgetApi.requestOpenIDConnectToken().catch(timeoutToConnectionError);
|
|
506
|
+
// the IOpenIDCredentials from the widget-api and IOpenIDToken form the matrix-js-sdk are compatible.
|
|
507
|
+
// we still recreate the token to make this transparent and catch'able by the linter in case the types change in the future.
|
|
508
|
+
return {
|
|
509
|
+
access_token: token.access_token,
|
|
510
|
+
expires_in: token.expires_in,
|
|
511
|
+
matrix_server_name: token.matrix_server_name,
|
|
512
|
+
token_type: token.token_type
|
|
513
|
+
};
|
|
605
514
|
}
|
|
606
|
-
queueToDevice(
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
})();
|
|
515
|
+
async queueToDevice({
|
|
516
|
+
eventType,
|
|
517
|
+
batch
|
|
518
|
+
}) {
|
|
519
|
+
// map: user Id → device Id → payload
|
|
520
|
+
const contentMap = new MapWithDefault(() => new Map());
|
|
521
|
+
for (const {
|
|
522
|
+
userId,
|
|
523
|
+
deviceId,
|
|
524
|
+
payload
|
|
525
|
+
} of batch) {
|
|
526
|
+
contentMap.getOrCreate(userId).set(deviceId, payload);
|
|
527
|
+
}
|
|
528
|
+
await this.widgetApi.sendToDevice(eventType, false, recursiveMapToObject(contentMap)).catch(timeoutToConnectionError);
|
|
621
529
|
}
|
|
622
530
|
|
|
623
531
|
/**
|
|
@@ -633,20 +541,14 @@ export class RoomWidgetClient extends MatrixClient {
|
|
|
633
541
|
* @param encrypted - Whether the event should be encrypted.
|
|
634
542
|
* @param contentMap - The content to send. Map from user_id to device_id to content object.
|
|
635
543
|
*/
|
|
636
|
-
sendToDeviceViaWidgetApi(eventType, encrypted, contentMap) {
|
|
637
|
-
|
|
638
|
-
return _asyncToGenerator(function* () {
|
|
639
|
-
yield _this14.widgetApi.sendToDevice(eventType, encrypted, recursiveMapToObject(contentMap)).catch(timeoutToConnectionError);
|
|
640
|
-
})();
|
|
544
|
+
async sendToDeviceViaWidgetApi(eventType, encrypted, contentMap) {
|
|
545
|
+
await this.widgetApi.sendToDevice(eventType, encrypted, recursiveMapToObject(contentMap)).catch(timeoutToConnectionError);
|
|
641
546
|
}
|
|
642
547
|
|
|
643
548
|
// Overridden since we get TURN servers automatically over the widget API,
|
|
644
549
|
// and this method would otherwise complain about missing an access token
|
|
645
|
-
checkTurnServers() {
|
|
646
|
-
|
|
647
|
-
return _asyncToGenerator(function* () {
|
|
648
|
-
return _this15.turnServers.length > 0;
|
|
649
|
-
})();
|
|
550
|
+
async checkTurnServers() {
|
|
551
|
+
return this.turnServers.length > 0;
|
|
650
552
|
}
|
|
651
553
|
|
|
652
554
|
// Overridden since we 'sync' manually without the sync API
|
|
@@ -654,61 +556,34 @@ export class RoomWidgetClient extends MatrixClient {
|
|
|
654
556
|
return this.syncState;
|
|
655
557
|
}
|
|
656
558
|
setSyncState(state) {
|
|
657
|
-
|
|
559
|
+
const oldState = this.syncState;
|
|
658
560
|
this.syncState = state;
|
|
659
561
|
this.emit(ClientEvent.Sync, state, oldState);
|
|
660
562
|
}
|
|
661
|
-
ack(ev) {
|
|
662
|
-
|
|
663
|
-
return _asyncToGenerator(function* () {
|
|
664
|
-
yield _this16.widgetApi.transport.reply(ev.detail, {});
|
|
665
|
-
})();
|
|
563
|
+
async ack(ev) {
|
|
564
|
+
this.widgetApi.transport.reply(ev.detail, {});
|
|
666
565
|
}
|
|
667
|
-
watchTurnServers() {
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
{
|
|
683
|
-
_this17.turnServers = [{
|
|
684
|
-
urls: server.uris,
|
|
685
|
-
username: server.username,
|
|
686
|
-
credential: server.password
|
|
687
|
-
}];
|
|
688
|
-
_this17.emit(ClientEvent.TurnServers, _this17.turnServers);
|
|
689
|
-
logger.log("Received TURN server: ".concat(server.uris));
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
} catch (err) {
|
|
693
|
-
_didIteratorError = true;
|
|
694
|
-
_iteratorError = err;
|
|
695
|
-
} finally {
|
|
696
|
-
try {
|
|
697
|
-
if (_iteratorAbruptCompletion && _iterator.return != null) {
|
|
698
|
-
yield _iterator.return();
|
|
699
|
-
}
|
|
700
|
-
} finally {
|
|
701
|
-
if (_didIteratorError) {
|
|
702
|
-
throw _iteratorError;
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
} catch (e) {
|
|
707
|
-
logger.warn("Error watching TURN servers", e);
|
|
708
|
-
} finally {
|
|
709
|
-
_this17.lifecycle.signal.removeEventListener("abort", onClientStopped);
|
|
566
|
+
async watchTurnServers() {
|
|
567
|
+
const servers = this.widgetApi.getTurnServers();
|
|
568
|
+
const onClientStopped = () => {
|
|
569
|
+
servers.return(undefined);
|
|
570
|
+
};
|
|
571
|
+
this.lifecycle.signal.addEventListener("abort", onClientStopped);
|
|
572
|
+
try {
|
|
573
|
+
for await (const server of servers) {
|
|
574
|
+
this.turnServers = [{
|
|
575
|
+
urls: server.uris,
|
|
576
|
+
username: server.username,
|
|
577
|
+
credential: server.password
|
|
578
|
+
}];
|
|
579
|
+
this.emit(ClientEvent.TurnServers, this.turnServers);
|
|
580
|
+
logger.log(`Received TURN server: ${server.uris}`);
|
|
710
581
|
}
|
|
711
|
-
}
|
|
582
|
+
} catch (e) {
|
|
583
|
+
logger.warn("Error watching TURN servers", e);
|
|
584
|
+
} finally {
|
|
585
|
+
this.lifecycle.signal.removeEventListener("abort", onClientStopped);
|
|
586
|
+
}
|
|
712
587
|
}
|
|
713
588
|
}
|
|
714
589
|
function processAndThrow(error) {
|