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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexeddb-store-worker.js","names":["LocalIndexedDBStoreBackend","logger","IndexedDBStoreWorker","constructor","postMessage","_defineProperty","call","command","ev","_this$backend","_this$backend2","_this$backend3","_this$backend4","_this$backend5","_this$backend6","_this$backend7","_this$backend8","_this$backend9","_this$backend0","_this$backend1","_this$backend10","_this$backend11","_this$backend12","_this$backend13","_this$backend14","_this$backend15","_this$backend16","_this$backend17","msg","data","prom","backend","indexedDB","args","Promise","resolve","connect","onClose","isNewlyCreated","clearDatabase","getSavedSync","setSyncData","syncToDatabase","getUserPresenceEvents","getNextBatchToken","getOutOfBandMembers","clearOutOfBandMembers","setOutOfBandMembers","getClientOptions","storeClientOptions","saveToDeviceBatches","getOldestToDeviceBatch","removeToDeviceBatch","getUserProfile","storeUserProfiles","removeUserProfiles","undefined","seq","error","then","ret","result","err","message","name"],"sources":["../../src/store/indexeddb-store-worker.ts"],"sourcesContent":["/*\nCopyright 2017 - 2021 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { LocalIndexedDBStoreBackend } from \"./indexeddb-local-backend.ts\";\nimport { logger } from \"../logger.ts\";\n\ninterface ICmd {\n command: string;\n seq: number;\n args: any[];\n}\n\n/**\n * This class lives in the webworker and drives a LocalIndexedDBStoreBackend\n * controlled by messages from the main process.\n *\n * @example\n * It should be instantiated by a web worker script provided by the application\n * in a script, for example:\n * ```\n * import {IndexedDBStoreWorker} from 'matrix-js-sdk/lib/indexeddb-worker.js';\n * const remoteWorker = new IndexedDBStoreWorker(postMessage);\n * onmessage = remoteWorker.onMessage;\n * ```\n *\n * Note that it is advisable to import this class by referencing the file directly to\n * avoid a dependency on the whole js-sdk.\n *\n */\nexport class IndexedDBStoreWorker {\n private backend?: LocalIndexedDBStoreBackend;\n\n /**\n * @param postMessage - The web worker postMessage function that\n * should be used to communicate back to the main script.\n */\n public constructor(private readonly postMessage: InstanceType<typeof Worker>[\"postMessage\"]) {}\n\n private onClose = (): void => {\n this.postMessage.call(null, {\n command: \"closed\",\n });\n };\n\n /**\n * Passes a message event from the main script into the class. This method\n * can be directly assigned to the web worker `onmessage` variable.\n *\n * @param ev - The message event\n */\n public onMessage = (ev: MessageEvent): void => {\n const msg: ICmd = ev.data;\n let prom: Promise<any> | undefined;\n\n switch (msg.command) {\n case \"setupWorker\":\n // this is the 'indexedDB' global (where global != window\n // because it's a web worker and there is no window).\n this.backend = new LocalIndexedDBStoreBackend(indexedDB, msg.args[0]);\n prom = Promise.resolve();\n break;\n case \"connect\":\n prom = this.backend?.connect(this.onClose);\n break;\n case \"isNewlyCreated\":\n prom = this.backend?.isNewlyCreated();\n break;\n case \"clearDatabase\":\n prom = this.backend?.clearDatabase();\n break;\n case \"getSavedSync\":\n prom = this.backend?.getSavedSync(false);\n break;\n case \"setSyncData\":\n prom = this.backend?.setSyncData(msg.args[0]);\n break;\n case \"syncToDatabase\":\n prom = this.backend?.syncToDatabase(msg.args[0]);\n break;\n case \"getUserPresenceEvents\":\n prom = this.backend?.getUserPresenceEvents();\n break;\n case \"getNextBatchToken\":\n prom = this.backend?.getNextBatchToken();\n break;\n case \"getOutOfBandMembers\":\n prom = this.backend?.getOutOfBandMembers(msg.args[0]);\n break;\n case \"clearOutOfBandMembers\":\n prom = this.backend?.clearOutOfBandMembers(msg.args[0]);\n break;\n case \"setOutOfBandMembers\":\n prom = this.backend?.setOutOfBandMembers(msg.args[0], msg.args[1]);\n break;\n case \"getClientOptions\":\n prom = this.backend?.getClientOptions();\n break;\n case \"storeClientOptions\":\n prom = this.backend?.storeClientOptions(msg.args[0]);\n break;\n case \"saveToDeviceBatches\":\n prom = this.backend?.saveToDeviceBatches(msg.args[0]);\n break;\n case \"getOldestToDeviceBatch\":\n prom = this.backend?.getOldestToDeviceBatch();\n break;\n case \"removeToDeviceBatch\":\n prom = this.backend?.removeToDeviceBatch(msg.args[0]);\n break;\n case \"getUserProfile\":\n prom = this.backend?.getUserProfile(msg.args[0]);\n break;\n case \"storeUserProfiles\":\n prom = this.backend?.storeUserProfiles(msg.args[0]);\n break;\n case \"removeUserProfiles\":\n prom = this.backend?.removeUserProfiles(msg.args[0]);\n break;\n }\n\n if (prom === undefined) {\n this.postMessage({\n command: \"cmd_fail\",\n seq: msg.seq,\n // Can't be an Error because they're not structured cloneable\n error: \"Unrecognised command\",\n });\n return;\n }\n\n prom.then(\n (ret) => {\n this.postMessage.call(null, {\n command: \"cmd_success\",\n seq: msg.seq,\n result: ret,\n });\n },\n (err) => {\n logger.error(\"Error running command: \" + msg.command, err);\n this.postMessage.call(null, {\n command: \"cmd_fail\",\n seq: msg.seq,\n // Just send a string because Error objects aren't cloneable\n error: {\n message: err.message,\n name: err.name,\n },\n });\n },\n );\n };\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,0BAA0B,QAAQ,8BAA8B;AACzE,SAASC,MAAM,QAAQ,cAAc;AAQrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,CAAC;EAG9B;AACJ;AACA;AACA;EACWC,WAAWA,CAAkBC,WAAuD,EAAE;IAAA,KAAzDA,WAAuD,GAAvDA,WAAuD;IAAAC,eAAA;IAAAA,eAAA,kBAEzE,MAAY;MAC1B,IAAI,CAACD,WAAW,CAACE,IAAI,CAAC,IAAI,EAAE;QACxBC,OAAO,EAAE;MACb,CAAC,CAAC;IACN,CAAC;IAED;AACJ;AACA;AACA;AACA;AACA;IALIF,eAAA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nBkD,GAAG,EAAE7B,GAAG,CAAC6B,GAAG;UACZ;UACAC,KAAK,EAAE;QACX,CAAC,CAAC;QACF;MACJ;MAEA5B,IAAI,CAAC6B,IAAI,CACJC,GAAG,IAAK;QACL,IAAI,CAACxD,WAAW,CAACE,IAAI,CAAC,IAAI,EAAE;UACxBC,OAAO,EAAE,aAAa;UACtBkD,GAAG,EAAE7B,GAAG,CAAC6B,GAAG;UACZI,MAAM,EAAED;QACZ,CAAC,CAAC;MACN,CAAC,EACAE,GAAG,IAAK;QACL7D,MAAM,CAACyD,KAAK,CAAC,yBAAyB,GAAG9B,GAAG,CAACrB,OAAO,EAAEuD,GAAG,CAAC;QAC1D,IAAI,CAAC1D,WAAW,CAACE,IAAI,CAAC,IAAI,EAAE;UACxBC,OAAO,EAAE,UAAU;UACnBkD,GAAG,EAAE7B,GAAG,CAAC6B,GAAG;UACZ;UACAC,KAAK,EAAE;YACHK,OAAO,EAAED,GAAG,CAACC,OAAO;YACpBC,IAAI,EAAEF,GAAG,CAACE;UACd;QACJ,CAAC,CAAC;MACN,CACJ,CAAC;IACL,CAAC;EAnH6F;AAoHlG","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"indexeddb-store-worker.js","names":[],"sources":["../../src/store/indexeddb-store-worker.ts"],"sourcesContent":["/*\nCopyright 2017 - 2021 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { LocalIndexedDBStoreBackend } from \"./indexeddb-local-backend.ts\";\nimport { logger } from \"../logger.ts\";\n\ninterface ICmd {\n command: string;\n seq: number;\n args: any[];\n}\n\n/**\n * This class lives in the webworker and drives a LocalIndexedDBStoreBackend\n * controlled by messages from the main process.\n *\n * @example\n * It should be instantiated by a web worker script provided by the application\n * in a script, for example:\n * ```\n * import {IndexedDBStoreWorker} from 'matrix-js-sdk/lib/indexeddb-worker.js';\n * const remoteWorker = new IndexedDBStoreWorker(postMessage);\n * onmessage = remoteWorker.onMessage;\n * ```\n *\n * Note that it is advisable to import this class by referencing the file directly to\n * avoid a dependency on the whole js-sdk.\n *\n */\nexport class IndexedDBStoreWorker {\n private backend?: LocalIndexedDBStoreBackend;\n\n /**\n * @param postMessage - The web worker postMessage function that\n * should be used to communicate back to the main script.\n */\n public constructor(private readonly postMessage: InstanceType<typeof Worker>[\"postMessage\"]) {}\n\n private onClose = (): void => {\n this.postMessage.call(null, {\n command: \"closed\",\n });\n };\n\n /**\n * Passes a message event from the main script into the class. This method\n * can be directly assigned to the web worker `onmessage` variable.\n *\n * @param ev - The message event\n */\n public onMessage = (ev: MessageEvent): void => {\n const msg: ICmd = ev.data;\n let prom: Promise<any> | undefined;\n\n switch (msg.command) {\n case \"setupWorker\":\n // this is the 'indexedDB' global (where global != window\n // because it's a web worker and there is no window).\n this.backend = new LocalIndexedDBStoreBackend(indexedDB, msg.args[0]);\n prom = Promise.resolve();\n break;\n case \"connect\":\n prom = this.backend?.connect(this.onClose);\n break;\n case \"isNewlyCreated\":\n prom = this.backend?.isNewlyCreated();\n break;\n case \"clearDatabase\":\n prom = this.backend?.clearDatabase();\n break;\n case \"getSavedSync\":\n prom = this.backend?.getSavedSync(false);\n break;\n case \"setSyncData\":\n prom = this.backend?.setSyncData(msg.args[0]);\n break;\n case \"syncToDatabase\":\n prom = this.backend?.syncToDatabase(msg.args[0]);\n break;\n case \"getUserPresenceEvents\":\n prom = this.backend?.getUserPresenceEvents();\n break;\n case \"getNextBatchToken\":\n prom = this.backend?.getNextBatchToken();\n break;\n case \"getOutOfBandMembers\":\n prom = this.backend?.getOutOfBandMembers(msg.args[0]);\n break;\n case \"clearOutOfBandMembers\":\n prom = this.backend?.clearOutOfBandMembers(msg.args[0]);\n break;\n case \"setOutOfBandMembers\":\n prom = this.backend?.setOutOfBandMembers(msg.args[0], msg.args[1]);\n break;\n case \"getClientOptions\":\n prom = this.backend?.getClientOptions();\n break;\n case \"storeClientOptions\":\n prom = this.backend?.storeClientOptions(msg.args[0]);\n break;\n case \"saveToDeviceBatches\":\n prom = this.backend?.saveToDeviceBatches(msg.args[0]);\n break;\n case \"getOldestToDeviceBatch\":\n prom = this.backend?.getOldestToDeviceBatch();\n break;\n case \"removeToDeviceBatch\":\n prom = this.backend?.removeToDeviceBatch(msg.args[0]);\n break;\n case \"getUserProfile\":\n prom = this.backend?.getUserProfile(msg.args[0]);\n break;\n case \"storeUserProfiles\":\n prom = this.backend?.storeUserProfiles(msg.args[0]);\n break;\n case \"removeUserProfiles\":\n prom = this.backend?.removeUserProfiles(msg.args[0]);\n break;\n }\n\n if (prom === undefined) {\n this.postMessage({\n command: \"cmd_fail\",\n seq: msg.seq,\n // Can't be an Error because they're not structured cloneable\n error: \"Unrecognised command\",\n });\n return;\n }\n\n prom.then(\n (ret) => {\n this.postMessage.call(null, {\n command: \"cmd_success\",\n seq: msg.seq,\n result: ret,\n });\n },\n (err) => {\n logger.error(\"Error running command: \" + msg.command, err);\n this.postMessage.call(null, {\n command: \"cmd_fail\",\n seq: msg.seq,\n // Just send a string because Error objects aren't cloneable\n error: {\n message: err.message,\n name: err.name,\n },\n });\n },\n );\n };\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAS,0BAA0B,QAAQ,8BAA8B;AACzE,SAAS,MAAM,QAAQ,cAAc;AAQrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM,oBAAoB,CAAC;EAG9B;AACJ;AACA;AACA;EACW,WAAW,CAAkB,WAAuD,EAAE;IAAA;IAA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AAK,oBAAoB;UACrB,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;UACpD;MACR;MAEA,IAAI,IAAI,KAAK,SAAS,EAAE;QACpB,IAAI,CAAC,WAAW,CAAC;UACb,OAAO,EAAE,UAAU;UACnB,GAAG,EAAE,GAAG,CAAC,GAAG;UACZ;UACA,KAAK,EAAE;QACX,CAAC,CAAC;QACF;MACJ;MAEA,IAAI,CAAC,IAAI,CACJ,GAAG,IAAK;QACL,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE;UACxB,OAAO,EAAE,aAAa;UACtB,GAAG,EAAE,GAAG,CAAC,GAAG;UACZ,MAAM,EAAE;QACZ,CAAC,CAAC;MACN,CAAC,EACA,GAAG,IAAK;QACL,MAAM,CAAC,KAAK,CAAC,yBAAyB,GAAG,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC;QAC1D,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE;UACxB,OAAO,EAAE,UAAU;UACnB,GAAG,EAAE,GAAG,CAAC,GAAG;UACZ;UACA,KAAK,EAAE;YACH,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,IAAI,EAAE,GAAG,CAAC;UACd;QACJ,CAAC,CAAC;MACN,CACJ,CAAC;IACL,CAAC;IAAA,KAnHmC,WAAuD,GAAvD,WAAuD;EAAG;AAoHlG","ignoreList":[]}
|
package/lib/store/indexeddb.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
2
|
/*
|
|
5
3
|
Copyright 2017 - 2021 Vector Creations Ltd
|
|
@@ -34,7 +32,7 @@ import { TypedEventEmitter } from "../models/typed-event-emitter.js";
|
|
|
34
32
|
// so infrequently that the /sync size gets bigger on reload. Writing more
|
|
35
33
|
// often does not affect the length of the pause since the entire /sync
|
|
36
34
|
// response is persisted each time.
|
|
37
|
-
|
|
35
|
+
const WRITE_DELAY_MS = 1000 * 60 * 5; // once every 5 minutes
|
|
38
36
|
|
|
39
37
|
export class IndexedDBStore extends MemoryStore {
|
|
40
38
|
static exists(indexedDB, dbName) {
|
|
@@ -69,7 +67,6 @@ export class IndexedDBStore extends MemoryStore {
|
|
|
69
67
|
*/
|
|
70
68
|
constructor(opts) {
|
|
71
69
|
super(opts);
|
|
72
|
-
this.opts = opts;
|
|
73
70
|
_defineProperty(this, "_backend", void 0);
|
|
74
71
|
_defineProperty(this, "startedUp", false);
|
|
75
72
|
_defineProperty(this, "syncTs", 0);
|
|
@@ -110,7 +107,7 @@ export class IndexedDBStore extends MemoryStore {
|
|
|
110
107
|
return this.backend.clearDatabase().then(() => {
|
|
111
108
|
logger.log("Deleted indexeddb data.");
|
|
112
109
|
}, err => {
|
|
113
|
-
logger.error(
|
|
110
|
+
logger.error(`Failed to delete indexeddb data: ${err}`);
|
|
114
111
|
throw err;
|
|
115
112
|
});
|
|
116
113
|
}, null));
|
|
@@ -119,8 +116,8 @@ export class IndexedDBStore extends MemoryStore {
|
|
|
119
116
|
|
|
120
117
|
// work out changed users (this doesn't handle deletions but you
|
|
121
118
|
// can't 'delete' users as they are just presence events).
|
|
122
|
-
|
|
123
|
-
for (
|
|
119
|
+
const userTuples = [];
|
|
120
|
+
for (const u of this.getUsers()) {
|
|
124
121
|
if (this.userModifiedMap[u.userId] === u.getLastModifiedTime()) continue;
|
|
125
122
|
if (!u.events.presence) continue;
|
|
126
123
|
userTuples.push([u.userId, u.events.presence.event]);
|
|
@@ -164,6 +161,7 @@ export class IndexedDBStore extends MemoryStore {
|
|
|
164
161
|
super.storeClientOptions(options);
|
|
165
162
|
return this.backend.storeClientOptions(options);
|
|
166
163
|
}, "storeClientOptions"));
|
|
164
|
+
this.opts = opts;
|
|
167
165
|
if (!opts.indexedDB) {
|
|
168
166
|
throw new Error("Missing required option: indexedDB");
|
|
169
167
|
}
|
|
@@ -192,10 +190,10 @@ export class IndexedDBStore extends MemoryStore {
|
|
|
192
190
|
*/
|
|
193
191
|
startup() {
|
|
194
192
|
if (this.startedUp) {
|
|
195
|
-
logger.log(
|
|
193
|
+
logger.log(`IndexedDBStore.startup: already started`);
|
|
196
194
|
return Promise.resolve();
|
|
197
195
|
}
|
|
198
|
-
logger.log(
|
|
196
|
+
logger.log(`IndexedDBStore.startup: connecting to backend`);
|
|
199
197
|
return this.backend.connect(this.onClose).catch(e => {
|
|
200
198
|
if (this.opts.workerFactory) {
|
|
201
199
|
logger.log("Falling back to local indexeddb backend");
|
|
@@ -204,18 +202,15 @@ export class IndexedDBStore extends MemoryStore {
|
|
|
204
202
|
}
|
|
205
203
|
throw e;
|
|
206
204
|
}).then(() => {
|
|
207
|
-
logger.log(
|
|
205
|
+
logger.log(`IndexedDBStore.startup: loading presence events`);
|
|
208
206
|
return this.backend.getUserPresenceEvents();
|
|
209
207
|
}).then(userPresenceEvents => {
|
|
210
|
-
logger.log(
|
|
211
|
-
userPresenceEvents.forEach(
|
|
212
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
213
|
-
userId = _ref2[0],
|
|
214
|
-
rawEvent = _ref2[1];
|
|
208
|
+
logger.log(`IndexedDBStore.startup: processing presence events`);
|
|
209
|
+
userPresenceEvents.forEach(([userId, rawEvent]) => {
|
|
215
210
|
if (!this.createUser) {
|
|
216
211
|
throw new Error("`IndexedDBStore.startup` must be called after assigning it to the client, not before!");
|
|
217
212
|
}
|
|
218
|
-
|
|
213
|
+
const u = this.createUser(userId);
|
|
219
214
|
if (rawEvent) {
|
|
220
215
|
u.setPresenceEvent(new MatrixEvent(rawEvent));
|
|
221
216
|
}
|
|
@@ -242,7 +237,7 @@ export class IndexedDBStore extends MemoryStore {
|
|
|
242
237
|
* (at the time this function is called).
|
|
243
238
|
*/
|
|
244
239
|
wantsSave() {
|
|
245
|
-
|
|
240
|
+
const now = Date.now();
|
|
246
241
|
return now - this.syncTs > WRITE_DELAY_MS;
|
|
247
242
|
}
|
|
248
243
|
|
|
@@ -253,8 +248,7 @@ export class IndexedDBStore extends MemoryStore {
|
|
|
253
248
|
* @returns Promise resolves after the write completes
|
|
254
249
|
* (or immediately if no write is performed)
|
|
255
250
|
*/
|
|
256
|
-
save() {
|
|
257
|
-
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
251
|
+
save(force = false) {
|
|
258
252
|
if (force || this.wantsSave()) {
|
|
259
253
|
return this.reallySave();
|
|
260
254
|
}
|
|
@@ -273,24 +267,20 @@ export class IndexedDBStore extends MemoryStore {
|
|
|
273
267
|
* @returns A wrapped member function.
|
|
274
268
|
*/
|
|
275
269
|
degradable(func, fallback) {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
return /*#__PURE__*/_asyncToGenerator(function* () {
|
|
279
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
280
|
-
args[_key] = arguments[_key];
|
|
281
|
-
}
|
|
270
|
+
const fallbackFn = fallback ? super[fallback] : null;
|
|
271
|
+
return async (...args) => {
|
|
282
272
|
try {
|
|
283
|
-
return
|
|
273
|
+
return await func.call(this, ...args);
|
|
284
274
|
} catch (e) {
|
|
285
275
|
logger.error("IndexedDBStore failure, degrading to MemoryStore", e);
|
|
286
|
-
|
|
276
|
+
this.emitter.emit("degraded", e);
|
|
287
277
|
try {
|
|
288
278
|
// We try to delete IndexedDB after degrading since this store is only a
|
|
289
279
|
// cache (the app will still function correctly without the data).
|
|
290
280
|
// It's possible that deleting repair IndexedDB for the next app load,
|
|
291
281
|
// potentially by making a little more space available.
|
|
292
282
|
logger.log("IndexedDBStore trying to delete degraded data");
|
|
293
|
-
|
|
283
|
+
await this.backend.clearDatabase();
|
|
294
284
|
logger.log("IndexedDBStore delete after degrading succeeded");
|
|
295
285
|
} catch (e) {
|
|
296
286
|
logger.warn("IndexedDBStore delete after degrading failed", e);
|
|
@@ -303,41 +293,33 @@ export class IndexedDBStore extends MemoryStore {
|
|
|
303
293
|
// `IndexedDBStore` also maintain the state that `MemoryStore` uses (many are
|
|
304
294
|
// not overridden at all).
|
|
305
295
|
if (fallbackFn) {
|
|
306
|
-
return fallbackFn.call(
|
|
296
|
+
return fallbackFn.call(this, ...args);
|
|
307
297
|
}
|
|
308
298
|
}
|
|
309
|
-
}
|
|
299
|
+
};
|
|
310
300
|
}
|
|
311
301
|
|
|
312
302
|
// XXX: ideally these would be stored in indexeddb as part of the room but,
|
|
313
303
|
// we don't store rooms as such and instead accumulate entire sync responses atm.
|
|
314
|
-
getPendingEvents(roomId) {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
return JSON.parse(serialized);
|
|
323
|
-
} catch (e) {
|
|
324
|
-
logger.error("Could not parse persisted pending events", e);
|
|
325
|
-
}
|
|
304
|
+
async getPendingEvents(roomId) {
|
|
305
|
+
if (!this.localStorage) return super.getPendingEvents(roomId);
|
|
306
|
+
const serialized = this.localStorage.getItem(pendingEventsKey(roomId));
|
|
307
|
+
if (serialized) {
|
|
308
|
+
try {
|
|
309
|
+
return JSON.parse(serialized);
|
|
310
|
+
} catch (e) {
|
|
311
|
+
logger.error("Could not parse persisted pending events", e);
|
|
326
312
|
}
|
|
327
|
-
|
|
328
|
-
|
|
313
|
+
}
|
|
314
|
+
return [];
|
|
329
315
|
}
|
|
330
|
-
setPendingEvents(roomId, events) {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
} else {
|
|
338
|
-
_this3.localStorage.removeItem(pendingEventsKey(roomId));
|
|
339
|
-
}
|
|
340
|
-
})();
|
|
316
|
+
async setPendingEvents(roomId, events) {
|
|
317
|
+
if (!this.localStorage) return super.setPendingEvents(roomId, events);
|
|
318
|
+
if (events.length > 0) {
|
|
319
|
+
this.localStorage.setItem(pendingEventsKey(roomId), JSON.stringify(events));
|
|
320
|
+
} else {
|
|
321
|
+
this.localStorage.removeItem(pendingEventsKey(roomId));
|
|
322
|
+
}
|
|
341
323
|
}
|
|
342
324
|
saveToDeviceBatches(batches) {
|
|
343
325
|
return this.backend.saveToDeviceBatches(batches);
|
|
@@ -348,23 +330,14 @@ export class IndexedDBStore extends MemoryStore {
|
|
|
348
330
|
removeToDeviceBatch(id) {
|
|
349
331
|
return this.backend.removeToDeviceBatch(id);
|
|
350
332
|
}
|
|
351
|
-
getUserProfile(userId) {
|
|
352
|
-
|
|
353
|
-
return _asyncToGenerator(function* () {
|
|
354
|
-
return _this4.backend.getUserProfile(userId);
|
|
355
|
-
})();
|
|
333
|
+
async getUserProfile(userId) {
|
|
334
|
+
return this.backend.getUserProfile(userId);
|
|
356
335
|
}
|
|
357
|
-
storeUserProfiles(userProfiles) {
|
|
358
|
-
|
|
359
|
-
return _asyncToGenerator(function* () {
|
|
360
|
-
return _this5.backend.storeUserProfiles(userProfiles);
|
|
361
|
-
})();
|
|
336
|
+
async storeUserProfiles(userProfiles) {
|
|
337
|
+
return this.backend.storeUserProfiles(userProfiles);
|
|
362
338
|
}
|
|
363
|
-
removeUserProfiles(userIds) {
|
|
364
|
-
|
|
365
|
-
return _asyncToGenerator(function* () {
|
|
366
|
-
return _this6.backend.removeUserProfiles(userIds);
|
|
367
|
-
})();
|
|
339
|
+
async removeUserProfiles(userIds) {
|
|
340
|
+
return this.backend.removeUserProfiles(userIds);
|
|
368
341
|
}
|
|
369
342
|
}
|
|
370
343
|
|
|
@@ -373,6 +346,6 @@ export class IndexedDBStore extends MemoryStore {
|
|
|
373
346
|
* @returns Storage key to retrieve pending events
|
|
374
347
|
*/
|
|
375
348
|
function pendingEventsKey(roomId) {
|
|
376
|
-
return
|
|
349
|
+
return `mx_pending_events_${roomId}`;
|
|
377
350
|
}
|
|
378
351
|
//# sourceMappingURL=indexeddb.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexeddb.js","names":["MemoryStore","LocalIndexedDBStoreBackend","RemoteIndexedDBStoreBackend","MatrixEvent","logger","TypedEventEmitter","WRITE_DELAY_MS","IndexedDBStore","exists","indexedDB","dbName","constructor","opts","_defineProperty","emitter","emit","degradable","backend","getSavedSync","isNewlyCreated","getNextBatchToken","deleteAllData","clearDatabase","then","log","err","error","concat","syncTs","Date","now","userTuples","u","getUsers","userModifiedMap","userId","getLastModifiedTime","events","presence","push","event","syncToDatabase","syncData","setSyncData","roomId","getOutOfBandMembers","membershipEvents","setOutOfBandMembers","clearOutOfBandMembers","getClientOptions","options","storeClientOptions","Error","workerFactory","_backend","on","handler","startup","startedUp","Promise","resolve","connect","onClose","catch","e","getUserPresenceEvents","userPresenceEvents","forEach","_ref","_ref2","_slicedToArray","rawEvent","createUser","setPresenceEvent","storeUser","destroy","wantsSave","save","force","arguments","length","undefined","reallySave","func","fallback","_this","fallbackFn","_asyncToGenerator","_len","args","Array","_key","call","warn","getPendingEvents","_superprop_getGetPendingEvents","_this2","localStorage","serialized","getItem","pendingEventsKey","JSON","parse","setPendingEvents","_superprop_getSetPendingEvents","_this3","setItem","stringify","removeItem","saveToDeviceBatches","batches","getOldestToDeviceBatch","removeToDeviceBatch","id","getUserProfile","_this4","storeUserProfiles","userProfiles","_this5","removeUserProfiles","userIds","_this6"],"sources":["../../src/store/indexeddb.ts"],"sourcesContent":["/*\nCopyright 2017 - 2021 Vector Creations Ltd\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n/* eslint-disable @babel/no-invalid-this */\n\nimport { MemoryStore, type IOpts as IBaseOpts } from \"./memory.ts\";\nimport { LocalIndexedDBStoreBackend } from \"./indexeddb-local-backend.ts\";\nimport { RemoteIndexedDBStoreBackend } from \"./indexeddb-remote-backend.ts\";\nimport { type IEvent, MatrixEvent } from \"../models/event.ts\";\nimport { logger } from \"../logger.ts\";\nimport { type ISavedSync } from \"./index.ts\";\nimport { type IIndexedDBBackend } from \"./indexeddb-backend.ts\";\nimport { type ISyncResponse } from \"../sync-accumulator.ts\";\nimport { type EventEmitterEvents, TypedEventEmitter } from \"../models/typed-event-emitter.ts\";\nimport { type IStateEventWithRoomId } from \"../@types/search.ts\";\nimport { type IndexedToDeviceBatch, type ToDeviceBatchWithTxnId } from \"../models/ToDeviceMessage.ts\";\nimport { type IStoredClientOpts } from \"../client.ts\";\nimport { type SyncUserProfile } from \"../models/user.ts\";\n\n/**\n * This is an internal module. See {@link IndexedDBStore} for the public class.\n */\n\n// If this value is too small we'll be writing very often which will cause\n// noticeable stop-the-world pauses. If this value is too big we'll be writing\n// so infrequently that the /sync size gets bigger on reload. Writing more\n// often does not affect the length of the pause since the entire /sync\n// response is persisted each time.\nconst WRITE_DELAY_MS = 1000 * 60 * 5; // once every 5 minutes\n\ninterface IOpts extends IBaseOpts {\n /** The Indexed DB interface e.g. `window.indexedDB` */\n indexedDB?: IDBFactory;\n /** Optional database name. The same name must be used to open the same database. */\n dbName?: string;\n /** Optional factory to spin up a Worker to execute the IDB transactions within. */\n workerFactory?: () => Worker;\n}\n\ntype EventHandlerMap = {\n // Fired when an IDB command fails on a degradable path, and the store falls back to MemoryStore\n // This signals the potential for data volatility.\n degraded: (e: Error) => void;\n // Fired when the IndexedDB gets closed unexpectedly, for example, if the underlying storage is removed or\n // if the user clears the database in the browser's history preferences.\n closed: () => void;\n};\n\nexport class IndexedDBStore extends MemoryStore {\n public static exists(indexedDB: IDBFactory, dbName: string): Promise<boolean> {\n return LocalIndexedDBStoreBackend.exists(indexedDB, dbName);\n }\n\n public _backend: IIndexedDBBackend;\n\n private startedUp = false;\n private syncTs = 0;\n // Records the last-modified-time of each user at the last point we saved\n // the database, such that we can derive the set if users that have been\n // modified since we last saved.\n private userModifiedMap: Record<string, number> = {}; // user_id : timestamp\n private emitter = new TypedEventEmitter<keyof EventHandlerMap, EventHandlerMap>();\n\n /**\n * Construct a new Indexed Database store, which extends MemoryStore.\n *\n * This store functions like a MemoryStore except it periodically persists\n * the contents of the store to an IndexedDB backend.\n *\n * All data is still kept in-memory but can be loaded from disk by calling\n * `startup()`. This can make startup times quicker as a complete\n * sync from the server is not required. This does not reduce memory usage as all\n * the data is eagerly fetched when `startup()` is called.\n * ```\n * let opts = { indexedDB: window.indexedDB, localStorage: window.localStorage };\n * let store = new IndexedDBStore(opts);\n * let client = sdk.createClient({\n * store: store,\n * });\n * await store.startup(); // load from indexed db, must be called after createClient\n * client.startClient();\n * client.on(\"sync\", function(state, prevState, data) {\n * if (state === \"PREPARED\") {\n * console.log(\"Started up, now with go faster stripes!\");\n * }\n * });\n * ```\n *\n * @param opts - Options object.\n */\n public constructor(private readonly opts: IOpts) {\n super(opts);\n\n if (!opts.indexedDB) {\n throw new Error(\"Missing required option: indexedDB\");\n }\n\n if (opts.workerFactory) {\n this._backend = new RemoteIndexedDBStoreBackend(opts.workerFactory, opts.dbName);\n } else {\n this._backend = new LocalIndexedDBStoreBackend(opts.indexedDB, opts.dbName);\n }\n }\n\n /**\n * The backend instance.\n * Call through to this API if you need to perform specific indexeddb actions like deleting the database.\n */\n public get backend(): IIndexedDBBackend {\n return this._backend;\n }\n\n /** Re-exports `TypedEventEmitter.on` */\n public on(event: EventEmitterEvents | \"degraded\" | \"closed\", handler: (...args: any[]) => void): void {\n this.emitter.on(event, handler);\n }\n\n /**\n * @returns Resolved when loaded from indexed db.\n */\n public startup(): Promise<void> {\n if (this.startedUp) {\n logger.log(`IndexedDBStore.startup: already started`);\n return Promise.resolve();\n }\n\n logger.log(`IndexedDBStore.startup: connecting to backend`);\n return this.backend\n .connect(this.onClose)\n .catch((e) => {\n if (this.opts.workerFactory) {\n logger.log(\"Falling back to local indexeddb backend\");\n this._backend = new LocalIndexedDBStoreBackend(this.opts.indexedDB!, this.opts.dbName);\n return this.backend.connect(this.onClose);\n }\n throw e;\n })\n .then(() => {\n logger.log(`IndexedDBStore.startup: loading presence events`);\n return this.backend.getUserPresenceEvents();\n })\n .then((userPresenceEvents) => {\n logger.log(`IndexedDBStore.startup: processing presence events`);\n userPresenceEvents.forEach(([userId, rawEvent]) => {\n if (!this.createUser) {\n throw new Error(\n \"`IndexedDBStore.startup` must be called after assigning it to the client, not before!\",\n );\n }\n const u = this.createUser(userId);\n if (rawEvent) {\n u.setPresenceEvent(new MatrixEvent(rawEvent));\n }\n this.userModifiedMap[u.userId] = u.getLastModifiedTime();\n this.storeUser(u);\n });\n this.startedUp = true;\n });\n }\n\n /*\n * Close the database and destroy any associated workers\n */\n public destroy(): Promise<void> {\n return this.backend.destroy();\n }\n\n private onClose = (): void => {\n this.emitter.emit(\"closed\");\n };\n\n /**\n * @returns Promise which resolves with a sync response to restore the\n * client state to where it was at the last save, or null if there\n * is no saved sync data.\n */\n public getSavedSync = this.degradable((): Promise<ISavedSync | null> => {\n return this.backend.getSavedSync();\n }, \"getSavedSync\");\n\n /** @returns whether or not the database was newly created in this session. */\n public isNewlyCreated = this.degradable((): Promise<boolean> => {\n return this.backend.isNewlyCreated();\n }, \"isNewlyCreated\");\n\n /**\n * @returns If there is a saved sync, the nextBatch token\n * for this sync, otherwise null.\n */\n public getSavedSyncToken = this.degradable((): Promise<string | null> => {\n return this.backend.getNextBatchToken();\n }, \"getSavedSyncToken\");\n\n /**\n * Delete all data from this store.\n * @returns Promise which resolves if the data was deleted from the database.\n */\n public deleteAllData = this.degradable((): Promise<void> => {\n super.deleteAllData();\n return this.backend.clearDatabase().then(\n () => {\n logger.log(\"Deleted indexeddb data.\");\n },\n (err) => {\n logger.error(`Failed to delete indexeddb data: ${err}`);\n throw err;\n },\n );\n }, null);\n\n /**\n * Whether this store would like to save its data\n * Note that obviously whether the store wants to save or\n * not could change between calling this function and calling\n * save().\n *\n * @returns True if calling save() will actually save\n * (at the time this function is called).\n */\n public wantsSave(): boolean {\n const now = Date.now();\n return now - this.syncTs > WRITE_DELAY_MS;\n }\n\n /**\n * Possibly write data to the database.\n *\n * @param force - True to force a save to happen\n * @returns Promise resolves after the write completes\n * (or immediately if no write is performed)\n */\n public save(force = false): Promise<void> {\n if (force || this.wantsSave()) {\n return this.reallySave();\n }\n return Promise.resolve();\n }\n\n private reallySave = this.degradable((): Promise<void> => {\n this.syncTs = Date.now(); // set now to guard against multi-writes\n\n // work out changed users (this doesn't handle deletions but you\n // can't 'delete' users as they are just presence events).\n const userTuples: [userId: string, presenceEvent: Partial<IEvent>][] = [];\n for (const u of this.getUsers()) {\n if (this.userModifiedMap[u.userId] === u.getLastModifiedTime()) continue;\n if (!u.events.presence) continue;\n\n userTuples.push([u.userId, u.events.presence.event]);\n\n // note that we've saved this version of the user\n this.userModifiedMap[u.userId] = u.getLastModifiedTime();\n }\n\n return this.backend.syncToDatabase(userTuples);\n }, null);\n\n public setSyncData = this.degradable((syncData: ISyncResponse): Promise<void> => {\n return this.backend.setSyncData(syncData);\n }, \"setSyncData\");\n\n /**\n * Returns the out-of-band membership events for this room that\n * were previously loaded.\n * @returns the events, potentially an empty array if OOB loading didn't yield any new members\n * @returns in case the members for this room haven't been stored yet\n */\n public getOutOfBandMembers = this.degradable((roomId: string): Promise<IStateEventWithRoomId[] | null> => {\n return this.backend.getOutOfBandMembers(roomId);\n }, \"getOutOfBandMembers\");\n\n /**\n * Stores the out-of-band membership events for this room. Note that\n * it still makes sense to store an empty array as the OOB status for the room is\n * marked as fetched, and getOutOfBandMembers will return an empty array instead of null\n * @param membershipEvents - the membership events to store\n * @returns when all members have been stored\n */\n public setOutOfBandMembers = this.degradable(\n (roomId: string, membershipEvents: IStateEventWithRoomId[]): Promise<void> => {\n super.setOutOfBandMembers(roomId, membershipEvents);\n return this.backend.setOutOfBandMembers(roomId, membershipEvents);\n },\n \"setOutOfBandMembers\",\n );\n\n public clearOutOfBandMembers = this.degradable((roomId: string) => {\n super.clearOutOfBandMembers(roomId);\n return this.backend.clearOutOfBandMembers(roomId);\n }, \"clearOutOfBandMembers\");\n\n public getClientOptions = this.degradable((): Promise<IStoredClientOpts | undefined> => {\n return this.backend.getClientOptions();\n }, \"getClientOptions\");\n\n public storeClientOptions = this.degradable((options: IStoredClientOpts): Promise<void> => {\n super.storeClientOptions(options);\n return this.backend.storeClientOptions(options);\n }, \"storeClientOptions\");\n\n /**\n * All member functions of `IndexedDBStore` that access the backend use this wrapper to\n * watch for failures after initial store startup, including `QuotaExceededError` as\n * free disk space changes, etc.\n *\n * When IndexedDB fails via any of these paths, we degrade this back to a `MemoryStore`\n * in place so that the current operation and all future ones are in-memory only.\n *\n * @param func - The degradable work to do.\n * @param fallback - The method name for fallback.\n * @returns A wrapped member function.\n */\n private degradable<A extends Array<any>, F extends keyof MemoryStore | null, R = void>(\n func: DegradableFn<A, R>,\n fallback: F,\n ): DegradableFn<A, F extends string ? R : void> {\n const fallbackFn = fallback ? (super[fallback] as (...args: A) => Promise<R>) : null;\n\n return (async (...args) => {\n try {\n return await func.call(this, ...args);\n } catch (e) {\n logger.error(\"IndexedDBStore failure, degrading to MemoryStore\", e);\n this.emitter.emit(\"degraded\", e as Error);\n try {\n // We try to delete IndexedDB after degrading since this store is only a\n // cache (the app will still function correctly without the data).\n // It's possible that deleting repair IndexedDB for the next app load,\n // potentially by making a little more space available.\n logger.log(\"IndexedDBStore trying to delete degraded data\");\n await this.backend.clearDatabase();\n logger.log(\"IndexedDBStore delete after degrading succeeded\");\n } catch (e) {\n logger.warn(\"IndexedDBStore delete after degrading failed\", e);\n }\n // Degrade the store from being an instance of `IndexedDBStore` to instead be\n // an instance of `MemoryStore` so that future API calls use the memory path\n // directly and skip IndexedDB entirely. This should be safe as\n // `IndexedDBStore` already extends from `MemoryStore`, so we are making the\n // store become its parent type in a way. The mutator methods of\n // `IndexedDBStore` also maintain the state that `MemoryStore` uses (many are\n // not overridden at all).\n if (fallbackFn) {\n return fallbackFn.call(this, ...args);\n }\n }\n }) as DegradableFn<A, F extends string ? R : void>;\n }\n\n // XXX: ideally these would be stored in indexeddb as part of the room but,\n // we don't store rooms as such and instead accumulate entire sync responses atm.\n public async getPendingEvents(roomId: string): Promise<Partial<IEvent>[]> {\n if (!this.localStorage) return super.getPendingEvents(roomId);\n\n const serialized = this.localStorage.getItem(pendingEventsKey(roomId));\n if (serialized) {\n try {\n return JSON.parse(serialized);\n } catch (e) {\n logger.error(\"Could not parse persisted pending events\", e);\n }\n }\n return [];\n }\n\n public async setPendingEvents(roomId: string, events: Partial<IEvent>[]): Promise<void> {\n if (!this.localStorage) return super.setPendingEvents(roomId, events);\n\n if (events.length > 0) {\n this.localStorage.setItem(pendingEventsKey(roomId), JSON.stringify(events));\n } else {\n this.localStorage.removeItem(pendingEventsKey(roomId));\n }\n }\n\n public saveToDeviceBatches(batches: ToDeviceBatchWithTxnId[]): Promise<void> {\n return this.backend.saveToDeviceBatches(batches);\n }\n\n public getOldestToDeviceBatch(): Promise<IndexedToDeviceBatch | null> {\n return this.backend.getOldestToDeviceBatch();\n }\n\n public removeToDeviceBatch(id: number): Promise<void> {\n return this.backend.removeToDeviceBatch(id);\n }\n\n public async getUserProfile(userId: string): Promise<SyncUserProfile | undefined> {\n return this.backend.getUserProfile(userId);\n }\n\n public async storeUserProfiles(userProfiles: Map<string, SyncUserProfile>): Promise<void> {\n return this.backend.storeUserProfiles(userProfiles);\n }\n\n public async removeUserProfiles(userIds: string[]): Promise<void> {\n return this.backend.removeUserProfiles(userIds);\n }\n}\n\n/**\n * @param roomId - ID of the current room\n * @returns Storage key to retrieve pending events\n */\nfunction pendingEventsKey(roomId: string): string {\n return `mx_pending_events_${roomId}`;\n}\n\ntype DegradableFn<A extends Array<any>, T> = (...args: A) => Promise<T>;\n"],"mappings":";;;AAAA;AACA;AACA;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indexeddb.ts"],"sourcesContent":["/*\nCopyright 2017 - 2021 Vector Creations Ltd\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n/* eslint-disable @babel/no-invalid-this */\n\nimport { MemoryStore, type IOpts as IBaseOpts } from \"./memory.ts\";\nimport { LocalIndexedDBStoreBackend } from \"./indexeddb-local-backend.ts\";\nimport { RemoteIndexedDBStoreBackend } from \"./indexeddb-remote-backend.ts\";\nimport { type IEvent, MatrixEvent } from \"../models/event.ts\";\nimport { logger } from \"../logger.ts\";\nimport { type ISavedSync } from \"./index.ts\";\nimport { type IIndexedDBBackend } from \"./indexeddb-backend.ts\";\nimport { type ISyncResponse } from \"../sync-accumulator.ts\";\nimport { type EventEmitterEvents, TypedEventEmitter } from \"../models/typed-event-emitter.ts\";\nimport { type IStateEventWithRoomId } from \"../@types/search.ts\";\nimport { type IndexedToDeviceBatch, type ToDeviceBatchWithTxnId } from \"../models/ToDeviceMessage.ts\";\nimport { type IStoredClientOpts } from \"../client.ts\";\nimport { type SyncUserProfile } from \"../models/user.ts\";\n\n/**\n * This is an internal module. See {@link IndexedDBStore} for the public class.\n */\n\n// If this value is too small we'll be writing very often which will cause\n// noticeable stop-the-world pauses. If this value is too big we'll be writing\n// so infrequently that the /sync size gets bigger on reload. Writing more\n// often does not affect the length of the pause since the entire /sync\n// response is persisted each time.\nconst WRITE_DELAY_MS = 1000 * 60 * 5; // once every 5 minutes\n\ninterface IOpts extends IBaseOpts {\n /** The Indexed DB interface e.g. `window.indexedDB` */\n indexedDB?: IDBFactory;\n /** Optional database name. The same name must be used to open the same database. */\n dbName?: string;\n /** Optional factory to spin up a Worker to execute the IDB transactions within. */\n workerFactory?: () => Worker;\n}\n\ntype EventHandlerMap = {\n // Fired when an IDB command fails on a degradable path, and the store falls back to MemoryStore\n // This signals the potential for data volatility.\n degraded: (e: Error) => void;\n // Fired when the IndexedDB gets closed unexpectedly, for example, if the underlying storage is removed or\n // if the user clears the database in the browser's history preferences.\n closed: () => void;\n};\n\nexport class IndexedDBStore extends MemoryStore {\n public static exists(indexedDB: IDBFactory, dbName: string): Promise<boolean> {\n return LocalIndexedDBStoreBackend.exists(indexedDB, dbName);\n }\n\n public _backend: IIndexedDBBackend;\n\n private startedUp = false;\n private syncTs = 0;\n // Records the last-modified-time of each user at the last point we saved\n // the database, such that we can derive the set if users that have been\n // modified since we last saved.\n private userModifiedMap: Record<string, number> = {}; // user_id : timestamp\n private emitter = new TypedEventEmitter<keyof EventHandlerMap, EventHandlerMap>();\n\n /**\n * Construct a new Indexed Database store, which extends MemoryStore.\n *\n * This store functions like a MemoryStore except it periodically persists\n * the contents of the store to an IndexedDB backend.\n *\n * All data is still kept in-memory but can be loaded from disk by calling\n * `startup()`. This can make startup times quicker as a complete\n * sync from the server is not required. This does not reduce memory usage as all\n * the data is eagerly fetched when `startup()` is called.\n * ```\n * let opts = { indexedDB: window.indexedDB, localStorage: window.localStorage };\n * let store = new IndexedDBStore(opts);\n * let client = sdk.createClient({\n * store: store,\n * });\n * await store.startup(); // load from indexed db, must be called after createClient\n * client.startClient();\n * client.on(\"sync\", function(state, prevState, data) {\n * if (state === \"PREPARED\") {\n * console.log(\"Started up, now with go faster stripes!\");\n * }\n * });\n * ```\n *\n * @param opts - Options object.\n */\n public constructor(private readonly opts: IOpts) {\n super(opts);\n\n if (!opts.indexedDB) {\n throw new Error(\"Missing required option: indexedDB\");\n }\n\n if (opts.workerFactory) {\n this._backend = new RemoteIndexedDBStoreBackend(opts.workerFactory, opts.dbName);\n } else {\n this._backend = new LocalIndexedDBStoreBackend(opts.indexedDB, opts.dbName);\n }\n }\n\n /**\n * The backend instance.\n * Call through to this API if you need to perform specific indexeddb actions like deleting the database.\n */\n public get backend(): IIndexedDBBackend {\n return this._backend;\n }\n\n /** Re-exports `TypedEventEmitter.on` */\n public on(event: EventEmitterEvents | \"degraded\" | \"closed\", handler: (...args: any[]) => void): void {\n this.emitter.on(event, handler);\n }\n\n /**\n * @returns Resolved when loaded from indexed db.\n */\n public startup(): Promise<void> {\n if (this.startedUp) {\n logger.log(`IndexedDBStore.startup: already started`);\n return Promise.resolve();\n }\n\n logger.log(`IndexedDBStore.startup: connecting to backend`);\n return this.backend\n .connect(this.onClose)\n .catch((e) => {\n if (this.opts.workerFactory) {\n logger.log(\"Falling back to local indexeddb backend\");\n this._backend = new LocalIndexedDBStoreBackend(this.opts.indexedDB!, this.opts.dbName);\n return this.backend.connect(this.onClose);\n }\n throw e;\n })\n .then(() => {\n logger.log(`IndexedDBStore.startup: loading presence events`);\n return this.backend.getUserPresenceEvents();\n })\n .then((userPresenceEvents) => {\n logger.log(`IndexedDBStore.startup: processing presence events`);\n userPresenceEvents.forEach(([userId, rawEvent]) => {\n if (!this.createUser) {\n throw new Error(\n \"`IndexedDBStore.startup` must be called after assigning it to the client, not before!\",\n );\n }\n const u = this.createUser(userId);\n if (rawEvent) {\n u.setPresenceEvent(new MatrixEvent(rawEvent));\n }\n this.userModifiedMap[u.userId] = u.getLastModifiedTime();\n this.storeUser(u);\n });\n this.startedUp = true;\n });\n }\n\n /*\n * Close the database and destroy any associated workers\n */\n public destroy(): Promise<void> {\n return this.backend.destroy();\n }\n\n private onClose = (): void => {\n this.emitter.emit(\"closed\");\n };\n\n /**\n * @returns Promise which resolves with a sync response to restore the\n * client state to where it was at the last save, or null if there\n * is no saved sync data.\n */\n public getSavedSync = this.degradable((): Promise<ISavedSync | null> => {\n return this.backend.getSavedSync();\n }, \"getSavedSync\");\n\n /** @returns whether or not the database was newly created in this session. */\n public isNewlyCreated = this.degradable((): Promise<boolean> => {\n return this.backend.isNewlyCreated();\n }, \"isNewlyCreated\");\n\n /**\n * @returns If there is a saved sync, the nextBatch token\n * for this sync, otherwise null.\n */\n public getSavedSyncToken = this.degradable((): Promise<string | null> => {\n return this.backend.getNextBatchToken();\n }, \"getSavedSyncToken\");\n\n /**\n * Delete all data from this store.\n * @returns Promise which resolves if the data was deleted from the database.\n */\n public deleteAllData = this.degradable((): Promise<void> => {\n super.deleteAllData();\n return this.backend.clearDatabase().then(\n () => {\n logger.log(\"Deleted indexeddb data.\");\n },\n (err) => {\n logger.error(`Failed to delete indexeddb data: ${err}`);\n throw err;\n },\n );\n }, null);\n\n /**\n * Whether this store would like to save its data\n * Note that obviously whether the store wants to save or\n * not could change between calling this function and calling\n * save().\n *\n * @returns True if calling save() will actually save\n * (at the time this function is called).\n */\n public wantsSave(): boolean {\n const now = Date.now();\n return now - this.syncTs > WRITE_DELAY_MS;\n }\n\n /**\n * Possibly write data to the database.\n *\n * @param force - True to force a save to happen\n * @returns Promise resolves after the write completes\n * (or immediately if no write is performed)\n */\n public save(force = false): Promise<void> {\n if (force || this.wantsSave()) {\n return this.reallySave();\n }\n return Promise.resolve();\n }\n\n private reallySave = this.degradable((): Promise<void> => {\n this.syncTs = Date.now(); // set now to guard against multi-writes\n\n // work out changed users (this doesn't handle deletions but you\n // can't 'delete' users as they are just presence events).\n const userTuples: [userId: string, presenceEvent: Partial<IEvent>][] = [];\n for (const u of this.getUsers()) {\n if (this.userModifiedMap[u.userId] === u.getLastModifiedTime()) continue;\n if (!u.events.presence) continue;\n\n userTuples.push([u.userId, u.events.presence.event]);\n\n // note that we've saved this version of the user\n this.userModifiedMap[u.userId] = u.getLastModifiedTime();\n }\n\n return this.backend.syncToDatabase(userTuples);\n }, null);\n\n public setSyncData = this.degradable((syncData: ISyncResponse): Promise<void> => {\n return this.backend.setSyncData(syncData);\n }, \"setSyncData\");\n\n /**\n * Returns the out-of-band membership events for this room that\n * were previously loaded.\n * @returns the events, potentially an empty array if OOB loading didn't yield any new members\n * @returns in case the members for this room haven't been stored yet\n */\n public getOutOfBandMembers = this.degradable((roomId: string): Promise<IStateEventWithRoomId[] | null> => {\n return this.backend.getOutOfBandMembers(roomId);\n }, \"getOutOfBandMembers\");\n\n /**\n * Stores the out-of-band membership events for this room. Note that\n * it still makes sense to store an empty array as the OOB status for the room is\n * marked as fetched, and getOutOfBandMembers will return an empty array instead of null\n * @param membershipEvents - the membership events to store\n * @returns when all members have been stored\n */\n public setOutOfBandMembers = this.degradable(\n (roomId: string, membershipEvents: IStateEventWithRoomId[]): Promise<void> => {\n super.setOutOfBandMembers(roomId, membershipEvents);\n return this.backend.setOutOfBandMembers(roomId, membershipEvents);\n },\n \"setOutOfBandMembers\",\n );\n\n public clearOutOfBandMembers = this.degradable((roomId: string) => {\n super.clearOutOfBandMembers(roomId);\n return this.backend.clearOutOfBandMembers(roomId);\n }, \"clearOutOfBandMembers\");\n\n public getClientOptions = this.degradable((): Promise<IStoredClientOpts | undefined> => {\n return this.backend.getClientOptions();\n }, \"getClientOptions\");\n\n public storeClientOptions = this.degradable((options: IStoredClientOpts): Promise<void> => {\n super.storeClientOptions(options);\n return this.backend.storeClientOptions(options);\n }, \"storeClientOptions\");\n\n /**\n * All member functions of `IndexedDBStore` that access the backend use this wrapper to\n * watch for failures after initial store startup, including `QuotaExceededError` as\n * free disk space changes, etc.\n *\n * When IndexedDB fails via any of these paths, we degrade this back to a `MemoryStore`\n * in place so that the current operation and all future ones are in-memory only.\n *\n * @param func - The degradable work to do.\n * @param fallback - The method name for fallback.\n * @returns A wrapped member function.\n */\n private degradable<A extends Array<any>, F extends keyof MemoryStore | null, R = void>(\n func: DegradableFn<A, R>,\n fallback: F,\n ): DegradableFn<A, F extends string ? R : void> {\n const fallbackFn = fallback ? (super[fallback] as (...args: A) => Promise<R>) : null;\n\n return (async (...args) => {\n try {\n return await func.call(this, ...args);\n } catch (e) {\n logger.error(\"IndexedDBStore failure, degrading to MemoryStore\", e);\n this.emitter.emit(\"degraded\", e as Error);\n try {\n // We try to delete IndexedDB after degrading since this store is only a\n // cache (the app will still function correctly without the data).\n // It's possible that deleting repair IndexedDB for the next app load,\n // potentially by making a little more space available.\n logger.log(\"IndexedDBStore trying to delete degraded data\");\n await this.backend.clearDatabase();\n logger.log(\"IndexedDBStore delete after degrading succeeded\");\n } catch (e) {\n logger.warn(\"IndexedDBStore delete after degrading failed\", e);\n }\n // Degrade the store from being an instance of `IndexedDBStore` to instead be\n // an instance of `MemoryStore` so that future API calls use the memory path\n // directly and skip IndexedDB entirely. This should be safe as\n // `IndexedDBStore` already extends from `MemoryStore`, so we are making the\n // store become its parent type in a way. The mutator methods of\n // `IndexedDBStore` also maintain the state that `MemoryStore` uses (many are\n // not overridden at all).\n if (fallbackFn) {\n return fallbackFn.call(this, ...args);\n }\n }\n }) as DegradableFn<A, F extends string ? R : void>;\n }\n\n // XXX: ideally these would be stored in indexeddb as part of the room but,\n // we don't store rooms as such and instead accumulate entire sync responses atm.\n public async getPendingEvents(roomId: string): Promise<Partial<IEvent>[]> {\n if (!this.localStorage) return super.getPendingEvents(roomId);\n\n const serialized = this.localStorage.getItem(pendingEventsKey(roomId));\n if (serialized) {\n try {\n return JSON.parse(serialized);\n } catch (e) {\n logger.error(\"Could not parse persisted pending events\", e);\n }\n }\n return [];\n }\n\n public async setPendingEvents(roomId: string, events: Partial<IEvent>[]): Promise<void> {\n if (!this.localStorage) return super.setPendingEvents(roomId, events);\n\n if (events.length > 0) {\n this.localStorage.setItem(pendingEventsKey(roomId), JSON.stringify(events));\n } else {\n this.localStorage.removeItem(pendingEventsKey(roomId));\n }\n }\n\n public saveToDeviceBatches(batches: ToDeviceBatchWithTxnId[]): Promise<void> {\n return this.backend.saveToDeviceBatches(batches);\n }\n\n public getOldestToDeviceBatch(): Promise<IndexedToDeviceBatch | null> {\n return this.backend.getOldestToDeviceBatch();\n }\n\n public removeToDeviceBatch(id: number): Promise<void> {\n return this.backend.removeToDeviceBatch(id);\n }\n\n public async getUserProfile(userId: string): Promise<SyncUserProfile | undefined> {\n return this.backend.getUserProfile(userId);\n }\n\n public async storeUserProfiles(userProfiles: Map<string, SyncUserProfile>): Promise<void> {\n return this.backend.storeUserProfiles(userProfiles);\n }\n\n public async removeUserProfiles(userIds: string[]): Promise<void> {\n return this.backend.removeUserProfiles(userIds);\n }\n}\n\n/**\n * @param roomId - ID of the current room\n * @returns Storage key to retrieve pending events\n */\nfunction pendingEventsKey(roomId: string): string {\n return `mx_pending_events_${roomId}`;\n}\n\ntype DegradableFn<A extends Array<any>, T> = (...args: A) => Promise<T>;\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,SAAS,WAAW,QAAiC,aAAa;AAClE,SAAS,0BAA0B,QAAQ,8BAA8B;AACzE,SAAS,2BAA2B,QAAQ,+BAA+B;AAC3E,SAAsB,WAAW,QAAQ,oBAAoB;AAC7D,SAAS,MAAM,QAAQ,cAAc;AAIrC,SAAkC,iBAAiB,QAAQ,kCAAkC;AAM7F;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAM,cAAc,GAAG,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;;AAoBtC,OAAO,MAAM,cAAc,SAAS,WAAW,CAAC;EAC5C,OAAc,MAAM,CAAC,SAAqB,EAAE,MAAc,EAAoB;IAC1E,OAAO,0BAA0B,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC;EAC/D;EAYA;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACW,WAAW,CAAkB,IAAW,EAAE;IAC7C,KAAK,CAAC,IAAI,CAAC;IAAC;IAAA,mCApCI,KAAK;IAAA,gCACR,CAAC;IAClB;IACA;IACA;IAAA,yCACkD,CAAC,CAAC;IAAE;IAAA,iCACpC,IAAI,iBAAiB,CAAyC,CAAC;IAAA,iCA0G/D,MAAY;M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,YAA0C,EAAiB;IACtF,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,YAAY,CAAC;EACvD;EAEA,MAAa,kBAAkB,CAAC,OAAiB,EAAiB;IAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC;EACnD;AACJ;;AAEA;AACA;AACA;AACA;AACA,SAAS,gBAAgB,CAAC,MAAc,EAAU;EAC9C,OAAO,qBAAqB,MAAM,EAAE;AACxC","ignoreList":[]}
|
|
@@ -15,7 +15,7 @@ limitations under the License.
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { TypedEventEmitter } from "../models/typed-event-emitter.js";
|
|
18
|
-
export
|
|
18
|
+
export let LocalStorageErrors = /*#__PURE__*/function (LocalStorageErrors) {
|
|
19
19
|
LocalStorageErrors["Global"] = "Global";
|
|
20
20
|
LocalStorageErrors["SetItemError"] = "setItem";
|
|
21
21
|
LocalStorageErrors["GetItemError"] = "getItem";
|
|
@@ -33,5 +33,5 @@ export var LocalStorageErrors = /*#__PURE__*/function (LocalStorageErrors) {
|
|
|
33
33
|
* See: https://github.com/vector-im/element-web/issues/18423
|
|
34
34
|
*/
|
|
35
35
|
class LocalStorageErrorsEventsEmitter extends TypedEventEmitter {}
|
|
36
|
-
export
|
|
36
|
+
export const localStorageErrorsEventsEmitter = new LocalStorageErrorsEventsEmitter();
|
|
37
37
|
//# sourceMappingURL=local-storage-events-emitter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-storage-events-emitter.js","names":[
|
|
1
|
+
{"version":3,"file":"local-storage-events-emitter.js","names":[],"sources":["../../src/store/local-storage-events-emitter.ts"],"sourcesContent":["/*\nCopyright 2021 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { TypedEventEmitter } from \"../models/typed-event-emitter.ts\";\n\nexport enum LocalStorageErrors {\n Global = \"Global\",\n SetItemError = \"setItem\",\n GetItemError = \"getItem\",\n RemoveItemError = \"removeItem\",\n ClearError = \"clear\",\n QuotaExceededError = \"QuotaExceededError\",\n}\n\ntype EventHandlerMap = {\n [LocalStorageErrors.Global]: (error: Error) => void;\n [LocalStorageErrors.SetItemError]: (error: Error) => void;\n [LocalStorageErrors.GetItemError]: (error: Error) => void;\n [LocalStorageErrors.RemoveItemError]: (error: Error) => void;\n [LocalStorageErrors.ClearError]: (error: Error) => void;\n [LocalStorageErrors.QuotaExceededError]: (error: Error) => void;\n};\n\n/**\n * Used in element-web as a temporary hack to handle all the localStorage errors on the highest level possible\n * As of 15.11.2021 (DD/MM/YYYY) we're not properly handling local storage exceptions anywhere.\n * This store, as an event emitter, is used to re-emit local storage exceptions so that we can handle them\n * and show some kind of a \"It's dead Jim\" modal to the users, telling them that hey,\n * maybe you should check out your disk, as it's probably dying and your session may die with it.\n * See: https://github.com/vector-im/element-web/issues/18423\n */\nclass LocalStorageErrorsEventsEmitter extends TypedEventEmitter<LocalStorageErrors, EventHandlerMap> {}\nexport const localStorageErrorsEventsEmitter = new LocalStorageErrorsEventsEmitter();\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAS,iBAAiB,QAAQ,kCAAkC;AAEpE,WAAY,kBAAkB,0BAAlB,kBAAkB;EAAlB,kBAAkB;EAAlB,kBAAkB;EAAlB,kBAAkB;EAAlB,kBAAkB;EAAlB,kBAAkB;EAAlB,kBAAkB;EAAA,OAAlB,kBAAkB;AAAA;AAkB9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,+BAA+B,SAAS,iBAAiB,CAAsC;AACrG,OAAO,MAAM,+BAA+B,GAAG,IAAI,+BAA+B,CAAC,CAAC","ignoreList":[]}
|