@unwanted/matrix-sdk-mini 34.12.0-1 → 34.12.0-3
Sign up to get free protection for your applications and to get access to all the features.
- package/git-revision.txt +1 -1
- package/lib/@types/event.d.ts +0 -19
- package/lib/@types/event.d.ts.map +1 -1
- package/lib/@types/event.js.map +1 -1
- package/lib/@types/global.d.js +0 -2
- package/lib/@types/global.d.js.map +1 -1
- package/lib/browser-index.d.ts.map +1 -1
- package/lib/browser-index.js +0 -11
- package/lib/browser-index.js.map +1 -1
- package/lib/client.d.ts +2 -1224
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +345 -2826
- package/lib/client.js.map +1 -1
- package/lib/embedded.d.ts +0 -22
- package/lib/embedded.d.ts.map +1 -1
- package/lib/embedded.js +24 -167
- package/lib/embedded.js.map +1 -1
- package/lib/event-mapper.d.ts.map +1 -1
- package/lib/event-mapper.js +0 -4
- package/lib/event-mapper.js.map +1 -1
- package/lib/matrix.d.ts +0 -25
- package/lib/matrix.d.ts.map +1 -1
- package/lib/matrix.js +1 -30
- package/lib/matrix.js.map +1 -1
- package/lib/models/MSC3089Branch.d.ts.map +1 -1
- package/lib/models/MSC3089Branch.js +0 -3
- package/lib/models/MSC3089Branch.js.map +1 -1
- package/lib/models/event.d.ts +0 -94
- package/lib/models/event.d.ts.map +1 -1
- package/lib/models/event.js +0 -274
- package/lib/models/event.js.map +1 -1
- package/lib/models/poll.d.ts.map +1 -1
- package/lib/models/poll.js +1 -5
- package/lib/models/poll.js.map +1 -1
- package/lib/models/relations-container.d.ts.map +1 -1
- package/lib/models/relations-container.js +1 -7
- package/lib/models/relations-container.js.map +1 -1
- package/lib/models/relations.d.ts +0 -1
- package/lib/models/relations.d.ts.map +1 -1
- package/lib/models/relations.js +0 -8
- package/lib/models/relations.js.map +1 -1
- package/lib/models/room-state.d.ts.map +1 -1
- package/lib/models/room-state.js +10 -26
- package/lib/models/room-state.js.map +1 -1
- package/lib/models/room.d.ts +0 -18
- package/lib/models/room.d.ts.map +1 -1
- package/lib/models/room.js +94 -148
- package/lib/models/room.js.map +1 -1
- package/lib/models/thread.d.ts.map +1 -1
- package/lib/models/thread.js +0 -1
- package/lib/models/thread.js.map +1 -1
- package/lib/sliding-sync-sdk.d.ts +2 -3
- package/lib/sliding-sync-sdk.d.ts.map +1 -1
- package/lib/sliding-sync-sdk.js +41 -90
- package/lib/sliding-sync-sdk.js.map +1 -1
- package/lib/sync.d.ts +0 -12
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +1 -73
- package/lib/sync.js.map +1 -1
- package/lib/testing.d.ts +0 -48
- package/lib/testing.d.ts.map +1 -1
- package/lib/testing.js +0 -105
- package/lib/testing.js.map +1 -1
- package/package.json +1 -3
- package/src/@types/event.ts +2 -36
- package/src/@types/global.d.ts +0 -3
- package/src/browser-index.ts +0 -11
- package/src/client.ts +52 -2876
- package/src/embedded.ts +3 -132
- package/src/event-mapper.ts +0 -4
- package/src/matrix.ts +0 -41
- package/src/models/MSC3089Branch.ts +0 -3
- package/src/models/event.ts +0 -289
- package/src/models/poll.ts +0 -6
- package/src/models/relations-container.ts +1 -8
- package/src/models/relations.ts +0 -8
- package/src/models/room-state.ts +2 -8
- package/src/models/room.ts +0 -62
- package/src/models/thread.ts +0 -1
- package/src/sliding-sync-sdk.ts +2 -72
- package/src/sync.ts +1 -98
- package/src/testing.ts +0 -108
- package/lib/@types/crypto.d.ts +0 -47
- package/lib/@types/crypto.d.ts.map +0 -1
- package/lib/@types/crypto.js +0 -1
- package/lib/@types/crypto.js.map +0 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js +0 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js.map +0 -1
- package/lib/common-crypto/CryptoBackend.d.ts +0 -240
- package/lib/common-crypto/CryptoBackend.d.ts.map +0 -1
- package/lib/common-crypto/CryptoBackend.js +0 -73
- package/lib/common-crypto/CryptoBackend.js.map +0 -1
- package/lib/common-crypto/key-passphrase.d.ts +0 -14
- package/lib/common-crypto/key-passphrase.d.ts.map +0 -1
- package/lib/common-crypto/key-passphrase.js +0 -33
- package/lib/common-crypto/key-passphrase.js.map +0 -1
- package/lib/crypto/CrossSigning.d.ts +0 -184
- package/lib/crypto/CrossSigning.d.ts.map +0 -1
- package/lib/crypto/CrossSigning.js +0 -718
- package/lib/crypto/CrossSigning.js.map +0 -1
- package/lib/crypto/DeviceList.d.ts +0 -216
- package/lib/crypto/DeviceList.d.ts.map +0 -1
- package/lib/crypto/DeviceList.js +0 -892
- package/lib/crypto/DeviceList.js.map +0 -1
- package/lib/crypto/EncryptionSetup.d.ts +0 -152
- package/lib/crypto/EncryptionSetup.d.ts.map +0 -1
- package/lib/crypto/EncryptionSetup.js +0 -356
- package/lib/crypto/EncryptionSetup.js.map +0 -1
- package/lib/crypto/OlmDevice.d.ts +0 -457
- package/lib/crypto/OlmDevice.d.ts.map +0 -1
- package/lib/crypto/OlmDevice.js +0 -1241
- package/lib/crypto/OlmDevice.js.map +0 -1
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts +0 -109
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts.map +0 -1
- package/lib/crypto/OutgoingRoomKeyRequestManager.js +0 -415
- package/lib/crypto/OutgoingRoomKeyRequestManager.js.map +0 -1
- package/lib/crypto/RoomList.d.ts +0 -26
- package/lib/crypto/RoomList.d.ts.map +0 -1
- package/lib/crypto/RoomList.js +0 -71
- package/lib/crypto/RoomList.js.map +0 -1
- package/lib/crypto/SecretSharing.d.ts +0 -24
- package/lib/crypto/SecretSharing.d.ts.map +0 -1
- package/lib/crypto/SecretSharing.js +0 -194
- package/lib/crypto/SecretSharing.js.map +0 -1
- package/lib/crypto/SecretStorage.d.ts +0 -55
- package/lib/crypto/SecretStorage.d.ts.map +0 -1
- package/lib/crypto/SecretStorage.js +0 -118
- package/lib/crypto/SecretStorage.js.map +0 -1
- package/lib/crypto/aes.d.ts +0 -6
- package/lib/crypto/aes.d.ts.map +0 -1
- package/lib/crypto/aes.js +0 -24
- package/lib/crypto/aes.js.map +0 -1
- package/lib/crypto/algorithms/base.d.ts +0 -156
- package/lib/crypto/algorithms/base.d.ts.map +0 -1
- package/lib/crypto/algorithms/base.js +0 -187
- package/lib/crypto/algorithms/base.js.map +0 -1
- package/lib/crypto/algorithms/index.d.ts +0 -4
- package/lib/crypto/algorithms/index.d.ts.map +0 -1
- package/lib/crypto/algorithms/index.js +0 -20
- package/lib/crypto/algorithms/index.js.map +0 -1
- package/lib/crypto/algorithms/megolm.d.ts +0 -385
- package/lib/crypto/algorithms/megolm.d.ts.map +0 -1
- package/lib/crypto/algorithms/megolm.js +0 -1822
- package/lib/crypto/algorithms/megolm.js.map +0 -1
- package/lib/crypto/algorithms/olm.d.ts +0 -5
- package/lib/crypto/algorithms/olm.d.ts.map +0 -1
- package/lib/crypto/algorithms/olm.js +0 -299
- package/lib/crypto/algorithms/olm.js.map +0 -1
- package/lib/crypto/api.d.ts +0 -32
- package/lib/crypto/api.d.ts.map +0 -1
- package/lib/crypto/api.js +0 -22
- package/lib/crypto/api.js.map +0 -1
- package/lib/crypto/backup.d.ts +0 -227
- package/lib/crypto/backup.d.ts.map +0 -1
- package/lib/crypto/backup.js +0 -824
- package/lib/crypto/backup.js.map +0 -1
- package/lib/crypto/crypto.d.ts +0 -3
- package/lib/crypto/crypto.d.ts.map +0 -1
- package/lib/crypto/crypto.js +0 -19
- package/lib/crypto/crypto.js.map +0 -1
- package/lib/crypto/dehydration.d.ts +0 -34
- package/lib/crypto/dehydration.d.ts.map +0 -1
- package/lib/crypto/dehydration.js +0 -252
- package/lib/crypto/dehydration.js.map +0 -1
- package/lib/crypto/device-converter.d.ts +0 -9
- package/lib/crypto/device-converter.d.ts.map +0 -1
- package/lib/crypto/device-converter.js +0 -42
- package/lib/crypto/device-converter.js.map +0 -1
- package/lib/crypto/deviceinfo.d.ts +0 -99
- package/lib/crypto/deviceinfo.d.ts.map +0 -1
- package/lib/crypto/deviceinfo.js +0 -148
- package/lib/crypto/deviceinfo.js.map +0 -1
- package/lib/crypto/index.d.ts +0 -1209
- package/lib/crypto/index.d.ts.map +0 -1
- package/lib/crypto/index.js +0 -4097
- package/lib/crypto/index.js.map +0 -1
- package/lib/crypto/key_passphrase.d.ts +0 -14
- package/lib/crypto/key_passphrase.d.ts.map +0 -1
- package/lib/crypto/key_passphrase.js +0 -44
- package/lib/crypto/key_passphrase.js.map +0 -1
- package/lib/crypto/keybackup.d.ts +0 -18
- package/lib/crypto/keybackup.d.ts.map +0 -1
- package/lib/crypto/keybackup.js +0 -1
- package/lib/crypto/keybackup.js.map +0 -1
- package/lib/crypto/olmlib.d.ts +0 -129
- package/lib/crypto/olmlib.d.ts.map +0 -1
- package/lib/crypto/olmlib.js +0 -492
- package/lib/crypto/olmlib.js.map +0 -1
- package/lib/crypto/recoverykey.d.ts +0 -2
- package/lib/crypto/recoverykey.d.ts.map +0 -1
- package/lib/crypto/recoverykey.js +0 -19
- package/lib/crypto/recoverykey.js.map +0 -1
- package/lib/crypto/store/base.d.ts +0 -252
- package/lib/crypto/store/base.d.ts.map +0 -1
- package/lib/crypto/store/base.js +0 -64
- package/lib/crypto/store/base.js.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts +0 -187
- package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.js +0 -1145
- package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store.d.ts +0 -432
- package/lib/crypto/store/indexeddb-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store.js +0 -728
- package/lib/crypto/store/indexeddb-crypto-store.js.map +0 -1
- package/lib/crypto/store/localStorage-crypto-store.d.ts +0 -119
- package/lib/crypto/store/localStorage-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/localStorage-crypto-store.js +0 -531
- package/lib/crypto/store/localStorage-crypto-store.js.map +0 -1
- package/lib/crypto/store/memory-crypto-store.d.ts +0 -215
- package/lib/crypto/store/memory-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/memory-crypto-store.js +0 -622
- package/lib/crypto/store/memory-crypto-store.js.map +0 -1
- package/lib/crypto/verification/Base.d.ts +0 -105
- package/lib/crypto/verification/Base.d.ts.map +0 -1
- package/lib/crypto/verification/Base.js +0 -372
- package/lib/crypto/verification/Base.js.map +0 -1
- package/lib/crypto/verification/Error.d.ts +0 -35
- package/lib/crypto/verification/Error.d.ts.map +0 -1
- package/lib/crypto/verification/Error.js +0 -86
- package/lib/crypto/verification/Error.js.map +0 -1
- package/lib/crypto/verification/IllegalMethod.d.ts +0 -15
- package/lib/crypto/verification/IllegalMethod.d.ts.map +0 -1
- package/lib/crypto/verification/IllegalMethod.js +0 -43
- package/lib/crypto/verification/IllegalMethod.js.map +0 -1
- package/lib/crypto/verification/QRCode.d.ts +0 -51
- package/lib/crypto/verification/QRCode.d.ts.map +0 -1
- package/lib/crypto/verification/QRCode.js +0 -277
- package/lib/crypto/verification/QRCode.js.map +0 -1
- package/lib/crypto/verification/SAS.d.ts +0 -27
- package/lib/crypto/verification/SAS.d.ts.map +0 -1
- package/lib/crypto/verification/SAS.js +0 -485
- package/lib/crypto/verification/SAS.js.map +0 -1
- package/lib/crypto/verification/SASDecimal.d.ts +0 -8
- package/lib/crypto/verification/SASDecimal.d.ts.map +0 -1
- package/lib/crypto/verification/SASDecimal.js +0 -34
- package/lib/crypto/verification/SASDecimal.js.map +0 -1
- package/lib/crypto/verification/request/Channel.d.ts +0 -18
- package/lib/crypto/verification/request/Channel.d.ts.map +0 -1
- package/lib/crypto/verification/request/Channel.js +0 -1
- package/lib/crypto/verification/request/Channel.js.map +0 -1
- package/lib/crypto/verification/request/InRoomChannel.d.ts +0 -113
- package/lib/crypto/verification/request/InRoomChannel.d.ts.map +0 -1
- package/lib/crypto/verification/request/InRoomChannel.js +0 -351
- package/lib/crypto/verification/request/InRoomChannel.js.map +0 -1
- package/lib/crypto/verification/request/ToDeviceChannel.d.ts +0 -105
- package/lib/crypto/verification/request/ToDeviceChannel.d.ts.map +0 -1
- package/lib/crypto/verification/request/ToDeviceChannel.js +0 -328
- package/lib/crypto/verification/request/ToDeviceChannel.js.map +0 -1
- package/lib/crypto/verification/request/VerificationRequest.d.ts +0 -227
- package/lib/crypto/verification/request/VerificationRequest.d.ts.map +0 -1
- package/lib/crypto/verification/request/VerificationRequest.js +0 -937
- package/lib/crypto/verification/request/VerificationRequest.js.map +0 -1
- package/lib/crypto-api/CryptoEvent.d.ts +0 -69
- package/lib/crypto-api/CryptoEvent.d.ts.map +0 -1
- package/lib/crypto-api/CryptoEvent.js +0 -33
- package/lib/crypto-api/CryptoEvent.js.map +0 -1
- package/lib/crypto-api/CryptoEventHandlerMap.d.ts +0 -16
- package/lib/crypto-api/CryptoEventHandlerMap.d.ts.map +0 -1
- package/lib/crypto-api/CryptoEventHandlerMap.js +0 -22
- package/lib/crypto-api/CryptoEventHandlerMap.js.map +0 -1
- package/lib/crypto-api/index.d.ts +0 -978
- package/lib/crypto-api/index.d.ts.map +0 -1
- package/lib/crypto-api/index.js +0 -304
- package/lib/crypto-api/index.js.map +0 -1
- package/lib/crypto-api/key-passphrase.d.ts +0 -11
- package/lib/crypto-api/key-passphrase.d.ts.map +0 -1
- package/lib/crypto-api/key-passphrase.js +0 -51
- package/lib/crypto-api/key-passphrase.js.map +0 -1
- package/lib/crypto-api/keybackup.d.ts +0 -88
- package/lib/crypto-api/keybackup.d.ts.map +0 -1
- package/lib/crypto-api/keybackup.js +0 -1
- package/lib/crypto-api/keybackup.js.map +0 -1
- package/lib/crypto-api/recovery-key.d.ts +0 -11
- package/lib/crypto-api/recovery-key.d.ts.map +0 -1
- package/lib/crypto-api/recovery-key.js +0 -65
- package/lib/crypto-api/recovery-key.js.map +0 -1
- package/lib/crypto-api/verification.d.ts +0 -344
- package/lib/crypto-api/verification.d.ts.map +0 -1
- package/lib/crypto-api/verification.js +0 -91
- package/lib/crypto-api/verification.js.map +0 -1
- package/lib/matrixrtc/CallMembership.d.ts +0 -66
- package/lib/matrixrtc/CallMembership.d.ts.map +0 -1
- package/lib/matrixrtc/CallMembership.js +0 -197
- package/lib/matrixrtc/CallMembership.js.map +0 -1
- package/lib/matrixrtc/LivekitFocus.d.ts +0 -16
- package/lib/matrixrtc/LivekitFocus.d.ts.map +0 -1
- package/lib/matrixrtc/LivekitFocus.js +0 -20
- package/lib/matrixrtc/LivekitFocus.js.map +0 -1
- package/lib/matrixrtc/MatrixRTCSession.d.ts +0 -295
- package/lib/matrixrtc/MatrixRTCSession.d.ts.map +0 -1
- package/lib/matrixrtc/MatrixRTCSession.js +0 -1043
- package/lib/matrixrtc/MatrixRTCSession.js.map +0 -1
- package/lib/matrixrtc/MatrixRTCSessionManager.d.ts +0 -40
- package/lib/matrixrtc/MatrixRTCSessionManager.d.ts.map +0 -1
- package/lib/matrixrtc/MatrixRTCSessionManager.js +0 -146
- package/lib/matrixrtc/MatrixRTCSessionManager.js.map +0 -1
- package/lib/matrixrtc/focus.d.ts +0 -10
- package/lib/matrixrtc/focus.d.ts.map +0 -1
- package/lib/matrixrtc/focus.js +0 -1
- package/lib/matrixrtc/focus.js.map +0 -1
- package/lib/matrixrtc/index.d.ts +0 -7
- package/lib/matrixrtc/index.d.ts.map +0 -1
- package/lib/matrixrtc/index.js +0 -21
- package/lib/matrixrtc/index.js.map +0 -1
- package/lib/matrixrtc/types.d.ts +0 -19
- package/lib/matrixrtc/types.d.ts.map +0 -1
- package/lib/matrixrtc/types.js +0 -1
- package/lib/matrixrtc/types.js.map +0 -1
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts +0 -112
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts.map +0 -1
- package/lib/rendezvous/MSC4108SignInWithQR.js +0 -392
- package/lib/rendezvous/MSC4108SignInWithQR.js.map +0 -1
- package/lib/rendezvous/RendezvousChannel.d.ts +0 -27
- package/lib/rendezvous/RendezvousChannel.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousChannel.js +0 -1
- package/lib/rendezvous/RendezvousChannel.js.map +0 -1
- package/lib/rendezvous/RendezvousCode.d.ts +0 -9
- package/lib/rendezvous/RendezvousCode.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousCode.js +0 -1
- package/lib/rendezvous/RendezvousCode.js.map +0 -1
- package/lib/rendezvous/RendezvousError.d.ts +0 -6
- package/lib/rendezvous/RendezvousError.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousError.js +0 -23
- package/lib/rendezvous/RendezvousError.js.map +0 -1
- package/lib/rendezvous/RendezvousFailureReason.d.ts +0 -31
- package/lib/rendezvous/RendezvousFailureReason.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousFailureReason.js +0 -38
- package/lib/rendezvous/RendezvousFailureReason.js.map +0 -1
- package/lib/rendezvous/RendezvousIntent.d.ts +0 -5
- package/lib/rendezvous/RendezvousIntent.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousIntent.js +0 -22
- package/lib/rendezvous/RendezvousIntent.js.map +0 -1
- package/lib/rendezvous/RendezvousTransport.d.ts +0 -36
- package/lib/rendezvous/RendezvousTransport.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousTransport.js +0 -1
- package/lib/rendezvous/RendezvousTransport.js.map +0 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts +0 -58
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts.map +0 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.js +0 -246
- package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +0 -1
- package/lib/rendezvous/channels/index.d.ts +0 -2
- package/lib/rendezvous/channels/index.d.ts.map +0 -1
- package/lib/rendezvous/channels/index.js +0 -18
- package/lib/rendezvous/channels/index.js.map +0 -1
- package/lib/rendezvous/index.d.ts +0 -10
- package/lib/rendezvous/index.d.ts.map +0 -1
- package/lib/rendezvous/index.js +0 -23
- package/lib/rendezvous/index.js.map +0 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +0 -61
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts.map +0 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js +0 -253
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +0 -1
- package/lib/rendezvous/transports/index.d.ts +0 -2
- package/lib/rendezvous/transports/index.d.ts.map +0 -1
- package/lib/rendezvous/transports/index.js +0 -18
- package/lib/rendezvous/transports/index.js.map +0 -1
- package/lib/rust-crypto/CrossSigningIdentity.d.ts +0 -33
- package/lib/rust-crypto/CrossSigningIdentity.d.ts.map +0 -1
- package/lib/rust-crypto/CrossSigningIdentity.js +0 -157
- package/lib/rust-crypto/CrossSigningIdentity.js.map +0 -1
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts +0 -98
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts.map +0 -1
- package/lib/rust-crypto/DehydratedDeviceManager.js +0 -285
- package/lib/rust-crypto/DehydratedDeviceManager.js.map +0 -1
- package/lib/rust-crypto/KeyClaimManager.d.ts +0 -33
- package/lib/rust-crypto/KeyClaimManager.d.ts.map +0 -1
- package/lib/rust-crypto/KeyClaimManager.js +0 -82
- package/lib/rust-crypto/KeyClaimManager.js.map +0 -1
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts +0 -43
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts.map +0 -1
- package/lib/rust-crypto/OutgoingRequestProcessor.js +0 -195
- package/lib/rust-crypto/OutgoingRequestProcessor.js.map +0 -1
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts +0 -47
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts.map +0 -1
- package/lib/rust-crypto/OutgoingRequestsManager.js +0 -148
- package/lib/rust-crypto/OutgoingRequestsManager.js.map +0 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +0 -120
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts.map +0 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +0 -467
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +0 -1
- package/lib/rust-crypto/RoomEncryptor.d.ts +0 -98
- package/lib/rust-crypto/RoomEncryptor.d.ts.map +0 -1
- package/lib/rust-crypto/RoomEncryptor.js +0 -299
- package/lib/rust-crypto/RoomEncryptor.js.map +0 -1
- package/lib/rust-crypto/backup.d.ts +0 -254
- package/lib/rust-crypto/backup.d.ts.map +0 -1
- package/lib/rust-crypto/backup.js +0 -837
- package/lib/rust-crypto/backup.js.map +0 -1
- package/lib/rust-crypto/constants.d.ts +0 -3
- package/lib/rust-crypto/constants.d.ts.map +0 -1
- package/lib/rust-crypto/constants.js +0 -19
- package/lib/rust-crypto/constants.js.map +0 -1
- package/lib/rust-crypto/device-converter.d.ts +0 -28
- package/lib/rust-crypto/device-converter.d.ts.map +0 -1
- package/lib/rust-crypto/device-converter.js +0 -123
- package/lib/rust-crypto/device-converter.js.map +0 -1
- package/lib/rust-crypto/index.d.ts +0 -61
- package/lib/rust-crypto/index.d.ts.map +0 -1
- package/lib/rust-crypto/index.js +0 -152
- package/lib/rust-crypto/index.js.map +0 -1
- package/lib/rust-crypto/libolm_migration.d.ts +0 -81
- package/lib/rust-crypto/libolm_migration.d.ts.map +0 -1
- package/lib/rust-crypto/libolm_migration.js +0 -459
- package/lib/rust-crypto/libolm_migration.js.map +0 -1
- package/lib/rust-crypto/rust-crypto.d.ts +0 -556
- package/lib/rust-crypto/rust-crypto.d.ts.map +0 -1
- package/lib/rust-crypto/rust-crypto.js +0 -2016
- package/lib/rust-crypto/rust-crypto.js.map +0 -1
- package/lib/rust-crypto/secret-storage.d.ts +0 -22
- package/lib/rust-crypto/secret-storage.d.ts.map +0 -1
- package/lib/rust-crypto/secret-storage.js +0 -63
- package/lib/rust-crypto/secret-storage.js.map +0 -1
- package/lib/rust-crypto/verification.d.ts +0 -319
- package/lib/rust-crypto/verification.d.ts.map +0 -1
- package/lib/rust-crypto/verification.js +0 -816
- package/lib/rust-crypto/verification.js.map +0 -1
- package/lib/secret-storage.d.ts +0 -370
- package/lib/secret-storage.d.ts.map +0 -1
- package/lib/secret-storage.js +0 -466
- package/lib/secret-storage.js.map +0 -1
- package/lib/webrtc/audioContext.d.ts +0 -15
- package/lib/webrtc/audioContext.d.ts.map +0 -1
- package/lib/webrtc/audioContext.js +0 -46
- package/lib/webrtc/audioContext.js.map +0 -1
- package/lib/webrtc/call.d.ts +0 -560
- package/lib/webrtc/call.d.ts.map +0 -1
- package/lib/webrtc/call.js +0 -2541
- package/lib/webrtc/call.js.map +0 -1
- package/lib/webrtc/callEventHandler.d.ts +0 -37
- package/lib/webrtc/callEventHandler.d.ts.map +0 -1
- package/lib/webrtc/callEventHandler.js +0 -344
- package/lib/webrtc/callEventHandler.js.map +0 -1
- package/lib/webrtc/callEventTypes.d.ts +0 -73
- package/lib/webrtc/callEventTypes.d.ts.map +0 -1
- package/lib/webrtc/callEventTypes.js +0 -13
- package/lib/webrtc/callEventTypes.js.map +0 -1
- package/lib/webrtc/callFeed.d.ts +0 -128
- package/lib/webrtc/callFeed.d.ts.map +0 -1
- package/lib/webrtc/callFeed.js +0 -289
- package/lib/webrtc/callFeed.js.map +0 -1
- package/lib/webrtc/groupCall.d.ts +0 -323
- package/lib/webrtc/groupCall.d.ts.map +0 -1
- package/lib/webrtc/groupCall.js +0 -1337
- package/lib/webrtc/groupCall.js.map +0 -1
- package/lib/webrtc/groupCallEventHandler.d.ts +0 -31
- package/lib/webrtc/groupCallEventHandler.d.ts.map +0 -1
- package/lib/webrtc/groupCallEventHandler.js +0 -178
- package/lib/webrtc/groupCallEventHandler.js.map +0 -1
- package/lib/webrtc/mediaHandler.d.ts +0 -89
- package/lib/webrtc/mediaHandler.d.ts.map +0 -1
- package/lib/webrtc/mediaHandler.js +0 -437
- package/lib/webrtc/mediaHandler.js.map +0 -1
- package/lib/webrtc/stats/callFeedStatsReporter.d.ts +0 -8
- package/lib/webrtc/stats/callFeedStatsReporter.d.ts.map +0 -1
- package/lib/webrtc/stats/callFeedStatsReporter.js +0 -82
- package/lib/webrtc/stats/callFeedStatsReporter.js.map +0 -1
- package/lib/webrtc/stats/callStatsReportGatherer.d.ts +0 -25
- package/lib/webrtc/stats/callStatsReportGatherer.d.ts.map +0 -1
- package/lib/webrtc/stats/callStatsReportGatherer.js +0 -199
- package/lib/webrtc/stats/callStatsReportGatherer.js.map +0 -1
- package/lib/webrtc/stats/callStatsReportSummary.d.ts +0 -17
- package/lib/webrtc/stats/callStatsReportSummary.d.ts.map +0 -1
- package/lib/webrtc/stats/callStatsReportSummary.js +0 -1
- package/lib/webrtc/stats/callStatsReportSummary.js.map +0 -1
- package/lib/webrtc/stats/connectionStats.d.ts +0 -28
- package/lib/webrtc/stats/connectionStats.d.ts.map +0 -1
- package/lib/webrtc/stats/connectionStats.js +0 -26
- package/lib/webrtc/stats/connectionStats.js.map +0 -1
- package/lib/webrtc/stats/connectionStatsBuilder.d.ts +0 -5
- package/lib/webrtc/stats/connectionStatsBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/connectionStatsBuilder.js +0 -27
- package/lib/webrtc/stats/connectionStatsBuilder.js.map +0 -1
- package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts +0 -7
- package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/connectionStatsReportBuilder.js +0 -121
- package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +0 -1
- package/lib/webrtc/stats/groupCallStats.d.ts +0 -22
- package/lib/webrtc/stats/groupCallStats.d.ts.map +0 -1
- package/lib/webrtc/stats/groupCallStats.js +0 -78
- package/lib/webrtc/stats/groupCallStats.js.map +0 -1
- package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts +0 -10
- package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaSsrcHandler.js +0 -57
- package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackHandler.d.ts +0 -12
- package/lib/webrtc/stats/media/mediaTrackHandler.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackHandler.js +0 -62
- package/lib/webrtc/stats/media/mediaTrackHandler.js.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStats.d.ts +0 -86
- package/lib/webrtc/stats/media/mediaTrackStats.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStats.js +0 -142
- package/lib/webrtc/stats/media/mediaTrackStats.js.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts +0 -22
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +0 -76
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +0 -1
- package/lib/webrtc/stats/statsReport.d.ts +0 -99
- package/lib/webrtc/stats/statsReport.d.ts.map +0 -1
- package/lib/webrtc/stats/statsReport.js +0 -32
- package/lib/webrtc/stats/statsReport.js.map +0 -1
- package/lib/webrtc/stats/statsReportEmitter.d.ts +0 -15
- package/lib/webrtc/stats/statsReportEmitter.d.ts.map +0 -1
- package/lib/webrtc/stats/statsReportEmitter.js +0 -33
- package/lib/webrtc/stats/statsReportEmitter.js.map +0 -1
- package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts +0 -16
- package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts.map +0 -1
- package/lib/webrtc/stats/summaryStatsReportGatherer.js +0 -116
- package/lib/webrtc/stats/summaryStatsReportGatherer.js.map +0 -1
- package/lib/webrtc/stats/trackStatsBuilder.d.ts +0 -19
- package/lib/webrtc/stats/trackStatsBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/trackStatsBuilder.js +0 -168
- package/lib/webrtc/stats/trackStatsBuilder.js.map +0 -1
- package/lib/webrtc/stats/transportStats.d.ts +0 -11
- package/lib/webrtc/stats/transportStats.d.ts.map +0 -1
- package/lib/webrtc/stats/transportStats.js +0 -1
- package/lib/webrtc/stats/transportStats.js.map +0 -1
- package/lib/webrtc/stats/transportStatsBuilder.d.ts +0 -5
- package/lib/webrtc/stats/transportStatsBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/transportStatsBuilder.js +0 -34
- package/lib/webrtc/stats/transportStatsBuilder.js.map +0 -1
- package/lib/webrtc/stats/valueFormatter.d.ts +0 -4
- package/lib/webrtc/stats/valueFormatter.d.ts.map +0 -1
- package/lib/webrtc/stats/valueFormatter.js +0 -25
- package/lib/webrtc/stats/valueFormatter.js.map +0 -1
- package/src/@types/crypto.ts +0 -73
- package/src/@types/matrix-sdk-crypto-wasm.d.ts +0 -44
- package/src/common-crypto/CryptoBackend.ts +0 -302
- package/src/common-crypto/README.md +0 -4
- package/src/common-crypto/key-passphrase.ts +0 -43
- package/src/crypto/CrossSigning.ts +0 -773
- package/src/crypto/DeviceList.ts +0 -989
- package/src/crypto/EncryptionSetup.ts +0 -351
- package/src/crypto/OlmDevice.ts +0 -1500
- package/src/crypto/OutgoingRoomKeyRequestManager.ts +0 -485
- package/src/crypto/RoomList.ts +0 -70
- package/src/crypto/SecretSharing.ts +0 -240
- package/src/crypto/SecretStorage.ts +0 -136
- package/src/crypto/aes.ts +0 -23
- package/src/crypto/algorithms/base.ts +0 -236
- package/src/crypto/algorithms/index.ts +0 -20
- package/src/crypto/algorithms/megolm.ts +0 -2216
- package/src/crypto/algorithms/olm.ts +0 -381
- package/src/crypto/api.ts +0 -70
- package/src/crypto/backup.ts +0 -922
- package/src/crypto/crypto.ts +0 -18
- package/src/crypto/dehydration.ts +0 -272
- package/src/crypto/device-converter.ts +0 -45
- package/src/crypto/deviceinfo.ts +0 -158
- package/src/crypto/index.ts +0 -4414
- package/src/crypto/key_passphrase.ts +0 -42
- package/src/crypto/keybackup.ts +0 -47
- package/src/crypto/olmlib.ts +0 -539
- package/src/crypto/recoverykey.ts +0 -18
- package/src/crypto/store/base.ts +0 -348
- package/src/crypto/store/indexeddb-crypto-store-backend.ts +0 -1250
- package/src/crypto/store/indexeddb-crypto-store.ts +0 -845
- package/src/crypto/store/localStorage-crypto-store.ts +0 -579
- package/src/crypto/store/memory-crypto-store.ts +0 -680
- package/src/crypto/verification/Base.ts +0 -409
- package/src/crypto/verification/Error.ts +0 -76
- package/src/crypto/verification/IllegalMethod.ts +0 -50
- package/src/crypto/verification/QRCode.ts +0 -310
- package/src/crypto/verification/SAS.ts +0 -494
- package/src/crypto/verification/SASDecimal.ts +0 -37
- package/src/crypto/verification/request/Channel.ts +0 -34
- package/src/crypto/verification/request/InRoomChannel.ts +0 -371
- package/src/crypto/verification/request/ToDeviceChannel.ts +0 -354
- package/src/crypto/verification/request/VerificationRequest.ts +0 -976
- package/src/crypto-api/CryptoEvent.ts +0 -93
- package/src/crypto-api/CryptoEventHandlerMap.ts +0 -32
- package/src/crypto-api/index.ts +0 -1175
- package/src/crypto-api/key-passphrase.ts +0 -58
- package/src/crypto-api/keybackup.ts +0 -115
- package/src/crypto-api/recovery-key.ts +0 -69
- package/src/crypto-api/verification.ts +0 -408
- package/src/matrixrtc/CallMembership.ts +0 -247
- package/src/matrixrtc/LivekitFocus.ts +0 -39
- package/src/matrixrtc/MatrixRTCSession.ts +0 -1319
- package/src/matrixrtc/MatrixRTCSessionManager.ts +0 -166
- package/src/matrixrtc/focus.ts +0 -25
- package/src/matrixrtc/index.ts +0 -22
- package/src/matrixrtc/types.ts +0 -36
- package/src/rendezvous/MSC4108SignInWithQR.ts +0 -444
- package/src/rendezvous/RendezvousChannel.ts +0 -48
- package/src/rendezvous/RendezvousCode.ts +0 -25
- package/src/rendezvous/RendezvousError.ts +0 -26
- package/src/rendezvous/RendezvousFailureReason.ts +0 -49
- package/src/rendezvous/RendezvousIntent.ts +0 -20
- package/src/rendezvous/RendezvousTransport.ts +0 -58
- package/src/rendezvous/channels/MSC4108SecureChannel.ts +0 -270
- package/src/rendezvous/channels/index.ts +0 -17
- package/src/rendezvous/index.ts +0 -25
- package/src/rendezvous/transports/MSC4108RendezvousSession.ts +0 -270
- package/src/rendezvous/transports/index.ts +0 -17
- package/src/rust-crypto/CrossSigningIdentity.ts +0 -183
- package/src/rust-crypto/DehydratedDeviceManager.ts +0 -306
- package/src/rust-crypto/KeyClaimManager.ts +0 -86
- package/src/rust-crypto/OutgoingRequestProcessor.ts +0 -236
- package/src/rust-crypto/OutgoingRequestsManager.ts +0 -143
- package/src/rust-crypto/PerSessionKeyBackupDownloader.ts +0 -501
- package/src/rust-crypto/RoomEncryptor.ts +0 -352
- package/src/rust-crypto/backup.ts +0 -881
- package/src/rust-crypto/constants.ts +0 -18
- package/src/rust-crypto/device-converter.ts +0 -128
- package/src/rust-crypto/index.ts +0 -237
- package/src/rust-crypto/libolm_migration.ts +0 -530
- package/src/rust-crypto/rust-crypto.ts +0 -2205
- package/src/rust-crypto/secret-storage.ts +0 -60
- package/src/rust-crypto/verification.ts +0 -830
- package/src/secret-storage.ts +0 -693
- package/src/webrtc/audioContext.ts +0 -44
- package/src/webrtc/call.ts +0 -3074
- package/src/webrtc/callEventHandler.ts +0 -425
- package/src/webrtc/callEventTypes.ts +0 -93
- package/src/webrtc/callFeed.ts +0 -364
- package/src/webrtc/groupCall.ts +0 -1735
- package/src/webrtc/groupCallEventHandler.ts +0 -234
- package/src/webrtc/mediaHandler.ts +0 -484
- package/src/webrtc/stats/callFeedStatsReporter.ts +0 -94
- package/src/webrtc/stats/callStatsReportGatherer.ts +0 -219
- package/src/webrtc/stats/callStatsReportSummary.ts +0 -30
- package/src/webrtc/stats/connectionStats.ts +0 -47
- package/src/webrtc/stats/connectionStatsBuilder.ts +0 -28
- package/src/webrtc/stats/connectionStatsReportBuilder.ts +0 -140
- package/src/webrtc/stats/groupCallStats.ts +0 -93
- package/src/webrtc/stats/media/mediaSsrcHandler.ts +0 -57
- package/src/webrtc/stats/media/mediaTrackHandler.ts +0 -76
- package/src/webrtc/stats/media/mediaTrackStats.ts +0 -176
- package/src/webrtc/stats/media/mediaTrackStatsHandler.ts +0 -90
- package/src/webrtc/stats/statsReport.ts +0 -133
- package/src/webrtc/stats/statsReportEmitter.ts +0 -49
- package/src/webrtc/stats/summaryStatsReportGatherer.ts +0 -148
- package/src/webrtc/stats/trackStatsBuilder.ts +0 -207
- package/src/webrtc/stats/transportStats.ts +0 -26
- package/src/webrtc/stats/transportStatsBuilder.ts +0 -48
- package/src/webrtc/stats/valueFormatter.ts +0 -27
package/lib/models/event.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"event.js","names":["ExtensibleEvents","logger","EVENT_VISIBILITY_CHANGE_TYPE","EventType","RelationType","ToDeviceMessageId","UNSIGNED_THREAD_ID_FIELD","UNSIGNED_MEMBERSHIP_FIELD","deepSortedObjectEntries","internaliseString","THREAD_RELATION_TYPE","ThreadEvent","TypedReEmitter","TypedEventEmitter","DecryptionError","EventTimeline","DecryptionFailureCode","EventStatus","MESSAGE_VISIBLE","Object","freeze","visible","MatrixEventEvent","MatrixEvent","constructor","_this$getTs","event","arguments","length","undefined","_defineProperty","forEach","prop","_event$content","content","_event$content2","txnId","txn_id","age","getAge","localTimestamp","Date","now","getTs","reEmitter","unstableExtensibleEvent","_hasCachedExtEv","_cachedExtEv","parse","getEffectiveEvent","invalidateExtensibleEvent","assign","getContent","getWireType","RoomMessageEncrypted","key","value","entries","getWireContent","includes","clearEvent","getId","event_id","getSender","sender","getType","type","getRoomId","room_id","origin_server_ts","getDate","getDetails","room","_this$getDate","concat","toISOString","msgid","getOriginalContent","_localRedactionEvent","_replacingEvent","threadRootId","_this$getWireContent","isState","relatesTo","rel_type","name","thread","id","threadId","unsigned","getUnsigned","isThreadRoot","threadDetails","getServerAggregatedRelation","replyEventId","_this$getWireContent$","relationEventId","_this$getWireContent2","getPrevContent","prev_content","getDirectionalContent","forwardLooking","getLocalAge","getStateKey","state_key","getMembershipAtEvent","findIn","makeEncrypted","cryptoType","cryptoContent","senderCurve25519Key","claimedEd25519Key","isBeingDecrypted","decryptionPromise","getDecryptionPromise","isDecryptionFailure","_decryptionFailureReason","decryptionFailureReason","isEncryptedDisabledForUnverifiedDevices","MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE","shouldAttemptDecryption","isRedacted","isEncrypted","attemptDecryption","crypto","_arguments","_this","_asyncToGenerator","options","Error","alreadyDecrypted","forceRedecrypt","forceRedecryptIfUntrusted","isKeySourceUntrusted","log","retryDecryption","decryptionLoop","cancelAndResendKeyRequest","userId","wireContent","requestRoomKey","algorithm","session_id","sender_key","getKeyRequestRecipients","recipients","deviceId","_arguments2","_this2","Promise","resolve","err","res","decryptEvent","isRetry","info","setClearData","e","detailedError","detailedString","String","warn","setClearDataForDecryptionFailure","code","UNKNOWN_ERROR","setPushDetails","emit","Decrypted","decryptionResult","_decryptionResult$sen","_decryptionResult$cla","forwardingCurve25519KeyChain","untrusted","reason","RoomMessage","msgtype","body","getClearContent","getSenderKey","getKeysClaimed","ed25519","getClaimedEd25519Key","getForwardingCurve25519KeyChain","setUnsigned","unmarkLocallyRedacted","redacted_because","markLocallyRedacted","redactionEvent","BeforeRedaction","applyVisibilityEvent","visibilityChange","_visibilityChange$vis","_visibilityChange$rea","change","visibility","VisibilityChange","messageVisibility","makeRedacted","hasOwnProperty","REDACT_KEEP_KEYS","has","keeps","REDACT_KEEP_CONTENT_MAP","moveAllRelatedToMainTimeline","moveToMainTimeline","events","_event$getRelation","getRelation","_this$thread","timelineSet","removeEvent","setThread","timeline","getLiveTimeline","getTimelineSet","insertEventIntoTimeline","getState","FORWARDS","Boolean","isRedaction","RoomRedaction","asVisibilityChange","matches","relation","eventId","isVisibilityEvent","getRedactionEvent","_this$clearEvent","_this$event$unsigned","_this$clearEvent$unsi","_this$clearEvent2","getPushActions","pushDetails","actions","getPushDetails","pushActions","rule","handleRemoteEcho","oldUnsigned","oldId","setStatus","LocalEventIdReplaced","isSending","status","Status","replaceLocalEventId","isRelation","relType","_this$getWireContent3","Replace","Thread","_this$getWireContent$2","makeReplaced","newEvent","Replaced","getAssociatedStatus","_this$getUnsigned$mR","replacingEventId","replaceRelation","replacingEvent","replacingEventDate","ts","Number","isFinite","_this$_replacingEvent","localRedactionEvent","getAssociatedId","redacts","hasAssociation","updateAssociatedId","flagCancelled","cancelled","_isCancelled","isCancelled","toSnapshot","ev","JSON","stringify","p","v","isEquivalentTo","otherEvent","myProps","theirProps","toJSON","decrypted","encrypted","setVerificationRequest","request","verificationRequest","setTxnId","getTxnId","stopReEmitting","Update","setThreadId","reEmit","getThread","Set","RoomMember","membership","RoomJoinRules","join_rule","RoomPowerLevels","ban","events_default","kick","redact","state_default","users","users_default"],"sources":["../../src/models/event.ts"],"sourcesContent":["/*\nCopyright 2015 - 2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n/**\n * This is an internal module. See {@link MatrixEvent} and {@link RoomEvent} for\n * the public classes.\n */\n\nimport { ExtensibleEvent, ExtensibleEvents, Optional } from \"matrix-events-sdk\";\n\nimport type { IEventDecryptionResult } from \"../@types/crypto.ts\";\nimport { logger } from \"../logger.ts\";\nimport { VerificationRequest } from \"../crypto/verification/request/VerificationRequest.ts\";\nimport {\n EVENT_VISIBILITY_CHANGE_TYPE,\n EventType,\n MsgType,\n RelationType,\n ToDeviceMessageId,\n UNSIGNED_THREAD_ID_FIELD,\n UNSIGNED_MEMBERSHIP_FIELD,\n} from \"../@types/event.ts\";\nimport { Crypto } from \"../crypto/index.ts\";\nimport { deepSortedObjectEntries, internaliseString } from \"../utils.ts\";\nimport { RoomMember } from \"./room-member.ts\";\nimport { Thread, THREAD_RELATION_TYPE, ThreadEvent, ThreadEventHandlerMap } from \"./thread.ts\";\nimport { IActionsObject } from \"../pushprocessor.ts\";\nimport { TypedReEmitter } from \"../ReEmitter.ts\";\nimport { MatrixError } from \"../http-api/index.ts\";\nimport { TypedEventEmitter } from \"./typed-event-emitter.ts\";\nimport { EventStatus } from \"./event-status.ts\";\nimport { CryptoBackend, DecryptionError } from \"../common-crypto/CryptoBackend.ts\";\nimport { IAnnotatedPushRule } from \"../@types/PushRules.ts\";\nimport { Room } from \"./room.ts\";\nimport { EventTimeline } from \"./event-timeline.ts\";\nimport { Membership } from \"../@types/membership.ts\";\nimport { DecryptionFailureCode } from \"../crypto-api/index.ts\";\n\nexport { EventStatus } from \"./event-status.ts\";\n\n/* eslint-disable camelcase */\nexport interface IContent {\n [key: string]: any;\n \"msgtype\"?: MsgType | string;\n \"membership\"?: Membership;\n \"avatar_url\"?: string;\n \"displayname\"?: string;\n \"m.relates_to\"?: IEventRelation;\n\n \"m.mentions\"?: IMentions;\n}\n\ntype StrippedState = Required<Pick<IEvent, \"content\" | \"state_key\" | \"type\" | \"sender\">>;\n\nexport interface IUnsigned {\n [key: string]: any;\n \"age\"?: number;\n \"prev_sender\"?: string;\n \"prev_content\"?: IContent;\n \"redacted_because\"?: IEvent;\n \"replaces_state\"?: string;\n \"transaction_id\"?: string;\n \"invite_room_state\"?: StrippedState[];\n \"m.relations\"?: Record<RelationType | string, any>; // No common pattern for aggregated relations\n [UNSIGNED_THREAD_ID_FIELD.name]?: string;\n}\n\nexport interface IThreadBundledRelationship {\n latest_event: IEvent;\n count: number;\n current_user_participated?: boolean;\n}\n\nexport interface IEvent {\n event_id: string;\n type: string;\n content: IContent;\n sender: string;\n room_id?: string;\n origin_server_ts: number;\n txn_id?: string;\n state_key?: string;\n membership?: Membership;\n unsigned: IUnsigned;\n redacts?: string;\n}\n\nexport interface IAggregatedRelation {\n origin_server_ts: number;\n event_id?: string;\n sender?: string;\n type?: string;\n count?: number;\n key?: string;\n}\n\nexport interface IEventRelation {\n \"rel_type\"?: RelationType | string;\n \"event_id\"?: string;\n \"is_falling_back\"?: boolean;\n \"m.in_reply_to\"?: {\n event_id?: string;\n };\n \"key\"?: string;\n}\n\nexport interface IMentions {\n user_ids?: string[];\n room?: boolean;\n}\n\nexport interface PushDetails {\n rule?: IAnnotatedPushRule;\n actions?: IActionsObject;\n}\n\n/**\n * When an event is a visibility change event, as per MSC3531,\n * the visibility change implied by the event.\n */\nexport interface IVisibilityChange {\n /**\n * If `true`, the target event should be made visible.\n * Otherwise, it should be hidden.\n */\n visible: boolean;\n\n /**\n * The event id affected.\n */\n eventId: string;\n\n /**\n * Optionally, a human-readable reason explaining why\n * the event was hidden. Ignored if the event was made\n * visible.\n */\n reason: string | null;\n}\n\nexport interface IMarkedUnreadEvent {\n unread: boolean;\n}\n\nexport interface IClearEvent {\n room_id?: string;\n type: string;\n content: Omit<IContent, \"membership\" | \"avatar_url\" | \"displayname\" | \"m.relates_to\">;\n unsigned?: IUnsigned;\n}\n/* eslint-enable camelcase */\n\ninterface IKeyRequestRecipient {\n userId: string;\n deviceId: \"*\" | string;\n}\n\nexport interface IDecryptOptions {\n /** Whether to emit {@link MatrixEventEvent.Decrypted} events on successful decryption. Defaults to true.\n */\n emit?: boolean;\n\n /**\n * True if this is a retry, after receiving an update to the session key. (Enables more logging.)\n *\n * This is only intended for use within the js-sdk.\n *\n * @internal\n */\n isRetry?: boolean;\n\n /**\n * Whether the message should be re-decrypted if it was previously successfully decrypted with an untrusted key.\n * Defaults to `false`.\n */\n forceRedecryptIfUntrusted?: boolean;\n}\n\n/**\n * Message hiding, as specified by https://github.com/matrix-org/matrix-doc/pull/3531.\n */\nexport type MessageVisibility = IMessageVisibilityHidden | IMessageVisibilityVisible;\n/**\n * Variant of `MessageVisibility` for the case in which the message should be displayed.\n */\nexport interface IMessageVisibilityVisible {\n readonly visible: true;\n}\n/**\n * Variant of `MessageVisibility` for the case in which the message should be hidden.\n */\nexport interface IMessageVisibilityHidden {\n readonly visible: false;\n /**\n * Optionally, a human-readable reason to show to the user indicating why the\n * message has been hidden (e.g. \"Message Pending Moderation\").\n */\n readonly reason: string | null;\n}\n// A singleton implementing `IMessageVisibilityVisible`.\nconst MESSAGE_VISIBLE: IMessageVisibilityVisible = Object.freeze({ visible: true });\n\nexport enum MatrixEventEvent {\n /**\n * An event has been decrypted, or we have failed to decrypt it.\n *\n * The payload consists of:\n *\n * * `event` - The {@link MatrixEvent} which we attempted to decrypt.\n *\n * * `err` - The error that occurred during decryption, or `undefined` if no error occurred.\n * Avoid use of this: {@link MatrixEvent.decryptionFailureReason} is more useful.\n */\n Decrypted = \"Event.decrypted\",\n\n BeforeRedaction = \"Event.beforeRedaction\",\n VisibilityChange = \"Event.visibilityChange\",\n LocalEventIdReplaced = \"Event.localEventIdReplaced\",\n Status = \"Event.status\",\n Replaced = \"Event.replaced\",\n RelationsCreated = \"Event.relationsCreated\",\n}\n\nexport type MatrixEventEmittedEvents = MatrixEventEvent | ThreadEvent.Update;\n\nexport type MatrixEventHandlerMap = {\n [MatrixEventEvent.Decrypted]: (event: MatrixEvent, err?: Error) => void;\n [MatrixEventEvent.BeforeRedaction]: (event: MatrixEvent, redactionEvent: MatrixEvent) => void;\n [MatrixEventEvent.VisibilityChange]: (event: MatrixEvent, visible: boolean) => void;\n [MatrixEventEvent.LocalEventIdReplaced]: (event: MatrixEvent) => void;\n [MatrixEventEvent.Status]: (event: MatrixEvent, status: EventStatus | null) => void;\n [MatrixEventEvent.Replaced]: (event: MatrixEvent) => void;\n [MatrixEventEvent.RelationsCreated]: (relationType: string, eventType: string) => void;\n} & Pick<ThreadEventHandlerMap, ThreadEvent.Update>;\n\nexport class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, MatrixEventHandlerMap> {\n // applied push rule and action for this event\n private pushDetails: PushDetails = {};\n private _replacingEvent: MatrixEvent | null = null;\n private _localRedactionEvent: MatrixEvent | null = null;\n private _isCancelled = false;\n private clearEvent?: IClearEvent;\n\n /* Message hiding, as specified by https://github.com/matrix-org/matrix-doc/pull/3531.\n\n Note: We're returning this object, so any value stored here MUST be frozen.\n */\n private visibility: MessageVisibility = MESSAGE_VISIBLE;\n\n // Not all events will be extensible-event compatible, so cache a flag in\n // addition to a falsy cached event value. We check the flag later on in\n // a public getter to decide if the cache is valid.\n private _hasCachedExtEv = false;\n private _cachedExtEv: Optional<ExtensibleEvent> = undefined;\n\n /** If we failed to decrypt this event, the reason for the failure. Otherwise, `null`. */\n private _decryptionFailureReason: DecryptionFailureCode | null = null;\n\n /* curve25519 key which we believe belongs to the sender of the event. See\n * getSenderKey()\n */\n private senderCurve25519Key: string | null = null;\n\n /* ed25519 key which the sender of this event (for olm) or the creator of\n * the megolm session (for megolm) claims to own. See getClaimedEd25519Key()\n */\n private claimedEd25519Key: string | null = null;\n\n /* curve25519 keys of devices involved in telling us about the\n * senderCurve25519Key and claimedEd25519Key.\n * See getForwardingCurve25519KeyChain().\n */\n private forwardingCurve25519KeyChain: string[] = [];\n\n /* where the decryption key is untrusted\n */\n private untrusted: boolean | null = null;\n\n /* if we have a process decrypting this event, a Promise which resolves\n * when it is finished. Normally null.\n */\n private decryptionPromise: Promise<void> | null = null;\n\n /* flag to indicate if we should retry decrypting this event after the\n * first attempt (eg, we have received new data which means that a second\n * attempt may succeed)\n */\n private retryDecryption = false;\n\n /* The txnId with which this event was sent if it was during this session,\n * allows for a unique ID which does not change when the event comes back down sync.\n */\n private txnId?: string;\n\n /**\n * A reference to the thread this event belongs to\n */\n private thread?: Thread;\n private threadId?: string;\n\n /* Set an approximate timestamp for the event relative the local clock.\n * This will inherently be approximate because it doesn't take into account\n * the time between the server putting the 'age' field on the event as it sent\n * it to us and the time we're now constructing this event, but that's better\n * than assuming the local clock is in sync with the origin HS's clock.\n */\n public localTimestamp: number;\n\n /**\n * The room member who sent this event, or null e.g.\n * this is a presence event. This is only guaranteed to be set for events that\n * appear in a timeline, ie. do not guarantee that it will be set on state\n * events.\n * @privateRemarks\n * Should be read-only\n */\n public sender: RoomMember | null = null;\n /**\n * The room member who is the target of this event, e.g.\n * the invitee, the person being banned, etc.\n * @privateRemarks\n * Should be read-only\n */\n public target: RoomMember | null = null;\n /**\n * The sending status of the event.\n * @privateRemarks\n * Should be read-only\n */\n public status: EventStatus | null = null;\n /**\n * most recent error associated with sending the event, if any\n * @privateRemarks\n * Should be read-only. May not be a MatrixError.\n */\n public error: MatrixError | null = null;\n /**\n * True if this event is 'forward looking', meaning\n * that getDirectionalContent() will return event.content and not event.prev_content.\n * Only state events may be backwards looking\n * Default: true. <strong>This property is experimental and may change.</strong>\n * @privateRemarks\n * Should be read-only\n */\n public forwardLooking = true;\n\n /* If the event is a `m.key.verification.request` (or to_device `m.key.verification.start`) event,\n * `Crypto` will set this the `VerificationRequest` for the event\n * so it can be easily accessed from the timeline.\n */\n public verificationRequest?: VerificationRequest;\n\n private readonly reEmitter: TypedReEmitter<MatrixEventEmittedEvents, MatrixEventHandlerMap>;\n\n /**\n * Construct a Matrix Event object\n *\n * @param event - The raw (possibly encrypted) event. <b>Do not access\n * this property</b> directly unless you absolutely have to. Prefer the getter\n * methods defined on this class. Using the getter methods shields your app\n * from changes to event JSON between Matrix versions.\n */\n public constructor(public event: Partial<IEvent> = {}) {\n super();\n\n // intern the values of matrix events to force share strings and reduce the\n // amount of needless string duplication. This can save moderate amounts of\n // memory (~10% on a 350MB heap).\n // 'membership' at the event level (rather than the content level) is a legacy\n // field that Element never otherwise looks at, but it will still take up a lot\n // of space if we don't intern it.\n ([\"state_key\", \"type\", \"sender\", \"room_id\", \"membership\"] as const).forEach((prop) => {\n if (typeof event[prop] !== \"string\") return;\n event[prop] = internaliseString(event[prop]!);\n });\n\n ([\"membership\", \"avatar_url\", \"displayname\"] as const).forEach((prop) => {\n if (typeof event.content?.[prop] !== \"string\") return;\n event.content[prop] = internaliseString(event.content[prop]!);\n });\n\n ([\"rel_type\"] as const).forEach((prop) => {\n if (typeof event.content?.[\"m.relates_to\"]?.[prop] !== \"string\") return;\n event.content[\"m.relates_to\"][prop] = internaliseString(event.content[\"m.relates_to\"][prop]!);\n });\n\n this.txnId = event.txn_id;\n // The localTimestamp is calculated using the age.\n // Some events lack an `age` property, either because they are EDUs such as typing events,\n // or due to server-side bugs such as https://github.com/matrix-org/synapse/issues/8429.\n // The fallback in these cases will be to use the origin_server_ts.\n // For EDUs, the origin_server_ts also is not defined so we use Date.now().\n const age = this.getAge();\n this.localTimestamp = age !== undefined ? Date.now() - age : (this.getTs() ?? Date.now());\n this.reEmitter = new TypedReEmitter(this);\n }\n\n /**\n * Unstable getter to try and get an extensible event. Note that this might\n * return a falsy value if the event could not be parsed as an extensible\n * event.\n *\n * @deprecated Use stable functions where possible.\n */\n public get unstableExtensibleEvent(): Optional<ExtensibleEvent> {\n if (!this._hasCachedExtEv) {\n this._cachedExtEv = ExtensibleEvents.parse(this.getEffectiveEvent());\n }\n return this._cachedExtEv;\n }\n\n private invalidateExtensibleEvent(): void {\n // just reset the flag - that'll trick the getter into parsing a new event\n this._hasCachedExtEv = false;\n }\n\n /**\n * Gets the event as it would appear if it had been sent unencrypted.\n *\n * If the event is encrypted, we attempt to mock up an event as it would have looked had the sender not encrypted it.\n * If the event is not encrypted, a copy of it is simply returned as-is.\n *\n * @returns A shallow copy of the event, in wire format, as it would have been had it not been encrypted.\n */\n public getEffectiveEvent(): IEvent {\n const content = Object.assign({}, this.getContent()); // clone for mutation\n\n if (this.getWireType() === EventType.RoomMessageEncrypted) {\n // Encrypted events sometimes aren't symmetrical on the `content` so we'll copy\n // that over too, but only for missing properties. We don't copy over mismatches\n // between the plain and decrypted copies of `content` because we assume that the\n // app is relying on the decrypted version, so we want to expose that as a source\n // of truth here too.\n for (const [key, value] of Object.entries(this.getWireContent())) {\n // Skip fields from the encrypted event schema though - we don't want to leak\n // these.\n if ([\"algorithm\", \"ciphertext\", \"device_id\", \"sender_key\", \"session_id\"].includes(key)) {\n continue;\n }\n\n if (content[key] === undefined) content[key] = value;\n }\n }\n\n // clearEvent doesn't have all the fields, so we'll copy what we can from this.event.\n // We also copy over our \"fixed\" content key.\n return Object.assign({}, this.event, this.clearEvent, { content }) as IEvent;\n }\n\n /**\n * Get the event_id for this event.\n * @returns The event ID, e.g. <code>$143350589368169JsLZx:localhost\n * </code>\n */\n public getId(): string | undefined {\n return this.event.event_id;\n }\n\n /**\n * Get the user_id for this event.\n * @returns The user ID, e.g. `@alice:matrix.org`\n */\n public getSender(): string | undefined {\n return this.event.sender; // v2 / v1\n }\n\n /**\n * Get the (decrypted, if necessary) type of event.\n *\n * @returns The event type, e.g. `m.room.message`\n */\n public getType(): EventType | string {\n if (this.clearEvent) {\n return this.clearEvent.type;\n }\n return this.event.type!;\n }\n\n /**\n * Get the (possibly encrypted) type of the event that will be sent to the\n * homeserver.\n *\n * @returns The event type.\n */\n public getWireType(): EventType | string {\n return this.event.type!;\n }\n\n /**\n * Get the room_id for this event. This will return `undefined`\n * for `m.presence` events.\n * @returns The room ID, e.g. <code>!cURbafjkfsMDVwdRDQ:matrix.org\n * </code>\n */\n public getRoomId(): string | undefined {\n return this.event.room_id;\n }\n\n /**\n * Get the timestamp of this event.\n * @returns The event timestamp, e.g. `1433502692297`\n */\n public getTs(): number {\n return this.event.origin_server_ts!;\n }\n\n /**\n * Get the timestamp of this event, as a Date object.\n * @returns The event date, e.g. `new Date(1433502692297)`\n */\n public getDate(): Date | null {\n return this.event.origin_server_ts ? new Date(this.event.origin_server_ts) : null;\n }\n\n /**\n * Get a string containing details of this event\n *\n * This is intended for logging, to help trace errors. Example output:\n *\n * @example\n * ```\n * id=$HjnOHV646n0SjLDAqFrgIjim7RCpB7cdMXFrekWYAn type=m.room.encrypted\n * sender=@user:example.com room=!room:example.com ts=2022-10-25T17:30:28.404Z\n * ```\n */\n public getDetails(): string {\n const room = this.getRoomId();\n if (room) {\n // in-room event\n return `id=${this.getId()} type=${this.getWireType()} sender=${this.getSender()} room=${room} ts=${this.getDate()?.toISOString()}`;\n } else {\n // to-device event\n const msgid = this.getContent()[ToDeviceMessageId];\n return `msgid=${msgid} type=${this.getWireType()} sender=${this.getSender()}`;\n }\n }\n\n /**\n * Get the (decrypted, if necessary) event content JSON, even if the event\n * was replaced by another event.\n *\n * @returns The event content JSON, or an empty object.\n */\n public getOriginalContent<T = IContent>(): T {\n if (this._localRedactionEvent) {\n return {} as T;\n }\n if (this.clearEvent) {\n return (this.clearEvent.content || {}) as T;\n }\n return (this.event.content || {}) as T;\n }\n\n /**\n * Get the (decrypted, if necessary) event content JSON,\n * or the content from the replacing event, if any.\n * See `makeReplaced`.\n *\n * @returns The event content JSON, or an empty object.\n */\n public getContent<T extends IContent = IContent>(): T {\n if (this._localRedactionEvent) {\n return {} as T;\n } else if (this._replacingEvent) {\n return this._replacingEvent.getContent()[\"m.new_content\"] || {};\n } else {\n return this.getOriginalContent();\n }\n }\n\n /**\n * Get the (possibly encrypted) event content JSON that will be sent to the\n * homeserver.\n *\n * @returns The event content JSON, or an empty object.\n */\n public getWireContent(): IContent {\n return this.event.content || {};\n }\n\n /**\n * Get the event ID of the thread head\n */\n public get threadRootId(): string | undefined {\n // don't allow state events to be threaded as per the spec\n if (this.isState()) {\n return undefined;\n }\n const relatesTo = this.getWireContent()?.[\"m.relates_to\"];\n if (relatesTo?.rel_type === THREAD_RELATION_TYPE.name) {\n return relatesTo.event_id;\n }\n if (this.thread) {\n return this.thread.id;\n }\n if (this.threadId !== undefined) {\n return this.threadId;\n }\n const unsigned = this.getUnsigned();\n if (typeof unsigned[UNSIGNED_THREAD_ID_FIELD.name] === \"string\") {\n return unsigned[UNSIGNED_THREAD_ID_FIELD.name];\n }\n return undefined;\n }\n\n /**\n * A helper to check if an event is a thread's head or not\n */\n public get isThreadRoot(): boolean {\n // don't allow state events to be threaded as per the spec\n if (this.isState()) {\n return false;\n }\n\n const threadDetails = this.getServerAggregatedRelation<IThreadBundledRelationship>(THREAD_RELATION_TYPE.name);\n\n // Bundled relationships only returned when the sync response is limited\n // hence us having to check both bundled relation and inspect the thread\n // model\n return !!threadDetails || this.threadRootId === this.getId();\n }\n\n public get replyEventId(): string | undefined {\n return this.getWireContent()[\"m.relates_to\"]?.[\"m.in_reply_to\"]?.event_id;\n }\n\n public get relationEventId(): string | undefined {\n return this.getWireContent()?.[\"m.relates_to\"]?.event_id;\n }\n\n /**\n * Get the previous event content JSON. This will only return something for\n * state events which exist in the timeline.\n * @returns The previous event content JSON, or an empty object.\n */\n public getPrevContent(): IContent {\n // v2 then v1 then default\n return this.getUnsigned().prev_content || {};\n }\n\n /**\n * Get either 'content' or 'prev_content' depending on if this event is\n * 'forward-looking' or not. This can be modified via event.forwardLooking.\n * In practice, this means we get the chronologically earlier content value\n * for this event (this method should surely be called getEarlierContent)\n * <strong>This method is experimental and may change.</strong>\n * @returns event.content if this event is forward-looking, else\n * event.prev_content.\n */\n public getDirectionalContent(): IContent {\n return this.forwardLooking ? this.getContent() : this.getPrevContent();\n }\n\n /**\n * Get the age of this event. This represents the age of the event when the\n * event arrived at the device, and not the age of the event when this\n * function was called.\n * Can only be returned once the server has echo'ed back\n * @returns The age of this event in milliseconds.\n */\n public getAge(): number | undefined {\n return this.getUnsigned().age;\n }\n\n /**\n * Get the age of the event when this function was called.\n * This is the 'age' field adjusted according to how long this client has\n * had the event.\n * @returns The age of this event in milliseconds.\n */\n public getLocalAge(): number {\n return Date.now() - this.localTimestamp;\n }\n\n /**\n * Get the event state_key if it has one. This will return <code>undefined\n * </code> for message events.\n * @returns The event's `state_key`.\n */\n public getStateKey(): string | undefined {\n return this.event.state_key;\n }\n\n /**\n * Check if this event is a state event.\n * @returns True if this is a state event.\n */\n public isState(): boolean {\n return this.event.state_key !== undefined;\n }\n\n /**\n * Get the user's room membership at the time the event was sent, as reported\n * by the server. This uses MSC4115.\n *\n * @returns The user's room membership, or `undefined` if the server does\n * not report it.\n */\n public getMembershipAtEvent(): Optional<Membership | string> {\n const unsigned = this.getUnsigned();\n return UNSIGNED_MEMBERSHIP_FIELD.findIn<Membership | string>(unsigned);\n }\n\n /**\n * Replace the content of this event with encrypted versions.\n * (This is used when sending an event; it should not be used by applications).\n *\n * @internal\n *\n * @param cryptoType - type of the encrypted event - typically\n * <tt>\"m.room.encrypted\"</tt>\n *\n * @param cryptoContent - raw 'content' for the encrypted event.\n *\n * @param senderCurve25519Key - curve25519 key to record for the\n * sender of this event.\n * See {@link MatrixEvent#getSenderKey}.\n *\n * @param claimedEd25519Key - claimed ed25519 key to record for the\n * sender if this event.\n * See {@link MatrixEvent#getClaimedEd25519Key}\n */\n public makeEncrypted(\n cryptoType: string,\n cryptoContent: object,\n senderCurve25519Key: string,\n claimedEd25519Key: string,\n ): void {\n // keep the plain-text data for 'view source'\n this.clearEvent = {\n type: this.event.type!,\n content: this.event.content!,\n };\n this.event.type = cryptoType;\n this.event.content = cryptoContent;\n this.senderCurve25519Key = senderCurve25519Key;\n this.claimedEd25519Key = claimedEd25519Key;\n }\n\n /**\n * Check if this event is currently being decrypted.\n *\n * @returns True if this event is currently being decrypted, else false.\n */\n public isBeingDecrypted(): boolean {\n return this.decryptionPromise != null;\n }\n\n public getDecryptionPromise(): Promise<void> | null {\n return this.decryptionPromise;\n }\n\n /**\n * Check if this event is an encrypted event which we failed to decrypt\n *\n * (This implies that we might retry decryption at some point in the future)\n *\n * @returns True if this event is an encrypted event which we\n * couldn't decrypt.\n */\n public isDecryptionFailure(): boolean {\n return this._decryptionFailureReason !== null;\n }\n\n /** If we failed to decrypt this event, the reason for the failure. Otherwise, `null`. */\n public get decryptionFailureReason(): DecryptionFailureCode | null {\n return this._decryptionFailureReason;\n }\n\n /**\n * True if this event is an encrypted event which we failed to decrypt, the receiver's device is unverified and\n * the sender has disabled encrypting to unverified devices.\n *\n * @deprecated: Prefer `event.decryptionFailureReason === DecryptionFailureCode.MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE`.\n */\n public get isEncryptedDisabledForUnverifiedDevices(): boolean {\n return this.decryptionFailureReason === DecryptionFailureCode.MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE;\n }\n\n public shouldAttemptDecryption(): boolean {\n if (this.isRedacted()) return false;\n if (this.isBeingDecrypted()) return false;\n if (this.clearEvent) return false;\n if (!this.isEncrypted()) return false;\n\n return true;\n }\n\n /**\n * Start the process of trying to decrypt this event.\n *\n * (This is used within the SDK: it isn't intended for use by applications)\n *\n * @internal\n *\n * @param crypto - crypto module\n *\n * @returns promise which resolves (to undefined) when the decryption\n * attempt is completed.\n */\n public async attemptDecryption(crypto: CryptoBackend, options: IDecryptOptions = {}): Promise<void> {\n // start with a couple of sanity checks.\n if (!this.isEncrypted()) {\n throw new Error(\"Attempt to decrypt event which isn't encrypted\");\n }\n\n const alreadyDecrypted = this.clearEvent && !this.isDecryptionFailure();\n const forceRedecrypt = options.forceRedecryptIfUntrusted && this.isKeySourceUntrusted();\n if (alreadyDecrypted && !forceRedecrypt) {\n // we may want to just ignore this? let's start with rejecting it.\n throw new Error(\"Attempt to decrypt event which has already been decrypted\");\n }\n\n // if we already have a decryption attempt in progress, then it may\n // fail because it was using outdated info. We now have reason to\n // succeed where it failed before, but we don't want to have multiple\n // attempts going at the same time, so just set a flag that says we have\n // new info.\n //\n if (this.decryptionPromise) {\n logger.log(`Event ${this.getId()} already being decrypted; queueing a retry`);\n this.retryDecryption = true;\n return this.decryptionPromise;\n }\n\n this.decryptionPromise = this.decryptionLoop(crypto, options);\n return this.decryptionPromise;\n }\n\n /**\n * Cancel any room key request for this event and resend another.\n *\n * @param crypto - crypto module\n * @param userId - the user who received this event\n *\n * @returns a promise that resolves when the request is queued\n */\n public cancelAndResendKeyRequest(crypto: Crypto, userId: string): Promise<void> {\n const wireContent = this.getWireContent();\n return crypto.requestRoomKey(\n {\n algorithm: wireContent.algorithm,\n room_id: this.getRoomId()!,\n session_id: wireContent.session_id,\n sender_key: wireContent.sender_key,\n },\n this.getKeyRequestRecipients(userId),\n true,\n );\n }\n\n /**\n * Calculate the recipients for keyshare requests.\n *\n * @param userId - the user who received this event.\n *\n * @returns array of recipients\n */\n public getKeyRequestRecipients(userId: string): IKeyRequestRecipient[] {\n // send the request to all of our own devices\n const recipients = [\n {\n userId,\n deviceId: \"*\",\n },\n ];\n\n return recipients;\n }\n\n private async decryptionLoop(crypto: CryptoBackend, options: IDecryptOptions = {}): Promise<void> {\n // make sure that this method never runs completely synchronously.\n // (doing so would mean that we would clear decryptionPromise *before*\n // it is set in attemptDecryption - and hence end up with a stuck\n // `decryptionPromise`).\n await Promise.resolve();\n\n // eslint-disable-next-line no-constant-condition\n while (true) {\n this.retryDecryption = false;\n\n let err: Error | undefined = undefined;\n try {\n const res = await crypto.decryptEvent(this);\n if (options.isRetry === true) {\n logger.info(`Decrypted event on retry (${this.getDetails()})`);\n }\n this.setClearData(res);\n this._decryptionFailureReason = null;\n } catch (e) {\n const detailedError = e instanceof DecryptionError ? (<DecryptionError>e).detailedString : String(e);\n\n err = e as Error;\n\n // see if we have a retry queued.\n //\n // NB: make sure to keep this check in the same tick of the\n // event loop as `decryptionPromise = null` below - otherwise we\n // risk a race:\n //\n // * A: we check retryDecryption here and see that it is\n // false\n // * B: we get a second call to attemptDecryption, which sees\n // that decryptionPromise is set so sets\n // retryDecryption\n // * A: we continue below, clear decryptionPromise, and\n // never do the retry.\n //\n if (this.retryDecryption) {\n // decryption error, but we have a retry queued.\n logger.log(`Error decrypting event (${this.getDetails()}), but retrying: ${detailedError}`);\n continue;\n }\n\n // decryption error, no retries queued. Warn about the error and\n // set it to m.bad.encrypted.\n //\n // the detailedString already includes the name and message of the error, and the stack isn't much use,\n // so we don't bother to log `e` separately.\n logger.warn(`Error decrypting event (${this.getDetails()}): ${detailedError}`);\n\n this.setClearDataForDecryptionFailure(String(e));\n this._decryptionFailureReason =\n e instanceof DecryptionError ? (<DecryptionError>e).code : DecryptionFailureCode.UNKNOWN_ERROR;\n }\n\n // Make sure we clear 'decryptionPromise' before sending the 'Event.decrypted' event,\n // otherwise the app will be confused to see `isBeingDecrypted` still set when\n // there isn't an `Event.decrypted` on the way.\n //\n // see also notes on retryDecryption above.\n //\n this.decryptionPromise = null;\n this.retryDecryption = false;\n\n // Before we emit the event, clear the push actions so that they can be recalculated\n // by relevant code. We do this because the clear event has now changed, making it\n // so that existing rules can be re-run over the applicable properties. Stuff like\n // highlighting when the user's name is mentioned rely on this happening. We also want\n // to set the push actions before emitting so that any notification listeners don't\n // pick up the wrong contents.\n this.setPushDetails();\n\n if (options.emit !== false) {\n this.emit(MatrixEventEvent.Decrypted, this, err);\n }\n\n return;\n }\n }\n\n /**\n * Update the cleartext data on this event.\n *\n * (This is used after decrypting an event; it should not be used by applications).\n *\n * @internal\n *\n * @param decryptionResult - the decryption result, including the plaintext and some key info\n */\n private setClearData(decryptionResult: IEventDecryptionResult): void {\n this.clearEvent = decryptionResult.clearEvent;\n this.senderCurve25519Key = decryptionResult.senderCurve25519Key ?? null;\n this.claimedEd25519Key = decryptionResult.claimedEd25519Key ?? null;\n this.forwardingCurve25519KeyChain = decryptionResult.forwardingCurve25519KeyChain || [];\n this.untrusted = decryptionResult.untrusted || false;\n this.invalidateExtensibleEvent();\n }\n\n /**\n * Update the cleartext data on this event after a decryption failure.\n *\n * @param reason - the textual reason for the failure\n */\n private setClearDataForDecryptionFailure(reason: string): void {\n this.clearEvent = {\n type: EventType.RoomMessage,\n content: {\n msgtype: \"m.bad.encrypted\",\n body: `** Unable to decrypt: ${reason} **`,\n },\n };\n this.senderCurve25519Key = null;\n this.claimedEd25519Key = null;\n this.forwardingCurve25519KeyChain = [];\n this.untrusted = false;\n this.invalidateExtensibleEvent();\n }\n\n /**\n * Gets the cleartext content for this event. If the event is not encrypted,\n * or encryption has not been completed, this will return null.\n *\n * @returns The cleartext (decrypted) content for the event\n */\n public getClearContent(): IContent | null {\n return this.clearEvent ? this.clearEvent.content : null;\n }\n\n /**\n * Check if the event is encrypted.\n * @returns True if this event is encrypted.\n */\n public isEncrypted(): boolean {\n return !this.isState() && this.event.type === EventType.RoomMessageEncrypted;\n }\n\n /**\n * The curve25519 key for the device that we think sent this event\n *\n * For an Olm-encrypted event, this is inferred directly from the DH\n * exchange at the start of the session: the curve25519 key is involved in\n * the DH exchange, so only a device which holds the private part of that\n * key can establish such a session.\n *\n * For a megolm-encrypted event, it is inferred from the Olm message which\n * established the megolm session\n */\n public getSenderKey(): string | null {\n return this.senderCurve25519Key;\n }\n\n /**\n * The additional keys the sender of this encrypted event claims to possess.\n *\n * Just a wrapper for #getClaimedEd25519Key (q.v.)\n */\n public getKeysClaimed(): Partial<Record<\"ed25519\", string>> {\n if (!this.claimedEd25519Key) return {};\n\n return {\n ed25519: this.claimedEd25519Key,\n };\n }\n\n /**\n * Get the ed25519 the sender of this event claims to own.\n *\n * For Olm messages, this claim is encoded directly in the plaintext of the\n * event itself. For megolm messages, it is implied by the m.room_key event\n * which established the megolm session.\n *\n * Until we download the device list of the sender, it's just a claim: the\n * device list gives a proof that the owner of the curve25519 key used for\n * this event (and returned by #getSenderKey) also owns the ed25519 key by\n * signing the public curve25519 key with the ed25519 key.\n *\n * In general, applications should not use this method directly, but should\n * instead use {@link Crypto.CryptoApi#getEncryptionInfoForEvent}.\n */\n public getClaimedEd25519Key(): string | null {\n return this.claimedEd25519Key;\n }\n\n /**\n * Get the curve25519 keys of the devices which were involved in telling us\n * about the claimedEd25519Key and sender curve25519 key.\n *\n * Normally this will be empty, but in the case of a forwarded megolm\n * session, the sender keys are sent to us by another device (the forwarding\n * device), which we need to trust to do this. In that case, the result will\n * be a list consisting of one entry.\n *\n * If the device that sent us the key (A) got it from another device which\n * it wasn't prepared to vouch for (B), the result will be [A, B]. And so on.\n *\n * @returns base64-encoded curve25519 keys, from oldest to newest.\n */\n public getForwardingCurve25519KeyChain(): string[] {\n return this.forwardingCurve25519KeyChain;\n }\n\n /**\n * Whether the decryption key was obtained from an untrusted source. If so,\n * we cannot verify the authenticity of the message.\n */\n public isKeySourceUntrusted(): boolean | undefined {\n return !!this.untrusted;\n }\n\n public getUnsigned(): IUnsigned {\n return this.event.unsigned || {};\n }\n\n public setUnsigned(unsigned: IUnsigned): void {\n this.event.unsigned = unsigned;\n }\n\n public unmarkLocallyRedacted(): boolean {\n const value = this._localRedactionEvent;\n this._localRedactionEvent = null;\n if (this.event.unsigned) {\n this.event.unsigned.redacted_because = undefined;\n }\n return !!value;\n }\n\n public markLocallyRedacted(redactionEvent: MatrixEvent): void {\n if (this._localRedactionEvent) return;\n this.emit(MatrixEventEvent.BeforeRedaction, this, redactionEvent);\n this._localRedactionEvent = redactionEvent;\n if (!this.event.unsigned) {\n this.event.unsigned = {};\n }\n this.event.unsigned.redacted_because = redactionEvent.event as IEvent;\n }\n\n /**\n * Change the visibility of an event, as per https://github.com/matrix-org/matrix-doc/pull/3531 .\n *\n * @param visibilityChange - event holding a hide/unhide payload, or nothing\n * if the event is being reset to its original visibility (presumably\n * by a visibility event being redacted).\n *\n * @remarks\n * Fires {@link MatrixEventEvent.VisibilityChange} if `visibilityEvent`\n * caused a change in the actual visibility of this event, either by making it\n * visible (if it was hidden), by making it hidden (if it was visible) or by\n * changing the reason (if it was hidden).\n */\n public applyVisibilityEvent(visibilityChange?: IVisibilityChange): void {\n const visible = visibilityChange?.visible ?? true;\n const reason = visibilityChange?.reason ?? null;\n let change = false;\n if (this.visibility.visible !== visible) {\n change = true;\n } else if (!this.visibility.visible && this.visibility[\"reason\"] !== reason) {\n change = true;\n }\n if (change) {\n if (visible) {\n this.visibility = MESSAGE_VISIBLE;\n } else {\n this.visibility = Object.freeze({\n visible: false,\n reason,\n });\n }\n this.emit(MatrixEventEvent.VisibilityChange, this, visible);\n }\n }\n\n /**\n * Return instructions to display or hide the message.\n *\n * @returns Instructions determining whether the message\n * should be displayed.\n */\n public messageVisibility(): MessageVisibility {\n // Note: We may return `this.visibility` without fear, as\n // this is a shallow frozen object.\n return this.visibility;\n }\n\n /**\n * Update the content of an event in the same way it would be by the server\n * if it were redacted before it was sent to us\n *\n * @param redactionEvent - event causing the redaction\n * @param room - the room in which the event exists\n */\n public makeRedacted(redactionEvent: MatrixEvent, room: Room): void {\n // quick sanity-check\n if (!redactionEvent.event) {\n throw new Error(\"invalid redactionEvent in makeRedacted\");\n }\n\n this._localRedactionEvent = null;\n\n this.emit(MatrixEventEvent.BeforeRedaction, this, redactionEvent);\n\n this._replacingEvent = null;\n // we attempt to replicate what we would see from the server if\n // the event had been redacted before we saw it.\n //\n // The server removes (most of) the content of the event, and adds a\n // \"redacted_because\" key to the unsigned section containing the\n // redacted event.\n if (!this.event.unsigned) {\n this.event.unsigned = {};\n }\n this.event.unsigned.redacted_because = redactionEvent.event as IEvent;\n\n for (const key in this.event) {\n if (this.event.hasOwnProperty(key) && !REDACT_KEEP_KEYS.has(key)) {\n delete this.event[key as keyof IEvent];\n }\n }\n\n // If the event is encrypted prune the decrypted bits\n if (this.isEncrypted()) {\n this.clearEvent = undefined;\n }\n\n const keeps =\n this.getType() in REDACT_KEEP_CONTENT_MAP\n ? REDACT_KEEP_CONTENT_MAP[this.getType() as keyof typeof REDACT_KEEP_CONTENT_MAP]\n : {};\n const content = this.getContent();\n for (const key in content) {\n if (content.hasOwnProperty(key) && !keeps[key]) {\n delete content[key];\n }\n }\n\n // If the redacted event was in a thread (but not thread root), move it\n // to the main timeline. This will change if MSC3389 is merged.\n if (!this.isThreadRoot && this.threadRootId && this.threadRootId !== this.getId()) {\n this.moveAllRelatedToMainTimeline(room);\n redactionEvent.moveToMainTimeline(room);\n }\n\n this.invalidateExtensibleEvent();\n }\n\n private moveAllRelatedToMainTimeline(room: Room): void {\n const thread = this.thread;\n this.moveToMainTimeline(room);\n\n // If we dont have access to the thread, we can only move this\n // event, not things related to it.\n if (thread) {\n for (const event of thread.events) {\n if (event.getRelation()?.event_id === this.getId()) {\n event.moveAllRelatedToMainTimeline(room);\n }\n }\n }\n }\n\n private moveToMainTimeline(room: Room): void {\n // Remove it from its thread\n this.thread?.timelineSet.removeEvent(this.getId()!);\n this.setThread(undefined);\n\n // And insert it into the main timeline\n const timeline = room.getLiveTimeline();\n // We use insertEventIntoTimeline to insert it in timestamp order,\n // because we don't know where it should go (until we have MSC4033).\n timeline.getTimelineSet().insertEventIntoTimeline(this, timeline, timeline.getState(EventTimeline.FORWARDS)!);\n }\n\n /**\n * Check if this event has been redacted\n *\n * @returns True if this event has been redacted\n */\n public isRedacted(): boolean {\n return Boolean(this.getUnsigned().redacted_because);\n }\n\n /**\n * Check if this event is a redaction of another event\n *\n * @returns True if this event is a redaction\n */\n public isRedaction(): boolean {\n return this.getType() === EventType.RoomRedaction;\n }\n\n /**\n * Return the visibility change caused by this event,\n * as per https://github.com/matrix-org/matrix-doc/pull/3531.\n *\n * @returns If the event is a well-formed visibility change event,\n * an instance of `IVisibilityChange`, otherwise `null`.\n */\n public asVisibilityChange(): IVisibilityChange | null {\n if (!EVENT_VISIBILITY_CHANGE_TYPE.matches(this.getType())) {\n // Not a visibility change event.\n return null;\n }\n const relation = this.getRelation();\n if (!relation || relation.rel_type != \"m.reference\") {\n // Ill-formed, ignore this event.\n return null;\n }\n const eventId = relation.event_id;\n if (!eventId) {\n // Ill-formed, ignore this event.\n return null;\n }\n const content = this.getWireContent();\n const visible = !!content.visible;\n const reason = content.reason;\n if (reason && typeof reason != \"string\") {\n // Ill-formed, ignore this event.\n return null;\n }\n // Well-formed visibility change event.\n return {\n visible,\n reason,\n eventId,\n };\n }\n\n /**\n * Check if this event alters the visibility of another event,\n * as per https://github.com/matrix-org/matrix-doc/pull/3531.\n *\n * @returns True if this event alters the visibility\n * of another event.\n */\n public isVisibilityEvent(): boolean {\n return EVENT_VISIBILITY_CHANGE_TYPE.matches(this.getType());\n }\n\n /**\n * Get the (decrypted, if necessary) redaction event JSON\n * if event was redacted\n *\n * @returns The redaction event JSON, or an empty object\n */\n public getRedactionEvent(): IEvent | {} | null {\n if (!this.isRedacted()) return null;\n\n if (this.clearEvent?.unsigned) {\n return this.clearEvent?.unsigned.redacted_because ?? null;\n } else if (this.event.unsigned?.redacted_because) {\n return this.event.unsigned.redacted_because;\n } else {\n return {};\n }\n }\n\n /**\n * Get the push actions, if known, for this event\n *\n * @returns push actions\n */\n public getPushActions(): IActionsObject | null {\n return this.pushDetails.actions || null;\n }\n\n /**\n * Get the push details, if known, for this event\n *\n * @returns push actions\n */\n public getPushDetails(): PushDetails {\n return this.pushDetails;\n }\n\n /**\n * Set the push details for this event.\n *\n * @param pushActions - push actions\n * @param rule - the executed push rule\n */\n public setPushDetails(pushActions?: IActionsObject, rule?: IAnnotatedPushRule): void {\n this.pushDetails = {\n actions: pushActions,\n rule,\n };\n }\n\n /**\n * Replace the `event` property and recalculate any properties based on it.\n * @param event - the object to assign to the `event` property\n */\n public handleRemoteEcho(event: object): void {\n const oldUnsigned = this.getUnsigned();\n const oldId = this.getId();\n this.event = event;\n // if this event was redacted before it was sent, it's locally marked as redacted.\n // At this point, we've received the remote echo for the event, but not yet for\n // the redaction that we are sending ourselves. Preserve the locally redacted\n // state by copying over redacted_because so we don't get a flash of\n // redacted, not-redacted, redacted as remote echos come in\n if (oldUnsigned.redacted_because) {\n if (!this.event.unsigned) {\n this.event.unsigned = {};\n }\n this.event.unsigned.redacted_because = oldUnsigned.redacted_because;\n }\n // successfully sent.\n this.setStatus(null);\n if (this.getId() !== oldId) {\n // emit the event if it changed\n this.emit(MatrixEventEvent.LocalEventIdReplaced, this);\n }\n\n this.localTimestamp = Date.now() - this.getAge()!;\n }\n\n /**\n * Whether the event is in any phase of sending, send failure, waiting for\n * remote echo, etc.\n */\n public isSending(): boolean {\n return !!this.status;\n }\n\n /**\n * Update the event's sending status and emit an event as well.\n *\n * @param status - The new status\n */\n public setStatus(status: EventStatus | null): void {\n this.status = status;\n this.emit(MatrixEventEvent.Status, this, status);\n }\n\n public replaceLocalEventId(eventId: string): void {\n this.event.event_id = eventId;\n this.emit(MatrixEventEvent.LocalEventIdReplaced, this);\n }\n\n /**\n * Get whether the event is a relation event, and of a given type if\n * `relType` is passed in. State events cannot be relation events\n *\n * @param relType - if given, checks that the relation is of the\n * given type\n */\n public isRelation(relType?: string): boolean {\n // Relation info is lifted out of the encrypted content when sent to\n // encrypted rooms, so we have to check `getWireContent` for this.\n const relation = this.getWireContent()?.[\"m.relates_to\"];\n if (\n this.isState() &&\n !!relation?.rel_type &&\n ([RelationType.Replace, RelationType.Thread] as string[]).includes(relation.rel_type)\n ) {\n // State events cannot be m.replace or m.thread relations\n return false;\n }\n return !!(relation?.rel_type && relation.event_id && (relType ? relation.rel_type === relType : true));\n }\n\n /**\n * Get relation info for the event, if any.\n */\n public getRelation(): IEventRelation | null {\n if (!this.isRelation()) {\n return null;\n }\n return this.getWireContent()[\"m.relates_to\"] ?? null;\n }\n\n /**\n * Set an event that replaces the content of this event, through an m.replace relation.\n *\n * @param newEvent - the event with the replacing content, if any.\n *\n * @remarks\n * Fires {@link MatrixEventEvent.Replaced}\n */\n public makeReplaced(newEvent?: MatrixEvent): void {\n // don't allow redacted events to be replaced.\n // if newEvent is null we allow to go through though,\n // as with local redaction, the replacing event might get\n // cancelled, which should be reflected on the target event.\n if (this.isRedacted() && newEvent) {\n return;\n }\n // don't allow state events to be replaced using this mechanism as per MSC2676\n if (this.isState()) {\n return;\n }\n if (this._replacingEvent !== newEvent) {\n this._replacingEvent = newEvent ?? null;\n this.emit(MatrixEventEvent.Replaced, this);\n this.invalidateExtensibleEvent();\n }\n }\n\n /**\n * Returns the status of any associated edit or redaction\n * (not for reactions/annotations as their local echo doesn't affect the original event),\n * or else the status of the event.\n */\n public getAssociatedStatus(): EventStatus | null {\n if (this._replacingEvent) {\n return this._replacingEvent.status;\n } else if (this._localRedactionEvent) {\n return this._localRedactionEvent.status;\n }\n return this.status;\n }\n\n public getServerAggregatedRelation<T>(relType: RelationType | string): T | undefined {\n return this.getUnsigned()[\"m.relations\"]?.[relType];\n }\n\n /**\n * Returns the event ID of the event replacing the content of this event, if any.\n */\n public replacingEventId(): string | undefined {\n const replaceRelation = this.getServerAggregatedRelation<IAggregatedRelation>(RelationType.Replace);\n if (replaceRelation) {\n return replaceRelation.event_id;\n } else if (this._replacingEvent) {\n return this._replacingEvent.getId();\n }\n }\n\n /**\n * Returns the event replacing the content of this event, if any.\n * Replacements are aggregated on the server, so this would only\n * return an event in case it came down the sync, or for local echo of edits.\n */\n public replacingEvent(): MatrixEvent | null {\n return this._replacingEvent;\n }\n\n /**\n * Returns the origin_server_ts of the event replacing the content of this event, if any.\n */\n public replacingEventDate(): Date | undefined {\n const replaceRelation = this.getServerAggregatedRelation<IAggregatedRelation>(RelationType.Replace);\n if (replaceRelation) {\n const ts = replaceRelation.origin_server_ts;\n if (Number.isFinite(ts)) {\n return new Date(ts);\n }\n } else if (this._replacingEvent) {\n return this._replacingEvent.getDate() ?? undefined;\n }\n }\n\n /**\n * Returns the event that wants to redact this event, but hasn't been sent yet.\n * @returns the event\n */\n public localRedactionEvent(): MatrixEvent | null {\n return this._localRedactionEvent;\n }\n\n /**\n * For relations and redactions, returns the event_id this event is referring to.\n */\n public getAssociatedId(): string | undefined {\n const relation = this.getRelation();\n if (this.replyEventId) {\n return this.replyEventId;\n } else if (relation) {\n return relation.event_id;\n } else if (this.isRedaction()) {\n return this.event.redacts;\n }\n }\n\n /**\n * Checks if this event is associated with another event. See `getAssociatedId`.\n */\n public hasAssociation(): boolean {\n return !!this.getAssociatedId();\n }\n\n /**\n * Update the related id with a new one.\n *\n * Used to replace a local id with remote one before sending\n * an event with a related id.\n *\n * @param eventId - the new event id\n */\n public updateAssociatedId(eventId: string): void {\n const relation = this.getRelation();\n if (relation) {\n relation.event_id = eventId;\n } else if (this.isRedaction()) {\n this.event.redacts = eventId;\n }\n }\n\n /**\n * Flags an event as cancelled due to future conditions. For example, a verification\n * request event in the same sync transaction may be flagged as cancelled to warn\n * listeners that a cancellation event is coming down the same pipe shortly.\n * @param cancelled - Whether the event is to be cancelled or not.\n */\n public flagCancelled(cancelled = true): void {\n this._isCancelled = cancelled;\n }\n\n /**\n * Gets whether or not the event is flagged as cancelled. See flagCancelled() for\n * more information.\n * @returns True if the event is cancelled, false otherwise.\n */\n public isCancelled(): boolean {\n return this._isCancelled;\n }\n\n /**\n * Get a copy/snapshot of this event. The returned copy will be loosely linked\n * back to this instance, though will have \"frozen\" event information. Other\n * properties of this MatrixEvent instance will be copied verbatim, which can\n * mean they are in reference to this instance despite being on the copy too.\n * The reference the snapshot uses does not change, however members aside from\n * the underlying event will not be deeply cloned, thus may be mutated internally.\n * For example, the sender profile will be copied over at snapshot time, and\n * the sender profile internally may mutate without notice to the consumer.\n *\n * This is meant to be used to snapshot the event details themselves, not the\n * features (such as sender) surrounding the event.\n * @returns A snapshot of this event.\n */\n public toSnapshot(): MatrixEvent {\n const ev = new MatrixEvent(JSON.parse(JSON.stringify(this.event)));\n for (const [p, v] of Object.entries(this)) {\n if (p !== \"event\") {\n // exclude the thing we just cloned\n // @ts-ignore - XXX: this is just nasty\n ev[p as keyof MatrixEvent] = v;\n }\n }\n return ev;\n }\n\n /**\n * Determines if this event is equivalent to the given event. This only checks\n * the event object itself, not the other properties of the event. Intended for\n * use with toSnapshot() to identify events changing.\n * @param otherEvent - The other event to check against.\n * @returns True if the events are the same, false otherwise.\n */\n public isEquivalentTo(otherEvent: MatrixEvent): boolean {\n if (!otherEvent) return false;\n if (otherEvent === this) return true;\n const myProps = deepSortedObjectEntries(this.event);\n const theirProps = deepSortedObjectEntries(otherEvent.event);\n return JSON.stringify(myProps) === JSON.stringify(theirProps);\n }\n\n /**\n * Summarise the event as JSON.\n *\n * If encrypted, include both the decrypted and encrypted view of the event.\n *\n * This is named `toJSON` for use with `JSON.stringify` which checks objects\n * for functions named `toJSON` and will call them to customise the output\n * if they are defined.\n *\n * **WARNING** Do not log the result of this method; otherwise, it will end up\n * in rageshakes, leading to a privacy violation.\n *\n * @deprecated Prefer to use {@link MatrixEvent#getEffectiveEvent} or similar.\n * This method will be removed soon; it is too easy to use it accidentally\n * and cause a privacy violation (cf https://github.com/vector-im/element-web/issues/26380).\n * In any case, the value it returns is not a faithful serialization of the object.\n */\n public toJSON(): object {\n const event = this.getEffectiveEvent();\n\n if (!this.isEncrypted()) {\n return event;\n }\n\n return {\n decrypted: event,\n encrypted: this.event,\n };\n }\n\n public setVerificationRequest(request: VerificationRequest): void {\n this.verificationRequest = request;\n }\n\n public setTxnId(txnId: string): void {\n this.txnId = txnId;\n }\n\n public getTxnId(): string | undefined {\n return this.txnId;\n }\n\n /**\n * Set the instance of a thread associated with the current event\n * @param thread - the thread\n */\n public setThread(thread?: Thread): void {\n // don't allow state events to be threaded as per the spec\n if (this.isState()) {\n return;\n }\n if (this.thread) {\n this.reEmitter.stopReEmitting(this.thread, [ThreadEvent.Update]);\n }\n this.thread = thread;\n this.setThreadId(thread?.id);\n if (thread) {\n this.reEmitter.reEmit(thread, [ThreadEvent.Update]);\n }\n }\n\n /**\n * Get the instance of the thread associated with the current event\n */\n public getThread(): Thread | undefined {\n return this.thread;\n }\n\n public setThreadId(threadId?: string): void {\n this.threadId = threadId;\n }\n}\n\n/* REDACT_KEEP_KEYS gives the keys we keep when an event is redacted\n *\n * This is specified here:\n * http://matrix.org/speculator/spec/HEAD/client_server/latest.html#redactions\n *\n * Also:\n * - We keep 'unsigned' since that is created by the local server\n * - We keep user_id for backwards-compat with v1\n */\nconst REDACT_KEEP_KEYS = new Set([\n \"event_id\",\n \"type\",\n \"room_id\",\n \"user_id\",\n \"sender\",\n \"state_key\",\n \"prev_state\",\n \"content\",\n \"unsigned\",\n \"origin_server_ts\",\n]);\n\n// a map from state event type to the .content keys we keep when an event is redacted\nconst REDACT_KEEP_CONTENT_MAP: Record<string, Record<string, 1>> = {\n [EventType.RoomMember]: { membership: 1 },\n [EventType.RoomJoinRules]: { join_rule: 1 },\n [EventType.RoomPowerLevels]: {\n ban: 1,\n events: 1,\n events_default: 1,\n kick: 1,\n redact: 1,\n state_default: 1,\n users: 1,\n users_default: 1,\n },\n} as const;\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,SAA0BA,gBAAgB,QAAkB,mBAAmB;AAG/E,SAASC,MAAM,QAAQ,cAAc;AAErC,SACIC,4BAA4B,EAC5BC,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,WAAW,CAAChN,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEC,EAAE,CAAC;IAC5B,IAAID,MAAM,EAAE;MACR,IAAI,CAAC1C,SAAS,CAAC2P,MAAM,CAACjN,MAAM,EAAE,CAAC3E,WAAW,CAAC0R,MAAM,CAAC,CAAC;IACvD;EACJ;;EAEA;AACJ;AACA;EACWG,SAASA,CAAA,EAAuB;IACnC,OAAO,IAAI,CAAClN,MAAM;EACtB;EAEOgN,WAAWA,CAAC9M,QAAiB,EAAQ;IACxC,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAM+G,gBAAgB,GAAG,IAAIkG,GAAG,CAAC,CAC7B,UAAU,EACV,MAAM,EACN,SAAS,EACT,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,SAAS,EACT,UAAU,EACV,kBAAkB,CACrB,CAAC;;AAEF;AACA,IAAM/F,uBAA0D,GAAG;EAC/D,CAACvM,SAAS,CAACuS,UAAU,GAAG;IAAEC,UAAU,EAAE;EAAE,CAAC;EACzC,CAACxS,SAAS,CAACyS,aAAa,GAAG;IAAEC,SAAS,EAAE;EAAE,CAAC;EAC3C,CAAC1S,SAAS,CAAC2S,eAAe,GAAG;IACzBC,GAAG,EAAE,CAAC;IACNlG,MAAM,EAAE,CAAC;IACTmG,cAAc,EAAE,CAAC;IACjBC,IAAI,EAAE,CAAC;IACPC,MAAM,EAAE,CAAC;IACTC,aAAa,EAAE,CAAC;IAChBC,KAAK,EAAE,CAAC;IACRC,aAAa,EAAE;EACnB;AACJ,CAAU","ignoreList":[]}
|
1
|
+
{"version":3,"file":"event.js","names":["ExtensibleEvents","EVENT_VISIBILITY_CHANGE_TYPE","EventType","RelationType","ToDeviceMessageId","UNSIGNED_THREAD_ID_FIELD","UNSIGNED_MEMBERSHIP_FIELD","deepSortedObjectEntries","internaliseString","THREAD_RELATION_TYPE","ThreadEvent","TypedReEmitter","TypedEventEmitter","EventTimeline","EventStatus","MESSAGE_VISIBLE","Object","freeze","visible","MatrixEventEvent","MatrixEvent","constructor","_this$getTs","event","arguments","length","undefined","_defineProperty","forEach","prop","_event$content","content","_event$content2","txnId","txn_id","age","getAge","localTimestamp","Date","now","getTs","reEmitter","unstableExtensibleEvent","_hasCachedExtEv","_cachedExtEv","parse","getEffectiveEvent","invalidateExtensibleEvent","assign","getContent","getWireType","RoomMessageEncrypted","key","value","entries","getWireContent","includes","clearEvent","getId","event_id","getSender","sender","getType","type","getRoomId","room_id","origin_server_ts","getDate","getDetails","room","_this$getDate","concat","toISOString","msgid","getOriginalContent","_localRedactionEvent","_replacingEvent","threadRootId","_this$getWireContent","isState","relatesTo","rel_type","name","thread","id","threadId","unsigned","getUnsigned","isThreadRoot","threadDetails","getServerAggregatedRelation","replyEventId","_this$getWireContent$","relationEventId","_this$getWireContent2","getPrevContent","prev_content","getDirectionalContent","forwardLooking","getLocalAge","getStateKey","state_key","getMembershipAtEvent","findIn","shouldAttemptDecryption","isRedacted","isEncrypted","getKeyRequestRecipients","userId","recipients","deviceId","getClearContent","getSenderKey","senderCurve25519Key","getKeysClaimed","claimedEd25519Key","ed25519","getClaimedEd25519Key","getForwardingCurve25519KeyChain","forwardingCurve25519KeyChain","isKeySourceUntrusted","untrusted","setUnsigned","unmarkLocallyRedacted","redacted_because","markLocallyRedacted","redactionEvent","emit","BeforeRedaction","applyVisibilityEvent","visibilityChange","_visibilityChange$vis","_visibilityChange$rea","reason","change","visibility","VisibilityChange","messageVisibility","makeRedacted","Error","hasOwnProperty","REDACT_KEEP_KEYS","has","keeps","REDACT_KEEP_CONTENT_MAP","moveAllRelatedToMainTimeline","moveToMainTimeline","events","_event$getRelation","getRelation","_this$thread","timelineSet","removeEvent","setThread","timeline","getLiveTimeline","getTimelineSet","insertEventIntoTimeline","getState","FORWARDS","Boolean","isRedaction","RoomRedaction","asVisibilityChange","matches","relation","eventId","isVisibilityEvent","getRedactionEvent","_this$clearEvent","_this$event$unsigned","_this$clearEvent$unsi","_this$clearEvent2","getPushActions","pushDetails","actions","getPushDetails","setPushDetails","pushActions","rule","handleRemoteEcho","oldUnsigned","oldId","setStatus","LocalEventIdReplaced","isSending","status","Status","replaceLocalEventId","isRelation","relType","_this$getWireContent3","Replace","Thread","_this$getWireContent$2","makeReplaced","newEvent","Replaced","getAssociatedStatus","_this$getUnsigned$mR","replacingEventId","replaceRelation","replacingEvent","replacingEventDate","ts","Number","isFinite","_this$_replacingEvent","localRedactionEvent","getAssociatedId","redacts","hasAssociation","updateAssociatedId","flagCancelled","cancelled","_isCancelled","isCancelled","toSnapshot","ev","JSON","stringify","p","v","isEquivalentTo","otherEvent","myProps","theirProps","toJSON","decrypted","encrypted","setTxnId","getTxnId","stopReEmitting","Update","setThreadId","reEmit","getThread","Set","RoomMember","membership","RoomJoinRules","join_rule","RoomPowerLevels","ban","events_default","kick","redact","state_default","users","users_default"],"sources":["../../src/models/event.ts"],"sourcesContent":["/*\nCopyright 2015 - 2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n/**\n * This is an internal module. See {@link MatrixEvent} and {@link RoomEvent} for\n * the public classes.\n */\n\nimport { ExtensibleEvent, ExtensibleEvents, Optional } from \"matrix-events-sdk\";\n\nimport {\n EVENT_VISIBILITY_CHANGE_TYPE,\n EventType,\n MsgType,\n RelationType,\n ToDeviceMessageId,\n UNSIGNED_THREAD_ID_FIELD,\n UNSIGNED_MEMBERSHIP_FIELD,\n} from \"../@types/event.ts\";\nimport { deepSortedObjectEntries, internaliseString } from \"../utils.ts\";\nimport { RoomMember } from \"./room-member.ts\";\nimport { Thread, THREAD_RELATION_TYPE, ThreadEvent, ThreadEventHandlerMap } from \"./thread.ts\";\nimport { IActionsObject } from \"../pushprocessor.ts\";\nimport { TypedReEmitter } from \"../ReEmitter.ts\";\nimport { MatrixError } from \"../http-api/index.ts\";\nimport { TypedEventEmitter } from \"./typed-event-emitter.ts\";\nimport { EventStatus } from \"./event-status.ts\";\nimport { IAnnotatedPushRule } from \"../@types/PushRules.ts\";\nimport { Room } from \"./room.ts\";\nimport { EventTimeline } from \"./event-timeline.ts\";\nimport { Membership } from \"../@types/membership.ts\";\n\nexport { EventStatus } from \"./event-status.ts\";\n\n/* eslint-disable camelcase */\nexport interface IContent {\n [key: string]: any;\n \"msgtype\"?: MsgType | string;\n \"membership\"?: Membership;\n \"avatar_url\"?: string;\n \"displayname\"?: string;\n \"m.relates_to\"?: IEventRelation;\n\n \"m.mentions\"?: IMentions;\n}\n\ntype StrippedState = Required<Pick<IEvent, \"content\" | \"state_key\" | \"type\" | \"sender\">>;\n\nexport interface IUnsigned {\n [key: string]: any;\n \"age\"?: number;\n \"prev_sender\"?: string;\n \"prev_content\"?: IContent;\n \"redacted_because\"?: IEvent;\n \"replaces_state\"?: string;\n \"transaction_id\"?: string;\n \"invite_room_state\"?: StrippedState[];\n \"m.relations\"?: Record<RelationType | string, any>; // No common pattern for aggregated relations\n [UNSIGNED_THREAD_ID_FIELD.name]?: string;\n}\n\nexport interface IThreadBundledRelationship {\n latest_event: IEvent;\n count: number;\n current_user_participated?: boolean;\n}\n\nexport interface IEvent {\n event_id: string;\n type: string;\n content: IContent;\n sender: string;\n room_id?: string;\n origin_server_ts: number;\n txn_id?: string;\n state_key?: string;\n membership?: Membership;\n unsigned: IUnsigned;\n redacts?: string;\n}\n\nexport interface IAggregatedRelation {\n origin_server_ts: number;\n event_id?: string;\n sender?: string;\n type?: string;\n count?: number;\n key?: string;\n}\n\nexport interface IEventRelation {\n \"rel_type\"?: RelationType | string;\n \"event_id\"?: string;\n \"is_falling_back\"?: boolean;\n \"m.in_reply_to\"?: {\n event_id?: string;\n };\n \"key\"?: string;\n}\n\nexport interface IMentions {\n user_ids?: string[];\n room?: boolean;\n}\n\nexport interface PushDetails {\n rule?: IAnnotatedPushRule;\n actions?: IActionsObject;\n}\n\n/**\n * When an event is a visibility change event, as per MSC3531,\n * the visibility change implied by the event.\n */\nexport interface IVisibilityChange {\n /**\n * If `true`, the target event should be made visible.\n * Otherwise, it should be hidden.\n */\n visible: boolean;\n\n /**\n * The event id affected.\n */\n eventId: string;\n\n /**\n * Optionally, a human-readable reason explaining why\n * the event was hidden. Ignored if the event was made\n * visible.\n */\n reason: string | null;\n}\n\nexport interface IMarkedUnreadEvent {\n unread: boolean;\n}\n\nexport interface IClearEvent {\n room_id?: string;\n type: string;\n content: Omit<IContent, \"membership\" | \"avatar_url\" | \"displayname\" | \"m.relates_to\">;\n unsigned?: IUnsigned;\n}\n/* eslint-enable camelcase */\n\ninterface IKeyRequestRecipient {\n userId: string;\n deviceId: \"*\" | string;\n}\n\nexport interface IDecryptOptions {\n /** Whether to emit {@link MatrixEventEvent.Decrypted} events on successful decryption. Defaults to true.\n */\n emit?: boolean;\n\n /**\n * True if this is a retry, after receiving an update to the session key. (Enables more logging.)\n *\n * This is only intended for use within the js-sdk.\n *\n * @internal\n */\n isRetry?: boolean;\n\n /**\n * Whether the message should be re-decrypted if it was previously successfully decrypted with an untrusted key.\n * Defaults to `false`.\n */\n forceRedecryptIfUntrusted?: boolean;\n}\n\n/**\n * Message hiding, as specified by https://github.com/matrix-org/matrix-doc/pull/3531.\n */\nexport type MessageVisibility = IMessageVisibilityHidden | IMessageVisibilityVisible;\n/**\n * Variant of `MessageVisibility` for the case in which the message should be displayed.\n */\nexport interface IMessageVisibilityVisible {\n readonly visible: true;\n}\n/**\n * Variant of `MessageVisibility` for the case in which the message should be hidden.\n */\nexport interface IMessageVisibilityHidden {\n readonly visible: false;\n /**\n * Optionally, a human-readable reason to show to the user indicating why the\n * message has been hidden (e.g. \"Message Pending Moderation\").\n */\n readonly reason: string | null;\n}\n// A singleton implementing `IMessageVisibilityVisible`.\nconst MESSAGE_VISIBLE: IMessageVisibilityVisible = Object.freeze({ visible: true });\n\nexport enum MatrixEventEvent {\n /**\n * An event has been decrypted, or we have failed to decrypt it.\n *\n * The payload consists of:\n *\n * * `event` - The {@link MatrixEvent} which we attempted to decrypt.\n *\n * * `err` - The error that occurred during decryption, or `undefined` if no error occurred.\n * Avoid use of this: {@link MatrixEvent.decryptionFailureReason} is more useful.\n */\n Decrypted = \"Event.decrypted\",\n\n BeforeRedaction = \"Event.beforeRedaction\",\n VisibilityChange = \"Event.visibilityChange\",\n LocalEventIdReplaced = \"Event.localEventIdReplaced\",\n Status = \"Event.status\",\n Replaced = \"Event.replaced\",\n RelationsCreated = \"Event.relationsCreated\",\n}\n\nexport type MatrixEventEmittedEvents = MatrixEventEvent | ThreadEvent.Update;\n\nexport type MatrixEventHandlerMap = {\n [MatrixEventEvent.Decrypted]: (event: MatrixEvent, err?: Error) => void;\n [MatrixEventEvent.BeforeRedaction]: (event: MatrixEvent, redactionEvent: MatrixEvent) => void;\n [MatrixEventEvent.VisibilityChange]: (event: MatrixEvent, visible: boolean) => void;\n [MatrixEventEvent.LocalEventIdReplaced]: (event: MatrixEvent) => void;\n [MatrixEventEvent.Status]: (event: MatrixEvent, status: EventStatus | null) => void;\n [MatrixEventEvent.Replaced]: (event: MatrixEvent) => void;\n [MatrixEventEvent.RelationsCreated]: (relationType: string, eventType: string) => void;\n} & Pick<ThreadEventHandlerMap, ThreadEvent.Update>;\n\nexport class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, MatrixEventHandlerMap> {\n // applied push rule and action for this event\n private pushDetails: PushDetails = {};\n private _replacingEvent: MatrixEvent | null = null;\n private _localRedactionEvent: MatrixEvent | null = null;\n private _isCancelled = false;\n private clearEvent?: IClearEvent;\n\n /* Message hiding, as specified by https://github.com/matrix-org/matrix-doc/pull/3531.\n\n Note: We're returning this object, so any value stored here MUST be frozen.\n */\n private visibility: MessageVisibility = MESSAGE_VISIBLE;\n\n // Not all events will be extensible-event compatible, so cache a flag in\n // addition to a falsy cached event value. We check the flag later on in\n // a public getter to decide if the cache is valid.\n private _hasCachedExtEv = false;\n private _cachedExtEv: Optional<ExtensibleEvent> = undefined;\n\n /* curve25519 key which we believe belongs to the sender of the event. See\n * getSenderKey()\n */\n private senderCurve25519Key: string | null = null;\n\n /* ed25519 key which the sender of this event (for olm) or the creator of\n * the megolm session (for megolm) claims to own. See getClaimedEd25519Key()\n */\n private claimedEd25519Key: string | null = null;\n\n /* curve25519 keys of devices involved in telling us about the\n * senderCurve25519Key and claimedEd25519Key.\n * See getForwardingCurve25519KeyChain().\n */\n private forwardingCurve25519KeyChain: string[] = [];\n\n /* where the decryption key is untrusted\n */\n private untrusted: boolean | null = null;\n\n /* The txnId with which this event was sent if it was during this session,\n * allows for a unique ID which does not change when the event comes back down sync.\n */\n private txnId?: string;\n\n /**\n * A reference to the thread this event belongs to\n */\n private thread?: Thread;\n private threadId?: string;\n\n /* Set an approximate timestamp for the event relative the local clock.\n * This will inherently be approximate because it doesn't take into account\n * the time between the server putting the 'age' field on the event as it sent\n * it to us and the time we're now constructing this event, but that's better\n * than assuming the local clock is in sync with the origin HS's clock.\n */\n public localTimestamp: number;\n\n /**\n * The room member who sent this event, or null e.g.\n * this is a presence event. This is only guaranteed to be set for events that\n * appear in a timeline, ie. do not guarantee that it will be set on state\n * events.\n * @privateRemarks\n * Should be read-only\n */\n public sender: RoomMember | null = null;\n /**\n * The room member who is the target of this event, e.g.\n * the invitee, the person being banned, etc.\n * @privateRemarks\n * Should be read-only\n */\n public target: RoomMember | null = null;\n /**\n * The sending status of the event.\n * @privateRemarks\n * Should be read-only\n */\n public status: EventStatus | null = null;\n /**\n * most recent error associated with sending the event, if any\n * @privateRemarks\n * Should be read-only. May not be a MatrixError.\n */\n public error: MatrixError | null = null;\n /**\n * True if this event is 'forward looking', meaning\n * that getDirectionalContent() will return event.content and not event.prev_content.\n * Only state events may be backwards looking\n * Default: true. <strong>This property is experimental and may change.</strong>\n * @privateRemarks\n * Should be read-only\n */\n public forwardLooking = true;\n\n private readonly reEmitter: TypedReEmitter<MatrixEventEmittedEvents, MatrixEventHandlerMap>;\n\n /**\n * Construct a Matrix Event object\n *\n * @param event - The raw (possibly encrypted) event. <b>Do not access\n * this property</b> directly unless you absolutely have to. Prefer the getter\n * methods defined on this class. Using the getter methods shields your app\n * from changes to event JSON between Matrix versions.\n */\n public constructor(public event: Partial<IEvent> = {}) {\n super();\n\n // intern the values of matrix events to force share strings and reduce the\n // amount of needless string duplication. This can save moderate amounts of\n // memory (~10% on a 350MB heap).\n // 'membership' at the event level (rather than the content level) is a legacy\n // field that Element never otherwise looks at, but it will still take up a lot\n // of space if we don't intern it.\n ([\"state_key\", \"type\", \"sender\", \"room_id\", \"membership\"] as const).forEach((prop) => {\n if (typeof event[prop] !== \"string\") return;\n event[prop] = internaliseString(event[prop]!);\n });\n\n ([\"membership\", \"avatar_url\", \"displayname\"] as const).forEach((prop) => {\n if (typeof event.content?.[prop] !== \"string\") return;\n event.content[prop] = internaliseString(event.content[prop]!);\n });\n\n ([\"rel_type\"] as const).forEach((prop) => {\n if (typeof event.content?.[\"m.relates_to\"]?.[prop] !== \"string\") return;\n event.content[\"m.relates_to\"][prop] = internaliseString(event.content[\"m.relates_to\"][prop]!);\n });\n\n this.txnId = event.txn_id;\n // The localTimestamp is calculated using the age.\n // Some events lack an `age` property, either because they are EDUs such as typing events,\n // or due to server-side bugs such as https://github.com/matrix-org/synapse/issues/8429.\n // The fallback in these cases will be to use the origin_server_ts.\n // For EDUs, the origin_server_ts also is not defined so we use Date.now().\n const age = this.getAge();\n this.localTimestamp = age !== undefined ? Date.now() - age : (this.getTs() ?? Date.now());\n this.reEmitter = new TypedReEmitter(this);\n }\n\n /**\n * Unstable getter to try and get an extensible event. Note that this might\n * return a falsy value if the event could not be parsed as an extensible\n * event.\n *\n * @deprecated Use stable functions where possible.\n */\n public get unstableExtensibleEvent(): Optional<ExtensibleEvent> {\n if (!this._hasCachedExtEv) {\n this._cachedExtEv = ExtensibleEvents.parse(this.getEffectiveEvent());\n }\n return this._cachedExtEv;\n }\n\n private invalidateExtensibleEvent(): void {\n // just reset the flag - that'll trick the getter into parsing a new event\n this._hasCachedExtEv = false;\n }\n\n /**\n * Gets the event as it would appear if it had been sent unencrypted.\n *\n * If the event is encrypted, we attempt to mock up an event as it would have looked had the sender not encrypted it.\n * If the event is not encrypted, a copy of it is simply returned as-is.\n *\n * @returns A shallow copy of the event, in wire format, as it would have been had it not been encrypted.\n */\n public getEffectiveEvent(): IEvent {\n const content = Object.assign({}, this.getContent()); // clone for mutation\n\n if (this.getWireType() === EventType.RoomMessageEncrypted) {\n // Encrypted events sometimes aren't symmetrical on the `content` so we'll copy\n // that over too, but only for missing properties. We don't copy over mismatches\n // between the plain and decrypted copies of `content` because we assume that the\n // app is relying on the decrypted version, so we want to expose that as a source\n // of truth here too.\n for (const [key, value] of Object.entries(this.getWireContent())) {\n // Skip fields from the encrypted event schema though - we don't want to leak\n // these.\n if ([\"algorithm\", \"ciphertext\", \"device_id\", \"sender_key\", \"session_id\"].includes(key)) {\n continue;\n }\n\n if (content[key] === undefined) content[key] = value;\n }\n }\n\n // clearEvent doesn't have all the fields, so we'll copy what we can from this.event.\n // We also copy over our \"fixed\" content key.\n return Object.assign({}, this.event, this.clearEvent, { content }) as IEvent;\n }\n\n /**\n * Get the event_id for this event.\n * @returns The event ID, e.g. <code>$143350589368169JsLZx:localhost\n * </code>\n */\n public getId(): string | undefined {\n return this.event.event_id;\n }\n\n /**\n * Get the user_id for this event.\n * @returns The user ID, e.g. `@alice:matrix.org`\n */\n public getSender(): string | undefined {\n return this.event.sender; // v2 / v1\n }\n\n /**\n * Get the (decrypted, if necessary) type of event.\n *\n * @returns The event type, e.g. `m.room.message`\n */\n public getType(): EventType | string {\n if (this.clearEvent) {\n return this.clearEvent.type;\n }\n return this.event.type!;\n }\n\n /**\n * Get the (possibly encrypted) type of the event that will be sent to the\n * homeserver.\n *\n * @returns The event type.\n */\n public getWireType(): EventType | string {\n return this.event.type!;\n }\n\n /**\n * Get the room_id for this event. This will return `undefined`\n * for `m.presence` events.\n * @returns The room ID, e.g. <code>!cURbafjkfsMDVwdRDQ:matrix.org\n * </code>\n */\n public getRoomId(): string | undefined {\n return this.event.room_id;\n }\n\n /**\n * Get the timestamp of this event.\n * @returns The event timestamp, e.g. `1433502692297`\n */\n public getTs(): number {\n return this.event.origin_server_ts!;\n }\n\n /**\n * Get the timestamp of this event, as a Date object.\n * @returns The event date, e.g. `new Date(1433502692297)`\n */\n public getDate(): Date | null {\n return this.event.origin_server_ts ? new Date(this.event.origin_server_ts) : null;\n }\n\n /**\n * Get a string containing details of this event\n *\n * This is intended for logging, to help trace errors. Example output:\n *\n * @example\n * ```\n * id=$HjnOHV646n0SjLDAqFrgIjim7RCpB7cdMXFrekWYAn type=m.room.encrypted\n * sender=@user:example.com room=!room:example.com ts=2022-10-25T17:30:28.404Z\n * ```\n */\n public getDetails(): string {\n const room = this.getRoomId();\n if (room) {\n // in-room event\n return `id=${this.getId()} type=${this.getWireType()} sender=${this.getSender()} room=${room} ts=${this.getDate()?.toISOString()}`;\n } else {\n // to-device event\n const msgid = this.getContent()[ToDeviceMessageId];\n return `msgid=${msgid} type=${this.getWireType()} sender=${this.getSender()}`;\n }\n }\n\n /**\n * Get the (decrypted, if necessary) event content JSON, even if the event\n * was replaced by another event.\n *\n * @returns The event content JSON, or an empty object.\n */\n public getOriginalContent<T = IContent>(): T {\n if (this._localRedactionEvent) {\n return {} as T;\n }\n if (this.clearEvent) {\n return (this.clearEvent.content || {}) as T;\n }\n return (this.event.content || {}) as T;\n }\n\n /**\n * Get the (decrypted, if necessary) event content JSON,\n * or the content from the replacing event, if any.\n * See `makeReplaced`.\n *\n * @returns The event content JSON, or an empty object.\n */\n public getContent<T extends IContent = IContent>(): T {\n if (this._localRedactionEvent) {\n return {} as T;\n } else if (this._replacingEvent) {\n return this._replacingEvent.getContent()[\"m.new_content\"] || {};\n } else {\n return this.getOriginalContent();\n }\n }\n\n /**\n * Get the (possibly encrypted) event content JSON that will be sent to the\n * homeserver.\n *\n * @returns The event content JSON, or an empty object.\n */\n public getWireContent(): IContent {\n return this.event.content || {};\n }\n\n /**\n * Get the event ID of the thread head\n */\n public get threadRootId(): string | undefined {\n // don't allow state events to be threaded as per the spec\n if (this.isState()) {\n return undefined;\n }\n const relatesTo = this.getWireContent()?.[\"m.relates_to\"];\n if (relatesTo?.rel_type === THREAD_RELATION_TYPE.name) {\n return relatesTo.event_id;\n }\n if (this.thread) {\n return this.thread.id;\n }\n if (this.threadId !== undefined) {\n return this.threadId;\n }\n const unsigned = this.getUnsigned();\n if (typeof unsigned[UNSIGNED_THREAD_ID_FIELD.name] === \"string\") {\n return unsigned[UNSIGNED_THREAD_ID_FIELD.name];\n }\n return undefined;\n }\n\n /**\n * A helper to check if an event is a thread's head or not\n */\n public get isThreadRoot(): boolean {\n // don't allow state events to be threaded as per the spec\n if (this.isState()) {\n return false;\n }\n\n const threadDetails = this.getServerAggregatedRelation<IThreadBundledRelationship>(THREAD_RELATION_TYPE.name);\n\n // Bundled relationships only returned when the sync response is limited\n // hence us having to check both bundled relation and inspect the thread\n // model\n return !!threadDetails || this.threadRootId === this.getId();\n }\n\n public get replyEventId(): string | undefined {\n return this.getWireContent()[\"m.relates_to\"]?.[\"m.in_reply_to\"]?.event_id;\n }\n\n public get relationEventId(): string | undefined {\n return this.getWireContent()?.[\"m.relates_to\"]?.event_id;\n }\n\n /**\n * Get the previous event content JSON. This will only return something for\n * state events which exist in the timeline.\n * @returns The previous event content JSON, or an empty object.\n */\n public getPrevContent(): IContent {\n // v2 then v1 then default\n return this.getUnsigned().prev_content || {};\n }\n\n /**\n * Get either 'content' or 'prev_content' depending on if this event is\n * 'forward-looking' or not. This can be modified via event.forwardLooking.\n * In practice, this means we get the chronologically earlier content value\n * for this event (this method should surely be called getEarlierContent)\n * <strong>This method is experimental and may change.</strong>\n * @returns event.content if this event is forward-looking, else\n * event.prev_content.\n */\n public getDirectionalContent(): IContent {\n return this.forwardLooking ? this.getContent() : this.getPrevContent();\n }\n\n /**\n * Get the age of this event. This represents the age of the event when the\n * event arrived at the device, and not the age of the event when this\n * function was called.\n * Can only be returned once the server has echo'ed back\n * @returns The age of this event in milliseconds.\n */\n public getAge(): number | undefined {\n return this.getUnsigned().age;\n }\n\n /**\n * Get the age of the event when this function was called.\n * This is the 'age' field adjusted according to how long this client has\n * had the event.\n * @returns The age of this event in milliseconds.\n */\n public getLocalAge(): number {\n return Date.now() - this.localTimestamp;\n }\n\n /**\n * Get the event state_key if it has one. This will return <code>undefined\n * </code> for message events.\n * @returns The event's `state_key`.\n */\n public getStateKey(): string | undefined {\n return this.event.state_key;\n }\n\n /**\n * Check if this event is a state event.\n * @returns True if this is a state event.\n */\n public isState(): boolean {\n return this.event.state_key !== undefined;\n }\n\n /**\n * Get the user's room membership at the time the event was sent, as reported\n * by the server. This uses MSC4115.\n *\n * @returns The user's room membership, or `undefined` if the server does\n * not report it.\n */\n public getMembershipAtEvent(): Optional<Membership | string> {\n const unsigned = this.getUnsigned();\n return UNSIGNED_MEMBERSHIP_FIELD.findIn<Membership | string>(unsigned);\n }\n\n public shouldAttemptDecryption(): boolean {\n if (this.isRedacted()) return false;\n if (this.clearEvent) return false;\n if (!this.isEncrypted()) return false;\n\n return true;\n }\n\n /**\n * Calculate the recipients for keyshare requests.\n *\n * @param userId - the user who received this event.\n *\n * @returns array of recipients\n */\n public getKeyRequestRecipients(userId: string): IKeyRequestRecipient[] {\n // send the request to all of our own devices\n const recipients = [\n {\n userId,\n deviceId: \"*\",\n },\n ];\n\n return recipients;\n }\n\n /**\n * Gets the cleartext content for this event. If the event is not encrypted,\n * or encryption has not been completed, this will return null.\n *\n * @returns The cleartext (decrypted) content for the event\n */\n public getClearContent(): IContent | null {\n return this.clearEvent ? this.clearEvent.content : null;\n }\n\n /**\n * Check if the event is encrypted.\n * @returns True if this event is encrypted.\n */\n public isEncrypted(): boolean {\n return !this.isState() && this.event.type === EventType.RoomMessageEncrypted;\n }\n\n /**\n * The curve25519 key for the device that we think sent this event\n *\n * For an Olm-encrypted event, this is inferred directly from the DH\n * exchange at the start of the session: the curve25519 key is involved in\n * the DH exchange, so only a device which holds the private part of that\n * key can establish such a session.\n *\n * For a megolm-encrypted event, it is inferred from the Olm message which\n * established the megolm session\n */\n public getSenderKey(): string | null {\n return this.senderCurve25519Key;\n }\n\n /**\n * The additional keys the sender of this encrypted event claims to possess.\n *\n * Just a wrapper for #getClaimedEd25519Key (q.v.)\n */\n public getKeysClaimed(): Partial<Record<\"ed25519\", string>> {\n if (!this.claimedEd25519Key) return {};\n\n return {\n ed25519: this.claimedEd25519Key,\n };\n }\n\n /**\n * Get the ed25519 the sender of this event claims to own.\n *\n * For Olm messages, this claim is encoded directly in the plaintext of the\n * event itself. For megolm messages, it is implied by the m.room_key event\n * which established the megolm session.\n *\n * Until we download the device list of the sender, it's just a claim: the\n * device list gives a proof that the owner of the curve25519 key used for\n * this event (and returned by #getSenderKey) also owns the ed25519 key by\n * signing the public curve25519 key with the ed25519 key.\n *\n * In general, applications should not use this method directly, but should\n * instead use {@link Crypto.CryptoApi#getEncryptionInfoForEvent}.\n */\n public getClaimedEd25519Key(): string | null {\n return this.claimedEd25519Key;\n }\n\n /**\n * Get the curve25519 keys of the devices which were involved in telling us\n * about the claimedEd25519Key and sender curve25519 key.\n *\n * Normally this will be empty, but in the case of a forwarded megolm\n * session, the sender keys are sent to us by another device (the forwarding\n * device), which we need to trust to do this. In that case, the result will\n * be a list consisting of one entry.\n *\n * If the device that sent us the key (A) got it from another device which\n * it wasn't prepared to vouch for (B), the result will be [A, B]. And so on.\n *\n * @returns base64-encoded curve25519 keys, from oldest to newest.\n */\n public getForwardingCurve25519KeyChain(): string[] {\n return this.forwardingCurve25519KeyChain;\n }\n\n /**\n * Whether the decryption key was obtained from an untrusted source. If so,\n * we cannot verify the authenticity of the message.\n */\n public isKeySourceUntrusted(): boolean | undefined {\n return !!this.untrusted;\n }\n\n public getUnsigned(): IUnsigned {\n return this.event.unsigned || {};\n }\n\n public setUnsigned(unsigned: IUnsigned): void {\n this.event.unsigned = unsigned;\n }\n\n public unmarkLocallyRedacted(): boolean {\n const value = this._localRedactionEvent;\n this._localRedactionEvent = null;\n if (this.event.unsigned) {\n this.event.unsigned.redacted_because = undefined;\n }\n return !!value;\n }\n\n public markLocallyRedacted(redactionEvent: MatrixEvent): void {\n if (this._localRedactionEvent) return;\n this.emit(MatrixEventEvent.BeforeRedaction, this, redactionEvent);\n this._localRedactionEvent = redactionEvent;\n if (!this.event.unsigned) {\n this.event.unsigned = {};\n }\n this.event.unsigned.redacted_because = redactionEvent.event as IEvent;\n }\n\n /**\n * Change the visibility of an event, as per https://github.com/matrix-org/matrix-doc/pull/3531 .\n *\n * @param visibilityChange - event holding a hide/unhide payload, or nothing\n * if the event is being reset to its original visibility (presumably\n * by a visibility event being redacted).\n *\n * @remarks\n * Fires {@link MatrixEventEvent.VisibilityChange} if `visibilityEvent`\n * caused a change in the actual visibility of this event, either by making it\n * visible (if it was hidden), by making it hidden (if it was visible) or by\n * changing the reason (if it was hidden).\n */\n public applyVisibilityEvent(visibilityChange?: IVisibilityChange): void {\n const visible = visibilityChange?.visible ?? true;\n const reason = visibilityChange?.reason ?? null;\n let change = false;\n if (this.visibility.visible !== visible) {\n change = true;\n } else if (!this.visibility.visible && this.visibility[\"reason\"] !== reason) {\n change = true;\n }\n if (change) {\n if (visible) {\n this.visibility = MESSAGE_VISIBLE;\n } else {\n this.visibility = Object.freeze({\n visible: false,\n reason,\n });\n }\n this.emit(MatrixEventEvent.VisibilityChange, this, visible);\n }\n }\n\n /**\n * Return instructions to display or hide the message.\n *\n * @returns Instructions determining whether the message\n * should be displayed.\n */\n public messageVisibility(): MessageVisibility {\n // Note: We may return `this.visibility` without fear, as\n // this is a shallow frozen object.\n return this.visibility;\n }\n\n /**\n * Update the content of an event in the same way it would be by the server\n * if it were redacted before it was sent to us\n *\n * @param redactionEvent - event causing the redaction\n * @param room - the room in which the event exists\n */\n public makeRedacted(redactionEvent: MatrixEvent, room: Room): void {\n // quick sanity-check\n if (!redactionEvent.event) {\n throw new Error(\"invalid redactionEvent in makeRedacted\");\n }\n\n this._localRedactionEvent = null;\n\n this.emit(MatrixEventEvent.BeforeRedaction, this, redactionEvent);\n\n this._replacingEvent = null;\n // we attempt to replicate what we would see from the server if\n // the event had been redacted before we saw it.\n //\n // The server removes (most of) the content of the event, and adds a\n // \"redacted_because\" key to the unsigned section containing the\n // redacted event.\n if (!this.event.unsigned) {\n this.event.unsigned = {};\n }\n this.event.unsigned.redacted_because = redactionEvent.event as IEvent;\n\n for (const key in this.event) {\n if (this.event.hasOwnProperty(key) && !REDACT_KEEP_KEYS.has(key)) {\n delete this.event[key as keyof IEvent];\n }\n }\n\n // If the event is encrypted prune the decrypted bits\n if (this.isEncrypted()) {\n this.clearEvent = undefined;\n }\n\n const keeps =\n this.getType() in REDACT_KEEP_CONTENT_MAP\n ? REDACT_KEEP_CONTENT_MAP[this.getType() as keyof typeof REDACT_KEEP_CONTENT_MAP]\n : {};\n const content = this.getContent();\n for (const key in content) {\n if (content.hasOwnProperty(key) && !keeps[key]) {\n delete content[key];\n }\n }\n\n // If the redacted event was in a thread (but not thread root), move it\n // to the main timeline. This will change if MSC3389 is merged.\n if (!this.isThreadRoot && this.threadRootId && this.threadRootId !== this.getId()) {\n this.moveAllRelatedToMainTimeline(room);\n redactionEvent.moveToMainTimeline(room);\n }\n\n this.invalidateExtensibleEvent();\n }\n\n private moveAllRelatedToMainTimeline(room: Room): void {\n const thread = this.thread;\n this.moveToMainTimeline(room);\n\n // If we dont have access to the thread, we can only move this\n // event, not things related to it.\n if (thread) {\n for (const event of thread.events) {\n if (event.getRelation()?.event_id === this.getId()) {\n event.moveAllRelatedToMainTimeline(room);\n }\n }\n }\n }\n\n private moveToMainTimeline(room: Room): void {\n // Remove it from its thread\n this.thread?.timelineSet.removeEvent(this.getId()!);\n this.setThread(undefined);\n\n // And insert it into the main timeline\n const timeline = room.getLiveTimeline();\n // We use insertEventIntoTimeline to insert it in timestamp order,\n // because we don't know where it should go (until we have MSC4033).\n timeline.getTimelineSet().insertEventIntoTimeline(this, timeline, timeline.getState(EventTimeline.FORWARDS)!);\n }\n\n /**\n * Check if this event has been redacted\n *\n * @returns True if this event has been redacted\n */\n public isRedacted(): boolean {\n return Boolean(this.getUnsigned().redacted_because);\n }\n\n /**\n * Check if this event is a redaction of another event\n *\n * @returns True if this event is a redaction\n */\n public isRedaction(): boolean {\n return this.getType() === EventType.RoomRedaction;\n }\n\n /**\n * Return the visibility change caused by this event,\n * as per https://github.com/matrix-org/matrix-doc/pull/3531.\n *\n * @returns If the event is a well-formed visibility change event,\n * an instance of `IVisibilityChange`, otherwise `null`.\n */\n public asVisibilityChange(): IVisibilityChange | null {\n if (!EVENT_VISIBILITY_CHANGE_TYPE.matches(this.getType())) {\n // Not a visibility change event.\n return null;\n }\n const relation = this.getRelation();\n if (!relation || relation.rel_type != \"m.reference\") {\n // Ill-formed, ignore this event.\n return null;\n }\n const eventId = relation.event_id;\n if (!eventId) {\n // Ill-formed, ignore this event.\n return null;\n }\n const content = this.getWireContent();\n const visible = !!content.visible;\n const reason = content.reason;\n if (reason && typeof reason != \"string\") {\n // Ill-formed, ignore this event.\n return null;\n }\n // Well-formed visibility change event.\n return {\n visible,\n reason,\n eventId,\n };\n }\n\n /**\n * Check if this event alters the visibility of another event,\n * as per https://github.com/matrix-org/matrix-doc/pull/3531.\n *\n * @returns True if this event alters the visibility\n * of another event.\n */\n public isVisibilityEvent(): boolean {\n return EVENT_VISIBILITY_CHANGE_TYPE.matches(this.getType());\n }\n\n /**\n * Get the (decrypted, if necessary) redaction event JSON\n * if event was redacted\n *\n * @returns The redaction event JSON, or an empty object\n */\n public getRedactionEvent(): IEvent | {} | null {\n if (!this.isRedacted()) return null;\n\n if (this.clearEvent?.unsigned) {\n return this.clearEvent?.unsigned.redacted_because ?? null;\n } else if (this.event.unsigned?.redacted_because) {\n return this.event.unsigned.redacted_because;\n } else {\n return {};\n }\n }\n\n /**\n * Get the push actions, if known, for this event\n *\n * @returns push actions\n */\n public getPushActions(): IActionsObject | null {\n return this.pushDetails.actions || null;\n }\n\n /**\n * Get the push details, if known, for this event\n *\n * @returns push actions\n */\n public getPushDetails(): PushDetails {\n return this.pushDetails;\n }\n\n /**\n * Set the push details for this event.\n *\n * @param pushActions - push actions\n * @param rule - the executed push rule\n */\n public setPushDetails(pushActions?: IActionsObject, rule?: IAnnotatedPushRule): void {\n this.pushDetails = {\n actions: pushActions,\n rule,\n };\n }\n\n /**\n * Replace the `event` property and recalculate any properties based on it.\n * @param event - the object to assign to the `event` property\n */\n public handleRemoteEcho(event: object): void {\n const oldUnsigned = this.getUnsigned();\n const oldId = this.getId();\n this.event = event;\n // if this event was redacted before it was sent, it's locally marked as redacted.\n // At this point, we've received the remote echo for the event, but not yet for\n // the redaction that we are sending ourselves. Preserve the locally redacted\n // state by copying over redacted_because so we don't get a flash of\n // redacted, not-redacted, redacted as remote echos come in\n if (oldUnsigned.redacted_because) {\n if (!this.event.unsigned) {\n this.event.unsigned = {};\n }\n this.event.unsigned.redacted_because = oldUnsigned.redacted_because;\n }\n // successfully sent.\n this.setStatus(null);\n if (this.getId() !== oldId) {\n // emit the event if it changed\n this.emit(MatrixEventEvent.LocalEventIdReplaced, this);\n }\n\n this.localTimestamp = Date.now() - this.getAge()!;\n }\n\n /**\n * Whether the event is in any phase of sending, send failure, waiting for\n * remote echo, etc.\n */\n public isSending(): boolean {\n return !!this.status;\n }\n\n /**\n * Update the event's sending status and emit an event as well.\n *\n * @param status - The new status\n */\n public setStatus(status: EventStatus | null): void {\n this.status = status;\n this.emit(MatrixEventEvent.Status, this, status);\n }\n\n public replaceLocalEventId(eventId: string): void {\n this.event.event_id = eventId;\n this.emit(MatrixEventEvent.LocalEventIdReplaced, this);\n }\n\n /**\n * Get whether the event is a relation event, and of a given type if\n * `relType` is passed in. State events cannot be relation events\n *\n * @param relType - if given, checks that the relation is of the\n * given type\n */\n public isRelation(relType?: string): boolean {\n // Relation info is lifted out of the encrypted content when sent to\n // encrypted rooms, so we have to check `getWireContent` for this.\n const relation = this.getWireContent()?.[\"m.relates_to\"];\n if (\n this.isState() &&\n !!relation?.rel_type &&\n ([RelationType.Replace, RelationType.Thread] as string[]).includes(relation.rel_type)\n ) {\n // State events cannot be m.replace or m.thread relations\n return false;\n }\n return !!(relation?.rel_type && relation.event_id && (relType ? relation.rel_type === relType : true));\n }\n\n /**\n * Get relation info for the event, if any.\n */\n public getRelation(): IEventRelation | null {\n if (!this.isRelation()) {\n return null;\n }\n return this.getWireContent()[\"m.relates_to\"] ?? null;\n }\n\n /**\n * Set an event that replaces the content of this event, through an m.replace relation.\n *\n * @param newEvent - the event with the replacing content, if any.\n *\n * @remarks\n * Fires {@link MatrixEventEvent.Replaced}\n */\n public makeReplaced(newEvent?: MatrixEvent): void {\n // don't allow redacted events to be replaced.\n // if newEvent is null we allow to go through though,\n // as with local redaction, the replacing event might get\n // cancelled, which should be reflected on the target event.\n if (this.isRedacted() && newEvent) {\n return;\n }\n // don't allow state events to be replaced using this mechanism as per MSC2676\n if (this.isState()) {\n return;\n }\n if (this._replacingEvent !== newEvent) {\n this._replacingEvent = newEvent ?? null;\n this.emit(MatrixEventEvent.Replaced, this);\n this.invalidateExtensibleEvent();\n }\n }\n\n /**\n * Returns the status of any associated edit or redaction\n * (not for reactions/annotations as their local echo doesn't affect the original event),\n * or else the status of the event.\n */\n public getAssociatedStatus(): EventStatus | null {\n if (this._replacingEvent) {\n return this._replacingEvent.status;\n } else if (this._localRedactionEvent) {\n return this._localRedactionEvent.status;\n }\n return this.status;\n }\n\n public getServerAggregatedRelation<T>(relType: RelationType | string): T | undefined {\n return this.getUnsigned()[\"m.relations\"]?.[relType];\n }\n\n /**\n * Returns the event ID of the event replacing the content of this event, if any.\n */\n public replacingEventId(): string | undefined {\n const replaceRelation = this.getServerAggregatedRelation<IAggregatedRelation>(RelationType.Replace);\n if (replaceRelation) {\n return replaceRelation.event_id;\n } else if (this._replacingEvent) {\n return this._replacingEvent.getId();\n }\n }\n\n /**\n * Returns the event replacing the content of this event, if any.\n * Replacements are aggregated on the server, so this would only\n * return an event in case it came down the sync, or for local echo of edits.\n */\n public replacingEvent(): MatrixEvent | null {\n return this._replacingEvent;\n }\n\n /**\n * Returns the origin_server_ts of the event replacing the content of this event, if any.\n */\n public replacingEventDate(): Date | undefined {\n const replaceRelation = this.getServerAggregatedRelation<IAggregatedRelation>(RelationType.Replace);\n if (replaceRelation) {\n const ts = replaceRelation.origin_server_ts;\n if (Number.isFinite(ts)) {\n return new Date(ts);\n }\n } else if (this._replacingEvent) {\n return this._replacingEvent.getDate() ?? undefined;\n }\n }\n\n /**\n * Returns the event that wants to redact this event, but hasn't been sent yet.\n * @returns the event\n */\n public localRedactionEvent(): MatrixEvent | null {\n return this._localRedactionEvent;\n }\n\n /**\n * For relations and redactions, returns the event_id this event is referring to.\n */\n public getAssociatedId(): string | undefined {\n const relation = this.getRelation();\n if (this.replyEventId) {\n return this.replyEventId;\n } else if (relation) {\n return relation.event_id;\n } else if (this.isRedaction()) {\n return this.event.redacts;\n }\n }\n\n /**\n * Checks if this event is associated with another event. See `getAssociatedId`.\n */\n public hasAssociation(): boolean {\n return !!this.getAssociatedId();\n }\n\n /**\n * Update the related id with a new one.\n *\n * Used to replace a local id with remote one before sending\n * an event with a related id.\n *\n * @param eventId - the new event id\n */\n public updateAssociatedId(eventId: string): void {\n const relation = this.getRelation();\n if (relation) {\n relation.event_id = eventId;\n } else if (this.isRedaction()) {\n this.event.redacts = eventId;\n }\n }\n\n /**\n * Flags an event as cancelled due to future conditions. For example, a verification\n * request event in the same sync transaction may be flagged as cancelled to warn\n * listeners that a cancellation event is coming down the same pipe shortly.\n * @param cancelled - Whether the event is to be cancelled or not.\n */\n public flagCancelled(cancelled = true): void {\n this._isCancelled = cancelled;\n }\n\n /**\n * Gets whether or not the event is flagged as cancelled. See flagCancelled() for\n * more information.\n * @returns True if the event is cancelled, false otherwise.\n */\n public isCancelled(): boolean {\n return this._isCancelled;\n }\n\n /**\n * Get a copy/snapshot of this event. The returned copy will be loosely linked\n * back to this instance, though will have \"frozen\" event information. Other\n * properties of this MatrixEvent instance will be copied verbatim, which can\n * mean they are in reference to this instance despite being on the copy too.\n * The reference the snapshot uses does not change, however members aside from\n * the underlying event will not be deeply cloned, thus may be mutated internally.\n * For example, the sender profile will be copied over at snapshot time, and\n * the sender profile internally may mutate without notice to the consumer.\n *\n * This is meant to be used to snapshot the event details themselves, not the\n * features (such as sender) surrounding the event.\n * @returns A snapshot of this event.\n */\n public toSnapshot(): MatrixEvent {\n const ev = new MatrixEvent(JSON.parse(JSON.stringify(this.event)));\n for (const [p, v] of Object.entries(this)) {\n if (p !== \"event\") {\n // exclude the thing we just cloned\n // @ts-ignore - XXX: this is just nasty\n ev[p as keyof MatrixEvent] = v;\n }\n }\n return ev;\n }\n\n /**\n * Determines if this event is equivalent to the given event. This only checks\n * the event object itself, not the other properties of the event. Intended for\n * use with toSnapshot() to identify events changing.\n * @param otherEvent - The other event to check against.\n * @returns True if the events are the same, false otherwise.\n */\n public isEquivalentTo(otherEvent: MatrixEvent): boolean {\n if (!otherEvent) return false;\n if (otherEvent === this) return true;\n const myProps = deepSortedObjectEntries(this.event);\n const theirProps = deepSortedObjectEntries(otherEvent.event);\n return JSON.stringify(myProps) === JSON.stringify(theirProps);\n }\n\n /**\n * Summarise the event as JSON.\n *\n * If encrypted, include both the decrypted and encrypted view of the event.\n *\n * This is named `toJSON` for use with `JSON.stringify` which checks objects\n * for functions named `toJSON` and will call them to customise the output\n * if they are defined.\n *\n * **WARNING** Do not log the result of this method; otherwise, it will end up\n * in rageshakes, leading to a privacy violation.\n *\n * @deprecated Prefer to use {@link MatrixEvent#getEffectiveEvent} or similar.\n * This method will be removed soon; it is too easy to use it accidentally\n * and cause a privacy violation (cf https://github.com/vector-im/element-web/issues/26380).\n * In any case, the value it returns is not a faithful serialization of the object.\n */\n public toJSON(): object {\n const event = this.getEffectiveEvent();\n\n if (!this.isEncrypted()) {\n return event;\n }\n\n return {\n decrypted: event,\n encrypted: this.event,\n };\n }\n\n public setTxnId(txnId: string): void {\n this.txnId = txnId;\n }\n\n public getTxnId(): string | undefined {\n return this.txnId;\n }\n\n /**\n * Set the instance of a thread associated with the current event\n * @param thread - the thread\n */\n public setThread(thread?: Thread): void {\n // don't allow state events to be threaded as per the spec\n if (this.isState()) {\n return;\n }\n if (this.thread) {\n this.reEmitter.stopReEmitting(this.thread, [ThreadEvent.Update]);\n }\n this.thread = thread;\n this.setThreadId(thread?.id);\n if (thread) {\n this.reEmitter.reEmit(thread, [ThreadEvent.Update]);\n }\n }\n\n /**\n * Get the instance of the thread associated with the current event\n */\n public getThread(): Thread | undefined {\n return this.thread;\n }\n\n public setThreadId(threadId?: string): void {\n this.threadId = threadId;\n }\n}\n\n/* REDACT_KEEP_KEYS gives the keys we keep when an event is redacted\n *\n * This is specified here:\n * http://matrix.org/speculator/spec/HEAD/client_server/latest.html#redactions\n *\n * Also:\n * - We keep 'unsigned' since that is created by the local server\n * - We keep user_id for backwards-compat with v1\n */\nconst REDACT_KEEP_KEYS = new Set([\n \"event_id\",\n \"type\",\n \"room_id\",\n \"user_id\",\n \"sender\",\n \"state_key\",\n \"prev_state\",\n \"content\",\n \"unsigned\",\n \"origin_server_ts\",\n]);\n\n// a map from state event type to the .content keys we keep when an event is redacted\nconst REDACT_KEEP_CONTENT_MAP: Record<string, Record<string, 1>> = {\n [EventType.RoomMember]: { membership: 1 },\n [EventType.RoomJoinRules]: { join_rule: 1 },\n [EventType.RoomPowerLevels]: {\n ban: 1,\n events: 1,\n events_default: 1,\n kick: 1,\n redact: 1,\n state_default: 1,\n users: 1,\n users_default: 1,\n },\n} as const;\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA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W;IACtC,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,IAAI;IAfhB,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,SAAS,EAAE,cAAc,CAAC;IAC1C,OAAO,CAAC,oBAAoB,CAAS;IACrC,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,SAAS,CAA0B;IAC3C,OAAO,CAAC,QAAQ,CAA0B;IAC1C;;;OAGG;IACH,OAAO,CAAC,6BAA6B,CAAqB;gBAGtC,SAAS,EAAE,WAAW,EAC9B,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,IAAI;IAUtB,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED,IAAW,UAAU,IAAI,MAAM,GAAG,SAAS,CAE1C;IAED,IAAW,OAAO,IAAI,OAAO,CAE5B;IAED,IAAW,mBAAmB,IAAI,OAAO,CAExC;IAED,IAAW,2BAA2B,IAAI,MAAM,CAE/C;IAEY,YAAY,IAAI,OAAO,CAAC,SAAS,CAAC;IAgB/C;;;;OAIG;IACI,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;YA0BhC,cAAc;IAwD5B;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAe9B,OAAO,CAAC,wBAAwB,CAU9B;IAEF,OAAO,CAAC,gBAAgB;CAyB3B;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,UAAW,WAAW,KAAG,OAGhD,CAAC"}
|
package/lib/models/poll.js
CHANGED
@@ -31,9 +31,6 @@ export var PollEvent = /*#__PURE__*/function (PollEvent) {
|
|
31
31
|
}({});
|
32
32
|
var filterResponseRelations = (relationEvents, pollEndTimestamp) => {
|
33
33
|
var responseEvents = relationEvents.filter(event => {
|
34
|
-
if (event.isDecryptionFailure()) {
|
35
|
-
return;
|
36
|
-
}
|
37
34
|
return M_POLL_RESPONSE.matches(event.getType()) &&
|
38
35
|
// From MSC3381:
|
39
36
|
// "Votes sent on or before the end event's timestamp are valid votes"
|
@@ -61,7 +58,7 @@ export class Poll extends TypedEventEmitter {
|
|
61
58
|
*/
|
62
59
|
_defineProperty(this, "undecryptableRelationEventIds", new Set());
|
63
60
|
_defineProperty(this, "countUndecryptableEvents", events => {
|
64
|
-
var undecryptableEventIds = events.
|
61
|
+
var undecryptableEventIds = events.map(event => event.getId());
|
65
62
|
var previousCount = this.undecryptableRelationsCount;
|
66
63
|
this.undecryptableRelationEventIds = new Set([...this.undecryptableRelationEventIds, ...undecryptableEventIds]);
|
67
64
|
if (this.undecryptableRelationsCount !== previousCount) {
|
@@ -151,7 +148,6 @@ export class Poll extends TypedEventEmitter {
|
|
151
148
|
var allRelations = yield _this2.matrixClient.relations(_this2.roomId, _this2.rootEvent.getId(), "m.reference", undefined, {
|
152
149
|
from: _this2.relationsNextBatch || undefined
|
153
150
|
});
|
154
|
-
yield Promise.all(allRelations.events.map(event => _this2.matrixClient.decryptEventIfNeeded(event)));
|
155
151
|
var responses = _this2.responses || new Relations("m.reference", M_POLL_RESPONSE.name, _this2.matrixClient, [M_POLL_RESPONSE.altName]);
|
156
152
|
var pollEndEvent = allRelations.events.find(event => M_POLL_END.matches(event.getType()));
|
157
153
|
if (_this2.validateEndEvent(pollEndEvent)) {
|
package/lib/models/poll.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"poll.js","names":["M_POLL_START","M_POLL_END","M_POLL_RESPONSE","Relations","TypedEventEmitter","PollEvent","filterResponseRelations","relationEvents","pollEndTimestamp","responseEvents","filter","event","isDecryptionFailure","matches","getType","getTs","Poll","constructor","rootEvent","matrixClient","room","_defineProperty","Set","events","undecryptableEventIds","map","getId","previousCount","undecryptableRelationsCount","undecryptableRelationEventIds","emit","UndecryptableRelations","getRoomId","Error","roomId","pollEvent","unstableExtensibleEvent","pollId","endEventId","_this$endEvent","endEvent","isEnded","isFetchingResponses","_isFetchingResponses","size","getResponses","_this","_asyncToGenerator","responses","fetchResponses","onNewRelation","_this$endEvent2","validateEndEvent","refilterResponsesOnEnd","End","Number","MAX_SAFE_INTEGER","countUndecryptableEvents","length","forEach","addEvent","Responses","_this2","_this2$endEvent","_allRelations$nextBat","allRelations","relations","undefined","from","relationsNextBatch","Promise","all","decryptEventIfNeeded","name","altName","pollEndEvent","find","pollCloseTimestamp","nextBatch","_this$endEvent3","getRelations","_this$responses","removeEvent","roomCurrentState","currentState","endEventSender","getSender","maySendRedactionForEvent","isPollEvent","eventType"],"sources":["../../src/models/poll.ts"],"sourcesContent":["/*\nCopyright 2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { M_POLL_START } from \"matrix-events-sdk\";\n\nimport { M_POLL_END, M_POLL_RESPONSE } from \"../@types/polls.ts\";\nimport { MatrixClient } from \"../client.ts\";\nimport { PollStartEvent } from \"../extensible_events_v1/PollStartEvent.ts\";\nimport { MatrixEvent } from \"./event.ts\";\nimport { Relations } from \"./relations.ts\";\nimport { Room } from \"./room.ts\";\nimport { TypedEventEmitter } from \"./typed-event-emitter.ts\";\n\nexport enum PollEvent {\n New = \"Poll.new\",\n End = \"Poll.end\",\n Update = \"Poll.update\",\n Responses = \"Poll.Responses\",\n Destroy = \"Poll.Destroy\",\n UndecryptableRelations = \"Poll.UndecryptableRelations\",\n}\n\nexport type PollEventHandlerMap = {\n [PollEvent.Update]: (event: MatrixEvent, poll: Poll) => void;\n [PollEvent.Destroy]: (pollIdentifier: string) => void;\n [PollEvent.End]: () => void;\n [PollEvent.Responses]: (responses: Relations) => void;\n [PollEvent.UndecryptableRelations]: (count: number) => void;\n};\n\nconst filterResponseRelations = (\n relationEvents: MatrixEvent[],\n pollEndTimestamp: number,\n): {\n responseEvents: MatrixEvent[];\n} => {\n const responseEvents = relationEvents.filter((event) => {\n if (event.isDecryptionFailure()) {\n return;\n }\n return (\n M_POLL_RESPONSE.matches(event.getType()) &&\n // From MSC3381:\n // \"Votes sent on or before the end event's timestamp are valid votes\"\n event.getTs() <= pollEndTimestamp\n );\n });\n\n return { responseEvents };\n};\n\nexport class Poll extends TypedEventEmitter<Exclude<PollEvent, PollEvent.New>, PollEventHandlerMap> {\n public readonly roomId: string;\n public readonly pollEvent: PollStartEvent;\n private _isFetchingResponses = false;\n private relationsNextBatch: string | undefined;\n private responses: null | Relations = null;\n private endEvent: MatrixEvent | undefined;\n /**\n * Keep track of undecryptable relations\n * As incomplete result sets affect poll results\n */\n private undecryptableRelationEventIds = new Set<string>();\n\n public constructor(\n public readonly rootEvent: MatrixEvent,\n private matrixClient: MatrixClient,\n private room: Room,\n ) {\n super();\n if (!this.rootEvent.getRoomId() || !this.rootEvent.getId()) {\n throw new Error(\"Invalid poll start event.\");\n }\n this.roomId = this.rootEvent.getRoomId()!;\n this.pollEvent = this.rootEvent.unstableExtensibleEvent as unknown as PollStartEvent;\n }\n\n public get pollId(): string {\n return this.rootEvent.getId()!;\n }\n\n public get endEventId(): string | undefined {\n return this.endEvent?.getId();\n }\n\n public get isEnded(): boolean {\n return !!this.endEvent;\n }\n\n public get isFetchingResponses(): boolean {\n return this._isFetchingResponses;\n }\n\n public get undecryptableRelationsCount(): number {\n return this.undecryptableRelationEventIds.size;\n }\n\n public async getResponses(): Promise<Relations> {\n // if we have already fetched some responses\n // just return them\n if (this.responses) {\n return this.responses;\n }\n\n // if there is no fetching in progress\n // start fetching\n if (!this.isFetchingResponses) {\n await this.fetchResponses();\n }\n // return whatever responses we got from the first page\n return this.responses!;\n }\n\n /**\n *\n * @param event - event with a relation to the rootEvent\n * @returns void\n */\n public onNewRelation(event: MatrixEvent): void {\n if (M_POLL_END.matches(event.getType()) && this.validateEndEvent(event)) {\n this.endEvent = event;\n this.refilterResponsesOnEnd();\n this.emit(PollEvent.End);\n }\n\n // wait for poll responses to be initialised\n if (!this.responses) {\n return;\n }\n\n const pollEndTimestamp = this.endEvent?.getTs() || Number.MAX_SAFE_INTEGER;\n const { responseEvents } = filterResponseRelations([event], pollEndTimestamp);\n\n this.countUndecryptableEvents([event]);\n\n if (responseEvents.length) {\n responseEvents.forEach((event) => {\n this.responses!.addEvent(event);\n });\n\n this.emit(PollEvent.Responses, this.responses);\n }\n }\n\n private async fetchResponses(): Promise<void> {\n this._isFetchingResponses = true;\n\n // we want:\n // - stable and unstable M_POLL_RESPONSE\n // - stable and unstable M_POLL_END\n // so make one api call and filter by event type client side\n const allRelations = await this.matrixClient.relations(\n this.roomId,\n this.rootEvent.getId()!,\n \"m.reference\",\n undefined,\n {\n from: this.relationsNextBatch || undefined,\n },\n );\n\n await Promise.all(allRelations.events.map((event) => this.matrixClient.decryptEventIfNeeded(event)));\n\n const responses =\n this.responses ||\n new Relations(\"m.reference\", M_POLL_RESPONSE.name, this.matrixClient, [M_POLL_RESPONSE.altName!]);\n\n const pollEndEvent = allRelations.events.find((event) => M_POLL_END.matches(event.getType()));\n\n if (this.validateEndEvent(pollEndEvent)) {\n this.endEvent = pollEndEvent;\n this.refilterResponsesOnEnd();\n this.emit(PollEvent.End);\n }\n\n const pollCloseTimestamp = this.endEvent?.getTs() || Number.MAX_SAFE_INTEGER;\n\n const { responseEvents } = filterResponseRelations(allRelations.events, pollCloseTimestamp);\n\n responseEvents.forEach((event) => {\n responses.addEvent(event);\n });\n\n this.relationsNextBatch = allRelations.nextBatch ?? undefined;\n this.responses = responses;\n this.countUndecryptableEvents(allRelations.events);\n\n // while there are more pages of relations\n // fetch them\n if (this.relationsNextBatch) {\n // don't await\n // we want to return the first page as soon as possible\n this.fetchResponses();\n } else {\n // no more pages\n this._isFetchingResponses = false;\n }\n\n // emit after updating _isFetchingResponses state\n this.emit(PollEvent.Responses, this.responses);\n }\n\n /**\n * Only responses made before the poll ended are valid\n * Refilter after an end event is recieved\n * To ensure responses are valid\n */\n private refilterResponsesOnEnd(): void {\n if (!this.responses) {\n return;\n }\n\n const pollEndTimestamp = this.endEvent?.getTs() || Number.MAX_SAFE_INTEGER;\n this.responses.getRelations().forEach((event) => {\n if (event.getTs() > pollEndTimestamp) {\n this.responses?.removeEvent(event);\n }\n });\n\n this.emit(PollEvent.Responses, this.responses);\n }\n\n private countUndecryptableEvents = (events: MatrixEvent[]): void => {\n const undecryptableEventIds = events\n .filter((event) => event.isDecryptionFailure())\n .map((event) => event.getId()!);\n\n const previousCount = this.undecryptableRelationsCount;\n this.undecryptableRelationEventIds = new Set([...this.undecryptableRelationEventIds, ...undecryptableEventIds]);\n\n if (this.undecryptableRelationsCount !== previousCount) {\n this.emit(PollEvent.UndecryptableRelations, this.undecryptableRelationsCount);\n }\n };\n\n private validateEndEvent(endEvent?: MatrixEvent): boolean {\n if (!endEvent) {\n return false;\n }\n /**\n * Repeated end events are ignored -\n * only the first (valid) closure event by origin_server_ts is counted.\n */\n if (this.endEvent && this.endEvent.getTs() < endEvent.getTs()) {\n return false;\n }\n\n /**\n * MSC3381\n * If a m.poll.end event is received from someone other than the poll creator or user with permission to redact\n * others' messages in the room, the event must be ignored by clients due to being invalid.\n */\n const roomCurrentState = this.room.currentState;\n const endEventSender = endEvent.getSender();\n return (\n !!endEventSender &&\n (endEventSender === this.rootEvent.getSender() ||\n roomCurrentState.maySendRedactionForEvent(this.rootEvent, endEventSender))\n );\n }\n}\n\n/**\n * Tests whether the event is a start, response or end poll event.\n *\n * @param event - Event to test\n * @returns true if the event is a poll event, else false\n */\nexport const isPollEvent = (event: MatrixEvent): boolean => {\n const eventType = event.getType();\n return M_POLL_START.matches(eventType) || M_POLL_RESPONSE.matches(eventType) || M_POLL_END.matches(eventType);\n};\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,YAAY,QAAQ,mBAAmB;AAEhD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AdA,eAAA,CAAgBC,WAAW,CAACvE,KAAK,CAAC;MACtC;IACJ,CAAC,CAAC;IAEF,IAAI,CAACmB,IAAI,CAACzB,SAAS,CAACwD,SAAS,EAAE,IAAI,CAACb,SAAS,CAAC;EAClD;EAeQI,gBAAgBA,CAACZ,QAAsB,EAAW;IACtD,IAAI,CAACA,QAAQ,EAAE;MACX,OAAO,KAAK;IAChB;IACA;AACR;AACA;AACA;IACQ,IAAI,IAAI,CAACA,QAAQ,IAAI,IAAI,CAACA,QAAQ,CAACzB,KAAK,CAAC,CAAC,GAAGyB,QAAQ,CAACzB,KAAK,CAAC,CAAC,EAAE;MAC3D,OAAO,KAAK;IAChB;;IAEA;AACR;AACA;AACA;AACA;IACQ,IAAMoE,gBAAgB,GAAG,IAAI,CAAC/D,IAAI,CAACgE,YAAY;IAC/C,IAAMC,cAAc,GAAG7C,QAAQ,CAAC8C,SAAS,CAAC,CAAC;IAC3C,OACI,CAAC,CAACD,cAAc,KACfA,cAAc,KAAK,IAAI,CAACnE,SAAS,CAACoE,SAAS,CAAC,CAAC,IAC1CH,gBAAgB,CAACI,wBAAwB,CAAC,IAAI,CAACrE,SAAS,EAAEmE,cAAc,CAAC,CAAC;EAEtF;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMG,WAAW,GAAI7E,KAAkB,IAAc;EACxD,IAAM8E,SAAS,GAAG9E,KAAK,CAACG,OAAO,CAAC,CAAC;EACjC,OAAOd,YAAY,CAACa,OAAO,CAAC4E,SAAS,CAAC,IAAIvF,eAAe,CAACW,OAAO,CAAC4E,SAAS,CAAC,IAAIxF,UAAU,CAACY,OAAO,CAAC4E,SAAS,CAAC;AACjH,CAAC","ignoreList":[]}
|
1
|
+
{"version":3,"file":"poll.js","names":["M_POLL_START","M_POLL_END","M_POLL_RESPONSE","Relations","TypedEventEmitter","PollEvent","filterResponseRelations","relationEvents","pollEndTimestamp","responseEvents","filter","event","matches","getType","getTs","Poll","constructor","rootEvent","matrixClient","room","_defineProperty","Set","events","undecryptableEventIds","map","getId","previousCount","undecryptableRelationsCount","undecryptableRelationEventIds","emit","UndecryptableRelations","getRoomId","Error","roomId","pollEvent","unstableExtensibleEvent","pollId","endEventId","_this$endEvent","endEvent","isEnded","isFetchingResponses","_isFetchingResponses","size","getResponses","_this","_asyncToGenerator","responses","fetchResponses","onNewRelation","_this$endEvent2","validateEndEvent","refilterResponsesOnEnd","End","Number","MAX_SAFE_INTEGER","countUndecryptableEvents","length","forEach","addEvent","Responses","_this2","_this2$endEvent","_allRelations$nextBat","allRelations","relations","undefined","from","relationsNextBatch","name","altName","pollEndEvent","find","pollCloseTimestamp","nextBatch","_this$endEvent3","getRelations","_this$responses","removeEvent","roomCurrentState","currentState","endEventSender","getSender","maySendRedactionForEvent","isPollEvent","eventType"],"sources":["../../src/models/poll.ts"],"sourcesContent":["/*\nCopyright 2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { M_POLL_START } from \"matrix-events-sdk\";\n\nimport { M_POLL_END, M_POLL_RESPONSE } from \"../@types/polls.ts\";\nimport { MatrixClient } from \"../client.ts\";\nimport { PollStartEvent } from \"../extensible_events_v1/PollStartEvent.ts\";\nimport { MatrixEvent } from \"./event.ts\";\nimport { Relations } from \"./relations.ts\";\nimport { Room } from \"./room.ts\";\nimport { TypedEventEmitter } from \"./typed-event-emitter.ts\";\n\nexport enum PollEvent {\n New = \"Poll.new\",\n End = \"Poll.end\",\n Update = \"Poll.update\",\n Responses = \"Poll.Responses\",\n Destroy = \"Poll.Destroy\",\n UndecryptableRelations = \"Poll.UndecryptableRelations\",\n}\n\nexport type PollEventHandlerMap = {\n [PollEvent.Update]: (event: MatrixEvent, poll: Poll) => void;\n [PollEvent.Destroy]: (pollIdentifier: string) => void;\n [PollEvent.End]: () => void;\n [PollEvent.Responses]: (responses: Relations) => void;\n [PollEvent.UndecryptableRelations]: (count: number) => void;\n};\n\nconst filterResponseRelations = (\n relationEvents: MatrixEvent[],\n pollEndTimestamp: number,\n): {\n responseEvents: MatrixEvent[];\n} => {\n const responseEvents = relationEvents.filter((event) => {\n return (\n M_POLL_RESPONSE.matches(event.getType()) &&\n // From MSC3381:\n // \"Votes sent on or before the end event's timestamp are valid votes\"\n event.getTs() <= pollEndTimestamp\n );\n });\n\n return { responseEvents };\n};\n\nexport class Poll extends TypedEventEmitter<Exclude<PollEvent, PollEvent.New>, PollEventHandlerMap> {\n public readonly roomId: string;\n public readonly pollEvent: PollStartEvent;\n private _isFetchingResponses = false;\n private relationsNextBatch: string | undefined;\n private responses: null | Relations = null;\n private endEvent: MatrixEvent | undefined;\n /**\n * Keep track of undecryptable relations\n * As incomplete result sets affect poll results\n */\n private undecryptableRelationEventIds = new Set<string>();\n\n public constructor(\n public readonly rootEvent: MatrixEvent,\n private matrixClient: MatrixClient,\n private room: Room,\n ) {\n super();\n if (!this.rootEvent.getRoomId() || !this.rootEvent.getId()) {\n throw new Error(\"Invalid poll start event.\");\n }\n this.roomId = this.rootEvent.getRoomId()!;\n this.pollEvent = this.rootEvent.unstableExtensibleEvent as unknown as PollStartEvent;\n }\n\n public get pollId(): string {\n return this.rootEvent.getId()!;\n }\n\n public get endEventId(): string | undefined {\n return this.endEvent?.getId();\n }\n\n public get isEnded(): boolean {\n return !!this.endEvent;\n }\n\n public get isFetchingResponses(): boolean {\n return this._isFetchingResponses;\n }\n\n public get undecryptableRelationsCount(): number {\n return this.undecryptableRelationEventIds.size;\n }\n\n public async getResponses(): Promise<Relations> {\n // if we have already fetched some responses\n // just return them\n if (this.responses) {\n return this.responses;\n }\n\n // if there is no fetching in progress\n // start fetching\n if (!this.isFetchingResponses) {\n await this.fetchResponses();\n }\n // return whatever responses we got from the first page\n return this.responses!;\n }\n\n /**\n *\n * @param event - event with a relation to the rootEvent\n * @returns void\n */\n public onNewRelation(event: MatrixEvent): void {\n if (M_POLL_END.matches(event.getType()) && this.validateEndEvent(event)) {\n this.endEvent = event;\n this.refilterResponsesOnEnd();\n this.emit(PollEvent.End);\n }\n\n // wait for poll responses to be initialised\n if (!this.responses) {\n return;\n }\n\n const pollEndTimestamp = this.endEvent?.getTs() || Number.MAX_SAFE_INTEGER;\n const { responseEvents } = filterResponseRelations([event], pollEndTimestamp);\n\n this.countUndecryptableEvents([event]);\n\n if (responseEvents.length) {\n responseEvents.forEach((event) => {\n this.responses!.addEvent(event);\n });\n\n this.emit(PollEvent.Responses, this.responses);\n }\n }\n\n private async fetchResponses(): Promise<void> {\n this._isFetchingResponses = true;\n\n // we want:\n // - stable and unstable M_POLL_RESPONSE\n // - stable and unstable M_POLL_END\n // so make one api call and filter by event type client side\n const allRelations = await this.matrixClient.relations(\n this.roomId,\n this.rootEvent.getId()!,\n \"m.reference\",\n undefined,\n {\n from: this.relationsNextBatch || undefined,\n },\n );\n\n const responses =\n this.responses ||\n new Relations(\"m.reference\", M_POLL_RESPONSE.name, this.matrixClient, [M_POLL_RESPONSE.altName!]);\n\n const pollEndEvent = allRelations.events.find((event) => M_POLL_END.matches(event.getType()));\n\n if (this.validateEndEvent(pollEndEvent)) {\n this.endEvent = pollEndEvent;\n this.refilterResponsesOnEnd();\n this.emit(PollEvent.End);\n }\n\n const pollCloseTimestamp = this.endEvent?.getTs() || Number.MAX_SAFE_INTEGER;\n\n const { responseEvents } = filterResponseRelations(allRelations.events, pollCloseTimestamp);\n\n responseEvents.forEach((event) => {\n responses.addEvent(event);\n });\n\n this.relationsNextBatch = allRelations.nextBatch ?? undefined;\n this.responses = responses;\n this.countUndecryptableEvents(allRelations.events);\n\n // while there are more pages of relations\n // fetch them\n if (this.relationsNextBatch) {\n // don't await\n // we want to return the first page as soon as possible\n this.fetchResponses();\n } else {\n // no more pages\n this._isFetchingResponses = false;\n }\n\n // emit after updating _isFetchingResponses state\n this.emit(PollEvent.Responses, this.responses);\n }\n\n /**\n * Only responses made before the poll ended are valid\n * Refilter after an end event is recieved\n * To ensure responses are valid\n */\n private refilterResponsesOnEnd(): void {\n if (!this.responses) {\n return;\n }\n\n const pollEndTimestamp = this.endEvent?.getTs() || Number.MAX_SAFE_INTEGER;\n this.responses.getRelations().forEach((event) => {\n if (event.getTs() > pollEndTimestamp) {\n this.responses?.removeEvent(event);\n }\n });\n\n this.emit(PollEvent.Responses, this.responses);\n }\n\n private countUndecryptableEvents = (events: MatrixEvent[]): void => {\n const undecryptableEventIds = events\n .map((event) => event.getId()!);\n\n const previousCount = this.undecryptableRelationsCount;\n this.undecryptableRelationEventIds = new Set([...this.undecryptableRelationEventIds, ...undecryptableEventIds]);\n\n if (this.undecryptableRelationsCount !== previousCount) {\n this.emit(PollEvent.UndecryptableRelations, this.undecryptableRelationsCount);\n }\n };\n\n private validateEndEvent(endEvent?: MatrixEvent): boolean {\n if (!endEvent) {\n return false;\n }\n /**\n * Repeated end events are ignored -\n * only the first (valid) closure event by origin_server_ts is counted.\n */\n if (this.endEvent && this.endEvent.getTs() < endEvent.getTs()) {\n return false;\n }\n\n /**\n * MSC3381\n * If a m.poll.end event is received from someone other than the poll creator or user with permission to redact\n * others' messages in the room, the event must be ignored by clients due to being invalid.\n */\n const roomCurrentState = this.room.currentState;\n const endEventSender = endEvent.getSender();\n return (\n !!endEventSender &&\n (endEventSender === this.rootEvent.getSender() ||\n roomCurrentState.maySendRedactionForEvent(this.rootEvent, endEventSender))\n );\n }\n}\n\n/**\n * Tests whether the event is a start, response or end poll event.\n *\n * @param event - Event to test\n * @returns true if the event is a poll event, else false\n */\nexport const isPollEvent = (event: MatrixEvent): boolean => {\n const eventType = event.getType();\n return M_POLL_START.matches(eventType) || M_POLL_RESPONSE.matches(eventType) || M_POLL_END.matches(eventType);\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CAACZ,QAAsB,EAAW;IACtD,IAAI,CAACA,QAAQ,EAAE;MACX,OAAO,KAAK;IAChB;IACA;AACR;AACA;AACA;IACQ,IAAI,IAAI,CAACA,QAAQ,IAAI,IAAI,CAACA,QAAQ,CAACzB,KAAK,CAAC,CAAC,GAAGyB,QAAQ,CAACzB,KAAK,CAAC,CAAC,EAAE;MAC3D,OAAO,KAAK;IAChB;;IAEA;AACR;AACA;AACA;AACA;IACQ,IAAMiE,gBAAgB,GAAG,IAAI,CAAC5D,IAAI,CAAC6D,YAAY;IAC/C,IAAMC,cAAc,GAAG1C,QAAQ,CAAC2C,SAAS,CAAC,CAAC;IAC3C,OACI,CAAC,CAACD,cAAc,KACfA,cAAc,KAAK,IAAI,CAAChE,SAAS,CAACiE,SAAS,CAAC,CAAC,IAC1CH,gBAAgB,CAACI,wBAAwB,CAAC,IAAI,CAAClE,SAAS,EAAEgE,cAAc,CAAC,CAAC;EAEtF;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMG,WAAW,GAAIzE,KAAkB,IAAc;EACxD,IAAM0E,SAAS,GAAG1E,KAAK,CAACE,OAAO,CAAC,CAAC;EACjC,OAAOb,YAAY,CAACY,OAAO,CAACyE,SAAS,CAAC,IAAInF,eAAe,CAACU,OAAO,CAACyE,SAAS,CAAC,IAAIpF,UAAU,CAACW,OAAO,CAACyE,SAAS,CAAC;AACjH,CAAC","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"relations-container.d.ts","sourceRoot":"","sources":["../../src/models/relations-container.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAe,WAAW,EAAoB,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAA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B,IAAI,CAAC,EAAE,IAAI,YAAA;IAGhC;;;;;;;;;;;;;OAaG;IACI,sBAAsB,CACzB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,YAAY,GAAG,MAAM,EACnC,SAAS,EAAE,SAAS,GAAG,MAAM,GAC9B,SAAS,GAAG,SAAS;IAIjB,yBAAyB,CAAC,aAAa,EAAE,MAAM,GAAG,WAAW,EAAE;IAYtE;;;;;;OAMG;IACI,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAWrD;;;;;OAKG;IACI,mBAAmB,CAAC,KAAK,EAAE,WAAW,EAAE,WAAW,CAAC,EAAE,gBAAgB,GAAG,IAAI;CAkDvF"}
|
@@ -86,17 +86,11 @@ export class RelationsContainer {
|
|
86
86
|
var relation = event.getRelation();
|
87
87
|
if (!relation) return;
|
88
88
|
var onEventDecrypted = () => {
|
89
|
-
if (event.isDecryptionFailure()) {
|
90
|
-
// This could for example happen if the encryption keys are not yet available.
|
91
|
-
// The event may still be decrypted later. Register the listener again.
|
92
|
-
event.once(MatrixEventEvent.Decrypted, onEventDecrypted);
|
93
|
-
return;
|
94
|
-
}
|
95
89
|
this.aggregateChildEvent(event, timelineSet);
|
96
90
|
};
|
97
91
|
|
98
92
|
// If the event is currently encrypted, wait until it has been decrypted.
|
99
|
-
if (event.
|
93
|
+
if (event.shouldAttemptDecryption()) {
|
100
94
|
event.once(MatrixEventEvent.Decrypted, onEventDecrypted);
|
101
95
|
return;
|
102
96
|
}
|