@unwanted/matrix-sdk-mini 34.12.0 → 36.0.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/git-revision.txt +1 -1
- package/lib/@types/event.d.ts +25 -19
- package/lib/@types/event.d.ts.map +1 -1
- package/lib/@types/event.js +5 -0
- package/lib/@types/event.js.map +1 -1
- package/lib/@types/global.d.js +0 -2
- package/lib/@types/global.d.js.map +1 -1
- package/lib/autodiscovery.d.ts +1 -1
- package/lib/autodiscovery.d.ts.map +1 -1
- package/lib/autodiscovery.js.map +1 -1
- package/lib/base64.d.ts +3 -6
- package/lib/base64.d.ts.map +1 -1
- package/lib/base64.js +43 -36
- package/lib/base64.js.map +1 -1
- package/lib/browser-index.d.ts.map +1 -1
- package/lib/browser-index.js +0 -11
- package/lib/browser-index.js.map +1 -1
- package/lib/client.d.ts +45 -1306
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +406 -2963
- package/lib/client.js.map +1 -1
- package/lib/digest.d.ts +2 -2
- package/lib/digest.d.ts.map +1 -1
- package/lib/digest.js +2 -2
- package/lib/digest.js.map +1 -1
- package/lib/embedded.d.ts +2 -23
- package/lib/embedded.d.ts.map +1 -1
- package/lib/embedded.js +82 -209
- package/lib/embedded.js.map +1 -1
- package/lib/event-mapper.d.ts.map +1 -1
- package/lib/event-mapper.js +0 -4
- package/lib/event-mapper.js.map +1 -1
- package/lib/feature.d.ts.map +1 -1
- package/lib/feature.js +2 -1
- package/lib/feature.js.map +1 -1
- package/lib/http-api/errors.d.ts +3 -3
- package/lib/http-api/errors.js +3 -3
- package/lib/http-api/errors.js.map +1 -1
- package/lib/http-api/utils.js +2 -2
- package/lib/http-api/utils.js.map +1 -1
- package/lib/matrix.d.ts +0 -25
- package/lib/matrix.d.ts.map +1 -1
- package/lib/matrix.js +1 -30
- package/lib/matrix.js.map +1 -1
- package/lib/models/MSC3089Branch.d.ts.map +1 -1
- package/lib/models/MSC3089Branch.js +0 -3
- package/lib/models/MSC3089Branch.js.map +1 -1
- package/lib/models/event-timeline-set.d.ts +6 -10
- package/lib/models/event-timeline-set.d.ts.map +1 -1
- package/lib/models/event-timeline-set.js +28 -36
- package/lib/models/event-timeline-set.js.map +1 -1
- package/lib/models/event-timeline.d.ts +7 -2
- package/lib/models/event-timeline.d.ts.map +1 -1
- package/lib/models/event-timeline.js +9 -30
- package/lib/models/event-timeline.js.map +1 -1
- package/lib/models/event.d.ts +12 -96
- package/lib/models/event.d.ts.map +1 -1
- package/lib/models/event.js +59 -286
- package/lib/models/event.js.map +1 -1
- package/lib/models/invites-ignorer-types.d.ts +27 -0
- package/lib/models/invites-ignorer-types.d.ts.map +1 -0
- package/lib/models/invites-ignorer-types.js +36 -0
- package/lib/models/invites-ignorer-types.js.map +1 -0
- package/lib/models/invites-ignorer.d.ts +2 -26
- package/lib/models/invites-ignorer.d.ts.map +1 -1
- package/lib/models/invites-ignorer.js +2 -27
- package/lib/models/invites-ignorer.js.map +1 -1
- package/lib/models/poll.d.ts.map +1 -1
- package/lib/models/poll.js +1 -5
- package/lib/models/poll.js.map +1 -1
- package/lib/models/relations-container.d.ts.map +1 -1
- package/lib/models/relations-container.js +1 -7
- package/lib/models/relations-container.js.map +1 -1
- package/lib/models/relations.d.ts +0 -1
- package/lib/models/relations.d.ts.map +1 -1
- package/lib/models/relations.js +0 -8
- package/lib/models/relations.js.map +1 -1
- package/lib/models/room-member.d.ts +6 -1
- package/lib/models/room-member.d.ts.map +1 -1
- package/lib/models/room-member.js +7 -1
- package/lib/models/room-member.js.map +1 -1
- package/lib/models/room-state.d.ts +2 -13
- package/lib/models/room-state.d.ts.map +1 -1
- package/lib/models/room-state.js +12 -56
- package/lib/models/room-state.js.map +1 -1
- package/lib/models/room.d.ts +8 -21
- package/lib/models/room.d.ts.map +1 -1
- package/lib/models/room.js +128 -163
- package/lib/models/room.js.map +1 -1
- package/lib/models/thread.d.ts.map +1 -1
- package/lib/models/thread.js +5 -4
- package/lib/models/thread.js.map +1 -1
- package/lib/oidc/authorize.d.ts +2 -2
- package/lib/oidc/authorize.d.ts.map +1 -1
- package/lib/oidc/authorize.js +5 -5
- package/lib/oidc/authorize.js.map +1 -1
- package/lib/oidc/discovery.d.ts +8 -0
- package/lib/oidc/discovery.d.ts.map +1 -1
- package/lib/oidc/discovery.js +22 -11
- package/lib/oidc/discovery.js.map +1 -1
- package/lib/oidc/index.d.ts +3 -4
- package/lib/oidc/index.d.ts.map +1 -1
- package/lib/oidc/index.js.map +1 -1
- package/lib/oidc/register.js +3 -3
- package/lib/oidc/register.js.map +1 -1
- package/lib/oidc/tokenRefresher.d.ts.map +1 -1
- package/lib/oidc/tokenRefresher.js +6 -5
- package/lib/oidc/tokenRefresher.js.map +1 -1
- package/lib/oidc/validate.d.ts +9 -23
- package/lib/oidc/validate.d.ts.map +1 -1
- package/lib/oidc/validate.js +13 -28
- package/lib/oidc/validate.js.map +1 -1
- package/lib/randomstring.d.ts +30 -3
- package/lib/randomstring.d.ts.map +1 -1
- package/lib/randomstring.js +68 -16
- package/lib/randomstring.js.map +1 -1
- package/lib/sliding-sync-sdk.d.ts +3 -4
- package/lib/sliding-sync-sdk.d.ts.map +1 -1
- package/lib/sliding-sync-sdk.js +55 -102
- package/lib/sliding-sync-sdk.js.map +1 -1
- package/lib/sliding-sync.js +9 -6
- package/lib/sliding-sync.js.map +1 -1
- package/lib/store/indexeddb-local-backend.js +4 -2
- package/lib/store/indexeddb-local-backend.js.map +1 -1
- package/lib/store/indexeddb.d.ts +1 -1
- package/lib/store/indexeddb.d.ts.map +1 -1
- package/lib/store/indexeddb.js.map +1 -1
- package/lib/sync-accumulator.d.ts +6 -4
- package/lib/sync-accumulator.d.ts.map +1 -1
- package/lib/sync-accumulator.js +23 -12
- package/lib/sync-accumulator.js.map +1 -1
- package/lib/sync.d.ts +10 -13
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +94 -115
- package/lib/sync.js.map +1 -1
- package/lib/testing.d.ts +13 -44
- package/lib/testing.d.ts.map +1 -1
- package/lib/testing.js +36 -99
- package/lib/testing.js.map +1 -1
- package/lib/types.d.ts +0 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +14 -15
- package/src/@types/event.ts +19 -36
- package/src/@types/global.d.ts +21 -4
- package/src/autodiscovery.ts +1 -1
- package/src/base64.ts +38 -40
- package/src/browser-index.ts +0 -11
- package/src/client.ts +175 -3136
- package/src/digest.ts +3 -3
- package/src/embedded.ts +43 -149
- package/src/event-mapper.ts +0 -4
- package/src/feature.ts +1 -0
- package/src/http-api/errors.ts +3 -3
- package/src/http-api/utils.ts +2 -2
- package/src/matrix.ts +0 -41
- package/src/models/MSC3089Branch.ts +0 -3
- package/src/models/event-timeline-set.ts +17 -38
- package/src/models/event-timeline.ts +11 -26
- package/src/models/event.ts +54 -295
- package/src/models/invites-ignorer-types.ts +48 -0
- package/src/models/invites-ignorer.ts +7 -42
- package/src/models/poll.ts +0 -6
- package/src/models/relations-container.ts +1 -8
- package/src/models/relations.ts +0 -8
- package/src/models/room-member.ts +16 -1
- package/src/models/room-state.ts +4 -37
- package/src/models/room.ts +34 -69
- package/src/models/thread.ts +4 -3
- package/src/oidc/authorize.ts +7 -7
- package/src/oidc/discovery.ts +16 -10
- package/src/oidc/index.ts +3 -4
- package/src/oidc/register.ts +3 -3
- package/src/oidc/tokenRefresher.ts +3 -2
- package/src/oidc/validate.ts +40 -63
- package/src/randomstring.ts +65 -19
- package/src/sliding-sync-sdk.ts +10 -83
- package/src/sliding-sync.ts +6 -6
- package/src/store/indexeddb-local-backend.ts +2 -2
- package/src/store/indexeddb.ts +1 -1
- package/src/sync-accumulator.ts +33 -16
- package/src/sync.ts +112 -143
- package/src/testing.ts +36 -103
- package/src/types.ts +0 -1
- package/CHANGELOG.md +0 -5910
- package/lib/@types/AESEncryptedSecretStoragePayload.d.ts +0 -14
- package/lib/@types/AESEncryptedSecretStoragePayload.d.ts.map +0 -1
- package/lib/@types/AESEncryptedSecretStoragePayload.js +0 -1
- package/lib/@types/AESEncryptedSecretStoragePayload.js.map +0 -1
- package/lib/@types/crypto.d.ts +0 -47
- package/lib/@types/crypto.d.ts.map +0 -1
- package/lib/@types/crypto.js +0 -1
- package/lib/@types/crypto.js.map +0 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js +0 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js.map +0 -1
- package/lib/common-crypto/CryptoBackend.d.ts +0 -240
- package/lib/common-crypto/CryptoBackend.d.ts.map +0 -1
- package/lib/common-crypto/CryptoBackend.js +0 -73
- package/lib/common-crypto/CryptoBackend.js.map +0 -1
- package/lib/common-crypto/key-passphrase.d.ts +0 -14
- package/lib/common-crypto/key-passphrase.d.ts.map +0 -1
- package/lib/common-crypto/key-passphrase.js +0 -33
- package/lib/common-crypto/key-passphrase.js.map +0 -1
- package/lib/crypto/CrossSigning.d.ts +0 -184
- package/lib/crypto/CrossSigning.d.ts.map +0 -1
- package/lib/crypto/CrossSigning.js +0 -718
- package/lib/crypto/CrossSigning.js.map +0 -1
- package/lib/crypto/DeviceList.d.ts +0 -216
- package/lib/crypto/DeviceList.d.ts.map +0 -1
- package/lib/crypto/DeviceList.js +0 -892
- package/lib/crypto/DeviceList.js.map +0 -1
- package/lib/crypto/EncryptionSetup.d.ts +0 -152
- package/lib/crypto/EncryptionSetup.d.ts.map +0 -1
- package/lib/crypto/EncryptionSetup.js +0 -356
- package/lib/crypto/EncryptionSetup.js.map +0 -1
- package/lib/crypto/OlmDevice.d.ts +0 -457
- package/lib/crypto/OlmDevice.d.ts.map +0 -1
- package/lib/crypto/OlmDevice.js +0 -1241
- package/lib/crypto/OlmDevice.js.map +0 -1
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts +0 -109
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts.map +0 -1
- package/lib/crypto/OutgoingRoomKeyRequestManager.js +0 -415
- package/lib/crypto/OutgoingRoomKeyRequestManager.js.map +0 -1
- package/lib/crypto/RoomList.d.ts +0 -26
- package/lib/crypto/RoomList.d.ts.map +0 -1
- package/lib/crypto/RoomList.js +0 -71
- package/lib/crypto/RoomList.js.map +0 -1
- package/lib/crypto/SecretSharing.d.ts +0 -24
- package/lib/crypto/SecretSharing.d.ts.map +0 -1
- package/lib/crypto/SecretSharing.js +0 -194
- package/lib/crypto/SecretSharing.js.map +0 -1
- package/lib/crypto/SecretStorage.d.ts +0 -55
- package/lib/crypto/SecretStorage.d.ts.map +0 -1
- package/lib/crypto/SecretStorage.js +0 -118
- package/lib/crypto/SecretStorage.js.map +0 -1
- package/lib/crypto/aes.d.ts +0 -6
- package/lib/crypto/aes.d.ts.map +0 -1
- package/lib/crypto/aes.js +0 -24
- package/lib/crypto/aes.js.map +0 -1
- package/lib/crypto/algorithms/base.d.ts +0 -156
- package/lib/crypto/algorithms/base.d.ts.map +0 -1
- package/lib/crypto/algorithms/base.js +0 -187
- package/lib/crypto/algorithms/base.js.map +0 -1
- package/lib/crypto/algorithms/index.d.ts +0 -4
- package/lib/crypto/algorithms/index.d.ts.map +0 -1
- package/lib/crypto/algorithms/index.js +0 -20
- package/lib/crypto/algorithms/index.js.map +0 -1
- package/lib/crypto/algorithms/megolm.d.ts +0 -385
- package/lib/crypto/algorithms/megolm.d.ts.map +0 -1
- package/lib/crypto/algorithms/megolm.js +0 -1822
- package/lib/crypto/algorithms/megolm.js.map +0 -1
- package/lib/crypto/algorithms/olm.d.ts +0 -5
- package/lib/crypto/algorithms/olm.d.ts.map +0 -1
- package/lib/crypto/algorithms/olm.js +0 -299
- package/lib/crypto/algorithms/olm.js.map +0 -1
- package/lib/crypto/api.d.ts +0 -32
- package/lib/crypto/api.d.ts.map +0 -1
- package/lib/crypto/api.js +0 -22
- package/lib/crypto/api.js.map +0 -1
- package/lib/crypto/backup.d.ts +0 -227
- package/lib/crypto/backup.d.ts.map +0 -1
- package/lib/crypto/backup.js +0 -824
- package/lib/crypto/backup.js.map +0 -1
- package/lib/crypto/crypto.d.ts +0 -3
- package/lib/crypto/crypto.d.ts.map +0 -1
- package/lib/crypto/crypto.js +0 -19
- package/lib/crypto/crypto.js.map +0 -1
- package/lib/crypto/dehydration.d.ts +0 -34
- package/lib/crypto/dehydration.d.ts.map +0 -1
- package/lib/crypto/dehydration.js +0 -252
- package/lib/crypto/dehydration.js.map +0 -1
- package/lib/crypto/device-converter.d.ts +0 -9
- package/lib/crypto/device-converter.d.ts.map +0 -1
- package/lib/crypto/device-converter.js +0 -42
- package/lib/crypto/device-converter.js.map +0 -1
- package/lib/crypto/deviceinfo.d.ts +0 -99
- package/lib/crypto/deviceinfo.d.ts.map +0 -1
- package/lib/crypto/deviceinfo.js +0 -148
- package/lib/crypto/deviceinfo.js.map +0 -1
- package/lib/crypto/index.d.ts +0 -1210
- package/lib/crypto/index.d.ts.map +0 -1
- package/lib/crypto/index.js +0 -4101
- package/lib/crypto/index.js.map +0 -1
- package/lib/crypto/key_passphrase.d.ts +0 -14
- package/lib/crypto/key_passphrase.d.ts.map +0 -1
- package/lib/crypto/key_passphrase.js +0 -44
- package/lib/crypto/key_passphrase.js.map +0 -1
- package/lib/crypto/keybackup.d.ts +0 -18
- package/lib/crypto/keybackup.d.ts.map +0 -1
- package/lib/crypto/keybackup.js +0 -1
- package/lib/crypto/keybackup.js.map +0 -1
- package/lib/crypto/olmlib.d.ts +0 -129
- package/lib/crypto/olmlib.d.ts.map +0 -1
- package/lib/crypto/olmlib.js +0 -492
- package/lib/crypto/olmlib.js.map +0 -1
- package/lib/crypto/recoverykey.d.ts +0 -2
- package/lib/crypto/recoverykey.d.ts.map +0 -1
- package/lib/crypto/recoverykey.js +0 -19
- package/lib/crypto/recoverykey.js.map +0 -1
- package/lib/crypto/store/base.d.ts +0 -252
- package/lib/crypto/store/base.d.ts.map +0 -1
- package/lib/crypto/store/base.js +0 -64
- package/lib/crypto/store/base.js.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts +0 -187
- package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.js +0 -1145
- package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store.d.ts +0 -432
- package/lib/crypto/store/indexeddb-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store.js +0 -728
- package/lib/crypto/store/indexeddb-crypto-store.js.map +0 -1
- package/lib/crypto/store/localStorage-crypto-store.d.ts +0 -119
- package/lib/crypto/store/localStorage-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/localStorage-crypto-store.js +0 -531
- package/lib/crypto/store/localStorage-crypto-store.js.map +0 -1
- package/lib/crypto/store/memory-crypto-store.d.ts +0 -215
- package/lib/crypto/store/memory-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/memory-crypto-store.js +0 -622
- package/lib/crypto/store/memory-crypto-store.js.map +0 -1
- package/lib/crypto/verification/Base.d.ts +0 -105
- package/lib/crypto/verification/Base.d.ts.map +0 -1
- package/lib/crypto/verification/Base.js +0 -372
- package/lib/crypto/verification/Base.js.map +0 -1
- package/lib/crypto/verification/Error.d.ts +0 -35
- package/lib/crypto/verification/Error.d.ts.map +0 -1
- package/lib/crypto/verification/Error.js +0 -86
- package/lib/crypto/verification/Error.js.map +0 -1
- package/lib/crypto/verification/IllegalMethod.d.ts +0 -15
- package/lib/crypto/verification/IllegalMethod.d.ts.map +0 -1
- package/lib/crypto/verification/IllegalMethod.js +0 -43
- package/lib/crypto/verification/IllegalMethod.js.map +0 -1
- package/lib/crypto/verification/QRCode.d.ts +0 -51
- package/lib/crypto/verification/QRCode.d.ts.map +0 -1
- package/lib/crypto/verification/QRCode.js +0 -277
- package/lib/crypto/verification/QRCode.js.map +0 -1
- package/lib/crypto/verification/SAS.d.ts +0 -27
- package/lib/crypto/verification/SAS.d.ts.map +0 -1
- package/lib/crypto/verification/SAS.js +0 -485
- package/lib/crypto/verification/SAS.js.map +0 -1
- package/lib/crypto/verification/SASDecimal.d.ts +0 -8
- package/lib/crypto/verification/SASDecimal.d.ts.map +0 -1
- package/lib/crypto/verification/SASDecimal.js +0 -34
- package/lib/crypto/verification/SASDecimal.js.map +0 -1
- package/lib/crypto/verification/request/Channel.d.ts +0 -18
- package/lib/crypto/verification/request/Channel.d.ts.map +0 -1
- package/lib/crypto/verification/request/Channel.js +0 -1
- package/lib/crypto/verification/request/Channel.js.map +0 -1
- package/lib/crypto/verification/request/InRoomChannel.d.ts +0 -113
- package/lib/crypto/verification/request/InRoomChannel.d.ts.map +0 -1
- package/lib/crypto/verification/request/InRoomChannel.js +0 -351
- package/lib/crypto/verification/request/InRoomChannel.js.map +0 -1
- package/lib/crypto/verification/request/ToDeviceChannel.d.ts +0 -105
- package/lib/crypto/verification/request/ToDeviceChannel.d.ts.map +0 -1
- package/lib/crypto/verification/request/ToDeviceChannel.js +0 -328
- package/lib/crypto/verification/request/ToDeviceChannel.js.map +0 -1
- package/lib/crypto/verification/request/VerificationRequest.d.ts +0 -227
- package/lib/crypto/verification/request/VerificationRequest.d.ts.map +0 -1
- package/lib/crypto/verification/request/VerificationRequest.js +0 -937
- package/lib/crypto/verification/request/VerificationRequest.js.map +0 -1
- package/lib/crypto-api/CryptoEvent.d.ts +0 -69
- package/lib/crypto-api/CryptoEvent.d.ts.map +0 -1
- package/lib/crypto-api/CryptoEvent.js +0 -33
- package/lib/crypto-api/CryptoEvent.js.map +0 -1
- package/lib/crypto-api/CryptoEventHandlerMap.d.ts +0 -16
- package/lib/crypto-api/CryptoEventHandlerMap.d.ts.map +0 -1
- package/lib/crypto-api/CryptoEventHandlerMap.js +0 -22
- package/lib/crypto-api/CryptoEventHandlerMap.js.map +0 -1
- package/lib/crypto-api/index.d.ts +0 -978
- package/lib/crypto-api/index.d.ts.map +0 -1
- package/lib/crypto-api/index.js +0 -304
- package/lib/crypto-api/index.js.map +0 -1
- package/lib/crypto-api/key-passphrase.d.ts +0 -11
- package/lib/crypto-api/key-passphrase.d.ts.map +0 -1
- package/lib/crypto-api/key-passphrase.js +0 -51
- package/lib/crypto-api/key-passphrase.js.map +0 -1
- package/lib/crypto-api/keybackup.d.ts +0 -88
- package/lib/crypto-api/keybackup.d.ts.map +0 -1
- package/lib/crypto-api/keybackup.js +0 -1
- package/lib/crypto-api/keybackup.js.map +0 -1
- package/lib/crypto-api/recovery-key.d.ts +0 -11
- package/lib/crypto-api/recovery-key.d.ts.map +0 -1
- package/lib/crypto-api/recovery-key.js +0 -65
- package/lib/crypto-api/recovery-key.js.map +0 -1
- package/lib/crypto-api/verification.d.ts +0 -344
- package/lib/crypto-api/verification.d.ts.map +0 -1
- package/lib/crypto-api/verification.js +0 -91
- package/lib/crypto-api/verification.js.map +0 -1
- package/lib/matrixrtc/CallMembership.d.ts +0 -66
- package/lib/matrixrtc/CallMembership.d.ts.map +0 -1
- package/lib/matrixrtc/CallMembership.js +0 -197
- package/lib/matrixrtc/CallMembership.js.map +0 -1
- package/lib/matrixrtc/LivekitFocus.d.ts +0 -16
- package/lib/matrixrtc/LivekitFocus.d.ts.map +0 -1
- package/lib/matrixrtc/LivekitFocus.js +0 -20
- package/lib/matrixrtc/LivekitFocus.js.map +0 -1
- package/lib/matrixrtc/MatrixRTCSession.d.ts +0 -295
- package/lib/matrixrtc/MatrixRTCSession.d.ts.map +0 -1
- package/lib/matrixrtc/MatrixRTCSession.js +0 -1043
- package/lib/matrixrtc/MatrixRTCSession.js.map +0 -1
- package/lib/matrixrtc/MatrixRTCSessionManager.d.ts +0 -40
- package/lib/matrixrtc/MatrixRTCSessionManager.d.ts.map +0 -1
- package/lib/matrixrtc/MatrixRTCSessionManager.js +0 -146
- package/lib/matrixrtc/MatrixRTCSessionManager.js.map +0 -1
- package/lib/matrixrtc/focus.d.ts +0 -10
- package/lib/matrixrtc/focus.d.ts.map +0 -1
- package/lib/matrixrtc/focus.js +0 -1
- package/lib/matrixrtc/focus.js.map +0 -1
- package/lib/matrixrtc/index.d.ts +0 -7
- package/lib/matrixrtc/index.d.ts.map +0 -1
- package/lib/matrixrtc/index.js +0 -21
- package/lib/matrixrtc/index.js.map +0 -1
- package/lib/matrixrtc/types.d.ts +0 -19
- package/lib/matrixrtc/types.d.ts.map +0 -1
- package/lib/matrixrtc/types.js +0 -1
- package/lib/matrixrtc/types.js.map +0 -1
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts +0 -112
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts.map +0 -1
- package/lib/rendezvous/MSC4108SignInWithQR.js +0 -392
- package/lib/rendezvous/MSC4108SignInWithQR.js.map +0 -1
- package/lib/rendezvous/RendezvousChannel.d.ts +0 -27
- package/lib/rendezvous/RendezvousChannel.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousChannel.js +0 -1
- package/lib/rendezvous/RendezvousChannel.js.map +0 -1
- package/lib/rendezvous/RendezvousCode.d.ts +0 -9
- package/lib/rendezvous/RendezvousCode.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousCode.js +0 -1
- package/lib/rendezvous/RendezvousCode.js.map +0 -1
- package/lib/rendezvous/RendezvousError.d.ts +0 -6
- package/lib/rendezvous/RendezvousError.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousError.js +0 -23
- package/lib/rendezvous/RendezvousError.js.map +0 -1
- package/lib/rendezvous/RendezvousFailureReason.d.ts +0 -31
- package/lib/rendezvous/RendezvousFailureReason.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousFailureReason.js +0 -38
- package/lib/rendezvous/RendezvousFailureReason.js.map +0 -1
- package/lib/rendezvous/RendezvousIntent.d.ts +0 -5
- package/lib/rendezvous/RendezvousIntent.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousIntent.js +0 -22
- package/lib/rendezvous/RendezvousIntent.js.map +0 -1
- package/lib/rendezvous/RendezvousTransport.d.ts +0 -36
- package/lib/rendezvous/RendezvousTransport.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousTransport.js +0 -1
- package/lib/rendezvous/RendezvousTransport.js.map +0 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts +0 -58
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts.map +0 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.js +0 -246
- package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +0 -1
- package/lib/rendezvous/channels/index.d.ts +0 -2
- package/lib/rendezvous/channels/index.d.ts.map +0 -1
- package/lib/rendezvous/channels/index.js +0 -18
- package/lib/rendezvous/channels/index.js.map +0 -1
- package/lib/rendezvous/index.d.ts +0 -10
- package/lib/rendezvous/index.d.ts.map +0 -1
- package/lib/rendezvous/index.js +0 -23
- package/lib/rendezvous/index.js.map +0 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +0 -61
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts.map +0 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js +0 -253
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +0 -1
- package/lib/rendezvous/transports/index.d.ts +0 -2
- package/lib/rendezvous/transports/index.d.ts.map +0 -1
- package/lib/rendezvous/transports/index.js +0 -18
- package/lib/rendezvous/transports/index.js.map +0 -1
- package/lib/rust-crypto/CrossSigningIdentity.d.ts +0 -33
- package/lib/rust-crypto/CrossSigningIdentity.d.ts.map +0 -1
- package/lib/rust-crypto/CrossSigningIdentity.js +0 -157
- package/lib/rust-crypto/CrossSigningIdentity.js.map +0 -1
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts +0 -98
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts.map +0 -1
- package/lib/rust-crypto/DehydratedDeviceManager.js +0 -285
- package/lib/rust-crypto/DehydratedDeviceManager.js.map +0 -1
- package/lib/rust-crypto/KeyClaimManager.d.ts +0 -33
- package/lib/rust-crypto/KeyClaimManager.d.ts.map +0 -1
- package/lib/rust-crypto/KeyClaimManager.js +0 -82
- package/lib/rust-crypto/KeyClaimManager.js.map +0 -1
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts +0 -43
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts.map +0 -1
- package/lib/rust-crypto/OutgoingRequestProcessor.js +0 -195
- package/lib/rust-crypto/OutgoingRequestProcessor.js.map +0 -1
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts +0 -47
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts.map +0 -1
- package/lib/rust-crypto/OutgoingRequestsManager.js +0 -148
- package/lib/rust-crypto/OutgoingRequestsManager.js.map +0 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +0 -120
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts.map +0 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +0 -467
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +0 -1
- package/lib/rust-crypto/RoomEncryptor.d.ts +0 -98
- package/lib/rust-crypto/RoomEncryptor.d.ts.map +0 -1
- package/lib/rust-crypto/RoomEncryptor.js +0 -299
- package/lib/rust-crypto/RoomEncryptor.js.map +0 -1
- package/lib/rust-crypto/backup.d.ts +0 -254
- package/lib/rust-crypto/backup.d.ts.map +0 -1
- package/lib/rust-crypto/backup.js +0 -837
- package/lib/rust-crypto/backup.js.map +0 -1
- package/lib/rust-crypto/constants.d.ts +0 -3
- package/lib/rust-crypto/constants.d.ts.map +0 -1
- package/lib/rust-crypto/constants.js +0 -19
- package/lib/rust-crypto/constants.js.map +0 -1
- package/lib/rust-crypto/device-converter.d.ts +0 -28
- package/lib/rust-crypto/device-converter.d.ts.map +0 -1
- package/lib/rust-crypto/device-converter.js +0 -123
- package/lib/rust-crypto/device-converter.js.map +0 -1
- package/lib/rust-crypto/index.d.ts +0 -61
- package/lib/rust-crypto/index.d.ts.map +0 -1
- package/lib/rust-crypto/index.js +0 -152
- package/lib/rust-crypto/index.js.map +0 -1
- package/lib/rust-crypto/libolm_migration.d.ts +0 -81
- package/lib/rust-crypto/libolm_migration.d.ts.map +0 -1
- package/lib/rust-crypto/libolm_migration.js +0 -459
- package/lib/rust-crypto/libolm_migration.js.map +0 -1
- package/lib/rust-crypto/rust-crypto.d.ts +0 -556
- package/lib/rust-crypto/rust-crypto.d.ts.map +0 -1
- package/lib/rust-crypto/rust-crypto.js +0 -2016
- package/lib/rust-crypto/rust-crypto.js.map +0 -1
- package/lib/rust-crypto/secret-storage.d.ts +0 -22
- package/lib/rust-crypto/secret-storage.d.ts.map +0 -1
- package/lib/rust-crypto/secret-storage.js +0 -63
- package/lib/rust-crypto/secret-storage.js.map +0 -1
- package/lib/rust-crypto/verification.d.ts +0 -319
- package/lib/rust-crypto/verification.d.ts.map +0 -1
- package/lib/rust-crypto/verification.js +0 -816
- package/lib/rust-crypto/verification.js.map +0 -1
- package/lib/secret-storage.d.ts +0 -370
- package/lib/secret-storage.d.ts.map +0 -1
- package/lib/secret-storage.js +0 -466
- package/lib/secret-storage.js.map +0 -1
- package/lib/utils/decryptAESSecretStorageItem.d.ts +0 -12
- package/lib/utils/decryptAESSecretStorageItem.d.ts.map +0 -1
- package/lib/utils/decryptAESSecretStorageItem.js +0 -50
- package/lib/utils/decryptAESSecretStorageItem.js.map +0 -1
- package/lib/utils/encryptAESSecretStorageItem.d.ts +0 -16
- package/lib/utils/encryptAESSecretStorageItem.d.ts.map +0 -1
- package/lib/utils/encryptAESSecretStorageItem.js +0 -68
- package/lib/utils/encryptAESSecretStorageItem.js.map +0 -1
- package/lib/utils/internal/deriveKeys.d.ts +0 -10
- package/lib/utils/internal/deriveKeys.d.ts.map +0 -1
- package/lib/utils/internal/deriveKeys.js +0 -60
- package/lib/utils/internal/deriveKeys.js.map +0 -1
- package/lib/webrtc/audioContext.d.ts +0 -15
- package/lib/webrtc/audioContext.d.ts.map +0 -1
- package/lib/webrtc/audioContext.js +0 -46
- package/lib/webrtc/audioContext.js.map +0 -1
- package/lib/webrtc/call.d.ts +0 -560
- package/lib/webrtc/call.d.ts.map +0 -1
- package/lib/webrtc/call.js +0 -2541
- package/lib/webrtc/call.js.map +0 -1
- package/lib/webrtc/callEventHandler.d.ts +0 -37
- package/lib/webrtc/callEventHandler.d.ts.map +0 -1
- package/lib/webrtc/callEventHandler.js +0 -344
- package/lib/webrtc/callEventHandler.js.map +0 -1
- package/lib/webrtc/callEventTypes.d.ts +0 -73
- package/lib/webrtc/callEventTypes.d.ts.map +0 -1
- package/lib/webrtc/callEventTypes.js +0 -13
- package/lib/webrtc/callEventTypes.js.map +0 -1
- package/lib/webrtc/callFeed.d.ts +0 -128
- package/lib/webrtc/callFeed.d.ts.map +0 -1
- package/lib/webrtc/callFeed.js +0 -289
- package/lib/webrtc/callFeed.js.map +0 -1
- package/lib/webrtc/groupCall.d.ts +0 -323
- package/lib/webrtc/groupCall.d.ts.map +0 -1
- package/lib/webrtc/groupCall.js +0 -1337
- package/lib/webrtc/groupCall.js.map +0 -1
- package/lib/webrtc/groupCallEventHandler.d.ts +0 -31
- package/lib/webrtc/groupCallEventHandler.d.ts.map +0 -1
- package/lib/webrtc/groupCallEventHandler.js +0 -178
- package/lib/webrtc/groupCallEventHandler.js.map +0 -1
- package/lib/webrtc/mediaHandler.d.ts +0 -89
- package/lib/webrtc/mediaHandler.d.ts.map +0 -1
- package/lib/webrtc/mediaHandler.js +0 -437
- package/lib/webrtc/mediaHandler.js.map +0 -1
- package/lib/webrtc/stats/callFeedStatsReporter.d.ts +0 -8
- package/lib/webrtc/stats/callFeedStatsReporter.d.ts.map +0 -1
- package/lib/webrtc/stats/callFeedStatsReporter.js +0 -82
- package/lib/webrtc/stats/callFeedStatsReporter.js.map +0 -1
- package/lib/webrtc/stats/callStatsReportGatherer.d.ts +0 -25
- package/lib/webrtc/stats/callStatsReportGatherer.d.ts.map +0 -1
- package/lib/webrtc/stats/callStatsReportGatherer.js +0 -199
- package/lib/webrtc/stats/callStatsReportGatherer.js.map +0 -1
- package/lib/webrtc/stats/callStatsReportSummary.d.ts +0 -17
- package/lib/webrtc/stats/callStatsReportSummary.d.ts.map +0 -1
- package/lib/webrtc/stats/callStatsReportSummary.js +0 -1
- package/lib/webrtc/stats/callStatsReportSummary.js.map +0 -1
- package/lib/webrtc/stats/connectionStats.d.ts +0 -28
- package/lib/webrtc/stats/connectionStats.d.ts.map +0 -1
- package/lib/webrtc/stats/connectionStats.js +0 -26
- package/lib/webrtc/stats/connectionStats.js.map +0 -1
- package/lib/webrtc/stats/connectionStatsBuilder.d.ts +0 -5
- package/lib/webrtc/stats/connectionStatsBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/connectionStatsBuilder.js +0 -27
- package/lib/webrtc/stats/connectionStatsBuilder.js.map +0 -1
- package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts +0 -7
- package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/connectionStatsReportBuilder.js +0 -121
- package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +0 -1
- package/lib/webrtc/stats/groupCallStats.d.ts +0 -22
- package/lib/webrtc/stats/groupCallStats.d.ts.map +0 -1
- package/lib/webrtc/stats/groupCallStats.js +0 -78
- package/lib/webrtc/stats/groupCallStats.js.map +0 -1
- package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts +0 -10
- package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaSsrcHandler.js +0 -57
- package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackHandler.d.ts +0 -12
- package/lib/webrtc/stats/media/mediaTrackHandler.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackHandler.js +0 -62
- package/lib/webrtc/stats/media/mediaTrackHandler.js.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStats.d.ts +0 -86
- package/lib/webrtc/stats/media/mediaTrackStats.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStats.js +0 -142
- package/lib/webrtc/stats/media/mediaTrackStats.js.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts +0 -22
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +0 -76
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +0 -1
- package/lib/webrtc/stats/statsReport.d.ts +0 -99
- package/lib/webrtc/stats/statsReport.d.ts.map +0 -1
- package/lib/webrtc/stats/statsReport.js +0 -32
- package/lib/webrtc/stats/statsReport.js.map +0 -1
- package/lib/webrtc/stats/statsReportEmitter.d.ts +0 -15
- package/lib/webrtc/stats/statsReportEmitter.d.ts.map +0 -1
- package/lib/webrtc/stats/statsReportEmitter.js +0 -33
- package/lib/webrtc/stats/statsReportEmitter.js.map +0 -1
- package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts +0 -16
- package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts.map +0 -1
- package/lib/webrtc/stats/summaryStatsReportGatherer.js +0 -116
- package/lib/webrtc/stats/summaryStatsReportGatherer.js.map +0 -1
- package/lib/webrtc/stats/trackStatsBuilder.d.ts +0 -19
- package/lib/webrtc/stats/trackStatsBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/trackStatsBuilder.js +0 -168
- package/lib/webrtc/stats/trackStatsBuilder.js.map +0 -1
- package/lib/webrtc/stats/transportStats.d.ts +0 -11
- package/lib/webrtc/stats/transportStats.d.ts.map +0 -1
- package/lib/webrtc/stats/transportStats.js +0 -1
- package/lib/webrtc/stats/transportStats.js.map +0 -1
- package/lib/webrtc/stats/transportStatsBuilder.d.ts +0 -5
- package/lib/webrtc/stats/transportStatsBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/transportStatsBuilder.js +0 -34
- package/lib/webrtc/stats/transportStatsBuilder.js.map +0 -1
- package/lib/webrtc/stats/valueFormatter.d.ts +0 -4
- package/lib/webrtc/stats/valueFormatter.d.ts.map +0 -1
- package/lib/webrtc/stats/valueFormatter.js +0 -25
- package/lib/webrtc/stats/valueFormatter.js.map +0 -1
- package/src/@types/AESEncryptedSecretStoragePayload.ts +0 -29
- package/src/@types/crypto.ts +0 -73
- package/src/@types/matrix-sdk-crypto-wasm.d.ts +0 -44
- package/src/common-crypto/CryptoBackend.ts +0 -302
- package/src/common-crypto/README.md +0 -4
- package/src/common-crypto/key-passphrase.ts +0 -43
- package/src/crypto/CrossSigning.ts +0 -773
- package/src/crypto/DeviceList.ts +0 -989
- package/src/crypto/EncryptionSetup.ts +0 -351
- package/src/crypto/OlmDevice.ts +0 -1500
- package/src/crypto/OutgoingRoomKeyRequestManager.ts +0 -485
- package/src/crypto/RoomList.ts +0 -70
- package/src/crypto/SecretSharing.ts +0 -240
- package/src/crypto/SecretStorage.ts +0 -136
- package/src/crypto/aes.ts +0 -23
- package/src/crypto/algorithms/base.ts +0 -236
- package/src/crypto/algorithms/index.ts +0 -20
- package/src/crypto/algorithms/megolm.ts +0 -2216
- package/src/crypto/algorithms/olm.ts +0 -381
- package/src/crypto/api.ts +0 -70
- package/src/crypto/backup.ts +0 -922
- package/src/crypto/crypto.ts +0 -18
- package/src/crypto/dehydration.ts +0 -272
- package/src/crypto/device-converter.ts +0 -45
- package/src/crypto/deviceinfo.ts +0 -158
- package/src/crypto/index.ts +0 -4418
- package/src/crypto/key_passphrase.ts +0 -42
- package/src/crypto/keybackup.ts +0 -47
- package/src/crypto/olmlib.ts +0 -539
- package/src/crypto/recoverykey.ts +0 -18
- package/src/crypto/store/base.ts +0 -348
- package/src/crypto/store/indexeddb-crypto-store-backend.ts +0 -1250
- package/src/crypto/store/indexeddb-crypto-store.ts +0 -845
- package/src/crypto/store/localStorage-crypto-store.ts +0 -579
- package/src/crypto/store/memory-crypto-store.ts +0 -680
- package/src/crypto/verification/Base.ts +0 -409
- package/src/crypto/verification/Error.ts +0 -76
- package/src/crypto/verification/IllegalMethod.ts +0 -50
- package/src/crypto/verification/QRCode.ts +0 -310
- package/src/crypto/verification/SAS.ts +0 -494
- package/src/crypto/verification/SASDecimal.ts +0 -37
- package/src/crypto/verification/request/Channel.ts +0 -34
- package/src/crypto/verification/request/InRoomChannel.ts +0 -371
- package/src/crypto/verification/request/ToDeviceChannel.ts +0 -354
- package/src/crypto/verification/request/VerificationRequest.ts +0 -976
- package/src/crypto-api/CryptoEvent.ts +0 -93
- package/src/crypto-api/CryptoEventHandlerMap.ts +0 -32
- package/src/crypto-api/index.ts +0 -1175
- package/src/crypto-api/key-passphrase.ts +0 -58
- package/src/crypto-api/keybackup.ts +0 -115
- package/src/crypto-api/recovery-key.ts +0 -69
- package/src/crypto-api/verification.ts +0 -408
- package/src/matrixrtc/CallMembership.ts +0 -247
- package/src/matrixrtc/LivekitFocus.ts +0 -39
- package/src/matrixrtc/MatrixRTCSession.ts +0 -1319
- package/src/matrixrtc/MatrixRTCSessionManager.ts +0 -166
- package/src/matrixrtc/focus.ts +0 -25
- package/src/matrixrtc/index.ts +0 -22
- package/src/matrixrtc/types.ts +0 -36
- package/src/rendezvous/MSC4108SignInWithQR.ts +0 -444
- package/src/rendezvous/RendezvousChannel.ts +0 -48
- package/src/rendezvous/RendezvousCode.ts +0 -25
- package/src/rendezvous/RendezvousError.ts +0 -26
- package/src/rendezvous/RendezvousFailureReason.ts +0 -49
- package/src/rendezvous/RendezvousIntent.ts +0 -20
- package/src/rendezvous/RendezvousTransport.ts +0 -58
- package/src/rendezvous/channels/MSC4108SecureChannel.ts +0 -270
- package/src/rendezvous/channels/index.ts +0 -17
- package/src/rendezvous/index.ts +0 -25
- package/src/rendezvous/transports/MSC4108RendezvousSession.ts +0 -270
- package/src/rendezvous/transports/index.ts +0 -17
- package/src/rust-crypto/CrossSigningIdentity.ts +0 -183
- package/src/rust-crypto/DehydratedDeviceManager.ts +0 -306
- package/src/rust-crypto/KeyClaimManager.ts +0 -86
- package/src/rust-crypto/OutgoingRequestProcessor.ts +0 -236
- package/src/rust-crypto/OutgoingRequestsManager.ts +0 -143
- package/src/rust-crypto/PerSessionKeyBackupDownloader.ts +0 -501
- package/src/rust-crypto/RoomEncryptor.ts +0 -352
- package/src/rust-crypto/backup.ts +0 -881
- package/src/rust-crypto/constants.ts +0 -18
- package/src/rust-crypto/device-converter.ts +0 -128
- package/src/rust-crypto/index.ts +0 -237
- package/src/rust-crypto/libolm_migration.ts +0 -530
- package/src/rust-crypto/rust-crypto.ts +0 -2205
- package/src/rust-crypto/secret-storage.ts +0 -60
- package/src/rust-crypto/verification.ts +0 -830
- package/src/secret-storage.ts +0 -693
- package/src/utils/decryptAESSecretStorageItem.ts +0 -54
- package/src/utils/encryptAESSecretStorageItem.ts +0 -73
- package/src/utils/internal/deriveKeys.ts +0 -63
- package/src/webrtc/audioContext.ts +0 -44
- package/src/webrtc/call.ts +0 -3074
- package/src/webrtc/callEventHandler.ts +0 -425
- package/src/webrtc/callEventTypes.ts +0 -93
- package/src/webrtc/callFeed.ts +0 -364
- package/src/webrtc/groupCall.ts +0 -1735
- package/src/webrtc/groupCallEventHandler.ts +0 -234
- package/src/webrtc/mediaHandler.ts +0 -484
- package/src/webrtc/stats/callFeedStatsReporter.ts +0 -94
- package/src/webrtc/stats/callStatsReportGatherer.ts +0 -219
- package/src/webrtc/stats/callStatsReportSummary.ts +0 -30
- package/src/webrtc/stats/connectionStats.ts +0 -47
- package/src/webrtc/stats/connectionStatsBuilder.ts +0 -28
- package/src/webrtc/stats/connectionStatsReportBuilder.ts +0 -140
- package/src/webrtc/stats/groupCallStats.ts +0 -93
- package/src/webrtc/stats/media/mediaSsrcHandler.ts +0 -57
- package/src/webrtc/stats/media/mediaTrackHandler.ts +0 -76
- package/src/webrtc/stats/media/mediaTrackStats.ts +0 -176
- package/src/webrtc/stats/media/mediaTrackStatsHandler.ts +0 -90
- package/src/webrtc/stats/statsReport.ts +0 -133
- package/src/webrtc/stats/statsReportEmitter.ts +0 -49
- package/src/webrtc/stats/summaryStatsReportGatherer.ts +0 -148
- package/src/webrtc/stats/trackStatsBuilder.ts +0 -207
- package/src/webrtc/stats/transportStats.ts +0 -26
- package/src/webrtc/stats/transportStatsBuilder.ts +0 -48
- package/src/webrtc/stats/valueFormatter.ts +0 -27
package/lib/sliding-sync.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sliding-sync.js","names":["logger","TypedEventEmitter","sleep","defer","BUFFER_PERIOD_MS","MSC3575_WILDCARD","MSC3575_STATE_KEY_ME","MSC3575_STATE_KEY_LAZY","SlidingSyncState","SlidingList","constructor","list","_defineProperty","replaceList","setModified","modified","isModified","updateListRange","newRanges","ranges","JSON","parse","stringify","filters","roomIndexToRoomId","joinedCount","getList","forceIncludeAllParams","isIndexInRange","i","r","ExtensionState","SlidingSyncEvent","SlidingSync","proxyBaseUrl","lists","roomSubscriptionInfo","client","timeoutMS","Set","Map","forEach","key","set","addCustomSubscription","name","sub","customSubscriptions","has","warn","concat","useCustomSubscription","roomId","roomIdToCustomSubscription","get","confirmedRoomSubscriptions","delete","getListData","data","Object","assign","getListParams","params","setListRanges","Promise","reject","Error","resend","setList","existingList","listModifiedCount","getRoomSubscriptions","Array","from","desiredRoomSubscriptions","modifyRoomSubscriptions","s","modifyRoomSubscriptionInfo","rs","registerExtension","ext","extensions","getExtensionRequest","isInitial","keys","extName","onRequest","onPreExtensionsResponse","_this","_asyncToGenerator","all","map","_ref","when","PreProcess","onResponse","_x","apply","arguments","onPostExtensionsResponse","_this2","_ref2","PostProcess","_x2","invokeRoomDataListeners","roomData","_this3","required_state","timeline","emitPromised","RoomData","invokeLifecycleListeners","state","resp","err","emit","Lifecycle","shiftRight","listKey","hi","low","shiftLeft","removeEntry","index","max","n","Number","addEntry","processListOps","gapIndex","listData","ops","op","debug","room_id","startIndex","range","room_ids","join","_this$abortController","needsResend","txnIdDefers","length","promise","txnId","makeTxnId","d","push","_objectSpread","abortController","abort","AbortController","resolveTransactionDefers","txnIndex","resolve","slice","stop","_this$abortController2","terminated","removeAllListeners","List","resetup","_this$abortController3","l","start","_this4","currentPos","_loop","doNotUpdateList","reqLists","reqBody","pos","timeout","clientTimeout","undefined","newSubscriptions","difference","unsubscriptions","size","unsubscribe_rooms","room_subscriptions","customSubName","txn_id","pendingReq","slidingSync","signal","add","rooms","count","RequestFinished","httpStatus","error","listKeysWithUpdates","entries","Complete","_ret","setA","setB","diff","elem"],"sources":["../src/sliding-sync.ts"],"sourcesContent":["/*\nCopyright 2022 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 { logger } from \"./logger.ts\";\nimport { MatrixClient } from \"./client.ts\";\nimport { IRoomEvent, IStateEvent } from \"./sync-accumulator.ts\";\nimport { TypedEventEmitter } from \"./models/typed-event-emitter.ts\";\nimport { sleep, IDeferred, defer } from \"./utils.ts\";\nimport { HTTPError } from \"./http-api/index.ts\";\n\n// /sync requests allow you to set a timeout= but the request may continue\n// beyond that and wedge forever, so we need to track how long we are willing\n// to keep open the connection. This constant is *ADDED* to the timeout= value\n// to determine the max time we're willing to wait.\nconst BUFFER_PERIOD_MS = 10 * 1000;\n\nexport const MSC3575_WILDCARD = \"*\";\nexport const MSC3575_STATE_KEY_ME = \"$ME\";\nexport const MSC3575_STATE_KEY_LAZY = \"$LAZY\";\n\n/**\n * Represents a subscription to a room or set of rooms. Controls which events are returned.\n */\nexport interface MSC3575RoomSubscription {\n required_state?: string[][];\n timeline_limit?: number;\n include_old_rooms?: MSC3575RoomSubscription;\n}\n\n/**\n * Controls which rooms are returned in a given list.\n */\nexport interface MSC3575Filter {\n is_dm?: boolean;\n is_encrypted?: boolean;\n is_invite?: boolean;\n room_name_like?: string;\n room_types?: string[];\n not_room_types?: string[];\n spaces?: string[];\n tags?: string[];\n not_tags?: string[];\n}\n\n/**\n * Represents a list subscription.\n */\nexport interface MSC3575List extends MSC3575RoomSubscription {\n ranges: number[][];\n sort?: string[];\n filters?: MSC3575Filter;\n slow_get_all_rooms?: boolean;\n}\n\n/**\n * A complete Sliding Sync request.\n */\nexport interface MSC3575SlidingSyncRequest {\n // json body params\n lists?: Record<string, MSC3575List>;\n unsubscribe_rooms?: string[];\n room_subscriptions?: Record<string, MSC3575RoomSubscription>;\n extensions?: object;\n txn_id?: string;\n\n // query params\n pos?: string;\n timeout?: number;\n clientTimeout?: number;\n}\n\nexport interface MSC3575RoomData {\n name: string;\n required_state: IStateEvent[];\n timeline: (IRoomEvent | IStateEvent)[];\n notification_count?: number;\n highlight_count?: number;\n joined_count?: number;\n invited_count?: number;\n invite_state?: IStateEvent[];\n initial?: boolean;\n limited?: boolean;\n is_dm?: boolean;\n prev_batch?: string;\n num_live?: number;\n}\n\ninterface ListResponse {\n count: number;\n ops: Operation[];\n}\n\ninterface BaseOperation {\n op: string;\n}\n\ninterface DeleteOperation extends BaseOperation {\n op: \"DELETE\";\n index: number;\n}\n\ninterface InsertOperation extends BaseOperation {\n op: \"INSERT\";\n index: number;\n room_id: string;\n}\n\ninterface InvalidateOperation extends BaseOperation {\n op: \"INVALIDATE\";\n range: [number, number];\n}\n\ninterface SyncOperation extends BaseOperation {\n op: \"SYNC\";\n range: [number, number];\n room_ids: string[];\n}\n\ntype Operation = DeleteOperation | InsertOperation | InvalidateOperation | SyncOperation;\n\n/**\n * A complete Sliding Sync response\n */\nexport interface MSC3575SlidingSyncResponse {\n pos: string;\n txn_id?: string;\n lists: Record<string, ListResponse>;\n rooms: Record<string, MSC3575RoomData>;\n extensions: Record<string, object>;\n}\n\nexport enum SlidingSyncState {\n /**\n * Fired by SlidingSyncEvent.Lifecycle event immediately before processing the response.\n */\n RequestFinished = \"FINISHED\",\n /**\n * Fired by SlidingSyncEvent.Lifecycle event immediately after all room data listeners have been\n * invoked, but before list listeners.\n */\n Complete = \"COMPLETE\",\n}\n\n/**\n * Internal Class. SlidingList represents a single list in sliding sync. The list can have filters,\n * multiple sliding windows, and maintains the index-\\>room_id mapping.\n */\nclass SlidingList {\n private list!: MSC3575List;\n private isModified?: boolean;\n\n // returned data\n public roomIndexToRoomId: Record<number, string> = {};\n public joinedCount = 0;\n\n /**\n * Construct a new sliding list.\n * @param list - The range, sort and filter values to use for this list.\n */\n public constructor(list: MSC3575List) {\n this.replaceList(list);\n }\n\n /**\n * Mark this list as modified or not. Modified lists will return sticky params with calls to getList.\n * This is useful for the first time the list is sent, or if the list has changed in some way.\n * @param modified - True to mark this list as modified so all sticky parameters will be re-sent.\n */\n public setModified(modified: boolean): void {\n this.isModified = modified;\n }\n\n /**\n * Update the list range for this list. Does not affect modified status as list ranges are non-sticky.\n * @param newRanges - The new ranges for the list\n */\n public updateListRange(newRanges: number[][]): void {\n this.list.ranges = JSON.parse(JSON.stringify(newRanges));\n }\n\n /**\n * Replace list parameters. All fields will be replaced with the new list parameters.\n * @param list - The new list parameters\n */\n public replaceList(list: MSC3575List): void {\n list.filters = list.filters || {};\n list.ranges = list.ranges || [];\n this.list = JSON.parse(JSON.stringify(list));\n this.isModified = true;\n\n // reset values as the join count may be very different (if filters changed) including the rooms\n // (e.g. sort orders or sliding window ranges changed)\n\n // the constantly changing sliding window ranges. Not an array for performance reasons\n // E.g. tracking ranges 0-99, 500-599, we don't want to have a 600 element array\n this.roomIndexToRoomId = {};\n // the total number of joined rooms according to the server, always >= len(roomIndexToRoomId)\n this.joinedCount = 0;\n }\n\n /**\n * Return a copy of the list suitable for a request body.\n * @param forceIncludeAllParams - True to forcibly include all params even if the list\n * hasn't been modified. Callers may want to do this if they are modifying the list prior to calling\n * updateList.\n */\n public getList(forceIncludeAllParams: boolean): MSC3575List {\n let list = {\n ranges: JSON.parse(JSON.stringify(this.list.ranges)),\n };\n if (this.isModified || forceIncludeAllParams) {\n list = JSON.parse(JSON.stringify(this.list));\n }\n return list;\n }\n\n /**\n * Check if a given index is within the list range. This is required even though the /sync API\n * provides explicit updates with index positions because of the following situation:\n * 0 1 2 3 4 5 6 7 8 indexes\n * a b c d e f COMMANDS: SYNC 0 2 a b c; SYNC 6 8 d e f;\n * a b c d _ f COMMAND: DELETE 7;\n * e a b c d f COMMAND: INSERT 0 e;\n * c=3 is wrong as we are not tracking it, ergo we need to see if `i` is in range else drop it\n * @param i - The index to check\n * @returns True if the index is within a sliding window\n */\n public isIndexInRange(i: number): boolean {\n for (const r of this.list.ranges) {\n if (r[0] <= i && i <= r[1]) {\n return true;\n }\n }\n return false;\n }\n}\n\n/**\n * When onResponse extensions should be invoked: before or after processing the main response.\n */\nexport enum ExtensionState {\n // Call onResponse before processing the response body. This is useful when your extension is\n // preparing the ground for the response body e.g. processing to-device messages before the\n // encrypted event arrives.\n PreProcess = \"ExtState.PreProcess\",\n // Call onResponse after processing the response body. This is useful when your extension is\n // decorating data from the client, and you rely on MatrixClient.getRoom returning the Room object\n // e.g. room account data.\n PostProcess = \"ExtState.PostProcess\",\n}\n\n/**\n * An interface that must be satisfied to register extensions\n */\nexport interface Extension<Req extends {}, Res extends {}> {\n /**\n * The extension name to go under 'extensions' in the request body.\n * @returns The JSON key.\n */\n name(): string;\n /**\n * A function which is called when the request JSON is being formed.\n * Returns the data to insert under this key.\n * @param isInitial - True when this is part of the initial request (send sticky params)\n * @returns The request JSON to send.\n */\n onRequest(isInitial: boolean): Req | undefined;\n /**\n * A function which is called when there is response JSON under this extension.\n * @param data - The response JSON under the extension name.\n */\n onResponse(data: Res): Promise<void>;\n /**\n * Controls when onResponse should be called.\n * @returns The state when it should be called.\n */\n when(): ExtensionState;\n}\n\n/**\n * Events which can be fired by the SlidingSync class. These are designed to provide different levels\n * of information when processing sync responses.\n * - RoomData: concerns rooms, useful for SlidingSyncSdk to update its knowledge of rooms.\n * - Lifecycle: concerns callbacks at various well-defined points in the sync process.\n * - List: concerns lists, useful for UI layers to re-render room lists.\n * Specifically, the order of event invocation is:\n * - Lifecycle (state=RequestFinished)\n * - RoomData (N times)\n * - Lifecycle (state=Complete)\n * - List (at most once per list)\n */\nexport enum SlidingSyncEvent {\n /**\n * This event fires when there are updates for a room. Fired as and when rooms are encountered\n * in the response.\n */\n RoomData = \"SlidingSync.RoomData\",\n /**\n * This event fires at various points in the /sync loop lifecycle.\n * - SlidingSyncState.RequestFinished: Fires after we receive a valid response but before the\n * response has been processed. Perform any pre-process steps here. If there was a problem syncing,\n * `err` will be set (e.g network errors).\n * - SlidingSyncState.Complete: Fires after all SlidingSyncEvent.RoomData have been fired but before\n * SlidingSyncEvent.List.\n */\n Lifecycle = \"SlidingSync.Lifecycle\",\n /**\n * This event fires whenever there has been a change to this list index. It fires exactly once\n * per list, even if there were multiple operations for the list.\n * It fires AFTER Lifecycle and RoomData events.\n */\n List = \"SlidingSync.List\",\n}\n\nexport type SlidingSyncEventHandlerMap = {\n [SlidingSyncEvent.RoomData]: (roomId: string, roomData: MSC3575RoomData) => Promise<void> | void;\n [SlidingSyncEvent.Lifecycle]: (\n state: SlidingSyncState,\n resp: MSC3575SlidingSyncResponse | null,\n err?: Error,\n ) => void;\n [SlidingSyncEvent.List]: (listKey: string, joinedCount: number, roomIndexToRoomId: Record<number, string>) => void;\n};\n\n/**\n * SlidingSync is a high-level data structure which controls the majority of sliding sync.\n * It has no hooks into JS SDK except for needing a MatrixClient to perform the HTTP request.\n * This means this class (and everything it uses) can be used in isolation from JS SDK if needed.\n * To hook this up with the JS SDK, you need to use SlidingSyncSdk.\n */\nexport class SlidingSync extends TypedEventEmitter<SlidingSyncEvent, SlidingSyncEventHandlerMap> {\n private lists: Map<string, SlidingList>;\n private listModifiedCount = 0;\n private terminated = false;\n // flag set when resend() is called because we cannot rely on detecting AbortError in JS SDK :(\n private needsResend = false;\n // the txn_id to send with the next request.\n private txnId: string | null = null;\n // a list (in chronological order of when they were sent) of objects containing the txn ID and\n // a defer to resolve/reject depending on whether they were successfully sent or not.\n private txnIdDefers: (IDeferred<string> & { txnId: string })[] = [];\n // map of extension name to req/resp handler\n private extensions: Record<string, Extension<any, any>> = {};\n\n private desiredRoomSubscriptions = new Set<string>(); // the *desired* room subscriptions\n private confirmedRoomSubscriptions = new Set<string>();\n\n // map of custom subscription name to the subscription\n private customSubscriptions: Map<string, MSC3575RoomSubscription> = new Map();\n // map of room ID to custom subscription name\n private roomIdToCustomSubscription: Map<string, string> = new Map();\n\n private pendingReq?: Promise<MSC3575SlidingSyncResponse>;\n private abortController?: AbortController;\n\n /**\n * Create a new sliding sync instance\n * @param proxyBaseUrl - The base URL of the sliding sync proxy\n * @param lists - The lists to use for sliding sync.\n * @param roomSubscriptionInfo - The params to use for room subscriptions.\n * @param client - The client to use for /sync calls.\n * @param timeoutMS - The number of milliseconds to wait for a response.\n */\n public constructor(\n private readonly proxyBaseUrl: string,\n lists: Map<string, MSC3575List>,\n private roomSubscriptionInfo: MSC3575RoomSubscription,\n private readonly client: MatrixClient,\n private readonly timeoutMS: number,\n ) {\n super();\n this.lists = new Map<string, SlidingList>();\n lists.forEach((list, key) => {\n this.lists.set(key, new SlidingList(list));\n });\n }\n\n /**\n * Add a custom room subscription, referred to by an arbitrary name. If a subscription with this\n * name already exists, it is replaced. No requests are sent by calling this method.\n * @param name - The name of the subscription. Only used to reference this subscription in\n * useCustomSubscription.\n * @param sub - The subscription information.\n */\n public addCustomSubscription(name: string, sub: MSC3575RoomSubscription): void {\n if (this.customSubscriptions.has(name)) {\n logger.warn(`addCustomSubscription: ${name} already exists as a custom subscription, ignoring.`);\n return;\n }\n this.customSubscriptions.set(name, sub);\n }\n\n /**\n * Use a custom subscription previously added via addCustomSubscription. No requests are sent\n * by calling this method. Use modifyRoomSubscriptions to resend subscription information.\n * @param roomId - The room to use the subscription in.\n * @param name - The name of the subscription. If this name is unknown, the default subscription\n * will be used.\n */\n public useCustomSubscription(roomId: string, name: string): void {\n // We already know about this custom subscription, as it is immutable,\n // we don't need to unconfirm the subscription.\n if (this.roomIdToCustomSubscription.get(roomId) === name) {\n return;\n }\n this.roomIdToCustomSubscription.set(roomId, name);\n // unconfirm this subscription so a resend() will send it up afresh.\n this.confirmedRoomSubscriptions.delete(roomId);\n }\n\n /**\n * Get the room index data for a list.\n * @param key - The list key\n * @returns The list data which contains the rooms in this list\n */\n public getListData(key: string): { joinedCount: number; roomIndexToRoomId: Record<number, string> } | null {\n const data = this.lists.get(key);\n if (!data) {\n return null;\n }\n return {\n joinedCount: data.joinedCount,\n roomIndexToRoomId: Object.assign({}, data.roomIndexToRoomId),\n };\n }\n\n /**\n * Get the full request list parameters for a list index. This function is provided for callers to use\n * in conjunction with setList to update fields on an existing list.\n * @param key - The list key to get the params for.\n * @returns A copy of the list params or undefined.\n */\n public getListParams(key: string): MSC3575List | null {\n const params = this.lists.get(key);\n if (!params) {\n return null;\n }\n return params.getList(true);\n }\n\n /**\n * Set new ranges for an existing list. Calling this function when _only_ the ranges have changed\n * is more efficient than calling setList(index,list) as this function won't resend sticky params,\n * whereas setList always will.\n * @param key - The list key to modify\n * @param ranges - The new ranges to apply.\n * @returns A promise which resolves to the transaction ID when it has been received down sync\n * (or rejects with the transaction ID if the action was not applied e.g the request was cancelled\n * immediately after sending, in which case the action will be applied in the subsequent request)\n */\n public setListRanges(key: string, ranges: number[][]): Promise<string> {\n const list = this.lists.get(key);\n if (!list) {\n return Promise.reject(new Error(\"no list with key \" + key));\n }\n list.updateListRange(ranges);\n return this.resend();\n }\n\n /**\n * Add or replace a list. Calling this function will interrupt the /sync request to resend new\n * lists.\n * @param key - The key to modify\n * @param list - The new list parameters.\n * @returns A promise which resolves to the transaction ID when it has been received down sync\n * (or rejects with the transaction ID if the action was not applied e.g the request was cancelled\n * immediately after sending, in which case the action will be applied in the subsequent request)\n */\n public setList(key: string, list: MSC3575List): Promise<string> {\n const existingList = this.lists.get(key);\n if (existingList) {\n existingList.replaceList(list);\n this.lists.set(key, existingList);\n } else {\n this.lists.set(key, new SlidingList(list));\n }\n this.listModifiedCount += 1;\n return this.resend();\n }\n\n /**\n * Get the room subscriptions for the sync API.\n * @returns A copy of the desired room subscriptions.\n */\n public getRoomSubscriptions(): Set<string> {\n return new Set(Array.from(this.desiredRoomSubscriptions));\n }\n\n /**\n * Modify the room subscriptions for the sync API. Calling this function will interrupt the\n * /sync request to resend new subscriptions. If the /sync stream has not started, this will\n * prepare the room subscriptions for when start() is called.\n * @param s - The new desired room subscriptions.\n * @returns A promise which resolves to the transaction ID when it has been received down sync\n * (or rejects with the transaction ID if the action was not applied e.g the request was cancelled\n * immediately after sending, in which case the action will be applied in the subsequent request)\n */\n public modifyRoomSubscriptions(s: Set<string>): Promise<string> {\n this.desiredRoomSubscriptions = s;\n return this.resend();\n }\n\n /**\n * Modify which events to retrieve for room subscriptions. Invalidates all room subscriptions\n * such that they will be sent up afresh.\n * @param rs - The new room subscription fields to fetch.\n * @returns A promise which resolves to the transaction ID when it has been received down sync\n * (or rejects with the transaction ID if the action was not applied e.g the request was cancelled\n * immediately after sending, in which case the action will be applied in the subsequent request)\n */\n public modifyRoomSubscriptionInfo(rs: MSC3575RoomSubscription): Promise<string> {\n this.roomSubscriptionInfo = rs;\n this.confirmedRoomSubscriptions = new Set<string>();\n return this.resend();\n }\n\n /**\n * Register an extension to send with the /sync request.\n * @param ext - The extension to register.\n */\n public registerExtension(ext: Extension<any, any>): void {\n if (this.extensions[ext.name()]) {\n throw new Error(`registerExtension: ${ext.name()} already exists as an extension`);\n }\n this.extensions[ext.name()] = ext;\n }\n\n private getExtensionRequest(isInitial: boolean): Record<string, object | undefined> {\n const ext: Record<string, object | undefined> = {};\n Object.keys(this.extensions).forEach((extName) => {\n ext[extName] = this.extensions[extName].onRequest(isInitial);\n });\n return ext;\n }\n\n private async onPreExtensionsResponse(ext: Record<string, object>): Promise<void> {\n await Promise.all(\n Object.keys(ext).map(async (extName) => {\n if (this.extensions[extName].when() == ExtensionState.PreProcess) {\n await this.extensions[extName].onResponse(ext[extName]);\n }\n }),\n );\n }\n\n private async onPostExtensionsResponse(ext: Record<string, object>): Promise<void> {\n await Promise.all(\n Object.keys(ext).map(async (extName) => {\n if (this.extensions[extName].when() == ExtensionState.PostProcess) {\n await this.extensions[extName].onResponse(ext[extName]);\n }\n }),\n );\n }\n\n /**\n * Invoke all attached room data listeners.\n * @param roomId - The room which received some data.\n * @param roomData - The raw sliding sync response JSON.\n */\n private async invokeRoomDataListeners(roomId: string, roomData: MSC3575RoomData): Promise<void> {\n if (!roomData.required_state) {\n roomData.required_state = [];\n }\n if (!roomData.timeline) {\n roomData.timeline = [];\n }\n await this.emitPromised(SlidingSyncEvent.RoomData, roomId, roomData);\n }\n\n /**\n * Invoke all attached lifecycle listeners.\n * @param state - The Lifecycle state\n * @param resp - The raw sync response JSON\n * @param err - Any error that occurred when making the request e.g. network errors.\n */\n private invokeLifecycleListeners(\n state: SlidingSyncState,\n resp: MSC3575SlidingSyncResponse | null,\n err?: Error,\n ): void {\n this.emit(SlidingSyncEvent.Lifecycle, state, resp, err);\n }\n\n private shiftRight(listKey: string, hi: number, low: number): void {\n const list = this.lists.get(listKey);\n if (!list) {\n return;\n }\n // l h\n // 0,1,2,3,4 <- before\n // 0,1,2,2,3 <- after, hi is deleted and low is duplicated\n for (let i = hi; i > low; i--) {\n if (list.isIndexInRange(i)) {\n list.roomIndexToRoomId[i] = list.roomIndexToRoomId[i - 1];\n }\n }\n }\n\n private shiftLeft(listKey: string, hi: number, low: number): void {\n const list = this.lists.get(listKey);\n if (!list) {\n return;\n }\n // l h\n // 0,1,2,3,4 <- before\n // 0,1,3,4,4 <- after, low is deleted and hi is duplicated\n for (let i = low; i < hi; i++) {\n if (list.isIndexInRange(i)) {\n list.roomIndexToRoomId[i] = list.roomIndexToRoomId[i + 1];\n }\n }\n }\n\n private removeEntry(listKey: string, index: number): void {\n const list = this.lists.get(listKey);\n if (!list) {\n return;\n }\n // work out the max index\n let max = -1;\n for (const n in list.roomIndexToRoomId) {\n if (Number(n) > max) {\n max = Number(n);\n }\n }\n if (max < 0 || index > max) {\n return;\n }\n // Everything higher than the gap needs to be shifted left.\n this.shiftLeft(listKey, max, index);\n delete list.roomIndexToRoomId[max];\n }\n\n private addEntry(listKey: string, index: number): void {\n const list = this.lists.get(listKey);\n if (!list) {\n return;\n }\n // work out the max index\n let max = -1;\n for (const n in list.roomIndexToRoomId) {\n if (Number(n) > max) {\n max = Number(n);\n }\n }\n if (max < 0 || index > max) {\n return;\n }\n // Everything higher than the gap needs to be shifted right, +1 so we don't delete the highest element\n this.shiftRight(listKey, max + 1, index);\n }\n\n private processListOps(list: ListResponse, listKey: string): void {\n let gapIndex = -1;\n const listData = this.lists.get(listKey);\n if (!listData) {\n return;\n }\n list.ops.forEach((op: Operation) => {\n if (!listData) {\n return;\n }\n switch (op.op) {\n case \"DELETE\": {\n logger.debug(\"DELETE\", listKey, op.index, \";\");\n delete listData.roomIndexToRoomId[op.index];\n if (gapIndex !== -1) {\n // we already have a DELETE operation to process, so process it.\n this.removeEntry(listKey, gapIndex);\n }\n gapIndex = op.index;\n break;\n }\n case \"INSERT\": {\n logger.debug(\"INSERT\", listKey, op.index, op.room_id, \";\");\n if (listData.roomIndexToRoomId[op.index]) {\n // something is in this space, shift items out of the way\n if (gapIndex < 0) {\n // we haven't been told where to shift from, so make way for a new room entry.\n this.addEntry(listKey, op.index);\n } else if (gapIndex > op.index) {\n // the gap is further down the list, shift every element to the right\n // starting at the gap so we can just shift each element in turn:\n // [A,B,C,_] gapIndex=3, op.index=0\n // [A,B,C,C] i=3\n // [A,B,B,C] i=2\n // [A,A,B,C] i=1\n // Terminate. We'll assign into op.index next.\n this.shiftRight(listKey, gapIndex, op.index);\n } else if (gapIndex < op.index) {\n // the gap is further up the list, shift every element to the left\n // starting at the gap so we can just shift each element in turn\n this.shiftLeft(listKey, op.index, gapIndex);\n }\n }\n // forget the gap, we don't need it anymore. This is outside the check for\n // a room being present in this index position because INSERTs always universally\n // forget the gap, not conditionally based on the presence of a room in the INSERT\n // position. Without this, DELETE 0; INSERT 0; would do the wrong thing.\n gapIndex = -1;\n listData.roomIndexToRoomId[op.index] = op.room_id;\n break;\n }\n case \"INVALIDATE\": {\n const startIndex = op.range[0];\n for (let i = startIndex; i <= op.range[1]; i++) {\n delete listData.roomIndexToRoomId[i];\n }\n logger.debug(\"INVALIDATE\", listKey, op.range[0], op.range[1], \";\");\n break;\n }\n case \"SYNC\": {\n const startIndex = op.range[0];\n for (let i = startIndex; i <= op.range[1]; i++) {\n const roomId = op.room_ids[i - startIndex];\n if (!roomId) {\n break; // we are at the end of list\n }\n listData.roomIndexToRoomId[i] = roomId;\n }\n logger.debug(\"SYNC\", listKey, op.range[0], op.range[1], (op.room_ids || []).join(\" \"), \";\");\n break;\n }\n }\n });\n if (gapIndex !== -1) {\n // we already have a DELETE operation to process, so process it\n // Everything higher than the gap needs to be shifted left.\n this.removeEntry(listKey, gapIndex);\n }\n }\n\n /**\n * Resend a Sliding Sync request. Used when something has changed in the request. Resolves with\n * the transaction ID of this request on success. Rejects with the transaction ID of this request\n * on failure.\n */\n public resend(): Promise<string> {\n if (this.needsResend && this.txnIdDefers.length > 0) {\n // we already have a resend queued, so just return the same promise\n return this.txnIdDefers[this.txnIdDefers.length - 1].promise;\n }\n this.needsResend = true;\n this.txnId = this.client.makeTxnId();\n const d = defer<string>();\n this.txnIdDefers.push({\n ...d,\n txnId: this.txnId,\n });\n this.abortController?.abort();\n this.abortController = new AbortController();\n return d.promise;\n }\n\n private resolveTransactionDefers(txnId?: string): void {\n if (!txnId) {\n return;\n }\n // find the matching index\n let txnIndex = -1;\n for (let i = 0; i < this.txnIdDefers.length; i++) {\n if (this.txnIdDefers[i].txnId === txnId) {\n txnIndex = i;\n break;\n }\n }\n if (txnIndex === -1) {\n // this shouldn't happen; we shouldn't be seeing txn_ids for things we don't know about,\n // whine about it.\n logger.warn(`resolveTransactionDefers: seen ${txnId} but it isn't a pending txn, ignoring.`);\n return;\n }\n // This list is sorted in time, so if the input txnId ACKs in the middle of this array,\n // then everything before it that hasn't been ACKed yet never will and we should reject them.\n for (let i = 0; i < txnIndex; i++) {\n this.txnIdDefers[i].reject(this.txnIdDefers[i].txnId);\n }\n this.txnIdDefers[txnIndex].resolve(txnId);\n // clear out settled promises, including the one we resolved.\n this.txnIdDefers = this.txnIdDefers.slice(txnIndex + 1);\n }\n\n /**\n * Stop syncing with the server.\n */\n public stop(): void {\n this.terminated = true;\n this.abortController?.abort();\n // remove all listeners so things can be GC'd\n this.removeAllListeners(SlidingSyncEvent.Lifecycle);\n this.removeAllListeners(SlidingSyncEvent.List);\n this.removeAllListeners(SlidingSyncEvent.RoomData);\n }\n\n /**\n * Re-setup this connection e.g in the event of an expired session.\n */\n private resetup(): void {\n logger.warn(\"SlidingSync: resetting connection info\");\n // any pending txn ID defers will be forgotten already by the server, so clear them out\n this.txnIdDefers.forEach((d) => {\n d.reject(d.txnId);\n });\n this.txnIdDefers = [];\n // resend sticky params and de-confirm all subscriptions\n this.lists.forEach((l) => {\n l.setModified(true);\n });\n this.confirmedRoomSubscriptions = new Set<string>(); // leave desired ones alone though!\n // reset the connection as we might be wedged\n this.needsResend = true;\n this.abortController?.abort();\n this.abortController = new AbortController();\n }\n\n /**\n * Start syncing with the server. Blocks until stopped.\n */\n public async start(): Promise<void> {\n this.abortController = new AbortController();\n\n let currentPos: string | undefined;\n while (!this.terminated) {\n this.needsResend = false;\n let doNotUpdateList = false;\n let resp: MSC3575SlidingSyncResponse | undefined;\n try {\n const listModifiedCount = this.listModifiedCount;\n const reqLists: Record<string, MSC3575List> = {};\n this.lists.forEach((l: SlidingList, key: string) => {\n reqLists[key] = l.getList(false);\n });\n const reqBody: MSC3575SlidingSyncRequest = {\n lists: reqLists,\n pos: currentPos,\n timeout: this.timeoutMS,\n clientTimeout: this.timeoutMS + BUFFER_PERIOD_MS,\n extensions: this.getExtensionRequest(currentPos === undefined),\n };\n // check if we are (un)subscribing to a room and modify request this one time for it\n const newSubscriptions = difference(this.desiredRoomSubscriptions, this.confirmedRoomSubscriptions);\n const unsubscriptions = difference(this.confirmedRoomSubscriptions, this.desiredRoomSubscriptions);\n if (unsubscriptions.size > 0) {\n reqBody.unsubscribe_rooms = Array.from(unsubscriptions);\n }\n if (newSubscriptions.size > 0) {\n reqBody.room_subscriptions = {};\n for (const roomId of newSubscriptions) {\n const customSubName = this.roomIdToCustomSubscription.get(roomId);\n let sub = this.roomSubscriptionInfo;\n if (customSubName && this.customSubscriptions.has(customSubName)) {\n sub = this.customSubscriptions.get(customSubName)!;\n }\n reqBody.room_subscriptions[roomId] = sub;\n }\n }\n if (this.txnId) {\n reqBody.txn_id = this.txnId;\n this.txnId = null;\n }\n this.pendingReq = this.client.slidingSync(reqBody, this.proxyBaseUrl, this.abortController.signal);\n resp = await this.pendingReq;\n currentPos = resp.pos;\n // update what we think we're subscribed to.\n for (const roomId of newSubscriptions) {\n this.confirmedRoomSubscriptions.add(roomId);\n }\n for (const roomId of unsubscriptions) {\n this.confirmedRoomSubscriptions.delete(roomId);\n }\n if (listModifiedCount !== this.listModifiedCount) {\n // the lists have been modified whilst we were waiting for 'await' to return, but the abort()\n // call did nothing. It is NOT SAFE to modify the list array now. We'll process the response but\n // not update list pointers.\n logger.debug(\"list modified during await call, not updating list\");\n doNotUpdateList = true;\n }\n // mark all these lists as having been sent as sticky so we don't keep sending sticky params\n this.lists.forEach((l) => {\n l.setModified(false);\n });\n // set default empty values so we don't need to null check\n resp.lists = resp.lists || {};\n resp.rooms = resp.rooms || {};\n resp.extensions = resp.extensions || {};\n Object.keys(resp.lists).forEach((key: string) => {\n const list = this.lists.get(key);\n if (!list || !resp) {\n return;\n }\n list.joinedCount = resp.lists[key].count;\n });\n this.invokeLifecycleListeners(SlidingSyncState.RequestFinished, resp);\n } catch (err) {\n if ((<HTTPError>err).httpStatus) {\n this.invokeLifecycleListeners(SlidingSyncState.RequestFinished, null, <Error>err);\n if ((<HTTPError>err).httpStatus === 400) {\n // session probably expired TODO: assign an errcode\n // so drop state and re-request\n this.resetup();\n currentPos = undefined;\n await sleep(50); // in case the 400 was for something else; don't tightloop\n continue;\n } // else fallthrough to generic error handling\n } else if (this.needsResend || (<Error>err).name === \"AbortError\") {\n continue; // don't sleep as we caused this error by abort()ing the request.\n }\n logger.error(err);\n await sleep(5000);\n }\n if (!resp) {\n continue;\n }\n await this.onPreExtensionsResponse(resp.extensions);\n\n for (const roomId in resp.rooms) {\n await this.invokeRoomDataListeners(roomId, resp!.rooms[roomId]);\n }\n\n const listKeysWithUpdates: Set<string> = new Set();\n if (!doNotUpdateList) {\n for (const [key, list] of Object.entries(resp.lists)) {\n list.ops = list.ops || [];\n if (list.ops.length > 0) {\n listKeysWithUpdates.add(key);\n }\n this.processListOps(list, key);\n }\n }\n this.invokeLifecycleListeners(SlidingSyncState.Complete, resp);\n await this.onPostExtensionsResponse(resp.extensions);\n listKeysWithUpdates.forEach((listKey: string) => {\n const list = this.lists.get(listKey);\n if (!list) {\n return;\n }\n this.emit(SlidingSyncEvent.List, listKey, list.joinedCount, Object.assign({}, list.roomIndexToRoomId));\n });\n\n this.resolveTransactionDefers(resp.txn_id);\n }\n }\n}\n\nconst difference = (setA: Set<string>, setB: Set<string>): Set<string> => {\n const diff = new Set(setA);\n for (const elem of setB) {\n diff.delete(elem);\n }\n return diff;\n};\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,QAAQ,aAAa;AAGpC,SAASC,iBAAiB,QAAQ,iCAAiC;AACnE,SAASC,KAAK,EAAaC,KAAK,QAAQ,YAAY;AAGpD;AACA;AACA;AACA;AACA,IAAMC,gBAAgB,GAAG,EAAE,GAAG,IAAI;AAElC,OAAO,IAAMC,gBAAgB,GAAG,GAAG;AACnC,OAAO,IAAMC,oBAAoB,GAAG,KAAK;AACzC,OAAO,IAAMC,sBAAsB,GAAG,OAAO;;AAE7C;AACA;AACA;;AAOA;AACA;AACA;;AAaA;AACA;AACA;;AAQA;AACA;AACA;;AAgEA;AACA;AACA;;AASA,WAAYC,gBAAgB,0BAAhBA,gBAAgB;EAA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ACC,MAAM,CAAC,CAAC,CAAC,EAAEjD,IAAI,CAACa,iBAAiB,CAAC,CAAC;UAC1G,CAAC,CAAC;UAEF6I,MAAI,CAACb,wBAAwB,CAACvC,IAAI,CAACqE,MAAM,CAAC;QAC9C,CAAC;QAAAa,IAAA;MAtHD,OAAO,CAAC9B,MAAI,CAACP,UAAU;QAAAqC,IAAA,UAAA5B,KAAA;QAAA,IAAA4B,IAAA,QAgFP;MAAS;IAsCxB;EACL;AACJ;AAEA,IAAMnB,UAAU,GAAGA,CAACoB,IAAiB,EAAEC,IAAiB,KAAkB;EACtE,IAAMC,IAAI,GAAG,IAAI/J,GAAG,CAAC6J,IAAI,CAAC;EAC1B,KAAK,IAAMG,IAAI,IAAIF,IAAI,EAAE;IACrBC,IAAI,CAAC9I,MAAM,CAAC+I,IAAI,CAAC;EACrB;EACA,OAAOD,IAAI;AACf,CAAC","ignoreList":[]}
|
1
|
+
{"version":3,"file":"sliding-sync.js","names":["logger","TypedEventEmitter","sleep","defer","BUFFER_PERIOD_MS","MSC3575_WILDCARD","MSC3575_STATE_KEY_ME","MSC3575_STATE_KEY_LAZY","SlidingSyncState","SlidingList","constructor","list","_defineProperty","replaceList","setModified","modified","isModified","updateListRange","newRanges","ranges","JSON","parse","stringify","_list$filters","_list$ranges","filters","roomIndexToRoomId","joinedCount","getList","forceIncludeAllParams","isIndexInRange","i","r","ExtensionState","SlidingSyncEvent","SlidingSync","proxyBaseUrl","lists","roomSubscriptionInfo","client","timeoutMS","Set","Map","forEach","key","set","addCustomSubscription","name","sub","customSubscriptions","has","warn","concat","useCustomSubscription","roomId","roomIdToCustomSubscription","get","confirmedRoomSubscriptions","delete","getListData","data","Object","assign","getListParams","params","setListRanges","Promise","reject","Error","resend","setList","existingList","listModifiedCount","getRoomSubscriptions","Array","from","desiredRoomSubscriptions","modifyRoomSubscriptions","s","modifyRoomSubscriptionInfo","rs","registerExtension","ext","extensions","getExtensionRequest","isInitial","keys","extName","onRequest","onPreExtensionsResponse","_this","_asyncToGenerator","all","map","_ref","when","PreProcess","onResponse","_x","apply","arguments","onPostExtensionsResponse","_this2","_ref2","PostProcess","_x2","invokeRoomDataListeners","roomData","_this3","required_state","timeline","emitPromised","RoomData","invokeLifecycleListeners","state","resp","err","emit","Lifecycle","shiftRight","listKey","hi","low","shiftLeft","removeEntry","index","max","n","Number","addEntry","processListOps","gapIndex","listData","ops","op","debug","room_id","startIndex","range","room_ids","join","_this$abortController","needsResend","txnIdDefers","length","promise","txnId","makeTxnId","d","push","_objectSpread","abortController","abort","AbortController","resolveTransactionDefers","txnIndex","resolve","slice","stop","_this$abortController2","terminated","removeAllListeners","List","resetup","_this$abortController3","l","start","_this4","currentPos","_loop","doNotUpdateList","_resp$lists","_resp$rooms","_resp$extensions","reqLists","reqBody","pos","timeout","clientTimeout","undefined","newSubscriptions","difference","unsubscriptions","size","unsubscribe_rooms","room_subscriptions","customSubName","txn_id","pendingReq","slidingSync","signal","add","rooms","count","RequestFinished","httpStatus","error","listKeysWithUpdates","entries","_list$ops","Complete","_ret","setA","setB","diff","elem"],"sources":["../src/sliding-sync.ts"],"sourcesContent":["/*\nCopyright 2022 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 { logger } from \"./logger.ts\";\nimport { MatrixClient } from \"./client.ts\";\nimport { IRoomEvent, IStateEvent } from \"./sync-accumulator.ts\";\nimport { TypedEventEmitter } from \"./models/typed-event-emitter.ts\";\nimport { sleep, IDeferred, defer } from \"./utils.ts\";\nimport { HTTPError } from \"./http-api/index.ts\";\n\n// /sync requests allow you to set a timeout= but the request may continue\n// beyond that and wedge forever, so we need to track how long we are willing\n// to keep open the connection. This constant is *ADDED* to the timeout= value\n// to determine the max time we're willing to wait.\nconst BUFFER_PERIOD_MS = 10 * 1000;\n\nexport const MSC3575_WILDCARD = \"*\";\nexport const MSC3575_STATE_KEY_ME = \"$ME\";\nexport const MSC3575_STATE_KEY_LAZY = \"$LAZY\";\n\n/**\n * Represents a subscription to a room or set of rooms. Controls which events are returned.\n */\nexport interface MSC3575RoomSubscription {\n required_state?: string[][];\n timeline_limit?: number;\n include_old_rooms?: MSC3575RoomSubscription;\n}\n\n/**\n * Controls which rooms are returned in a given list.\n */\nexport interface MSC3575Filter {\n is_dm?: boolean;\n is_encrypted?: boolean;\n is_invite?: boolean;\n room_name_like?: string;\n room_types?: string[];\n not_room_types?: string[];\n spaces?: string[];\n tags?: string[];\n not_tags?: string[];\n}\n\n/**\n * Represents a list subscription.\n */\nexport interface MSC3575List extends MSC3575RoomSubscription {\n ranges: number[][];\n sort?: string[];\n filters?: MSC3575Filter;\n slow_get_all_rooms?: boolean;\n}\n\n/**\n * A complete Sliding Sync request.\n */\nexport interface MSC3575SlidingSyncRequest {\n // json body params\n lists?: Record<string, MSC3575List>;\n unsubscribe_rooms?: string[];\n room_subscriptions?: Record<string, MSC3575RoomSubscription>;\n extensions?: object;\n txn_id?: string;\n\n // query params\n pos?: string;\n timeout?: number;\n clientTimeout?: number;\n}\n\nexport interface MSC3575RoomData {\n name: string;\n required_state: IStateEvent[];\n timeline: (IRoomEvent | IStateEvent)[];\n notification_count?: number;\n highlight_count?: number;\n joined_count?: number;\n invited_count?: number;\n invite_state?: IStateEvent[];\n initial?: boolean;\n limited?: boolean;\n is_dm?: boolean;\n prev_batch?: string;\n num_live?: number;\n}\n\ninterface ListResponse {\n count: number;\n ops: Operation[];\n}\n\ninterface BaseOperation {\n op: string;\n}\n\ninterface DeleteOperation extends BaseOperation {\n op: \"DELETE\";\n index: number;\n}\n\ninterface InsertOperation extends BaseOperation {\n op: \"INSERT\";\n index: number;\n room_id: string;\n}\n\ninterface InvalidateOperation extends BaseOperation {\n op: \"INVALIDATE\";\n range: [number, number];\n}\n\ninterface SyncOperation extends BaseOperation {\n op: \"SYNC\";\n range: [number, number];\n room_ids: string[];\n}\n\ntype Operation = DeleteOperation | InsertOperation | InvalidateOperation | SyncOperation;\n\n/**\n * A complete Sliding Sync response\n */\nexport interface MSC3575SlidingSyncResponse {\n pos: string;\n txn_id?: string;\n lists: Record<string, ListResponse>;\n rooms: Record<string, MSC3575RoomData>;\n extensions: Record<string, object>;\n}\n\nexport enum SlidingSyncState {\n /**\n * Fired by SlidingSyncEvent.Lifecycle event immediately before processing the response.\n */\n RequestFinished = \"FINISHED\",\n /**\n * Fired by SlidingSyncEvent.Lifecycle event immediately after all room data listeners have been\n * invoked, but before list listeners.\n */\n Complete = \"COMPLETE\",\n}\n\n/**\n * Internal Class. SlidingList represents a single list in sliding sync. The list can have filters,\n * multiple sliding windows, and maintains the index-\\>room_id mapping.\n */\nclass SlidingList {\n private list!: MSC3575List;\n private isModified?: boolean;\n\n // returned data\n public roomIndexToRoomId: Record<number, string> = {};\n public joinedCount = 0;\n\n /**\n * Construct a new sliding list.\n * @param list - The range, sort and filter values to use for this list.\n */\n public constructor(list: MSC3575List) {\n this.replaceList(list);\n }\n\n /**\n * Mark this list as modified or not. Modified lists will return sticky params with calls to getList.\n * This is useful for the first time the list is sent, or if the list has changed in some way.\n * @param modified - True to mark this list as modified so all sticky parameters will be re-sent.\n */\n public setModified(modified: boolean): void {\n this.isModified = modified;\n }\n\n /**\n * Update the list range for this list. Does not affect modified status as list ranges are non-sticky.\n * @param newRanges - The new ranges for the list\n */\n public updateListRange(newRanges: number[][]): void {\n this.list.ranges = JSON.parse(JSON.stringify(newRanges));\n }\n\n /**\n * Replace list parameters. All fields will be replaced with the new list parameters.\n * @param list - The new list parameters\n */\n public replaceList(list: MSC3575List): void {\n list.filters = list.filters ?? {};\n list.ranges = list.ranges ?? [];\n this.list = JSON.parse(JSON.stringify(list));\n this.isModified = true;\n\n // reset values as the join count may be very different (if filters changed) including the rooms\n // (e.g. sort orders or sliding window ranges changed)\n\n // the constantly changing sliding window ranges. Not an array for performance reasons\n // E.g. tracking ranges 0-99, 500-599, we don't want to have a 600 element array\n this.roomIndexToRoomId = {};\n // the total number of joined rooms according to the server, always >= len(roomIndexToRoomId)\n this.joinedCount = 0;\n }\n\n /**\n * Return a copy of the list suitable for a request body.\n * @param forceIncludeAllParams - True to forcibly include all params even if the list\n * hasn't been modified. Callers may want to do this if they are modifying the list prior to calling\n * updateList.\n */\n public getList(forceIncludeAllParams: boolean): MSC3575List {\n let list = {\n ranges: JSON.parse(JSON.stringify(this.list.ranges)),\n };\n if (this.isModified || forceIncludeAllParams) {\n list = JSON.parse(JSON.stringify(this.list));\n }\n return list;\n }\n\n /**\n * Check if a given index is within the list range. This is required even though the /sync API\n * provides explicit updates with index positions because of the following situation:\n * 0 1 2 3 4 5 6 7 8 indexes\n * a b c d e f COMMANDS: SYNC 0 2 a b c; SYNC 6 8 d e f;\n * a b c d _ f COMMAND: DELETE 7;\n * e a b c d f COMMAND: INSERT 0 e;\n * c=3 is wrong as we are not tracking it, ergo we need to see if `i` is in range else drop it\n * @param i - The index to check\n * @returns True if the index is within a sliding window\n */\n public isIndexInRange(i: number): boolean {\n for (const r of this.list.ranges) {\n if (r[0] <= i && i <= r[1]) {\n return true;\n }\n }\n return false;\n }\n}\n\n/**\n * When onResponse extensions should be invoked: before or after processing the main response.\n */\nexport enum ExtensionState {\n // Call onResponse before processing the response body. This is useful when your extension is\n // preparing the ground for the response body e.g. processing to-device messages before the\n // encrypted event arrives.\n PreProcess = \"ExtState.PreProcess\",\n // Call onResponse after processing the response body. This is useful when your extension is\n // decorating data from the client, and you rely on MatrixClient.getRoom returning the Room object\n // e.g. room account data.\n PostProcess = \"ExtState.PostProcess\",\n}\n\n/**\n * An interface that must be satisfied to register extensions\n */\nexport interface Extension<Req extends {}, Res extends {}> {\n /**\n * The extension name to go under 'extensions' in the request body.\n * @returns The JSON key.\n */\n name(): string;\n /**\n * A function which is called when the request JSON is being formed.\n * Returns the data to insert under this key.\n * @param isInitial - True when this is part of the initial request (send sticky params)\n * @returns The request JSON to send.\n */\n onRequest(isInitial: boolean): Req | undefined;\n /**\n * A function which is called when there is response JSON under this extension.\n * @param data - The response JSON under the extension name.\n */\n onResponse(data: Res): Promise<void>;\n /**\n * Controls when onResponse should be called.\n * @returns The state when it should be called.\n */\n when(): ExtensionState;\n}\n\n/**\n * Events which can be fired by the SlidingSync class. These are designed to provide different levels\n * of information when processing sync responses.\n * - RoomData: concerns rooms, useful for SlidingSyncSdk to update its knowledge of rooms.\n * - Lifecycle: concerns callbacks at various well-defined points in the sync process.\n * - List: concerns lists, useful for UI layers to re-render room lists.\n * Specifically, the order of event invocation is:\n * - Lifecycle (state=RequestFinished)\n * - RoomData (N times)\n * - Lifecycle (state=Complete)\n * - List (at most once per list)\n */\nexport enum SlidingSyncEvent {\n /**\n * This event fires when there are updates for a room. Fired as and when rooms are encountered\n * in the response.\n */\n RoomData = \"SlidingSync.RoomData\",\n /**\n * This event fires at various points in the /sync loop lifecycle.\n * - SlidingSyncState.RequestFinished: Fires after we receive a valid response but before the\n * response has been processed. Perform any pre-process steps here. If there was a problem syncing,\n * `err` will be set (e.g network errors).\n * - SlidingSyncState.Complete: Fires after all SlidingSyncEvent.RoomData have been fired but before\n * SlidingSyncEvent.List.\n */\n Lifecycle = \"SlidingSync.Lifecycle\",\n /**\n * This event fires whenever there has been a change to this list index. It fires exactly once\n * per list, even if there were multiple operations for the list.\n * It fires AFTER Lifecycle and RoomData events.\n */\n List = \"SlidingSync.List\",\n}\n\nexport type SlidingSyncEventHandlerMap = {\n [SlidingSyncEvent.RoomData]: (roomId: string, roomData: MSC3575RoomData) => Promise<void> | void;\n [SlidingSyncEvent.Lifecycle]: (\n state: SlidingSyncState,\n resp: MSC3575SlidingSyncResponse | null,\n err?: Error,\n ) => void;\n [SlidingSyncEvent.List]: (listKey: string, joinedCount: number, roomIndexToRoomId: Record<number, string>) => void;\n};\n\n/**\n * SlidingSync is a high-level data structure which controls the majority of sliding sync.\n * It has no hooks into JS SDK except for needing a MatrixClient to perform the HTTP request.\n * This means this class (and everything it uses) can be used in isolation from JS SDK if needed.\n * To hook this up with the JS SDK, you need to use SlidingSyncSdk.\n */\nexport class SlidingSync extends TypedEventEmitter<SlidingSyncEvent, SlidingSyncEventHandlerMap> {\n private lists: Map<string, SlidingList>;\n private listModifiedCount = 0;\n private terminated = false;\n // flag set when resend() is called because we cannot rely on detecting AbortError in JS SDK :(\n private needsResend = false;\n // the txn_id to send with the next request.\n private txnId: string | null = null;\n // a list (in chronological order of when they were sent) of objects containing the txn ID and\n // a defer to resolve/reject depending on whether they were successfully sent or not.\n private txnIdDefers: (IDeferred<string> & { txnId: string })[] = [];\n // map of extension name to req/resp handler\n private extensions: Record<string, Extension<any, any>> = {};\n\n private desiredRoomSubscriptions = new Set<string>(); // the *desired* room subscriptions\n private confirmedRoomSubscriptions = new Set<string>();\n\n // map of custom subscription name to the subscription\n private customSubscriptions: Map<string, MSC3575RoomSubscription> = new Map();\n // map of room ID to custom subscription name\n private roomIdToCustomSubscription: Map<string, string> = new Map();\n\n private pendingReq?: Promise<MSC3575SlidingSyncResponse>;\n private abortController?: AbortController;\n\n /**\n * Create a new sliding sync instance\n * @param proxyBaseUrl - The base URL of the sliding sync proxy\n * @param lists - The lists to use for sliding sync.\n * @param roomSubscriptionInfo - The params to use for room subscriptions.\n * @param client - The client to use for /sync calls.\n * @param timeoutMS - The number of milliseconds to wait for a response.\n */\n public constructor(\n private readonly proxyBaseUrl: string,\n lists: Map<string, MSC3575List>,\n private roomSubscriptionInfo: MSC3575RoomSubscription,\n private readonly client: MatrixClient,\n private readonly timeoutMS: number,\n ) {\n super();\n this.lists = new Map<string, SlidingList>();\n lists.forEach((list, key) => {\n this.lists.set(key, new SlidingList(list));\n });\n }\n\n /**\n * Add a custom room subscription, referred to by an arbitrary name. If a subscription with this\n * name already exists, it is replaced. No requests are sent by calling this method.\n * @param name - The name of the subscription. Only used to reference this subscription in\n * useCustomSubscription.\n * @param sub - The subscription information.\n */\n public addCustomSubscription(name: string, sub: MSC3575RoomSubscription): void {\n if (this.customSubscriptions.has(name)) {\n logger.warn(`addCustomSubscription: ${name} already exists as a custom subscription, ignoring.`);\n return;\n }\n this.customSubscriptions.set(name, sub);\n }\n\n /**\n * Use a custom subscription previously added via addCustomSubscription. No requests are sent\n * by calling this method. Use modifyRoomSubscriptions to resend subscription information.\n * @param roomId - The room to use the subscription in.\n * @param name - The name of the subscription. If this name is unknown, the default subscription\n * will be used.\n */\n public useCustomSubscription(roomId: string, name: string): void {\n // We already know about this custom subscription, as it is immutable,\n // we don't need to unconfirm the subscription.\n if (this.roomIdToCustomSubscription.get(roomId) === name) {\n return;\n }\n this.roomIdToCustomSubscription.set(roomId, name);\n // unconfirm this subscription so a resend() will send it up afresh.\n this.confirmedRoomSubscriptions.delete(roomId);\n }\n\n /**\n * Get the room index data for a list.\n * @param key - The list key\n * @returns The list data which contains the rooms in this list\n */\n public getListData(key: string): { joinedCount: number; roomIndexToRoomId: Record<number, string> } | null {\n const data = this.lists.get(key);\n if (!data) {\n return null;\n }\n return {\n joinedCount: data.joinedCount,\n roomIndexToRoomId: Object.assign({}, data.roomIndexToRoomId),\n };\n }\n\n /**\n * Get the full request list parameters for a list index. This function is provided for callers to use\n * in conjunction with setList to update fields on an existing list.\n * @param key - The list key to get the params for.\n * @returns A copy of the list params or undefined.\n */\n public getListParams(key: string): MSC3575List | null {\n const params = this.lists.get(key);\n if (!params) {\n return null;\n }\n return params.getList(true);\n }\n\n /**\n * Set new ranges for an existing list. Calling this function when _only_ the ranges have changed\n * is more efficient than calling setList(index,list) as this function won't resend sticky params,\n * whereas setList always will.\n * @param key - The list key to modify\n * @param ranges - The new ranges to apply.\n * @returns A promise which resolves to the transaction ID when it has been received down sync\n * (or rejects with the transaction ID if the action was not applied e.g the request was cancelled\n * immediately after sending, in which case the action will be applied in the subsequent request)\n */\n public setListRanges(key: string, ranges: number[][]): Promise<string> {\n const list = this.lists.get(key);\n if (!list) {\n return Promise.reject(new Error(\"no list with key \" + key));\n }\n list.updateListRange(ranges);\n return this.resend();\n }\n\n /**\n * Add or replace a list. Calling this function will interrupt the /sync request to resend new\n * lists.\n * @param key - The key to modify\n * @param list - The new list parameters.\n * @returns A promise which resolves to the transaction ID when it has been received down sync\n * (or rejects with the transaction ID if the action was not applied e.g the request was cancelled\n * immediately after sending, in which case the action will be applied in the subsequent request)\n */\n public setList(key: string, list: MSC3575List): Promise<string> {\n const existingList = this.lists.get(key);\n if (existingList) {\n existingList.replaceList(list);\n this.lists.set(key, existingList);\n } else {\n this.lists.set(key, new SlidingList(list));\n }\n this.listModifiedCount += 1;\n return this.resend();\n }\n\n /**\n * Get the room subscriptions for the sync API.\n * @returns A copy of the desired room subscriptions.\n */\n public getRoomSubscriptions(): Set<string> {\n return new Set(Array.from(this.desiredRoomSubscriptions));\n }\n\n /**\n * Modify the room subscriptions for the sync API. Calling this function will interrupt the\n * /sync request to resend new subscriptions. If the /sync stream has not started, this will\n * prepare the room subscriptions for when start() is called.\n * @param s - The new desired room subscriptions.\n * @returns A promise which resolves to the transaction ID when it has been received down sync\n * (or rejects with the transaction ID if the action was not applied e.g the request was cancelled\n * immediately after sending, in which case the action will be applied in the subsequent request)\n */\n public modifyRoomSubscriptions(s: Set<string>): Promise<string> {\n this.desiredRoomSubscriptions = s;\n return this.resend();\n }\n\n /**\n * Modify which events to retrieve for room subscriptions. Invalidates all room subscriptions\n * such that they will be sent up afresh.\n * @param rs - The new room subscription fields to fetch.\n * @returns A promise which resolves to the transaction ID when it has been received down sync\n * (or rejects with the transaction ID if the action was not applied e.g the request was cancelled\n * immediately after sending, in which case the action will be applied in the subsequent request)\n */\n public modifyRoomSubscriptionInfo(rs: MSC3575RoomSubscription): Promise<string> {\n this.roomSubscriptionInfo = rs;\n this.confirmedRoomSubscriptions = new Set<string>();\n return this.resend();\n }\n\n /**\n * Register an extension to send with the /sync request.\n * @param ext - The extension to register.\n */\n public registerExtension(ext: Extension<any, any>): void {\n if (this.extensions[ext.name()]) {\n throw new Error(`registerExtension: ${ext.name()} already exists as an extension`);\n }\n this.extensions[ext.name()] = ext;\n }\n\n private getExtensionRequest(isInitial: boolean): Record<string, object | undefined> {\n const ext: Record<string, object | undefined> = {};\n Object.keys(this.extensions).forEach((extName) => {\n ext[extName] = this.extensions[extName].onRequest(isInitial);\n });\n return ext;\n }\n\n private async onPreExtensionsResponse(ext: Record<string, object>): Promise<void> {\n await Promise.all(\n Object.keys(ext).map(async (extName) => {\n if (this.extensions[extName].when() == ExtensionState.PreProcess) {\n await this.extensions[extName].onResponse(ext[extName]);\n }\n }),\n );\n }\n\n private async onPostExtensionsResponse(ext: Record<string, object>): Promise<void> {\n await Promise.all(\n Object.keys(ext).map(async (extName) => {\n if (this.extensions[extName].when() == ExtensionState.PostProcess) {\n await this.extensions[extName].onResponse(ext[extName]);\n }\n }),\n );\n }\n\n /**\n * Invoke all attached room data listeners.\n * @param roomId - The room which received some data.\n * @param roomData - The raw sliding sync response JSON.\n */\n private async invokeRoomDataListeners(roomId: string, roomData: MSC3575RoomData): Promise<void> {\n if (!roomData.required_state) {\n roomData.required_state = [];\n }\n if (!roomData.timeline) {\n roomData.timeline = [];\n }\n await this.emitPromised(SlidingSyncEvent.RoomData, roomId, roomData);\n }\n\n /**\n * Invoke all attached lifecycle listeners.\n * @param state - The Lifecycle state\n * @param resp - The raw sync response JSON\n * @param err - Any error that occurred when making the request e.g. network errors.\n */\n private invokeLifecycleListeners(\n state: SlidingSyncState,\n resp: MSC3575SlidingSyncResponse | null,\n err?: Error,\n ): void {\n this.emit(SlidingSyncEvent.Lifecycle, state, resp, err);\n }\n\n private shiftRight(listKey: string, hi: number, low: number): void {\n const list = this.lists.get(listKey);\n if (!list) {\n return;\n }\n // l h\n // 0,1,2,3,4 <- before\n // 0,1,2,2,3 <- after, hi is deleted and low is duplicated\n for (let i = hi; i > low; i--) {\n if (list.isIndexInRange(i)) {\n list.roomIndexToRoomId[i] = list.roomIndexToRoomId[i - 1];\n }\n }\n }\n\n private shiftLeft(listKey: string, hi: number, low: number): void {\n const list = this.lists.get(listKey);\n if (!list) {\n return;\n }\n // l h\n // 0,1,2,3,4 <- before\n // 0,1,3,4,4 <- after, low is deleted and hi is duplicated\n for (let i = low; i < hi; i++) {\n if (list.isIndexInRange(i)) {\n list.roomIndexToRoomId[i] = list.roomIndexToRoomId[i + 1];\n }\n }\n }\n\n private removeEntry(listKey: string, index: number): void {\n const list = this.lists.get(listKey);\n if (!list) {\n return;\n }\n // work out the max index\n let max = -1;\n for (const n in list.roomIndexToRoomId) {\n if (Number(n) > max) {\n max = Number(n);\n }\n }\n if (max < 0 || index > max) {\n return;\n }\n // Everything higher than the gap needs to be shifted left.\n this.shiftLeft(listKey, max, index);\n delete list.roomIndexToRoomId[max];\n }\n\n private addEntry(listKey: string, index: number): void {\n const list = this.lists.get(listKey);\n if (!list) {\n return;\n }\n // work out the max index\n let max = -1;\n for (const n in list.roomIndexToRoomId) {\n if (Number(n) > max) {\n max = Number(n);\n }\n }\n if (max < 0 || index > max) {\n return;\n }\n // Everything higher than the gap needs to be shifted right, +1 so we don't delete the highest element\n this.shiftRight(listKey, max + 1, index);\n }\n\n private processListOps(list: ListResponse, listKey: string): void {\n let gapIndex = -1;\n const listData = this.lists.get(listKey);\n if (!listData) {\n return;\n }\n list.ops.forEach((op: Operation) => {\n if (!listData) {\n return;\n }\n switch (op.op) {\n case \"DELETE\": {\n logger.debug(\"DELETE\", listKey, op.index, \";\");\n delete listData.roomIndexToRoomId[op.index];\n if (gapIndex !== -1) {\n // we already have a DELETE operation to process, so process it.\n this.removeEntry(listKey, gapIndex);\n }\n gapIndex = op.index;\n break;\n }\n case \"INSERT\": {\n logger.debug(\"INSERT\", listKey, op.index, op.room_id, \";\");\n if (listData.roomIndexToRoomId[op.index]) {\n // something is in this space, shift items out of the way\n if (gapIndex < 0) {\n // we haven't been told where to shift from, so make way for a new room entry.\n this.addEntry(listKey, op.index);\n } else if (gapIndex > op.index) {\n // the gap is further down the list, shift every element to the right\n // starting at the gap so we can just shift each element in turn:\n // [A,B,C,_] gapIndex=3, op.index=0\n // [A,B,C,C] i=3\n // [A,B,B,C] i=2\n // [A,A,B,C] i=1\n // Terminate. We'll assign into op.index next.\n this.shiftRight(listKey, gapIndex, op.index);\n } else if (gapIndex < op.index) {\n // the gap is further up the list, shift every element to the left\n // starting at the gap so we can just shift each element in turn\n this.shiftLeft(listKey, op.index, gapIndex);\n }\n }\n // forget the gap, we don't need it anymore. This is outside the check for\n // a room being present in this index position because INSERTs always universally\n // forget the gap, not conditionally based on the presence of a room in the INSERT\n // position. Without this, DELETE 0; INSERT 0; would do the wrong thing.\n gapIndex = -1;\n listData.roomIndexToRoomId[op.index] = op.room_id;\n break;\n }\n case \"INVALIDATE\": {\n const startIndex = op.range[0];\n for (let i = startIndex; i <= op.range[1]; i++) {\n delete listData.roomIndexToRoomId[i];\n }\n logger.debug(\"INVALIDATE\", listKey, op.range[0], op.range[1], \";\");\n break;\n }\n case \"SYNC\": {\n const startIndex = op.range[0];\n for (let i = startIndex; i <= op.range[1]; i++) {\n const roomId = op.room_ids[i - startIndex];\n if (!roomId) {\n break; // we are at the end of list\n }\n listData.roomIndexToRoomId[i] = roomId;\n }\n logger.debug(\"SYNC\", listKey, op.range[0], op.range[1], (op.room_ids || []).join(\" \"), \";\");\n break;\n }\n }\n });\n if (gapIndex !== -1) {\n // we already have a DELETE operation to process, so process it\n // Everything higher than the gap needs to be shifted left.\n this.removeEntry(listKey, gapIndex);\n }\n }\n\n /**\n * Resend a Sliding Sync request. Used when something has changed in the request. Resolves with\n * the transaction ID of this request on success. Rejects with the transaction ID of this request\n * on failure.\n */\n public resend(): Promise<string> {\n if (this.needsResend && this.txnIdDefers.length > 0) {\n // we already have a resend queued, so just return the same promise\n return this.txnIdDefers[this.txnIdDefers.length - 1].promise;\n }\n this.needsResend = true;\n this.txnId = this.client.makeTxnId();\n const d = defer<string>();\n this.txnIdDefers.push({\n ...d,\n txnId: this.txnId,\n });\n this.abortController?.abort();\n this.abortController = new AbortController();\n return d.promise;\n }\n\n private resolveTransactionDefers(txnId?: string): void {\n if (!txnId) {\n return;\n }\n // find the matching index\n let txnIndex = -1;\n for (let i = 0; i < this.txnIdDefers.length; i++) {\n if (this.txnIdDefers[i].txnId === txnId) {\n txnIndex = i;\n break;\n }\n }\n if (txnIndex === -1) {\n // this shouldn't happen; we shouldn't be seeing txn_ids for things we don't know about,\n // whine about it.\n logger.warn(`resolveTransactionDefers: seen ${txnId} but it isn't a pending txn, ignoring.`);\n return;\n }\n // This list is sorted in time, so if the input txnId ACKs in the middle of this array,\n // then everything before it that hasn't been ACKed yet never will and we should reject them.\n for (let i = 0; i < txnIndex; i++) {\n this.txnIdDefers[i].reject(this.txnIdDefers[i].txnId);\n }\n this.txnIdDefers[txnIndex].resolve(txnId);\n // clear out settled promises, including the one we resolved.\n this.txnIdDefers = this.txnIdDefers.slice(txnIndex + 1);\n }\n\n /**\n * Stop syncing with the server.\n */\n public stop(): void {\n this.terminated = true;\n this.abortController?.abort();\n // remove all listeners so things can be GC'd\n this.removeAllListeners(SlidingSyncEvent.Lifecycle);\n this.removeAllListeners(SlidingSyncEvent.List);\n this.removeAllListeners(SlidingSyncEvent.RoomData);\n }\n\n /**\n * Re-setup this connection e.g in the event of an expired session.\n */\n private resetup(): void {\n logger.warn(\"SlidingSync: resetting connection info\");\n // any pending txn ID defers will be forgotten already by the server, so clear them out\n this.txnIdDefers.forEach((d) => {\n d.reject(d.txnId);\n });\n this.txnIdDefers = [];\n // resend sticky params and de-confirm all subscriptions\n this.lists.forEach((l) => {\n l.setModified(true);\n });\n this.confirmedRoomSubscriptions = new Set<string>(); // leave desired ones alone though!\n // reset the connection as we might be wedged\n this.needsResend = true;\n this.abortController?.abort();\n this.abortController = new AbortController();\n }\n\n /**\n * Start syncing with the server. Blocks until stopped.\n */\n public async start(): Promise<void> {\n this.abortController = new AbortController();\n\n let currentPos: string | undefined;\n while (!this.terminated) {\n this.needsResend = false;\n let doNotUpdateList = false;\n let resp: MSC3575SlidingSyncResponse | undefined;\n try {\n const listModifiedCount = this.listModifiedCount;\n const reqLists: Record<string, MSC3575List> = {};\n this.lists.forEach((l: SlidingList, key: string) => {\n reqLists[key] = l.getList(false);\n });\n const reqBody: MSC3575SlidingSyncRequest = {\n lists: reqLists,\n pos: currentPos,\n timeout: this.timeoutMS,\n clientTimeout: this.timeoutMS + BUFFER_PERIOD_MS,\n extensions: this.getExtensionRequest(currentPos === undefined),\n };\n // check if we are (un)subscribing to a room and modify request this one time for it\n const newSubscriptions = difference(this.desiredRoomSubscriptions, this.confirmedRoomSubscriptions);\n const unsubscriptions = difference(this.confirmedRoomSubscriptions, this.desiredRoomSubscriptions);\n if (unsubscriptions.size > 0) {\n reqBody.unsubscribe_rooms = Array.from(unsubscriptions);\n }\n if (newSubscriptions.size > 0) {\n reqBody.room_subscriptions = {};\n for (const roomId of newSubscriptions) {\n const customSubName = this.roomIdToCustomSubscription.get(roomId);\n let sub = this.roomSubscriptionInfo;\n if (customSubName && this.customSubscriptions.has(customSubName)) {\n sub = this.customSubscriptions.get(customSubName)!;\n }\n reqBody.room_subscriptions[roomId] = sub;\n }\n }\n if (this.txnId) {\n reqBody.txn_id = this.txnId;\n this.txnId = null;\n }\n this.pendingReq = this.client.slidingSync(reqBody, this.proxyBaseUrl, this.abortController.signal);\n resp = await this.pendingReq;\n currentPos = resp.pos;\n // update what we think we're subscribed to.\n for (const roomId of newSubscriptions) {\n this.confirmedRoomSubscriptions.add(roomId);\n }\n for (const roomId of unsubscriptions) {\n this.confirmedRoomSubscriptions.delete(roomId);\n }\n if (listModifiedCount !== this.listModifiedCount) {\n // the lists have been modified whilst we were waiting for 'await' to return, but the abort()\n // call did nothing. It is NOT SAFE to modify the list array now. We'll process the response but\n // not update list pointers.\n logger.debug(\"list modified during await call, not updating list\");\n doNotUpdateList = true;\n }\n // mark all these lists as having been sent as sticky so we don't keep sending sticky params\n this.lists.forEach((l) => {\n l.setModified(false);\n });\n // set default empty values so we don't need to null check\n resp.lists = resp.lists ?? {};\n resp.rooms = resp.rooms ?? {};\n resp.extensions = resp.extensions ?? {};\n Object.keys(resp.lists).forEach((key: string) => {\n const list = this.lists.get(key);\n if (!list || !resp) {\n return;\n }\n list.joinedCount = resp.lists[key].count;\n });\n this.invokeLifecycleListeners(SlidingSyncState.RequestFinished, resp);\n } catch (err) {\n if ((<HTTPError>err).httpStatus) {\n this.invokeLifecycleListeners(SlidingSyncState.RequestFinished, null, <Error>err);\n if ((<HTTPError>err).httpStatus === 400) {\n // session probably expired TODO: assign an errcode\n // so drop state and re-request\n this.resetup();\n currentPos = undefined;\n await sleep(50); // in case the 400 was for something else; don't tightloop\n continue;\n } // else fallthrough to generic error handling\n } else if (this.needsResend || (<Error>err).name === \"AbortError\") {\n continue; // don't sleep as we caused this error by abort()ing the request.\n }\n logger.error(err);\n await sleep(5000);\n }\n if (!resp) {\n continue;\n }\n await this.onPreExtensionsResponse(resp.extensions);\n\n for (const roomId in resp.rooms) {\n await this.invokeRoomDataListeners(roomId, resp!.rooms[roomId]);\n }\n\n const listKeysWithUpdates: Set<string> = new Set();\n if (!doNotUpdateList) {\n for (const [key, list] of Object.entries(resp.lists)) {\n list.ops = list.ops ?? [];\n if (list.ops.length > 0) {\n listKeysWithUpdates.add(key);\n }\n this.processListOps(list, key);\n }\n }\n this.invokeLifecycleListeners(SlidingSyncState.Complete, resp);\n await this.onPostExtensionsResponse(resp.extensions);\n listKeysWithUpdates.forEach((listKey: string) => {\n const list = this.lists.get(listKey);\n if (!list) {\n return;\n }\n this.emit(SlidingSyncEvent.List, listKey, list.joinedCount, Object.assign({}, list.roomIndexToRoomId));\n });\n\n this.resolveTransactionDefers(resp.txn_id);\n }\n }\n}\n\nconst difference = (setA: Set<string>, setB: Set<string>): Set<string> => {\n const diff = new Set(setA);\n for (const elem of setB) {\n diff.delete(el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B,KAAkB;EACtE,IAAMC,IAAI,GAAG,IAAInK,GAAG,CAACiK,IAAI,CAAC;EAC1B,KAAK,IAAMG,IAAI,IAAIF,IAAI,EAAE;IACrBC,IAAI,CAAClJ,MAAM,CAACmJ,IAAI,CAAC;EACrB;EACA,OAAOD,IAAI;AACf,CAAC","ignoreList":[]}
|
@@ -69,7 +69,8 @@ function selectQuery(store, keyRange, resultMapper) {
|
|
69
69
|
return new Promise((resolve, reject) => {
|
70
70
|
var results = [];
|
71
71
|
query.onerror = () => {
|
72
|
-
|
72
|
+
var _query$error;
|
73
|
+
reject(new Error("Query failed: " + ((_query$error = query.error) === null || _query$error === void 0 ? void 0 : _query$error.name)));
|
73
74
|
};
|
74
75
|
// collect results
|
75
76
|
query.onsuccess = () => {
|
@@ -332,10 +333,11 @@ export class LocalIndexedDBStoreBackend {
|
|
332
333
|
logger.log("can't yet delete indexeddb ".concat(this.dbName, " because it is open elsewhere"));
|
333
334
|
};
|
334
335
|
req.onerror = () => {
|
336
|
+
var _req$error;
|
335
337
|
// in firefox, with indexedDB disabled, this fails with a
|
336
338
|
// DOMError. We treat this as non-fatal, so that we can still
|
337
339
|
// use the app.
|
338
|
-
logger.warn("unable to delete js-sdk store indexeddb: ".concat(req.error));
|
340
|
+
logger.warn("unable to delete js-sdk store indexeddb: ".concat((_req$error = req.error) === null || _req$error === void 0 ? void 0 : _req$error.name));
|
339
341
|
resolve();
|
340
342
|
};
|
341
343
|
req.onsuccess = () => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"indexeddb-local-backend.js","names":["SyncAccumulator","deepCopy","promiseTry","exists","idbExists","logger","DB_MIGRATIONS","db","createObjectStore","keyPath","oobMembersStore","createIndex","autoIncrement","VERSION","length","selectQuery","store","keyRange","resultMapper","query","openCursor","Promise","resolve","reject","results","onerror","Error","error","onsuccess","cursor","result","push","continue","txnAsPromise","txn","oncomplete","event","reqAsEventPromise","req","reqAsPromise","err","reqAsCursorPromise","then","LocalIndexedDBStoreBackend","indexedDB","dbName","constructor","arguments","undefined","_defineProperty","syncAccumulator","connect","onClose","_this","disconnected","log","open","onupgradeneeded","ev","oldVersion","concat","_isNewlyCreated","forEach","migration","index","onblocked","_asyncToGenerator","onversionchange","_this$db","close","onclose","init","isNewlyCreated","all","loadAccountData","loadSyncData","_ref2","accountData","syncData","accumulate","next_batch","nextBatch","rooms","roomsData","account_data","events","getOutOfBandMembers","roomId","tx","transaction","objectStore","roomIndex","range","IDBKeyRange","only","request","membershipEvents","oobWritten","record","value","oob_written","setOutOfBandMembers","_this2","e","put","markerObject","room_id","state_key","clearOutOfBandMembers","_this3","readTx","roomRange","minStateKeyProm","openKeyCursor","primaryKey","maxStateKeyProm","minStateKey","maxStateKey","writeTx","writeStore","membersKeyRange","bound","delete","clearDatabase","_this$db2","deleteDatabase","warn","getSavedSync","copy","data","getJSON","getNextBatchToken","setSyncData","syncToDatabase","userTuples","_this4","syncToDatabasePromise","pendingUserPresenceData","unshift","doSyncToDatabase","_this5","persistUserPresenceEvents","persistAccountData","persistSyncData","clobber","tuples","tuple","userId","getUserPresenceEvents","getClientOptions","_cursor$value","options","storeClientOptions","_this6","saveToDeviceBatches","batches","_this7","batch","add","getOldestToDeviceBatch","_this8","resultBatch","id","key","txnId","eventType","removeToDeviceBatch","_this9","destroy","_this10","_this10$db"],"sources":["../../src/store/indexeddb-local-backend.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 { IMinimalEvent, ISyncData, ISyncResponse, SyncAccumulator } from \"../sync-accumulator.ts\";\nimport { deepCopy, promiseTry } from \"../utils.ts\";\nimport { exists as idbExists } from \"../indexeddb-helpers.ts\";\nimport { logger } from \"../logger.ts\";\nimport { IStateEventWithRoomId, IStoredClientOpts } from \"../matrix.ts\";\nimport { ISavedSync } from \"./index.ts\";\nimport { IIndexedDBBackend, UserTuple } from \"./indexeddb-backend.ts\";\nimport { IndexedToDeviceBatch, ToDeviceBatchWithTxnId } from \"../models/ToDeviceMessage.ts\";\n\ntype DbMigration = (db: IDBDatabase) => void;\nconst DB_MIGRATIONS: DbMigration[] = [\n (db): void => {\n // Make user store, clobber based on user ID. (userId property of User objects)\n db.createObjectStore(\"users\", { keyPath: [\"userId\"] });\n\n // Make account data store, clobber based on event type.\n // (event.type property of MatrixEvent objects)\n db.createObjectStore(\"accountData\", { keyPath: [\"type\"] });\n\n // Make /sync store (sync tokens, room data, etc), always clobber (const key).\n db.createObjectStore(\"sync\", { keyPath: [\"clobber\"] });\n },\n (db): void => {\n const oobMembersStore = db.createObjectStore(\"oob_membership_events\", {\n keyPath: [\"room_id\", \"state_key\"],\n });\n oobMembersStore.createIndex(\"room\", \"room_id\");\n },\n (db): void => {\n db.createObjectStore(\"client_options\", { keyPath: [\"clobber\"] });\n },\n (db): void => {\n db.createObjectStore(\"to_device_queue\", { autoIncrement: true });\n },\n // Expand as needed.\n];\nconst VERSION = DB_MIGRATIONS.length;\n\n/**\n * Helper method to collect results from a Cursor and promiseify it.\n * @param store - The store to perform openCursor on.\n * @param keyRange - Optional key range to apply on the cursor.\n * @param resultMapper - A function which is repeatedly called with a\n * Cursor.\n * Return the data you want to keep.\n * @returns Promise which resolves to an array of whatever you returned from\n * resultMapper.\n */\nfunction selectQuery<T>(\n store: IDBObjectStore,\n keyRange: IDBKeyRange | IDBValidKey | undefined,\n resultMapper: (cursor: IDBCursorWithValue) => T,\n): Promise<T[]> {\n const query = store.openCursor(keyRange);\n return new Promise((resolve, reject) => {\n const results: T[] = [];\n query.onerror = (): void => {\n reject(new Error(\"Query failed: \" + query.error));\n };\n // collect results\n query.onsuccess = (): void => {\n const cursor = query.result;\n if (!cursor) {\n resolve(results);\n return; // end of results\n }\n results.push(resultMapper(cursor));\n cursor.continue();\n };\n });\n}\n\nfunction txnAsPromise(txn: IDBTransaction): Promise<Event> {\n return new Promise((resolve, reject) => {\n txn.oncomplete = function (event): void {\n resolve(event);\n };\n txn.onerror = function (): void {\n reject(txn.error);\n };\n });\n}\n\nfunction reqAsEventPromise(req: IDBRequest): Promise<Event> {\n return new Promise((resolve, reject) => {\n req.onsuccess = function (event): void {\n resolve(event);\n };\n req.onerror = function (): void {\n reject(req.error);\n };\n });\n}\n\nfunction reqAsPromise(req: IDBRequest): Promise<IDBRequest> {\n return new Promise((resolve, reject) => {\n req.onsuccess = (): void => resolve(req);\n req.onerror = (err): void => reject(err);\n });\n}\n\nfunction reqAsCursorPromise<T>(req: IDBRequest<T>): Promise<T> {\n return reqAsEventPromise(req).then((event) => req.result);\n}\n\nexport class LocalIndexedDBStoreBackend implements IIndexedDBBackend {\n public static exists(indexedDB: IDBFactory, dbName: string): Promise<boolean> {\n dbName = \"matrix-js-sdk:\" + (dbName || \"default\");\n return idbExists(indexedDB, dbName);\n }\n\n private readonly dbName: string;\n private readonly syncAccumulator: SyncAccumulator;\n private db?: IDBDatabase;\n private disconnected = true;\n private _isNewlyCreated = false;\n private syncToDatabasePromise?: Promise<void>;\n private pendingUserPresenceData: UserTuple[] = [];\n\n /**\n * Does the actual reading from and writing to the indexeddb\n *\n * Construct a new Indexed Database store backend. This requires a call to\n * `connect()` before this store can be used.\n * @param indexedDB - The Indexed DB interface e.g\n * `window.indexedDB`\n * @param dbName - Optional database name. The same name must be used\n * to open the same database.\n */\n public constructor(\n private readonly indexedDB: IDBFactory,\n dbName = \"default\",\n ) {\n this.dbName = \"matrix-js-sdk:\" + dbName;\n this.syncAccumulator = new SyncAccumulator();\n }\n\n /**\n * Attempt to connect to the database. This can fail if the user does not\n * grant permission.\n * @returns Promise which resolves if successfully connected.\n */\n public connect(onClose?: () => void): Promise<void> {\n if (!this.disconnected) {\n logger.log(`LocalIndexedDBStoreBackend.connect: already connected or connecting`);\n return Promise.resolve();\n }\n\n this.disconnected = false;\n\n logger.log(`LocalIndexedDBStoreBackend.connect: connecting...`);\n const req = this.indexedDB.open(this.dbName, VERSION);\n req.onupgradeneeded = (ev): void => {\n const db = req.result;\n const oldVersion = ev.oldVersion;\n logger.log(`LocalIndexedDBStoreBackend.connect: upgrading from ${oldVersion}`);\n if (oldVersion < 1) {\n // The database did not previously exist\n this._isNewlyCreated = true;\n }\n DB_MIGRATIONS.forEach((migration, index) => {\n if (oldVersion <= index) migration(db);\n });\n };\n\n req.onblocked = (): void => {\n logger.log(`can't yet open LocalIndexedDBStoreBackend because it is open elsewhere`);\n };\n\n logger.log(`LocalIndexedDBStoreBackend.connect: awaiting connection...`);\n return reqAsEventPromise(req).then(async () => {\n logger.log(`LocalIndexedDBStoreBackend.connect: connected`);\n this.db = req.result;\n\n // add a poorly-named listener for when deleteDatabase is called\n // so we can close our db connections.\n this.db.onversionchange = (): void => {\n this.db?.close(); // this does not call onclose\n this.disconnected = true;\n this.db = undefined;\n };\n this.db.onclose = (): void => {\n this.disconnected = true;\n this.db = undefined;\n onClose?.();\n };\n\n await this.init();\n });\n }\n\n /** @returns whether or not the database was newly created in this session. */\n public isNewlyCreated(): Promise<boolean> {\n return Promise.resolve(this._isNewlyCreated);\n }\n\n /**\n * Having connected, load initial data from the database and prepare for use\n * @returns Promise which resolves on success\n */\n private init(): Promise<unknown> {\n return Promise.all([this.loadAccountData(), this.loadSyncData()]).then(([accountData, syncData]) => {\n logger.log(`LocalIndexedDBStoreBackend: loaded initial data`);\n this.syncAccumulator.accumulate(\n {\n next_batch: syncData.nextBatch,\n rooms: syncData.roomsData,\n account_data: {\n events: accountData,\n },\n },\n true,\n );\n });\n }\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(roomId: string): Promise<IStateEventWithRoomId[] | null> {\n return new Promise<IStateEventWithRoomId[] | null>((resolve, reject) => {\n const tx = this.db!.transaction([\"oob_membership_events\"], \"readonly\");\n const store = tx.objectStore(\"oob_membership_events\");\n const roomIndex = store.index(\"room\");\n const range = IDBKeyRange.only(roomId);\n const request = roomIndex.openCursor(range);\n\n const membershipEvents: IStateEventWithRoomId[] = [];\n // did we encounter the oob_written marker object\n // amongst the results? That means OOB member\n // loading already happened for this room\n // but there were no members to persist as they\n // were all known already\n let oobWritten = false;\n\n request.onsuccess = (): void => {\n const cursor = request.result;\n if (!cursor) {\n // Unknown room\n if (!membershipEvents.length && !oobWritten) {\n return resolve(null);\n }\n return resolve(membershipEvents);\n }\n const record = cursor.value;\n if (record.oob_written) {\n oobWritten = true;\n } else {\n membershipEvents.push(record);\n }\n cursor.continue();\n };\n request.onerror = (err): void => {\n reject(err);\n };\n }).then((events) => {\n logger.log(`LL: got ${events?.length} membershipEvents from storage for room ${roomId} ...`);\n return events;\n });\n }\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 */\n public async setOutOfBandMembers(roomId: string, membershipEvents: IStateEventWithRoomId[]): Promise<void> {\n logger.log(`LL: backend about to store ${membershipEvents.length}` + ` members for ${roomId}`);\n const tx = this.db!.transaction([\"oob_membership_events\"], \"readwrite\");\n const store = tx.objectStore(\"oob_membership_events\");\n membershipEvents.forEach((e) => {\n store.put(e);\n });\n // aside from all the events, we also write a marker object to the store\n // to mark the fact that OOB members have been written for this room.\n // It's possible that 0 members need to be written as all where previously know\n // but we still need to know whether to return null or [] from getOutOfBandMembers\n // where null means out of band members haven't been stored yet for this room\n const markerObject = {\n room_id: roomId,\n oob_written: true,\n state_key: 0,\n };\n store.put(markerObject);\n await txnAsPromise(tx);\n logger.log(`LL: backend done storing for ${roomId}!`);\n }\n\n public async clearOutOfBandMembers(roomId: string): Promise<void> {\n // the approach to delete all members for a room\n // is to get the min and max state key from the index\n // for that room, and then delete between those\n // keys in the store.\n // this should be way faster than deleting every member\n // individually for a large room.\n const readTx = this.db!.transaction([\"oob_membership_events\"], \"readonly\");\n const store = readTx.objectStore(\"oob_membership_events\");\n const roomIndex = store.index(\"room\");\n const roomRange = IDBKeyRange.only(roomId);\n\n const minStateKeyProm = reqAsCursorPromise(roomIndex.openKeyCursor(roomRange, \"next\")).then(\n (cursor) => (<IDBValidKey[]>cursor?.primaryKey)[1],\n );\n const maxStateKeyProm = reqAsCursorPromise(roomIndex.openKeyCursor(roomRange, \"prev\")).then(\n (cursor) => (<IDBValidKey[]>cursor?.primaryKey)[1],\n );\n const [minStateKey, maxStateKey] = await Promise.all([minStateKeyProm, maxStateKeyProm]);\n\n const writeTx = this.db!.transaction([\"oob_membership_events\"], \"readwrite\");\n const writeStore = writeTx.objectStore(\"oob_membership_events\");\n const membersKeyRange = IDBKeyRange.bound([roomId, minStateKey], [roomId, maxStateKey]);\n\n logger.log(\n `LL: Deleting all users + marker in storage for room ${roomId}, with key range:`,\n [roomId, minStateKey],\n [roomId, maxStateKey],\n );\n await reqAsPromise(writeStore.delete(membersKeyRange));\n }\n\n /**\n * Clear the entire database. This should be used when logging out of a client\n * to prevent mixing data between accounts. Closes the database.\n * @returns Resolved when the database is cleared.\n */\n public clearDatabase(): Promise<void> {\n return new Promise((resolve) => {\n logger.log(`Removing indexeddb instance: ${this.dbName}`);\n\n // Close the database first to avoid firing unexpected close events\n this.db?.close();\n\n const req = this.indexedDB.deleteDatabase(this.dbName);\n\n req.onblocked = (): void => {\n logger.log(`can't yet delete indexeddb ${this.dbName} because it is open elsewhere`);\n };\n\n req.onerror = (): void => {\n // in firefox, with indexedDB disabled, this fails with a\n // DOMError. We treat this as non-fatal, so that we can still\n // use the app.\n logger.warn(`unable to delete js-sdk store indexeddb: ${req.error}`);\n resolve();\n };\n\n req.onsuccess = (): void => {\n logger.log(`Removed indexeddb instance: ${this.dbName}`);\n resolve();\n };\n });\n }\n\n /**\n * @param copy - If false, the data returned is from internal\n * buffers and must not be mutated. Otherwise, a copy is made before\n * returning such that the data can be safely mutated. Default: true.\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(copy = true): Promise<ISavedSync | null> {\n const data = this.syncAccumulator.getJSON();\n if (!data.nextBatch) return Promise.resolve(null);\n if (copy) {\n // We must deep copy the stored data so that the /sync processing code doesn't\n // corrupt the internal state of the sync accumulator (it adds non-clonable keys)\n return Promise.resolve(deepCopy(data));\n } else {\n return Promise.resolve(data);\n }\n }\n\n public getNextBatchToken(): Promise<string> {\n return Promise.resolve(this.syncAccumulator.getNextBatchToken());\n }\n\n public setSyncData(syncData: ISyncResponse): Promise<void> {\n return Promise.resolve().then(() => {\n this.syncAccumulator.accumulate(syncData);\n });\n }\n\n /**\n * Sync users and all accumulated sync data to the database.\n * If a previous sync is in flight, the new data will be added to the\n * next sync and the current sync's promise will be returned.\n * @param userTuples - The user tuples\n * @returns Promise which resolves if the data was persisted.\n */\n public async syncToDatabase(userTuples: UserTuple[]): Promise<void> {\n if (this.syncToDatabasePromise) {\n logger.warn(\"Skipping syncToDatabase() as persist already in flight\");\n this.pendingUserPresenceData.push(...userTuples);\n return this.syncToDatabasePromise;\n }\n userTuples.unshift(...this.pendingUserPresenceData);\n this.syncToDatabasePromise = this.doSyncToDatabase(userTuples);\n return this.syncToDatabasePromise;\n }\n\n private async doSyncToDatabase(userTuples: UserTuple[]): Promise<void> {\n try {\n const syncData = this.syncAccumulator.getJSON(true);\n await Promise.all([\n this.persistUserPresenceEvents(userTuples),\n this.persistAccountData(syncData.accountData),\n this.persistSyncData(syncData.nextBatch, syncData.roomsData),\n ]);\n } finally {\n this.syncToDatabasePromise = undefined;\n }\n }\n\n /**\n * Persist rooms /sync data along with the next batch token.\n * @param nextBatch - The next_batch /sync value.\n * @param roomsData - The 'rooms' /sync data from a SyncAccumulator\n * @returns Promise which resolves if the data was persisted.\n */\n private persistSyncData(nextBatch: string, roomsData: ISyncResponse[\"rooms\"]): Promise<void> {\n logger.log(\"Persisting sync data up to\", nextBatch);\n return promiseTry<void>(() => {\n const txn = this.db!.transaction([\"sync\"], \"readwrite\");\n const store = txn.objectStore(\"sync\");\n store.put({\n clobber: \"-\", // constant key so will always clobber\n nextBatch,\n roomsData,\n }); // put == UPSERT\n return txnAsPromise(txn).then(() => {\n logger.log(\"Persisted sync data up to\", nextBatch);\n });\n });\n }\n\n /**\n * Persist a list of account data events. Events with the same 'type' will\n * be replaced.\n * @param accountData - An array of raw user-scoped account data events\n * @returns Promise which resolves if the events were persisted.\n */\n private persistAccountData(accountData: IMinimalEvent[]): Promise<void> {\n return promiseTry<void>(() => {\n const txn = this.db!.transaction([\"accountData\"], \"readwrite\");\n const store = txn.objectStore(\"accountData\");\n for (const event of accountData) {\n store.put(event); // put == UPSERT\n }\n return txnAsPromise(txn).then();\n });\n }\n\n /**\n * Persist a list of [user id, presence event] they are for.\n * Users with the same 'userId' will be replaced.\n * Presence events should be the event in its raw form (not the Event\n * object)\n * @param tuples - An array of [userid, event] tuples\n * @returns Promise which resolves if the users were persisted.\n */\n private persistUserPresenceEvents(tuples: UserTuple[]): Promise<void> {\n return promiseTry<void>(() => {\n const txn = this.db!.transaction([\"users\"], \"readwrite\");\n const store = txn.objectStore(\"users\");\n for (const tuple of tuples) {\n store.put({\n userId: tuple[0],\n event: tuple[1],\n }); // put == UPSERT\n }\n return txnAsPromise(txn).then();\n });\n }\n\n /**\n * Load all user presence events from the database. This is not cached.\n * FIXME: It would probably be more sensible to store the events in the\n * sync.\n * @returns A list of presence events in their raw form.\n */\n public getUserPresenceEvents(): Promise<UserTuple[]> {\n return promiseTry<UserTuple[]>(() => {\n const txn = this.db!.transaction([\"users\"], \"readonly\");\n const store = txn.objectStore(\"users\");\n return selectQuery(store, undefined, (cursor) => {\n return [cursor.value.userId, cursor.value.event];\n });\n });\n }\n\n /**\n * Load all the account data events from the database. This is not cached.\n * @returns A list of raw global account events.\n */\n private loadAccountData(): Promise<IMinimalEvent[]> {\n logger.log(`LocalIndexedDBStoreBackend: loading account data...`);\n return promiseTry<IMinimalEvent[]>(() => {\n const txn = this.db!.transaction([\"accountData\"], \"readonly\");\n const store = txn.objectStore(\"accountData\");\n return selectQuery(store, undefined, (cursor) => {\n return cursor.value;\n }).then((result: IMinimalEvent[]) => {\n logger.log(`LocalIndexedDBStoreBackend: loaded account data`);\n return result;\n });\n });\n }\n\n /**\n * Load the sync data from the database.\n * @returns An object with \"roomsData\" and \"nextBatch\" keys.\n */\n private loadSyncData(): Promise<ISyncData> {\n logger.log(`LocalIndexedDBStoreBackend: loading sync data...`);\n return promiseTry<ISyncData>(() => {\n const txn = this.db!.transaction([\"sync\"], \"readonly\");\n const store = txn.objectStore(\"sync\");\n return selectQuery(store, undefined, (cursor) => {\n return cursor.value;\n }).then((results: ISyncData[]) => {\n logger.log(`LocalIndexedDBStoreBackend: loaded sync data`);\n if (results.length > 1) {\n logger.warn(\"loadSyncData: More than 1 sync row found.\");\n }\n return results.length > 0 ? results[0] : ({} as ISyncData);\n });\n });\n }\n\n public getClientOptions(): Promise<IStoredClientOpts | undefined> {\n return Promise.resolve().then(() => {\n const txn = this.db!.transaction([\"client_options\"], \"readonly\");\n const store = txn.objectStore(\"client_options\");\n return selectQuery(store, undefined, (cursor) => {\n return cursor.value?.options;\n }).then((results) => results[0]);\n });\n }\n\n public async storeClientOptions(options: IStoredClientOpts): Promise<void> {\n const txn = this.db!.transaction([\"client_options\"], \"readwrite\");\n const store = txn.objectStore(\"client_options\");\n store.put({\n clobber: \"-\", // constant key so will always clobber\n options: options,\n }); // put == UPSERT\n await txnAsPromise(txn);\n }\n\n public async saveToDeviceBatches(batches: ToDeviceBatchWithTxnId[]): Promise<void> {\n const txn = this.db!.transaction([\"to_device_queue\"], \"readwrite\");\n const store = txn.objectStore(\"to_device_queue\");\n for (const batch of batches) {\n store.add(batch);\n }\n await txnAsPromise(txn);\n }\n\n public async getOldestToDeviceBatch(): Promise<IndexedToDeviceBatch | null> {\n const txn = this.db!.transaction([\"to_device_queue\"], \"readonly\");\n const store = txn.objectStore(\"to_device_queue\");\n const cursor = await reqAsCursorPromise(store.openCursor());\n if (!cursor) return null;\n\n const resultBatch = cursor.value as ToDeviceBatchWithTxnId;\n\n return {\n id: cursor.key as number,\n txnId: resultBatch.txnId,\n eventType: resultBatch.eventType,\n batch: resultBatch.batch,\n };\n }\n\n public async removeToDeviceBatch(id: number): Promise<void> {\n const txn = this.db!.transaction([\"to_device_queue\"], \"readwrite\");\n const store = txn.objectStore(\"to_device_queue\");\n store.delete(id);\n await txnAsPromise(txn);\n }\n\n /*\n * Close the database\n */\n public async destroy(): Promise<void> {\n this.db?.close();\n }\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAkDA,eAAe,QAAQ,wBAAwB;AACjG,SAASC,QAAQ,EAAEC,UAAU,QAAQ,aAAa;AAClD,SAASC,MAAM,IAAIC,SAAS,QAAQ,yBAAyB;AAC7D,SAASC,MAAM,QAAQ,cAAc;AAOrC,IAAMC,aAA4B,GAAG,CAChCC,EAAE,IAAW;EACV;EACAA,EAAE,CAACC,iBAAiB,CAAC,OAAO,EAAE;IAAEC,OAAO,EAAE,CAAC,QAAQ;EAAE,CAAC,CAAC;;EAEtD;EACA;EACAF,EAAE,CAACC,iBAAiB,CAAC,aAAa,EAAE;IAAEC,OAAO,EAAE,CAAC,MAAM;EAAE,CAAC,CAAC;;EAE1D;EACAF,EAAE,CAACC,iBAAiB,CAAC,MAAM,EAAE;IAAEC,OAAO,EAAE,CAAC,SAAS;EAAE,CAAC,CAAC;AAC1D,CAAC,EACAF,EAAE,IAAW;EACV,IAAMG,eAAe,GAAGH,EAAE,CAACC,iBAAiB,CAAC,uBAAuB,E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iB,CAAC,EAAE,WAAW,CAAC;MAClE,IAAMzE,KAAK,GAAGkB,GAAG,CAACwD,WAAW,CAAC,iBAAiB,CAAC;MAChD1E,KAAK,CAAC0G,MAAM,CAACwC,EAAE,CAAC;MAChB,MAAMjI,YAAY,CAACC,GAAG,CAAC;IAAC;EAC5B;;EAEA;AACJ;AACA;EACiBsI,OAAOA,CAAA,EAAkB;IAAA,IAAAC,OAAA;IAAA,OAAAvG,iBAAA;MAAA,IAAAwG,UAAA;MAClC,CAAAA,UAAA,GAAAD,OAAI,CAAClK,EAAE,cAAAmK,UAAA,eAAPA,UAAA,CAASrG,KAAK,CAAC,CAAC;IAAC;EACrB;AACJ","ignoreList":[]}
|
1
|
+
{"version":3,"file":"indexeddb-local-backend.js","names":["SyncAccumulator","deepCopy","promiseTry","exists","idbExists","logger","DB_MIGRATIONS","db","createObjectStore","keyPath","oobMembersStore","createIndex","autoIncrement","VERSION","length","selectQuery","store","keyRange","resultMapper","query","openCursor","Promise","resolve","reject","results","onerror","_query$error","Error","error","name","onsuccess","cursor","result","push","continue","txnAsPromise","txn","oncomplete","event","reqAsEventPromise","req","reqAsPromise","err","reqAsCursorPromise","then","LocalIndexedDBStoreBackend","indexedDB","dbName","constructor","arguments","undefined","_defineProperty","syncAccumulator","connect","onClose","_this","disconnected","log","open","onupgradeneeded","ev","oldVersion","concat","_isNewlyCreated","forEach","migration","index","onblocked","_asyncToGenerator","onversionchange","_this$db","close","onclose","init","isNewlyCreated","all","loadAccountData","loadSyncData","_ref2","accountData","syncData","accumulate","next_batch","nextBatch","rooms","roomsData","account_data","events","getOutOfBandMembers","roomId","tx","transaction","objectStore","roomIndex","range","IDBKeyRange","only","request","membershipEvents","oobWritten","record","value","oob_written","setOutOfBandMembers","_this2","e","put","markerObject","room_id","state_key","clearOutOfBandMembers","_this3","readTx","roomRange","minStateKeyProm","openKeyCursor","primaryKey","maxStateKeyProm","minStateKey","maxStateKey","writeTx","writeStore","membersKeyRange","bound","delete","clearDatabase","_this$db2","deleteDatabase","_req$error","warn","getSavedSync","copy","data","getJSON","getNextBatchToken","setSyncData","syncToDatabase","userTuples","_this4","syncToDatabasePromise","pendingUserPresenceData","unshift","doSyncToDatabase","_this5","persistUserPresenceEvents","persistAccountData","persistSyncData","clobber","tuples","tuple","userId","getUserPresenceEvents","getClientOptions","_cursor$value","options","storeClientOptions","_this6","saveToDeviceBatches","batches","_this7","batch","add","getOldestToDeviceBatch","_this8","resultBatch","id","key","txnId","eventType","removeToDeviceBatch","_this9","destroy","_this10","_this10$db"],"sources":["../../src/store/indexeddb-local-backend.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 { IMinimalEvent, ISyncData, ISyncResponse, SyncAccumulator } from \"../sync-accumulator.ts\";\nimport { deepCopy, promiseTry } from \"../utils.ts\";\nimport { exists as idbExists } from \"../indexeddb-helpers.ts\";\nimport { logger } from \"../logger.ts\";\nimport { IStateEventWithRoomId, IStoredClientOpts } from \"../matrix.ts\";\nimport { ISavedSync } from \"./index.ts\";\nimport { IIndexedDBBackend, UserTuple } from \"./indexeddb-backend.ts\";\nimport { IndexedToDeviceBatch, ToDeviceBatchWithTxnId } from \"../models/ToDeviceMessage.ts\";\n\ntype DbMigration = (db: IDBDatabase) => void;\nconst DB_MIGRATIONS: DbMigration[] = [\n (db): void => {\n // Make user store, clobber based on user ID. (userId property of User objects)\n db.createObjectStore(\"users\", { keyPath: [\"userId\"] });\n\n // Make account data store, clobber based on event type.\n // (event.type property of MatrixEvent objects)\n db.createObjectStore(\"accountData\", { keyPath: [\"type\"] });\n\n // Make /sync store (sync tokens, room data, etc), always clobber (const key).\n db.createObjectStore(\"sync\", { keyPath: [\"clobber\"] });\n },\n (db): void => {\n const oobMembersStore = db.createObjectStore(\"oob_membership_events\", {\n keyPath: [\"room_id\", \"state_key\"],\n });\n oobMembersStore.createIndex(\"room\", \"room_id\");\n },\n (db): void => {\n db.createObjectStore(\"client_options\", { keyPath: [\"clobber\"] });\n },\n (db): void => {\n db.createObjectStore(\"to_device_queue\", { autoIncrement: true });\n },\n // Expand as needed.\n];\nconst VERSION = DB_MIGRATIONS.length;\n\n/**\n * Helper method to collect results from a Cursor and promiseify it.\n * @param store - The store to perform openCursor on.\n * @param keyRange - Optional key range to apply on the cursor.\n * @param resultMapper - A function which is repeatedly called with a\n * Cursor.\n * Return the data you want to keep.\n * @returns Promise which resolves to an array of whatever you returned from\n * resultMapper.\n */\nfunction selectQuery<T>(\n store: IDBObjectStore,\n keyRange: IDBKeyRange | IDBValidKey | undefined,\n resultMapper: (cursor: IDBCursorWithValue) => T,\n): Promise<T[]> {\n const query = store.openCursor(keyRange);\n return new Promise((resolve, reject) => {\n const results: T[] = [];\n query.onerror = (): void => {\n reject(new Error(\"Query failed: \" + query.error?.name));\n };\n // collect results\n query.onsuccess = (): void => {\n const cursor = query.result;\n if (!cursor) {\n resolve(results);\n return; // end of results\n }\n results.push(resultMapper(cursor));\n cursor.continue();\n };\n });\n}\n\nfunction txnAsPromise(txn: IDBTransaction): Promise<Event> {\n return new Promise((resolve, reject) => {\n txn.oncomplete = function (event): void {\n resolve(event);\n };\n txn.onerror = function (): void {\n reject(txn.error);\n };\n });\n}\n\nfunction reqAsEventPromise(req: IDBRequest): Promise<Event> {\n return new Promise((resolve, reject) => {\n req.onsuccess = function (event): void {\n resolve(event);\n };\n req.onerror = function (): void {\n reject(req.error);\n };\n });\n}\n\nfunction reqAsPromise(req: IDBRequest): Promise<IDBRequest> {\n return new Promise((resolve, reject) => {\n req.onsuccess = (): void => resolve(req);\n req.onerror = (err): void => reject(err);\n });\n}\n\nfunction reqAsCursorPromise<T>(req: IDBRequest<T>): Promise<T> {\n return reqAsEventPromise(req).then((event) => req.result);\n}\n\nexport class LocalIndexedDBStoreBackend implements IIndexedDBBackend {\n public static exists(indexedDB: IDBFactory, dbName: string): Promise<boolean> {\n dbName = \"matrix-js-sdk:\" + (dbName || \"default\");\n return idbExists(indexedDB, dbName);\n }\n\n private readonly dbName: string;\n private readonly syncAccumulator: SyncAccumulator;\n private db?: IDBDatabase;\n private disconnected = true;\n private _isNewlyCreated = false;\n private syncToDatabasePromise?: Promise<void>;\n private pendingUserPresenceData: UserTuple[] = [];\n\n /**\n * Does the actual reading from and writing to the indexeddb\n *\n * Construct a new Indexed Database store backend. This requires a call to\n * `connect()` before this store can be used.\n * @param indexedDB - The Indexed DB interface e.g\n * `window.indexedDB`\n * @param dbName - Optional database name. The same name must be used\n * to open the same database.\n */\n public constructor(\n private readonly indexedDB: IDBFactory,\n dbName = \"default\",\n ) {\n this.dbName = \"matrix-js-sdk:\" + dbName;\n this.syncAccumulator = new SyncAccumulator();\n }\n\n /**\n * Attempt to connect to the database. This can fail if the user does not\n * grant permission.\n * @returns Promise which resolves if successfully connected.\n */\n public connect(onClose?: () => void): Promise<void> {\n if (!this.disconnected) {\n logger.log(`LocalIndexedDBStoreBackend.connect: already connected or connecting`);\n return Promise.resolve();\n }\n\n this.disconnected = false;\n\n logger.log(`LocalIndexedDBStoreBackend.connect: connecting...`);\n const req = this.indexedDB.open(this.dbName, VERSION);\n req.onupgradeneeded = (ev): void => {\n const db = req.result;\n const oldVersion = ev.oldVersion;\n logger.log(`LocalIndexedDBStoreBackend.connect: upgrading from ${oldVersion}`);\n if (oldVersion < 1) {\n // The database did not previously exist\n this._isNewlyCreated = true;\n }\n DB_MIGRATIONS.forEach((migration, index) => {\n if (oldVersion <= index) migration(db);\n });\n };\n\n req.onblocked = (): void => {\n logger.log(`can't yet open LocalIndexedDBStoreBackend because it is open elsewhere`);\n };\n\n logger.log(`LocalIndexedDBStoreBackend.connect: awaiting connection...`);\n return reqAsEventPromise(req).then(async () => {\n logger.log(`LocalIndexedDBStoreBackend.connect: connected`);\n this.db = req.result;\n\n // add a poorly-named listener for when deleteDatabase is called\n // so we can close our db connections.\n this.db.onversionchange = (): void => {\n this.db?.close(); // this does not call onclose\n this.disconnected = true;\n this.db = undefined;\n };\n this.db.onclose = (): void => {\n this.disconnected = true;\n this.db = undefined;\n onClose?.();\n };\n\n await this.init();\n });\n }\n\n /** @returns whether or not the database was newly created in this session. */\n public isNewlyCreated(): Promise<boolean> {\n return Promise.resolve(this._isNewlyCreated);\n }\n\n /**\n * Having connected, load initial data from the database and prepare for use\n * @returns Promise which resolves on success\n */\n private init(): Promise<unknown> {\n return Promise.all([this.loadAccountData(), this.loadSyncData()]).then(([accountData, syncData]) => {\n logger.log(`LocalIndexedDBStoreBackend: loaded initial data`);\n this.syncAccumulator.accumulate(\n {\n next_batch: syncData.nextBatch,\n rooms: syncData.roomsData,\n account_data: {\n events: accountData,\n },\n },\n true,\n );\n });\n }\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(roomId: string): Promise<IStateEventWithRoomId[] | null> {\n return new Promise<IStateEventWithRoomId[] | null>((resolve, reject) => {\n const tx = this.db!.transaction([\"oob_membership_events\"], \"readonly\");\n const store = tx.objectStore(\"oob_membership_events\");\n const roomIndex = store.index(\"room\");\n const range = IDBKeyRange.only(roomId);\n const request = roomIndex.openCursor(range);\n\n const membershipEvents: IStateEventWithRoomId[] = [];\n // did we encounter the oob_written marker object\n // amongst the results? That means OOB member\n // loading already happened for this room\n // but there were no members to persist as they\n // were all known already\n let oobWritten = false;\n\n request.onsuccess = (): void => {\n const cursor = request.result;\n if (!cursor) {\n // Unknown room\n if (!membershipEvents.length && !oobWritten) {\n return resolve(null);\n }\n return resolve(membershipEvents);\n }\n const record = cursor.value;\n if (record.oob_written) {\n oobWritten = true;\n } else {\n membershipEvents.push(record);\n }\n cursor.continue();\n };\n request.onerror = (err): void => {\n reject(err);\n };\n }).then((events) => {\n logger.log(`LL: got ${events?.length} membershipEvents from storage for room ${roomId} ...`);\n return events;\n });\n }\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 */\n public async setOutOfBandMembers(roomId: string, membershipEvents: IStateEventWithRoomId[]): Promise<void> {\n logger.log(`LL: backend about to store ${membershipEvents.length}` + ` members for ${roomId}`);\n const tx = this.db!.transaction([\"oob_membership_events\"], \"readwrite\");\n const store = tx.objectStore(\"oob_membership_events\");\n membershipEvents.forEach((e) => {\n store.put(e);\n });\n // aside from all the events, we also write a marker object to the store\n // to mark the fact that OOB members have been written for this room.\n // It's possible that 0 members need to be written as all where previously know\n // but we still need to know whether to return null or [] from getOutOfBandMembers\n // where null means out of band members haven't been stored yet for this room\n const markerObject = {\n room_id: roomId,\n oob_written: true,\n state_key: 0,\n };\n store.put(markerObject);\n await txnAsPromise(tx);\n logger.log(`LL: backend done storing for ${roomId}!`);\n }\n\n public async clearOutOfBandMembers(roomId: string): Promise<void> {\n // the approach to delete all members for a room\n // is to get the min and max state key from the index\n // for that room, and then delete between those\n // keys in the store.\n // this should be way faster than deleting every member\n // individually for a large room.\n const readTx = this.db!.transaction([\"oob_membership_events\"], \"readonly\");\n const store = readTx.objectStore(\"oob_membership_events\");\n const roomIndex = store.index(\"room\");\n const roomRange = IDBKeyRange.only(roomId);\n\n const minStateKeyProm = reqAsCursorPromise(roomIndex.openKeyCursor(roomRange, \"next\")).then(\n (cursor) => (<IDBValidKey[]>cursor?.primaryKey)[1],\n );\n const maxStateKeyProm = reqAsCursorPromise(roomIndex.openKeyCursor(roomRange, \"prev\")).then(\n (cursor) => (<IDBValidKey[]>cursor?.primaryKey)[1],\n );\n const [minStateKey, maxStateKey] = await Promise.all([minStateKeyProm, maxStateKeyProm]);\n\n const writeTx = this.db!.transaction([\"oob_membership_events\"], \"readwrite\");\n const writeStore = writeTx.objectStore(\"oob_membership_events\");\n const membersKeyRange = IDBKeyRange.bound([roomId, minStateKey], [roomId, maxStateKey]);\n\n logger.log(\n `LL: Deleting all users + marker in storage for room ${roomId}, with key range:`,\n [roomId, minStateKey],\n [roomId, maxStateKey],\n );\n await reqAsPromise(writeStore.delete(membersKeyRange));\n }\n\n /**\n * Clear the entire database. This should be used when logging out of a client\n * to prevent mixing data between accounts. Closes the database.\n * @returns Resolved when the database is cleared.\n */\n public clearDatabase(): Promise<void> {\n return new Promise((resolve) => {\n logger.log(`Removing indexeddb instance: ${this.dbName}`);\n\n // Close the database first to avoid firing unexpected close events\n this.db?.close();\n\n const req = this.indexedDB.deleteDatabase(this.dbName);\n\n req.onblocked = (): void => {\n logger.log(`can't yet delete indexeddb ${this.dbName} because it is open elsewhere`);\n };\n\n req.onerror = (): void => {\n // in firefox, with indexedDB disabled, this fails with a\n // DOMError. We treat this as non-fatal, so that we can still\n // use the app.\n logger.warn(`unable to delete js-sdk store indexeddb: ${req.error?.name}`);\n resolve();\n };\n\n req.onsuccess = (): void => {\n logger.log(`Removed indexeddb instance: ${this.dbName}`);\n resolve();\n };\n });\n }\n\n /**\n * @param copy - If false, the data returned is from internal\n * buffers and must not be mutated. Otherwise, a copy is made before\n * returning such that the data can be safely mutated. Default: true.\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(copy = true): Promise<ISavedSync | null> {\n const data = this.syncAccumulator.getJSON();\n if (!data.nextBatch) return Promise.resolve(null);\n if (copy) {\n // We must deep copy the stored data so that the /sync processing code doesn't\n // corrupt the internal state of the sync accumulator (it adds non-clonable keys)\n return Promise.resolve(deepCopy(data));\n } else {\n return Promise.resolve(data);\n }\n }\n\n public getNextBatchToken(): Promise<string> {\n return Promise.resolve(this.syncAccumulator.getNextBatchToken());\n }\n\n public setSyncData(syncData: ISyncResponse): Promise<void> {\n return Promise.resolve().then(() => {\n this.syncAccumulator.accumulate(syncData);\n });\n }\n\n /**\n * Sync users and all accumulated sync data to the database.\n * If a previous sync is in flight, the new data will be added to the\n * next sync and the current sync's promise will be returned.\n * @param userTuples - The user tuples\n * @returns Promise which resolves if the data was persisted.\n */\n public async syncToDatabase(userTuples: UserTuple[]): Promise<void> {\n if (this.syncToDatabasePromise) {\n logger.warn(\"Skipping syncToDatabase() as persist already in flight\");\n this.pendingUserPresenceData.push(...userTuples);\n return this.syncToDatabasePromise;\n }\n userTuples.unshift(...this.pendingUserPresenceData);\n this.syncToDatabasePromise = this.doSyncToDatabase(userTuples);\n return this.syncToDatabasePromise;\n }\n\n private async doSyncToDatabase(userTuples: UserTuple[]): Promise<void> {\n try {\n const syncData = this.syncAccumulator.getJSON(true);\n await Promise.all([\n this.persistUserPresenceEvents(userTuples),\n this.persistAccountData(syncData.accountData),\n this.persistSyncData(syncData.nextBatch, syncData.roomsData),\n ]);\n } finally {\n this.syncToDatabasePromise = undefined;\n }\n }\n\n /**\n * Persist rooms /sync data along with the next batch token.\n * @param nextBatch - The next_batch /sync value.\n * @param roomsData - The 'rooms' /sync data from a SyncAccumulator\n * @returns Promise which resolves if the data was persisted.\n */\n private persistSyncData(nextBatch: string, roomsData: ISyncResponse[\"rooms\"]): Promise<void> {\n logger.log(\"Persisting sync data up to\", nextBatch);\n return promiseTry<void>(() => {\n const txn = this.db!.transaction([\"sync\"], \"readwrite\");\n const store = txn.objectStore(\"sync\");\n store.put({\n clobber: \"-\", // constant key so will always clobber\n nextBatch,\n roomsData,\n }); // put == UPSERT\n return txnAsPromise(txn).then(() => {\n logger.log(\"Persisted sync data up to\", nextBatch);\n });\n });\n }\n\n /**\n * Persist a list of account data events. Events with the same 'type' will\n * be replaced.\n * @param accountData - An array of raw user-scoped account data events\n * @returns Promise which resolves if the events were persisted.\n */\n private persistAccountData(accountData: IMinimalEvent[]): Promise<void> {\n return promiseTry<void>(() => {\n const txn = this.db!.transaction([\"accountData\"], \"readwrite\");\n const store = txn.objectStore(\"accountData\");\n for (const event of accountData) {\n store.put(event); // put == UPSERT\n }\n return txnAsPromise(txn).then();\n });\n }\n\n /**\n * Persist a list of [user id, presence event] they are for.\n * Users with the same 'userId' will be replaced.\n * Presence events should be the event in its raw form (not the Event\n * object)\n * @param tuples - An array of [userid, event] tuples\n * @returns Promise which resolves if the users were persisted.\n */\n private persistUserPresenceEvents(tuples: UserTuple[]): Promise<void> {\n return promiseTry<void>(() => {\n const txn = this.db!.transaction([\"users\"], \"readwrite\");\n const store = txn.objectStore(\"users\");\n for (const tuple of tuples) {\n store.put({\n userId: tuple[0],\n event: tuple[1],\n }); // put == UPSERT\n }\n return txnAsPromise(txn).then();\n });\n }\n\n /**\n * Load all user presence events from the database. This is not cached.\n * FIXME: It would probably be more sensible to store the events in the\n * sync.\n * @returns A list of presence events in their raw form.\n */\n public getUserPresenceEvents(): Promise<UserTuple[]> {\n return promiseTry<UserTuple[]>(() => {\n const txn = this.db!.transaction([\"users\"], \"readonly\");\n const store = txn.objectStore(\"users\");\n return selectQuery(store, undefined, (cursor) => {\n return [cursor.value.userId, cursor.value.event];\n });\n });\n }\n\n /**\n * Load all the account data events from the database. This is not cached.\n * @returns A list of raw global account events.\n */\n private loadAccountData(): Promise<IMinimalEvent[]> {\n logger.log(`LocalIndexedDBStoreBackend: loading account data...`);\n return promiseTry<IMinimalEvent[]>(() => {\n const txn = this.db!.transaction([\"accountData\"], \"readonly\");\n const store = txn.objectStore(\"accountData\");\n return selectQuery(store, undefined, (cursor) => {\n return cursor.value;\n }).then((result: IMinimalEvent[]) => {\n logger.log(`LocalIndexedDBStoreBackend: loaded account data`);\n return result;\n });\n });\n }\n\n /**\n * Load the sync data from the database.\n * @returns An object with \"roomsData\" and \"nextBatch\" keys.\n */\n private loadSyncData(): Promise<ISyncData> {\n logger.log(`LocalIndexedDBStoreBackend: loading sync data...`);\n return promiseTry<ISyncData>(() => {\n const txn = this.db!.transaction([\"sync\"], \"readonly\");\n const store = txn.objectStore(\"sync\");\n return selectQuery(store, undefined, (cursor) => {\n return cursor.value;\n }).then((results: ISyncData[]) => {\n logger.log(`LocalIndexedDBStoreBackend: loaded sync data`);\n if (results.length > 1) {\n logger.warn(\"loadSyncData: More than 1 sync row found.\");\n }\n return results.length > 0 ? results[0] : ({} as ISyncData);\n });\n });\n }\n\n public getClientOptions(): Promise<IStoredClientOpts | undefined> {\n return Promise.resolve().then(() => {\n const txn = this.db!.transaction([\"client_options\"], \"readonly\");\n const store = txn.objectStore(\"client_options\");\n return selectQuery(store, undefined, (cursor) => {\n return cursor.value?.options;\n }).then((results) => results[0]);\n });\n }\n\n public async storeClientOptions(options: IStoredClientOpts): Promise<void> {\n const txn = this.db!.transaction([\"client_options\"], \"readwrite\");\n const store = txn.objectStore(\"client_options\");\n store.put({\n clobber: \"-\", // constant key so will always clobber\n options: options,\n }); // put == UPSERT\n await txnAsPromise(txn);\n }\n\n public async saveToDeviceBatches(batches: ToDeviceBatchWithTxnId[]): Promise<void> {\n const txn = this.db!.transaction([\"to_device_queue\"], \"readwrite\");\n const store = txn.objectStore(\"to_device_queue\");\n for (const batch of batches) {\n store.add(batch);\n }\n await txnAsPromise(txn);\n }\n\n public async getOldestToDeviceBatch(): Promise<IndexedToDeviceBatch | null> {\n const txn = this.db!.transaction([\"to_device_queue\"], \"readonly\");\n const store = txn.objectStore(\"to_device_queue\");\n const cursor = await reqAsCursorPromise(store.openCursor());\n if (!cursor) return null;\n\n const resultBatch = cursor.value as ToDeviceBatchWithTxnId;\n\n return {\n id: cursor.key as number,\n txnId: resultBatch.txnId,\n eventType: resultBatch.eventType,\n batch: resultBatch.batch,\n };\n }\n\n public async removeToDeviceBatch(id: number): Promise<void> {\n const txn = this.db!.transaction([\"to_device_queue\"], \"readwrite\");\n const store = txn.objectStore(\"to_device_queue\");\n store.delete(id);\n await txnAsPromise(txn);\n }\n\n /*\n * Close the database\n */\n public async destroy(): Promise<void> {\n this.db?.close();\n }\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAkDA,eAAe,QAAQ,wBAAwB;AACjG,SAASC,QAAQ,EAAEC,UAAU,QAAQ,aAAa;AAClD,SAASC,MAAM,IAAIC,SAAS,QAAQ,yBAAyB;AAC7D,SAASC,MAAM,QAAQ,cAAc;AAOrC,IAAMC,aAA4B,GAAG,CAChCC,EAAE,IAAW;EACV;EACAA,EAAE,CAACC,iBAAiB,CAAC,OAAO,EAAE;IAAEC,OAAO,EAAE,CAAC,QAAQ;EAAE,CAAC,CAAC;;EAEtD;EACA;EACAF,EAAE,CAACC,iBAAiB,CAAC,aAAa,EAAE;IAAEC,OAAO,EAAE,CAAC,MAAM;EAAE,CAAC,CAAC;;EAE1D;EACAF,EAAE,CAACC,iBAAiB,CAAC,MAAM,EAAE;IAAEC,OAAO,EAAE,CAAC,SAAS;EAAE,CAAC,CAAC;AAC1D,CAAC,EACAF,EAAE,IAAW;EACV,IAAMG,eAAe,GAAGH,EAAE,CAACC,iBAAiB,CAAC,uBAAuB,EAAE;IAClEC,OAAO,EAAE,CAAC,SAAS,EAAE,WAAW;EACpC,CAAC,CAAC;EACFC,eAAe,CAACC,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC;AAClD,CAAC,EACAJ,EAAE,IAAW;EACVA,EAAE,CAACC,iBAAiB,CAAC,gBAAgB,EAAE;IAAEC,OAAO,EAAE,CAAC,SAAS;EAAE,CAAC,CAAC;AACpE,CAAC,EACAF,EAAE,IAAW;EACVA,EAAE,CAACC,iBAAiB,CAAC,iBAAiB,EAAE;IAAEI,aAAa,EAAE;EAAK,CAAC,CAAC;AACpE;AACA;AAAA,CACH;AACD,IAAMC,OAAO,GAAGP,aAAa,CAACQ,MAAM;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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AA;MAClC,CAAAA,UAAA,GAAAD,OAAI,CAACrK,EAAE,cAAAsK,UAAA,eAAPA,UAAA,CAAStG,KAAK,CAAC,CAAC;IAAC;EACrB;AACJ","ignoreList":[]}
|
package/lib/store/indexeddb.d.ts
CHANGED
@@ -9,7 +9,7 @@ import { IndexedToDeviceBatch, ToDeviceBatchWithTxnId } from "../models/ToDevice
|
|
9
9
|
import { IStoredClientOpts } from "../client.ts";
|
10
10
|
interface IOpts extends IBaseOpts {
|
11
11
|
/** The Indexed DB interface e.g. `window.indexedDB` */
|
12
|
-
indexedDB
|
12
|
+
indexedDB?: IDBFactory;
|
13
13
|
/** Optional database name. The same name must be used to open the same database. */
|
14
14
|
dbName?: string;
|
15
15
|
/** Optional factory to spin up a Worker to execute the IDB transactions within. */
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"indexeddb.d.ts","sourceRoot":"","sources":["../../src/store/indexeddb.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,WAAW,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AAG9D,OAAO,EAAE,MAAM,EAAe,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAqB,MAAM,kCAAkC,CAAC;AACzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAajD,UAAU,KAAM,SAAQ,SAAS;IAC7B,uDAAuD;IACvD,SAAS,EAAE,UAAU,CAAC;
|
1
|
+
{"version":3,"file":"indexeddb.d.ts","sourceRoot":"","sources":["../../src/store/ind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