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/sliding-sync-sdk.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
2
|
/*
|
|
4
3
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
5
4
|
|
|
@@ -32,7 +31,7 @@ import { KnownMembership } from "./@types/membership.js";
|
|
|
32
31
|
// Number of consecutive failed syncs that will lead to a syncState of ERROR as opposed
|
|
33
32
|
// to RECONNECTING. This is needed to inform the client of server issues when the
|
|
34
33
|
// keepAlive is successful but the server /sync fails.
|
|
35
|
-
|
|
34
|
+
const FAILED_SYNC_ERROR_THRESHOLD = 3;
|
|
36
35
|
class ExtensionE2EE {
|
|
37
36
|
constructor(crypto) {
|
|
38
37
|
this.crypto = crypto;
|
|
@@ -43,43 +42,37 @@ class ExtensionE2EE {
|
|
|
43
42
|
when() {
|
|
44
43
|
return ExtensionState.PreProcess;
|
|
45
44
|
}
|
|
46
|
-
onRequest(isInitial) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return _asyncToGenerator(function* () {
|
|
67
|
-
// Handle device list updates
|
|
68
|
-
if (data.device_lists) {
|
|
69
|
-
yield _this2.crypto.processDeviceLists(data.device_lists);
|
|
70
|
-
}
|
|
45
|
+
async onRequest(isInitial) {
|
|
46
|
+
if (isInitial) {
|
|
47
|
+
// In SSS, the `?pos=` contains the stream position for device list updates.
|
|
48
|
+
// If we do not have a `?pos=` (e.g because we forgot it, or because the server
|
|
49
|
+
// invalidated our connection) then we MUST invlaidate all device lists because
|
|
50
|
+
// the server will not tell us the delta. This will then cause UTDs as we will fail
|
|
51
|
+
// to encrypt for new devices. This is an expensive call, so we should
|
|
52
|
+
// really really remember `?pos=` wherever possible.
|
|
53
|
+
logger.log("ExtensionE2EE: invalidating all device lists due to missing 'pos'");
|
|
54
|
+
await this.crypto.markAllTrackedUsersAsDirty();
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
enabled: true // this is sticky so only send it on the initial request
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async onResponse(data) {
|
|
61
|
+
// Handle device list updates
|
|
62
|
+
if (data.device_lists) {
|
|
63
|
+
await this.crypto.processDeviceLists(data.device_lists);
|
|
64
|
+
}
|
|
71
65
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
})();
|
|
66
|
+
// Handle one_time_keys_count and unused_fallback_key_types
|
|
67
|
+
await this.crypto.processKeyCounts(data.device_one_time_keys_count, data["device_unused_fallback_key_types"] || data["org.matrix.msc2732.device_unused_fallback_key_types"]);
|
|
68
|
+
this.crypto.onSyncCompleted({});
|
|
76
69
|
}
|
|
77
70
|
}
|
|
78
71
|
class ExtensionToDevice {
|
|
79
72
|
constructor(client, cryptoCallbacks) {
|
|
73
|
+
_defineProperty(this, "nextBatch", null);
|
|
80
74
|
this.client = client;
|
|
81
75
|
this.cryptoCallbacks = cryptoCallbacks;
|
|
82
|
-
_defineProperty(this, "nextBatch", null);
|
|
83
76
|
}
|
|
84
77
|
name() {
|
|
85
78
|
return "to_device";
|
|
@@ -87,34 +80,27 @@ class ExtensionToDevice {
|
|
|
87
80
|
when() {
|
|
88
81
|
return ExtensionState.PreProcess;
|
|
89
82
|
}
|
|
90
|
-
onRequest(isInitial) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
message: rawEvent,
|
|
112
|
-
encryptionInfo: null
|
|
113
|
-
}));
|
|
114
|
-
}
|
|
115
|
-
processToDeviceMessages(receivedToDeviceMessages, _this4.client);
|
|
116
|
-
_this4.nextBatch = data.next_batch;
|
|
117
|
-
})();
|
|
83
|
+
async onRequest(isInitial) {
|
|
84
|
+
return {
|
|
85
|
+
since: this.nextBatch !== null ? this.nextBatch : undefined,
|
|
86
|
+
limit: 100,
|
|
87
|
+
enabled: true
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
async onResponse(data) {
|
|
91
|
+
const events = data["events"] || [];
|
|
92
|
+
let receivedToDeviceMessages;
|
|
93
|
+
if (this.cryptoCallbacks) {
|
|
94
|
+
receivedToDeviceMessages = await this.cryptoCallbacks.preprocessToDeviceMessages(events);
|
|
95
|
+
} else {
|
|
96
|
+
// Crypto is not enabled, so we just return the events.
|
|
97
|
+
receivedToDeviceMessages = events.map(rawEvent => ({
|
|
98
|
+
message: rawEvent,
|
|
99
|
+
encryptionInfo: null
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
processToDeviceMessages(receivedToDeviceMessages, this.client);
|
|
103
|
+
this.nextBatch = data.next_batch;
|
|
118
104
|
}
|
|
119
105
|
}
|
|
120
106
|
class ExtensionAccountData {
|
|
@@ -127,36 +113,31 @@ class ExtensionAccountData {
|
|
|
127
113
|
when() {
|
|
128
114
|
return ExtensionState.PostProcess;
|
|
129
115
|
}
|
|
130
|
-
onRequest(isInitial) {
|
|
131
|
-
return
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
};
|
|
135
|
-
})();
|
|
116
|
+
async onRequest(isInitial) {
|
|
117
|
+
return {
|
|
118
|
+
enabled: true
|
|
119
|
+
};
|
|
136
120
|
}
|
|
137
|
-
onResponse(data) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
logger.warn("got account data for room but room doesn't exist on client:", roomId);
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
room.addAccountData(accountDataEvents);
|
|
151
|
-
accountDataEvents.forEach(e => {
|
|
152
|
-
_this5.client.emit(ClientEvent.Event, e);
|
|
153
|
-
});
|
|
121
|
+
async onResponse(data) {
|
|
122
|
+
if (data.global && data.global.length > 0) {
|
|
123
|
+
this.processGlobalAccountData(data.global);
|
|
124
|
+
}
|
|
125
|
+
for (const roomId in data.rooms) {
|
|
126
|
+
const accountDataEvents = mapEvents(this.client, roomId, data.rooms[roomId]);
|
|
127
|
+
const room = this.client.getRoom(roomId);
|
|
128
|
+
if (!room) {
|
|
129
|
+
logger.warn("got account data for room but room doesn't exist on client:", roomId);
|
|
130
|
+
continue;
|
|
154
131
|
}
|
|
155
|
-
|
|
132
|
+
room.addAccountData(accountDataEvents);
|
|
133
|
+
accountDataEvents.forEach(e => {
|
|
134
|
+
this.client.emit(ClientEvent.Event, e);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
156
137
|
}
|
|
157
138
|
processGlobalAccountData(globalAccountData) {
|
|
158
|
-
|
|
159
|
-
|
|
139
|
+
const events = mapEvents(this.client, undefined, globalAccountData);
|
|
140
|
+
const prevEventsMap = events.reduce((m, c) => {
|
|
160
141
|
m[c.getType()] = this.client.store.getAccountData(c.getType());
|
|
161
142
|
return m;
|
|
162
143
|
}, {});
|
|
@@ -167,10 +148,10 @@ class ExtensionAccountData {
|
|
|
167
148
|
// will be updated when we receive push rules via getPushRules
|
|
168
149
|
// (see sync) before syncing over the network.
|
|
169
150
|
if (accountDataEvent.getType() === EventType.PushRules) {
|
|
170
|
-
|
|
151
|
+
const rules = accountDataEvent.getContent();
|
|
171
152
|
this.client.setPushRules(rules);
|
|
172
153
|
}
|
|
173
|
-
|
|
154
|
+
const prevEvent = prevEventsMap[accountDataEvent.getType()];
|
|
174
155
|
this.client.emit(ClientEvent.AccountData, accountDataEvent, prevEvent);
|
|
175
156
|
return accountDataEvent;
|
|
176
157
|
});
|
|
@@ -186,23 +167,18 @@ class ExtensionTyping {
|
|
|
186
167
|
when() {
|
|
187
168
|
return ExtensionState.PostProcess;
|
|
188
169
|
}
|
|
189
|
-
onRequest(isInitial) {
|
|
190
|
-
return
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
};
|
|
194
|
-
})();
|
|
170
|
+
async onRequest(isInitial) {
|
|
171
|
+
return {
|
|
172
|
+
enabled: true
|
|
173
|
+
};
|
|
195
174
|
}
|
|
196
|
-
onResponse(data) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
processEphemeralEvents(_this6.client, roomId, [data.rooms[roomId]]);
|
|
204
|
-
}
|
|
205
|
-
})();
|
|
175
|
+
async onResponse(data) {
|
|
176
|
+
if (!data?.rooms) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
for (const roomId in data.rooms) {
|
|
180
|
+
processEphemeralEvents(this.client, roomId, [data.rooms[roomId]]);
|
|
181
|
+
}
|
|
206
182
|
}
|
|
207
183
|
}
|
|
208
184
|
class ExtensionReceipts {
|
|
@@ -215,23 +191,18 @@ class ExtensionReceipts {
|
|
|
215
191
|
when() {
|
|
216
192
|
return ExtensionState.PostProcess;
|
|
217
193
|
}
|
|
218
|
-
onRequest(isInitial) {
|
|
219
|
-
return
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
};
|
|
223
|
-
})();
|
|
194
|
+
async onRequest(isInitial) {
|
|
195
|
+
return {
|
|
196
|
+
enabled: true
|
|
197
|
+
};
|
|
224
198
|
}
|
|
225
|
-
onResponse(data) {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
processEphemeralEvents(_this7.client, roomId, [data.rooms[roomId]]);
|
|
233
|
-
}
|
|
234
|
-
})();
|
|
199
|
+
async onResponse(data) {
|
|
200
|
+
if (!data?.rooms) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
for (const roomId in data.rooms) {
|
|
204
|
+
processEphemeralEvents(this.client, roomId, [data.rooms[roomId]]);
|
|
205
|
+
}
|
|
235
206
|
}
|
|
236
207
|
}
|
|
237
208
|
|
|
@@ -243,8 +214,6 @@ export class SlidingSyncSdk {
|
|
|
243
214
|
// accumulator of sync events in the current sync response
|
|
244
215
|
|
|
245
216
|
constructor(slidingSync, client, opts, syncOpts) {
|
|
246
|
-
this.slidingSync = slidingSync;
|
|
247
|
-
this.client = client;
|
|
248
217
|
_defineProperty(this, "opts", void 0);
|
|
249
218
|
_defineProperty(this, "syncOpts", void 0);
|
|
250
219
|
_defineProperty(this, "syncState", null);
|
|
@@ -252,6 +221,8 @@ export class SlidingSyncSdk {
|
|
|
252
221
|
_defineProperty(this, "lastPos", null);
|
|
253
222
|
_defineProperty(this, "failCount", 0);
|
|
254
223
|
_defineProperty(this, "notifEvents", []);
|
|
224
|
+
this.slidingSync = slidingSync;
|
|
225
|
+
this.client = client;
|
|
255
226
|
this.opts = defaultClientOpts(opts);
|
|
256
227
|
this.syncOpts = defaultSyncApiOpts(syncOpts);
|
|
257
228
|
if (client.getNotifTimelineSet()) {
|
|
@@ -259,7 +230,7 @@ export class SlidingSyncSdk {
|
|
|
259
230
|
}
|
|
260
231
|
this.slidingSync.on(SlidingSyncEvent.Lifecycle, this.onLifecycle.bind(this));
|
|
261
232
|
this.slidingSync.on(SlidingSyncEvent.RoomData, this.onRoomData.bind(this));
|
|
262
|
-
|
|
233
|
+
const extensions = [new ExtensionToDevice(this.client, this.syncOpts.cryptoCallbacks), new ExtensionAccountData(this.client), new ExtensionTyping(this.client), new ExtensionReceipts(this.client)];
|
|
263
234
|
if (this.syncOpts.cryptoCallbacks) {
|
|
264
235
|
extensions.push(new ExtensionE2EE(this.syncOpts.cryptoCallbacks));
|
|
265
236
|
}
|
|
@@ -267,19 +238,16 @@ export class SlidingSyncSdk {
|
|
|
267
238
|
this.slidingSync.registerExtension(ext);
|
|
268
239
|
});
|
|
269
240
|
}
|
|
270
|
-
onRoomData(roomId, roomData) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
_this8.syncOpts.logger.debug("initial flag not set but no stored room exists for room ", roomId, roomData);
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
room = _createAndReEmitRoom(_this8.client, roomId, _this8.opts);
|
|
241
|
+
async onRoomData(roomId, roomData) {
|
|
242
|
+
let room = this.client.store.getRoom(roomId);
|
|
243
|
+
if (!room) {
|
|
244
|
+
if (!roomData.initial) {
|
|
245
|
+
this.syncOpts.logger.debug("initial flag not set but no stored room exists for room ", roomId, roomData);
|
|
246
|
+
return;
|
|
280
247
|
}
|
|
281
|
-
|
|
282
|
-
}
|
|
248
|
+
room = _createAndReEmitRoom(this.client, roomId, this.opts);
|
|
249
|
+
}
|
|
250
|
+
await this.processRoomData(this.client, room, roomData);
|
|
283
251
|
}
|
|
284
252
|
onLifecycle(state, resp, err) {
|
|
285
253
|
if (err) {
|
|
@@ -321,7 +289,7 @@ export class SlidingSyncSdk {
|
|
|
321
289
|
}
|
|
322
290
|
} else {
|
|
323
291
|
this.failCount = 0;
|
|
324
|
-
this.syncOpts.logger.debug(
|
|
292
|
+
this.syncOpts.logger.debug(`SlidingSyncState.RequestFinished with ${Object.keys(resp?.rooms || []).length} rooms`);
|
|
325
293
|
}
|
|
326
294
|
break;
|
|
327
295
|
}
|
|
@@ -331,10 +299,8 @@ export class SlidingSyncSdk {
|
|
|
331
299
|
* Sync rooms the user has left.
|
|
332
300
|
* @returns Resolved when they've been added to the store.
|
|
333
301
|
*/
|
|
334
|
-
syncLeftRooms() {
|
|
335
|
-
return
|
|
336
|
-
return []; // TODO
|
|
337
|
-
})();
|
|
302
|
+
async syncLeftRooms() {
|
|
303
|
+
return []; // TODO
|
|
338
304
|
}
|
|
339
305
|
|
|
340
306
|
/**
|
|
@@ -344,10 +310,8 @@ export class SlidingSyncSdk {
|
|
|
344
310
|
* @returns A promise which resolves once the room has been added to the
|
|
345
311
|
* store.
|
|
346
312
|
*/
|
|
347
|
-
peek(roomId) {
|
|
348
|
-
return
|
|
349
|
-
return null; // TODO
|
|
350
|
-
})();
|
|
313
|
+
async peek(roomId) {
|
|
314
|
+
return null; // TODO
|
|
351
315
|
}
|
|
352
316
|
|
|
353
317
|
/**
|
|
@@ -382,16 +346,17 @@ export class SlidingSyncSdk {
|
|
|
382
346
|
* this object.
|
|
383
347
|
*/
|
|
384
348
|
getSyncStateData() {
|
|
385
|
-
|
|
386
|
-
return (_this$syncStateData = this.syncStateData) !== null && _this$syncStateData !== void 0 ? _this$syncStateData : null;
|
|
349
|
+
return this.syncStateData ?? null;
|
|
387
350
|
}
|
|
388
351
|
|
|
389
352
|
// Helper functions which set up JS SDK structs are below and are identical to the sync v2 counterparts
|
|
390
353
|
|
|
391
354
|
createRoom(roomId) {
|
|
392
355
|
// XXX cargoculted from sync.ts
|
|
393
|
-
|
|
394
|
-
|
|
356
|
+
const {
|
|
357
|
+
timelineSupport
|
|
358
|
+
} = this.client;
|
|
359
|
+
const room = new Room(roomId, this.client, this.client.getUserId(), {
|
|
395
360
|
lazyLoadMembers: this.opts.lazyLoadMembers,
|
|
396
361
|
pendingEventOrdering: this.opts.pendingEventOrdering,
|
|
397
362
|
timelineSupport
|
|
@@ -407,8 +372,7 @@ export class SlidingSyncSdk {
|
|
|
407
372
|
// order to hook them correctly.
|
|
408
373
|
this.client.reEmitter.reEmit(room.currentState, [RoomStateEvent.Events, RoomStateEvent.Members, RoomStateEvent.NewMember, RoomStateEvent.Update]);
|
|
409
374
|
room.currentState.on(RoomStateEvent.NewMember, (event, state, member) => {
|
|
410
|
-
|
|
411
|
-
member.user = (_this$client$getUser = this.client.getUser(member.userId)) !== null && _this$client$getUser !== void 0 ? _this$client$getUser : undefined;
|
|
375
|
+
member.user = this.client.getUser(member.userId) ?? undefined;
|
|
412
376
|
this.client.reEmitter.reEmit(member, [RoomMemberEvent.Name, RoomMemberEvent.Typing, RoomMemberEvent.PowerLevel, RoomMemberEvent.Membership]);
|
|
413
377
|
});
|
|
414
378
|
}
|
|
@@ -433,189 +397,180 @@ export class SlidingSyncSdk {
|
|
|
433
397
|
}
|
|
434
398
|
return false;
|
|
435
399
|
}
|
|
436
|
-
processRoomData(client, room, roomData) {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
seenKnownEvent = true;
|
|
473
|
-
continue; // don't include this event, it's a dupe
|
|
474
|
-
}
|
|
475
|
-
if (seenKnownEvent) {
|
|
476
|
-
// old -> new
|
|
477
|
-
oldEvents.push(recvEvent);
|
|
478
|
-
} else {
|
|
479
|
-
// old -> new
|
|
480
|
-
newEvents.unshift(recvEvent);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
timelineEvents = newEvents;
|
|
484
|
-
if (oldEvents.length > 0) {
|
|
485
|
-
// old events are scrollback, insert them now
|
|
486
|
-
room.addEventsToTimeline(oldEvents, true, false, room.getLiveTimeline(), roomData.prev_batch);
|
|
400
|
+
async processRoomData(client, room, roomData) {
|
|
401
|
+
roomData = ensureNameEvent(client, room.roomId, roomData);
|
|
402
|
+
const stateEvents = mapEvents(this.client, room.roomId, roomData.required_state);
|
|
403
|
+
// Prevent events from being decrypted ahead of time
|
|
404
|
+
// this helps large account to speed up faster
|
|
405
|
+
// room::decryptCriticalEvent is in charge of decrypting all the events
|
|
406
|
+
// required for a client to function properly
|
|
407
|
+
let timelineEvents = mapEvents(this.client, room.roomId, roomData.timeline, false);
|
|
408
|
+
const ephemeralEvents = []; // TODO this.mapSyncEventsFormat(joinObj.ephemeral);
|
|
409
|
+
|
|
410
|
+
// TODO: handle threaded / beacon events
|
|
411
|
+
|
|
412
|
+
if (roomData.limited || roomData.initial) {
|
|
413
|
+
// we should not know about any of these timeline entries if this is a genuinely new room.
|
|
414
|
+
// If we do, then we've effectively done scrollback (e.g requesting timeline_limit: 1 for
|
|
415
|
+
// this room, then timeline_limit: 50).
|
|
416
|
+
const knownEvents = new Set();
|
|
417
|
+
room.getLiveTimeline().getEvents().forEach(e => {
|
|
418
|
+
knownEvents.add(e.getId());
|
|
419
|
+
});
|
|
420
|
+
// all unknown events BEFORE a known event must be scrollback e.g:
|
|
421
|
+
// D E <-- what we know
|
|
422
|
+
// A B C D E F <-- what we just received
|
|
423
|
+
// means:
|
|
424
|
+
// A B C <-- scrollback
|
|
425
|
+
// D E <-- dupes
|
|
426
|
+
// F <-- new event
|
|
427
|
+
// We bucket events based on if we have seen a known event yet.
|
|
428
|
+
const oldEvents = [];
|
|
429
|
+
const newEvents = [];
|
|
430
|
+
let seenKnownEvent = false;
|
|
431
|
+
for (let i = timelineEvents.length - 1; i >= 0; i--) {
|
|
432
|
+
const recvEvent = timelineEvents[i];
|
|
433
|
+
if (knownEvents.has(recvEvent.getId())) {
|
|
434
|
+
seenKnownEvent = true;
|
|
435
|
+
continue; // don't include this event, it's a dupe
|
|
487
436
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
if (roomData.highlight_count != null) {
|
|
495
|
-
// We track unread notifications ourselves in encrypted rooms, so don't
|
|
496
|
-
// bother setting it here. We trust our calculations better than the
|
|
497
|
-
// server's for this case, and therefore will assume that our non-zero
|
|
498
|
-
// count is accurate.
|
|
499
|
-
if (!encrypted || encrypted && room.getUnreadNotificationCount(NotificationCountType.Highlight) <= 0) {
|
|
500
|
-
room.setUnreadNotificationCount(NotificationCountType.Highlight, roomData.highlight_count);
|
|
437
|
+
if (seenKnownEvent) {
|
|
438
|
+
// old -> new
|
|
439
|
+
oldEvents.push(recvEvent);
|
|
440
|
+
} else {
|
|
441
|
+
// old -> new
|
|
442
|
+
newEvents.unshift(recvEvent);
|
|
501
443
|
}
|
|
502
444
|
}
|
|
503
|
-
|
|
504
|
-
|
|
445
|
+
timelineEvents = newEvents;
|
|
446
|
+
if (oldEvents.length > 0) {
|
|
447
|
+
// old events are scrollback, insert them now
|
|
448
|
+
room.addEventsToTimeline(oldEvents, true, false, room.getLiveTimeline(), roomData.prev_batch);
|
|
505
449
|
}
|
|
506
|
-
|
|
507
|
-
|
|
450
|
+
}
|
|
451
|
+
const encrypted = room.hasEncryptionStateEvent();
|
|
452
|
+
// we do this first so it's correct when any of the events fire
|
|
453
|
+
if (roomData.notification_count != null) {
|
|
454
|
+
room.setUnreadNotificationCount(NotificationCountType.Total, roomData.notification_count);
|
|
455
|
+
}
|
|
456
|
+
if (roomData.highlight_count != null) {
|
|
457
|
+
// We track unread notifications ourselves in encrypted rooms, so don't
|
|
458
|
+
// bother setting it here. We trust our calculations better than the
|
|
459
|
+
// server's for this case, and therefore will assume that our non-zero
|
|
460
|
+
// count is accurate.
|
|
461
|
+
if (!encrypted || encrypted && room.getUnreadNotificationCount(NotificationCountType.Highlight) <= 0) {
|
|
462
|
+
room.setUnreadNotificationCount(NotificationCountType.Highlight, roomData.highlight_count);
|
|
508
463
|
}
|
|
509
|
-
|
|
510
|
-
|
|
464
|
+
}
|
|
465
|
+
if (roomData.bump_stamp) {
|
|
466
|
+
room.setBumpStamp(roomData.bump_stamp);
|
|
467
|
+
}
|
|
468
|
+
if (Number.isInteger(roomData.invited_count)) {
|
|
469
|
+
room.currentState.setInvitedMemberCount(roomData.invited_count);
|
|
470
|
+
}
|
|
471
|
+
if (Number.isInteger(roomData.joined_count)) {
|
|
472
|
+
room.currentState.setJoinedMemberCount(roomData.joined_count);
|
|
473
|
+
}
|
|
474
|
+
if (roomData.invite_state) {
|
|
475
|
+
const inviteStateEvents = mapEvents(this.client, room.roomId, roomData.invite_state);
|
|
476
|
+
await this.injectRoomEvents(room, inviteStateEvents);
|
|
477
|
+
if (roomData.initial) {
|
|
478
|
+
room.recalculate();
|
|
479
|
+
this.client.store.storeRoom(room);
|
|
480
|
+
this.client.emit(ClientEvent.Room, room);
|
|
511
481
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
482
|
+
inviteStateEvents.forEach(e => {
|
|
483
|
+
this.client.emit(ClientEvent.Event, e);
|
|
484
|
+
});
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
if (roomData.limited) {
|
|
488
|
+
// set the back-pagination token. Do this *before* adding any
|
|
489
|
+
// events so that clients can start back-paginating.
|
|
490
|
+
room.getLiveTimeline().setPaginationToken(roomData.prev_batch ?? null, EventTimeline.BACKWARDS);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/* TODO
|
|
494
|
+
else if (roomData.limited) {
|
|
495
|
+
let limited = true;
|
|
496
|
+
// we've got a limited sync, so we *probably* have a gap in the
|
|
497
|
+
// timeline, so should reset. But we might have been peeking or
|
|
498
|
+
// paginating and already have some of the events, in which
|
|
499
|
+
// case we just want to append any subsequent events to the end
|
|
500
|
+
// of the existing timeline.
|
|
501
|
+
//
|
|
502
|
+
// This is particularly important in the case that we already have
|
|
503
|
+
// *all* of the events in the timeline - in that case, if we reset
|
|
504
|
+
// the timeline, we'll end up with an entirely empty timeline,
|
|
505
|
+
// which we'll try to paginate but not get any new events (which
|
|
506
|
+
// will stop us linking the empty timeline into the chain).
|
|
507
|
+
//
|
|
508
|
+
for (let i = timelineEvents.length - 1; i >= 0; i--) {
|
|
509
|
+
const eventId = timelineEvents[i].getId();
|
|
510
|
+
if (room.getTimelineForEvent(eventId)) {
|
|
511
|
+
this.syncOpts.logger.debug("Already have event " + eventId + " in limited " +
|
|
512
|
+
"sync - not resetting");
|
|
513
|
+
limited = false;
|
|
514
|
+
// we might still be missing some of the events before i;
|
|
515
|
+
// we don't want to be adding them to the end of the
|
|
516
|
+
// timeline because that would put them out of order.
|
|
517
|
+
timelineEvents.splice(0, i);
|
|
518
|
+
// XXX: there's a problem here if the skipped part of the
|
|
519
|
+
// timeline modifies the state set in stateEvents, because
|
|
520
|
+
// we'll end up using the state from stateEvents rather
|
|
521
|
+
// than the later state from timelineEvents. We probably
|
|
522
|
+
// need to wind stateEvents forward over the events we're
|
|
523
|
+
// skipping.
|
|
524
|
+
break;
|
|
525
|
+
}
|
|
519
526
|
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
527
|
+
if (limited) {
|
|
528
|
+
room.resetLiveTimeline(
|
|
529
|
+
roomData.prev_batch,
|
|
530
|
+
null, // TODO this.syncOpts.canResetEntireTimeline(room.roomId) ? null : syncEventData.oldSyncToken,
|
|
531
|
+
);
|
|
532
|
+
// We have to assume any gap in any timeline is
|
|
533
|
+
// reason to stop incrementally tracking notifications and
|
|
534
|
+
// reset the timeline.
|
|
535
|
+
this.client.resetNotifTimelineSet();
|
|
536
|
+
this.registerStateListeners(room);
|
|
537
|
+
}
|
|
538
|
+
} */
|
|
531
539
|
|
|
532
|
-
|
|
533
|
-
else if (roomData.limited) {
|
|
534
|
-
let limited = true;
|
|
535
|
-
// we've got a limited sync, so we *probably* have a gap in the
|
|
536
|
-
// timeline, so should reset. But we might have been peeking or
|
|
537
|
-
// paginating and already have some of the events, in which
|
|
538
|
-
// case we just want to append any subsequent events to the end
|
|
539
|
-
// of the existing timeline.
|
|
540
|
-
//
|
|
541
|
-
// This is particularly important in the case that we already have
|
|
542
|
-
// *all* of the events in the timeline - in that case, if we reset
|
|
543
|
-
// the timeline, we'll end up with an entirely empty timeline,
|
|
544
|
-
// which we'll try to paginate but not get any new events (which
|
|
545
|
-
// will stop us linking the empty timeline into the chain).
|
|
546
|
-
//
|
|
547
|
-
for (let i = timelineEvents.length - 1; i >= 0; i--) {
|
|
548
|
-
const eventId = timelineEvents[i].getId();
|
|
549
|
-
if (room.getTimelineForEvent(eventId)) {
|
|
550
|
-
this.syncOpts.logger.debug("Already have event " + eventId + " in limited " +
|
|
551
|
-
"sync - not resetting");
|
|
552
|
-
limited = false;
|
|
553
|
-
// we might still be missing some of the events before i;
|
|
554
|
-
// we don't want to be adding them to the end of the
|
|
555
|
-
// timeline because that would put them out of order.
|
|
556
|
-
timelineEvents.splice(0, i);
|
|
557
|
-
// XXX: there's a problem here if the skipped part of the
|
|
558
|
-
// timeline modifies the state set in stateEvents, because
|
|
559
|
-
// we'll end up using the state from stateEvents rather
|
|
560
|
-
// than the later state from timelineEvents. We probably
|
|
561
|
-
// need to wind stateEvents forward over the events we're
|
|
562
|
-
// skipping.
|
|
563
|
-
break;
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
if (limited) {
|
|
567
|
-
room.resetLiveTimeline(
|
|
568
|
-
roomData.prev_batch,
|
|
569
|
-
null, // TODO this.syncOpts.canResetEntireTimeline(room.roomId) ? null : syncEventData.oldSyncToken,
|
|
570
|
-
);
|
|
571
|
-
// We have to assume any gap in any timeline is
|
|
572
|
-
// reason to stop incrementally tracking notifications and
|
|
573
|
-
// reset the timeline.
|
|
574
|
-
this.client.resetNotifTimelineSet();
|
|
575
|
-
this.registerStateListeners(room);
|
|
576
|
-
}
|
|
577
|
-
} */
|
|
540
|
+
await this.injectRoomEvents(room, stateEvents, timelineEvents, roomData.num_live);
|
|
578
541
|
|
|
579
|
-
|
|
542
|
+
// we deliberately don't add ephemeral events to the timeline
|
|
543
|
+
room.addEphemeralEvents(ephemeralEvents);
|
|
580
544
|
|
|
581
|
-
|
|
582
|
-
|
|
545
|
+
// local fields must be set before any async calls because call site assumes
|
|
546
|
+
// synchronous execution prior to emitting SlidingSyncState.Complete
|
|
547
|
+
room.updateMyMembership(KnownMembership.Join);
|
|
548
|
+
room.setMSC4186SummaryData(roomData.heroes, roomData.joined_count, roomData.invited_count);
|
|
549
|
+
room.recalculate();
|
|
550
|
+
if (roomData.initial) {
|
|
551
|
+
client.store.storeRoom(room);
|
|
552
|
+
client.emit(ClientEvent.Room, room);
|
|
553
|
+
}
|
|
583
554
|
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
if (
|
|
590
|
-
|
|
591
|
-
client.emit(ClientEvent.Room, room);
|
|
555
|
+
// check if any timeline events should bing and add them to the notifEvents array:
|
|
556
|
+
// we'll purge this once we've fully processed the sync response
|
|
557
|
+
this.addNotifications(timelineEvents);
|
|
558
|
+
const processRoomEvent = async e => {
|
|
559
|
+
client.emit(ClientEvent.Event, e);
|
|
560
|
+
if (e.isState() && e.getType() == EventType.RoomEncryption && this.syncOpts.cryptoCallbacks) {
|
|
561
|
+
await this.syncOpts.cryptoCallbacks.onCryptoEvent(room, e);
|
|
592
562
|
}
|
|
563
|
+
};
|
|
564
|
+
await promiseMapSeries(stateEvents, processRoomEvent);
|
|
565
|
+
await promiseMapSeries(timelineEvents, processRoomEvent);
|
|
566
|
+
ephemeralEvents.forEach(function (e) {
|
|
567
|
+
client.emit(ClientEvent.Event, e);
|
|
568
|
+
});
|
|
593
569
|
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
var _ref = _asyncToGenerator(function* (e) {
|
|
599
|
-
client.emit(ClientEvent.Event, e);
|
|
600
|
-
if (e.isState() && e.getType() == EventType.RoomEncryption && _this9.syncOpts.cryptoCallbacks) {
|
|
601
|
-
yield _this9.syncOpts.cryptoCallbacks.onCryptoEvent(room, e);
|
|
602
|
-
}
|
|
603
|
-
});
|
|
604
|
-
return function processRoomEvent(_x) {
|
|
605
|
-
return _ref.apply(this, arguments);
|
|
606
|
-
};
|
|
607
|
-
}();
|
|
608
|
-
yield promiseMapSeries(stateEvents, processRoomEvent);
|
|
609
|
-
yield promiseMapSeries(timelineEvents, processRoomEvent);
|
|
610
|
-
ephemeralEvents.forEach(function (e) {
|
|
611
|
-
client.emit(ClientEvent.Event, e);
|
|
612
|
-
});
|
|
613
|
-
|
|
614
|
-
// Decrypt only the last message in all rooms to make sure we can generate a preview
|
|
615
|
-
// And decrypt all events after the recorded read receipt to ensure an accurate
|
|
616
|
-
// notification count
|
|
617
|
-
room.decryptCriticalEvents();
|
|
618
|
-
})();
|
|
570
|
+
// Decrypt only the last message in all rooms to make sure we can generate a preview
|
|
571
|
+
// And decrypt all events after the recorded read receipt to ensure an accurate
|
|
572
|
+
// notification count
|
|
573
|
+
room.decryptCriticalEvents();
|
|
619
574
|
}
|
|
620
575
|
|
|
621
576
|
/**
|
|
@@ -627,94 +582,88 @@ export class SlidingSyncSdk {
|
|
|
627
582
|
* @param numLive - the number of events in timelineEventList which just happened,
|
|
628
583
|
* supplied from the server.
|
|
629
584
|
*/
|
|
630
|
-
injectRoomEvents(room, stateEventList) {
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
//
|
|
637
|
-
// the
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
// push actions cache elsewhere so we can freeze MatrixEvents, or otherwise
|
|
647
|
-
// find some solution where MatrixEvents are immutable but allow for a cache
|
|
648
|
-
// field.
|
|
649
|
-
for (var ev of stateEventList) {
|
|
650
|
-
_this0.client.getPushActionsForEvent(ev);
|
|
651
|
-
}
|
|
652
|
-
liveTimeline.initialiseState(stateEventList);
|
|
585
|
+
async injectRoomEvents(room, stateEventList, timelineEventList = [], numLive = 0) {
|
|
586
|
+
// If there are no events in the timeline yet, initialise it with
|
|
587
|
+
// the given state events
|
|
588
|
+
const liveTimeline = room.getLiveTimeline();
|
|
589
|
+
const timelineWasEmpty = liveTimeline.getEvents().length == 0;
|
|
590
|
+
if (timelineWasEmpty) {
|
|
591
|
+
// Passing these events into initialiseState will freeze them, so we need
|
|
592
|
+
// to compute and cache the push actions for them now, otherwise sync dies
|
|
593
|
+
// with an attempt to assign to read only property.
|
|
594
|
+
// XXX: This is pretty horrible and is assuming all sorts of behaviour from
|
|
595
|
+
// these functions that it shouldn't be. We should probably either store the
|
|
596
|
+
// push actions cache elsewhere so we can freeze MatrixEvents, or otherwise
|
|
597
|
+
// find some solution where MatrixEvents are immutable but allow for a cache
|
|
598
|
+
// field.
|
|
599
|
+
for (const ev of stateEventList) {
|
|
600
|
+
this.client.getPushActionsForEvent(ev);
|
|
653
601
|
}
|
|
602
|
+
liveTimeline.initialiseState(stateEventList);
|
|
603
|
+
}
|
|
654
604
|
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
605
|
+
// If the timeline wasn't empty, we process the state events here: they're
|
|
606
|
+
// defined as updates to the state before the start of the timeline, so this
|
|
607
|
+
// starts to roll the state forward.
|
|
608
|
+
// XXX: That's what we *should* do, but this can happen if we were previously
|
|
609
|
+
// peeking in a room, in which case we obviously do *not* want to add the
|
|
610
|
+
// state events here onto the end of the timeline. Historically, the js-sdk
|
|
611
|
+
// has just set these new state events on the old and new state. This seems
|
|
612
|
+
// very wrong because there could be events in the timeline that diverge the
|
|
613
|
+
// state, in which case this is going to leave things out of sync. However,
|
|
614
|
+
// for now I think it;s best to behave the same as the code has done previously.
|
|
615
|
+
if (!timelineWasEmpty) {
|
|
616
|
+
// XXX: As above, don't do this...
|
|
617
|
+
//room.addLiveEvents(stateEventList || []);
|
|
618
|
+
// Do this instead...
|
|
619
|
+
room.oldState.setStateEvents(stateEventList);
|
|
620
|
+
room.currentState.setStateEvents(stateEventList);
|
|
621
|
+
}
|
|
672
622
|
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
623
|
+
// the timeline is broken into 'live' events which just happened and normal timeline events
|
|
624
|
+
// which are still to be appended to the end of the live timeline but happened a while ago.
|
|
625
|
+
// The live events are marked as fromCache=false to ensure that downstream components know
|
|
626
|
+
// this is a live event, not historical (from a remote server cache).
|
|
627
|
+
|
|
628
|
+
let liveTimelineEvents = [];
|
|
629
|
+
if (numLive > 0) {
|
|
630
|
+
// last numLive events are live
|
|
631
|
+
liveTimelineEvents = timelineEventList.slice(-1 * numLive);
|
|
632
|
+
// everything else is not live
|
|
633
|
+
timelineEventList = timelineEventList.slice(0, -1 * liveTimelineEvents.length);
|
|
634
|
+
}
|
|
685
635
|
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
636
|
+
// Execute the timeline events.
|
|
637
|
+
// This also needs to be done before running push rules on the events as they need
|
|
638
|
+
// to be decorated with sender etc.
|
|
639
|
+
await room.addLiveEvents(timelineEventList, {
|
|
640
|
+
fromCache: true,
|
|
641
|
+
addToState: false
|
|
642
|
+
});
|
|
643
|
+
if (liveTimelineEvents.length > 0) {
|
|
644
|
+
await room.addLiveEvents(liveTimelineEvents, {
|
|
645
|
+
fromCache: false,
|
|
691
646
|
addToState: false
|
|
692
647
|
});
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
fromCache: false,
|
|
696
|
-
addToState: false
|
|
697
|
-
});
|
|
698
|
-
}
|
|
699
|
-
room.recalculate();
|
|
648
|
+
}
|
|
649
|
+
room.recalculate();
|
|
700
650
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
})();
|
|
651
|
+
// resolve invites now we have set the latest state
|
|
652
|
+
this.resolveInvites(room);
|
|
704
653
|
}
|
|
705
654
|
resolveInvites(room) {
|
|
706
655
|
if (!room || !this.opts.resolveInvitesToProfiles) {
|
|
707
656
|
return;
|
|
708
657
|
}
|
|
709
|
-
|
|
658
|
+
const client = this.client;
|
|
710
659
|
// For each invited room member we want to give them a displayname/avatar url
|
|
711
660
|
// if they have one (the m.room.member invites don't contain this).
|
|
712
661
|
room.getMembersWithMembership(KnownMembership.Invite).forEach(function (member) {
|
|
713
662
|
if (member.requestedProfileInfo) return;
|
|
714
663
|
member.requestedProfileInfo = true;
|
|
715
664
|
// try to get a cached copy first.
|
|
716
|
-
|
|
717
|
-
|
|
665
|
+
const user = client.getUser(member.userId);
|
|
666
|
+
let promise;
|
|
718
667
|
if (user) {
|
|
719
668
|
promise = Promise.resolve({
|
|
720
669
|
avatar_url: user.avatarUrl,
|
|
@@ -727,7 +676,7 @@ export class SlidingSyncSdk {
|
|
|
727
676
|
// slightly naughty by doctoring the invite event but this means all
|
|
728
677
|
// the code paths remain the same between invite/join display name stuff
|
|
729
678
|
// which is a worthy trade-off for some minor pollution.
|
|
730
|
-
|
|
679
|
+
const inviteEvent = member.events.member;
|
|
731
680
|
if (inviteEvent.getContent().membership !== KnownMembership.Invite) {
|
|
732
681
|
// between resolving and now they have since joined, so don't clobber
|
|
733
682
|
return;
|
|
@@ -748,31 +697,28 @@ export class SlidingSyncSdk {
|
|
|
748
697
|
/**
|
|
749
698
|
* Main entry point. Blocks until stop() is called.
|
|
750
699
|
*/
|
|
751
|
-
sync() {
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
if (_this1.shouldAbortSync(err)) {
|
|
768
|
-
return;
|
|
769
|
-
}
|
|
700
|
+
async sync() {
|
|
701
|
+
this.syncOpts.logger.debug("Sliding sync init loop");
|
|
702
|
+
|
|
703
|
+
// 1) We need to get push rules so we can check if events should bing as we get
|
|
704
|
+
// them from /sync.
|
|
705
|
+
while (!this.client.isGuest()) {
|
|
706
|
+
try {
|
|
707
|
+
this.syncOpts.logger.debug("Getting push rules...");
|
|
708
|
+
const result = await this.client.getPushRules();
|
|
709
|
+
this.syncOpts.logger.debug("Got push rules");
|
|
710
|
+
this.client.pushRules = result;
|
|
711
|
+
break;
|
|
712
|
+
} catch (err) {
|
|
713
|
+
this.syncOpts.logger.error("Getting push rules failed", err);
|
|
714
|
+
if (this.shouldAbortSync(err)) {
|
|
715
|
+
return;
|
|
770
716
|
}
|
|
771
717
|
}
|
|
718
|
+
}
|
|
772
719
|
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
})();
|
|
720
|
+
// start syncing
|
|
721
|
+
await this.slidingSync.start();
|
|
776
722
|
}
|
|
777
723
|
|
|
778
724
|
/**
|
|
@@ -789,7 +735,7 @@ export class SlidingSyncSdk {
|
|
|
789
735
|
* @param data - Object of additional data to emit in the event
|
|
790
736
|
*/
|
|
791
737
|
updateSyncState(newState, data) {
|
|
792
|
-
|
|
738
|
+
const old = this.syncState;
|
|
793
739
|
this.syncState = newState;
|
|
794
740
|
this.syncStateData = data;
|
|
795
741
|
this.client.emit(ClientEvent.Sync, this.syncState, old, data);
|
|
@@ -808,8 +754,8 @@ export class SlidingSyncSdk {
|
|
|
808
754
|
if (!this.client.getNotifTimelineSet()) {
|
|
809
755
|
return;
|
|
810
756
|
}
|
|
811
|
-
for (
|
|
812
|
-
|
|
757
|
+
for (const timelineEvent of timelineEventList) {
|
|
758
|
+
const pushActions = this.client.getPushActionsForEvent(timelineEvent);
|
|
813
759
|
if (pushActions && pushActions.notify && pushActions.tweaks && pushActions.tweaks.highlight) {
|
|
814
760
|
this.notifEvents.push(timelineEvent);
|
|
815
761
|
}
|
|
@@ -828,8 +774,7 @@ export class SlidingSyncSdk {
|
|
|
828
774
|
return a.getTs() - b.getTs();
|
|
829
775
|
});
|
|
830
776
|
this.notifEvents.forEach(event => {
|
|
831
|
-
|
|
832
|
-
(_this$client$getNotif = this.client.getNotifTimelineSet()) === null || _this$client$getNotif === void 0 || _this$client$getNotif.addLiveEvent(event, {
|
|
777
|
+
this.client.getNotifTimelineSet()?.addLiveEvent(event, {
|
|
833
778
|
addToState: false
|
|
834
779
|
});
|
|
835
780
|
});
|
|
@@ -843,7 +788,7 @@ function ensureNameEvent(client, roomId, roomData) {
|
|
|
843
788
|
if (!roomData.name) {
|
|
844
789
|
return roomData;
|
|
845
790
|
}
|
|
846
|
-
for (
|
|
791
|
+
for (const stateEvent of roomData.required_state) {
|
|
847
792
|
if (stateEvent.type === EventType.RoomName && stateEvent.state_key === "") {
|
|
848
793
|
stateEvent.content = {
|
|
849
794
|
name: roomData.name
|
|
@@ -865,9 +810,8 @@ function ensureNameEvent(client, roomId, roomData) {
|
|
|
865
810
|
}
|
|
866
811
|
// Helper functions which set up JS SDK structs are below and are identical to the sync v2 counterparts,
|
|
867
812
|
// just outside the class.
|
|
868
|
-
function mapEvents(client, roomId, events) {
|
|
869
|
-
|
|
870
|
-
var mapper = client.getEventMapper({
|
|
813
|
+
function mapEvents(client, roomId, events, decrypt = true) {
|
|
814
|
+
const mapper = client.getEventMapper({
|
|
871
815
|
decrypt
|
|
872
816
|
});
|
|
873
817
|
return events.map(function (e) {
|
|
@@ -876,8 +820,8 @@ function mapEvents(client, roomId, events) {
|
|
|
876
820
|
});
|
|
877
821
|
}
|
|
878
822
|
function processEphemeralEvents(client, roomId, ephEvents) {
|
|
879
|
-
|
|
880
|
-
|
|
823
|
+
const ephemeralEvents = mapEvents(client, roomId, ephEvents);
|
|
824
|
+
const room = client.getRoom(roomId);
|
|
881
825
|
if (!room) {
|
|
882
826
|
logger.warn("got ephemeral events for room but room doesn't exist on client:", roomId);
|
|
883
827
|
return;
|