@unwanted/matrix-sdk-mini 34.12.0-1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +5910 -0
- package/LICENSE +177 -0
- package/README.md +459 -0
- package/git-revision.txt +1 -0
- package/lib/@types/AESEncryptedSecretStoragePayload.d.ts +14 -0
- package/lib/@types/AESEncryptedSecretStoragePayload.d.ts.map +1 -0
- package/lib/@types/AESEncryptedSecretStoragePayload.js +1 -0
- package/lib/@types/AESEncryptedSecretStoragePayload.js.map +1 -0
- package/lib/@types/IIdentityServerProvider.d.ts +9 -0
- package/lib/@types/IIdentityServerProvider.d.ts.map +1 -0
- package/lib/@types/IIdentityServerProvider.js +1 -0
- package/lib/@types/IIdentityServerProvider.js.map +1 -0
- package/lib/@types/PushRules.d.ts +140 -0
- package/lib/@types/PushRules.d.ts.map +1 -0
- package/lib/@types/PushRules.js +94 -0
- package/lib/@types/PushRules.js.map +1 -0
- package/lib/@types/another-json.d.js +0 -0
- package/lib/@types/another-json.d.js.map +1 -0
- package/lib/@types/auth.d.ts +208 -0
- package/lib/@types/auth.d.ts.map +1 -0
- package/lib/@types/auth.js +99 -0
- package/lib/@types/auth.js.map +1 -0
- package/lib/@types/beacon.d.ts +106 -0
- package/lib/@types/beacon.d.ts.map +1 -0
- package/lib/@types/beacon.js +119 -0
- package/lib/@types/beacon.js.map +1 -0
- package/lib/@types/common.d.ts +9 -0
- package/lib/@types/common.d.ts.map +1 -0
- package/lib/@types/common.js +1 -0
- package/lib/@types/common.js.map +1 -0
- package/lib/@types/crypto.d.ts +47 -0
- package/lib/@types/crypto.d.ts.map +1 -0
- package/lib/@types/crypto.js +1 -0
- package/lib/@types/crypto.js.map +1 -0
- package/lib/@types/event.d.ts +258 -0
- package/lib/@types/event.d.ts.map +1 -0
- package/lib/@types/event.js +239 -0
- package/lib/@types/event.js.map +1 -0
- package/lib/@types/events.d.ts +92 -0
- package/lib/@types/events.d.ts.map +1 -0
- package/lib/@types/events.js +1 -0
- package/lib/@types/events.js.map +1 -0
- package/lib/@types/extensible_events.d.ts +98 -0
- package/lib/@types/extensible_events.d.ts.map +1 -0
- package/lib/@types/extensible_events.js +116 -0
- package/lib/@types/extensible_events.js.map +1 -0
- package/lib/@types/global.d.js +20 -0
- package/lib/@types/global.d.js.map +1 -0
- package/lib/@types/local_notifications.d.ts +4 -0
- package/lib/@types/local_notifications.d.ts.map +1 -0
- package/lib/@types/local_notifications.js +1 -0
- package/lib/@types/local_notifications.js.map +1 -0
- package/lib/@types/location.d.ts +60 -0
- package/lib/@types/location.d.ts.map +1 -0
- package/lib/@types/location.js +67 -0
- package/lib/@types/location.js.map +1 -0
- package/lib/@types/matrix-sdk-crypto-wasm.d.js +1 -0
- package/lib/@types/matrix-sdk-crypto-wasm.d.js.map +1 -0
- package/lib/@types/media.d.ts +220 -0
- package/lib/@types/media.d.ts.map +1 -0
- package/lib/@types/media.js +1 -0
- package/lib/@types/media.js.map +1 -0
- package/lib/@types/membership.d.ts +41 -0
- package/lib/@types/membership.d.ts.map +1 -0
- package/lib/@types/membership.js +37 -0
- package/lib/@types/membership.js.map +1 -0
- package/lib/@types/oidc-client-ts.d.js +18 -0
- package/lib/@types/oidc-client-ts.d.js.map +1 -0
- package/lib/@types/partials.d.ts +39 -0
- package/lib/@types/partials.d.ts.map +1 -0
- package/lib/@types/partials.js +53 -0
- package/lib/@types/partials.js.map +1 -0
- package/lib/@types/polls.d.ts +88 -0
- package/lib/@types/polls.d.ts.map +1 -0
- package/lib/@types/polls.js +86 -0
- package/lib/@types/polls.js.map +1 -0
- package/lib/@types/read_receipts.d.ts +36 -0
- package/lib/@types/read_receipts.d.ts.map +1 -0
- package/lib/@types/read_receipts.js +27 -0
- package/lib/@types/read_receipts.js.map +1 -0
- package/lib/@types/registration.d.ts +85 -0
- package/lib/@types/registration.d.ts.map +1 -0
- package/lib/@types/registration.js +1 -0
- package/lib/@types/registration.js.map +1 -0
- package/lib/@types/requests.d.ts +241 -0
- package/lib/@types/requests.d.ts.map +1 -0
- package/lib/@types/requests.js +28 -0
- package/lib/@types/requests.js.map +1 -0
- package/lib/@types/search.d.ts +90 -0
- package/lib/@types/search.d.ts.map +1 -0
- package/lib/@types/search.js +30 -0
- package/lib/@types/search.js.map +1 -0
- package/lib/@types/signed.d.ts +9 -0
- package/lib/@types/signed.d.ts.map +1 -0
- package/lib/@types/signed.js +1 -0
- package/lib/@types/signed.js.map +1 -0
- package/lib/@types/spaces.d.ts +16 -0
- package/lib/@types/spaces.d.ts.map +1 -0
- package/lib/@types/spaces.js +1 -0
- package/lib/@types/spaces.js.map +1 -0
- package/lib/@types/state_events.d.ts +116 -0
- package/lib/@types/state_events.d.ts.map +1 -0
- package/lib/@types/state_events.js +1 -0
- package/lib/@types/state_events.js.map +1 -0
- package/lib/@types/synapse.d.ts +19 -0
- package/lib/@types/synapse.d.ts.map +1 -0
- package/lib/@types/synapse.js +1 -0
- package/lib/@types/synapse.js.map +1 -0
- package/lib/@types/sync.d.ts +8 -0
- package/lib/@types/sync.d.ts.map +1 -0
- package/lib/@types/sync.js +25 -0
- package/lib/@types/sync.js.map +1 -0
- package/lib/@types/threepids.d.ts +12 -0
- package/lib/@types/threepids.d.ts.map +1 -0
- package/lib/@types/threepids.js +24 -0
- package/lib/@types/threepids.js.map +1 -0
- package/lib/@types/topic.d.ts +48 -0
- package/lib/@types/topic.d.ts.map +1 -0
- package/lib/@types/topic.js +57 -0
- package/lib/@types/topic.js.map +1 -0
- package/lib/@types/uia.d.ts +12 -0
- package/lib/@types/uia.d.ts.map +1 -0
- package/lib/@types/uia.js +1 -0
- package/lib/@types/uia.js.map +1 -0
- package/lib/NamespacedValue.d.ts +33 -0
- package/lib/NamespacedValue.d.ts.map +1 -0
- package/lib/NamespacedValue.js +113 -0
- package/lib/NamespacedValue.js.map +1 -0
- package/lib/ReEmitter.d.ts +15 -0
- package/lib/ReEmitter.d.ts.map +1 -0
- package/lib/ReEmitter.js +87 -0
- package/lib/ReEmitter.js.map +1 -0
- package/lib/ToDeviceMessageQueue.d.ts +28 -0
- package/lib/ToDeviceMessageQueue.d.ts.map +1 -0
- package/lib/ToDeviceMessageQueue.js +135 -0
- package/lib/ToDeviceMessageQueue.js.map +1 -0
- package/lib/autodiscovery.d.ts +136 -0
- package/lib/autodiscovery.d.ts.map +1 -0
- package/lib/autodiscovery.js +464 -0
- package/lib/autodiscovery.js.map +1 -0
- package/lib/base64.d.ts +28 -0
- package/lib/base64.d.ts.map +1 -0
- package/lib/base64.js +88 -0
- package/lib/base64.js.map +1 -0
- package/lib/browser-index.d.ts +8 -0
- package/lib/browser-index.d.ts.map +1 -0
- package/lib/browser-index.js +35 -0
- package/lib/browser-index.js.map +1 -0
- package/lib/client.d.ts +4232 -0
- package/lib/client.d.ts.map +1 -0
- package/lib/client.js +8622 -0
- package/lib/client.js.map +1 -0
- package/lib/common-crypto/CryptoBackend.d.ts +240 -0
- package/lib/common-crypto/CryptoBackend.d.ts.map +1 -0
- package/lib/common-crypto/CryptoBackend.js +73 -0
- package/lib/common-crypto/CryptoBackend.js.map +1 -0
- package/lib/common-crypto/key-passphrase.d.ts +14 -0
- package/lib/common-crypto/key-passphrase.d.ts.map +1 -0
- package/lib/common-crypto/key-passphrase.js +33 -0
- package/lib/common-crypto/key-passphrase.js.map +1 -0
- package/lib/content-helpers.d.ts +90 -0
- package/lib/content-helpers.d.ts.map +1 -0
- package/lib/content-helpers.js +250 -0
- package/lib/content-helpers.js.map +1 -0
- package/lib/content-repo.d.ts +24 -0
- package/lib/content-repo.d.ts.map +1 -0
- package/lib/content-repo.js +104 -0
- package/lib/content-repo.js.map +1 -0
- package/lib/crypto/CrossSigning.d.ts +184 -0
- package/lib/crypto/CrossSigning.d.ts.map +1 -0
- package/lib/crypto/CrossSigning.js +718 -0
- package/lib/crypto/CrossSigning.js.map +1 -0
- package/lib/crypto/DeviceList.d.ts +216 -0
- package/lib/crypto/DeviceList.d.ts.map +1 -0
- package/lib/crypto/DeviceList.js +892 -0
- package/lib/crypto/DeviceList.js.map +1 -0
- package/lib/crypto/EncryptionSetup.d.ts +152 -0
- package/lib/crypto/EncryptionSetup.d.ts.map +1 -0
- package/lib/crypto/EncryptionSetup.js +356 -0
- package/lib/crypto/EncryptionSetup.js.map +1 -0
- package/lib/crypto/OlmDevice.d.ts +457 -0
- package/lib/crypto/OlmDevice.d.ts.map +1 -0
- package/lib/crypto/OlmDevice.js +1241 -0
- package/lib/crypto/OlmDevice.js.map +1 -0
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts +109 -0
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts.map +1 -0
- package/lib/crypto/OutgoingRoomKeyRequestManager.js +415 -0
- package/lib/crypto/OutgoingRoomKeyRequestManager.js.map +1 -0
- package/lib/crypto/RoomList.d.ts +26 -0
- package/lib/crypto/RoomList.d.ts.map +1 -0
- package/lib/crypto/RoomList.js +71 -0
- package/lib/crypto/RoomList.js.map +1 -0
- package/lib/crypto/SecretSharing.d.ts +24 -0
- package/lib/crypto/SecretSharing.d.ts.map +1 -0
- package/lib/crypto/SecretSharing.js +194 -0
- package/lib/crypto/SecretSharing.js.map +1 -0
- package/lib/crypto/SecretStorage.d.ts +55 -0
- package/lib/crypto/SecretStorage.d.ts.map +1 -0
- package/lib/crypto/SecretStorage.js +118 -0
- package/lib/crypto/SecretStorage.js.map +1 -0
- package/lib/crypto/aes.d.ts +6 -0
- package/lib/crypto/aes.d.ts.map +1 -0
- package/lib/crypto/aes.js +24 -0
- package/lib/crypto/aes.js.map +1 -0
- package/lib/crypto/algorithms/base.d.ts +156 -0
- package/lib/crypto/algorithms/base.d.ts.map +1 -0
- package/lib/crypto/algorithms/base.js +187 -0
- package/lib/crypto/algorithms/base.js.map +1 -0
- package/lib/crypto/algorithms/index.d.ts +4 -0
- package/lib/crypto/algorithms/index.d.ts.map +1 -0
- package/lib/crypto/algorithms/index.js +20 -0
- package/lib/crypto/algorithms/index.js.map +1 -0
- package/lib/crypto/algorithms/megolm.d.ts +385 -0
- package/lib/crypto/algorithms/megolm.d.ts.map +1 -0
- package/lib/crypto/algorithms/megolm.js +1822 -0
- package/lib/crypto/algorithms/megolm.js.map +1 -0
- package/lib/crypto/algorithms/olm.d.ts +5 -0
- package/lib/crypto/algorithms/olm.d.ts.map +1 -0
- package/lib/crypto/algorithms/olm.js +299 -0
- package/lib/crypto/algorithms/olm.js.map +1 -0
- package/lib/crypto/api.d.ts +32 -0
- package/lib/crypto/api.d.ts.map +1 -0
- package/lib/crypto/api.js +22 -0
- package/lib/crypto/api.js.map +1 -0
- package/lib/crypto/backup.d.ts +227 -0
- package/lib/crypto/backup.d.ts.map +1 -0
- package/lib/crypto/backup.js +824 -0
- package/lib/crypto/backup.js.map +1 -0
- package/lib/crypto/crypto.d.ts +3 -0
- package/lib/crypto/crypto.d.ts.map +1 -0
- package/lib/crypto/crypto.js +19 -0
- package/lib/crypto/crypto.js.map +1 -0
- package/lib/crypto/dehydration.d.ts +34 -0
- package/lib/crypto/dehydration.d.ts.map +1 -0
- package/lib/crypto/dehydration.js +252 -0
- package/lib/crypto/dehydration.js.map +1 -0
- package/lib/crypto/device-converter.d.ts +9 -0
- package/lib/crypto/device-converter.d.ts.map +1 -0
- package/lib/crypto/device-converter.js +42 -0
- package/lib/crypto/device-converter.js.map +1 -0
- package/lib/crypto/deviceinfo.d.ts +99 -0
- package/lib/crypto/deviceinfo.d.ts.map +1 -0
- package/lib/crypto/deviceinfo.js +148 -0
- package/lib/crypto/deviceinfo.js.map +1 -0
- package/lib/crypto/index.d.ts +1209 -0
- package/lib/crypto/index.d.ts.map +1 -0
- package/lib/crypto/index.js +4097 -0
- package/lib/crypto/index.js.map +1 -0
- package/lib/crypto/key_passphrase.d.ts +14 -0
- package/lib/crypto/key_passphrase.d.ts.map +1 -0
- package/lib/crypto/key_passphrase.js +44 -0
- package/lib/crypto/key_passphrase.js.map +1 -0
- package/lib/crypto/keybackup.d.ts +18 -0
- package/lib/crypto/keybackup.d.ts.map +1 -0
- package/lib/crypto/keybackup.js +1 -0
- package/lib/crypto/keybackup.js.map +1 -0
- package/lib/crypto/olmlib.d.ts +129 -0
- package/lib/crypto/olmlib.d.ts.map +1 -0
- package/lib/crypto/olmlib.js +492 -0
- package/lib/crypto/olmlib.js.map +1 -0
- package/lib/crypto/recoverykey.d.ts +2 -0
- package/lib/crypto/recoverykey.d.ts.map +1 -0
- package/lib/crypto/recoverykey.js +19 -0
- package/lib/crypto/recoverykey.js.map +1 -0
- package/lib/crypto/store/base.d.ts +252 -0
- package/lib/crypto/store/base.d.ts.map +1 -0
- package/lib/crypto/store/base.js +64 -0
- package/lib/crypto/store/base.js.map +1 -0
- package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts +187 -0
- package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts.map +1 -0
- package/lib/crypto/store/indexeddb-crypto-store-backend.js +1145 -0
- package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +1 -0
- package/lib/crypto/store/indexeddb-crypto-store.d.ts +432 -0
- package/lib/crypto/store/indexeddb-crypto-store.d.ts.map +1 -0
- package/lib/crypto/store/indexeddb-crypto-store.js +728 -0
- package/lib/crypto/store/indexeddb-crypto-store.js.map +1 -0
- package/lib/crypto/store/localStorage-crypto-store.d.ts +119 -0
- package/lib/crypto/store/localStorage-crypto-store.d.ts.map +1 -0
- package/lib/crypto/store/localStorage-crypto-store.js +531 -0
- package/lib/crypto/store/localStorage-crypto-store.js.map +1 -0
- package/lib/crypto/store/memory-crypto-store.d.ts +215 -0
- package/lib/crypto/store/memory-crypto-store.d.ts.map +1 -0
- package/lib/crypto/store/memory-crypto-store.js +622 -0
- package/lib/crypto/store/memory-crypto-store.js.map +1 -0
- package/lib/crypto/verification/Base.d.ts +105 -0
- package/lib/crypto/verification/Base.d.ts.map +1 -0
- package/lib/crypto/verification/Base.js +372 -0
- package/lib/crypto/verification/Base.js.map +1 -0
- package/lib/crypto/verification/Error.d.ts +35 -0
- package/lib/crypto/verification/Error.d.ts.map +1 -0
- package/lib/crypto/verification/Error.js +86 -0
- package/lib/crypto/verification/Error.js.map +1 -0
- package/lib/crypto/verification/IllegalMethod.d.ts +15 -0
- package/lib/crypto/verification/IllegalMethod.d.ts.map +1 -0
- package/lib/crypto/verification/IllegalMethod.js +43 -0
- package/lib/crypto/verification/IllegalMethod.js.map +1 -0
- package/lib/crypto/verification/QRCode.d.ts +51 -0
- package/lib/crypto/verification/QRCode.d.ts.map +1 -0
- package/lib/crypto/verification/QRCode.js +277 -0
- package/lib/crypto/verification/QRCode.js.map +1 -0
- package/lib/crypto/verification/SAS.d.ts +27 -0
- package/lib/crypto/verification/SAS.d.ts.map +1 -0
- package/lib/crypto/verification/SAS.js +485 -0
- package/lib/crypto/verification/SAS.js.map +1 -0
- package/lib/crypto/verification/SASDecimal.d.ts +8 -0
- package/lib/crypto/verification/SASDecimal.d.ts.map +1 -0
- package/lib/crypto/verification/SASDecimal.js +34 -0
- package/lib/crypto/verification/SASDecimal.js.map +1 -0
- package/lib/crypto/verification/request/Channel.d.ts +18 -0
- package/lib/crypto/verification/request/Channel.d.ts.map +1 -0
- package/lib/crypto/verification/request/Channel.js +1 -0
- package/lib/crypto/verification/request/Channel.js.map +1 -0
- package/lib/crypto/verification/request/InRoomChannel.d.ts +113 -0
- package/lib/crypto/verification/request/InRoomChannel.d.ts.map +1 -0
- package/lib/crypto/verification/request/InRoomChannel.js +351 -0
- package/lib/crypto/verification/request/InRoomChannel.js.map +1 -0
- package/lib/crypto/verification/request/ToDeviceChannel.d.ts +105 -0
- package/lib/crypto/verification/request/ToDeviceChannel.d.ts.map +1 -0
- package/lib/crypto/verification/request/ToDeviceChannel.js +328 -0
- package/lib/crypto/verification/request/ToDeviceChannel.js.map +1 -0
- package/lib/crypto/verification/request/VerificationRequest.d.ts +227 -0
- package/lib/crypto/verification/request/VerificationRequest.d.ts.map +1 -0
- package/lib/crypto/verification/request/VerificationRequest.js +937 -0
- package/lib/crypto/verification/request/VerificationRequest.js.map +1 -0
- package/lib/crypto-api/CryptoEvent.d.ts +69 -0
- package/lib/crypto-api/CryptoEvent.d.ts.map +1 -0
- package/lib/crypto-api/CryptoEvent.js +33 -0
- package/lib/crypto-api/CryptoEvent.js.map +1 -0
- package/lib/crypto-api/CryptoEventHandlerMap.d.ts +16 -0
- package/lib/crypto-api/CryptoEventHandlerMap.d.ts.map +1 -0
- package/lib/crypto-api/CryptoEventHandlerMap.js +22 -0
- package/lib/crypto-api/CryptoEventHandlerMap.js.map +1 -0
- package/lib/crypto-api/index.d.ts +978 -0
- package/lib/crypto-api/index.d.ts.map +1 -0
- package/lib/crypto-api/index.js +304 -0
- package/lib/crypto-api/index.js.map +1 -0
- package/lib/crypto-api/key-passphrase.d.ts +11 -0
- package/lib/crypto-api/key-passphrase.d.ts.map +1 -0
- package/lib/crypto-api/key-passphrase.js +51 -0
- package/lib/crypto-api/key-passphrase.js.map +1 -0
- package/lib/crypto-api/keybackup.d.ts +88 -0
- package/lib/crypto-api/keybackup.d.ts.map +1 -0
- package/lib/crypto-api/keybackup.js +1 -0
- package/lib/crypto-api/keybackup.js.map +1 -0
- package/lib/crypto-api/recovery-key.d.ts +11 -0
- package/lib/crypto-api/recovery-key.d.ts.map +1 -0
- package/lib/crypto-api/recovery-key.js +65 -0
- package/lib/crypto-api/recovery-key.js.map +1 -0
- package/lib/crypto-api/verification.d.ts +344 -0
- package/lib/crypto-api/verification.d.ts.map +1 -0
- package/lib/crypto-api/verification.js +91 -0
- package/lib/crypto-api/verification.js.map +1 -0
- package/lib/digest.d.ts +10 -0
- package/lib/digest.d.ts.map +1 -0
- package/lib/digest.js +40 -0
- package/lib/digest.js.map +1 -0
- package/lib/embedded.d.ts +143 -0
- package/lib/embedded.d.ts.map +1 -0
- package/lib/embedded.js +567 -0
- package/lib/embedded.js.map +1 -0
- package/lib/errors.d.ts +24 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +51 -0
- package/lib/errors.js.map +1 -0
- package/lib/event-mapper.d.ts +10 -0
- package/lib/event-mapper.d.ts.map +1 -0
- package/lib/event-mapper.js +81 -0
- package/lib/event-mapper.js.map +1 -0
- package/lib/extensible_events_v1/ExtensibleEvent.d.ts +38 -0
- package/lib/extensible_events_v1/ExtensibleEvent.d.ts.map +1 -0
- package/lib/extensible_events_v1/ExtensibleEvent.js +57 -0
- package/lib/extensible_events_v1/ExtensibleEvent.js.map +1 -0
- package/lib/extensible_events_v1/InvalidEventError.d.ts +7 -0
- package/lib/extensible_events_v1/InvalidEventError.d.ts.map +1 -0
- package/lib/extensible_events_v1/InvalidEventError.js +25 -0
- package/lib/extensible_events_v1/InvalidEventError.js.map +1 -0
- package/lib/extensible_events_v1/MessageEvent.d.ts +45 -0
- package/lib/extensible_events_v1/MessageEvent.d.ts.map +1 -0
- package/lib/extensible_events_v1/MessageEvent.js +134 -0
- package/lib/extensible_events_v1/MessageEvent.js.map +1 -0
- package/lib/extensible_events_v1/PollEndEvent.d.ts +33 -0
- package/lib/extensible_events_v1/PollEndEvent.d.ts.map +1 -0
- package/lib/extensible_events_v1/PollEndEvent.js +88 -0
- package/lib/extensible_events_v1/PollEndEvent.js.map +1 -0
- package/lib/extensible_events_v1/PollResponseEvent.d.ts +49 -0
- package/lib/extensible_events_v1/PollResponseEvent.d.ts.map +1 -0
- package/lib/extensible_events_v1/PollResponseEvent.js +135 -0
- package/lib/extensible_events_v1/PollResponseEvent.js.map +1 -0
- package/lib/extensible_events_v1/PollStartEvent.d.ts +71 -0
- package/lib/extensible_events_v1/PollStartEvent.d.ts.map +1 -0
- package/lib/extensible_events_v1/PollStartEvent.js +185 -0
- package/lib/extensible_events_v1/PollStartEvent.js.map +1 -0
- package/lib/extensible_events_v1/utilities.d.ts +14 -0
- package/lib/extensible_events_v1/utilities.d.ts.map +1 -0
- package/lib/extensible_events_v1/utilities.js +34 -0
- package/lib/extensible_events_v1/utilities.js.map +1 -0
- package/lib/feature.d.ts +20 -0
- package/lib/feature.d.ts.map +1 -0
- package/lib/feature.js +85 -0
- package/lib/feature.js.map +1 -0
- package/lib/filter-component.d.ts +64 -0
- package/lib/filter-component.d.ts.map +1 -0
- package/lib/filter-component.js +167 -0
- package/lib/filter-component.js.map +1 -0
- package/lib/filter.d.ts +97 -0
- package/lib/filter.d.ts.map +1 -0
- package/lib/filter.js +207 -0
- package/lib/filter.js.map +1 -0
- package/lib/http-api/errors.d.ts +80 -0
- package/lib/http-api/errors.d.ts.map +1 -0
- package/lib/http-api/errors.js +185 -0
- package/lib/http-api/errors.js.map +1 -0
- package/lib/http-api/fetch.d.ts +114 -0
- package/lib/http-api/fetch.d.ts.map +1 -0
- package/lib/http-api/fetch.js +346 -0
- package/lib/http-api/fetch.js.map +1 -0
- package/lib/http-api/index.d.ts +33 -0
- package/lib/http-api/index.d.ts.map +1 -0
- package/lib/http-api/index.js +180 -0
- package/lib/http-api/index.js.map +1 -0
- package/lib/http-api/interface.d.ts +142 -0
- package/lib/http-api/interface.d.ts.map +1 -0
- package/lib/http-api/interface.js +35 -0
- package/lib/http-api/interface.js.map +1 -0
- package/lib/http-api/method.d.ts +10 -0
- package/lib/http-api/method.d.ts.map +1 -0
- package/lib/http-api/method.js +27 -0
- package/lib/http-api/method.js.map +1 -0
- package/lib/http-api/prefix.d.ts +31 -0
- package/lib/http-api/prefix.d.ts.map +1 -0
- package/lib/http-api/prefix.js +32 -0
- package/lib/http-api/prefix.js.map +1 -0
- package/lib/http-api/utils.d.ts +37 -0
- package/lib/http-api/utils.d.ts.map +1 -0
- package/lib/http-api/utils.js +178 -0
- package/lib/http-api/utils.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +24 -0
- package/lib/index.js.map +1 -0
- package/lib/indexeddb-helpers.d.ts +10 -0
- package/lib/indexeddb-helpers.d.ts.map +1 -0
- package/lib/indexeddb-helpers.js +51 -0
- package/lib/indexeddb-helpers.js.map +1 -0
- package/lib/indexeddb-worker.d.ts +7 -0
- package/lib/indexeddb-worker.d.ts.map +1 -0
- package/lib/indexeddb-worker.js +25 -0
- package/lib/indexeddb-worker.js.map +1 -0
- package/lib/interactive-auth.d.ts +337 -0
- package/lib/interactive-auth.d.ts.map +1 -0
- package/lib/interactive-auth.js +557 -0
- package/lib/interactive-auth.js.map +1 -0
- package/lib/logger.d.ts +81 -0
- package/lib/logger.d.ts.map +1 -0
- package/lib/logger.js +139 -0
- package/lib/logger.js.map +1 -0
- package/lib/matrix.d.ts +118 -0
- package/lib/matrix.d.ts.map +1 -0
- package/lib/matrix.js +146 -0
- package/lib/matrix.js.map +1 -0
- package/lib/matrixrtc/CallMembership.d.ts +66 -0
- package/lib/matrixrtc/CallMembership.d.ts.map +1 -0
- package/lib/matrixrtc/CallMembership.js +197 -0
- package/lib/matrixrtc/CallMembership.js.map +1 -0
- package/lib/matrixrtc/LivekitFocus.d.ts +16 -0
- package/lib/matrixrtc/LivekitFocus.d.ts.map +1 -0
- package/lib/matrixrtc/LivekitFocus.js +20 -0
- package/lib/matrixrtc/LivekitFocus.js.map +1 -0
- package/lib/matrixrtc/MatrixRTCSession.d.ts +295 -0
- package/lib/matrixrtc/MatrixRTCSession.d.ts.map +1 -0
- package/lib/matrixrtc/MatrixRTCSession.js +1043 -0
- package/lib/matrixrtc/MatrixRTCSession.js.map +1 -0
- package/lib/matrixrtc/MatrixRTCSessionManager.d.ts +40 -0
- package/lib/matrixrtc/MatrixRTCSessionManager.d.ts.map +1 -0
- package/lib/matrixrtc/MatrixRTCSessionManager.js +146 -0
- package/lib/matrixrtc/MatrixRTCSessionManager.js.map +1 -0
- package/lib/matrixrtc/focus.d.ts +10 -0
- package/lib/matrixrtc/focus.d.ts.map +1 -0
- package/lib/matrixrtc/focus.js +1 -0
- package/lib/matrixrtc/focus.js.map +1 -0
- package/lib/matrixrtc/index.d.ts +7 -0
- package/lib/matrixrtc/index.d.ts.map +1 -0
- package/lib/matrixrtc/index.js +21 -0
- package/lib/matrixrtc/index.js.map +1 -0
- package/lib/matrixrtc/types.d.ts +19 -0
- package/lib/matrixrtc/types.d.ts.map +1 -0
- package/lib/matrixrtc/types.js +1 -0
- package/lib/matrixrtc/types.js.map +1 -0
- package/lib/models/MSC3089Branch.d.ts +98 -0
- package/lib/models/MSC3089Branch.d.ts.map +1 -0
- package/lib/models/MSC3089Branch.js +240 -0
- package/lib/models/MSC3089Branch.js.map +1 -0
- package/lib/models/MSC3089TreeSpace.d.ts +165 -0
- package/lib/models/MSC3089TreeSpace.d.ts.map +1 -0
- package/lib/models/MSC3089TreeSpace.js +520 -0
- package/lib/models/MSC3089TreeSpace.js.map +1 -0
- package/lib/models/ToDeviceMessage.d.ts +17 -0
- package/lib/models/ToDeviceMessage.d.ts.map +1 -0
- package/lib/models/ToDeviceMessage.js +1 -0
- package/lib/models/ToDeviceMessage.js.map +1 -0
- package/lib/models/beacon.d.ts +53 -0
- package/lib/models/beacon.d.ts.map +1 -0
- package/lib/models/beacon.js +174 -0
- package/lib/models/beacon.js.map +1 -0
- package/lib/models/compare-event-ordering.d.ts +24 -0
- package/lib/models/compare-event-ordering.d.ts.map +1 -0
- package/lib/models/compare-event-ordering.js +120 -0
- package/lib/models/compare-event-ordering.js.map +1 -0
- package/lib/models/device.d.ts +45 -0
- package/lib/models/device.d.ts.map +1 -0
- package/lib/models/device.js +77 -0
- package/lib/models/device.js.map +1 -0
- package/lib/models/event-context.d.ts +62 -0
- package/lib/models/event-context.d.ts.map +1 -0
- package/lib/models/event-context.js +113 -0
- package/lib/models/event-context.js.map +1 -0
- package/lib/models/event-status.d.ts +19 -0
- package/lib/models/event-status.d.ts.map +1 -0
- package/lib/models/event-status.js +30 -0
- package/lib/models/event-status.js.map +1 -0
- package/lib/models/event-timeline-set.d.ts +312 -0
- package/lib/models/event-timeline-set.d.ts.map +1 -0
- package/lib/models/event-timeline-set.js +813 -0
- package/lib/models/event-timeline-set.js.map +1 -0
- package/lib/models/event-timeline.d.ts +219 -0
- package/lib/models/event-timeline.d.ts.map +1 -0
- package/lib/models/event-timeline.js +455 -0
- package/lib/models/event-timeline.js.map +1 -0
- package/lib/models/event.d.ts +811 -0
- package/lib/models/event.d.ts.map +1 -0
- package/lib/models/event.js +1520 -0
- package/lib/models/event.js.map +1 -0
- package/lib/models/invites-ignorer.d.ts +136 -0
- package/lib/models/invites-ignorer.d.ts.map +1 -0
- package/lib/models/invites-ignorer.js +382 -0
- package/lib/models/invites-ignorer.js.map +1 -0
- package/lib/models/poll.d.ts +67 -0
- package/lib/models/poll.d.ts.map +1 -0
- package/lib/models/poll.js +241 -0
- package/lib/models/poll.js.map +1 -0
- package/lib/models/profile-keys.d.ts +8 -0
- package/lib/models/profile-keys.d.ts.map +1 -0
- package/lib/models/profile-keys.js +8 -0
- package/lib/models/profile-keys.js.map +1 -0
- package/lib/models/read-receipt.d.ts +115 -0
- package/lib/models/read-receipt.d.ts.map +1 -0
- package/lib/models/read-receipt.js +366 -0
- package/lib/models/read-receipt.js.map +1 -0
- package/lib/models/related-relations.d.ts +11 -0
- package/lib/models/related-relations.d.ts.map +1 -0
- package/lib/models/related-relations.js +33 -0
- package/lib/models/related-relations.js.map +1 -0
- package/lib/models/relations-container.d.ts +44 -0
- package/lib/models/relations-container.d.ts.map +1 -0
- package/lib/models/relations-container.js +132 -0
- package/lib/models/relations-container.js.map +1 -0
- package/lib/models/relations.d.ts +114 -0
- package/lib/models/relations.d.ts.map +1 -0
- package/lib/models/relations.js +354 -0
- package/lib/models/relations.js.map +1 -0
- package/lib/models/room-member.d.ts +204 -0
- package/lib/models/room-member.d.ts.map +1 -0
- package/lib/models/room-member.js +360 -0
- package/lib/models/room-member.js.map +1 -0
- package/lib/models/room-receipts.d.ts +39 -0
- package/lib/models/room-receipts.d.ts.map +1 -0
- package/lib/models/room-receipts.js +392 -0
- package/lib/models/room-receipts.js.map +1 -0
- package/lib/models/room-state.d.ts +468 -0
- package/lib/models/room-state.d.ts.map +1 -0
- package/lib/models/room-state.js +984 -0
- package/lib/models/room-state.js.map +1 -0
- package/lib/models/room-summary.d.ts +29 -0
- package/lib/models/room-summary.d.ts.map +1 -0
- package/lib/models/room-summary.js +28 -0
- package/lib/models/room-summary.js.map +1 -0
- package/lib/models/room.d.ts +1203 -0
- package/lib/models/room.d.ts.map +1 -0
- package/lib/models/room.js +3336 -0
- package/lib/models/room.js.map +1 -0
- package/lib/models/search-result.d.ts +20 -0
- package/lib/models/search-result.d.ts.map +1 -0
- package/lib/models/search-result.js +52 -0
- package/lib/models/search-result.js.map +1 -0
- package/lib/models/thread.d.ts +246 -0
- package/lib/models/thread.d.ts.map +1 -0
- package/lib/models/thread.js +861 -0
- package/lib/models/thread.js.map +1 -0
- package/lib/models/typed-event-emitter.d.ts +157 -0
- package/lib/models/typed-event-emitter.d.ts.map +1 -0
- package/lib/models/typed-event-emitter.js +227 -0
- package/lib/models/typed-event-emitter.js.map +1 -0
- package/lib/models/user.d.ts +195 -0
- package/lib/models/user.d.ts.map +1 -0
- package/lib/models/user.js +218 -0
- package/lib/models/user.js.map +1 -0
- package/lib/oidc/authorize.d.ts +90 -0
- package/lib/oidc/authorize.d.ts.map +1 -0
- package/lib/oidc/authorize.js +278 -0
- package/lib/oidc/authorize.js.map +1 -0
- package/lib/oidc/discovery.d.ts +14 -0
- package/lib/oidc/discovery.d.ts.map +1 -0
- package/lib/oidc/discovery.js +66 -0
- package/lib/oidc/discovery.js.map +1 -0
- package/lib/oidc/error.d.ts +18 -0
- package/lib/oidc/error.d.ts.map +1 -0
- package/lib/oidc/error.js +35 -0
- package/lib/oidc/error.js.map +1 -0
- package/lib/oidc/index.d.ts +17 -0
- package/lib/oidc/index.d.ts.map +1 -0
- package/lib/oidc/index.js +29 -0
- package/lib/oidc/index.js.map +1 -0
- package/lib/oidc/register.d.ts +43 -0
- package/lib/oidc/register.d.ts.map +1 -0
- package/lib/oidc/register.js +96 -0
- package/lib/oidc/register.js.map +1 -0
- package/lib/oidc/tokenRefresher.d.ts +69 -0
- package/lib/oidc/tokenRefresher.d.ts.map +1 -0
- package/lib/oidc/tokenRefresher.js +148 -0
- package/lib/oidc/tokenRefresher.js.map +1 -0
- package/lib/oidc/validate.d.ts +90 -0
- package/lib/oidc/validate.d.ts.map +1 -0
- package/lib/oidc/validate.js +194 -0
- package/lib/oidc/validate.js.map +1 -0
- package/lib/pushprocessor.d.ts +128 -0
- package/lib/pushprocessor.d.ts.map +1 -0
- package/lib/pushprocessor.js +685 -0
- package/lib/pushprocessor.js.map +1 -0
- package/lib/randomstring.d.ts +5 -0
- package/lib/randomstring.d.ts.map +1 -0
- package/lib/randomstring.js +43 -0
- package/lib/randomstring.js.map +1 -0
- package/lib/realtime-callbacks.d.ts +18 -0
- package/lib/realtime-callbacks.d.ts.map +1 -0
- package/lib/realtime-callbacks.js +177 -0
- package/lib/realtime-callbacks.js.map +1 -0
- package/lib/receipt-accumulator.d.ts +51 -0
- package/lib/receipt-accumulator.d.ts.map +1 -0
- package/lib/receipt-accumulator.js +164 -0
- package/lib/receipt-accumulator.js.map +1 -0
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts +112 -0
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts.map +1 -0
- package/lib/rendezvous/MSC4108SignInWithQR.js +392 -0
- package/lib/rendezvous/MSC4108SignInWithQR.js.map +1 -0
- package/lib/rendezvous/RendezvousChannel.d.ts +27 -0
- package/lib/rendezvous/RendezvousChannel.d.ts.map +1 -0
- package/lib/rendezvous/RendezvousChannel.js +1 -0
- package/lib/rendezvous/RendezvousChannel.js.map +1 -0
- package/lib/rendezvous/RendezvousCode.d.ts +9 -0
- package/lib/rendezvous/RendezvousCode.d.ts.map +1 -0
- package/lib/rendezvous/RendezvousCode.js +1 -0
- package/lib/rendezvous/RendezvousCode.js.map +1 -0
- package/lib/rendezvous/RendezvousError.d.ts +6 -0
- package/lib/rendezvous/RendezvousError.d.ts.map +1 -0
- package/lib/rendezvous/RendezvousError.js +23 -0
- package/lib/rendezvous/RendezvousError.js.map +1 -0
- package/lib/rendezvous/RendezvousFailureReason.d.ts +31 -0
- package/lib/rendezvous/RendezvousFailureReason.d.ts.map +1 -0
- package/lib/rendezvous/RendezvousFailureReason.js +38 -0
- package/lib/rendezvous/RendezvousFailureReason.js.map +1 -0
- package/lib/rendezvous/RendezvousIntent.d.ts +5 -0
- package/lib/rendezvous/RendezvousIntent.d.ts.map +1 -0
- package/lib/rendezvous/RendezvousIntent.js +22 -0
- package/lib/rendezvous/RendezvousIntent.js.map +1 -0
- package/lib/rendezvous/RendezvousTransport.d.ts +36 -0
- package/lib/rendezvous/RendezvousTransport.d.ts.map +1 -0
- package/lib/rendezvous/RendezvousTransport.js +1 -0
- package/lib/rendezvous/RendezvousTransport.js.map +1 -0
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts +58 -0
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts.map +1 -0
- package/lib/rendezvous/channels/MSC4108SecureChannel.js +246 -0
- package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +1 -0
- package/lib/rendezvous/channels/index.d.ts +2 -0
- package/lib/rendezvous/channels/index.d.ts.map +1 -0
- package/lib/rendezvous/channels/index.js +18 -0
- package/lib/rendezvous/channels/index.js.map +1 -0
- package/lib/rendezvous/index.d.ts +10 -0
- package/lib/rendezvous/index.d.ts.map +1 -0
- package/lib/rendezvous/index.js +23 -0
- package/lib/rendezvous/index.js.map +1 -0
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +61 -0
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts.map +1 -0
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js +253 -0
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +1 -0
- package/lib/rendezvous/transports/index.d.ts +2 -0
- package/lib/rendezvous/transports/index.d.ts.map +1 -0
- package/lib/rendezvous/transports/index.js +18 -0
- package/lib/rendezvous/transports/index.js.map +1 -0
- package/lib/room-hierarchy.d.ts +35 -0
- package/lib/room-hierarchy.d.ts.map +1 -0
- package/lib/room-hierarchy.js +136 -0
- package/lib/room-hierarchy.js.map +1 -0
- package/lib/rust-crypto/CrossSigningIdentity.d.ts +33 -0
- package/lib/rust-crypto/CrossSigningIdentity.d.ts.map +1 -0
- package/lib/rust-crypto/CrossSigningIdentity.js +157 -0
- package/lib/rust-crypto/CrossSigningIdentity.js.map +1 -0
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts +98 -0
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts.map +1 -0
- package/lib/rust-crypto/DehydratedDeviceManager.js +285 -0
- package/lib/rust-crypto/DehydratedDeviceManager.js.map +1 -0
- package/lib/rust-crypto/KeyClaimManager.d.ts +33 -0
- package/lib/rust-crypto/KeyClaimManager.d.ts.map +1 -0
- package/lib/rust-crypto/KeyClaimManager.js +82 -0
- package/lib/rust-crypto/KeyClaimManager.js.map +1 -0
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts +43 -0
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts.map +1 -0
- package/lib/rust-crypto/OutgoingRequestProcessor.js +195 -0
- package/lib/rust-crypto/OutgoingRequestProcessor.js.map +1 -0
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts +47 -0
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts.map +1 -0
- package/lib/rust-crypto/OutgoingRequestsManager.js +148 -0
- package/lib/rust-crypto/OutgoingRequestsManager.js.map +1 -0
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +120 -0
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts.map +1 -0
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +467 -0
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +1 -0
- package/lib/rust-crypto/RoomEncryptor.d.ts +98 -0
- package/lib/rust-crypto/RoomEncryptor.d.ts.map +1 -0
- package/lib/rust-crypto/RoomEncryptor.js +299 -0
- package/lib/rust-crypto/RoomEncryptor.js.map +1 -0
- package/lib/rust-crypto/backup.d.ts +254 -0
- package/lib/rust-crypto/backup.d.ts.map +1 -0
- package/lib/rust-crypto/backup.js +837 -0
- package/lib/rust-crypto/backup.js.map +1 -0
- package/lib/rust-crypto/constants.d.ts +3 -0
- package/lib/rust-crypto/constants.d.ts.map +1 -0
- package/lib/rust-crypto/constants.js +19 -0
- package/lib/rust-crypto/constants.js.map +1 -0
- package/lib/rust-crypto/device-converter.d.ts +28 -0
- package/lib/rust-crypto/device-converter.d.ts.map +1 -0
- package/lib/rust-crypto/device-converter.js +123 -0
- package/lib/rust-crypto/device-converter.js.map +1 -0
- package/lib/rust-crypto/index.d.ts +61 -0
- package/lib/rust-crypto/index.d.ts.map +1 -0
- package/lib/rust-crypto/index.js +152 -0
- package/lib/rust-crypto/index.js.map +1 -0
- package/lib/rust-crypto/libolm_migration.d.ts +81 -0
- package/lib/rust-crypto/libolm_migration.d.ts.map +1 -0
- package/lib/rust-crypto/libolm_migration.js +459 -0
- package/lib/rust-crypto/libolm_migration.js.map +1 -0
- package/lib/rust-crypto/rust-crypto.d.ts +556 -0
- package/lib/rust-crypto/rust-crypto.d.ts.map +1 -0
- package/lib/rust-crypto/rust-crypto.js +2016 -0
- package/lib/rust-crypto/rust-crypto.js.map +1 -0
- package/lib/rust-crypto/secret-storage.d.ts +22 -0
- package/lib/rust-crypto/secret-storage.d.ts.map +1 -0
- package/lib/rust-crypto/secret-storage.js +63 -0
- package/lib/rust-crypto/secret-storage.js.map +1 -0
- package/lib/rust-crypto/verification.d.ts +319 -0
- package/lib/rust-crypto/verification.d.ts.map +1 -0
- package/lib/rust-crypto/verification.js +816 -0
- package/lib/rust-crypto/verification.js.map +1 -0
- package/lib/scheduler.d.ts +132 -0
- package/lib/scheduler.d.ts.map +1 -0
- package/lib/scheduler.js +259 -0
- package/lib/scheduler.js.map +1 -0
- package/lib/secret-storage.d.ts +370 -0
- package/lib/secret-storage.d.ts.map +1 -0
- package/lib/secret-storage.js +466 -0
- package/lib/secret-storage.js.map +1 -0
- package/lib/serverCapabilities.d.ts +72 -0
- package/lib/serverCapabilities.d.ts.map +1 -0
- package/lib/serverCapabilities.js +105 -0
- package/lib/serverCapabilities.js.map +1 -0
- package/lib/service-types.d.ts +5 -0
- package/lib/service-types.d.ts.map +1 -0
- package/lib/service-types.js +22 -0
- package/lib/service-types.js.map +1 -0
- package/lib/sliding-sync-sdk.d.ts +107 -0
- package/lib/sliding-sync-sdk.d.ts.map +1 -0
- package/lib/sliding-sync-sdk.js +903 -0
- package/lib/sliding-sync-sdk.js.map +1 -0
- package/lib/sliding-sync.d.ts +343 -0
- package/lib/sliding-sync.d.ts.map +1 -0
- package/lib/sliding-sync.js +817 -0
- package/lib/sliding-sync.js.map +1 -0
- package/lib/store/index.d.ts +201 -0
- package/lib/store/index.d.ts.map +1 -0
- package/lib/store/index.js +1 -0
- package/lib/store/index.js.map +1 -0
- package/lib/store/indexeddb-backend.d.ts +24 -0
- package/lib/store/indexeddb-backend.d.ts.map +1 -0
- package/lib/store/indexeddb-backend.js +1 -0
- package/lib/store/indexeddb-backend.js.map +1 -0
- package/lib/store/indexeddb-local-backend.d.ts +129 -0
- package/lib/store/indexeddb-local-backend.d.ts.map +1 -0
- package/lib/store/indexeddb-local-backend.js +597 -0
- package/lib/store/indexeddb-local-backend.js.map +1 -0
- package/lib/store/indexeddb-remote-backend.d.ts +79 -0
- package/lib/store/indexeddb-remote-backend.d.ts.map +1 -0
- package/lib/store/indexeddb-remote-backend.js +210 -0
- package/lib/store/indexeddb-remote-backend.js.map +1 -0
- package/lib/store/indexeddb-store-worker.d.ts +35 -0
- package/lib/store/indexeddb-store-worker.d.ts.map +1 -0
- package/lib/store/indexeddb-store-worker.js +146 -0
- package/lib/store/indexeddb-store-worker.js.map +1 -0
- package/lib/store/indexeddb.d.ts +142 -0
- package/lib/store/indexeddb.d.ts.map +1 -0
- package/lib/store/indexeddb.js +347 -0
- package/lib/store/indexeddb.js.map +1 -0
- package/lib/store/local-storage-events-emitter.d.ts +30 -0
- package/lib/store/local-storage-events-emitter.d.ts.map +1 -0
- package/lib/store/local-storage-events-emitter.js +37 -0
- package/lib/store/local-storage-events-emitter.js.map +1 -0
- package/lib/store/memory.d.ts +209 -0
- package/lib/store/memory.d.ts.map +1 -0
- package/lib/store/memory.js +432 -0
- package/lib/store/memory.js.map +1 -0
- package/lib/store/stub.d.ts +161 -0
- package/lib/store/stub.d.ts.map +1 -0
- package/lib/store/stub.js +268 -0
- package/lib/store/stub.js.map +1 -0
- package/lib/sync-accumulator.d.ts +172 -0
- package/lib/sync-accumulator.d.ts.map +1 -0
- package/lib/sync-accumulator.js +532 -0
- package/lib/sync-accumulator.js.map +1 -0
- package/lib/sync.d.ts +260 -0
- package/lib/sync.d.ts.map +1 -0
- package/lib/sync.js +1686 -0
- package/lib/sync.js.map +1 -0
- package/lib/testing.d.ts +81 -0
- package/lib/testing.d.ts.map +1 -0
- package/lib/testing.js +162 -0
- package/lib/testing.js.map +1 -0
- package/lib/thread-utils.d.ts +10 -0
- package/lib/thread-utils.d.ts.map +1 -0
- package/lib/thread-utils.js +31 -0
- package/lib/thread-utils.js.map +1 -0
- package/lib/timeline-window.d.ts +168 -0
- package/lib/timeline-window.d.ts.map +1 -0
- package/lib/timeline-window.js +494 -0
- package/lib/timeline-window.js.map +1 -0
- package/lib/types.d.ts +33 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +33 -0
- package/lib/types.js.map +1 -0
- package/lib/utils/decryptAESSecretStorageItem.d.ts +12 -0
- package/lib/utils/decryptAESSecretStorageItem.d.ts.map +1 -0
- package/lib/utils/decryptAESSecretStorageItem.js +50 -0
- package/lib/utils/decryptAESSecretStorageItem.js.map +1 -0
- package/lib/utils/encryptAESSecretStorageItem.d.ts +16 -0
- package/lib/utils/encryptAESSecretStorageItem.d.ts.map +1 -0
- package/lib/utils/encryptAESSecretStorageItem.js +68 -0
- package/lib/utils/encryptAESSecretStorageItem.js.map +1 -0
- package/lib/utils/internal/deriveKeys.d.ts +10 -0
- package/lib/utils/internal/deriveKeys.d.ts.map +1 -0
- package/lib/utils/internal/deriveKeys.js +60 -0
- package/lib/utils/internal/deriveKeys.js.map +1 -0
- package/lib/utils.d.ts +267 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +749 -0
- package/lib/utils.js.map +1 -0
- package/lib/version-support.d.ts +19 -0
- package/lib/version-support.d.ts.map +1 -0
- package/lib/version-support.js +37 -0
- package/lib/version-support.js.map +1 -0
- package/lib/webrtc/audioContext.d.ts +15 -0
- package/lib/webrtc/audioContext.d.ts.map +1 -0
- package/lib/webrtc/audioContext.js +46 -0
- package/lib/webrtc/audioContext.js.map +1 -0
- package/lib/webrtc/call.d.ts +560 -0
- package/lib/webrtc/call.d.ts.map +1 -0
- package/lib/webrtc/call.js +2541 -0
- package/lib/webrtc/call.js.map +1 -0
- package/lib/webrtc/callEventHandler.d.ts +37 -0
- package/lib/webrtc/callEventHandler.d.ts.map +1 -0
- package/lib/webrtc/callEventHandler.js +344 -0
- package/lib/webrtc/callEventHandler.js.map +1 -0
- package/lib/webrtc/callEventTypes.d.ts +73 -0
- package/lib/webrtc/callEventTypes.d.ts.map +1 -0
- package/lib/webrtc/callEventTypes.js +13 -0
- package/lib/webrtc/callEventTypes.js.map +1 -0
- package/lib/webrtc/callFeed.d.ts +128 -0
- package/lib/webrtc/callFeed.d.ts.map +1 -0
- package/lib/webrtc/callFeed.js +289 -0
- package/lib/webrtc/callFeed.js.map +1 -0
- package/lib/webrtc/groupCall.d.ts +323 -0
- package/lib/webrtc/groupCall.d.ts.map +1 -0
- package/lib/webrtc/groupCall.js +1337 -0
- package/lib/webrtc/groupCall.js.map +1 -0
- package/lib/webrtc/groupCallEventHandler.d.ts +31 -0
- package/lib/webrtc/groupCallEventHandler.d.ts.map +1 -0
- package/lib/webrtc/groupCallEventHandler.js +178 -0
- package/lib/webrtc/groupCallEventHandler.js.map +1 -0
- package/lib/webrtc/mediaHandler.d.ts +89 -0
- package/lib/webrtc/mediaHandler.d.ts.map +1 -0
- package/lib/webrtc/mediaHandler.js +437 -0
- package/lib/webrtc/mediaHandler.js.map +1 -0
- package/lib/webrtc/stats/callFeedStatsReporter.d.ts +8 -0
- package/lib/webrtc/stats/callFeedStatsReporter.d.ts.map +1 -0
- package/lib/webrtc/stats/callFeedStatsReporter.js +82 -0
- package/lib/webrtc/stats/callFeedStatsReporter.js.map +1 -0
- package/lib/webrtc/stats/callStatsReportGatherer.d.ts +25 -0
- package/lib/webrtc/stats/callStatsReportGatherer.d.ts.map +1 -0
- package/lib/webrtc/stats/callStatsReportGatherer.js +199 -0
- package/lib/webrtc/stats/callStatsReportGatherer.js.map +1 -0
- package/lib/webrtc/stats/callStatsReportSummary.d.ts +17 -0
- package/lib/webrtc/stats/callStatsReportSummary.d.ts.map +1 -0
- package/lib/webrtc/stats/callStatsReportSummary.js +1 -0
- package/lib/webrtc/stats/callStatsReportSummary.js.map +1 -0
- package/lib/webrtc/stats/connectionStats.d.ts +28 -0
- package/lib/webrtc/stats/connectionStats.d.ts.map +1 -0
- package/lib/webrtc/stats/connectionStats.js +26 -0
- package/lib/webrtc/stats/connectionStats.js.map +1 -0
- package/lib/webrtc/stats/connectionStatsBuilder.d.ts +5 -0
- package/lib/webrtc/stats/connectionStatsBuilder.d.ts.map +1 -0
- package/lib/webrtc/stats/connectionStatsBuilder.js +27 -0
- package/lib/webrtc/stats/connectionStatsBuilder.js.map +1 -0
- package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts +7 -0
- package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts.map +1 -0
- package/lib/webrtc/stats/connectionStatsReportBuilder.js +121 -0
- package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +1 -0
- package/lib/webrtc/stats/groupCallStats.d.ts +22 -0
- package/lib/webrtc/stats/groupCallStats.d.ts.map +1 -0
- package/lib/webrtc/stats/groupCallStats.js +78 -0
- package/lib/webrtc/stats/groupCallStats.js.map +1 -0
- package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts +10 -0
- package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts.map +1 -0
- package/lib/webrtc/stats/media/mediaSsrcHandler.js +57 -0
- package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +1 -0
- package/lib/webrtc/stats/media/mediaTrackHandler.d.ts +12 -0
- package/lib/webrtc/stats/media/mediaTrackHandler.d.ts.map +1 -0
- package/lib/webrtc/stats/media/mediaTrackHandler.js +62 -0
- package/lib/webrtc/stats/media/mediaTrackHandler.js.map +1 -0
- package/lib/webrtc/stats/media/mediaTrackStats.d.ts +86 -0
- package/lib/webrtc/stats/media/mediaTrackStats.d.ts.map +1 -0
- package/lib/webrtc/stats/media/mediaTrackStats.js +142 -0
- package/lib/webrtc/stats/media/mediaTrackStats.js.map +1 -0
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts +22 -0
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts.map +1 -0
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +76 -0
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +1 -0
- package/lib/webrtc/stats/statsReport.d.ts +99 -0
- package/lib/webrtc/stats/statsReport.d.ts.map +1 -0
- package/lib/webrtc/stats/statsReport.js +32 -0
- package/lib/webrtc/stats/statsReport.js.map +1 -0
- package/lib/webrtc/stats/statsReportEmitter.d.ts +15 -0
- package/lib/webrtc/stats/statsReportEmitter.d.ts.map +1 -0
- package/lib/webrtc/stats/statsReportEmitter.js +33 -0
- package/lib/webrtc/stats/statsReportEmitter.js.map +1 -0
- package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts +16 -0
- package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts.map +1 -0
- package/lib/webrtc/stats/summaryStatsReportGatherer.js +116 -0
- package/lib/webrtc/stats/summaryStatsReportGatherer.js.map +1 -0
- package/lib/webrtc/stats/trackStatsBuilder.d.ts +19 -0
- package/lib/webrtc/stats/trackStatsBuilder.d.ts.map +1 -0
- package/lib/webrtc/stats/trackStatsBuilder.js +168 -0
- package/lib/webrtc/stats/trackStatsBuilder.js.map +1 -0
- package/lib/webrtc/stats/transportStats.d.ts +11 -0
- package/lib/webrtc/stats/transportStats.d.ts.map +1 -0
- package/lib/webrtc/stats/transportStats.js +1 -0
- package/lib/webrtc/stats/transportStats.js.map +1 -0
- package/lib/webrtc/stats/transportStatsBuilder.d.ts +5 -0
- package/lib/webrtc/stats/transportStatsBuilder.d.ts.map +1 -0
- package/lib/webrtc/stats/transportStatsBuilder.js +34 -0
- package/lib/webrtc/stats/transportStatsBuilder.js.map +1 -0
- package/lib/webrtc/stats/valueFormatter.d.ts +4 -0
- package/lib/webrtc/stats/valueFormatter.d.ts.map +1 -0
- package/lib/webrtc/stats/valueFormatter.js +25 -0
- package/lib/webrtc/stats/valueFormatter.js.map +1 -0
- package/package.json +134 -0
- package/src/@types/AESEncryptedSecretStoragePayload.ts +29 -0
- package/src/@types/IIdentityServerProvider.ts +24 -0
- package/src/@types/PushRules.ts +209 -0
- package/src/@types/another-json.d.ts +19 -0
- package/src/@types/auth.ts +252 -0
- package/src/@types/beacon.ts +140 -0
- package/src/@types/common.ts +22 -0
- package/src/@types/crypto.ts +73 -0
- package/src/@types/event.ts +370 -0
- package/src/@types/events.ts +119 -0
- package/src/@types/extensible_events.ts +150 -0
- package/src/@types/global.d.ts +70 -0
- package/src/@types/local_notifications.ts +19 -0
- package/src/@types/location.ts +92 -0
- package/src/@types/matrix-sdk-crypto-wasm.d.ts +44 -0
- package/src/@types/media.ts +245 -0
- package/src/@types/membership.ts +57 -0
- package/src/@types/oidc-client-ts.d.ts +24 -0
- package/src/@types/partials.ts +67 -0
- package/src/@types/polls.ts +119 -0
- package/src/@types/read_receipts.ts +61 -0
- package/src/@types/registration.ts +102 -0
- package/src/@types/requests.ts +314 -0
- package/src/@types/search.ts +119 -0
- package/src/@types/signed.ts +25 -0
- package/src/@types/spaces.ts +37 -0
- package/src/@types/state_events.ts +147 -0
- package/src/@types/synapse.ts +40 -0
- package/src/@types/sync.ts +27 -0
- package/src/@types/threepids.ts +29 -0
- package/src/@types/topic.ts +63 -0
- package/src/@types/uia.ts +29 -0
- package/src/NamespacedValue.ts +123 -0
- package/src/ReEmitter.ts +93 -0
- package/src/ToDeviceMessageQueue.ts +153 -0
- package/src/autodiscovery.ts +505 -0
- package/src/base64.ts +88 -0
- package/src/browser-index.ts +44 -0
- package/src/client.ts +10474 -0
- package/src/common-crypto/CryptoBackend.ts +302 -0
- package/src/common-crypto/README.md +4 -0
- package/src/common-crypto/key-passphrase.ts +43 -0
- package/src/content-helpers.ts +288 -0
- package/src/content-repo.ts +117 -0
- package/src/crypto/CrossSigning.ts +773 -0
- package/src/crypto/DeviceList.ts +989 -0
- package/src/crypto/EncryptionSetup.ts +351 -0
- package/src/crypto/OlmDevice.ts +1500 -0
- package/src/crypto/OutgoingRoomKeyRequestManager.ts +485 -0
- package/src/crypto/RoomList.ts +70 -0
- package/src/crypto/SecretSharing.ts +240 -0
- package/src/crypto/SecretStorage.ts +136 -0
- package/src/crypto/aes.ts +23 -0
- package/src/crypto/algorithms/base.ts +236 -0
- package/src/crypto/algorithms/index.ts +20 -0
- package/src/crypto/algorithms/megolm.ts +2216 -0
- package/src/crypto/algorithms/olm.ts +381 -0
- package/src/crypto/api.ts +70 -0
- package/src/crypto/backup.ts +922 -0
- package/src/crypto/crypto.ts +18 -0
- package/src/crypto/dehydration.ts +272 -0
- package/src/crypto/device-converter.ts +45 -0
- package/src/crypto/deviceinfo.ts +158 -0
- package/src/crypto/index.ts +4414 -0
- package/src/crypto/key_passphrase.ts +42 -0
- package/src/crypto/keybackup.ts +47 -0
- package/src/crypto/olmlib.ts +539 -0
- package/src/crypto/recoverykey.ts +18 -0
- package/src/crypto/store/base.ts +348 -0
- package/src/crypto/store/indexeddb-crypto-store-backend.ts +1250 -0
- package/src/crypto/store/indexeddb-crypto-store.ts +845 -0
- package/src/crypto/store/localStorage-crypto-store.ts +579 -0
- package/src/crypto/store/memory-crypto-store.ts +680 -0
- package/src/crypto/verification/Base.ts +409 -0
- package/src/crypto/verification/Error.ts +76 -0
- package/src/crypto/verification/IllegalMethod.ts +50 -0
- package/src/crypto/verification/QRCode.ts +310 -0
- package/src/crypto/verification/SAS.ts +494 -0
- package/src/crypto/verification/SASDecimal.ts +37 -0
- package/src/crypto/verification/request/Channel.ts +34 -0
- package/src/crypto/verification/request/InRoomChannel.ts +371 -0
- package/src/crypto/verification/request/ToDeviceChannel.ts +354 -0
- package/src/crypto/verification/request/VerificationRequest.ts +976 -0
- package/src/crypto-api/CryptoEvent.ts +93 -0
- package/src/crypto-api/CryptoEventHandlerMap.ts +32 -0
- package/src/crypto-api/index.ts +1175 -0
- package/src/crypto-api/key-passphrase.ts +58 -0
- package/src/crypto-api/keybackup.ts +115 -0
- package/src/crypto-api/recovery-key.ts +69 -0
- package/src/crypto-api/verification.ts +408 -0
- package/src/digest.ts +34 -0
- package/src/embedded.ts +631 -0
- package/src/errors.ts +54 -0
- package/src/event-mapper.ts +97 -0
- package/src/extensible_events_v1/ExtensibleEvent.ts +58 -0
- package/src/extensible_events_v1/InvalidEventError.ts +24 -0
- package/src/extensible_events_v1/MessageEvent.ts +145 -0
- package/src/extensible_events_v1/PollEndEvent.ts +97 -0
- package/src/extensible_events_v1/PollResponseEvent.ts +148 -0
- package/src/extensible_events_v1/PollStartEvent.ts +207 -0
- package/src/extensible_events_v1/utilities.ts +35 -0
- package/src/feature.ts +87 -0
- package/src/filter-component.ts +207 -0
- package/src/filter.ts +245 -0
- package/src/http-api/errors.ts +199 -0
- package/src/http-api/fetch.ts +383 -0
- package/src/http-api/index.ts +191 -0
- package/src/http-api/interface.ts +178 -0
- package/src/http-api/method.ts +25 -0
- package/src/http-api/prefix.ts +48 -0
- package/src/http-api/utils.ts +200 -0
- package/src/index.ts +25 -0
- package/src/indexeddb-helpers.ts +50 -0
- package/src/indexeddb-worker.ts +24 -0
- package/src/interactive-auth.ts +694 -0
- package/src/logger.ts +185 -0
- package/src/matrix.ts +177 -0
- package/src/matrixrtc/CallMembership.ts +247 -0
- package/src/matrixrtc/LivekitFocus.ts +39 -0
- package/src/matrixrtc/MatrixRTCSession.ts +1319 -0
- package/src/matrixrtc/MatrixRTCSessionManager.ts +166 -0
- package/src/matrixrtc/focus.ts +25 -0
- package/src/matrixrtc/index.ts +22 -0
- package/src/matrixrtc/types.ts +36 -0
- package/src/models/MSC3089Branch.ts +272 -0
- package/src/models/MSC3089TreeSpace.ts +565 -0
- package/src/models/ToDeviceMessage.ts +38 -0
- package/src/models/beacon.ts +214 -0
- package/src/models/compare-event-ordering.ts +139 -0
- package/src/models/device.ts +85 -0
- package/src/models/event-context.ts +110 -0
- package/src/models/event-status.ts +39 -0
- package/src/models/event-timeline-set.ts +979 -0
- package/src/models/event-timeline.ts +476 -0
- package/src/models/event.ts +1751 -0
- package/src/models/invites-ignorer.ts +376 -0
- package/src/models/poll.ts +285 -0
- package/src/models/profile-keys.ts +7 -0
- package/src/models/read-receipt.ts +422 -0
- package/src/models/related-relations.ts +39 -0
- package/src/models/relations-container.ts +149 -0
- package/src/models/relations.ts +368 -0
- package/src/models/room-member.ts +457 -0
- package/src/models/room-receipts.ts +439 -0
- package/src/models/room-state.ts +1130 -0
- package/src/models/room-summary.ts +47 -0
- package/src/models/room.ts +3822 -0
- package/src/models/search-result.ts +57 -0
- package/src/models/thread.ts +923 -0
- package/src/models/typed-event-emitter.ts +246 -0
- package/src/models/user.ts +302 -0
- package/src/oidc/authorize.ts +274 -0
- package/src/oidc/discovery.ts +60 -0
- package/src/oidc/error.ts +33 -0
- package/src/oidc/index.ts +34 -0
- package/src/oidc/register.ts +123 -0
- package/src/oidc/tokenRefresher.ts +149 -0
- package/src/oidc/validate.ts +282 -0
- package/src/pushprocessor.ts +837 -0
- package/src/randomstring.ts +51 -0
- package/src/realtime-callbacks.ts +191 -0
- package/src/receipt-accumulator.ts +189 -0
- package/src/rendezvous/MSC4108SignInWithQR.ts +444 -0
- package/src/rendezvous/RendezvousChannel.ts +48 -0
- package/src/rendezvous/RendezvousCode.ts +25 -0
- package/src/rendezvous/RendezvousError.ts +26 -0
- package/src/rendezvous/RendezvousFailureReason.ts +49 -0
- package/src/rendezvous/RendezvousIntent.ts +20 -0
- package/src/rendezvous/RendezvousTransport.ts +58 -0
- package/src/rendezvous/channels/MSC4108SecureChannel.ts +270 -0
- package/src/rendezvous/channels/index.ts +17 -0
- package/src/rendezvous/index.ts +25 -0
- package/src/rendezvous/transports/MSC4108RendezvousSession.ts +270 -0
- package/src/rendezvous/transports/index.ts +17 -0
- package/src/room-hierarchy.ts +152 -0
- package/src/rust-crypto/CrossSigningIdentity.ts +183 -0
- package/src/rust-crypto/DehydratedDeviceManager.ts +306 -0
- package/src/rust-crypto/KeyClaimManager.ts +86 -0
- package/src/rust-crypto/OutgoingRequestProcessor.ts +236 -0
- package/src/rust-crypto/OutgoingRequestsManager.ts +143 -0
- package/src/rust-crypto/PerSessionKeyBackupDownloader.ts +501 -0
- package/src/rust-crypto/RoomEncryptor.ts +352 -0
- package/src/rust-crypto/backup.ts +881 -0
- package/src/rust-crypto/constants.ts +18 -0
- package/src/rust-crypto/device-converter.ts +128 -0
- package/src/rust-crypto/index.ts +237 -0
- package/src/rust-crypto/libolm_migration.ts +530 -0
- package/src/rust-crypto/rust-crypto.ts +2205 -0
- package/src/rust-crypto/secret-storage.ts +60 -0
- package/src/rust-crypto/verification.ts +830 -0
- package/src/scheduler.ts +309 -0
- package/src/secret-storage.ts +693 -0
- package/src/serverCapabilities.ts +139 -0
- package/src/service-types.ts +20 -0
- package/src/sliding-sync-sdk.ts +1026 -0
- package/src/sliding-sync.ts +965 -0
- package/src/store/index.ts +261 -0
- package/src/store/indexeddb-backend.ts +41 -0
- package/src/store/indexeddb-local-backend.ts +610 -0
- package/src/store/indexeddb-remote-backend.ts +213 -0
- package/src/store/indexeddb-store-worker.ts +157 -0
- package/src/store/indexeddb.ts +397 -0
- package/src/store/local-storage-events-emitter.ts +46 -0
- package/src/store/memory.ts +448 -0
- package/src/store/stub.ts +280 -0
- package/src/sync-accumulator.ts +689 -0
- package/src/sync.ts +1920 -0
- package/src/testing.ts +191 -0
- package/src/thread-utils.ts +31 -0
- package/src/timeline-window.ts +536 -0
- package/src/types.ts +59 -0
- package/src/utils/decryptAESSecretStorageItem.ts +54 -0
- package/src/utils/encryptAESSecretStorageItem.ts +73 -0
- package/src/utils/internal/deriveKeys.ts +63 -0
- package/src/utils.ts +763 -0
- package/src/version-support.ts +36 -0
- package/src/webrtc/audioContext.ts +44 -0
- package/src/webrtc/call.ts +3074 -0
- package/src/webrtc/callEventHandler.ts +425 -0
- package/src/webrtc/callEventTypes.ts +93 -0
- package/src/webrtc/callFeed.ts +364 -0
- package/src/webrtc/groupCall.ts +1735 -0
- package/src/webrtc/groupCallEventHandler.ts +234 -0
- package/src/webrtc/mediaHandler.ts +484 -0
- package/src/webrtc/stats/callFeedStatsReporter.ts +94 -0
- package/src/webrtc/stats/callStatsReportGatherer.ts +219 -0
- package/src/webrtc/stats/callStatsReportSummary.ts +30 -0
- package/src/webrtc/stats/connectionStats.ts +47 -0
- package/src/webrtc/stats/connectionStatsBuilder.ts +28 -0
- package/src/webrtc/stats/connectionStatsReportBuilder.ts +140 -0
- package/src/webrtc/stats/groupCallStats.ts +93 -0
- package/src/webrtc/stats/media/mediaSsrcHandler.ts +57 -0
- package/src/webrtc/stats/media/mediaTrackHandler.ts +76 -0
- package/src/webrtc/stats/media/mediaTrackStats.ts +176 -0
- package/src/webrtc/stats/media/mediaTrackStatsHandler.ts +90 -0
- package/src/webrtc/stats/statsReport.ts +133 -0
- package/src/webrtc/stats/statsReportEmitter.ts +49 -0
- package/src/webrtc/stats/summaryStatsReportGatherer.ts +148 -0
- package/src/webrtc/stats/trackStatsBuilder.ts +207 -0
- package/src/webrtc/stats/transportStats.ts +26 -0
- package/src/webrtc/stats/transportStatsBuilder.ts +48 -0
- package/src/webrtc/stats/valueFormatter.ts +27 -0
@@ -0,0 +1,1751 @@
|
|
1
|
+
/*
|
2
|
+
Copyright 2015 - 2023 The Matrix.org Foundation C.I.C.
|
3
|
+
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
you may not use this file except in compliance with the License.
|
6
|
+
You may obtain a copy of the License at
|
7
|
+
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
See the License for the specific language governing permissions and
|
14
|
+
limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
/**
|
18
|
+
* This is an internal module. See {@link MatrixEvent} and {@link RoomEvent} for
|
19
|
+
* the public classes.
|
20
|
+
*/
|
21
|
+
|
22
|
+
import { ExtensibleEvent, ExtensibleEvents, Optional } from "matrix-events-sdk";
|
23
|
+
|
24
|
+
import type { IEventDecryptionResult } from "../@types/crypto.ts";
|
25
|
+
import { logger } from "../logger.ts";
|
26
|
+
import { VerificationRequest } from "../crypto/verification/request/VerificationRequest.ts";
|
27
|
+
import {
|
28
|
+
EVENT_VISIBILITY_CHANGE_TYPE,
|
29
|
+
EventType,
|
30
|
+
MsgType,
|
31
|
+
RelationType,
|
32
|
+
ToDeviceMessageId,
|
33
|
+
UNSIGNED_THREAD_ID_FIELD,
|
34
|
+
UNSIGNED_MEMBERSHIP_FIELD,
|
35
|
+
} from "../@types/event.ts";
|
36
|
+
import { Crypto } from "../crypto/index.ts";
|
37
|
+
import { deepSortedObjectEntries, internaliseString } from "../utils.ts";
|
38
|
+
import { RoomMember } from "./room-member.ts";
|
39
|
+
import { Thread, THREAD_RELATION_TYPE, ThreadEvent, ThreadEventHandlerMap } from "./thread.ts";
|
40
|
+
import { IActionsObject } from "../pushprocessor.ts";
|
41
|
+
import { TypedReEmitter } from "../ReEmitter.ts";
|
42
|
+
import { MatrixError } from "../http-api/index.ts";
|
43
|
+
import { TypedEventEmitter } from "./typed-event-emitter.ts";
|
44
|
+
import { EventStatus } from "./event-status.ts";
|
45
|
+
import { CryptoBackend, DecryptionError } from "../common-crypto/CryptoBackend.ts";
|
46
|
+
import { IAnnotatedPushRule } from "../@types/PushRules.ts";
|
47
|
+
import { Room } from "./room.ts";
|
48
|
+
import { EventTimeline } from "./event-timeline.ts";
|
49
|
+
import { Membership } from "../@types/membership.ts";
|
50
|
+
import { DecryptionFailureCode } from "../crypto-api/index.ts";
|
51
|
+
|
52
|
+
export { EventStatus } from "./event-status.ts";
|
53
|
+
|
54
|
+
/* eslint-disable camelcase */
|
55
|
+
export interface IContent {
|
56
|
+
[key: string]: any;
|
57
|
+
"msgtype"?: MsgType | string;
|
58
|
+
"membership"?: Membership;
|
59
|
+
"avatar_url"?: string;
|
60
|
+
"displayname"?: string;
|
61
|
+
"m.relates_to"?: IEventRelation;
|
62
|
+
|
63
|
+
"m.mentions"?: IMentions;
|
64
|
+
}
|
65
|
+
|
66
|
+
type StrippedState = Required<Pick<IEvent, "content" | "state_key" | "type" | "sender">>;
|
67
|
+
|
68
|
+
export interface IUnsigned {
|
69
|
+
[key: string]: any;
|
70
|
+
"age"?: number;
|
71
|
+
"prev_sender"?: string;
|
72
|
+
"prev_content"?: IContent;
|
73
|
+
"redacted_because"?: IEvent;
|
74
|
+
"replaces_state"?: string;
|
75
|
+
"transaction_id"?: string;
|
76
|
+
"invite_room_state"?: StrippedState[];
|
77
|
+
"m.relations"?: Record<RelationType | string, any>; // No common pattern for aggregated relations
|
78
|
+
[UNSIGNED_THREAD_ID_FIELD.name]?: string;
|
79
|
+
}
|
80
|
+
|
81
|
+
export interface IThreadBundledRelationship {
|
82
|
+
latest_event: IEvent;
|
83
|
+
count: number;
|
84
|
+
current_user_participated?: boolean;
|
85
|
+
}
|
86
|
+
|
87
|
+
export interface IEvent {
|
88
|
+
event_id: string;
|
89
|
+
type: string;
|
90
|
+
content: IContent;
|
91
|
+
sender: string;
|
92
|
+
room_id?: string;
|
93
|
+
origin_server_ts: number;
|
94
|
+
txn_id?: string;
|
95
|
+
state_key?: string;
|
96
|
+
membership?: Membership;
|
97
|
+
unsigned: IUnsigned;
|
98
|
+
redacts?: string;
|
99
|
+
}
|
100
|
+
|
101
|
+
export interface IAggregatedRelation {
|
102
|
+
origin_server_ts: number;
|
103
|
+
event_id?: string;
|
104
|
+
sender?: string;
|
105
|
+
type?: string;
|
106
|
+
count?: number;
|
107
|
+
key?: string;
|
108
|
+
}
|
109
|
+
|
110
|
+
export interface IEventRelation {
|
111
|
+
"rel_type"?: RelationType | string;
|
112
|
+
"event_id"?: string;
|
113
|
+
"is_falling_back"?: boolean;
|
114
|
+
"m.in_reply_to"?: {
|
115
|
+
event_id?: string;
|
116
|
+
};
|
117
|
+
"key"?: string;
|
118
|
+
}
|
119
|
+
|
120
|
+
export interface IMentions {
|
121
|
+
user_ids?: string[];
|
122
|
+
room?: boolean;
|
123
|
+
}
|
124
|
+
|
125
|
+
export interface PushDetails {
|
126
|
+
rule?: IAnnotatedPushRule;
|
127
|
+
actions?: IActionsObject;
|
128
|
+
}
|
129
|
+
|
130
|
+
/**
|
131
|
+
* When an event is a visibility change event, as per MSC3531,
|
132
|
+
* the visibility change implied by the event.
|
133
|
+
*/
|
134
|
+
export interface IVisibilityChange {
|
135
|
+
/**
|
136
|
+
* If `true`, the target event should be made visible.
|
137
|
+
* Otherwise, it should be hidden.
|
138
|
+
*/
|
139
|
+
visible: boolean;
|
140
|
+
|
141
|
+
/**
|
142
|
+
* The event id affected.
|
143
|
+
*/
|
144
|
+
eventId: string;
|
145
|
+
|
146
|
+
/**
|
147
|
+
* Optionally, a human-readable reason explaining why
|
148
|
+
* the event was hidden. Ignored if the event was made
|
149
|
+
* visible.
|
150
|
+
*/
|
151
|
+
reason: string | null;
|
152
|
+
}
|
153
|
+
|
154
|
+
export interface IMarkedUnreadEvent {
|
155
|
+
unread: boolean;
|
156
|
+
}
|
157
|
+
|
158
|
+
export interface IClearEvent {
|
159
|
+
room_id?: string;
|
160
|
+
type: string;
|
161
|
+
content: Omit<IContent, "membership" | "avatar_url" | "displayname" | "m.relates_to">;
|
162
|
+
unsigned?: IUnsigned;
|
163
|
+
}
|
164
|
+
/* eslint-enable camelcase */
|
165
|
+
|
166
|
+
interface IKeyRequestRecipient {
|
167
|
+
userId: string;
|
168
|
+
deviceId: "*" | string;
|
169
|
+
}
|
170
|
+
|
171
|
+
export interface IDecryptOptions {
|
172
|
+
/** Whether to emit {@link MatrixEventEvent.Decrypted} events on successful decryption. Defaults to true.
|
173
|
+
*/
|
174
|
+
emit?: boolean;
|
175
|
+
|
176
|
+
/**
|
177
|
+
* True if this is a retry, after receiving an update to the session key. (Enables more logging.)
|
178
|
+
*
|
179
|
+
* This is only intended for use within the js-sdk.
|
180
|
+
*
|
181
|
+
* @internal
|
182
|
+
*/
|
183
|
+
isRetry?: boolean;
|
184
|
+
|
185
|
+
/**
|
186
|
+
* Whether the message should be re-decrypted if it was previously successfully decrypted with an untrusted key.
|
187
|
+
* Defaults to `false`.
|
188
|
+
*/
|
189
|
+
forceRedecryptIfUntrusted?: boolean;
|
190
|
+
}
|
191
|
+
|
192
|
+
/**
|
193
|
+
* Message hiding, as specified by https://github.com/matrix-org/matrix-doc/pull/3531.
|
194
|
+
*/
|
195
|
+
export type MessageVisibility = IMessageVisibilityHidden | IMessageVisibilityVisible;
|
196
|
+
/**
|
197
|
+
* Variant of `MessageVisibility` for the case in which the message should be displayed.
|
198
|
+
*/
|
199
|
+
export interface IMessageVisibilityVisible {
|
200
|
+
readonly visible: true;
|
201
|
+
}
|
202
|
+
/**
|
203
|
+
* Variant of `MessageVisibility` for the case in which the message should be hidden.
|
204
|
+
*/
|
205
|
+
export interface IMessageVisibilityHidden {
|
206
|
+
readonly visible: false;
|
207
|
+
/**
|
208
|
+
* Optionally, a human-readable reason to show to the user indicating why the
|
209
|
+
* message has been hidden (e.g. "Message Pending Moderation").
|
210
|
+
*/
|
211
|
+
readonly reason: string | null;
|
212
|
+
}
|
213
|
+
// A singleton implementing `IMessageVisibilityVisible`.
|
214
|
+
const MESSAGE_VISIBLE: IMessageVisibilityVisible = Object.freeze({ visible: true });
|
215
|
+
|
216
|
+
export enum MatrixEventEvent {
|
217
|
+
/**
|
218
|
+
* An event has been decrypted, or we have failed to decrypt it.
|
219
|
+
*
|
220
|
+
* The payload consists of:
|
221
|
+
*
|
222
|
+
* * `event` - The {@link MatrixEvent} which we attempted to decrypt.
|
223
|
+
*
|
224
|
+
* * `err` - The error that occurred during decryption, or `undefined` if no error occurred.
|
225
|
+
* Avoid use of this: {@link MatrixEvent.decryptionFailureReason} is more useful.
|
226
|
+
*/
|
227
|
+
Decrypted = "Event.decrypted",
|
228
|
+
|
229
|
+
BeforeRedaction = "Event.beforeRedaction",
|
230
|
+
VisibilityChange = "Event.visibilityChange",
|
231
|
+
LocalEventIdReplaced = "Event.localEventIdReplaced",
|
232
|
+
Status = "Event.status",
|
233
|
+
Replaced = "Event.replaced",
|
234
|
+
RelationsCreated = "Event.relationsCreated",
|
235
|
+
}
|
236
|
+
|
237
|
+
export type MatrixEventEmittedEvents = MatrixEventEvent | ThreadEvent.Update;
|
238
|
+
|
239
|
+
export type MatrixEventHandlerMap = {
|
240
|
+
[MatrixEventEvent.Decrypted]: (event: MatrixEvent, err?: Error) => void;
|
241
|
+
[MatrixEventEvent.BeforeRedaction]: (event: MatrixEvent, redactionEvent: MatrixEvent) => void;
|
242
|
+
[MatrixEventEvent.VisibilityChange]: (event: MatrixEvent, visible: boolean) => void;
|
243
|
+
[MatrixEventEvent.LocalEventIdReplaced]: (event: MatrixEvent) => void;
|
244
|
+
[MatrixEventEvent.Status]: (event: MatrixEvent, status: EventStatus | null) => void;
|
245
|
+
[MatrixEventEvent.Replaced]: (event: MatrixEvent) => void;
|
246
|
+
[MatrixEventEvent.RelationsCreated]: (relationType: string, eventType: string) => void;
|
247
|
+
} & Pick<ThreadEventHandlerMap, ThreadEvent.Update>;
|
248
|
+
|
249
|
+
export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, MatrixEventHandlerMap> {
|
250
|
+
// applied push rule and action for this event
|
251
|
+
private pushDetails: PushDetails = {};
|
252
|
+
private _replacingEvent: MatrixEvent | null = null;
|
253
|
+
private _localRedactionEvent: MatrixEvent | null = null;
|
254
|
+
private _isCancelled = false;
|
255
|
+
private clearEvent?: IClearEvent;
|
256
|
+
|
257
|
+
/* Message hiding, as specified by https://github.com/matrix-org/matrix-doc/pull/3531.
|
258
|
+
|
259
|
+
Note: We're returning this object, so any value stored here MUST be frozen.
|
260
|
+
*/
|
261
|
+
private visibility: MessageVisibility = MESSAGE_VISIBLE;
|
262
|
+
|
263
|
+
// Not all events will be extensible-event compatible, so cache a flag in
|
264
|
+
// addition to a falsy cached event value. We check the flag later on in
|
265
|
+
// a public getter to decide if the cache is valid.
|
266
|
+
private _hasCachedExtEv = false;
|
267
|
+
private _cachedExtEv: Optional<ExtensibleEvent> = undefined;
|
268
|
+
|
269
|
+
/** If we failed to decrypt this event, the reason for the failure. Otherwise, `null`. */
|
270
|
+
private _decryptionFailureReason: DecryptionFailureCode | null = null;
|
271
|
+
|
272
|
+
/* curve25519 key which we believe belongs to the sender of the event. See
|
273
|
+
* getSenderKey()
|
274
|
+
*/
|
275
|
+
private senderCurve25519Key: string | null = null;
|
276
|
+
|
277
|
+
/* ed25519 key which the sender of this event (for olm) or the creator of
|
278
|
+
* the megolm session (for megolm) claims to own. See getClaimedEd25519Key()
|
279
|
+
*/
|
280
|
+
private claimedEd25519Key: string | null = null;
|
281
|
+
|
282
|
+
/* curve25519 keys of devices involved in telling us about the
|
283
|
+
* senderCurve25519Key and claimedEd25519Key.
|
284
|
+
* See getForwardingCurve25519KeyChain().
|
285
|
+
*/
|
286
|
+
private forwardingCurve25519KeyChain: string[] = [];
|
287
|
+
|
288
|
+
/* where the decryption key is untrusted
|
289
|
+
*/
|
290
|
+
private untrusted: boolean | null = null;
|
291
|
+
|
292
|
+
/* if we have a process decrypting this event, a Promise which resolves
|
293
|
+
* when it is finished. Normally null.
|
294
|
+
*/
|
295
|
+
private decryptionPromise: Promise<void> | null = null;
|
296
|
+
|
297
|
+
/* flag to indicate if we should retry decrypting this event after the
|
298
|
+
* first attempt (eg, we have received new data which means that a second
|
299
|
+
* attempt may succeed)
|
300
|
+
*/
|
301
|
+
private retryDecryption = false;
|
302
|
+
|
303
|
+
/* The txnId with which this event was sent if it was during this session,
|
304
|
+
* allows for a unique ID which does not change when the event comes back down sync.
|
305
|
+
*/
|
306
|
+
private txnId?: string;
|
307
|
+
|
308
|
+
/**
|
309
|
+
* A reference to the thread this event belongs to
|
310
|
+
*/
|
311
|
+
private thread?: Thread;
|
312
|
+
private threadId?: string;
|
313
|
+
|
314
|
+
/* Set an approximate timestamp for the event relative the local clock.
|
315
|
+
* This will inherently be approximate because it doesn't take into account
|
316
|
+
* the time between the server putting the 'age' field on the event as it sent
|
317
|
+
* it to us and the time we're now constructing this event, but that's better
|
318
|
+
* than assuming the local clock is in sync with the origin HS's clock.
|
319
|
+
*/
|
320
|
+
public localTimestamp: number;
|
321
|
+
|
322
|
+
/**
|
323
|
+
* The room member who sent this event, or null e.g.
|
324
|
+
* this is a presence event. This is only guaranteed to be set for events that
|
325
|
+
* appear in a timeline, ie. do not guarantee that it will be set on state
|
326
|
+
* events.
|
327
|
+
* @privateRemarks
|
328
|
+
* Should be read-only
|
329
|
+
*/
|
330
|
+
public sender: RoomMember | null = null;
|
331
|
+
/**
|
332
|
+
* The room member who is the target of this event, e.g.
|
333
|
+
* the invitee, the person being banned, etc.
|
334
|
+
* @privateRemarks
|
335
|
+
* Should be read-only
|
336
|
+
*/
|
337
|
+
public target: RoomMember | null = null;
|
338
|
+
/**
|
339
|
+
* The sending status of the event.
|
340
|
+
* @privateRemarks
|
341
|
+
* Should be read-only
|
342
|
+
*/
|
343
|
+
public status: EventStatus | null = null;
|
344
|
+
/**
|
345
|
+
* most recent error associated with sending the event, if any
|
346
|
+
* @privateRemarks
|
347
|
+
* Should be read-only. May not be a MatrixError.
|
348
|
+
*/
|
349
|
+
public error: MatrixError | null = null;
|
350
|
+
/**
|
351
|
+
* True if this event is 'forward looking', meaning
|
352
|
+
* that getDirectionalContent() will return event.content and not event.prev_content.
|
353
|
+
* Only state events may be backwards looking
|
354
|
+
* Default: true. <strong>This property is experimental and may change.</strong>
|
355
|
+
* @privateRemarks
|
356
|
+
* Should be read-only
|
357
|
+
*/
|
358
|
+
public forwardLooking = true;
|
359
|
+
|
360
|
+
/* If the event is a `m.key.verification.request` (or to_device `m.key.verification.start`) event,
|
361
|
+
* `Crypto` will set this the `VerificationRequest` for the event
|
362
|
+
* so it can be easily accessed from the timeline.
|
363
|
+
*/
|
364
|
+
public verificationRequest?: VerificationRequest;
|
365
|
+
|
366
|
+
private readonly reEmitter: TypedReEmitter<MatrixEventEmittedEvents, MatrixEventHandlerMap>;
|
367
|
+
|
368
|
+
/**
|
369
|
+
* Construct a Matrix Event object
|
370
|
+
*
|
371
|
+
* @param event - The raw (possibly encrypted) event. <b>Do not access
|
372
|
+
* this property</b> directly unless you absolutely have to. Prefer the getter
|
373
|
+
* methods defined on this class. Using the getter methods shields your app
|
374
|
+
* from changes to event JSON between Matrix versions.
|
375
|
+
*/
|
376
|
+
public constructor(public event: Partial<IEvent> = {}) {
|
377
|
+
super();
|
378
|
+
|
379
|
+
// intern the values of matrix events to force share strings and reduce the
|
380
|
+
// amount of needless string duplication. This can save moderate amounts of
|
381
|
+
// memory (~10% on a 350MB heap).
|
382
|
+
// 'membership' at the event level (rather than the content level) is a legacy
|
383
|
+
// field that Element never otherwise looks at, but it will still take up a lot
|
384
|
+
// of space if we don't intern it.
|
385
|
+
(["state_key", "type", "sender", "room_id", "membership"] as const).forEach((prop) => {
|
386
|
+
if (typeof event[prop] !== "string") return;
|
387
|
+
event[prop] = internaliseString(event[prop]!);
|
388
|
+
});
|
389
|
+
|
390
|
+
(["membership", "avatar_url", "displayname"] as const).forEach((prop) => {
|
391
|
+
if (typeof event.content?.[prop] !== "string") return;
|
392
|
+
event.content[prop] = internaliseString(event.content[prop]!);
|
393
|
+
});
|
394
|
+
|
395
|
+
(["rel_type"] as const).forEach((prop) => {
|
396
|
+
if (typeof event.content?.["m.relates_to"]?.[prop] !== "string") return;
|
397
|
+
event.content["m.relates_to"][prop] = internaliseString(event.content["m.relates_to"][prop]!);
|
398
|
+
});
|
399
|
+
|
400
|
+
this.txnId = event.txn_id;
|
401
|
+
// The localTimestamp is calculated using the age.
|
402
|
+
// Some events lack an `age` property, either because they are EDUs such as typing events,
|
403
|
+
// or due to server-side bugs such as https://github.com/matrix-org/synapse/issues/8429.
|
404
|
+
// The fallback in these cases will be to use the origin_server_ts.
|
405
|
+
// For EDUs, the origin_server_ts also is not defined so we use Date.now().
|
406
|
+
const age = this.getAge();
|
407
|
+
this.localTimestamp = age !== undefined ? Date.now() - age : (this.getTs() ?? Date.now());
|
408
|
+
this.reEmitter = new TypedReEmitter(this);
|
409
|
+
}
|
410
|
+
|
411
|
+
/**
|
412
|
+
* Unstable getter to try and get an extensible event. Note that this might
|
413
|
+
* return a falsy value if the event could not be parsed as an extensible
|
414
|
+
* event.
|
415
|
+
*
|
416
|
+
* @deprecated Use stable functions where possible.
|
417
|
+
*/
|
418
|
+
public get unstableExtensibleEvent(): Optional<ExtensibleEvent> {
|
419
|
+
if (!this._hasCachedExtEv) {
|
420
|
+
this._cachedExtEv = ExtensibleEvents.parse(this.getEffectiveEvent());
|
421
|
+
}
|
422
|
+
return this._cachedExtEv;
|
423
|
+
}
|
424
|
+
|
425
|
+
private invalidateExtensibleEvent(): void {
|
426
|
+
// just reset the flag - that'll trick the getter into parsing a new event
|
427
|
+
this._hasCachedExtEv = false;
|
428
|
+
}
|
429
|
+
|
430
|
+
/**
|
431
|
+
* Gets the event as it would appear if it had been sent unencrypted.
|
432
|
+
*
|
433
|
+
* If the event is encrypted, we attempt to mock up an event as it would have looked had the sender not encrypted it.
|
434
|
+
* If the event is not encrypted, a copy of it is simply returned as-is.
|
435
|
+
*
|
436
|
+
* @returns A shallow copy of the event, in wire format, as it would have been had it not been encrypted.
|
437
|
+
*/
|
438
|
+
public getEffectiveEvent(): IEvent {
|
439
|
+
const content = Object.assign({}, this.getContent()); // clone for mutation
|
440
|
+
|
441
|
+
if (this.getWireType() === EventType.RoomMessageEncrypted) {
|
442
|
+
// Encrypted events sometimes aren't symmetrical on the `content` so we'll copy
|
443
|
+
// that over too, but only for missing properties. We don't copy over mismatches
|
444
|
+
// between the plain and decrypted copies of `content` because we assume that the
|
445
|
+
// app is relying on the decrypted version, so we want to expose that as a source
|
446
|
+
// of truth here too.
|
447
|
+
for (const [key, value] of Object.entries(this.getWireContent())) {
|
448
|
+
// Skip fields from the encrypted event schema though - we don't want to leak
|
449
|
+
// these.
|
450
|
+
if (["algorithm", "ciphertext", "device_id", "sender_key", "session_id"].includes(key)) {
|
451
|
+
continue;
|
452
|
+
}
|
453
|
+
|
454
|
+
if (content[key] === undefined) content[key] = value;
|
455
|
+
}
|
456
|
+
}
|
457
|
+
|
458
|
+
// clearEvent doesn't have all the fields, so we'll copy what we can from this.event.
|
459
|
+
// We also copy over our "fixed" content key.
|
460
|
+
return Object.assign({}, this.event, this.clearEvent, { content }) as IEvent;
|
461
|
+
}
|
462
|
+
|
463
|
+
/**
|
464
|
+
* Get the event_id for this event.
|
465
|
+
* @returns The event ID, e.g. <code>$143350589368169JsLZx:localhost
|
466
|
+
* </code>
|
467
|
+
*/
|
468
|
+
public getId(): string | undefined {
|
469
|
+
return this.event.event_id;
|
470
|
+
}
|
471
|
+
|
472
|
+
/**
|
473
|
+
* Get the user_id for this event.
|
474
|
+
* @returns The user ID, e.g. `@alice:matrix.org`
|
475
|
+
*/
|
476
|
+
public getSender(): string | undefined {
|
477
|
+
return this.event.sender; // v2 / v1
|
478
|
+
}
|
479
|
+
|
480
|
+
/**
|
481
|
+
* Get the (decrypted, if necessary) type of event.
|
482
|
+
*
|
483
|
+
* @returns The event type, e.g. `m.room.message`
|
484
|
+
*/
|
485
|
+
public getType(): EventType | string {
|
486
|
+
if (this.clearEvent) {
|
487
|
+
return this.clearEvent.type;
|
488
|
+
}
|
489
|
+
return this.event.type!;
|
490
|
+
}
|
491
|
+
|
492
|
+
/**
|
493
|
+
* Get the (possibly encrypted) type of the event that will be sent to the
|
494
|
+
* homeserver.
|
495
|
+
*
|
496
|
+
* @returns The event type.
|
497
|
+
*/
|
498
|
+
public getWireType(): EventType | string {
|
499
|
+
return this.event.type!;
|
500
|
+
}
|
501
|
+
|
502
|
+
/**
|
503
|
+
* Get the room_id for this event. This will return `undefined`
|
504
|
+
* for `m.presence` events.
|
505
|
+
* @returns The room ID, e.g. <code>!cURbafjkfsMDVwdRDQ:matrix.org
|
506
|
+
* </code>
|
507
|
+
*/
|
508
|
+
public getRoomId(): string | undefined {
|
509
|
+
return this.event.room_id;
|
510
|
+
}
|
511
|
+
|
512
|
+
/**
|
513
|
+
* Get the timestamp of this event.
|
514
|
+
* @returns The event timestamp, e.g. `1433502692297`
|
515
|
+
*/
|
516
|
+
public getTs(): number {
|
517
|
+
return this.event.origin_server_ts!;
|
518
|
+
}
|
519
|
+
|
520
|
+
/**
|
521
|
+
* Get the timestamp of this event, as a Date object.
|
522
|
+
* @returns The event date, e.g. `new Date(1433502692297)`
|
523
|
+
*/
|
524
|
+
public getDate(): Date | null {
|
525
|
+
return this.event.origin_server_ts ? new Date(this.event.origin_server_ts) : null;
|
526
|
+
}
|
527
|
+
|
528
|
+
/**
|
529
|
+
* Get a string containing details of this event
|
530
|
+
*
|
531
|
+
* This is intended for logging, to help trace errors. Example output:
|
532
|
+
*
|
533
|
+
* @example
|
534
|
+
* ```
|
535
|
+
* id=$HjnOHV646n0SjLDAqFrgIjim7RCpB7cdMXFrekWYAn type=m.room.encrypted
|
536
|
+
* sender=@user:example.com room=!room:example.com ts=2022-10-25T17:30:28.404Z
|
537
|
+
* ```
|
538
|
+
*/
|
539
|
+
public getDetails(): string {
|
540
|
+
const room = this.getRoomId();
|
541
|
+
if (room) {
|
542
|
+
// in-room event
|
543
|
+
return `id=${this.getId()} type=${this.getWireType()} sender=${this.getSender()} room=${room} ts=${this.getDate()?.toISOString()}`;
|
544
|
+
} else {
|
545
|
+
// to-device event
|
546
|
+
const msgid = this.getContent()[ToDeviceMessageId];
|
547
|
+
return `msgid=${msgid} type=${this.getWireType()} sender=${this.getSender()}`;
|
548
|
+
}
|
549
|
+
}
|
550
|
+
|
551
|
+
/**
|
552
|
+
* Get the (decrypted, if necessary) event content JSON, even if the event
|
553
|
+
* was replaced by another event.
|
554
|
+
*
|
555
|
+
* @returns The event content JSON, or an empty object.
|
556
|
+
*/
|
557
|
+
public getOriginalContent<T = IContent>(): T {
|
558
|
+
if (this._localRedactionEvent) {
|
559
|
+
return {} as T;
|
560
|
+
}
|
561
|
+
if (this.clearEvent) {
|
562
|
+
return (this.clearEvent.content || {}) as T;
|
563
|
+
}
|
564
|
+
return (this.event.content || {}) as T;
|
565
|
+
}
|
566
|
+
|
567
|
+
/**
|
568
|
+
* Get the (decrypted, if necessary) event content JSON,
|
569
|
+
* or the content from the replacing event, if any.
|
570
|
+
* See `makeReplaced`.
|
571
|
+
*
|
572
|
+
* @returns The event content JSON, or an empty object.
|
573
|
+
*/
|
574
|
+
public getContent<T extends IContent = IContent>(): T {
|
575
|
+
if (this._localRedactionEvent) {
|
576
|
+
return {} as T;
|
577
|
+
} else if (this._replacingEvent) {
|
578
|
+
return this._replacingEvent.getContent()["m.new_content"] || {};
|
579
|
+
} else {
|
580
|
+
return this.getOriginalContent();
|
581
|
+
}
|
582
|
+
}
|
583
|
+
|
584
|
+
/**
|
585
|
+
* Get the (possibly encrypted) event content JSON that will be sent to the
|
586
|
+
* homeserver.
|
587
|
+
*
|
588
|
+
* @returns The event content JSON, or an empty object.
|
589
|
+
*/
|
590
|
+
public getWireContent(): IContent {
|
591
|
+
return this.event.content || {};
|
592
|
+
}
|
593
|
+
|
594
|
+
/**
|
595
|
+
* Get the event ID of the thread head
|
596
|
+
*/
|
597
|
+
public get threadRootId(): string | undefined {
|
598
|
+
// don't allow state events to be threaded as per the spec
|
599
|
+
if (this.isState()) {
|
600
|
+
return undefined;
|
601
|
+
}
|
602
|
+
const relatesTo = this.getWireContent()?.["m.relates_to"];
|
603
|
+
if (relatesTo?.rel_type === THREAD_RELATION_TYPE.name) {
|
604
|
+
return relatesTo.event_id;
|
605
|
+
}
|
606
|
+
if (this.thread) {
|
607
|
+
return this.thread.id;
|
608
|
+
}
|
609
|
+
if (this.threadId !== undefined) {
|
610
|
+
return this.threadId;
|
611
|
+
}
|
612
|
+
const unsigned = this.getUnsigned();
|
613
|
+
if (typeof unsigned[UNSIGNED_THREAD_ID_FIELD.name] === "string") {
|
614
|
+
return unsigned[UNSIGNED_THREAD_ID_FIELD.name];
|
615
|
+
}
|
616
|
+
return undefined;
|
617
|
+
}
|
618
|
+
|
619
|
+
/**
|
620
|
+
* A helper to check if an event is a thread's head or not
|
621
|
+
*/
|
622
|
+
public get isThreadRoot(): boolean {
|
623
|
+
// don't allow state events to be threaded as per the spec
|
624
|
+
if (this.isState()) {
|
625
|
+
return false;
|
626
|
+
}
|
627
|
+
|
628
|
+
const threadDetails = this.getServerAggregatedRelation<IThreadBundledRelationship>(THREAD_RELATION_TYPE.name);
|
629
|
+
|
630
|
+
// Bundled relationships only returned when the sync response is limited
|
631
|
+
// hence us having to check both bundled relation and inspect the thread
|
632
|
+
// model
|
633
|
+
return !!threadDetails || this.threadRootId === this.getId();
|
634
|
+
}
|
635
|
+
|
636
|
+
public get replyEventId(): string | undefined {
|
637
|
+
return this.getWireContent()["m.relates_to"]?.["m.in_reply_to"]?.event_id;
|
638
|
+
}
|
639
|
+
|
640
|
+
public get relationEventId(): string | undefined {
|
641
|
+
return this.getWireContent()?.["m.relates_to"]?.event_id;
|
642
|
+
}
|
643
|
+
|
644
|
+
/**
|
645
|
+
* Get the previous event content JSON. This will only return something for
|
646
|
+
* state events which exist in the timeline.
|
647
|
+
* @returns The previous event content JSON, or an empty object.
|
648
|
+
*/
|
649
|
+
public getPrevContent(): IContent {
|
650
|
+
// v2 then v1 then default
|
651
|
+
return this.getUnsigned().prev_content || {};
|
652
|
+
}
|
653
|
+
|
654
|
+
/**
|
655
|
+
* Get either 'content' or 'prev_content' depending on if this event is
|
656
|
+
* 'forward-looking' or not. This can be modified via event.forwardLooking.
|
657
|
+
* In practice, this means we get the chronologically earlier content value
|
658
|
+
* for this event (this method should surely be called getEarlierContent)
|
659
|
+
* <strong>This method is experimental and may change.</strong>
|
660
|
+
* @returns event.content if this event is forward-looking, else
|
661
|
+
* event.prev_content.
|
662
|
+
*/
|
663
|
+
public getDirectionalContent(): IContent {
|
664
|
+
return this.forwardLooking ? this.getContent() : this.getPrevContent();
|
665
|
+
}
|
666
|
+
|
667
|
+
/**
|
668
|
+
* Get the age of this event. This represents the age of the event when the
|
669
|
+
* event arrived at the device, and not the age of the event when this
|
670
|
+
* function was called.
|
671
|
+
* Can only be returned once the server has echo'ed back
|
672
|
+
* @returns The age of this event in milliseconds.
|
673
|
+
*/
|
674
|
+
public getAge(): number | undefined {
|
675
|
+
return this.getUnsigned().age;
|
676
|
+
}
|
677
|
+
|
678
|
+
/**
|
679
|
+
* Get the age of the event when this function was called.
|
680
|
+
* This is the 'age' field adjusted according to how long this client has
|
681
|
+
* had the event.
|
682
|
+
* @returns The age of this event in milliseconds.
|
683
|
+
*/
|
684
|
+
public getLocalAge(): number {
|
685
|
+
return Date.now() - this.localTimestamp;
|
686
|
+
}
|
687
|
+
|
688
|
+
/**
|
689
|
+
* Get the event state_key if it has one. This will return <code>undefined
|
690
|
+
* </code> for message events.
|
691
|
+
* @returns The event's `state_key`.
|
692
|
+
*/
|
693
|
+
public getStateKey(): string | undefined {
|
694
|
+
return this.event.state_key;
|
695
|
+
}
|
696
|
+
|
697
|
+
/**
|
698
|
+
* Check if this event is a state event.
|
699
|
+
* @returns True if this is a state event.
|
700
|
+
*/
|
701
|
+
public isState(): boolean {
|
702
|
+
return this.event.state_key !== undefined;
|
703
|
+
}
|
704
|
+
|
705
|
+
/**
|
706
|
+
* Get the user's room membership at the time the event was sent, as reported
|
707
|
+
* by the server. This uses MSC4115.
|
708
|
+
*
|
709
|
+
* @returns The user's room membership, or `undefined` if the server does
|
710
|
+
* not report it.
|
711
|
+
*/
|
712
|
+
public getMembershipAtEvent(): Optional<Membership | string> {
|
713
|
+
const unsigned = this.getUnsigned();
|
714
|
+
return UNSIGNED_MEMBERSHIP_FIELD.findIn<Membership | string>(unsigned);
|
715
|
+
}
|
716
|
+
|
717
|
+
/**
|
718
|
+
* Replace the content of this event with encrypted versions.
|
719
|
+
* (This is used when sending an event; it should not be used by applications).
|
720
|
+
*
|
721
|
+
* @internal
|
722
|
+
*
|
723
|
+
* @param cryptoType - type of the encrypted event - typically
|
724
|
+
* <tt>"m.room.encrypted"</tt>
|
725
|
+
*
|
726
|
+
* @param cryptoContent - raw 'content' for the encrypted event.
|
727
|
+
*
|
728
|
+
* @param senderCurve25519Key - curve25519 key to record for the
|
729
|
+
* sender of this event.
|
730
|
+
* See {@link MatrixEvent#getSenderKey}.
|
731
|
+
*
|
732
|
+
* @param claimedEd25519Key - claimed ed25519 key to record for the
|
733
|
+
* sender if this event.
|
734
|
+
* See {@link MatrixEvent#getClaimedEd25519Key}
|
735
|
+
*/
|
736
|
+
public makeEncrypted(
|
737
|
+
cryptoType: string,
|
738
|
+
cryptoContent: object,
|
739
|
+
senderCurve25519Key: string,
|
740
|
+
claimedEd25519Key: string,
|
741
|
+
): void {
|
742
|
+
// keep the plain-text data for 'view source'
|
743
|
+
this.clearEvent = {
|
744
|
+
type: this.event.type!,
|
745
|
+
content: this.event.content!,
|
746
|
+
};
|
747
|
+
this.event.type = cryptoType;
|
748
|
+
this.event.content = cryptoContent;
|
749
|
+
this.senderCurve25519Key = senderCurve25519Key;
|
750
|
+
this.claimedEd25519Key = claimedEd25519Key;
|
751
|
+
}
|
752
|
+
|
753
|
+
/**
|
754
|
+
* Check if this event is currently being decrypted.
|
755
|
+
*
|
756
|
+
* @returns True if this event is currently being decrypted, else false.
|
757
|
+
*/
|
758
|
+
public isBeingDecrypted(): boolean {
|
759
|
+
return this.decryptionPromise != null;
|
760
|
+
}
|
761
|
+
|
762
|
+
public getDecryptionPromise(): Promise<void> | null {
|
763
|
+
return this.decryptionPromise;
|
764
|
+
}
|
765
|
+
|
766
|
+
/**
|
767
|
+
* Check if this event is an encrypted event which we failed to decrypt
|
768
|
+
*
|
769
|
+
* (This implies that we might retry decryption at some point in the future)
|
770
|
+
*
|
771
|
+
* @returns True if this event is an encrypted event which we
|
772
|
+
* couldn't decrypt.
|
773
|
+
*/
|
774
|
+
public isDecryptionFailure(): boolean {
|
775
|
+
return this._decryptionFailureReason !== null;
|
776
|
+
}
|
777
|
+
|
778
|
+
/** If we failed to decrypt this event, the reason for the failure. Otherwise, `null`. */
|
779
|
+
public get decryptionFailureReason(): DecryptionFailureCode | null {
|
780
|
+
return this._decryptionFailureReason;
|
781
|
+
}
|
782
|
+
|
783
|
+
/**
|
784
|
+
* True if this event is an encrypted event which we failed to decrypt, the receiver's device is unverified and
|
785
|
+
* the sender has disabled encrypting to unverified devices.
|
786
|
+
*
|
787
|
+
* @deprecated: Prefer `event.decryptionFailureReason === DecryptionFailureCode.MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE`.
|
788
|
+
*/
|
789
|
+
public get isEncryptedDisabledForUnverifiedDevices(): boolean {
|
790
|
+
return this.decryptionFailureReason === DecryptionFailureCode.MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE;
|
791
|
+
}
|
792
|
+
|
793
|
+
public shouldAttemptDecryption(): boolean {
|
794
|
+
if (this.isRedacted()) return false;
|
795
|
+
if (this.isBeingDecrypted()) return false;
|
796
|
+
if (this.clearEvent) return false;
|
797
|
+
if (!this.isEncrypted()) return false;
|
798
|
+
|
799
|
+
return true;
|
800
|
+
}
|
801
|
+
|
802
|
+
/**
|
803
|
+
* Start the process of trying to decrypt this event.
|
804
|
+
*
|
805
|
+
* (This is used within the SDK: it isn't intended for use by applications)
|
806
|
+
*
|
807
|
+
* @internal
|
808
|
+
*
|
809
|
+
* @param crypto - crypto module
|
810
|
+
*
|
811
|
+
* @returns promise which resolves (to undefined) when the decryption
|
812
|
+
* attempt is completed.
|
813
|
+
*/
|
814
|
+
public async attemptDecryption(crypto: CryptoBackend, options: IDecryptOptions = {}): Promise<void> {
|
815
|
+
// start with a couple of sanity checks.
|
816
|
+
if (!this.isEncrypted()) {
|
817
|
+
throw new Error("Attempt to decrypt event which isn't encrypted");
|
818
|
+
}
|
819
|
+
|
820
|
+
const alreadyDecrypted = this.clearEvent && !this.isDecryptionFailure();
|
821
|
+
const forceRedecrypt = options.forceRedecryptIfUntrusted && this.isKeySourceUntrusted();
|
822
|
+
if (alreadyDecrypted && !forceRedecrypt) {
|
823
|
+
// we may want to just ignore this? let's start with rejecting it.
|
824
|
+
throw new Error("Attempt to decrypt event which has already been decrypted");
|
825
|
+
}
|
826
|
+
|
827
|
+
// if we already have a decryption attempt in progress, then it may
|
828
|
+
// fail because it was using outdated info. We now have reason to
|
829
|
+
// succeed where it failed before, but we don't want to have multiple
|
830
|
+
// attempts going at the same time, so just set a flag that says we have
|
831
|
+
// new info.
|
832
|
+
//
|
833
|
+
if (this.decryptionPromise) {
|
834
|
+
logger.log(`Event ${this.getId()} already being decrypted; queueing a retry`);
|
835
|
+
this.retryDecryption = true;
|
836
|
+
return this.decryptionPromise;
|
837
|
+
}
|
838
|
+
|
839
|
+
this.decryptionPromise = this.decryptionLoop(crypto, options);
|
840
|
+
return this.decryptionPromise;
|
841
|
+
}
|
842
|
+
|
843
|
+
/**
|
844
|
+
* Cancel any room key request for this event and resend another.
|
845
|
+
*
|
846
|
+
* @param crypto - crypto module
|
847
|
+
* @param userId - the user who received this event
|
848
|
+
*
|
849
|
+
* @returns a promise that resolves when the request is queued
|
850
|
+
*/
|
851
|
+
public cancelAndResendKeyRequest(crypto: Crypto, userId: string): Promise<void> {
|
852
|
+
const wireContent = this.getWireContent();
|
853
|
+
return crypto.requestRoomKey(
|
854
|
+
{
|
855
|
+
algorithm: wireContent.algorithm,
|
856
|
+
room_id: this.getRoomId()!,
|
857
|
+
session_id: wireContent.session_id,
|
858
|
+
sender_key: wireContent.sender_key,
|
859
|
+
},
|
860
|
+
this.getKeyRequestRecipients(userId),
|
861
|
+
true,
|
862
|
+
);
|
863
|
+
}
|
864
|
+
|
865
|
+
/**
|
866
|
+
* Calculate the recipients for keyshare requests.
|
867
|
+
*
|
868
|
+
* @param userId - the user who received this event.
|
869
|
+
*
|
870
|
+
* @returns array of recipients
|
871
|
+
*/
|
872
|
+
public getKeyRequestRecipients(userId: string): IKeyRequestRecipient[] {
|
873
|
+
// send the request to all of our own devices
|
874
|
+
const recipients = [
|
875
|
+
{
|
876
|
+
userId,
|
877
|
+
deviceId: "*",
|
878
|
+
},
|
879
|
+
];
|
880
|
+
|
881
|
+
return recipients;
|
882
|
+
}
|
883
|
+
|
884
|
+
private async decryptionLoop(crypto: CryptoBackend, options: IDecryptOptions = {}): Promise<void> {
|
885
|
+
// make sure that this method never runs completely synchronously.
|
886
|
+
// (doing so would mean that we would clear decryptionPromise *before*
|
887
|
+
// it is set in attemptDecryption - and hence end up with a stuck
|
888
|
+
// `decryptionPromise`).
|
889
|
+
await Promise.resolve();
|
890
|
+
|
891
|
+
// eslint-disable-next-line no-constant-condition
|
892
|
+
while (true) {
|
893
|
+
this.retryDecryption = false;
|
894
|
+
|
895
|
+
let err: Error | undefined = undefined;
|
896
|
+
try {
|
897
|
+
const res = await crypto.decryptEvent(this);
|
898
|
+
if (options.isRetry === true) {
|
899
|
+
logger.info(`Decrypted event on retry (${this.getDetails()})`);
|
900
|
+
}
|
901
|
+
this.setClearData(res);
|
902
|
+
this._decryptionFailureReason = null;
|
903
|
+
} catch (e) {
|
904
|
+
const detailedError = e instanceof DecryptionError ? (<DecryptionError>e).detailedString : String(e);
|
905
|
+
|
906
|
+
err = e as Error;
|
907
|
+
|
908
|
+
// see if we have a retry queued.
|
909
|
+
//
|
910
|
+
// NB: make sure to keep this check in the same tick of the
|
911
|
+
// event loop as `decryptionPromise = null` below - otherwise we
|
912
|
+
// risk a race:
|
913
|
+
//
|
914
|
+
// * A: we check retryDecryption here and see that it is
|
915
|
+
// false
|
916
|
+
// * B: we get a second call to attemptDecryption, which sees
|
917
|
+
// that decryptionPromise is set so sets
|
918
|
+
// retryDecryption
|
919
|
+
// * A: we continue below, clear decryptionPromise, and
|
920
|
+
// never do the retry.
|
921
|
+
//
|
922
|
+
if (this.retryDecryption) {
|
923
|
+
// decryption error, but we have a retry queued.
|
924
|
+
logger.log(`Error decrypting event (${this.getDetails()}), but retrying: ${detailedError}`);
|
925
|
+
continue;
|
926
|
+
}
|
927
|
+
|
928
|
+
// decryption error, no retries queued. Warn about the error and
|
929
|
+
// set it to m.bad.encrypted.
|
930
|
+
//
|
931
|
+
// the detailedString already includes the name and message of the error, and the stack isn't much use,
|
932
|
+
// so we don't bother to log `e` separately.
|
933
|
+
logger.warn(`Error decrypting event (${this.getDetails()}): ${detailedError}`);
|
934
|
+
|
935
|
+
this.setClearDataForDecryptionFailure(String(e));
|
936
|
+
this._decryptionFailureReason =
|
937
|
+
e instanceof DecryptionError ? (<DecryptionError>e).code : DecryptionFailureCode.UNKNOWN_ERROR;
|
938
|
+
}
|
939
|
+
|
940
|
+
// Make sure we clear 'decryptionPromise' before sending the 'Event.decrypted' event,
|
941
|
+
// otherwise the app will be confused to see `isBeingDecrypted` still set when
|
942
|
+
// there isn't an `Event.decrypted` on the way.
|
943
|
+
//
|
944
|
+
// see also notes on retryDecryption above.
|
945
|
+
//
|
946
|
+
this.decryptionPromise = null;
|
947
|
+
this.retryDecryption = false;
|
948
|
+
|
949
|
+
// Before we emit the event, clear the push actions so that they can be recalculated
|
950
|
+
// by relevant code. We do this because the clear event has now changed, making it
|
951
|
+
// so that existing rules can be re-run over the applicable properties. Stuff like
|
952
|
+
// highlighting when the user's name is mentioned rely on this happening. We also want
|
953
|
+
// to set the push actions before emitting so that any notification listeners don't
|
954
|
+
// pick up the wrong contents.
|
955
|
+
this.setPushDetails();
|
956
|
+
|
957
|
+
if (options.emit !== false) {
|
958
|
+
this.emit(MatrixEventEvent.Decrypted, this, err);
|
959
|
+
}
|
960
|
+
|
961
|
+
return;
|
962
|
+
}
|
963
|
+
}
|
964
|
+
|
965
|
+
/**
|
966
|
+
* Update the cleartext data on this event.
|
967
|
+
*
|
968
|
+
* (This is used after decrypting an event; it should not be used by applications).
|
969
|
+
*
|
970
|
+
* @internal
|
971
|
+
*
|
972
|
+
* @param decryptionResult - the decryption result, including the plaintext and some key info
|
973
|
+
*/
|
974
|
+
private setClearData(decryptionResult: IEventDecryptionResult): void {
|
975
|
+
this.clearEvent = decryptionResult.clearEvent;
|
976
|
+
this.senderCurve25519Key = decryptionResult.senderCurve25519Key ?? null;
|
977
|
+
this.claimedEd25519Key = decryptionResult.claimedEd25519Key ?? null;
|
978
|
+
this.forwardingCurve25519KeyChain = decryptionResult.forwardingCurve25519KeyChain || [];
|
979
|
+
this.untrusted = decryptionResult.untrusted || false;
|
980
|
+
this.invalidateExtensibleEvent();
|
981
|
+
}
|
982
|
+
|
983
|
+
/**
|
984
|
+
* Update the cleartext data on this event after a decryption failure.
|
985
|
+
*
|
986
|
+
* @param reason - the textual reason for the failure
|
987
|
+
*/
|
988
|
+
private setClearDataForDecryptionFailure(reason: string): void {
|
989
|
+
this.clearEvent = {
|
990
|
+
type: EventType.RoomMessage,
|
991
|
+
content: {
|
992
|
+
msgtype: "m.bad.encrypted",
|
993
|
+
body: `** Unable to decrypt: ${reason} **`,
|
994
|
+
},
|
995
|
+
};
|
996
|
+
this.senderCurve25519Key = null;
|
997
|
+
this.claimedEd25519Key = null;
|
998
|
+
this.forwardingCurve25519KeyChain = [];
|
999
|
+
this.untrusted = false;
|
1000
|
+
this.invalidateExtensibleEvent();
|
1001
|
+
}
|
1002
|
+
|
1003
|
+
/**
|
1004
|
+
* Gets the cleartext content for this event. If the event is not encrypted,
|
1005
|
+
* or encryption has not been completed, this will return null.
|
1006
|
+
*
|
1007
|
+
* @returns The cleartext (decrypted) content for the event
|
1008
|
+
*/
|
1009
|
+
public getClearContent(): IContent | null {
|
1010
|
+
return this.clearEvent ? this.clearEvent.content : null;
|
1011
|
+
}
|
1012
|
+
|
1013
|
+
/**
|
1014
|
+
* Check if the event is encrypted.
|
1015
|
+
* @returns True if this event is encrypted.
|
1016
|
+
*/
|
1017
|
+
public isEncrypted(): boolean {
|
1018
|
+
return !this.isState() && this.event.type === EventType.RoomMessageEncrypted;
|
1019
|
+
}
|
1020
|
+
|
1021
|
+
/**
|
1022
|
+
* The curve25519 key for the device that we think sent this event
|
1023
|
+
*
|
1024
|
+
* For an Olm-encrypted event, this is inferred directly from the DH
|
1025
|
+
* exchange at the start of the session: the curve25519 key is involved in
|
1026
|
+
* the DH exchange, so only a device which holds the private part of that
|
1027
|
+
* key can establish such a session.
|
1028
|
+
*
|
1029
|
+
* For a megolm-encrypted event, it is inferred from the Olm message which
|
1030
|
+
* established the megolm session
|
1031
|
+
*/
|
1032
|
+
public getSenderKey(): string | null {
|
1033
|
+
return this.senderCurve25519Key;
|
1034
|
+
}
|
1035
|
+
|
1036
|
+
/**
|
1037
|
+
* The additional keys the sender of this encrypted event claims to possess.
|
1038
|
+
*
|
1039
|
+
* Just a wrapper for #getClaimedEd25519Key (q.v.)
|
1040
|
+
*/
|
1041
|
+
public getKeysClaimed(): Partial<Record<"ed25519", string>> {
|
1042
|
+
if (!this.claimedEd25519Key) return {};
|
1043
|
+
|
1044
|
+
return {
|
1045
|
+
ed25519: this.claimedEd25519Key,
|
1046
|
+
};
|
1047
|
+
}
|
1048
|
+
|
1049
|
+
/**
|
1050
|
+
* Get the ed25519 the sender of this event claims to own.
|
1051
|
+
*
|
1052
|
+
* For Olm messages, this claim is encoded directly in the plaintext of the
|
1053
|
+
* event itself. For megolm messages, it is implied by the m.room_key event
|
1054
|
+
* which established the megolm session.
|
1055
|
+
*
|
1056
|
+
* Until we download the device list of the sender, it's just a claim: the
|
1057
|
+
* device list gives a proof that the owner of the curve25519 key used for
|
1058
|
+
* this event (and returned by #getSenderKey) also owns the ed25519 key by
|
1059
|
+
* signing the public curve25519 key with the ed25519 key.
|
1060
|
+
*
|
1061
|
+
* In general, applications should not use this method directly, but should
|
1062
|
+
* instead use {@link Crypto.CryptoApi#getEncryptionInfoForEvent}.
|
1063
|
+
*/
|
1064
|
+
public getClaimedEd25519Key(): string | null {
|
1065
|
+
return this.claimedEd25519Key;
|
1066
|
+
}
|
1067
|
+
|
1068
|
+
/**
|
1069
|
+
* Get the curve25519 keys of the devices which were involved in telling us
|
1070
|
+
* about the claimedEd25519Key and sender curve25519 key.
|
1071
|
+
*
|
1072
|
+
* Normally this will be empty, but in the case of a forwarded megolm
|
1073
|
+
* session, the sender keys are sent to us by another device (the forwarding
|
1074
|
+
* device), which we need to trust to do this. In that case, the result will
|
1075
|
+
* be a list consisting of one entry.
|
1076
|
+
*
|
1077
|
+
* If the device that sent us the key (A) got it from another device which
|
1078
|
+
* it wasn't prepared to vouch for (B), the result will be [A, B]. And so on.
|
1079
|
+
*
|
1080
|
+
* @returns base64-encoded curve25519 keys, from oldest to newest.
|
1081
|
+
*/
|
1082
|
+
public getForwardingCurve25519KeyChain(): string[] {
|
1083
|
+
return this.forwardingCurve25519KeyChain;
|
1084
|
+
}
|
1085
|
+
|
1086
|
+
/**
|
1087
|
+
* Whether the decryption key was obtained from an untrusted source. If so,
|
1088
|
+
* we cannot verify the authenticity of the message.
|
1089
|
+
*/
|
1090
|
+
public isKeySourceUntrusted(): boolean | undefined {
|
1091
|
+
return !!this.untrusted;
|
1092
|
+
}
|
1093
|
+
|
1094
|
+
public getUnsigned(): IUnsigned {
|
1095
|
+
return this.event.unsigned || {};
|
1096
|
+
}
|
1097
|
+
|
1098
|
+
public setUnsigned(unsigned: IUnsigned): void {
|
1099
|
+
this.event.unsigned = unsigned;
|
1100
|
+
}
|
1101
|
+
|
1102
|
+
public unmarkLocallyRedacted(): boolean {
|
1103
|
+
const value = this._localRedactionEvent;
|
1104
|
+
this._localRedactionEvent = null;
|
1105
|
+
if (this.event.unsigned) {
|
1106
|
+
this.event.unsigned.redacted_because = undefined;
|
1107
|
+
}
|
1108
|
+
return !!value;
|
1109
|
+
}
|
1110
|
+
|
1111
|
+
public markLocallyRedacted(redactionEvent: MatrixEvent): void {
|
1112
|
+
if (this._localRedactionEvent) return;
|
1113
|
+
this.emit(MatrixEventEvent.BeforeRedaction, this, redactionEvent);
|
1114
|
+
this._localRedactionEvent = redactionEvent;
|
1115
|
+
if (!this.event.unsigned) {
|
1116
|
+
this.event.unsigned = {};
|
1117
|
+
}
|
1118
|
+
this.event.unsigned.redacted_because = redactionEvent.event as IEvent;
|
1119
|
+
}
|
1120
|
+
|
1121
|
+
/**
|
1122
|
+
* Change the visibility of an event, as per https://github.com/matrix-org/matrix-doc/pull/3531 .
|
1123
|
+
*
|
1124
|
+
* @param visibilityChange - event holding a hide/unhide payload, or nothing
|
1125
|
+
* if the event is being reset to its original visibility (presumably
|
1126
|
+
* by a visibility event being redacted).
|
1127
|
+
*
|
1128
|
+
* @remarks
|
1129
|
+
* Fires {@link MatrixEventEvent.VisibilityChange} if `visibilityEvent`
|
1130
|
+
* caused a change in the actual visibility of this event, either by making it
|
1131
|
+
* visible (if it was hidden), by making it hidden (if it was visible) or by
|
1132
|
+
* changing the reason (if it was hidden).
|
1133
|
+
*/
|
1134
|
+
public applyVisibilityEvent(visibilityChange?: IVisibilityChange): void {
|
1135
|
+
const visible = visibilityChange?.visible ?? true;
|
1136
|
+
const reason = visibilityChange?.reason ?? null;
|
1137
|
+
let change = false;
|
1138
|
+
if (this.visibility.visible !== visible) {
|
1139
|
+
change = true;
|
1140
|
+
} else if (!this.visibility.visible && this.visibility["reason"] !== reason) {
|
1141
|
+
change = true;
|
1142
|
+
}
|
1143
|
+
if (change) {
|
1144
|
+
if (visible) {
|
1145
|
+
this.visibility = MESSAGE_VISIBLE;
|
1146
|
+
} else {
|
1147
|
+
this.visibility = Object.freeze({
|
1148
|
+
visible: false,
|
1149
|
+
reason,
|
1150
|
+
});
|
1151
|
+
}
|
1152
|
+
this.emit(MatrixEventEvent.VisibilityChange, this, visible);
|
1153
|
+
}
|
1154
|
+
}
|
1155
|
+
|
1156
|
+
/**
|
1157
|
+
* Return instructions to display or hide the message.
|
1158
|
+
*
|
1159
|
+
* @returns Instructions determining whether the message
|
1160
|
+
* should be displayed.
|
1161
|
+
*/
|
1162
|
+
public messageVisibility(): MessageVisibility {
|
1163
|
+
// Note: We may return `this.visibility` without fear, as
|
1164
|
+
// this is a shallow frozen object.
|
1165
|
+
return this.visibility;
|
1166
|
+
}
|
1167
|
+
|
1168
|
+
/**
|
1169
|
+
* Update the content of an event in the same way it would be by the server
|
1170
|
+
* if it were redacted before it was sent to us
|
1171
|
+
*
|
1172
|
+
* @param redactionEvent - event causing the redaction
|
1173
|
+
* @param room - the room in which the event exists
|
1174
|
+
*/
|
1175
|
+
public makeRedacted(redactionEvent: MatrixEvent, room: Room): void {
|
1176
|
+
// quick sanity-check
|
1177
|
+
if (!redactionEvent.event) {
|
1178
|
+
throw new Error("invalid redactionEvent in makeRedacted");
|
1179
|
+
}
|
1180
|
+
|
1181
|
+
this._localRedactionEvent = null;
|
1182
|
+
|
1183
|
+
this.emit(MatrixEventEvent.BeforeRedaction, this, redactionEvent);
|
1184
|
+
|
1185
|
+
this._replacingEvent = null;
|
1186
|
+
// we attempt to replicate what we would see from the server if
|
1187
|
+
// the event had been redacted before we saw it.
|
1188
|
+
//
|
1189
|
+
// The server removes (most of) the content of the event, and adds a
|
1190
|
+
// "redacted_because" key to the unsigned section containing the
|
1191
|
+
// redacted event.
|
1192
|
+
if (!this.event.unsigned) {
|
1193
|
+
this.event.unsigned = {};
|
1194
|
+
}
|
1195
|
+
this.event.unsigned.redacted_because = redactionEvent.event as IEvent;
|
1196
|
+
|
1197
|
+
for (const key in this.event) {
|
1198
|
+
if (this.event.hasOwnProperty(key) && !REDACT_KEEP_KEYS.has(key)) {
|
1199
|
+
delete this.event[key as keyof IEvent];
|
1200
|
+
}
|
1201
|
+
}
|
1202
|
+
|
1203
|
+
// If the event is encrypted prune the decrypted bits
|
1204
|
+
if (this.isEncrypted()) {
|
1205
|
+
this.clearEvent = undefined;
|
1206
|
+
}
|
1207
|
+
|
1208
|
+
const keeps =
|
1209
|
+
this.getType() in REDACT_KEEP_CONTENT_MAP
|
1210
|
+
? REDACT_KEEP_CONTENT_MAP[this.getType() as keyof typeof REDACT_KEEP_CONTENT_MAP]
|
1211
|
+
: {};
|
1212
|
+
const content = this.getContent();
|
1213
|
+
for (const key in content) {
|
1214
|
+
if (content.hasOwnProperty(key) && !keeps[key]) {
|
1215
|
+
delete content[key];
|
1216
|
+
}
|
1217
|
+
}
|
1218
|
+
|
1219
|
+
// If the redacted event was in a thread (but not thread root), move it
|
1220
|
+
// to the main timeline. This will change if MSC3389 is merged.
|
1221
|
+
if (!this.isThreadRoot && this.threadRootId && this.threadRootId !== this.getId()) {
|
1222
|
+
this.moveAllRelatedToMainTimeline(room);
|
1223
|
+
redactionEvent.moveToMainTimeline(room);
|
1224
|
+
}
|
1225
|
+
|
1226
|
+
this.invalidateExtensibleEvent();
|
1227
|
+
}
|
1228
|
+
|
1229
|
+
private moveAllRelatedToMainTimeline(room: Room): void {
|
1230
|
+
const thread = this.thread;
|
1231
|
+
this.moveToMainTimeline(room);
|
1232
|
+
|
1233
|
+
// If we dont have access to the thread, we can only move this
|
1234
|
+
// event, not things related to it.
|
1235
|
+
if (thread) {
|
1236
|
+
for (const event of thread.events) {
|
1237
|
+
if (event.getRelation()?.event_id === this.getId()) {
|
1238
|
+
event.moveAllRelatedToMainTimeline(room);
|
1239
|
+
}
|
1240
|
+
}
|
1241
|
+
}
|
1242
|
+
}
|
1243
|
+
|
1244
|
+
private moveToMainTimeline(room: Room): void {
|
1245
|
+
// Remove it from its thread
|
1246
|
+
this.thread?.timelineSet.removeEvent(this.getId()!);
|
1247
|
+
this.setThread(undefined);
|
1248
|
+
|
1249
|
+
// And insert it into the main timeline
|
1250
|
+
const timeline = room.getLiveTimeline();
|
1251
|
+
// We use insertEventIntoTimeline to insert it in timestamp order,
|
1252
|
+
// because we don't know where it should go (until we have MSC4033).
|
1253
|
+
timeline.getTimelineSet().insertEventIntoTimeline(this, timeline, timeline.getState(EventTimeline.FORWARDS)!);
|
1254
|
+
}
|
1255
|
+
|
1256
|
+
/**
|
1257
|
+
* Check if this event has been redacted
|
1258
|
+
*
|
1259
|
+
* @returns True if this event has been redacted
|
1260
|
+
*/
|
1261
|
+
public isRedacted(): boolean {
|
1262
|
+
return Boolean(this.getUnsigned().redacted_because);
|
1263
|
+
}
|
1264
|
+
|
1265
|
+
/**
|
1266
|
+
* Check if this event is a redaction of another event
|
1267
|
+
*
|
1268
|
+
* @returns True if this event is a redaction
|
1269
|
+
*/
|
1270
|
+
public isRedaction(): boolean {
|
1271
|
+
return this.getType() === EventType.RoomRedaction;
|
1272
|
+
}
|
1273
|
+
|
1274
|
+
/**
|
1275
|
+
* Return the visibility change caused by this event,
|
1276
|
+
* as per https://github.com/matrix-org/matrix-doc/pull/3531.
|
1277
|
+
*
|
1278
|
+
* @returns If the event is a well-formed visibility change event,
|
1279
|
+
* an instance of `IVisibilityChange`, otherwise `null`.
|
1280
|
+
*/
|
1281
|
+
public asVisibilityChange(): IVisibilityChange | null {
|
1282
|
+
if (!EVENT_VISIBILITY_CHANGE_TYPE.matches(this.getType())) {
|
1283
|
+
// Not a visibility change event.
|
1284
|
+
return null;
|
1285
|
+
}
|
1286
|
+
const relation = this.getRelation();
|
1287
|
+
if (!relation || relation.rel_type != "m.reference") {
|
1288
|
+
// Ill-formed, ignore this event.
|
1289
|
+
return null;
|
1290
|
+
}
|
1291
|
+
const eventId = relation.event_id;
|
1292
|
+
if (!eventId) {
|
1293
|
+
// Ill-formed, ignore this event.
|
1294
|
+
return null;
|
1295
|
+
}
|
1296
|
+
const content = this.getWireContent();
|
1297
|
+
const visible = !!content.visible;
|
1298
|
+
const reason = content.reason;
|
1299
|
+
if (reason && typeof reason != "string") {
|
1300
|
+
// Ill-formed, ignore this event.
|
1301
|
+
return null;
|
1302
|
+
}
|
1303
|
+
// Well-formed visibility change event.
|
1304
|
+
return {
|
1305
|
+
visible,
|
1306
|
+
reason,
|
1307
|
+
eventId,
|
1308
|
+
};
|
1309
|
+
}
|
1310
|
+
|
1311
|
+
/**
|
1312
|
+
* Check if this event alters the visibility of another event,
|
1313
|
+
* as per https://github.com/matrix-org/matrix-doc/pull/3531.
|
1314
|
+
*
|
1315
|
+
* @returns True if this event alters the visibility
|
1316
|
+
* of another event.
|
1317
|
+
*/
|
1318
|
+
public isVisibilityEvent(): boolean {
|
1319
|
+
return EVENT_VISIBILITY_CHANGE_TYPE.matches(this.getType());
|
1320
|
+
}
|
1321
|
+
|
1322
|
+
/**
|
1323
|
+
* Get the (decrypted, if necessary) redaction event JSON
|
1324
|
+
* if event was redacted
|
1325
|
+
*
|
1326
|
+
* @returns The redaction event JSON, or an empty object
|
1327
|
+
*/
|
1328
|
+
public getRedactionEvent(): IEvent | {} | null {
|
1329
|
+
if (!this.isRedacted()) return null;
|
1330
|
+
|
1331
|
+
if (this.clearEvent?.unsigned) {
|
1332
|
+
return this.clearEvent?.unsigned.redacted_because ?? null;
|
1333
|
+
} else if (this.event.unsigned?.redacted_because) {
|
1334
|
+
return this.event.unsigned.redacted_because;
|
1335
|
+
} else {
|
1336
|
+
return {};
|
1337
|
+
}
|
1338
|
+
}
|
1339
|
+
|
1340
|
+
/**
|
1341
|
+
* Get the push actions, if known, for this event
|
1342
|
+
*
|
1343
|
+
* @returns push actions
|
1344
|
+
*/
|
1345
|
+
public getPushActions(): IActionsObject | null {
|
1346
|
+
return this.pushDetails.actions || null;
|
1347
|
+
}
|
1348
|
+
|
1349
|
+
/**
|
1350
|
+
* Get the push details, if known, for this event
|
1351
|
+
*
|
1352
|
+
* @returns push actions
|
1353
|
+
*/
|
1354
|
+
public getPushDetails(): PushDetails {
|
1355
|
+
return this.pushDetails;
|
1356
|
+
}
|
1357
|
+
|
1358
|
+
/**
|
1359
|
+
* Set the push details for this event.
|
1360
|
+
*
|
1361
|
+
* @param pushActions - push actions
|
1362
|
+
* @param rule - the executed push rule
|
1363
|
+
*/
|
1364
|
+
public setPushDetails(pushActions?: IActionsObject, rule?: IAnnotatedPushRule): void {
|
1365
|
+
this.pushDetails = {
|
1366
|
+
actions: pushActions,
|
1367
|
+
rule,
|
1368
|
+
};
|
1369
|
+
}
|
1370
|
+
|
1371
|
+
/**
|
1372
|
+
* Replace the `event` property and recalculate any properties based on it.
|
1373
|
+
* @param event - the object to assign to the `event` property
|
1374
|
+
*/
|
1375
|
+
public handleRemoteEcho(event: object): void {
|
1376
|
+
const oldUnsigned = this.getUnsigned();
|
1377
|
+
const oldId = this.getId();
|
1378
|
+
this.event = event;
|
1379
|
+
// if this event was redacted before it was sent, it's locally marked as redacted.
|
1380
|
+
// At this point, we've received the remote echo for the event, but not yet for
|
1381
|
+
// the redaction that we are sending ourselves. Preserve the locally redacted
|
1382
|
+
// state by copying over redacted_because so we don't get a flash of
|
1383
|
+
// redacted, not-redacted, redacted as remote echos come in
|
1384
|
+
if (oldUnsigned.redacted_because) {
|
1385
|
+
if (!this.event.unsigned) {
|
1386
|
+
this.event.unsigned = {};
|
1387
|
+
}
|
1388
|
+
this.event.unsigned.redacted_because = oldUnsigned.redacted_because;
|
1389
|
+
}
|
1390
|
+
// successfully sent.
|
1391
|
+
this.setStatus(null);
|
1392
|
+
if (this.getId() !== oldId) {
|
1393
|
+
// emit the event if it changed
|
1394
|
+
this.emit(MatrixEventEvent.LocalEventIdReplaced, this);
|
1395
|
+
}
|
1396
|
+
|
1397
|
+
this.localTimestamp = Date.now() - this.getAge()!;
|
1398
|
+
}
|
1399
|
+
|
1400
|
+
/**
|
1401
|
+
* Whether the event is in any phase of sending, send failure, waiting for
|
1402
|
+
* remote echo, etc.
|
1403
|
+
*/
|
1404
|
+
public isSending(): boolean {
|
1405
|
+
return !!this.status;
|
1406
|
+
}
|
1407
|
+
|
1408
|
+
/**
|
1409
|
+
* Update the event's sending status and emit an event as well.
|
1410
|
+
*
|
1411
|
+
* @param status - The new status
|
1412
|
+
*/
|
1413
|
+
public setStatus(status: EventStatus | null): void {
|
1414
|
+
this.status = status;
|
1415
|
+
this.emit(MatrixEventEvent.Status, this, status);
|
1416
|
+
}
|
1417
|
+
|
1418
|
+
public replaceLocalEventId(eventId: string): void {
|
1419
|
+
this.event.event_id = eventId;
|
1420
|
+
this.emit(MatrixEventEvent.LocalEventIdReplaced, this);
|
1421
|
+
}
|
1422
|
+
|
1423
|
+
/**
|
1424
|
+
* Get whether the event is a relation event, and of a given type if
|
1425
|
+
* `relType` is passed in. State events cannot be relation events
|
1426
|
+
*
|
1427
|
+
* @param relType - if given, checks that the relation is of the
|
1428
|
+
* given type
|
1429
|
+
*/
|
1430
|
+
public isRelation(relType?: string): boolean {
|
1431
|
+
// Relation info is lifted out of the encrypted content when sent to
|
1432
|
+
// encrypted rooms, so we have to check `getWireContent` for this.
|
1433
|
+
const relation = this.getWireContent()?.["m.relates_to"];
|
1434
|
+
if (
|
1435
|
+
this.isState() &&
|
1436
|
+
!!relation?.rel_type &&
|
1437
|
+
([RelationType.Replace, RelationType.Thread] as string[]).includes(relation.rel_type)
|
1438
|
+
) {
|
1439
|
+
// State events cannot be m.replace or m.thread relations
|
1440
|
+
return false;
|
1441
|
+
}
|
1442
|
+
return !!(relation?.rel_type && relation.event_id && (relType ? relation.rel_type === relType : true));
|
1443
|
+
}
|
1444
|
+
|
1445
|
+
/**
|
1446
|
+
* Get relation info for the event, if any.
|
1447
|
+
*/
|
1448
|
+
public getRelation(): IEventRelation | null {
|
1449
|
+
if (!this.isRelation()) {
|
1450
|
+
return null;
|
1451
|
+
}
|
1452
|
+
return this.getWireContent()["m.relates_to"] ?? null;
|
1453
|
+
}
|
1454
|
+
|
1455
|
+
/**
|
1456
|
+
* Set an event that replaces the content of this event, through an m.replace relation.
|
1457
|
+
*
|
1458
|
+
* @param newEvent - the event with the replacing content, if any.
|
1459
|
+
*
|
1460
|
+
* @remarks
|
1461
|
+
* Fires {@link MatrixEventEvent.Replaced}
|
1462
|
+
*/
|
1463
|
+
public makeReplaced(newEvent?: MatrixEvent): void {
|
1464
|
+
// don't allow redacted events to be replaced.
|
1465
|
+
// if newEvent is null we allow to go through though,
|
1466
|
+
// as with local redaction, the replacing event might get
|
1467
|
+
// cancelled, which should be reflected on the target event.
|
1468
|
+
if (this.isRedacted() && newEvent) {
|
1469
|
+
return;
|
1470
|
+
}
|
1471
|
+
// don't allow state events to be replaced using this mechanism as per MSC2676
|
1472
|
+
if (this.isState()) {
|
1473
|
+
return;
|
1474
|
+
}
|
1475
|
+
if (this._replacingEvent !== newEvent) {
|
1476
|
+
this._replacingEvent = newEvent ?? null;
|
1477
|
+
this.emit(MatrixEventEvent.Replaced, this);
|
1478
|
+
this.invalidateExtensibleEvent();
|
1479
|
+
}
|
1480
|
+
}
|
1481
|
+
|
1482
|
+
/**
|
1483
|
+
* Returns the status of any associated edit or redaction
|
1484
|
+
* (not for reactions/annotations as their local echo doesn't affect the original event),
|
1485
|
+
* or else the status of the event.
|
1486
|
+
*/
|
1487
|
+
public getAssociatedStatus(): EventStatus | null {
|
1488
|
+
if (this._replacingEvent) {
|
1489
|
+
return this._replacingEvent.status;
|
1490
|
+
} else if (this._localRedactionEvent) {
|
1491
|
+
return this._localRedactionEvent.status;
|
1492
|
+
}
|
1493
|
+
return this.status;
|
1494
|
+
}
|
1495
|
+
|
1496
|
+
public getServerAggregatedRelation<T>(relType: RelationType | string): T | undefined {
|
1497
|
+
return this.getUnsigned()["m.relations"]?.[relType];
|
1498
|
+
}
|
1499
|
+
|
1500
|
+
/**
|
1501
|
+
* Returns the event ID of the event replacing the content of this event, if any.
|
1502
|
+
*/
|
1503
|
+
public replacingEventId(): string | undefined {
|
1504
|
+
const replaceRelation = this.getServerAggregatedRelation<IAggregatedRelation>(RelationType.Replace);
|
1505
|
+
if (replaceRelation) {
|
1506
|
+
return replaceRelation.event_id;
|
1507
|
+
} else if (this._replacingEvent) {
|
1508
|
+
return this._replacingEvent.getId();
|
1509
|
+
}
|
1510
|
+
}
|
1511
|
+
|
1512
|
+
/**
|
1513
|
+
* Returns the event replacing the content of this event, if any.
|
1514
|
+
* Replacements are aggregated on the server, so this would only
|
1515
|
+
* return an event in case it came down the sync, or for local echo of edits.
|
1516
|
+
*/
|
1517
|
+
public replacingEvent(): MatrixEvent | null {
|
1518
|
+
return this._replacingEvent;
|
1519
|
+
}
|
1520
|
+
|
1521
|
+
/**
|
1522
|
+
* Returns the origin_server_ts of the event replacing the content of this event, if any.
|
1523
|
+
*/
|
1524
|
+
public replacingEventDate(): Date | undefined {
|
1525
|
+
const replaceRelation = this.getServerAggregatedRelation<IAggregatedRelation>(RelationType.Replace);
|
1526
|
+
if (replaceRelation) {
|
1527
|
+
const ts = replaceRelation.origin_server_ts;
|
1528
|
+
if (Number.isFinite(ts)) {
|
1529
|
+
return new Date(ts);
|
1530
|
+
}
|
1531
|
+
} else if (this._replacingEvent) {
|
1532
|
+
return this._replacingEvent.getDate() ?? undefined;
|
1533
|
+
}
|
1534
|
+
}
|
1535
|
+
|
1536
|
+
/**
|
1537
|
+
* Returns the event that wants to redact this event, but hasn't been sent yet.
|
1538
|
+
* @returns the event
|
1539
|
+
*/
|
1540
|
+
public localRedactionEvent(): MatrixEvent | null {
|
1541
|
+
return this._localRedactionEvent;
|
1542
|
+
}
|
1543
|
+
|
1544
|
+
/**
|
1545
|
+
* For relations and redactions, returns the event_id this event is referring to.
|
1546
|
+
*/
|
1547
|
+
public getAssociatedId(): string | undefined {
|
1548
|
+
const relation = this.getRelation();
|
1549
|
+
if (this.replyEventId) {
|
1550
|
+
return this.replyEventId;
|
1551
|
+
} else if (relation) {
|
1552
|
+
return relation.event_id;
|
1553
|
+
} else if (this.isRedaction()) {
|
1554
|
+
return this.event.redacts;
|
1555
|
+
}
|
1556
|
+
}
|
1557
|
+
|
1558
|
+
/**
|
1559
|
+
* Checks if this event is associated with another event. See `getAssociatedId`.
|
1560
|
+
*/
|
1561
|
+
public hasAssociation(): boolean {
|
1562
|
+
return !!this.getAssociatedId();
|
1563
|
+
}
|
1564
|
+
|
1565
|
+
/**
|
1566
|
+
* Update the related id with a new one.
|
1567
|
+
*
|
1568
|
+
* Used to replace a local id with remote one before sending
|
1569
|
+
* an event with a related id.
|
1570
|
+
*
|
1571
|
+
* @param eventId - the new event id
|
1572
|
+
*/
|
1573
|
+
public updateAssociatedId(eventId: string): void {
|
1574
|
+
const relation = this.getRelation();
|
1575
|
+
if (relation) {
|
1576
|
+
relation.event_id = eventId;
|
1577
|
+
} else if (this.isRedaction()) {
|
1578
|
+
this.event.redacts = eventId;
|
1579
|
+
}
|
1580
|
+
}
|
1581
|
+
|
1582
|
+
/**
|
1583
|
+
* Flags an event as cancelled due to future conditions. For example, a verification
|
1584
|
+
* request event in the same sync transaction may be flagged as cancelled to warn
|
1585
|
+
* listeners that a cancellation event is coming down the same pipe shortly.
|
1586
|
+
* @param cancelled - Whether the event is to be cancelled or not.
|
1587
|
+
*/
|
1588
|
+
public flagCancelled(cancelled = true): void {
|
1589
|
+
this._isCancelled = cancelled;
|
1590
|
+
}
|
1591
|
+
|
1592
|
+
/**
|
1593
|
+
* Gets whether or not the event is flagged as cancelled. See flagCancelled() for
|
1594
|
+
* more information.
|
1595
|
+
* @returns True if the event is cancelled, false otherwise.
|
1596
|
+
*/
|
1597
|
+
public isCancelled(): boolean {
|
1598
|
+
return this._isCancelled;
|
1599
|
+
}
|
1600
|
+
|
1601
|
+
/**
|
1602
|
+
* Get a copy/snapshot of this event. The returned copy will be loosely linked
|
1603
|
+
* back to this instance, though will have "frozen" event information. Other
|
1604
|
+
* properties of this MatrixEvent instance will be copied verbatim, which can
|
1605
|
+
* mean they are in reference to this instance despite being on the copy too.
|
1606
|
+
* The reference the snapshot uses does not change, however members aside from
|
1607
|
+
* the underlying event will not be deeply cloned, thus may be mutated internally.
|
1608
|
+
* For example, the sender profile will be copied over at snapshot time, and
|
1609
|
+
* the sender profile internally may mutate without notice to the consumer.
|
1610
|
+
*
|
1611
|
+
* This is meant to be used to snapshot the event details themselves, not the
|
1612
|
+
* features (such as sender) surrounding the event.
|
1613
|
+
* @returns A snapshot of this event.
|
1614
|
+
*/
|
1615
|
+
public toSnapshot(): MatrixEvent {
|
1616
|
+
const ev = new MatrixEvent(JSON.parse(JSON.stringify(this.event)));
|
1617
|
+
for (const [p, v] of Object.entries(this)) {
|
1618
|
+
if (p !== "event") {
|
1619
|
+
// exclude the thing we just cloned
|
1620
|
+
// @ts-ignore - XXX: this is just nasty
|
1621
|
+
ev[p as keyof MatrixEvent] = v;
|
1622
|
+
}
|
1623
|
+
}
|
1624
|
+
return ev;
|
1625
|
+
}
|
1626
|
+
|
1627
|
+
/**
|
1628
|
+
* Determines if this event is equivalent to the given event. This only checks
|
1629
|
+
* the event object itself, not the other properties of the event. Intended for
|
1630
|
+
* use with toSnapshot() to identify events changing.
|
1631
|
+
* @param otherEvent - The other event to check against.
|
1632
|
+
* @returns True if the events are the same, false otherwise.
|
1633
|
+
*/
|
1634
|
+
public isEquivalentTo(otherEvent: MatrixEvent): boolean {
|
1635
|
+
if (!otherEvent) return false;
|
1636
|
+
if (otherEvent === this) return true;
|
1637
|
+
const myProps = deepSortedObjectEntries(this.event);
|
1638
|
+
const theirProps = deepSortedObjectEntries(otherEvent.event);
|
1639
|
+
return JSON.stringify(myProps) === JSON.stringify(theirProps);
|
1640
|
+
}
|
1641
|
+
|
1642
|
+
/**
|
1643
|
+
* Summarise the event as JSON.
|
1644
|
+
*
|
1645
|
+
* If encrypted, include both the decrypted and encrypted view of the event.
|
1646
|
+
*
|
1647
|
+
* This is named `toJSON` for use with `JSON.stringify` which checks objects
|
1648
|
+
* for functions named `toJSON` and will call them to customise the output
|
1649
|
+
* if they are defined.
|
1650
|
+
*
|
1651
|
+
* **WARNING** Do not log the result of this method; otherwise, it will end up
|
1652
|
+
* in rageshakes, leading to a privacy violation.
|
1653
|
+
*
|
1654
|
+
* @deprecated Prefer to use {@link MatrixEvent#getEffectiveEvent} or similar.
|
1655
|
+
* This method will be removed soon; it is too easy to use it accidentally
|
1656
|
+
* and cause a privacy violation (cf https://github.com/vector-im/element-web/issues/26380).
|
1657
|
+
* In any case, the value it returns is not a faithful serialization of the object.
|
1658
|
+
*/
|
1659
|
+
public toJSON(): object {
|
1660
|
+
const event = this.getEffectiveEvent();
|
1661
|
+
|
1662
|
+
if (!this.isEncrypted()) {
|
1663
|
+
return event;
|
1664
|
+
}
|
1665
|
+
|
1666
|
+
return {
|
1667
|
+
decrypted: event,
|
1668
|
+
encrypted: this.event,
|
1669
|
+
};
|
1670
|
+
}
|
1671
|
+
|
1672
|
+
public setVerificationRequest(request: VerificationRequest): void {
|
1673
|
+
this.verificationRequest = request;
|
1674
|
+
}
|
1675
|
+
|
1676
|
+
public setTxnId(txnId: string): void {
|
1677
|
+
this.txnId = txnId;
|
1678
|
+
}
|
1679
|
+
|
1680
|
+
public getTxnId(): string | undefined {
|
1681
|
+
return this.txnId;
|
1682
|
+
}
|
1683
|
+
|
1684
|
+
/**
|
1685
|
+
* Set the instance of a thread associated with the current event
|
1686
|
+
* @param thread - the thread
|
1687
|
+
*/
|
1688
|
+
public setThread(thread?: Thread): void {
|
1689
|
+
// don't allow state events to be threaded as per the spec
|
1690
|
+
if (this.isState()) {
|
1691
|
+
return;
|
1692
|
+
}
|
1693
|
+
if (this.thread) {
|
1694
|
+
this.reEmitter.stopReEmitting(this.thread, [ThreadEvent.Update]);
|
1695
|
+
}
|
1696
|
+
this.thread = thread;
|
1697
|
+
this.setThreadId(thread?.id);
|
1698
|
+
if (thread) {
|
1699
|
+
this.reEmitter.reEmit(thread, [ThreadEvent.Update]);
|
1700
|
+
}
|
1701
|
+
}
|
1702
|
+
|
1703
|
+
/**
|
1704
|
+
* Get the instance of the thread associated with the current event
|
1705
|
+
*/
|
1706
|
+
public getThread(): Thread | undefined {
|
1707
|
+
return this.thread;
|
1708
|
+
}
|
1709
|
+
|
1710
|
+
public setThreadId(threadId?: string): void {
|
1711
|
+
this.threadId = threadId;
|
1712
|
+
}
|
1713
|
+
}
|
1714
|
+
|
1715
|
+
/* REDACT_KEEP_KEYS gives the keys we keep when an event is redacted
|
1716
|
+
*
|
1717
|
+
* This is specified here:
|
1718
|
+
* http://matrix.org/speculator/spec/HEAD/client_server/latest.html#redactions
|
1719
|
+
*
|
1720
|
+
* Also:
|
1721
|
+
* - We keep 'unsigned' since that is created by the local server
|
1722
|
+
* - We keep user_id for backwards-compat with v1
|
1723
|
+
*/
|
1724
|
+
const REDACT_KEEP_KEYS = new Set([
|
1725
|
+
"event_id",
|
1726
|
+
"type",
|
1727
|
+
"room_id",
|
1728
|
+
"user_id",
|
1729
|
+
"sender",
|
1730
|
+
"state_key",
|
1731
|
+
"prev_state",
|
1732
|
+
"content",
|
1733
|
+
"unsigned",
|
1734
|
+
"origin_server_ts",
|
1735
|
+
]);
|
1736
|
+
|
1737
|
+
// a map from state event type to the .content keys we keep when an event is redacted
|
1738
|
+
const REDACT_KEEP_CONTENT_MAP: Record<string, Record<string, 1>> = {
|
1739
|
+
[EventType.RoomMember]: { membership: 1 },
|
1740
|
+
[EventType.RoomJoinRules]: { join_rule: 1 },
|
1741
|
+
[EventType.RoomPowerLevels]: {
|
1742
|
+
ban: 1,
|
1743
|
+
events: 1,
|
1744
|
+
events_default: 1,
|
1745
|
+
kick: 1,
|
1746
|
+
redact: 1,
|
1747
|
+
state_default: 1,
|
1748
|
+
users: 1,
|
1749
|
+
users_default: 1,
|
1750
|
+
},
|
1751
|
+
} as const;
|