@unwanted/matrix-sdk-mini 34.12.0-2 → 34.12.0-4
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/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 -1221
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +331 -2821
- 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 -166
- 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 -19
- package/lib/matrix.d.ts.map +1 -1
- package/lib/matrix.js +1 -26
- 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/lib/types.d.ts +0 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +1 -3
- package/src/@types/global.d.ts +0 -3
- package/src/browser-index.ts +0 -11
- package/src/client.ts +60 -2882
- package/src/embedded.ts +3 -130
- package/src/event-mapper.ts +0 -4
- package/src/matrix.ts +0 -28
- 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/src/types.ts +0 -1
- package/CHANGELOG.md +0 -5910
- package/lib/@types/AESEncryptedSecretStoragePayload.d.ts +0 -14
- package/lib/@types/AESEncryptedSecretStoragePayload.d.ts.map +0 -1
- package/lib/@types/AESEncryptedSecretStoragePayload.js +0 -1
- package/lib/@types/AESEncryptedSecretStoragePayload.js.map +0 -1
- package/lib/@types/crypto.d.ts +0 -47
- package/lib/@types/crypto.d.ts.map +0 -1
- package/lib/@types/crypto.js +0 -1
- package/lib/@types/crypto.js.map +0 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js +0 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js.map +0 -1
- package/lib/common-crypto/CryptoBackend.d.ts +0 -240
- package/lib/common-crypto/CryptoBackend.d.ts.map +0 -1
- package/lib/common-crypto/CryptoBackend.js +0 -73
- package/lib/common-crypto/CryptoBackend.js.map +0 -1
- package/lib/common-crypto/key-passphrase.d.ts +0 -14
- package/lib/common-crypto/key-passphrase.d.ts.map +0 -1
- package/lib/common-crypto/key-passphrase.js +0 -33
- package/lib/common-crypto/key-passphrase.js.map +0 -1
- package/lib/crypto/CrossSigning.d.ts +0 -184
- package/lib/crypto/CrossSigning.d.ts.map +0 -1
- package/lib/crypto/CrossSigning.js +0 -718
- package/lib/crypto/CrossSigning.js.map +0 -1
- package/lib/crypto/DeviceList.d.ts +0 -216
- package/lib/crypto/DeviceList.d.ts.map +0 -1
- package/lib/crypto/DeviceList.js +0 -892
- package/lib/crypto/DeviceList.js.map +0 -1
- package/lib/crypto/EncryptionSetup.d.ts +0 -152
- package/lib/crypto/EncryptionSetup.d.ts.map +0 -1
- package/lib/crypto/EncryptionSetup.js +0 -356
- package/lib/crypto/EncryptionSetup.js.map +0 -1
- package/lib/crypto/OlmDevice.d.ts +0 -457
- package/lib/crypto/OlmDevice.d.ts.map +0 -1
- package/lib/crypto/OlmDevice.js +0 -1241
- package/lib/crypto/OlmDevice.js.map +0 -1
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts +0 -109
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts.map +0 -1
- package/lib/crypto/OutgoingRoomKeyRequestManager.js +0 -415
- package/lib/crypto/OutgoingRoomKeyRequestManager.js.map +0 -1
- package/lib/crypto/RoomList.d.ts +0 -26
- package/lib/crypto/RoomList.d.ts.map +0 -1
- package/lib/crypto/RoomList.js +0 -71
- package/lib/crypto/RoomList.js.map +0 -1
- package/lib/crypto/SecretSharing.d.ts +0 -24
- package/lib/crypto/SecretSharing.d.ts.map +0 -1
- package/lib/crypto/SecretSharing.js +0 -194
- package/lib/crypto/SecretSharing.js.map +0 -1
- package/lib/crypto/SecretStorage.d.ts +0 -55
- package/lib/crypto/SecretStorage.d.ts.map +0 -1
- package/lib/crypto/SecretStorage.js +0 -118
- package/lib/crypto/SecretStorage.js.map +0 -1
- package/lib/crypto/aes.d.ts +0 -6
- package/lib/crypto/aes.d.ts.map +0 -1
- package/lib/crypto/aes.js +0 -24
- package/lib/crypto/aes.js.map +0 -1
- package/lib/crypto/algorithms/base.d.ts +0 -156
- package/lib/crypto/algorithms/base.d.ts.map +0 -1
- package/lib/crypto/algorithms/base.js +0 -187
- package/lib/crypto/algorithms/base.js.map +0 -1
- package/lib/crypto/algorithms/index.d.ts +0 -4
- package/lib/crypto/algorithms/index.d.ts.map +0 -1
- package/lib/crypto/algorithms/index.js +0 -20
- package/lib/crypto/algorithms/index.js.map +0 -1
- package/lib/crypto/algorithms/megolm.d.ts +0 -385
- package/lib/crypto/algorithms/megolm.d.ts.map +0 -1
- package/lib/crypto/algorithms/megolm.js +0 -1822
- package/lib/crypto/algorithms/megolm.js.map +0 -1
- package/lib/crypto/algorithms/olm.d.ts +0 -5
- package/lib/crypto/algorithms/olm.d.ts.map +0 -1
- package/lib/crypto/algorithms/olm.js +0 -299
- package/lib/crypto/algorithms/olm.js.map +0 -1
- package/lib/crypto/api.d.ts +0 -32
- package/lib/crypto/api.d.ts.map +0 -1
- package/lib/crypto/api.js +0 -22
- package/lib/crypto/api.js.map +0 -1
- package/lib/crypto/backup.d.ts +0 -227
- package/lib/crypto/backup.d.ts.map +0 -1
- package/lib/crypto/backup.js +0 -824
- package/lib/crypto/backup.js.map +0 -1
- package/lib/crypto/crypto.d.ts +0 -3
- package/lib/crypto/crypto.d.ts.map +0 -1
- package/lib/crypto/crypto.js +0 -19
- package/lib/crypto/crypto.js.map +0 -1
- package/lib/crypto/dehydration.d.ts +0 -34
- package/lib/crypto/dehydration.d.ts.map +0 -1
- package/lib/crypto/dehydration.js +0 -252
- package/lib/crypto/dehydration.js.map +0 -1
- package/lib/crypto/device-converter.d.ts +0 -9
- package/lib/crypto/device-converter.d.ts.map +0 -1
- package/lib/crypto/device-converter.js +0 -42
- package/lib/crypto/device-converter.js.map +0 -1
- package/lib/crypto/deviceinfo.d.ts +0 -99
- package/lib/crypto/deviceinfo.d.ts.map +0 -1
- package/lib/crypto/deviceinfo.js +0 -148
- package/lib/crypto/deviceinfo.js.map +0 -1
- package/lib/crypto/index.d.ts +0 -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/rendezvous/MSC4108SignInWithQR.d.ts +0 -112
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts.map +0 -1
- package/lib/rendezvous/MSC4108SignInWithQR.js +0 -392
- package/lib/rendezvous/MSC4108SignInWithQR.js.map +0 -1
- package/lib/rendezvous/RendezvousChannel.d.ts +0 -27
- package/lib/rendezvous/RendezvousChannel.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousChannel.js +0 -1
- package/lib/rendezvous/RendezvousChannel.js.map +0 -1
- package/lib/rendezvous/RendezvousCode.d.ts +0 -9
- package/lib/rendezvous/RendezvousCode.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousCode.js +0 -1
- package/lib/rendezvous/RendezvousCode.js.map +0 -1
- package/lib/rendezvous/RendezvousError.d.ts +0 -6
- package/lib/rendezvous/RendezvousError.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousError.js +0 -23
- package/lib/rendezvous/RendezvousError.js.map +0 -1
- package/lib/rendezvous/RendezvousFailureReason.d.ts +0 -31
- package/lib/rendezvous/RendezvousFailureReason.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousFailureReason.js +0 -38
- package/lib/rendezvous/RendezvousFailureReason.js.map +0 -1
- package/lib/rendezvous/RendezvousIntent.d.ts +0 -5
- package/lib/rendezvous/RendezvousIntent.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousIntent.js +0 -22
- package/lib/rendezvous/RendezvousIntent.js.map +0 -1
- package/lib/rendezvous/RendezvousTransport.d.ts +0 -36
- package/lib/rendezvous/RendezvousTransport.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousTransport.js +0 -1
- package/lib/rendezvous/RendezvousTransport.js.map +0 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts +0 -58
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts.map +0 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.js +0 -246
- package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +0 -1
- package/lib/rendezvous/channels/index.d.ts +0 -2
- package/lib/rendezvous/channels/index.d.ts.map +0 -1
- package/lib/rendezvous/channels/index.js +0 -18
- package/lib/rendezvous/channels/index.js.map +0 -1
- package/lib/rendezvous/index.d.ts +0 -10
- package/lib/rendezvous/index.d.ts.map +0 -1
- package/lib/rendezvous/index.js +0 -23
- package/lib/rendezvous/index.js.map +0 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +0 -61
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts.map +0 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js +0 -253
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +0 -1
- package/lib/rendezvous/transports/index.d.ts +0 -2
- package/lib/rendezvous/transports/index.d.ts.map +0 -1
- package/lib/rendezvous/transports/index.js +0 -18
- package/lib/rendezvous/transports/index.js.map +0 -1
- package/lib/rust-crypto/CrossSigningIdentity.d.ts +0 -33
- package/lib/rust-crypto/CrossSigningIdentity.d.ts.map +0 -1
- package/lib/rust-crypto/CrossSigningIdentity.js +0 -157
- package/lib/rust-crypto/CrossSigningIdentity.js.map +0 -1
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts +0 -98
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts.map +0 -1
- package/lib/rust-crypto/DehydratedDeviceManager.js +0 -285
- package/lib/rust-crypto/DehydratedDeviceManager.js.map +0 -1
- package/lib/rust-crypto/KeyClaimManager.d.ts +0 -33
- package/lib/rust-crypto/KeyClaimManager.d.ts.map +0 -1
- package/lib/rust-crypto/KeyClaimManager.js +0 -82
- package/lib/rust-crypto/KeyClaimManager.js.map +0 -1
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts +0 -43
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts.map +0 -1
- package/lib/rust-crypto/OutgoingRequestProcessor.js +0 -195
- package/lib/rust-crypto/OutgoingRequestProcessor.js.map +0 -1
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts +0 -47
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts.map +0 -1
- package/lib/rust-crypto/OutgoingRequestsManager.js +0 -148
- package/lib/rust-crypto/OutgoingRequestsManager.js.map +0 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +0 -120
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts.map +0 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +0 -467
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +0 -1
- package/lib/rust-crypto/RoomEncryptor.d.ts +0 -98
- package/lib/rust-crypto/RoomEncryptor.d.ts.map +0 -1
- package/lib/rust-crypto/RoomEncryptor.js +0 -299
- package/lib/rust-crypto/RoomEncryptor.js.map +0 -1
- package/lib/rust-crypto/backup.d.ts +0 -254
- package/lib/rust-crypto/backup.d.ts.map +0 -1
- package/lib/rust-crypto/backup.js +0 -837
- package/lib/rust-crypto/backup.js.map +0 -1
- package/lib/rust-crypto/constants.d.ts +0 -3
- package/lib/rust-crypto/constants.d.ts.map +0 -1
- package/lib/rust-crypto/constants.js +0 -19
- package/lib/rust-crypto/constants.js.map +0 -1
- package/lib/rust-crypto/device-converter.d.ts +0 -28
- package/lib/rust-crypto/device-converter.d.ts.map +0 -1
- package/lib/rust-crypto/device-converter.js +0 -123
- package/lib/rust-crypto/device-converter.js.map +0 -1
- package/lib/rust-crypto/index.d.ts +0 -61
- package/lib/rust-crypto/index.d.ts.map +0 -1
- package/lib/rust-crypto/index.js +0 -152
- package/lib/rust-crypto/index.js.map +0 -1
- package/lib/rust-crypto/libolm_migration.d.ts +0 -81
- package/lib/rust-crypto/libolm_migration.d.ts.map +0 -1
- package/lib/rust-crypto/libolm_migration.js +0 -459
- package/lib/rust-crypto/libolm_migration.js.map +0 -1
- package/lib/rust-crypto/rust-crypto.d.ts +0 -556
- package/lib/rust-crypto/rust-crypto.d.ts.map +0 -1
- package/lib/rust-crypto/rust-crypto.js +0 -2016
- package/lib/rust-crypto/rust-crypto.js.map +0 -1
- package/lib/rust-crypto/secret-storage.d.ts +0 -22
- package/lib/rust-crypto/secret-storage.d.ts.map +0 -1
- package/lib/rust-crypto/secret-storage.js +0 -63
- package/lib/rust-crypto/secret-storage.js.map +0 -1
- package/lib/rust-crypto/verification.d.ts +0 -319
- package/lib/rust-crypto/verification.d.ts.map +0 -1
- package/lib/rust-crypto/verification.js +0 -816
- package/lib/rust-crypto/verification.js.map +0 -1
- package/lib/secret-storage.d.ts +0 -370
- package/lib/secret-storage.d.ts.map +0 -1
- package/lib/secret-storage.js +0 -466
- package/lib/secret-storage.js.map +0 -1
- package/lib/utils/decryptAESSecretStorageItem.d.ts +0 -12
- package/lib/utils/decryptAESSecretStorageItem.d.ts.map +0 -1
- package/lib/utils/decryptAESSecretStorageItem.js +0 -50
- package/lib/utils/decryptAESSecretStorageItem.js.map +0 -1
- package/lib/utils/encryptAESSecretStorageItem.d.ts +0 -16
- package/lib/utils/encryptAESSecretStorageItem.d.ts.map +0 -1
- package/lib/utils/encryptAESSecretStorageItem.js +0 -68
- package/lib/utils/encryptAESSecretStorageItem.js.map +0 -1
- package/lib/utils/internal/deriveKeys.d.ts +0 -10
- package/lib/utils/internal/deriveKeys.d.ts.map +0 -1
- package/lib/utils/internal/deriveKeys.js +0 -60
- package/lib/utils/internal/deriveKeys.js.map +0 -1
- package/src/@types/AESEncryptedSecretStoragePayload.ts +0 -29
- package/src/@types/crypto.ts +0 -73
- package/src/@types/matrix-sdk-crypto-wasm.d.ts +0 -44
- package/src/common-crypto/CryptoBackend.ts +0 -302
- package/src/common-crypto/README.md +0 -4
- package/src/common-crypto/key-passphrase.ts +0 -43
- package/src/crypto/CrossSigning.ts +0 -773
- package/src/crypto/DeviceList.ts +0 -989
- package/src/crypto/EncryptionSetup.ts +0 -351
- package/src/crypto/OlmDevice.ts +0 -1500
- package/src/crypto/OutgoingRoomKeyRequestManager.ts +0 -485
- package/src/crypto/RoomList.ts +0 -70
- package/src/crypto/SecretSharing.ts +0 -240
- package/src/crypto/SecretStorage.ts +0 -136
- package/src/crypto/aes.ts +0 -23
- package/src/crypto/algorithms/base.ts +0 -236
- package/src/crypto/algorithms/index.ts +0 -20
- package/src/crypto/algorithms/megolm.ts +0 -2216
- package/src/crypto/algorithms/olm.ts +0 -381
- package/src/crypto/api.ts +0 -70
- package/src/crypto/backup.ts +0 -922
- package/src/crypto/crypto.ts +0 -18
- package/src/crypto/dehydration.ts +0 -272
- package/src/crypto/device-converter.ts +0 -45
- package/src/crypto/deviceinfo.ts +0 -158
- package/src/crypto/index.ts +0 -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/rendezvous/MSC4108SignInWithQR.ts +0 -444
- package/src/rendezvous/RendezvousChannel.ts +0 -48
- package/src/rendezvous/RendezvousCode.ts +0 -25
- package/src/rendezvous/RendezvousError.ts +0 -26
- package/src/rendezvous/RendezvousFailureReason.ts +0 -49
- package/src/rendezvous/RendezvousIntent.ts +0 -20
- package/src/rendezvous/RendezvousTransport.ts +0 -58
- package/src/rendezvous/channels/MSC4108SecureChannel.ts +0 -270
- package/src/rendezvous/channels/index.ts +0 -17
- package/src/rendezvous/index.ts +0 -25
- package/src/rendezvous/transports/MSC4108RendezvousSession.ts +0 -270
- package/src/rendezvous/transports/index.ts +0 -17
- package/src/rust-crypto/CrossSigningIdentity.ts +0 -183
- package/src/rust-crypto/DehydratedDeviceManager.ts +0 -306
- package/src/rust-crypto/KeyClaimManager.ts +0 -86
- package/src/rust-crypto/OutgoingRequestProcessor.ts +0 -236
- package/src/rust-crypto/OutgoingRequestsManager.ts +0 -143
- package/src/rust-crypto/PerSessionKeyBackupDownloader.ts +0 -501
- package/src/rust-crypto/RoomEncryptor.ts +0 -352
- package/src/rust-crypto/backup.ts +0 -881
- package/src/rust-crypto/constants.ts +0 -18
- package/src/rust-crypto/device-converter.ts +0 -128
- package/src/rust-crypto/index.ts +0 -237
- package/src/rust-crypto/libolm_migration.ts +0 -530
- package/src/rust-crypto/rust-crypto.ts +0 -2205
- package/src/rust-crypto/secret-storage.ts +0 -60
- package/src/rust-crypto/verification.ts +0 -830
- package/src/secret-storage.ts +0 -693
- package/src/utils/decryptAESSecretStorageItem.ts +0 -54
- package/src/utils/encryptAESSecretStorageItem.ts +0 -73
- package/src/utils/internal/deriveKeys.ts +0 -63
package/lib/embedded.d.ts
CHANGED
@@ -1,13 +1,10 @@
|
|
1
1
|
import { WidgetApi } from "matrix-widget-api";
|
2
|
-
import { MatrixEvent } from "./models/event.ts";
|
3
2
|
import { ISendEventResponse, SendDelayedEventRequestOpts, SendDelayedEventResponse, UpdateDelayedEventAction } from "./@types/requests.ts";
|
4
3
|
import { StateEvents } from "./@types/event.ts";
|
5
4
|
import { MatrixClient, IMatrixClientCreateOpts, IStartClientOpts, SendToDeviceContentMap, IOpenIDToken } from "./client.ts";
|
6
5
|
import { SyncState } from "./sync.ts";
|
7
6
|
import { Room } from "./models/room.ts";
|
8
7
|
import { ToDeviceBatch } from "./models/ToDeviceMessage.ts";
|
9
|
-
import { DeviceInfo } from "./crypto/deviceinfo.ts";
|
10
|
-
import { IOlmDevice } from "./crypto/algorithms/megolm.ts";
|
11
8
|
interface IStateEventRequest {
|
12
9
|
eventType: string;
|
13
10
|
stateKey?: string;
|
@@ -100,8 +97,6 @@ export declare class RoomWidgetClient extends MatrixClient {
|
|
100
97
|
startClient(opts?: IStartClientOpts): Promise<void>;
|
101
98
|
stopClient(): void;
|
102
99
|
joinRoom(roomIdOrAlias: string): Promise<Room>;
|
103
|
-
protected encryptAndSendEvent(room: Room, event: MatrixEvent): Promise<ISendEventResponse>;
|
104
|
-
protected encryptAndSendEvent(room: Room, event: MatrixEvent, delayOpts: SendDelayedEventRequestOpts): Promise<SendDelayedEventResponse>;
|
105
100
|
sendStateEvent(roomId: string, eventType: string, content: any, stateKey?: string): Promise<ISendEventResponse>;
|
106
101
|
/**
|
107
102
|
* @experimental This currently relies on an unstable MSC (MSC4140).
|
@@ -115,29 +110,12 @@ export declare class RoomWidgetClient extends MatrixClient {
|
|
115
110
|
sendToDevice(eventType: string, contentMap: SendToDeviceContentMap): Promise<{}>;
|
116
111
|
getOpenIdToken(): Promise<IOpenIDToken>;
|
117
112
|
queueToDevice({ eventType, batch }: ToDeviceBatch): Promise<void>;
|
118
|
-
encryptAndSendToDevices(userDeviceInfoArr: IOlmDevice<DeviceInfo>[], payload: object): Promise<void>;
|
119
|
-
/**
|
120
|
-
* Send an event to a specific list of devices via the widget API. Optionally encrypts the event.
|
121
|
-
*
|
122
|
-
* If you are using a full MatrixClient you would be calling {@link MatrixClient.getCrypto().encryptToDeviceMessages()} followed
|
123
|
-
* by {@link MatrixClient.queueToDevice}.
|
124
|
-
*
|
125
|
-
* However, this is combined into a single step when running as an embedded widget client. So, we expose this method for those
|
126
|
-
* that need it.
|
127
|
-
*
|
128
|
-
* @param eventType - Type of the event to send.
|
129
|
-
* @param encrypted - Whether the event should be encrypted.
|
130
|
-
* @param contentMap - The content to send. Map from user_id to device_id to content object.
|
131
|
-
*/
|
132
|
-
sendToDeviceViaWidgetApi(eventType: string, encrypted: boolean, contentMap: SendToDeviceContentMap): Promise<void>;
|
133
|
-
checkTurnServers(): Promise<boolean>;
|
134
113
|
getSyncState(): SyncState | null;
|
135
114
|
private setSyncState;
|
136
115
|
private ack;
|
137
116
|
private updateTxId;
|
138
117
|
private onEvent;
|
139
118
|
private onToDevice;
|
140
|
-
private watchTurnServers;
|
141
119
|
}
|
142
120
|
export {};
|
143
121
|
//# sourceMappingURL=embedded.d.ts.map
|
package/lib/embedded.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"embedded.d.ts","sourceRoot":"","sources":["../src/embedded.ts"],"names":[],"mappings":"AAgBA,OAAO,EACH,SAAS,EAaZ,MAAM,mBAAmB,CAAC;
|
1
|
+
{"version":3,"file":"embedded.d.ts","sourceRoot":"","sources":["../src/embedded.ts"],"names":[],"mappings":"AAgBA,OAAO,EACH,SAAS,EAaZ,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACH,kBAAkB,EAClB,2BAA2B,EAC3B,wBAAwB,EACxB,wBAAwB,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACH,YAAY,EAEZ,uBAAuB,EACvB,gBAAgB,EAChB,sBAAsB,EACtB,YAAY,EAEf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAW,SAAS,EAAE,MAAM,WAAW,CAA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AI,SAAS,GAAG,IAAI;IAIvC,OAAO,CAAC,YAAY;YAMN,GAAG;IAIjB,OAAO,CAAC,UAAU,CAwChB;IAEF,OAAO,CAAC,OAAO,CAoBb;IAEF,OAAO,CAAC,UAAU,CAYhB;CACL"}
|
package/lib/embedded.js
CHANGED
@@ -2,8 +2,6 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
4
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
5
|
-
function _asyncIterator(r) { var n, t, o, e = 2; for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) { if (t && null != (n = r[t])) return n.call(r); if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r)); t = "@@asyncIterator", o = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
|
6
|
-
function AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var n = r.done; return Promise.resolve(r.value).then(function (r) { return { value: r, done: n }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(r) { this.s = r, this.n = r.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, return: function _return(r) { var n = this.s.return; return void 0 === n ? Promise.resolve({ value: r, done: !0 }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); }, throw: function _throw(r) { var n = this.s.return; return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(r); }
|
7
5
|
/*
|
8
6
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
9
7
|
|
@@ -21,8 +19,7 @@ limitations under the License.
|
|
21
19
|
*/
|
22
20
|
|
23
21
|
import { WidgetApiToWidgetAction, WidgetApiResponseError, MatrixCapabilities } from "matrix-widget-api";
|
24
|
-
import { MatrixEvent
|
25
|
-
import { EventType } from "./@types/event.js";
|
22
|
+
import { MatrixEvent } from "./models/event.js";
|
26
23
|
import { logger } from "./logger.js";
|
27
24
|
import { MatrixClient, ClientEvent, UNSTABLE_MSC4140_DELAYED_EVENTS } from "./client.js";
|
28
25
|
import { SyncApi, SyncState } from "./sync.js";
|
@@ -118,14 +115,14 @@ export class RoomWidgetClient extends MatrixClient {
|
|
118
115
|
// Verify the room ID matches, since it's possible for the client to
|
119
116
|
// send us events from other rooms if this widget is always on screen
|
120
117
|
if (ev.detail.data.room_id === _this.roomId) {
|
121
|
-
var
|
118
|
+
var event = new MatrixEvent(ev.detail.data);
|
122
119
|
|
123
120
|
// Only inject once we have update the txId
|
124
|
-
yield _this.updateTxId(
|
125
|
-
yield _this.syncApi.injectRoomEvents(_this.room, [], [
|
126
|
-
_this.emit(ClientEvent.Event,
|
121
|
+
yield _this.updateTxId(event);
|
122
|
+
yield _this.syncApi.injectRoomEvents(_this.room, [], [event]);
|
123
|
+
_this.emit(ClientEvent.Event, event);
|
127
124
|
_this.setSyncState(SyncState.Syncing);
|
128
|
-
logger.info("Received event ".concat(
|
125
|
+
logger.info("Received event ".concat(event.getId(), " ").concat(event.getType(), " ").concat(event.getStateKey()));
|
129
126
|
} else {
|
130
127
|
var {
|
131
128
|
event_id: eventId,
|
@@ -147,8 +144,6 @@ export class RoomWidgetClient extends MatrixClient {
|
|
147
144
|
sender: ev.detail.data.sender,
|
148
145
|
content: ev.detail.data.content
|
149
146
|
});
|
150
|
-
// Mark the event as encrypted if it was, using fake contents and keys since those are unknown to us
|
151
|
-
if (ev.detail.data.encrypted) event.makeEncrypted(EventType.RoomMessageEncrypted, {}, "", "");
|
152
147
|
_this.emit(ClientEvent.ToDeviceEvent, event);
|
153
148
|
_this.setSyncState(SyncState.Syncing);
|
154
149
|
yield _this.ack(ev);
|
@@ -257,7 +252,7 @@ export class RoomWidgetClient extends MatrixClient {
|
|
257
252
|
// still has some valuable helper methods that we make use of, so we
|
258
253
|
// instantiate it anyways
|
259
254
|
if (opts.slidingSync) {
|
260
|
-
_this2.syncApi = new SlidingSyncSdk(opts.slidingSync, _this2, opts
|
255
|
+
_this2.syncApi = new SlidingSyncSdk(opts.slidingSync, _this2, opts);
|
261
256
|
} else {
|
262
257
|
_this2.syncApi = new SyncApi(_this2, opts, _this2.buildSyncApiOptions());
|
263
258
|
}
|
@@ -294,9 +289,6 @@ export class RoomWidgetClient extends MatrixClient {
|
|
294
289
|
}
|
295
290
|
_this2.setSyncState(SyncState.Syncing);
|
296
291
|
logger.info("Finished backfilling events");
|
297
|
-
|
298
|
-
// Watch for TURN servers, if requested
|
299
|
-
if (_this2.capabilities.turnServers) _this2.watchTurnServers();
|
300
292
|
})();
|
301
293
|
}
|
302
294
|
stopClient() {
|
@@ -312,55 +304,12 @@ export class RoomWidgetClient extends MatrixClient {
|
|
312
304
|
throw new Error("Unknown room: ".concat(roomIdOrAlias));
|
313
305
|
})();
|
314
306
|
}
|
315
|
-
encryptAndSendEvent(room, event, delayOpts) {
|
316
|
-
var _this4 = this;
|
317
|
-
return _asyncToGenerator(function* () {
|
318
|
-
// We need to extend the content with the redacts parameter
|
319
|
-
// The js sdk uses event.redacts but the widget api uses event.content.redacts
|
320
|
-
// This will be converted back to event.redacts in the widget driver.
|
321
|
-
var content = event.event.redacts ? _objectSpread(_objectSpread({}, event.getContent()), {}, {
|
322
|
-
redacts: event.event.redacts
|
323
|
-
}) : event.getContent();
|
324
|
-
|
325
|
-
// Delayed event special case.
|
326
|
-
if (delayOpts) {
|
327
|
-
// TODO: updatePendingEvent for delayed events?
|
328
|
-
var _response = yield _this4.widgetApi.sendRoomEvent(event.getType(), content, room.roomId, "delay" in delayOpts ? delayOpts.delay : undefined, "parent_delay_id" in delayOpts ? delayOpts.parent_delay_id : undefined);
|
329
|
-
return _this4.validateSendDelayedEventResponse(_response);
|
330
|
-
}
|
331
|
-
var txId = event.getTxnId();
|
332
|
-
// Add the txnId to the pending list (still with unknown evID)
|
333
|
-
if (txId) _this4.pendingSendingEventsTxId.push({
|
334
|
-
type: event.getType(),
|
335
|
-
id: undefined,
|
336
|
-
txId
|
337
|
-
});
|
338
|
-
var response;
|
339
|
-
try {
|
340
|
-
response = yield _this4.widgetApi.sendRoomEvent(event.getType(), content, room.roomId);
|
341
|
-
} catch (e) {
|
342
|
-
_this4.updatePendingEventStatus(room, event, EventStatus.NOT_SENT);
|
343
|
-
throw e;
|
344
|
-
}
|
345
|
-
// This also checks for an event id on the response
|
346
|
-
room.updatePendingEvent(event, EventStatus.SENT, response.event_id);
|
347
|
-
|
348
|
-
// Update the pending events list with the eventId
|
349
|
-
_this4.pendingSendingEventsTxId.forEach(p => {
|
350
|
-
if (p.txId === txId) p.id = response.event_id;
|
351
|
-
});
|
352
|
-
_this4.eventEmitter.emit(RoomWidgetClientEvent.PendingEventsChanged);
|
353
|
-
return {
|
354
|
-
event_id: response.event_id
|
355
|
-
};
|
356
|
-
})();
|
357
|
-
}
|
358
307
|
sendStateEvent(roomId, eventType, content) {
|
359
308
|
var _arguments2 = arguments,
|
360
|
-
|
309
|
+
_this4 = this;
|
361
310
|
return _asyncToGenerator(function* () {
|
362
311
|
var stateKey = _arguments2.length > 3 && _arguments2[3] !== undefined ? _arguments2[3] : "";
|
363
|
-
var response = yield
|
312
|
+
var response = yield _this4.widgetApi.sendStateEvent(eventType, stateKey, content, roomId);
|
364
313
|
if (response.event_id === undefined) {
|
365
314
|
throw new Error("'event_id' absent from response to an event request");
|
366
315
|
}
|
@@ -376,14 +325,14 @@ export class RoomWidgetClient extends MatrixClient {
|
|
376
325
|
// eslint-disable-next-line
|
377
326
|
_unstable_sendDelayedStateEvent(roomId, delayOpts, eventType, content) {
|
378
327
|
var _arguments3 = arguments,
|
379
|
-
|
328
|
+
_this5 = this;
|
380
329
|
return _asyncToGenerator(function* () {
|
381
330
|
var stateKey = _arguments3.length > 4 && _arguments3[4] !== undefined ? _arguments3[4] : "";
|
382
|
-
if (!(yield
|
331
|
+
if (!(yield _this5.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
|
383
332
|
throw Error("Server does not support the delayed events API");
|
384
333
|
}
|
385
|
-
var response = yield
|
386
|
-
return
|
334
|
+
var response = yield _this5.widgetApi.sendStateEvent(eventType, stateKey, content, roomId, "delay" in delayOpts ? delayOpts.delay : undefined, "parent_delay_id" in delayOpts ? delayOpts.parent_delay_id : undefined);
|
335
|
+
return _this5.validateSendDelayedEventResponse(response);
|
387
336
|
})();
|
388
337
|
}
|
389
338
|
validateSendDelayedEventResponse(response) {
|
@@ -400,25 +349,25 @@ export class RoomWidgetClient extends MatrixClient {
|
|
400
349
|
*/
|
401
350
|
// eslint-disable-next-line
|
402
351
|
_unstable_updateDelayedEvent(delayId, action) {
|
403
|
-
var
|
352
|
+
var _this6 = this;
|
404
353
|
return _asyncToGenerator(function* () {
|
405
|
-
if (!(yield
|
354
|
+
if (!(yield _this6.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
|
406
355
|
throw Error("Server does not support the delayed events API");
|
407
356
|
}
|
408
|
-
return yield
|
357
|
+
return yield _this6.widgetApi.updateDelayedEvent(delayId, action);
|
409
358
|
})();
|
410
359
|
}
|
411
360
|
sendToDevice(eventType, contentMap) {
|
412
|
-
var
|
361
|
+
var _this7 = this;
|
413
362
|
return _asyncToGenerator(function* () {
|
414
|
-
yield
|
363
|
+
yield _this7.widgetApi.sendToDevice(eventType, false, recursiveMapToObject(contentMap));
|
415
364
|
return {};
|
416
365
|
})();
|
417
366
|
}
|
418
367
|
getOpenIdToken() {
|
419
|
-
var
|
368
|
+
var _this8 = this;
|
420
369
|
return _asyncToGenerator(function* () {
|
421
|
-
var token = yield
|
370
|
+
var token = yield _this8.widgetApi.requestOpenIDConnectToken();
|
422
371
|
// the IOpenIDCredentials from the widget-api and IOpenIDToken form the matrix-js-sdk are compatible.
|
423
372
|
// we still recreate the token to make this transparent and catch'able by the linter in case the types change in the future.
|
424
373
|
return {
|
@@ -430,7 +379,7 @@ export class RoomWidgetClient extends MatrixClient {
|
|
430
379
|
})();
|
431
380
|
}
|
432
381
|
queueToDevice(_ref10) {
|
433
|
-
var
|
382
|
+
var _this9 = this;
|
434
383
|
return _asyncToGenerator(function* () {
|
435
384
|
var {
|
436
385
|
eventType,
|
@@ -445,52 +394,7 @@ export class RoomWidgetClient extends MatrixClient {
|
|
445
394
|
} of batch) {
|
446
395
|
contentMap.getOrCreate(userId).set(deviceId, payload);
|
447
396
|
}
|
448
|
-
yield
|
449
|
-
})();
|
450
|
-
}
|
451
|
-
encryptAndSendToDevices(userDeviceInfoArr, payload) {
|
452
|
-
var _this11 = this;
|
453
|
-
return _asyncToGenerator(function* () {
|
454
|
-
// map: user Id → device Id → payload
|
455
|
-
var contentMap = new MapWithDefault(() => new Map());
|
456
|
-
for (var {
|
457
|
-
userId,
|
458
|
-
deviceInfo: {
|
459
|
-
deviceId
|
460
|
-
}
|
461
|
-
} of userDeviceInfoArr) {
|
462
|
-
contentMap.getOrCreate(userId).set(deviceId, payload);
|
463
|
-
}
|
464
|
-
yield _this11.widgetApi.sendToDevice(payload.type, true, recursiveMapToObject(contentMap));
|
465
|
-
})();
|
466
|
-
}
|
467
|
-
|
468
|
-
/**
|
469
|
-
* Send an event to a specific list of devices via the widget API. Optionally encrypts the event.
|
470
|
-
*
|
471
|
-
* If you are using a full MatrixClient you would be calling {@link MatrixClient.getCrypto().encryptToDeviceMessages()} followed
|
472
|
-
* by {@link MatrixClient.queueToDevice}.
|
473
|
-
*
|
474
|
-
* However, this is combined into a single step when running as an embedded widget client. So, we expose this method for those
|
475
|
-
* that need it.
|
476
|
-
*
|
477
|
-
* @param eventType - Type of the event to send.
|
478
|
-
* @param encrypted - Whether the event should be encrypted.
|
479
|
-
* @param contentMap - The content to send. Map from user_id to device_id to content object.
|
480
|
-
*/
|
481
|
-
sendToDeviceViaWidgetApi(eventType, encrypted, contentMap) {
|
482
|
-
var _this12 = this;
|
483
|
-
return _asyncToGenerator(function* () {
|
484
|
-
yield _this12.widgetApi.sendToDevice(eventType, encrypted, recursiveMapToObject(contentMap));
|
485
|
-
})();
|
486
|
-
}
|
487
|
-
|
488
|
-
// Overridden since we get TURN servers automatically over the widget API,
|
489
|
-
// and this method would otherwise complain about missing an access token
|
490
|
-
checkTurnServers() {
|
491
|
-
var _this13 = this;
|
492
|
-
return _asyncToGenerator(function* () {
|
493
|
-
return _this13.turnServers.length > 0;
|
397
|
+
yield _this9.widgetApi.sendToDevice(eventType, false, recursiveMapToObject(contentMap));
|
494
398
|
})();
|
495
399
|
}
|
496
400
|
|
@@ -504,55 +408,9 @@ export class RoomWidgetClient extends MatrixClient {
|
|
504
408
|
this.emit(ClientEvent.Sync, state, oldState);
|
505
409
|
}
|
506
410
|
ack(ev) {
|
507
|
-
var
|
508
|
-
return _asyncToGenerator(function* () {
|
509
|
-
yield _this14.widgetApi.transport.reply(ev.detail, {});
|
510
|
-
})();
|
511
|
-
}
|
512
|
-
watchTurnServers() {
|
513
|
-
var _this15 = this;
|
411
|
+
var _this10 = this;
|
514
412
|
return _asyncToGenerator(function* () {
|
515
|
-
|
516
|
-
var onClientStopped = () => {
|
517
|
-
servers.return(undefined);
|
518
|
-
};
|
519
|
-
_this15.lifecycle.signal.addEventListener("abort", onClientStopped);
|
520
|
-
try {
|
521
|
-
var _iteratorAbruptCompletion = false;
|
522
|
-
var _didIteratorError = false;
|
523
|
-
var _iteratorError;
|
524
|
-
try {
|
525
|
-
for (var _iterator = _asyncIterator(servers), _step; _iteratorAbruptCompletion = !(_step = yield _iterator.next()).done; _iteratorAbruptCompletion = false) {
|
526
|
-
var server = _step.value;
|
527
|
-
{
|
528
|
-
_this15.turnServers = [{
|
529
|
-
urls: server.uris,
|
530
|
-
username: server.username,
|
531
|
-
credential: server.password
|
532
|
-
}];
|
533
|
-
_this15.emit(ClientEvent.TurnServers, _this15.turnServers);
|
534
|
-
logger.log("Received TURN server: ".concat(server.uris));
|
535
|
-
}
|
536
|
-
}
|
537
|
-
} catch (err) {
|
538
|
-
_didIteratorError = true;
|
539
|
-
_iteratorError = err;
|
540
|
-
} finally {
|
541
|
-
try {
|
542
|
-
if (_iteratorAbruptCompletion && _iterator.return != null) {
|
543
|
-
yield _iterator.return();
|
544
|
-
}
|
545
|
-
} finally {
|
546
|
-
if (_didIteratorError) {
|
547
|
-
throw _iteratorError;
|
548
|
-
}
|
549
|
-
}
|
550
|
-
}
|
551
|
-
} catch (e) {
|
552
|
-
logger.warn("Error watching TURN servers", e);
|
553
|
-
} finally {
|
554
|
-
_this15.lifecycle.signal.removeEventListener("abort", onClientStopped);
|
555
|
-
}
|
413
|
+
yield _this10.widgetApi.transport.reply(ev.detail, {});
|
556
414
|
})();
|
557
415
|
}
|
558
416
|
}
|
package/lib/embedded.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"embedded.js","names":["WidgetApiToWidgetAction","WidgetApiResponseError","MatrixCapabilities","MatrixEvent","EventStatus","EventType","logger","MatrixClient","ClientEvent","UNSTABLE_MSC4140_DELAYED_EVENTS","SyncApi","SyncState","SlidingSyncSdk","MatrixError","User","MapWithDefault","recursiveMapToObject","TypedEventEmitter","RoomWidgetClientEvent","RoomWidgetClient","constructor","widgetApi","capabilities","roomId","opts","sendContentLoaded","_this","_capabilities$sendEve","_capabilities$receive","_capabilities$sendSta","_capabilities$receive2","_capabilities$sendEve2","_capabilities$receive3","_capabilities$sendSta2","_capabilities$receive4","_capabilities$sendToD","_capabilities$receive5","_capabilities$sendEve3","_capabilities$sendSta3","this","_defineProperty","_ref","_asyncToGenerator","event","getSender","getUserId","pendingSendingEventsTxId","some","p","getType","type","_this$pendingSendingE","matchingTxId","find","id","getId","txId","length","_this$pendingSendingE2","Promise","resolve","eventEmitter","once","PendingEventsChanged","setTxnId","setUnsigned","_objectSpread","getUnsigned","transaction_id","filter","emit","_x","apply","arguments","_ref2","ev","preventDefault","detail","data","room_id","updateTxId","syncApi","injectRoomEvents","room","Event","setSyncState","Syncing","info","concat","getStateKey","event_id","eventId","ack","_x2","_ref3","sender","content","encrypted","makeEncrypted","RoomMessageEncrypted","ToDeviceEvent","_x3","transportSend","transport","send","bind","_ref4","action","error","processAndThrow","_x4","_x5","transportSendComplete","sendComplete","_ref5","_x6","_x7","widgetApiReady","sendEvent","receiveEvent","sendMessage","Array","isArray","receiveMessage","sendState","receiveState","requestCapabilityForRoomTimeline","forEach","eventType","requestCapabilityToSendEvent","requestCapabilityToReceiveEvent","requestCapabilityToSendMessage","msgType","requestCapabilityToReceiveMessage","_ref6","stateKey","requestCapabilityToSendState","_ref7","requestCapabilityToReceiveState","sendToDevice","requestCapabilityToSendToDevice","receiveToDevice","requestCapabilityToReceiveToDevice","sendDelayedEvents","requestCapability","MSC4157SendDelayedEvent","updateDelayedEvents","MSC4157UpdateDelayedEvent","turnServers","MSC3846TurnServers","on","SendEvent","onEvent","SendToDevice","onToDevice","start","startClient","_arguments","_this2","_this2$capabilities$r","_this2$capabilities$r2","undefined","lifecycle","AbortController","userId","store","storeUser","slidingSync","buildSyncApiOptions","createRoom","storeRoom","all","map","_ref9","_ref8","rawEvents","readStateEvents","events","rawEvent","_x8","clientWellKnownPollPeriod","clientWellKnownIntervalID","setInterval","fetchClientWellKnown","watchTurnServers","stopClient","off","abort","joinRoom","roomIdOrAlias","_this3","Error","encryptAndSendEvent","delayOpts","_this4","redacts","getContent","response","sendRoomEvent","delay","parent_delay_id","validateSendDelayedEventResponse","getTxnId","push","e","updatePendingEventStatus","NOT_SENT","updatePendingEvent","SENT","sendStateEvent","_arguments2","_this5","_unstable_sendDelayedStateEvent","_arguments3","_this6","doesServerSupportUnstableFeature","delay_id","_unstable_updateDelayedEvent","delayId","_this7","updateDelayedEvent","contentMap","_this8","getOpenIdToken","_this9","token","requestOpenIDConnectToken","access_token","expires_in","matrix_server_name","token_type","queueToDevice","_ref10","_this10","batch","Map","deviceId","payload","getOrCreate","set","encryptAndSendToDevices","userDeviceInfoArr","_this11","deviceInfo","sendToDeviceViaWidgetApi","_this12","checkTurnServers","_this13","getSyncState","syncState","state","oldState","Sync","_this14","reply","_this15","servers","getTurnServers","onClientStopped","return","signal","addEventListener","_iteratorAbruptCompletion","_didIteratorError","_iteratorError","_iterator","_asyncIterator","_step","next","done","server","value","urls","uris","username","credential","password","TurnServers","log","err","warn","removeEventListener","matrix_api_error","fromWidgetApiErrorData"],"sources":["../src/embedded.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport {\n WidgetApi,\n WidgetApiToWidgetAction,\n WidgetApiResponseError,\n MatrixCapabilities,\n IWidgetApiRequest,\n IWidgetApiAcknowledgeResponseData,\n ISendEventToWidgetActionRequest,\n ISendToDeviceToWidgetActionRequest,\n ISendEventFromWidgetResponseData,\n IWidgetApiRequestData,\n WidgetApiAction,\n IWidgetApiResponse,\n IWidgetApiResponseData,\n} from \"matrix-widget-api\";\n\nimport { MatrixEvent, IEvent, IContent, EventStatus } from \"./models/event.ts\";\nimport {\n ISendEventResponse,\n SendDelayedEventRequestOpts,\n SendDelayedEventResponse,\n UpdateDelayedEventAction,\n} from \"./@types/requests.ts\";\nimport { EventType, StateEvents } from \"./@types/event.ts\";\nimport { logger } from \"./logger.ts\";\nimport {\n MatrixClient,\n ClientEvent,\n IMatrixClientCreateOpts,\n IStartClientOpts,\n SendToDeviceContentMap,\n IOpenIDToken,\n UNSTABLE_MSC4140_DELAYED_EVENTS,\n} from \"./client.ts\";\nimport { SyncApi, SyncState } from \"./sync.ts\";\nimport { SlidingSyncSdk } from \"./sliding-sync-sdk.ts\";\nimport { MatrixError } from \"./http-api/errors.ts\";\nimport { User } from \"./models/user.ts\";\nimport { Room } from \"./models/room.ts\";\nimport { ToDeviceBatch, ToDevicePayload } from \"./models/ToDeviceMessage.ts\";\nimport { DeviceInfo } from \"./crypto/deviceinfo.ts\";\nimport { IOlmDevice } from \"./crypto/algorithms/megolm.ts\";\nimport { MapWithDefault, recursiveMapToObject } from \"./utils.ts\";\nimport { TypedEventEmitter } from \"./matrix.ts\";\n\ninterface IStateEventRequest {\n eventType: string;\n stateKey?: string;\n}\n\nexport interface ICapabilities {\n /**\n * Event types that this client expects to send.\n */\n sendEvent?: string[];\n /**\n * Event types that this client expects to receive.\n */\n receiveEvent?: string[];\n\n /**\n * Message types that this client expects to send, or true for all message\n * types.\n */\n sendMessage?: string[] | true;\n /**\n * Message types that this client expects to receive, or true for all\n * message types.\n */\n receiveMessage?: string[] | true;\n\n /**\n * Types of state events that this client expects to send.\n */\n sendState?: IStateEventRequest[];\n /**\n * Types of state events that this client expects to receive.\n */\n receiveState?: IStateEventRequest[];\n\n /**\n * To-device event types that this client expects to send.\n */\n sendToDevice?: string[];\n /**\n * To-device event types that this client expects to receive.\n */\n receiveToDevice?: string[];\n\n /**\n * Whether this client needs access to TURN servers.\n * @defaultValue false\n */\n turnServers?: boolean;\n\n /**\n * Whether this client needs to be able to send delayed events.\n * @experimental Part of MSC4140 & MSC4157\n * @defaultValue false\n */\n sendDelayedEvents?: boolean;\n\n /**\n * Whether this client needs to be able to update delayed events.\n * @experimental Part of MSC4140 & MSC4157\n * @defaultValue false\n */\n updateDelayedEvents?: boolean;\n}\n\nexport enum RoomWidgetClientEvent {\n PendingEventsChanged = \"PendingEvent.pendingEventsChanged\",\n}\nexport type EventHandlerMap = { [RoomWidgetClientEvent.PendingEventsChanged]: () => void };\n/**\n * A MatrixClient that routes its requests through the widget API instead of the\n * real CS API.\n * @experimental This class is considered unstable!\n */\nexport class RoomWidgetClient extends MatrixClient {\n private room?: Room;\n private readonly widgetApiReady: Promise<void>;\n private lifecycle?: AbortController;\n private syncState: SyncState | null = null;\n\n private pendingSendingEventsTxId: { type: string; id: string | undefined; txId: string }[] = [];\n private eventEmitter = new TypedEventEmitter<keyof EventHandlerMap, EventHandlerMap>();\n\n /**\n *\n * @param widgetApi - The widget api to use for communication.\n * @param capabilities - The capabilities the widget client will request.\n * @param roomId - The room id the widget is associated with.\n * @param opts - The configuration options for this client.\n * @param sendContentLoaded - Whether to send a content loaded widget action immediately after initial setup.\n * Set to `false` if the widget uses `waitForIFrameLoad=true` (in this case the client does not expect a content loaded action at all),\n * or if the the widget wants to send the `ContentLoaded` action at a later point in time after the initial setup.\n */\n public constructor(\n private readonly widgetApi: WidgetApi,\n private readonly capabilities: ICapabilities,\n private readonly roomId: string,\n opts: IMatrixClientCreateOpts,\n sendContentLoaded: boolean,\n ) {\n super(opts);\n\n const transportSend = this.widgetApi.transport.send.bind(this.widgetApi.transport);\n this.widgetApi.transport.send = async <\n T extends IWidgetApiRequestData,\n R extends IWidgetApiResponseData = IWidgetApiAcknowledgeResponseData,\n >(\n action: WidgetApiAction,\n data: T,\n ): Promise<R> => {\n try {\n return await transportSend(action, data);\n } catch (error) {\n processAndThrow(error);\n }\n };\n\n const transportSendComplete = this.widgetApi.transport.sendComplete.bind(this.widgetApi.transport);\n this.widgetApi.transport.sendComplete = async <T extends IWidgetApiRequestData, R extends IWidgetApiResponse>(\n action: WidgetApiAction,\n data: T,\n ): Promise<R> => {\n try {\n return await transportSendComplete(action, data);\n } catch (error) {\n processAndThrow(error);\n }\n };\n\n this.widgetApiReady = new Promise<void>((resolve) => this.widgetApi.once(\"ready\", resolve));\n\n // Request capabilities for the functionality this client needs to support\n if (\n capabilities.sendEvent?.length ||\n capabilities.receiveEvent?.length ||\n capabilities.sendMessage === true ||\n (Array.isArray(capabilities.sendMessage) && capabilities.sendMessage.length) ||\n capabilities.receiveMessage === true ||\n (Array.isArray(capabilities.receiveMessage) && capabilities.receiveMessage.length) ||\n capabilities.sendState?.length ||\n capabilities.receiveState?.length\n ) {\n widgetApi.requestCapabilityForRoomTimeline(roomId);\n }\n capabilities.sendEvent?.forEach((eventType) => widgetApi.requestCapabilityToSendEvent(eventType));\n capabilities.receiveEvent?.forEach((eventType) => widgetApi.requestCapabilityToReceiveEvent(eventType));\n if (capabilities.sendMessage === true) {\n widgetApi.requestCapabilityToSendMessage();\n } else if (Array.isArray(capabilities.sendMessage)) {\n capabilities.sendMessage.forEach((msgType) => widgetApi.requestCapabilityToSendMessage(msgType));\n }\n if (capabilities.receiveMessage === true) {\n widgetApi.requestCapabilityToReceiveMessage();\n } else if (Array.isArray(capabilities.receiveMessage)) {\n capabilities.receiveMessage.forEach((msgType) => widgetApi.requestCapabilityToReceiveMessage(msgType));\n }\n capabilities.sendState?.forEach(({ eventType, stateKey }) =>\n widgetApi.requestCapabilityToSendState(eventType, stateKey),\n );\n capabilities.receiveState?.forEach(({ eventType, stateKey }) =>\n widgetApi.requestCapabilityToReceiveState(eventType, stateKey),\n );\n capabilities.sendToDevice?.forEach((eventType) => widgetApi.requestCapabilityToSendToDevice(eventType));\n capabilities.receiveToDevice?.forEach((eventType) => widgetApi.requestCapabilityToReceiveToDevice(eventType));\n if (\n capabilities.sendDelayedEvents &&\n (capabilities.sendEvent?.length ||\n capabilities.sendMessage === true ||\n (Array.isArray(capabilities.sendMessage) && capabilities.sendMessage.length) ||\n capabilities.sendState?.length)\n ) {\n widgetApi.requestCapability(MatrixCapabilities.MSC4157SendDelayedEvent);\n }\n if (capabilities.updateDelayedEvents) {\n widgetApi.requestCapability(MatrixCapabilities.MSC4157UpdateDelayedEvent);\n }\n if (capabilities.turnServers) {\n widgetApi.requestCapability(MatrixCapabilities.MSC3846TurnServers);\n }\n\n widgetApi.on(`action:${WidgetApiToWidgetAction.SendEvent}`, this.onEvent);\n widgetApi.on(`action:${WidgetApiToWidgetAction.SendToDevice}`, this.onToDevice);\n\n // Open communication with the host\n widgetApi.start();\n // Send a content loaded event now we've started the widget API\n // Note that element-web currently does not use waitForIFrameLoad=false and so\n // does *not* (yes, that is the right way around) wait for this event. Let's\n // start sending this, then once this has rolled out, we can change element-web to\n // use waitForIFrameLoad=false and have a widget API that's less racy.\n if (sendContentLoaded) widgetApi.sendContentLoaded();\n }\n\n public async startClient(opts: IStartClientOpts = {}): Promise<void> {\n this.lifecycle = new AbortController();\n\n // Create our own user object artificially (instead of waiting for sync)\n // so it's always available, even if the user is not in any rooms etc.\n const userId = this.getUserId();\n if (userId) {\n this.store.storeUser(new User(userId));\n }\n\n // Even though we have no access token and cannot sync, the sync class\n // still has some valuable helper methods that we make use of, so we\n // instantiate it anyways\n if (opts.slidingSync) {\n this.syncApi = new SlidingSyncSdk(opts.slidingSync, this, opts, this.buildSyncApiOptions());\n } else {\n this.syncApi = new SyncApi(this, opts, this.buildSyncApiOptions());\n }\n\n this.room = this.syncApi.createRoom(this.roomId);\n this.store.storeRoom(this.room);\n\n await this.widgetApiReady;\n\n // Backfill the requested events\n // We only get the most recent event for every type + state key combo,\n // so it doesn't really matter what order we inject them in\n await Promise.all(\n this.capabilities.receiveState?.map(async ({ eventType, stateKey }) => {\n const rawEvents = await this.widgetApi.readStateEvents(eventType, undefined, stateKey, [this.roomId]);\n const events = rawEvents.map((rawEvent) => new MatrixEvent(rawEvent as Partial<IEvent>));\n\n await this.syncApi!.injectRoomEvents(this.room!, [], events);\n events.forEach((event) => {\n this.emit(ClientEvent.Event, event);\n logger.info(`Backfilled event ${event.getId()} ${event.getType()} ${event.getStateKey()}`);\n });\n }) ?? [],\n );\n\n if (opts.clientWellKnownPollPeriod !== undefined) {\n this.clientWellKnownIntervalID = setInterval(() => {\n this.fetchClientWellKnown();\n }, 1000 * opts.clientWellKnownPollPeriod);\n this.fetchClientWellKnown();\n }\n\n this.setSyncState(SyncState.Syncing);\n logger.info(\"Finished backfilling events\");\n\n // Watch for TURN servers, if requested\n if (this.capabilities.turnServers) this.watchTurnServers();\n }\n\n public stopClient(): void {\n this.widgetApi.off(`action:${WidgetApiToWidgetAction.SendEvent}`, this.onEvent);\n this.widgetApi.off(`action:${WidgetApiToWidgetAction.SendToDevice}`, this.onToDevice);\n\n super.stopClient();\n this.lifecycle!.abort(); // Signal to other async tasks that the client has stopped\n }\n\n public async joinRoom(roomIdOrAlias: string): Promise<Room> {\n if (roomIdOrAlias === this.roomId) return this.room!;\n throw new Error(`Unknown room: ${roomIdOrAlias}`);\n }\n\n protected async encryptAndSendEvent(room: Room, event: MatrixEvent): Promise<ISendEventResponse>;\n protected async encryptAndSendEvent(\n room: Room,\n event: MatrixEvent,\n delayOpts: SendDelayedEventRequestOpts,\n ): Promise<SendDelayedEventResponse>;\n protected async encryptAndSendEvent(\n room: Room,\n event: MatrixEvent,\n delayOpts?: SendDelayedEventRequestOpts,\n ): Promise<ISendEventResponse | SendDelayedEventResponse> {\n // We need to extend the content with the redacts parameter\n // The js sdk uses event.redacts but the widget api uses event.content.redacts\n // This will be converted back to event.redacts in the widget driver.\n const content = event.event.redacts\n ? { ...event.getContent(), redacts: event.event.redacts }\n : event.getContent();\n\n // Delayed event special case.\n if (delayOpts) {\n // TODO: updatePendingEvent for delayed events?\n const response = await this.widgetApi.sendRoomEvent(\n event.getType(),\n content,\n room.roomId,\n \"delay\" in delayOpts ? delayOpts.delay : undefined,\n \"parent_delay_id\" in delayOpts ? delayOpts.parent_delay_id : undefined,\n );\n return this.validateSendDelayedEventResponse(response);\n }\n\n const txId = event.getTxnId();\n // Add the txnId to the pending list (still with unknown evID)\n if (txId) this.pendingSendingEventsTxId.push({ type: event.getType(), id: undefined, txId });\n\n let response: ISendEventFromWidgetResponseData;\n try {\n response = await this.widgetApi.sendRoomEvent(event.getType(), content, room.roomId);\n } catch (e) {\n this.updatePendingEventStatus(room, event, EventStatus.NOT_SENT);\n throw e;\n }\n // This also checks for an event id on the response\n room.updatePendingEvent(event, EventStatus.SENT, response.event_id);\n\n // Update the pending events list with the eventId\n this.pendingSendingEventsTxId.forEach((p) => {\n if (p.txId === txId) p.id = response.event_id;\n });\n this.eventEmitter.emit(RoomWidgetClientEvent.PendingEventsChanged);\n\n return { event_id: response.event_id! };\n }\n\n public async sendStateEvent(\n roomId: string,\n eventType: string,\n content: any,\n stateKey = \"\",\n ): Promise<ISendEventResponse> {\n const response = await this.widgetApi.sendStateEvent(eventType, stateKey, content, roomId);\n if (response.event_id === undefined) {\n throw new Error(\"'event_id' absent from response to an event request\");\n }\n return { event_id: response.event_id };\n }\n\n /**\n * @experimental This currently relies on an unstable MSC (MSC4140).\n */\n // eslint-disable-next-line\n public async _unstable_sendDelayedStateEvent<K extends keyof StateEvents>(\n roomId: string,\n delayOpts: SendDelayedEventRequestOpts,\n eventType: K,\n content: StateEvents[K],\n stateKey = \"\",\n ): Promise<SendDelayedEventResponse> {\n if (!(await this.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {\n throw Error(\"Server does not support the delayed events API\");\n }\n\n const response = await this.widgetApi.sendStateEvent(\n eventType,\n stateKey,\n content,\n roomId,\n \"delay\" in delayOpts ? delayOpts.delay : undefined,\n \"parent_delay_id\" in delayOpts ? delayOpts.parent_delay_id : undefined,\n );\n return this.validateSendDelayedEventResponse(response);\n }\n\n private validateSendDelayedEventResponse(response: ISendEventFromWidgetResponseData): SendDelayedEventResponse {\n if (response.delay_id === undefined) {\n throw new Error(\"'delay_id' absent from response to a delayed event request\");\n }\n return { delay_id: response.delay_id };\n }\n\n /**\n * @experimental This currently relies on an unstable MSC (MSC4140).\n */\n // eslint-disable-next-line\n public async _unstable_updateDelayedEvent(delayId: string, action: UpdateDelayedEventAction): Promise<{}> {\n if (!(await this.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {\n throw Error(\"Server does not support the delayed events API\");\n }\n\n return await this.widgetApi.updateDelayedEvent(delayId, action);\n }\n\n public async sendToDevice(eventType: string, contentMap: SendToDeviceContentMap): Promise<{}> {\n await this.widgetApi.sendToDevice(eventType, false, recursiveMapToObject(contentMap));\n return {};\n }\n\n public async getOpenIdToken(): Promise<IOpenIDToken> {\n const token = await this.widgetApi.requestOpenIDConnectToken();\n // the IOpenIDCredentials from the widget-api and IOpenIDToken form the matrix-js-sdk are compatible.\n // we still recreate the token to make this transparent and catch'able by the linter in case the types change in the future.\n return <IOpenIDToken>{\n access_token: token.access_token,\n expires_in: token.expires_in,\n matrix_server_name: token.matrix_server_name,\n token_type: token.token_type,\n };\n }\n\n public async queueToDevice({ eventType, batch }: ToDeviceBatch): Promise<void> {\n // map: user Id → device Id → payload\n const contentMap: MapWithDefault<string, Map<string, ToDevicePayload>> = new MapWithDefault(() => new Map());\n for (const { userId, deviceId, payload } of batch) {\n contentMap.getOrCreate(userId).set(deviceId, payload);\n }\n\n await this.widgetApi.sendToDevice(eventType, false, recursiveMapToObject(contentMap));\n }\n\n public async encryptAndSendToDevices(userDeviceInfoArr: IOlmDevice<DeviceInfo>[], payload: object): Promise<void> {\n // map: user Id → device Id → payload\n const contentMap: MapWithDefault<string, Map<string, object>> = new MapWithDefault(() => new Map());\n for (const {\n userId,\n deviceInfo: { deviceId },\n } of userDeviceInfoArr) {\n contentMap.getOrCreate(userId).set(deviceId, payload);\n }\n\n await this.widgetApi.sendToDevice((payload as { type: string }).type, true, recursiveMapToObject(contentMap));\n }\n\n /**\n * Send an event to a specific list of devices via the widget API. Optionally encrypts the event.\n *\n * If you are using a full MatrixClient you would be calling {@link MatrixClient.getCrypto().encryptToDeviceMessages()} followed\n * by {@link MatrixClient.queueToDevice}.\n *\n * However, this is combined into a single step when running as an embedded widget client. So, we expose this method for those\n * that need it.\n *\n * @param eventType - Type of the event to send.\n * @param encrypted - Whether the event should be encrypted.\n * @param contentMap - The content to send. Map from user_id to device_id to content object.\n */\n public async sendToDeviceViaWidgetApi(\n eventType: string,\n encrypted: boolean,\n contentMap: SendToDeviceContentMap,\n ): Promise<void> {\n await this.widgetApi.sendToDevice(eventType, encrypted, recursiveMapToObject(contentMap));\n }\n\n // Overridden since we get TURN servers automatically over the widget API,\n // and this method would otherwise complain about missing an access token\n public async checkTurnServers(): Promise<boolean> {\n return this.turnServers.length > 0;\n }\n\n // Overridden since we 'sync' manually without the sync API\n public getSyncState(): SyncState | null {\n return this.syncState;\n }\n\n private setSyncState(state: SyncState): void {\n const oldState = this.syncState;\n this.syncState = state;\n this.emit(ClientEvent.Sync, state, oldState);\n }\n\n private async ack(ev: CustomEvent<IWidgetApiRequest>): Promise<void> {\n await this.widgetApi.transport.reply<IWidgetApiAcknowledgeResponseData>(ev.detail, {});\n }\n\n private updateTxId = async (event: MatrixEvent): Promise<void> => {\n // We update the txId for remote echos that originate from this client.\n // This happens with the help of `pendingSendingEventsTxId` where we store all events that are currently sending\n // with their widget txId and once ready the final evId.\n if (\n // This could theoretically be an event send by this device\n // In that case we need to update the txId of the event because the embedded client/widget\n // knows this event with a different transaction Id than what was used by the host client.\n event.getSender() === this.getUserId() &&\n // We optimize by not blocking events from types that we have not send\n // with this client.\n this.pendingSendingEventsTxId.some((p) => event.getType() === p.type)\n ) {\n // Compare by event Id if we have a matching pending event where we know the txId.\n let matchingTxId = this.pendingSendingEventsTxId.find((p) => p.id === event.getId())?.txId;\n // Block any further processing of this event until we have received the sending response.\n // -> until we know the event id.\n // -> until we have not pending events anymore.\n while (!matchingTxId && this.pendingSendingEventsTxId.length > 0) {\n // Recheck whenever the PendingEventsChanged\n await new Promise<void>((resolve) =>\n this.eventEmitter.once(RoomWidgetClientEvent.PendingEventsChanged, () => resolve()),\n );\n matchingTxId = this.pendingSendingEventsTxId.find((p) => p.id === event.getId())?.txId;\n }\n\n // We found the correct txId: we update the event and delete the entry of the pending events.\n if (matchingTxId) {\n event.setTxnId(matchingTxId);\n event.setUnsigned({ ...event.getUnsigned(), transaction_id: matchingTxId });\n }\n this.pendingSendingEventsTxId = this.pendingSendingEventsTxId.filter((p) => p.id !== event.getId());\n\n // Emit once there are no pending events anymore to release all other events that got\n // awaited in the `while (!matchingTxId && this.pendingSendingEventsTxId.length > 0)` loop\n // but are not send by this client.\n if (this.pendingSendingEventsTxId.length === 0) {\n this.eventEmitter.emit(RoomWidgetClientEvent.PendingEventsChanged);\n }\n }\n };\n\n private onEvent = async (ev: CustomEvent<ISendEventToWidgetActionRequest>): Promise<void> => {\n ev.preventDefault();\n\n // Verify the room ID matches, since it's possible for the client to\n // send us events from other rooms if this widget is always on screen\n if (ev.detail.data.room_id === this.roomId) {\n const event = new MatrixEvent(ev.detail.data as Partial<IEvent>);\n\n // Only inject once we have update the txId\n await this.updateTxId(event);\n await this.syncApi!.injectRoomEvents(this.room!, [], [event]);\n this.emit(ClientEvent.Event, event);\n this.setSyncState(SyncState.Syncing);\n logger.info(`Received event ${event.getId()} ${event.getType()} ${event.getStateKey()}`);\n } else {\n const { event_id: eventId, room_id: roomId } = ev.detail.data;\n logger.info(`Received event ${eventId} for a different room ${roomId}; discarding`);\n }\n\n await this.ack(ev);\n };\n\n private onToDevice = async (ev: CustomEvent<ISendToDeviceToWidgetActionRequest>): Promise<void> => {\n ev.preventDefault();\n\n const event = new MatrixEvent({\n type: ev.detail.data.type,\n sender: ev.detail.data.sender,\n content: ev.detail.data.content as IContent,\n });\n // Mark the event as encrypted if it was, using fake contents and keys since those are unknown to us\n if (ev.detail.data.encrypted) event.makeEncrypted(EventType.RoomMessageEncrypted, {}, \"\", \"\");\n\n this.emit(ClientEvent.ToDeviceEvent, event);\n this.setSyncState(SyncState.Syncing);\n await this.ack(ev);\n };\n\n private async watchTurnServers(): Promise<void> {\n const servers = this.widgetApi.getTurnServers();\n const onClientStopped = (): void => {\n servers.return(undefined);\n };\n this.lifecycle!.signal.addEventListener(\"abort\", onClientStopped);\n\n try {\n for await (const server of servers) {\n this.turnServers = [\n {\n urls: server.uris,\n username: server.username,\n credential: server.password,\n },\n ];\n this.emit(ClientEvent.TurnServers, this.turnServers);\n logger.log(`Received TURN server: ${server.uris}`);\n }\n } catch (e) {\n logger.warn(\"Error watching TURN servers\", e);\n } finally {\n this.lifecycle!.signal.removeEventListener(\"abort\", onClientStopped);\n }\n }\n}\n\nfunction processAndThrow(error: unknown): never {\n if (error instanceof WidgetApiResponseError && error.data.matrix_api_error) {\n throw MatrixError.fromWidgetApiErrorData(error.data.matrix_api_error);\n } else {\n throw error;\n }\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAEIA,uBAAuB,EACvBC,sBAAsB,EACtBC,kBAAkB,QAUf,mBAAmB;AAE1B,SAASC,WAAW,EAAoBC,WAAW,QAAQ,mBAAmB;AAO9E,SAASC,SAAS,QAAqB,mBAAmB;AAC1D,SAASC,MAAM,QAAQ,aAAa;AACpC,SACIC,YAAY,EACZC,WAAW,EAKXC,+BAA+B,QAC5B,aAAa;AACpB,SAASC,OAAO,EAAEC,SAAS,QAAQ,WAAW;AAC9C,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAASC,WAAW,QAAQ,sBAAsB;AAClD,SAASC,IAAI,QAAQ,kBAAkB;AAKvC,SAASC,cAAc,EAAEC,oBAAoB,QAAQ,YAAY;AACjE,SAASC,iBAAiB,QAAQ,aAAa;AAmE/C,WAAYC,qBAAqB,0BAArBA,qBAAqB;EAArBA,qBAAqB;EAAA,OAArBA,qBAAqB;AAAA;AAIjC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC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AAA;QAAA;MACL,CAAC,CAAC,OAAO5D,CAAC,EAAE;QACRtM,MAAM,CAACkR,IAAI,CAAC,6BAA6B,EAAE5E,CAAC,CAAC;MACjD,CAAC,SAAS;QACNmD,OAAI,CAAC7F,SAAS,CAAEkG,MAAM,CAACqB,mBAAmB,CAAC,OAAO,EAAEvB,eAAe,CAAC;MACxE;IAAC;EACL;AACJ;AAEA,SAASrJ,eAAeA,CAACD,KAAc,EAAS;EAC5C,IAAIA,KAAK,YAAY3G,sBAAsB,IAAI2G,KAAK,CAAC9B,IAAI,CAAC4M,gBAAgB,EAAE;IACxE,MAAM7Q,WAAW,CAAC8Q,sBAAsB,CAAC/K,KAAK,CAAC9B,IAAI,CAAC4M,gBAAgB,CAAC;EACzE,CAAC,MAAM;IACH,MAAM9K,KAAK;EACf;AACJ","ignoreList":[]}
|
1
|
+
{"version":3,"file":"embedded.js","names":["WidgetApiToWidgetAction","WidgetApiResponseError","MatrixCapabilities","MatrixEvent","logger","MatrixClient","ClientEvent","UNSTABLE_MSC4140_DELAYED_EVENTS","SyncApi","SyncState","SlidingSyncSdk","MatrixError","User","MapWithDefault","recursiveMapToObject","TypedEventEmitter","RoomWidgetClientEvent","RoomWidgetClient","constructor","widgetApi","capabilities","roomId","opts","sendContentLoaded","_this","_capabilities$sendEve","_capabilities$receive","_capabilities$sendSta","_capabilities$receive2","_capabilities$sendEve2","_capabilities$receive3","_capabilities$sendSta2","_capabilities$receive4","_capabilities$sendToD","_capabilities$receive5","_capabilities$sendEve3","_capabilities$sendSta3","this","_defineProperty","_ref","_asyncToGenerator","event","getSender","getUserId","pendingSendingEventsTxId","some","p","getType","type","_this$pendingSendingE","matchingTxId","find","id","getId","txId","length","_this$pendingSendingE2","Promise","resolve","eventEmitter","once","PendingEventsChanged","setTxnId","setUnsigned","_objectSpread","getUnsigned","transaction_id","filter","emit","_x","apply","arguments","_ref2","ev","preventDefault","detail","data","room_id","updateTxId","syncApi","injectRoomEvents","room","Event","setSyncState","Syncing","info","concat","getStateKey","event_id","eventId","ack","_x2","_ref3","sender","content","ToDeviceEvent","_x3","transportSend","transport","send","bind","_ref4","action","error","processAndThrow","_x4","_x5","transportSendComplete","sendComplete","_ref5","_x6","_x7","widgetApiReady","sendEvent","receiveEvent","sendMessage","Array","isArray","receiveMessage","sendState","receiveState","requestCapabilityForRoomTimeline","forEach","eventType","requestCapabilityToSendEvent","requestCapabilityToReceiveEvent","requestCapabilityToSendMessage","msgType","requestCapabilityToReceiveMessage","_ref6","stateKey","requestCapabilityToSendState","_ref7","requestCapabilityToReceiveState","sendToDevice","requestCapabilityToSendToDevice","receiveToDevice","requestCapabilityToReceiveToDevice","sendDelayedEvents","requestCapability","MSC4157SendDelayedEvent","updateDelayedEvents","MSC4157UpdateDelayedEvent","turnServers","MSC3846TurnServers","on","SendEvent","onEvent","SendToDevice","onToDevice","start","startClient","_arguments","_this2","_this2$capabilities$r","_this2$capabilities$r2","undefined","lifecycle","AbortController","userId","store","storeUser","slidingSync","buildSyncApiOptions","createRoom","storeRoom","all","map","_ref9","_ref8","rawEvents","readStateEvents","events","rawEvent","_x8","clientWellKnownPollPeriod","clientWellKnownIntervalID","setInterval","fetchClientWellKnown","stopClient","off","abort","joinRoom","roomIdOrAlias","_this3","Error","sendStateEvent","_arguments2","_this4","response","_unstable_sendDelayedStateEvent","delayOpts","_arguments3","_this5","doesServerSupportUnstableFeature","delay","parent_delay_id","validateSendDelayedEventResponse","delay_id","_unstable_updateDelayedEvent","delayId","_this6","updateDelayedEvent","contentMap","_this7","getOpenIdToken","_this8","token","requestOpenIDConnectToken","access_token","expires_in","matrix_server_name","token_type","queueToDevice","_ref10","_this9","batch","Map","deviceId","payload","getOrCreate","set","getSyncState","syncState","state","oldState","Sync","_this10","reply","matrix_api_error","fromWidgetApiErrorData"],"sources":["../src/embedded.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport {\n WidgetApi,\n WidgetApiToWidgetAction,\n WidgetApiResponseError,\n MatrixCapabilities,\n IWidgetApiRequest,\n IWidgetApiAcknowledgeResponseData,\n ISendEventToWidgetActionRequest,\n ISendToDeviceToWidgetActionRequest,\n ISendEventFromWidgetResponseData,\n IWidgetApiRequestData,\n WidgetApiAction,\n IWidgetApiResponse,\n IWidgetApiResponseData,\n} from \"matrix-widget-api\";\n\nimport { MatrixEvent, IEvent, IContent } from \"./models/event.ts\";\nimport {\n ISendEventResponse,\n SendDelayedEventRequestOpts,\n SendDelayedEventResponse,\n UpdateDelayedEventAction,\n} from \"./@types/requests.ts\";\nimport { StateEvents } from \"./@types/event.ts\";\nimport { logger } from \"./logger.ts\";\nimport {\n MatrixClient,\n ClientEvent,\n IMatrixClientCreateOpts,\n IStartClientOpts,\n SendToDeviceContentMap,\n IOpenIDToken,\n UNSTABLE_MSC4140_DELAYED_EVENTS,\n} from \"./client.ts\";\nimport { SyncApi, SyncState } from \"./sync.ts\";\nimport { SlidingSyncSdk } from \"./sliding-sync-sdk.ts\";\nimport { MatrixError } from \"./http-api/errors.ts\";\nimport { User } from \"./models/user.ts\";\nimport { Room } from \"./models/room.ts\";\nimport { ToDeviceBatch, ToDevicePayload } from \"./models/ToDeviceMessage.ts\";\nimport { MapWithDefault, recursiveMapToObject } from \"./utils.ts\";\nimport { TypedEventEmitter } from \"./matrix.ts\";\n\ninterface IStateEventRequest {\n eventType: string;\n stateKey?: string;\n}\n\nexport interface ICapabilities {\n /**\n * Event types that this client expects to send.\n */\n sendEvent?: string[];\n /**\n * Event types that this client expects to receive.\n */\n receiveEvent?: string[];\n\n /**\n * Message types that this client expects to send, or true for all message\n * types.\n */\n sendMessage?: string[] | true;\n /**\n * Message types that this client expects to receive, or true for all\n * message types.\n */\n receiveMessage?: string[] | true;\n\n /**\n * Types of state events that this client expects to send.\n */\n sendState?: IStateEventRequest[];\n /**\n * Types of state events that this client expects to receive.\n */\n receiveState?: IStateEventRequest[];\n\n /**\n * To-device event types that this client expects to send.\n */\n sendToDevice?: string[];\n /**\n * To-device event types that this client expects to receive.\n */\n receiveToDevice?: string[];\n\n /**\n * Whether this client needs access to TURN servers.\n * @defaultValue false\n */\n turnServers?: boolean;\n\n /**\n * Whether this client needs to be able to send delayed events.\n * @experimental Part of MSC4140 & MSC4157\n * @defaultValue false\n */\n sendDelayedEvents?: boolean;\n\n /**\n * Whether this client needs to be able to update delayed events.\n * @experimental Part of MSC4140 & MSC4157\n * @defaultValue false\n */\n updateDelayedEvents?: boolean;\n}\n\nexport enum RoomWidgetClientEvent {\n PendingEventsChanged = \"PendingEvent.pendingEventsChanged\",\n}\nexport type EventHandlerMap = { [RoomWidgetClientEvent.PendingEventsChanged]: () => void };\n/**\n * A MatrixClient that routes its requests through the widget API instead of the\n * real CS API.\n * @experimental This class is considered unstable!\n */\nexport class RoomWidgetClient extends MatrixClient {\n private room?: Room;\n private readonly widgetApiReady: Promise<void>;\n private lifecycle?: AbortController;\n private syncState: SyncState | null = null;\n\n private pendingSendingEventsTxId: { type: string; id: string | undefined; txId: string }[] = [];\n private eventEmitter = new TypedEventEmitter<keyof EventHandlerMap, EventHandlerMap>();\n\n /**\n *\n * @param widgetApi - The widget api to use for communication.\n * @param capabilities - The capabilities the widget client will request.\n * @param roomId - The room id the widget is associated with.\n * @param opts - The configuration options for this client.\n * @param sendContentLoaded - Whether to send a content loaded widget action immediately after initial setup.\n * Set to `false` if the widget uses `waitForIFrameLoad=true` (in this case the client does not expect a content loaded action at all),\n * or if the the widget wants to send the `ContentLoaded` action at a later point in time after the initial setup.\n */\n public constructor(\n private readonly widgetApi: WidgetApi,\n private readonly capabilities: ICapabilities,\n private readonly roomId: string,\n opts: IMatrixClientCreateOpts,\n sendContentLoaded: boolean,\n ) {\n super(opts);\n\n const transportSend = this.widgetApi.transport.send.bind(this.widgetApi.transport);\n this.widgetApi.transport.send = async <\n T extends IWidgetApiRequestData,\n R extends IWidgetApiResponseData = IWidgetApiAcknowledgeResponseData,\n >(\n action: WidgetApiAction,\n data: T,\n ): Promise<R> => {\n try {\n return await transportSend(action, data);\n } catch (error) {\n processAndThrow(error);\n }\n };\n\n const transportSendComplete = this.widgetApi.transport.sendComplete.bind(this.widgetApi.transport);\n this.widgetApi.transport.sendComplete = async <T extends IWidgetApiRequestData, R extends IWidgetApiResponse>(\n action: WidgetApiAction,\n data: T,\n ): Promise<R> => {\n try {\n return await transportSendComplete(action, data);\n } catch (error) {\n processAndThrow(error);\n }\n };\n\n this.widgetApiReady = new Promise<void>((resolve) => this.widgetApi.once(\"ready\", resolve));\n\n // Request capabilities for the functionality this client needs to support\n if (\n capabilities.sendEvent?.length ||\n capabilities.receiveEvent?.length ||\n capabilities.sendMessage === true ||\n (Array.isArray(capabilities.sendMessage) && capabilities.sendMessage.length) ||\n capabilities.receiveMessage === true ||\n (Array.isArray(capabilities.receiveMessage) && capabilities.receiveMessage.length) ||\n capabilities.sendState?.length ||\n capabilities.receiveState?.length\n ) {\n widgetApi.requestCapabilityForRoomTimeline(roomId);\n }\n capabilities.sendEvent?.forEach((eventType) => widgetApi.requestCapabilityToSendEvent(eventType));\n capabilities.receiveEvent?.forEach((eventType) => widgetApi.requestCapabilityToReceiveEvent(eventType));\n if (capabilities.sendMessage === true) {\n widgetApi.requestCapabilityToSendMessage();\n } else if (Array.isArray(capabilities.sendMessage)) {\n capabilities.sendMessage.forEach((msgType) => widgetApi.requestCapabilityToSendMessage(msgType));\n }\n if (capabilities.receiveMessage === true) {\n widgetApi.requestCapabilityToReceiveMessage();\n } else if (Array.isArray(capabilities.receiveMessage)) {\n capabilities.receiveMessage.forEach((msgType) => widgetApi.requestCapabilityToReceiveMessage(msgType));\n }\n capabilities.sendState?.forEach(({ eventType, stateKey }) =>\n widgetApi.requestCapabilityToSendState(eventType, stateKey),\n );\n capabilities.receiveState?.forEach(({ eventType, stateKey }) =>\n widgetApi.requestCapabilityToReceiveState(eventType, stateKey),\n );\n capabilities.sendToDevice?.forEach((eventType) => widgetApi.requestCapabilityToSendToDevice(eventType));\n capabilities.receiveToDevice?.forEach((eventType) => widgetApi.requestCapabilityToReceiveToDevice(eventType));\n if (\n capabilities.sendDelayedEvents &&\n (capabilities.sendEvent?.length ||\n capabilities.sendMessage === true ||\n (Array.isArray(capabilities.sendMessage) && capabilities.sendMessage.length) ||\n capabilities.sendState?.length)\n ) {\n widgetApi.requestCapability(MatrixCapabilities.MSC4157SendDelayedEvent);\n }\n if (capabilities.updateDelayedEvents) {\n widgetApi.requestCapability(MatrixCapabilities.MSC4157UpdateDelayedEvent);\n }\n if (capabilities.turnServers) {\n widgetApi.requestCapability(MatrixCapabilities.MSC3846TurnServers);\n }\n\n widgetApi.on(`action:${WidgetApiToWidgetAction.SendEvent}`, this.onEvent);\n widgetApi.on(`action:${WidgetApiToWidgetAction.SendToDevice}`, this.onToDevice);\n\n // Open communication with the host\n widgetApi.start();\n // Send a content loaded event now we've started the widget API\n // Note that element-web currently does not use waitForIFrameLoad=false and so\n // does *not* (yes, that is the right way around) wait for this event. Let's\n // start sending this, then once this has rolled out, we can change element-web to\n // use waitForIFrameLoad=false and have a widget API that's less racy.\n if (sendContentLoaded) widgetApi.sendContentLoaded();\n }\n\n public async startClient(opts: IStartClientOpts = {}): Promise<void> {\n this.lifecycle = new AbortController();\n\n // Create our own user object artificially (instead of waiting for sync)\n // so it's always available, even if the user is not in any rooms etc.\n const userId = this.getUserId();\n if (userId) {\n this.store.storeUser(new User(userId));\n }\n\n // Even though we have no access token and cannot sync, the sync class\n // still has some valuable helper methods that we make use of, so we\n // instantiate it anyways\n if (opts.slidingSync) {\n this.syncApi = new SlidingSyncSdk(opts.slidingSync, this, opts);\n } else {\n this.syncApi = new SyncApi(this, opts, this.buildSyncApiOptions());\n }\n\n this.room = this.syncApi.createRoom(this.roomId);\n this.store.storeRoom(this.room);\n\n await this.widgetApiReady;\n\n // Backfill the requested events\n // We only get the most recent event for every type + state key combo,\n // so it doesn't really matter what order we inject them in\n await Promise.all(\n this.capabilities.receiveState?.map(async ({ eventType, stateKey }) => {\n const rawEvents = await this.widgetApi.readStateEvents(eventType, undefined, stateKey, [this.roomId]);\n const events = rawEvents.map((rawEvent) => new MatrixEvent(rawEvent as Partial<IEvent>));\n\n await this.syncApi!.injectRoomEvents(this.room!, [], events);\n events.forEach((event) => {\n this.emit(ClientEvent.Event, event);\n logger.info(`Backfilled event ${event.getId()} ${event.getType()} ${event.getStateKey()}`);\n });\n }) ?? [],\n );\n\n if (opts.clientWellKnownPollPeriod !== undefined) {\n this.clientWellKnownIntervalID = setInterval(() => {\n this.fetchClientWellKnown();\n }, 1000 * opts.clientWellKnownPollPeriod);\n this.fetchClientWellKnown();\n }\n\n this.setSyncState(SyncState.Syncing);\n logger.info(\"Finished backfilling events\");\n }\n\n public stopClient(): void {\n this.widgetApi.off(`action:${WidgetApiToWidgetAction.SendEvent}`, this.onEvent);\n this.widgetApi.off(`action:${WidgetApiToWidgetAction.SendToDevice}`, this.onToDevice);\n\n super.stopClient();\n this.lifecycle!.abort(); // Signal to other async tasks that the client has stopped\n }\n\n public async joinRoom(roomIdOrAlias: string): Promise<Room> {\n if (roomIdOrAlias === this.roomId) return this.room!;\n throw new Error(`Unknown room: ${roomIdOrAlias}`);\n }\n\n public async sendStateEvent(\n roomId: string,\n eventType: string,\n content: any,\n stateKey = \"\",\n ): Promise<ISendEventResponse> {\n const response = await this.widgetApi.sendStateEvent(eventType, stateKey, content, roomId);\n if (response.event_id === undefined) {\n throw new Error(\"'event_id' absent from response to an event request\");\n }\n return { event_id: response.event_id };\n }\n\n /**\n * @experimental This currently relies on an unstable MSC (MSC4140).\n */\n // eslint-disable-next-line\n public async _unstable_sendDelayedStateEvent<K extends keyof StateEvents>(\n roomId: string,\n delayOpts: SendDelayedEventRequestOpts,\n eventType: K,\n content: StateEvents[K],\n stateKey = \"\",\n ): Promise<SendDelayedEventResponse> {\n if (!(await this.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {\n throw Error(\"Server does not support the delayed events API\");\n }\n\n const response = await this.widgetApi.sendStateEvent(\n eventType,\n stateKey,\n content,\n roomId,\n \"delay\" in delayOpts ? delayOpts.delay : undefined,\n \"parent_delay_id\" in delayOpts ? delayOpts.parent_delay_id : undefined,\n );\n return this.validateSendDelayedEventResponse(response);\n }\n\n private validateSendDelayedEventResponse(response: ISendEventFromWidgetResponseData): SendDelayedEventResponse {\n if (response.delay_id === undefined) {\n throw new Error(\"'delay_id' absent from response to a delayed event request\");\n }\n return { delay_id: response.delay_id };\n }\n\n /**\n * @experimental This currently relies on an unstable MSC (MSC4140).\n */\n // eslint-disable-next-line\n public async _unstable_updateDelayedEvent(delayId: string, action: UpdateDelayedEventAction): Promise<{}> {\n if (!(await this.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {\n throw Error(\"Server does not support the delayed events API\");\n }\n\n return await this.widgetApi.updateDelayedEvent(delayId, action);\n }\n\n public async sendToDevice(eventType: string, contentMap: SendToDeviceContentMap): Promise<{}> {\n await this.widgetApi.sendToDevice(eventType, false, recursiveMapToObject(contentMap));\n return {};\n }\n\n public async getOpenIdToken(): Promise<IOpenIDToken> {\n const token = await this.widgetApi.requestOpenIDConnectToken();\n // the IOpenIDCredentials from the widget-api and IOpenIDToken form the matrix-js-sdk are compatible.\n // we still recreate the token to make this transparent and catch'able by the linter in case the types change in the future.\n return <IOpenIDToken>{\n access_token: token.access_token,\n expires_in: token.expires_in,\n matrix_server_name: token.matrix_server_name,\n token_type: token.token_type,\n };\n }\n\n public async queueToDevice({ eventType, batch }: ToDeviceBatch): Promise<void> {\n // map: user Id → device Id → payload\n const contentMap: MapWithDefault<string, Map<string, ToDevicePayload>> = new MapWithDefault(() => new Map());\n for (const { userId, deviceId, payload } of batch) {\n contentMap.getOrCreate(userId).set(deviceId, payload);\n }\n\n await this.widgetApi.sendToDevice(eventType, false, recursiveMapToObject(contentMap));\n }\n\n // Overridden since we 'sync' manually without the sync API\n public getSyncState(): SyncState | null {\n return this.syncState;\n }\n\n private setSyncState(state: SyncState): void {\n const oldState = this.syncState;\n this.syncState = state;\n this.emit(ClientEvent.Sync, state, oldState);\n }\n\n private async ack(ev: CustomEvent<IWidgetApiRequest>): Promise<void> {\n await this.widgetApi.transport.reply<IWidgetApiAcknowledgeResponseData>(ev.detail, {});\n }\n\n private updateTxId = async (event: MatrixEvent): Promise<void> => {\n // We update the txId for remote echos that originate from this client.\n // This happens with the help of `pendingSendingEventsTxId` where we store all events that are currently sending\n // with their widget txId and once ready the final evId.\n if (\n // This could theoretically be an event send by this device\n // In that case we need to update the txId of the event because the embedded client/widget\n // knows this event with a different transaction Id than what was used by the host client.\n event.getSender() === this.getUserId() &&\n // We optimize by not blocking events from types that we have not send\n // with this client.\n this.pendingSendingEventsTxId.some((p) => event.getType() === p.type)\n ) {\n // Compare by event Id if we have a matching pending event where we know the txId.\n let matchingTxId = this.pendingSendingEventsTxId.find((p) => p.id === event.getId())?.txId;\n // Block any further processing of this event until we have received the sending response.\n // -> until we know the event id.\n // -> until we have not pending events anymore.\n while (!matchingTxId && this.pendingSendingEventsTxId.length > 0) {\n // Recheck whenever the PendingEventsChanged\n await new Promise<void>((resolve) =>\n this.eventEmitter.once(RoomWidgetClientEvent.PendingEventsChanged, () => resolve()),\n );\n matchingTxId = this.pendingSendingEventsTxId.find((p) => p.id === event.getId())?.txId;\n }\n\n // We found the correct txId: we update the event and delete the entry of the pending events.\n if (matchingTxId) {\n event.setTxnId(matchingTxId);\n event.setUnsigned({ ...event.getUnsigned(), transaction_id: matchingTxId });\n }\n this.pendingSendingEventsTxId = this.pendingSendingEventsTxId.filter((p) => p.id !== event.getId());\n\n // Emit once there are no pending events anymore to release all other events that got\n // awaited in the `while (!matchingTxId && this.pendingSendingEventsTxId.length > 0)` loop\n // but are not send by this client.\n if (this.pendingSendingEventsTxId.length === 0) {\n this.eventEmitter.emit(RoomWidgetClientEvent.PendingEventsChanged);\n }\n }\n };\n\n private onEvent = async (ev: CustomEvent<ISendEventToWidgetActionRequest>): Promise<void> => {\n ev.preventDefault();\n\n // Verify the room ID matches, since it's possible for the client to\n // send us events from other rooms if this widget is always on screen\n if (ev.detail.data.room_id === this.roomId) {\n const event = new MatrixEvent(ev.detail.data as Partial<IEvent>);\n\n // Only inject once we have update the txId\n await this.updateTxId(event);\n await this.syncApi!.injectRoomEvents(this.room!, [], [event]);\n this.emit(ClientEvent.Event, event);\n this.setSyncState(SyncState.Syncing);\n logger.info(`Received event ${event.getId()} ${event.getType()} ${event.getStateKey()}`);\n } else {\n const { event_id: eventId, room_id: roomId } = ev.detail.data;\n logger.info(`Received event ${eventId} for a different room ${roomId}; discarding`);\n }\n\n await this.ack(ev);\n };\n\n private onToDevice = async (ev: CustomEvent<ISendToDeviceToWidgetActionRequest>): Promise<void> => {\n ev.preventDefault();\n\n const event = new MatrixEvent({\n type: ev.detail.data.type,\n sender: ev.detail.data.sender,\n content: ev.detail.data.content as IContent,\n });\n\n this.emit(ClientEvent.ToDeviceEvent, event);\n this.setSyncState(SyncState.Syncing);\n await this.ack(ev);\n };\n}\n\nfunction processAndThrow(error: unknown): never {\n if (error instanceof WidgetApiResponseError && error.data.matrix_api_error) {\n throw MatrixError.fromWidgetApiErrorData(error.data.matrix_api_error);\n } else {\n throw error;\n }\n}\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAEIA,uBAAuB,EACvBC,sBAAsB,EACtBC,kBAAkB,QAUf,mBAAmB;AAE1B,SAASC,WAAW,QAA0B,mBAAmB;AAQjE,SAASC,MAAM,QAAQ,aAAa;AACpC,SACIC,YAAY,EAC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AAW,CAAC2N,sBAAsB,CAAC/H,KAAK,CAAC3B,IAAI,CAACyJ,gBAAgB,CAAC;EACzE,CAAC,MAAM;IACH,MAAM9H,KAAK;EACf;AACJ","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"event-mapper.d.ts","sourceRoot":"","sources":["../src/event-mapper.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAoB,MAAM,mBAAmB,CAAC;AAG1E,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,WAAW,CAAC;AAEhE,MAAM,WAAW,UAAU;IAEvB,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,GAAG,WAAW,
|
1
|
+
{"version":3,"file":"event-mapper.d.ts","sourceRoot":"","sources":["../src/event-mapper.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAoB,MAAM,mBAAmB,CAAC;AAG1E,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,WAAW,CAAC;AAEhE,MAAM,WAAW,UAAU;IAEvB,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,GAAG,WAAW,CA6DrF"}
|
package/lib/event-mapper.js
CHANGED
@@ -21,7 +21,6 @@ import { MatrixEvent, MatrixEventEvent } from "./models/event.js";
|
|
21
21
|
import { RelationType } from "./@types/event.js";
|
22
22
|
export function eventMapperFor(client, options) {
|
23
23
|
var preventReEmit = Boolean(options.preventReEmit);
|
24
|
-
var decrypt = options.decrypt !== false;
|
25
24
|
function mapper(plainOldJsObject) {
|
26
25
|
if (options.toDevice) {
|
27
26
|
delete plainOldJsObject.room_id;
|
@@ -66,9 +65,6 @@ export function eventMapperFor(client, options) {
|
|
66
65
|
if (!preventReEmit) {
|
67
66
|
client.reEmitter.reEmit(event, [MatrixEventEvent.Decrypted]);
|
68
67
|
}
|
69
|
-
if (decrypt) {
|
70
|
-
client.decryptEventIfNeeded(event);
|
71
|
-
}
|
72
68
|
}
|
73
69
|
if (!preventReEmit) {
|
74
70
|
client.reEmitter.reEmit(event, [MatrixEventEvent.Replaced, MatrixEventEvent.VisibilityChange]);
|