@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/client.js
CHANGED
@@ -29,30 +29,24 @@ import { EventStatus, MatrixEvent, MatrixEventEvent } from "./models/event.js";
|
|
29
29
|
import { StubStore } from "./store/stub.js";
|
30
30
|
import { Filter } from "./filter.js";
|
31
31
|
import * as utils from "./utils.js";
|
32
|
-
import { noUnsafeEventProps, replaceParam,
|
32
|
+
import { noUnsafeEventProps, replaceParam, sleep } from "./utils.js";
|
33
33
|
import { Direction, EventTimeline } from "./models/event-timeline.js";
|
34
34
|
import { PushProcessor } from "./pushprocessor.js";
|
35
35
|
import { AutoDiscovery } from "./autodiscovery.js";
|
36
|
-
import
|
37
|
-
import { decodeBase64, encodeBase64, encodeUnpaddedBase64Url } from "./base64.js";
|
36
|
+
import { encodeUnpaddedBase64Url } from "./base64.js";
|
38
37
|
import { TypedReEmitter } from "./ReEmitter.js";
|
39
38
|
import { logger } from "./logger.js";
|
40
39
|
import { SERVICE_TYPES } from "./service-types.js";
|
41
40
|
import { ClientPrefix, IdentityPrefix, MatrixError, MatrixHttpApi, MediaPrefix, Method, retryNetworkOperation } from "./http-api/index.js";
|
42
|
-
import { Crypto, CryptoEvent as LegacyCryptoEvent, fixBackupKey } from "./crypto/index.js";
|
43
41
|
import { User, UserEvent } from "./models/user.js";
|
44
42
|
import { getHttpUriForMxc } from "./content-repo.js";
|
45
43
|
import { SearchResult } from "./models/search-result.js";
|
46
|
-
import { DEHYDRATION_ALGORITHM } from "./crypto/dehydration.js";
|
47
|
-
import { CrossSigningKey } from "./crypto/api.js";
|
48
44
|
import * as ContentHelpers from "./content-helpers.js";
|
49
45
|
import { NotificationCountType } from "./models/room.js";
|
50
|
-
import { RoomMemberEvent } from "./models/room-member.js";
|
51
46
|
import { EventType, LOCAL_NOTIFICATION_SETTINGS_PREFIX, MSC3912_RELATION_BASED_REDACTIONS_PROP, MsgType, PUSHER_ENABLED, RelationType, RoomCreateTypeField, RoomType, UNSTABLE_MSC3088_ENABLED, UNSTABLE_MSC3088_PURPOSE, UNSTABLE_MSC3089_TREE_SUBTYPE } from "./@types/event.js";
|
52
47
|
import { GuestAccess, HistoryVisibility, Preset } from "./@types/partials.js";
|
53
48
|
import { eventMapperFor } from "./event-mapper.js";
|
54
49
|
import { randomString } from "./randomstring.js";
|
55
|
-
import { BackupManager } from "./crypto/backup.js";
|
56
50
|
import { DEFAULT_TREE_POWER_LEVELS_TEMPLATE, MSC3089TreeSpace } from "./models/MSC3089TreeSpace.js";
|
57
51
|
import { SearchOrderBy } from "./@types/search.js";
|
58
52
|
import { PushRuleActionName, PushRuleKind } from "./@types/PushRules.js";
|
@@ -65,17 +59,11 @@ import { NamespacedValue, UnstableValue } from "./NamespacedValue.js";
|
|
65
59
|
import { ToDeviceMessageQueue } from "./ToDeviceMessageQueue.js";
|
66
60
|
import { IgnoredInvites } from "./models/invites-ignorer.js";
|
67
61
|
import { buildFeatureSupportMap, Feature, ServerSupport } from "./feature.js";
|
68
|
-
import { RUST_SDK_STORE_PREFIX } from "./rust-crypto/constants.js";
|
69
|
-
import { decodeRecoveryKey, CryptoEvent } from "./crypto-api/index.js";
|
70
|
-
import { ServerSideSecretStorageImpl } from "./secret-storage.js";
|
71
62
|
import { getRelationsThreadFilter } from "./thread-utils.js";
|
72
63
|
import { KnownMembership } from "./@types/membership.js";
|
73
64
|
import { ServerCapabilities } from "./serverCapabilities.js";
|
74
65
|
import { sha256 } from "./digest.js";
|
75
|
-
import { keyFromAuthData } from "./common-crypto/key-passphrase.js";
|
76
66
|
var SCROLLBACK_DELAY_MS = 3000;
|
77
|
-
var TURN_CHECK_INTERVAL = 10 * 60 * 1000; // poll for turn credentials every 10 minutes
|
78
|
-
|
79
67
|
export var UNSTABLE_MSC3852_LAST_SEEN_UA = new UnstableValue("last_seen_user_agent", "org.matrix.msc3852.last_seen_user_agent");
|
80
68
|
export var PendingEventOrdering = /*#__PURE__*/function (PendingEventOrdering) {
|
81
69
|
PendingEventOrdering["Chronological"] = "chronological";
|
@@ -88,16 +76,14 @@ export var UNSTABLE_MSC2666_MUTUAL_ROOMS = "uk.half-shot.msc2666.mutual_rooms";
|
|
88
76
|
export var UNSTABLE_MSC2666_QUERY_MUTUAL_ROOMS = "uk.half-shot.msc2666.query_mutual_rooms";
|
89
77
|
export var UNSTABLE_MSC4140_DELAYED_EVENTS = "org.matrix.msc4140";
|
90
78
|
export var UNSTABLE_MSC4133_EXTENDED_PROFILES = "uk.tcpip.msc4133";
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
CrossSigningKeyType["UserSigningKey"] = "user_signing_key";
|
95
|
-
return CrossSigningKeyType;
|
96
|
-
}(CrossSigningKeyType || {}); // Re-export for backwards compatibility
|
79
|
+
|
80
|
+
// Re-export for backwards compatibility
|
81
|
+
|
97
82
|
/**
|
98
83
|
* The summary of a room as defined by an initial version of MSC3266 and implemented in Synapse
|
99
84
|
* Proposed at https://github.com/matrix-org/matrix-doc/pull/3266
|
100
85
|
*/
|
86
|
+
|
101
87
|
/* eslint-enable camelcase */
|
102
88
|
|
103
89
|
// We're using this constant for methods overloading and inspect whether a variable
|
@@ -129,7 +115,7 @@ var SSO_ACTION_PARAM = new UnstableValue("action", "org.matrix.msc3824.action");
|
|
129
115
|
*/
|
130
116
|
export class MatrixClient extends TypedEventEmitter {
|
131
117
|
constructor(opts) {
|
132
|
-
var _opts$logger, _opts$usingExternalCr, _this
|
118
|
+
var _opts$logger, _opts$usingExternalCr, _this;
|
133
119
|
// If a custom logger is provided, use it. Otherwise, default to the global
|
134
120
|
// one in logger.ts.
|
135
121
|
super();
|
@@ -159,22 +145,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
159
145
|
_defineProperty(this, "identityServer", void 0);
|
160
146
|
_defineProperty(this, "http", void 0);
|
161
147
|
// XXX: Intended private, used in code.
|
162
|
-
/**
|
163
|
-
* The libolm crypto implementation, if it is in use.
|
164
|
-
*
|
165
|
-
* @deprecated This should not be used. Instead, use the methods exposed directly on this class or
|
166
|
-
* (where they are available) via {@link getCrypto}.
|
167
|
-
*/
|
168
|
-
_defineProperty(this, "crypto", void 0);
|
169
|
-
// XXX: Intended private, used in code. Being replaced by cryptoBackend
|
170
|
-
_defineProperty(this, "cryptoBackend", void 0);
|
171
|
-
// one of crypto or rustCrypto
|
172
|
-
_defineProperty(this, "cryptoCallbacks", void 0);
|
173
|
-
// XXX: Intended private, used in code.
|
174
|
-
_defineProperty(this, "supportsCallTransfer", false);
|
175
|
-
// XXX: Intended private, used in code.
|
176
|
-
_defineProperty(this, "forceTURN", false);
|
177
|
-
// XXX: Intended private, used in code.
|
178
148
|
_defineProperty(this, "iceCandidatePoolSize", 0);
|
179
149
|
// XXX: Intended private, used in code.
|
180
150
|
_defineProperty(this, "idBaseUrl", void 0);
|
@@ -183,13 +153,11 @@ export class MatrixClient extends TypedEventEmitter {
|
|
183
153
|
_defineProperty(this, "useLivekitForGroupCalls", void 0);
|
184
154
|
// Note: these are all `protected` to let downstream consumers make mistakes if they want to.
|
185
155
|
// We don't technically support this usage, but have reasons to do this.
|
186
|
-
_defineProperty(this, "canSupportVoip", false);
|
187
156
|
_defineProperty(this, "peekSync", null);
|
188
157
|
_defineProperty(this, "isGuestAccount", false);
|
189
158
|
_defineProperty(this, "ongoingScrollbacks", {});
|
190
159
|
_defineProperty(this, "notifTimelineSet", null);
|
191
160
|
/* @deprecated */
|
192
|
-
_defineProperty(this, "cryptoStore", void 0);
|
193
161
|
_defineProperty(this, "verificationMethods", void 0);
|
194
162
|
_defineProperty(this, "fallbackICEServerAllowed", false);
|
195
163
|
_defineProperty(this, "syncApi", void 0);
|
@@ -208,10 +176,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
208
176
|
_defineProperty(this, "serverVersionsPromise", void 0);
|
209
177
|
_defineProperty(this, "clientWellKnown", void 0);
|
210
178
|
_defineProperty(this, "clientWellKnownPromise", void 0);
|
211
|
-
_defineProperty(this, "turnServers", []);
|
212
|
-
_defineProperty(this, "turnServersExpiry", 0);
|
213
|
-
_defineProperty(this, "checkTurnServersIntervalID", void 0);
|
214
|
-
_defineProperty(this, "exportedOlmDeviceToImport", void 0);
|
215
179
|
_defineProperty(this, "txnCtr", 0);
|
216
180
|
_defineProperty(this, "sessionId", void 0);
|
217
181
|
/** IDs of events which are currently being encrypted.
|
@@ -220,10 +184,8 @@ export class MatrixClient extends TypedEventEmitter {
|
|
220
184
|
* that tells us that it has been cancelled, and we should not send it.
|
221
185
|
*/
|
222
186
|
_defineProperty(this, "eventsBeingEncrypted", new Set());
|
223
|
-
_defineProperty(this, "useE2eForGroupCall", true);
|
224
187
|
_defineProperty(this, "toDeviceMessageQueue", void 0);
|
225
188
|
_defineProperty(this, "livekitServiceURL", void 0);
|
226
|
-
_defineProperty(this, "_secretStorage", void 0);
|
227
189
|
// A manager for determining which invites should be ignored.
|
228
190
|
_defineProperty(this, "ignoredInvites", void 0);
|
229
191
|
_defineProperty(this, "serverCapabilitiesService", void 0);
|
@@ -288,8 +250,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
288
250
|
} else {
|
289
251
|
this.deviceId = opts.deviceToImport.deviceId;
|
290
252
|
this.credentials.userId = opts.deviceToImport.userId;
|
291
|
-
// will be used during async initialization of the crypto
|
292
|
-
this.exportedOlmDeviceToImport = opts.deviceToImport.olmDevice;
|
293
253
|
}
|
294
254
|
} else if (opts.pickleKey) {
|
295
255
|
this.pickleKey = opts.pickleKey;
|
@@ -319,28 +279,14 @@ export class MatrixClient extends TypedEventEmitter {
|
|
319
279
|
this.serverCapabilitiesService = new ServerCapabilities(this.http);
|
320
280
|
this.on(ClientEvent.Sync, this.fixupRoomNotifications);
|
321
281
|
this.timelineSupport = Boolean(opts.timelineSupport);
|
322
|
-
this.cryptoStore = opts.cryptoStore;
|
323
282
|
this.verificationMethods = opts.verificationMethods;
|
324
|
-
this.cryptoCallbacks = opts.cryptoCallbacks || {};
|
325
|
-
this.forceTURN = opts.forceTURN || false;
|
326
283
|
this.iceCandidatePoolSize = opts.iceCandidatePoolSize === undefined ? 0 : opts.iceCandidatePoolSize;
|
327
|
-
this.supportsCallTransfer = opts.supportsCallTransfer || false;
|
328
284
|
this.fallbackICEServerAllowed = opts.fallbackICEServerAllowed || false;
|
329
285
|
this.isVoipWithNoMediaAllowed = opts.isVoipWithNoMediaAllowed || false;
|
330
|
-
if (opts.useE2eForGroupCall !== undefined) this.useE2eForGroupCall = opts.useE2eForGroupCall;
|
331
286
|
this.livekitServiceURL = opts.livekitServiceURL;
|
332
287
|
this.roomNameGenerator = opts.roomNameGenerator;
|
333
288
|
this.toDeviceMessageQueue = new ToDeviceMessageQueue(this);
|
334
|
-
|
335
|
-
// The SDK doesn't really provide a clean way for events to recalculate the push
|
336
|
-
// actions for themselves, so we have to kinda help them out when they are encrypted.
|
337
|
-
// We do this so that push rules are correctly executed on events in their decrypted
|
338
|
-
// state, such as highlights when the user's name is mentioned.
|
339
|
-
this.on(MatrixEventEvent.Decrypted, event => {
|
340
|
-
fixNotificationCountOnDecryption(this, event);
|
341
|
-
});
|
342
289
|
this.ignoredInvites = new IgnoredInvites(this);
|
343
|
-
this._secretStorage = new ServerSideSecretStorageImpl(this, (_opts$cryptoCallbacks = opts.cryptoCallbacks) !== null && _opts$cryptoCallbacks !== void 0 ? _opts$cryptoCallbacks : {});
|
344
290
|
|
345
291
|
// having lots of event listeners is not unusual. 0 means "unlimited".
|
346
292
|
this.setMaxListeners(0);
|
@@ -375,15 +321,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
375
321
|
if (userId) {
|
376
322
|
_this2.store.storeUser(new User(userId));
|
377
323
|
}
|
378
|
-
|
379
|
-
// periodically poll for turn servers if we support voip
|
380
|
-
if (_this2.canSupportVoip) {
|
381
|
-
_this2.checkTurnServersIntervalID = setInterval(() => {
|
382
|
-
_this2.checkTurnServers();
|
383
|
-
}, TURN_CHECK_INTERVAL);
|
384
|
-
// noinspection ES6MissingAwait
|
385
|
-
_this2.checkTurnServers();
|
386
|
-
}
|
387
324
|
if (_this2.syncApi) {
|
388
325
|
// This shouldn't happen since we thought the client was not running
|
389
326
|
_this2.logger.error("Still have sync object whilst not running: stopping old one");
|
@@ -407,7 +344,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
407
344
|
}
|
408
345
|
_this2.clientOpts = opts !== null && opts !== void 0 ? opts : {};
|
409
346
|
if (_this2.clientOpts.slidingSync) {
|
410
|
-
_this2.syncApi = new SlidingSyncSdk(_this2.clientOpts.slidingSync, _this2, _this2.clientOpts
|
347
|
+
_this2.syncApi = new SlidingSyncSdk(_this2.clientOpts.slidingSync, _this2, _this2.clientOpts);
|
411
348
|
} else {
|
412
349
|
_this2.syncApi = new SyncApi(_this2, _this2.clientOpts, _this2.buildSyncApiOptions());
|
413
350
|
}
|
@@ -428,8 +365,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
428
365
|
*/
|
429
366
|
buildSyncApiOptions() {
|
430
367
|
return {
|
431
|
-
crypto: this.crypto,
|
432
|
-
cryptoCallbacks: this.cryptoBackend,
|
433
368
|
canResetEntireTimeline: roomId => {
|
434
369
|
if (!this.canResetTimelineCallback) {
|
435
370
|
return false;
|
@@ -444,9 +379,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
444
379
|
* clean shutdown.
|
445
380
|
*/
|
446
381
|
stopClient() {
|
447
|
-
var _this$
|
448
|
-
(_this$cryptoBackend = this.cryptoBackend) === null || _this$cryptoBackend === void 0 || _this$cryptoBackend.stop(); // crypto might have been initialised even if the client wasn't fully started
|
449
|
-
|
382
|
+
var _this$syncApi, _this$peekSync;
|
450
383
|
if (!this.clientRunning) return; // already stopped
|
451
384
|
|
452
385
|
this.logger.debug("stopping MatrixClient");
|
@@ -454,8 +387,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
454
387
|
(_this$syncApi = this.syncApi) === null || _this$syncApi === void 0 || _this$syncApi.stop();
|
455
388
|
this.syncApi = undefined;
|
456
389
|
(_this$peekSync = this.peekSync) === null || _this$peekSync === void 0 || _this$peekSync.stopPeeking();
|
457
|
-
globalThis.clearInterval(this.checkTurnServersIntervalID);
|
458
|
-
this.checkTurnServersIntervalID = undefined;
|
459
390
|
if (this.clientWellKnownIntervalID !== undefined) {
|
460
391
|
globalThis.clearInterval(this.clientWellKnownIntervalID);
|
461
392
|
}
|
@@ -463,219 +394,17 @@ export class MatrixClient extends TypedEventEmitter {
|
|
463
394
|
this.serverCapabilitiesService.stop();
|
464
395
|
}
|
465
396
|
|
466
|
-
/**
|
467
|
-
* Try to rehydrate a device if available. The client must have been
|
468
|
-
* initialized with a `cryptoCallback.getDehydrationKey` option, and this
|
469
|
-
* function must be called before initCrypto and startClient are called.
|
470
|
-
*
|
471
|
-
* @returns Promise which resolves to undefined if a device could not be dehydrated, or
|
472
|
-
* to the new device ID if the dehydration was successful.
|
473
|
-
* @returns Rejects: with an error response.
|
474
|
-
*
|
475
|
-
* @deprecated MSC2697 device dehydration is not supported for rust cryptography.
|
476
|
-
*/
|
477
|
-
rehydrateDevice() {
|
478
|
-
var _this3 = this;
|
479
|
-
return _asyncToGenerator(function* () {
|
480
|
-
if (_this3.crypto) {
|
481
|
-
throw new Error("Cannot rehydrate device after crypto is initialized");
|
482
|
-
}
|
483
|
-
if (!_this3.cryptoCallbacks.getDehydrationKey) {
|
484
|
-
return;
|
485
|
-
}
|
486
|
-
var getDeviceResult = yield _this3.getDehydratedDevice();
|
487
|
-
if (!getDeviceResult) {
|
488
|
-
return;
|
489
|
-
}
|
490
|
-
if (!getDeviceResult.device_data || !getDeviceResult.device_id) {
|
491
|
-
_this3.logger.info("no dehydrated device found");
|
492
|
-
return;
|
493
|
-
}
|
494
|
-
var account = new globalThis.Olm.Account();
|
495
|
-
try {
|
496
|
-
var deviceData = getDeviceResult.device_data;
|
497
|
-
if (deviceData.algorithm !== DEHYDRATION_ALGORITHM) {
|
498
|
-
_this3.logger.warn("Wrong algorithm for dehydrated device");
|
499
|
-
return;
|
500
|
-
}
|
501
|
-
_this3.logger.debug("unpickling dehydrated device");
|
502
|
-
var _key = yield _this3.cryptoCallbacks.getDehydrationKey(deviceData, k => {
|
503
|
-
// copy the key so that it doesn't get clobbered
|
504
|
-
account.unpickle(new Uint8Array(k), deviceData.account);
|
505
|
-
});
|
506
|
-
account.unpickle(_key, deviceData.account);
|
507
|
-
_this3.logger.debug("unpickled device");
|
508
|
-
var rehydrateResult = yield _this3.http.authedRequest(Method.Post, "/dehydrated_device/claim", undefined, {
|
509
|
-
device_id: getDeviceResult.device_id
|
510
|
-
}, {
|
511
|
-
prefix: "/_matrix/client/unstable/org.matrix.msc2697.v2"
|
512
|
-
});
|
513
|
-
if (rehydrateResult.success) {
|
514
|
-
_this3.deviceId = getDeviceResult.device_id;
|
515
|
-
_this3.logger.info("using dehydrated device");
|
516
|
-
var pickleKey = _this3.pickleKey || "DEFAULT_KEY";
|
517
|
-
_this3.exportedOlmDeviceToImport = {
|
518
|
-
pickledAccount: account.pickle(pickleKey),
|
519
|
-
sessions: [],
|
520
|
-
pickleKey: pickleKey
|
521
|
-
};
|
522
|
-
account.free();
|
523
|
-
return _this3.deviceId;
|
524
|
-
} else {
|
525
|
-
account.free();
|
526
|
-
_this3.logger.info("not using dehydrated device");
|
527
|
-
return;
|
528
|
-
}
|
529
|
-
} catch (e) {
|
530
|
-
account.free();
|
531
|
-
_this3.logger.warn("could not unpickle", e);
|
532
|
-
}
|
533
|
-
})();
|
534
|
-
}
|
535
|
-
|
536
|
-
/**
|
537
|
-
* Get the current dehydrated device, if any
|
538
|
-
* @returns A promise of an object containing the dehydrated device
|
539
|
-
*
|
540
|
-
* @deprecated MSC2697 device dehydration is not supported for rust cryptography.
|
541
|
-
*/
|
542
|
-
getDehydratedDevice() {
|
543
|
-
var _this4 = this;
|
544
|
-
return _asyncToGenerator(function* () {
|
545
|
-
try {
|
546
|
-
return yield _this4.http.authedRequest(Method.Get, "/dehydrated_device", undefined, undefined, {
|
547
|
-
prefix: "/_matrix/client/unstable/org.matrix.msc2697.v2"
|
548
|
-
});
|
549
|
-
} catch (e) {
|
550
|
-
_this4.logger.info("could not get dehydrated device", e);
|
551
|
-
return;
|
552
|
-
}
|
553
|
-
})();
|
554
|
-
}
|
555
|
-
|
556
|
-
/**
|
557
|
-
* Set the dehydration key. This will also periodically dehydrate devices to
|
558
|
-
* the server.
|
559
|
-
*
|
560
|
-
* @param key - the dehydration key
|
561
|
-
* @param keyInfo - Information about the key. Primarily for
|
562
|
-
* information about how to generate the key from a passphrase.
|
563
|
-
* @param deviceDisplayName - The device display name for the
|
564
|
-
* dehydrated device.
|
565
|
-
* @returns A promise that resolves when the dehydrated device is stored.
|
566
|
-
*
|
567
|
-
* @deprecated Not supported for Rust Cryptography.
|
568
|
-
*/
|
569
|
-
setDehydrationKey(key, keyInfo, deviceDisplayName) {
|
570
|
-
var _this5 = this;
|
571
|
-
return _asyncToGenerator(function* () {
|
572
|
-
if (!_this5.crypto) {
|
573
|
-
_this5.logger.warn("not dehydrating device if crypto is not enabled");
|
574
|
-
return;
|
575
|
-
}
|
576
|
-
return _this5.crypto.dehydrationManager.setKeyAndQueueDehydration(key, keyInfo, deviceDisplayName);
|
577
|
-
})();
|
578
|
-
}
|
579
|
-
|
580
|
-
/**
|
581
|
-
* Creates a new MSC2967 dehydrated device (without queuing periodic dehydration)
|
582
|
-
* @param key - the dehydration key
|
583
|
-
* @param keyInfo - Information about the key. Primarily for
|
584
|
-
* information about how to generate the key from a passphrase.
|
585
|
-
* @param deviceDisplayName - The device display name for the
|
586
|
-
* dehydrated device.
|
587
|
-
* @returns the device id of the newly created dehydrated device
|
588
|
-
*
|
589
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.startDehydration}.
|
590
|
-
*/
|
591
|
-
createDehydratedDevice(key, keyInfo, deviceDisplayName) {
|
592
|
-
var _this6 = this;
|
593
|
-
return _asyncToGenerator(function* () {
|
594
|
-
if (!_this6.crypto) {
|
595
|
-
_this6.logger.warn("not dehydrating device if crypto is not enabled");
|
596
|
-
return;
|
597
|
-
}
|
598
|
-
yield _this6.crypto.dehydrationManager.setKey(key, keyInfo, deviceDisplayName);
|
599
|
-
return _this6.crypto.dehydrationManager.dehydrateDevice();
|
600
|
-
})();
|
601
|
-
}
|
602
|
-
|
603
|
-
/** @deprecated Not supported for Rust Cryptography. */
|
604
|
-
exportDevice() {
|
605
|
-
var _this7 = this;
|
606
|
-
return _asyncToGenerator(function* () {
|
607
|
-
if (!_this7.crypto) {
|
608
|
-
_this7.logger.warn("not exporting device if crypto is not enabled");
|
609
|
-
return;
|
610
|
-
}
|
611
|
-
return {
|
612
|
-
userId: _this7.credentials.userId,
|
613
|
-
deviceId: _this7.deviceId,
|
614
|
-
// XXX: Private member access.
|
615
|
-
olmDevice: yield _this7.crypto.olmDevice.export()
|
616
|
-
};
|
617
|
-
})();
|
618
|
-
}
|
619
|
-
|
620
397
|
/**
|
621
398
|
* Clear any data out of the persistent stores used by the client.
|
622
399
|
*
|
623
400
|
* @returns Promise which resolves when the stores have been cleared.
|
624
401
|
*/
|
625
402
|
clearStores() {
|
626
|
-
var _this8 = this;
|
627
403
|
if (this.clientRunning) {
|
628
404
|
throw new Error("Cannot clear stores while client is running");
|
629
405
|
}
|
630
406
|
var promises = [];
|
631
407
|
promises.push(this.store.deleteAllData());
|
632
|
-
if (this.cryptoStore) {
|
633
|
-
promises.push(this.cryptoStore.deleteAllData());
|
634
|
-
}
|
635
|
-
|
636
|
-
// delete the stores used by the rust matrix-sdk-crypto, in case they were used
|
637
|
-
var deleteRustSdkStore = /*#__PURE__*/function () {
|
638
|
-
var _ref2 = _asyncToGenerator(function* () {
|
639
|
-
var indexedDB;
|
640
|
-
try {
|
641
|
-
indexedDB = globalThis.indexedDB;
|
642
|
-
if (!indexedDB) return; // No indexedDB support
|
643
|
-
} catch (_unused) {
|
644
|
-
// No indexedDB support
|
645
|
-
return;
|
646
|
-
}
|
647
|
-
var _loop = function* _loop(dbname) {
|
648
|
-
var prom = new Promise((resolve, reject) => {
|
649
|
-
_this8.logger.info("Removing IndexedDB instance ".concat(dbname));
|
650
|
-
var req = indexedDB.deleteDatabase(dbname);
|
651
|
-
req.onsuccess = _ => {
|
652
|
-
_this8.logger.info("Removed IndexedDB instance ".concat(dbname));
|
653
|
-
resolve(0);
|
654
|
-
};
|
655
|
-
req.onerror = e => {
|
656
|
-
// In private browsing, Firefox has a globalThis.indexedDB, but attempts to delete an indexeddb
|
657
|
-
// (even a non-existent one) fail with "DOMException: A mutation operation was attempted on a
|
658
|
-
// database that did not allow mutations."
|
659
|
-
//
|
660
|
-
// it seems like the only thing we can really do is ignore the error.
|
661
|
-
_this8.logger.warn("Failed to remove IndexedDB instance ".concat(dbname, ":"), e);
|
662
|
-
resolve(0);
|
663
|
-
};
|
664
|
-
req.onblocked = e => {
|
665
|
-
_this8.logger.info("cannot yet remove IndexedDB instance ".concat(dbname));
|
666
|
-
};
|
667
|
-
});
|
668
|
-
yield prom;
|
669
|
-
};
|
670
|
-
for (var dbname of ["".concat(RUST_SDK_STORE_PREFIX, "::matrix-sdk-crypto"), "".concat(RUST_SDK_STORE_PREFIX, "::matrix-sdk-crypto-meta")]) {
|
671
|
-
yield* _loop(dbname);
|
672
|
-
}
|
673
|
-
});
|
674
|
-
return function deleteRustSdkStore() {
|
675
|
-
return _ref2.apply(this, arguments);
|
676
|
-
};
|
677
|
-
}();
|
678
|
-
promises.push(deleteRustSdkStore());
|
679
408
|
return Promise.all(promises).then(); // .then to fix types
|
680
409
|
}
|
681
410
|
|
@@ -742,41 +471,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
742
471
|
getSessionId() {
|
743
472
|
return this.sessionId;
|
744
473
|
}
|
745
|
-
|
746
|
-
/**
|
747
|
-
* Check if the runtime environment supports VoIP calling.
|
748
|
-
* @returns True if VoIP is supported.
|
749
|
-
*/
|
750
|
-
supportsVoip() {
|
751
|
-
return this.canSupportVoip;
|
752
|
-
}
|
753
|
-
|
754
|
-
/**
|
755
|
-
* Set whether VoIP calls are forced to use only TURN
|
756
|
-
* candidates. This is the same as the forceTURN option
|
757
|
-
* when creating the client.
|
758
|
-
* @param force - True to force use of TURN servers
|
759
|
-
*/
|
760
|
-
setForceTURN(force) {
|
761
|
-
this.forceTURN = force;
|
762
|
-
}
|
763
|
-
|
764
|
-
/**
|
765
|
-
* Set whether to advertise transfer support to other parties on Matrix calls.
|
766
|
-
* @param support - True to advertise the 'm.call.transferee' capability
|
767
|
-
*/
|
768
|
-
setSupportsCallTransfer(support) {
|
769
|
-
this.supportsCallTransfer = support;
|
770
|
-
}
|
771
|
-
|
772
|
-
/**
|
773
|
-
* Returns true if to-device signalling for group calls will be encrypted with Olm.
|
774
|
-
* If false, it will be sent unencrypted.
|
775
|
-
* @returns boolean Whether group call signalling will be encrypted
|
776
|
-
*/
|
777
|
-
getUseE2eForGroupCall() {
|
778
|
-
return this.useE2eForGroupCall;
|
779
|
-
}
|
780
474
|
getLivekitServiceURL() {
|
781
475
|
return this.livekitServiceURL;
|
782
476
|
}
|
@@ -882,1879 +576,48 @@ export class MatrixClient extends TypedEventEmitter {
|
|
882
576
|
this.notifTimelineSet = set;
|
883
577
|
}
|
884
578
|
|
885
|
-
/**
|
886
|
-
* Gets the cached capabilities of the homeserver, returning cached ones if available.
|
887
|
-
* If there are no cached capabilities and none can be fetched, throw an exception.
|
888
|
-
*
|
889
|
-
* @returns Promise resolving with The capabilities of the homeserver
|
890
|
-
*/
|
891
|
-
getCapabilities() {
|
892
|
-
var
|
893
|
-
return _asyncToGenerator(function* () {
|
894
|
-
var caps =
|
895
|
-
if (caps) return caps;
|
896
|
-
return
|
897
|
-
})();
|
898
|
-
}
|
899
|
-
|
900
|
-
/**
|
901
|
-
* Gets the cached capabilities of the homeserver. If none have been fetched yet,
|
902
|
-
* return undefined.
|
903
|
-
*
|
904
|
-
* @returns The capabilities of the homeserver
|
905
|
-
*/
|
906
|
-
getCachedCapabilities() {
|
907
|
-
return this.serverCapabilitiesService.getCachedCapabilities();
|
908
|
-
}
|
909
|
-
|
910
|
-
/**
|
911
|
-
* Fetches the latest capabilities from the homeserver, ignoring any cached
|
912
|
-
* versions. The newly returned version is cached.
|
913
|
-
*
|
914
|
-
* @returns A promise which resolves to the capabilities of the homeserver
|
915
|
-
*/
|
916
|
-
fetchCapabilities() {
|
917
|
-
return this.serverCapabilitiesService.fetchCapabilities();
|
918
|
-
}
|
919
|
-
|
920
|
-
/**
|
921
|
-
* Initialise support for end-to-end encryption in this client, using libolm.
|
922
|
-
*
|
923
|
-
* You should call this method after creating the matrixclient, but *before*
|
924
|
-
* calling `startClient`, if you want to support end-to-end encryption.
|
925
|
-
*
|
926
|
-
* It will return a Promise which will resolve when the crypto layer has been
|
927
|
-
* successfully initialised.
|
928
|
-
*
|
929
|
-
* @deprecated libolm is deprecated. Prefer {@link initRustCrypto}.
|
930
|
-
*/
|
931
|
-
initCrypto() {
|
932
|
-
var _this10 = this;
|
933
|
-
return _asyncToGenerator(function* () {
|
934
|
-
if (_this10.cryptoBackend) {
|
935
|
-
_this10.logger.warn("Attempt to re-initialise e2e encryption on MatrixClient");
|
936
|
-
return;
|
937
|
-
}
|
938
|
-
if (!_this10.cryptoStore) {
|
939
|
-
// the cryptostore is provided by sdk.createClient, so this shouldn't happen
|
940
|
-
throw new Error("Cannot enable encryption: no cryptoStore provided");
|
941
|
-
}
|
942
|
-
_this10.logger.debug("Crypto: Starting up crypto store...");
|
943
|
-
yield _this10.cryptoStore.startup();
|
944
|
-
var userId = _this10.getUserId();
|
945
|
-
if (userId === null) {
|
946
|
-
throw new Error("Cannot enable encryption on MatrixClient with unknown userId: " + "ensure userId is passed in createClient().");
|
947
|
-
}
|
948
|
-
if (_this10.deviceId === null) {
|
949
|
-
throw new Error("Cannot enable encryption on MatrixClient with unknown deviceId: " + "ensure deviceId is passed in createClient().");
|
950
|
-
}
|
951
|
-
var crypto = new Crypto(_this10, userId, _this10.deviceId, _this10.store, _this10.cryptoStore, _this10.verificationMethods);
|
952
|
-
_this10.reEmitter.reEmit(crypto, [LegacyCryptoEvent.KeyBackupFailed, LegacyCryptoEvent.KeyBackupSessionsRemaining, LegacyCryptoEvent.RoomKeyRequest, LegacyCryptoEvent.RoomKeyRequestCancellation, LegacyCryptoEvent.Warning, LegacyCryptoEvent.DevicesUpdated, LegacyCryptoEvent.WillUpdateDevices, LegacyCryptoEvent.DeviceVerificationChanged, LegacyCryptoEvent.UserTrustStatusChanged, LegacyCryptoEvent.KeysChanged]);
|
953
|
-
_this10.logger.debug("Crypto: initialising crypto object...");
|
954
|
-
yield crypto.init({
|
955
|
-
exportedOlmDevice: _this10.exportedOlmDeviceToImport,
|
956
|
-
pickleKey: _this10.pickleKey
|
957
|
-
});
|
958
|
-
delete _this10.exportedOlmDeviceToImport;
|
959
|
-
_this10.olmVersion = Crypto.getOlmVersion();
|
960
|
-
|
961
|
-
// if crypto initialisation was successful, tell it to attach its event handlers.
|
962
|
-
crypto.registerEventHandlers(_this10);
|
963
|
-
_this10.cryptoBackend = _this10.crypto = crypto;
|
964
|
-
|
965
|
-
// upload our keys in the background
|
966
|
-
_this10.crypto.uploadDeviceKeys().catch(e => {
|
967
|
-
// TODO: throwing away this error is a really bad idea.
|
968
|
-
_this10.logger.error("Error uploading device keys", e);
|
969
|
-
});
|
970
|
-
})();
|
971
|
-
}
|
972
|
-
|
973
|
-
/**
|
974
|
-
* Initialise support for end-to-end encryption in this client, using the rust matrix-sdk-crypto.
|
975
|
-
*
|
976
|
-
* An alternative to {@link initCrypto}.
|
977
|
-
*
|
978
|
-
* @param args.useIndexedDB - True to use an indexeddb store, false to use an in-memory store. Defaults to 'true'.
|
979
|
-
* @param args.storageKey - A key with which to encrypt the indexeddb store. If provided, it must be exactly
|
980
|
-
* 32 bytes of data, and must be the same each time the client is initialised for a given device.
|
981
|
-
* If both this and `storagePassword` are unspecified, the store will be unencrypted.
|
982
|
-
* @param args.storagePassword - An alternative to `storageKey`. A password which will be used to derive a key to
|
983
|
-
* encrypt the store with. Deriving a key from a password is (deliberately) a slow operation, so prefer
|
984
|
-
* to pass a `storageKey` directly where possible.
|
985
|
-
*
|
986
|
-
* @returns a Promise which will resolve when the crypto layer has been
|
987
|
-
* successfully initialised.
|
988
|
-
*/
|
989
|
-
initRustCrypto() {
|
990
|
-
var _arguments = arguments,
|
991
|
-
_this11 = this;
|
992
|
-
return _asyncToGenerator(function* () {
|
993
|
-
var _this11$pickleKey;
|
994
|
-
var args = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : {};
|
995
|
-
if (_this11.cryptoBackend) {
|
996
|
-
_this11.logger.warn("Attempt to re-initialise e2e encryption on MatrixClient");
|
997
|
-
return;
|
998
|
-
}
|
999
|
-
var userId = _this11.getUserId();
|
1000
|
-
if (userId === null) {
|
1001
|
-
throw new Error("Cannot enable encryption on MatrixClient with unknown userId: " + "ensure userId is passed in createClient().");
|
1002
|
-
}
|
1003
|
-
var deviceId = _this11.getDeviceId();
|
1004
|
-
if (deviceId === null) {
|
1005
|
-
throw new Error("Cannot enable encryption on MatrixClient with unknown deviceId: " + "ensure deviceId is passed in createClient().");
|
1006
|
-
}
|
1007
|
-
|
1008
|
-
// importing rust-crypto will download the webassembly, so we delay it until we know it will be
|
1009
|
-
// needed.
|
1010
|
-
_this11.logger.debug("Downloading Rust crypto library");
|
1011
|
-
var RustCrypto = yield import("./rust-crypto/index.js");
|
1012
|
-
var rustCrypto = yield RustCrypto.initRustCrypto({
|
1013
|
-
logger: _this11.logger,
|
1014
|
-
http: _this11.http,
|
1015
|
-
userId: userId,
|
1016
|
-
deviceId: deviceId,
|
1017
|
-
secretStorage: _this11.secretStorage,
|
1018
|
-
cryptoCallbacks: _this11.cryptoCallbacks,
|
1019
|
-
storePrefix: args.useIndexedDB === false ? null : RUST_SDK_STORE_PREFIX,
|
1020
|
-
storeKey: args.storageKey,
|
1021
|
-
storePassphrase: args.storagePassword,
|
1022
|
-
legacyCryptoStore: _this11.cryptoStore,
|
1023
|
-
legacyPickleKey: (_this11$pickleKey = _this11.pickleKey) !== null && _this11$pickleKey !== void 0 ? _this11$pickleKey : "DEFAULT_KEY",
|
1024
|
-
legacyMigrationProgressListener: (progress, total) => {
|
1025
|
-
_this11.emit(CryptoEvent.LegacyCryptoStoreMigrationProgress, progress, total);
|
1026
|
-
}
|
1027
|
-
});
|
1028
|
-
rustCrypto.setSupportedVerificationMethods(_this11.verificationMethods);
|
1029
|
-
_this11.cryptoBackend = rustCrypto;
|
1030
|
-
|
1031
|
-
// attach the event listeners needed by RustCrypto
|
1032
|
-
_this11.on(RoomMemberEvent.Membership, rustCrypto.onRoomMembership.bind(rustCrypto));
|
1033
|
-
_this11.on(ClientEvent.Event, event => {
|
1034
|
-
rustCrypto.onLiveEventFromSync(event);
|
1035
|
-
});
|
1036
|
-
|
1037
|
-
// re-emit the events emitted by the crypto impl
|
1038
|
-
_this11.reEmitter.reEmit(rustCrypto, [CryptoEvent.VerificationRequestReceived, CryptoEvent.UserTrustStatusChanged, CryptoEvent.KeyBackupStatus, CryptoEvent.KeyBackupSessionsRemaining, CryptoEvent.KeyBackupFailed, CryptoEvent.KeyBackupDecryptionKeyCached, CryptoEvent.KeysChanged, CryptoEvent.DevicesUpdated, CryptoEvent.WillUpdateDevices]);
|
1039
|
-
})();
|
1040
|
-
}
|
1041
|
-
|
1042
|
-
/**
|
1043
|
-
* Access the server-side secret storage API for this client.
|
1044
|
-
*/
|
1045
|
-
get secretStorage() {
|
1046
|
-
return this._secretStorage;
|
1047
|
-
}
|
1048
|
-
|
1049
|
-
/**
|
1050
|
-
* Access the crypto API for this client.
|
1051
|
-
*
|
1052
|
-
* If end-to-end encryption has been enabled for this client (via {@link initCrypto} or {@link initRustCrypto}),
|
1053
|
-
* returns an object giving access to the crypto API. Otherwise, returns `undefined`.
|
1054
|
-
*/
|
1055
|
-
getCrypto() {
|
1056
|
-
return this.cryptoBackend;
|
1057
|
-
}
|
1058
|
-
|
1059
|
-
/**
|
1060
|
-
* Is end-to-end crypto enabled for this client.
|
1061
|
-
* @returns True if end-to-end is enabled.
|
1062
|
-
* @deprecated prefer {@link getCrypto}
|
1063
|
-
*/
|
1064
|
-
isCryptoEnabled() {
|
1065
|
-
return !!this.cryptoBackend;
|
1066
|
-
}
|
1067
|
-
|
1068
|
-
/**
|
1069
|
-
* Get the Ed25519 key for this device
|
1070
|
-
*
|
1071
|
-
* @returns base64-encoded ed25519 key. Null if crypto is
|
1072
|
-
* disabled.
|
1073
|
-
*
|
1074
|
-
* @deprecated Not supported for Rust Cryptography.Prefer {@link CryptoApi.getOwnDeviceKeys}
|
1075
|
-
*/
|
1076
|
-
getDeviceEd25519Key() {
|
1077
|
-
var _this$crypto$getDevic, _this$crypto;
|
1078
|
-
return (_this$crypto$getDevic = (_this$crypto = this.crypto) === null || _this$crypto === void 0 ? void 0 : _this$crypto.getDeviceEd25519Key()) !== null && _this$crypto$getDevic !== void 0 ? _this$crypto$getDevic : null;
|
1079
|
-
}
|
1080
|
-
|
1081
|
-
/**
|
1082
|
-
* Get the Curve25519 key for this device
|
1083
|
-
*
|
1084
|
-
* @returns base64-encoded curve25519 key. Null if crypto is
|
1085
|
-
* disabled.
|
1086
|
-
*
|
1087
|
-
* @deprecated Not supported for Rust Cryptography. Use {@link CryptoApi.getOwnDeviceKeys}
|
1088
|
-
*/
|
1089
|
-
getDeviceCurve25519Key() {
|
1090
|
-
var _this$crypto$getDevic2, _this$crypto2;
|
1091
|
-
return (_this$crypto$getDevic2 = (_this$crypto2 = this.crypto) === null || _this$crypto2 === void 0 ? void 0 : _this$crypto2.getDeviceCurve25519Key()) !== null && _this$crypto$getDevic2 !== void 0 ? _this$crypto$getDevic2 : null;
|
1092
|
-
}
|
1093
|
-
|
1094
|
-
/**
|
1095
|
-
* @deprecated Does nothing.
|
1096
|
-
*/
|
1097
|
-
uploadKeys() {
|
1098
|
-
var _this12 = this;
|
1099
|
-
return _asyncToGenerator(function* () {
|
1100
|
-
_this12.logger.warn("MatrixClient.uploadKeys is deprecated");
|
1101
|
-
})();
|
1102
|
-
}
|
1103
|
-
|
1104
|
-
/**
|
1105
|
-
* Download the keys for a list of users and stores the keys in the session
|
1106
|
-
* store.
|
1107
|
-
* @param userIds - The users to fetch.
|
1108
|
-
* @param forceDownload - Always download the keys even if cached.
|
1109
|
-
*
|
1110
|
-
* @returns A promise which resolves to a map userId-\>deviceId-\>`DeviceInfo`
|
1111
|
-
*
|
1112
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.getUserDeviceInfo}
|
1113
|
-
*/
|
1114
|
-
downloadKeys(userIds, forceDownload) {
|
1115
|
-
if (!this.crypto) {
|
1116
|
-
return Promise.reject(new Error("End-to-end encryption disabled"));
|
1117
|
-
}
|
1118
|
-
return this.crypto.downloadKeys(userIds, forceDownload);
|
1119
|
-
}
|
1120
|
-
|
1121
|
-
/**
|
1122
|
-
* Get the stored device keys for a user id
|
1123
|
-
*
|
1124
|
-
* @param userId - the user to list keys for.
|
1125
|
-
*
|
1126
|
-
* @returns list of devices
|
1127
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.getUserDeviceInfo}
|
1128
|
-
*/
|
1129
|
-
getStoredDevicesForUser(userId) {
|
1130
|
-
if (!this.crypto) {
|
1131
|
-
throw new Error("End-to-end encryption disabled");
|
1132
|
-
}
|
1133
|
-
return this.crypto.getStoredDevicesForUser(userId) || [];
|
1134
|
-
}
|
1135
|
-
|
1136
|
-
/**
|
1137
|
-
* Get the stored device key for a user id and device id
|
1138
|
-
*
|
1139
|
-
* @param userId - the user to list keys for.
|
1140
|
-
* @param deviceId - unique identifier for the device
|
1141
|
-
*
|
1142
|
-
* @returns device or null
|
1143
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.getUserDeviceInfo}
|
1144
|
-
*/
|
1145
|
-
getStoredDevice(userId, deviceId) {
|
1146
|
-
if (!this.crypto) {
|
1147
|
-
throw new Error("End-to-end encryption disabled");
|
1148
|
-
}
|
1149
|
-
return this.crypto.getStoredDevice(userId, deviceId) || null;
|
1150
|
-
}
|
1151
|
-
|
1152
|
-
/**
|
1153
|
-
* Mark the given device as verified
|
1154
|
-
*
|
1155
|
-
* @param userId - owner of the device
|
1156
|
-
* @param deviceId - unique identifier for the device or user's
|
1157
|
-
* cross-signing public key ID.
|
1158
|
-
*
|
1159
|
-
* @param verified - whether to mark the device as verified. defaults
|
1160
|
-
* to 'true'.
|
1161
|
-
*
|
1162
|
-
* @returns
|
1163
|
-
*
|
1164
|
-
* @remarks
|
1165
|
-
* Fires {@link CryptoEvent#DeviceVerificationChanged}
|
1166
|
-
*/
|
1167
|
-
setDeviceVerified(userId, deviceId) {
|
1168
|
-
var verified = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
1169
|
-
var prom = this.setDeviceVerification(userId, deviceId, verified, null, null);
|
1170
|
-
|
1171
|
-
// if one of the user's own devices is being marked as verified / unverified,
|
1172
|
-
// check the key backup status, since whether or not we use this depends on
|
1173
|
-
// whether it has a signature from a verified device
|
1174
|
-
if (userId == this.credentials.userId) {
|
1175
|
-
this.checkKeyBackup();
|
1176
|
-
}
|
1177
|
-
return prom;
|
1178
|
-
}
|
1179
|
-
|
1180
|
-
/**
|
1181
|
-
* Mark the given device as blocked/unblocked
|
1182
|
-
*
|
1183
|
-
* @param userId - owner of the device
|
1184
|
-
* @param deviceId - unique identifier for the device or user's
|
1185
|
-
* cross-signing public key ID.
|
1186
|
-
*
|
1187
|
-
* @param blocked - whether to mark the device as blocked. defaults
|
1188
|
-
* to 'true'.
|
1189
|
-
*
|
1190
|
-
* @returns
|
1191
|
-
*
|
1192
|
-
* @remarks
|
1193
|
-
* Fires {@link LegacyCryptoEvent.DeviceVerificationChanged}
|
1194
|
-
*
|
1195
|
-
* @deprecated Not supported for Rust Cryptography.
|
1196
|
-
*/
|
1197
|
-
setDeviceBlocked(userId, deviceId) {
|
1198
|
-
var blocked = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
1199
|
-
return this.setDeviceVerification(userId, deviceId, null, blocked, null);
|
1200
|
-
}
|
1201
|
-
|
1202
|
-
/**
|
1203
|
-
* Mark the given device as known/unknown
|
1204
|
-
*
|
1205
|
-
* @param userId - owner of the device
|
1206
|
-
* @param deviceId - unique identifier for the device or user's
|
1207
|
-
* cross-signing public key ID.
|
1208
|
-
*
|
1209
|
-
* @param known - whether to mark the device as known. defaults
|
1210
|
-
* to 'true'.
|
1211
|
-
*
|
1212
|
-
* @returns
|
1213
|
-
*
|
1214
|
-
* @remarks
|
1215
|
-
* Fires {@link CryptoEvent#DeviceVerificationChanged}
|
1216
|
-
*
|
1217
|
-
* @deprecated Not supported for Rust Cryptography.
|
1218
|
-
*/
|
1219
|
-
setDeviceKnown(userId, deviceId) {
|
1220
|
-
var known = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
1221
|
-
return this.setDeviceVerification(userId, deviceId, null, null, known);
|
1222
|
-
}
|
1223
|
-
setDeviceVerification(userId, deviceId, verified, blocked, known) {
|
1224
|
-
var _this13 = this;
|
1225
|
-
return _asyncToGenerator(function* () {
|
1226
|
-
if (!_this13.crypto) {
|
1227
|
-
throw new Error("End-to-end encryption disabled");
|
1228
|
-
}
|
1229
|
-
yield _this13.crypto.setDeviceVerification(userId, deviceId, verified, blocked, known);
|
1230
|
-
})();
|
1231
|
-
}
|
1232
|
-
|
1233
|
-
/**
|
1234
|
-
* Request a key verification from another user, using a DM.
|
1235
|
-
*
|
1236
|
-
* @param userId - the user to request verification with
|
1237
|
-
* @param roomId - the room to use for verification
|
1238
|
-
*
|
1239
|
-
* @returns resolves to a VerificationRequest
|
1240
|
-
* when the request has been sent to the other party.
|
1241
|
-
*
|
1242
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.requestVerificationDM}.
|
1243
|
-
*/
|
1244
|
-
requestVerificationDM(userId, roomId) {
|
1245
|
-
if (!this.crypto) {
|
1246
|
-
throw new Error("End-to-end encryption disabled");
|
1247
|
-
}
|
1248
|
-
return this.crypto.requestVerificationDM(userId, roomId);
|
1249
|
-
}
|
1250
|
-
|
1251
|
-
/**
|
1252
|
-
* Finds a DM verification request that is already in progress for the given room id
|
1253
|
-
*
|
1254
|
-
* @param roomId - the room to use for verification
|
1255
|
-
*
|
1256
|
-
* @returns the VerificationRequest that is in progress, if any
|
1257
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.findVerificationRequestDMInProgress}.
|
1258
|
-
*/
|
1259
|
-
findVerificationRequestDMInProgress(roomId) {
|
1260
|
-
if (!this.cryptoBackend) {
|
1261
|
-
throw new Error("End-to-end encryption disabled");
|
1262
|
-
} else if (!this.crypto) {
|
1263
|
-
// Hack for element-R to avoid breaking the cypress tests. We can get rid of this once the react-sdk is
|
1264
|
-
// updated to use CryptoApi.findVerificationRequestDMInProgress.
|
1265
|
-
return undefined;
|
1266
|
-
}
|
1267
|
-
return this.crypto.findVerificationRequestDMInProgress(roomId);
|
1268
|
-
}
|
1269
|
-
|
1270
|
-
/**
|
1271
|
-
* Returns all to-device verification requests that are already in progress for the given user id
|
1272
|
-
*
|
1273
|
-
* @param userId - the ID of the user to query
|
1274
|
-
*
|
1275
|
-
* @returns the VerificationRequests that are in progress
|
1276
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.getVerificationRequestsToDeviceInProgress}.
|
1277
|
-
*/
|
1278
|
-
getVerificationRequestsToDeviceInProgress(userId) {
|
1279
|
-
if (!this.crypto) {
|
1280
|
-
throw new Error("End-to-end encryption disabled");
|
1281
|
-
}
|
1282
|
-
return this.crypto.getVerificationRequestsToDeviceInProgress(userId);
|
1283
|
-
}
|
1284
|
-
|
1285
|
-
/**
|
1286
|
-
* Request a key verification from another user.
|
1287
|
-
*
|
1288
|
-
* @param userId - the user to request verification with
|
1289
|
-
* @param devices - array of device IDs to send requests to. Defaults to
|
1290
|
-
* all devices owned by the user
|
1291
|
-
*
|
1292
|
-
* @returns resolves to a VerificationRequest
|
1293
|
-
* when the request has been sent to the other party.
|
1294
|
-
*
|
1295
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi#requestOwnUserVerification} or {@link CryptoApi#requestDeviceVerification}.
|
1296
|
-
*/
|
1297
|
-
requestVerification(userId, devices) {
|
1298
|
-
if (!this.crypto) {
|
1299
|
-
throw new Error("End-to-end encryption disabled");
|
1300
|
-
}
|
1301
|
-
return this.crypto.requestVerification(userId, devices);
|
1302
|
-
}
|
1303
|
-
|
1304
|
-
/**
|
1305
|
-
* Begin a key verification.
|
1306
|
-
*
|
1307
|
-
* @param method - the verification method to use
|
1308
|
-
* @param userId - the user to verify keys with
|
1309
|
-
* @param deviceId - the device to verify
|
1310
|
-
*
|
1311
|
-
* @returns a verification object
|
1312
|
-
* @deprecated Prefer {@link CryptoApi#requestOwnUserVerification} or {@link CryptoApi#requestDeviceVerification}.
|
1313
|
-
*/
|
1314
|
-
beginKeyVerification(method, userId, deviceId) {
|
1315
|
-
if (!this.crypto) {
|
1316
|
-
throw new Error("End-to-end encryption disabled");
|
1317
|
-
}
|
1318
|
-
return this.crypto.beginKeyVerification(method, userId, deviceId);
|
1319
|
-
}
|
1320
|
-
|
1321
|
-
/**
|
1322
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#checkKey}.
|
1323
|
-
*/
|
1324
|
-
checkSecretStorageKey(key, info) {
|
1325
|
-
return this.secretStorage.checkKey(key, info);
|
1326
|
-
}
|
1327
|
-
|
1328
|
-
/**
|
1329
|
-
* Set the global override for whether the client should ever send encrypted
|
1330
|
-
* messages to unverified devices. This provides the default for rooms which
|
1331
|
-
* do not specify a value.
|
1332
|
-
*
|
1333
|
-
* @param value - whether to blacklist all unverified devices by default
|
1334
|
-
*
|
1335
|
-
* @deprecated Prefer direct access to {@link CryptoApi.globalBlacklistUnverifiedDevices}:
|
1336
|
-
*
|
1337
|
-
* ```javascript
|
1338
|
-
* client.getCrypto().globalBlacklistUnverifiedDevices = value;
|
1339
|
-
* ```
|
1340
|
-
*/
|
1341
|
-
setGlobalBlacklistUnverifiedDevices(value) {
|
1342
|
-
if (!this.cryptoBackend) {
|
1343
|
-
throw new Error("End-to-end encryption disabled");
|
1344
|
-
}
|
1345
|
-
this.cryptoBackend.globalBlacklistUnverifiedDevices = value;
|
1346
|
-
return value;
|
1347
|
-
}
|
1348
|
-
|
1349
|
-
/**
|
1350
|
-
* @returns whether to blacklist all unverified devices by default
|
1351
|
-
*
|
1352
|
-
* @deprecated Prefer direct access to {@link CryptoApi.globalBlacklistUnverifiedDevices}:
|
1353
|
-
*
|
1354
|
-
* ```javascript
|
1355
|
-
* value = client.getCrypto().globalBlacklistUnverifiedDevices;
|
1356
|
-
* ```
|
1357
|
-
*/
|
1358
|
-
getGlobalBlacklistUnverifiedDevices() {
|
1359
|
-
if (!this.cryptoBackend) {
|
1360
|
-
throw new Error("End-to-end encryption disabled");
|
1361
|
-
}
|
1362
|
-
return this.cryptoBackend.globalBlacklistUnverifiedDevices;
|
1363
|
-
}
|
1364
|
-
|
1365
|
-
/**
|
1366
|
-
* Set whether sendMessage in a room with unknown and unverified devices
|
1367
|
-
* should throw an error and not send them message. This has 'Global' for
|
1368
|
-
* symmetry with setGlobalBlacklistUnverifiedDevices but there is currently
|
1369
|
-
* no room-level equivalent for this setting.
|
1370
|
-
*
|
1371
|
-
* This API is currently UNSTABLE and may change or be removed without notice.
|
1372
|
-
*
|
1373
|
-
* It has no effect with the Rust crypto implementation.
|
1374
|
-
*
|
1375
|
-
* @param value - whether error on unknown devices
|
1376
|
-
*
|
1377
|
-
* ```ts
|
1378
|
-
* client.getCrypto().globalErrorOnUnknownDevices = value;
|
1379
|
-
* ```
|
1380
|
-
*/
|
1381
|
-
setGlobalErrorOnUnknownDevices(value) {
|
1382
|
-
if (!this.cryptoBackend) {
|
1383
|
-
throw new Error("End-to-end encryption disabled");
|
1384
|
-
}
|
1385
|
-
this.cryptoBackend.globalErrorOnUnknownDevices = value;
|
1386
|
-
}
|
1387
|
-
|
1388
|
-
/**
|
1389
|
-
* @returns whether to error on unknown devices
|
1390
|
-
*
|
1391
|
-
* This API is currently UNSTABLE and may change or be removed without notice.
|
1392
|
-
*/
|
1393
|
-
getGlobalErrorOnUnknownDevices() {
|
1394
|
-
if (!this.cryptoBackend) {
|
1395
|
-
throw new Error("End-to-end encryption disabled");
|
1396
|
-
}
|
1397
|
-
return this.cryptoBackend.globalErrorOnUnknownDevices;
|
1398
|
-
}
|
1399
|
-
|
1400
|
-
/**
|
1401
|
-
* Get the ID of one of the user's cross-signing keys
|
1402
|
-
*
|
1403
|
-
* @param type - The type of key to get the ID of. One of
|
1404
|
-
* "master", "self_signing", or "user_signing". Defaults to "master".
|
1405
|
-
*
|
1406
|
-
* @returns the key ID
|
1407
|
-
* @deprecated Not supported for Rust Cryptography. prefer {@link Crypto.CryptoApi#getCrossSigningKeyId}
|
1408
|
-
*/
|
1409
|
-
getCrossSigningId() {
|
1410
|
-
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : CrossSigningKey.Master;
|
1411
|
-
if (!this.crypto) {
|
1412
|
-
throw new Error("End-to-end encryption disabled");
|
1413
|
-
}
|
1414
|
-
return this.crypto.getCrossSigningId(type);
|
1415
|
-
}
|
1416
|
-
|
1417
|
-
/**
|
1418
|
-
* Get the cross signing information for a given user.
|
1419
|
-
*
|
1420
|
-
* The cross-signing API is currently UNSTABLE and may change without notice.
|
1421
|
-
*
|
1422
|
-
* @param userId - the user ID to get the cross-signing info for.
|
1423
|
-
*
|
1424
|
-
* @returns the cross signing information for the user.
|
1425
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi#userHasCrossSigningKeys}
|
1426
|
-
*/
|
1427
|
-
getStoredCrossSigningForUser(userId) {
|
1428
|
-
if (!this.cryptoBackend) {
|
1429
|
-
throw new Error("End-to-end encryption disabled");
|
1430
|
-
}
|
1431
|
-
return this.cryptoBackend.getStoredCrossSigningForUser(userId);
|
1432
|
-
}
|
1433
|
-
|
1434
|
-
/**
|
1435
|
-
* Check whether a given user is trusted.
|
1436
|
-
*
|
1437
|
-
* The cross-signing API is currently UNSTABLE and may change without notice.
|
1438
|
-
*
|
1439
|
-
* @param userId - The ID of the user to check.
|
1440
|
-
*
|
1441
|
-
* @deprecated Use {@link Crypto.CryptoApi.getUserVerificationStatus | `CryptoApi.getUserVerificationStatus`}
|
1442
|
-
*/
|
1443
|
-
checkUserTrust(userId) {
|
1444
|
-
if (!this.cryptoBackend) {
|
1445
|
-
throw new Error("End-to-end encryption disabled");
|
1446
|
-
}
|
1447
|
-
return this.cryptoBackend.checkUserTrust(userId);
|
1448
|
-
}
|
1449
|
-
|
1450
|
-
/**
|
1451
|
-
* Check whether a given device is trusted.
|
1452
|
-
*
|
1453
|
-
* The cross-signing API is currently UNSTABLE and may change without notice.
|
1454
|
-
*
|
1455
|
-
* @param userId - The ID of the user whose devices is to be checked.
|
1456
|
-
* @param deviceId - The ID of the device to check
|
1457
|
-
*
|
1458
|
-
* @deprecated Use {@link Crypto.CryptoApi.getDeviceVerificationStatus | `CryptoApi.getDeviceVerificationStatus`}
|
1459
|
-
*/
|
1460
|
-
checkDeviceTrust(userId, deviceId) {
|
1461
|
-
if (!this.crypto) {
|
1462
|
-
throw new Error("End-to-end encryption disabled");
|
1463
|
-
}
|
1464
|
-
return this.crypto.checkDeviceTrust(userId, deviceId);
|
1465
|
-
}
|
1466
|
-
|
1467
|
-
/**
|
1468
|
-
* Check whether one of our own devices is cross-signed by our
|
1469
|
-
* user's stored keys, regardless of whether we trust those keys yet.
|
1470
|
-
*
|
1471
|
-
* @param deviceId - The ID of the device to check
|
1472
|
-
*
|
1473
|
-
* @returns true if the device is cross-signed
|
1474
|
-
*
|
1475
|
-
* @deprecated Not supported for Rust Cryptography.
|
1476
|
-
*/
|
1477
|
-
checkIfOwnDeviceCrossSigned(deviceId) {
|
1478
|
-
if (!this.crypto) {
|
1479
|
-
throw new Error("End-to-end encryption disabled");
|
1480
|
-
}
|
1481
|
-
return this.crypto.checkIfOwnDeviceCrossSigned(deviceId);
|
1482
|
-
}
|
1483
|
-
|
1484
|
-
/**
|
1485
|
-
* Check the copy of our cross-signing key that we have in the device list and
|
1486
|
-
* see if we can get the private key. If so, mark it as trusted.
|
1487
|
-
* @param opts - ICheckOwnCrossSigningTrustOpts object
|
1488
|
-
*
|
1489
|
-
* @deprecated Unneeded for the new crypto
|
1490
|
-
*/
|
1491
|
-
checkOwnCrossSigningTrust(opts) {
|
1492
|
-
if (!this.cryptoBackend) {
|
1493
|
-
throw new Error("End-to-end encryption disabled");
|
1494
|
-
}
|
1495
|
-
return this.cryptoBackend.checkOwnCrossSigningTrust(opts);
|
1496
|
-
}
|
1497
|
-
|
1498
|
-
/**
|
1499
|
-
* Checks that a given cross-signing private key matches a given public key.
|
1500
|
-
* This can be used by the getCrossSigningKey callback to verify that the
|
1501
|
-
* private key it is about to supply is the one that was requested.
|
1502
|
-
* @param privateKey - The private key
|
1503
|
-
* @param expectedPublicKey - The public key
|
1504
|
-
* @returns true if the key matches, otherwise false
|
1505
|
-
*
|
1506
|
-
* @deprecated Not supported for Rust Cryptography.
|
1507
|
-
*/
|
1508
|
-
checkCrossSigningPrivateKey(privateKey, expectedPublicKey) {
|
1509
|
-
if (!this.crypto) {
|
1510
|
-
throw new Error("End-to-end encryption disabled");
|
1511
|
-
}
|
1512
|
-
return this.crypto.checkCrossSigningPrivateKey(privateKey, expectedPublicKey);
|
1513
|
-
}
|
1514
|
-
|
1515
|
-
/**
|
1516
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi#requestDeviceVerification}.
|
1517
|
-
*/
|
1518
|
-
legacyDeviceVerification(userId, deviceId, method) {
|
1519
|
-
if (!this.crypto) {
|
1520
|
-
throw new Error("End-to-end encryption disabled");
|
1521
|
-
}
|
1522
|
-
return this.crypto.legacyDeviceVerification(userId, deviceId, method);
|
1523
|
-
}
|
1524
|
-
|
1525
|
-
/**
|
1526
|
-
* Perform any background tasks that can be done before a message is ready to
|
1527
|
-
* send, in order to speed up sending of the message.
|
1528
|
-
* @param room - the room the event is in
|
1529
|
-
*
|
1530
|
-
* @deprecated Prefer {@link CryptoApi.prepareToEncrypt | `CryptoApi.prepareToEncrypt`}:
|
1531
|
-
*
|
1532
|
-
* ```javascript
|
1533
|
-
* client.getCrypto().prepareToEncrypt(room);
|
1534
|
-
* ```
|
1535
|
-
*/
|
1536
|
-
prepareToEncrypt(room) {
|
1537
|
-
if (!this.cryptoBackend) {
|
1538
|
-
throw new Error("End-to-end encryption disabled");
|
1539
|
-
}
|
1540
|
-
this.cryptoBackend.prepareToEncrypt(room);
|
1541
|
-
}
|
1542
|
-
|
1543
|
-
/**
|
1544
|
-
* Checks if the user has previously published cross-signing keys
|
1545
|
-
*
|
1546
|
-
* This means downloading the devicelist for the user and checking if the list includes
|
1547
|
-
* the cross-signing pseudo-device.
|
1548
|
-
*
|
1549
|
-
* @deprecated Prefer {@link CryptoApi.userHasCrossSigningKeys | `CryptoApi.userHasCrossSigningKeys`}:
|
1550
|
-
*
|
1551
|
-
* ```javascript
|
1552
|
-
* result = client.getCrypto().userHasCrossSigningKeys();
|
1553
|
-
* ```
|
1554
|
-
*/
|
1555
|
-
userHasCrossSigningKeys() {
|
1556
|
-
if (!this.cryptoBackend) {
|
1557
|
-
throw new Error("End-to-end encryption disabled");
|
1558
|
-
}
|
1559
|
-
return this.cryptoBackend.userHasCrossSigningKeys();
|
1560
|
-
}
|
1561
|
-
|
1562
|
-
/**
|
1563
|
-
* Checks whether cross signing:
|
1564
|
-
* - is enabled on this account and trusted by this device
|
1565
|
-
* - has private keys either cached locally or stored in secret storage
|
1566
|
-
*
|
1567
|
-
* If this function returns false, bootstrapCrossSigning() can be used
|
1568
|
-
* to fix things such that it returns true. That is to say, after
|
1569
|
-
* bootstrapCrossSigning() completes successfully, this function should
|
1570
|
-
* return true.
|
1571
|
-
* @returns True if cross-signing is ready to be used on this device
|
1572
|
-
* @deprecated Prefer {@link CryptoApi.isCrossSigningReady | `CryptoApi.isCrossSigningReady`}:
|
1573
|
-
*/
|
1574
|
-
isCrossSigningReady() {
|
1575
|
-
if (!this.cryptoBackend) {
|
1576
|
-
throw new Error("End-to-end encryption disabled");
|
1577
|
-
}
|
1578
|
-
return this.cryptoBackend.isCrossSigningReady();
|
1579
|
-
}
|
1580
|
-
|
1581
|
-
/**
|
1582
|
-
* Bootstrap cross-signing by creating keys if needed. If everything is already
|
1583
|
-
* set up, then no changes are made, so this is safe to run to ensure
|
1584
|
-
* cross-signing is ready for use.
|
1585
|
-
*
|
1586
|
-
* This function:
|
1587
|
-
* - creates new cross-signing keys if they are not found locally cached nor in
|
1588
|
-
* secret storage (if it has been set up)
|
1589
|
-
*
|
1590
|
-
* @deprecated Prefer {@link CryptoApi.bootstrapCrossSigning | `CryptoApi.bootstrapCrossSigning`}.
|
1591
|
-
*/
|
1592
|
-
bootstrapCrossSigning(opts) {
|
1593
|
-
if (!this.cryptoBackend) {
|
1594
|
-
throw new Error("End-to-end encryption disabled");
|
1595
|
-
}
|
1596
|
-
return this.cryptoBackend.bootstrapCrossSigning(opts);
|
1597
|
-
}
|
1598
|
-
|
1599
|
-
/**
|
1600
|
-
* Whether to trust a others users signatures of their devices.
|
1601
|
-
* If false, devices will only be considered 'verified' if we have
|
1602
|
-
* verified that device individually (effectively disabling cross-signing).
|
1603
|
-
*
|
1604
|
-
* Default: true
|
1605
|
-
*
|
1606
|
-
* @returns True if trusting cross-signed devices
|
1607
|
-
*
|
1608
|
-
* @deprecated Prefer {@link CryptoApi.getTrustCrossSignedDevices | `CryptoApi.getTrustCrossSignedDevices`}.
|
1609
|
-
*/
|
1610
|
-
getCryptoTrustCrossSignedDevices() {
|
1611
|
-
if (!this.cryptoBackend) {
|
1612
|
-
throw new Error("End-to-end encryption disabled");
|
1613
|
-
}
|
1614
|
-
return this.cryptoBackend.getTrustCrossSignedDevices();
|
1615
|
-
}
|
1616
|
-
|
1617
|
-
/**
|
1618
|
-
* See getCryptoTrustCrossSignedDevices
|
1619
|
-
*
|
1620
|
-
* @param val - True to trust cross-signed devices
|
1621
|
-
*
|
1622
|
-
* @deprecated Prefer {@link CryptoApi.setTrustCrossSignedDevices | `CryptoApi.setTrustCrossSignedDevices`}.
|
1623
|
-
*/
|
1624
|
-
setCryptoTrustCrossSignedDevices(val) {
|
1625
|
-
if (!this.cryptoBackend) {
|
1626
|
-
throw new Error("End-to-end encryption disabled");
|
1627
|
-
}
|
1628
|
-
this.cryptoBackend.setTrustCrossSignedDevices(val);
|
1629
|
-
}
|
1630
|
-
|
1631
|
-
/**
|
1632
|
-
* Counts the number of end to end session keys that are waiting to be backed up
|
1633
|
-
* @returns Promise which resolves to the number of sessions requiring backup
|
1634
|
-
*
|
1635
|
-
* @deprecated Not supported for Rust Cryptography.
|
1636
|
-
*/
|
1637
|
-
countSessionsNeedingBackup() {
|
1638
|
-
if (!this.crypto) {
|
1639
|
-
throw new Error("End-to-end encryption disabled");
|
1640
|
-
}
|
1641
|
-
return this.crypto.countSessionsNeedingBackup();
|
1642
|
-
}
|
1643
|
-
|
1644
|
-
/**
|
1645
|
-
* Get information about the encryption of an event
|
1646
|
-
*
|
1647
|
-
* @param event - event to be checked
|
1648
|
-
* @returns The event information.
|
1649
|
-
* @deprecated Prefer {@link Crypto.CryptoApi.getEncryptionInfoForEvent | `CryptoApi.getEncryptionInfoForEvent`}.
|
1650
|
-
*/
|
1651
|
-
getEventEncryptionInfo(event) {
|
1652
|
-
if (!this.cryptoBackend) {
|
1653
|
-
throw new Error("End-to-end encryption disabled");
|
1654
|
-
}
|
1655
|
-
return this.cryptoBackend.getEventEncryptionInfo(event);
|
1656
|
-
}
|
1657
|
-
|
1658
|
-
/**
|
1659
|
-
* Create a recovery key from a user-supplied passphrase.
|
1660
|
-
*
|
1661
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
1662
|
-
*
|
1663
|
-
* @param password - Passphrase string that can be entered by the user
|
1664
|
-
* when restoring the backup as an alternative to entering the recovery key.
|
1665
|
-
* Optional.
|
1666
|
-
* @returns Object with public key metadata, encoded private
|
1667
|
-
* recovery key which should be disposed of after displaying to the user,
|
1668
|
-
* and raw private key to avoid round tripping if needed.
|
1669
|
-
*
|
1670
|
-
* @deprecated Prefer {@link CryptoApi.createRecoveryKeyFromPassphrase | `CryptoApi.createRecoveryKeyFromPassphrase`}.
|
1671
|
-
*/
|
1672
|
-
createRecoveryKeyFromPassphrase(password) {
|
1673
|
-
if (!this.cryptoBackend) {
|
1674
|
-
throw new Error("End-to-end encryption disabled");
|
1675
|
-
}
|
1676
|
-
return this.cryptoBackend.createRecoveryKeyFromPassphrase(password);
|
1677
|
-
}
|
1678
|
-
|
1679
|
-
/**
|
1680
|
-
* Checks whether secret storage:
|
1681
|
-
* - is enabled on this account
|
1682
|
-
* - is storing cross-signing private keys
|
1683
|
-
* - is storing session backup key (if enabled)
|
1684
|
-
*
|
1685
|
-
* If this function returns false, bootstrapSecretStorage() can be used
|
1686
|
-
* to fix things such that it returns true. That is to say, after
|
1687
|
-
* bootstrapSecretStorage() completes successfully, this function should
|
1688
|
-
* return true.
|
1689
|
-
*
|
1690
|
-
* @returns True if secret storage is ready to be used on this device
|
1691
|
-
* @deprecated Prefer {@link CryptoApi.isSecretStorageReady | `CryptoApi.isSecretStorageReady`}.
|
1692
|
-
*/
|
1693
|
-
isSecretStorageReady() {
|
1694
|
-
if (!this.cryptoBackend) {
|
1695
|
-
throw new Error("End-to-end encryption disabled");
|
1696
|
-
}
|
1697
|
-
return this.cryptoBackend.isSecretStorageReady();
|
1698
|
-
}
|
1699
|
-
|
1700
|
-
/**
|
1701
|
-
* Bootstrap Secure Secret Storage if needed by creating a default key. If everything is
|
1702
|
-
* already set up, then no changes are made, so this is safe to run to ensure secret
|
1703
|
-
* storage is ready for use.
|
1704
|
-
*
|
1705
|
-
* This function
|
1706
|
-
* - creates a new Secure Secret Storage key if no default key exists
|
1707
|
-
* - if a key backup exists, it is migrated to store the key in the Secret
|
1708
|
-
* Storage
|
1709
|
-
* - creates a backup if none exists, and one is requested
|
1710
|
-
* - migrates Secure Secret Storage to use the latest algorithm, if an outdated
|
1711
|
-
* algorithm is found
|
1712
|
-
*
|
1713
|
-
* @deprecated Use {@link CryptoApi.bootstrapSecretStorage | `CryptoApi.bootstrapSecretStorage`}.
|
1714
|
-
*/
|
1715
|
-
bootstrapSecretStorage(opts) {
|
1716
|
-
if (!this.cryptoBackend) {
|
1717
|
-
throw new Error("End-to-end encryption disabled");
|
1718
|
-
}
|
1719
|
-
return this.cryptoBackend.bootstrapSecretStorage(opts);
|
1720
|
-
}
|
1721
|
-
|
1722
|
-
/**
|
1723
|
-
* Add a key for encrypting secrets.
|
1724
|
-
*
|
1725
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
1726
|
-
*
|
1727
|
-
* @param algorithm - the algorithm used by the key
|
1728
|
-
* @param opts - the options for the algorithm. The properties used
|
1729
|
-
* depend on the algorithm given.
|
1730
|
-
* @param keyName - the name of the key. If not given, a random name will be generated.
|
1731
|
-
*
|
1732
|
-
* @returns An object with:
|
1733
|
-
* keyId: the ID of the key
|
1734
|
-
* keyInfo: details about the key (iv, mac, passphrase)
|
1735
|
-
*
|
1736
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#addKey}.
|
1737
|
-
*/
|
1738
|
-
addSecretStorageKey(algorithm, opts, keyName) {
|
1739
|
-
return this.secretStorage.addKey(algorithm, opts, keyName);
|
1740
|
-
}
|
1741
|
-
|
1742
|
-
/**
|
1743
|
-
* Check whether we have a key with a given ID.
|
1744
|
-
*
|
1745
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
1746
|
-
*
|
1747
|
-
* @param keyId - The ID of the key to check
|
1748
|
-
* for. Defaults to the default key ID if not provided.
|
1749
|
-
* @returns Whether we have the key.
|
1750
|
-
*
|
1751
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#hasKey}.
|
1752
|
-
*/
|
1753
|
-
hasSecretStorageKey(keyId) {
|
1754
|
-
return this.secretStorage.hasKey(keyId);
|
1755
|
-
}
|
1756
|
-
|
1757
|
-
/**
|
1758
|
-
* Store an encrypted secret on the server.
|
1759
|
-
*
|
1760
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
1761
|
-
*
|
1762
|
-
* @param name - The name of the secret
|
1763
|
-
* @param secret - The secret contents.
|
1764
|
-
* @param keys - The IDs of the keys to use to encrypt the secret or null/undefined
|
1765
|
-
* to use the default (will throw if no default key is set).
|
1766
|
-
*
|
1767
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#store}.
|
1768
|
-
*/
|
1769
|
-
storeSecret(name, secret, keys) {
|
1770
|
-
return this.secretStorage.store(name, secret, keys);
|
1771
|
-
}
|
1772
|
-
|
1773
|
-
/**
|
1774
|
-
* Get a secret from storage.
|
1775
|
-
*
|
1776
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
1777
|
-
*
|
1778
|
-
* @param name - the name of the secret
|
1779
|
-
*
|
1780
|
-
* @returns the contents of the secret
|
1781
|
-
*
|
1782
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#get}.
|
1783
|
-
*/
|
1784
|
-
getSecret(name) {
|
1785
|
-
return this.secretStorage.get(name);
|
1786
|
-
}
|
1787
|
-
|
1788
|
-
/**
|
1789
|
-
* Check if a secret is stored on the server.
|
1790
|
-
*
|
1791
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
1792
|
-
*
|
1793
|
-
* @param name - the name of the secret
|
1794
|
-
* @returns map of key name to key info the secret is encrypted
|
1795
|
-
* with, or null if it is not present or not encrypted with a trusted
|
1796
|
-
* key
|
1797
|
-
*
|
1798
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#isStored}.
|
1799
|
-
*/
|
1800
|
-
isSecretStored(name) {
|
1801
|
-
return this.secretStorage.isStored(name);
|
1802
|
-
}
|
1803
|
-
|
1804
|
-
/**
|
1805
|
-
* Request a secret from another device.
|
1806
|
-
*
|
1807
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
1808
|
-
*
|
1809
|
-
* @param name - the name of the secret to request
|
1810
|
-
* @param devices - the devices to request the secret from
|
1811
|
-
*
|
1812
|
-
* @returns the secret request object
|
1813
|
-
* @deprecated Not supported for Rust Cryptography.
|
1814
|
-
*/
|
1815
|
-
requestSecret(name, devices) {
|
1816
|
-
if (!this.crypto) {
|
1817
|
-
throw new Error("End-to-end encryption disabled");
|
1818
|
-
}
|
1819
|
-
return this.crypto.requestSecret(name, devices);
|
1820
|
-
}
|
1821
|
-
|
1822
|
-
/**
|
1823
|
-
* Get the current default key ID for encrypting secrets.
|
1824
|
-
*
|
1825
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
1826
|
-
*
|
1827
|
-
* @returns The default key ID or null if no default key ID is set
|
1828
|
-
*
|
1829
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#getDefaultKeyId}.
|
1830
|
-
*/
|
1831
|
-
getDefaultSecretStorageKeyId() {
|
1832
|
-
return this.secretStorage.getDefaultKeyId();
|
1833
|
-
}
|
1834
|
-
|
1835
|
-
/**
|
1836
|
-
* Set the current default key ID for encrypting secrets.
|
1837
|
-
*
|
1838
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
1839
|
-
*
|
1840
|
-
* @param keyId - The new default key ID
|
1841
|
-
*
|
1842
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#setDefaultKeyId}.
|
1843
|
-
*/
|
1844
|
-
setDefaultSecretStorageKeyId(keyId) {
|
1845
|
-
return this.secretStorage.setDefaultKeyId(keyId);
|
1846
|
-
}
|
1847
|
-
|
1848
|
-
/**
|
1849
|
-
* Checks that a given secret storage private key matches a given public key.
|
1850
|
-
* This can be used by the getSecretStorageKey callback to verify that the
|
1851
|
-
* private key it is about to supply is the one that was requested.
|
1852
|
-
*
|
1853
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
1854
|
-
*
|
1855
|
-
* @param privateKey - The private key
|
1856
|
-
* @param expectedPublicKey - The public key
|
1857
|
-
* @returns true if the key matches, otherwise false
|
1858
|
-
*
|
1859
|
-
* @deprecated The use of asymmetric keys for SSSS is deprecated.
|
1860
|
-
* Use {@link SecretStorage.ServerSideSecretStorage#checkKey} for symmetric keys.
|
1861
|
-
*/
|
1862
|
-
checkSecretStoragePrivateKey(privateKey, expectedPublicKey) {
|
1863
|
-
if (!this.crypto) {
|
1864
|
-
throw new Error("End-to-end encryption disabled");
|
1865
|
-
}
|
1866
|
-
return this.crypto.checkSecretStoragePrivateKey(privateKey, expectedPublicKey);
|
1867
|
-
}
|
1868
|
-
|
1869
|
-
/**
|
1870
|
-
* Get e2e information on the device that sent an event
|
1871
|
-
*
|
1872
|
-
* @param event - event to be checked
|
1873
|
-
* @deprecated Not supported for Rust Cryptography.
|
1874
|
-
*/
|
1875
|
-
getEventSenderDeviceInfo(event) {
|
1876
|
-
var _this14 = this;
|
1877
|
-
return _asyncToGenerator(function* () {
|
1878
|
-
if (!_this14.crypto) {
|
1879
|
-
return null;
|
1880
|
-
}
|
1881
|
-
return _this14.crypto.getEventSenderDeviceInfo(event);
|
1882
|
-
})();
|
1883
|
-
}
|
1884
|
-
|
1885
|
-
/**
|
1886
|
-
* Check if the sender of an event is verified
|
1887
|
-
*
|
1888
|
-
* @param event - event to be checked
|
1889
|
-
*
|
1890
|
-
* @returns true if the sender of this event has been verified using
|
1891
|
-
* {@link MatrixClient#setDeviceVerified}.
|
1892
|
-
*
|
1893
|
-
* @deprecated Not supported for Rust Cryptography.
|
1894
|
-
*/
|
1895
|
-
isEventSenderVerified(event) {
|
1896
|
-
var _this15 = this;
|
1897
|
-
return _asyncToGenerator(function* () {
|
1898
|
-
var device = yield _this15.getEventSenderDeviceInfo(event);
|
1899
|
-
if (!device) {
|
1900
|
-
return false;
|
1901
|
-
}
|
1902
|
-
return device.isVerified();
|
1903
|
-
})();
|
1904
|
-
}
|
1905
|
-
|
1906
|
-
/**
|
1907
|
-
* Get outgoing room key request for this event if there is one.
|
1908
|
-
* @param event - The event to check for
|
1909
|
-
*
|
1910
|
-
* @returns A room key request, or null if there is none
|
1911
|
-
*
|
1912
|
-
* @deprecated Not supported for Rust Cryptography.
|
1913
|
-
*/
|
1914
|
-
getOutgoingRoomKeyRequest(event) {
|
1915
|
-
if (!this.crypto) {
|
1916
|
-
throw new Error("End-to-End encryption disabled");
|
1917
|
-
}
|
1918
|
-
var wireContent = event.getWireContent();
|
1919
|
-
var requestBody = {
|
1920
|
-
session_id: wireContent.session_id,
|
1921
|
-
sender_key: wireContent.sender_key,
|
1922
|
-
algorithm: wireContent.algorithm,
|
1923
|
-
room_id: event.getRoomId()
|
1924
|
-
};
|
1925
|
-
if (!requestBody.session_id || !requestBody.sender_key || !requestBody.algorithm || !requestBody.room_id) {
|
1926
|
-
return Promise.resolve(null);
|
1927
|
-
}
|
1928
|
-
return this.crypto.cryptoStore.getOutgoingRoomKeyRequest(requestBody);
|
1929
|
-
}
|
1930
|
-
|
1931
|
-
/**
|
1932
|
-
* Cancel a room key request for this event if one is ongoing and resend the
|
1933
|
-
* request.
|
1934
|
-
* @param event - event of which to cancel and resend the room
|
1935
|
-
* key request.
|
1936
|
-
* @returns A promise that will resolve when the key request is queued
|
1937
|
-
*
|
1938
|
-
* @deprecated Not supported for Rust Cryptography.
|
1939
|
-
*/
|
1940
|
-
cancelAndResendEventRoomKeyRequest(event) {
|
1941
|
-
if (!this.crypto) {
|
1942
|
-
throw new Error("End-to-End encryption disabled");
|
1943
|
-
}
|
1944
|
-
return event.cancelAndResendKeyRequest(this.crypto, this.getUserId());
|
1945
|
-
}
|
1946
|
-
|
1947
|
-
/**
|
1948
|
-
* Enable end-to-end encryption for a room. This does not modify room state.
|
1949
|
-
* Any messages sent before the returned promise resolves will be sent unencrypted.
|
1950
|
-
* @param roomId - The room ID to enable encryption in.
|
1951
|
-
* @param config - The encryption config for the room.
|
1952
|
-
* @returns A promise that will resolve when encryption is set up.
|
1953
|
-
*
|
1954
|
-
* @deprecated Not supported for Rust Cryptography. To enable encryption in a room, send an `m.room.encryption`
|
1955
|
-
* state event.
|
1956
|
-
*/
|
1957
|
-
setRoomEncryption(roomId, config) {
|
1958
|
-
if (!this.crypto) {
|
1959
|
-
throw new Error("End-to-End encryption disabled");
|
1960
|
-
}
|
1961
|
-
return this.crypto.setRoomEncryption(roomId, config);
|
1962
|
-
}
|
1963
|
-
|
1964
|
-
/**
|
1965
|
-
* Whether encryption is enabled for a room.
|
1966
|
-
* @param roomId - the room id to query.
|
1967
|
-
* @returns whether encryption is enabled.
|
1968
|
-
*
|
1969
|
-
* @deprecated Not correctly supported for Rust Cryptography. Use {@link CryptoApi.isEncryptionEnabledInRoom} and/or
|
1970
|
-
* {@link Room.hasEncryptionStateEvent}.
|
1971
|
-
*/
|
1972
|
-
isRoomEncrypted(roomId) {
|
1973
|
-
var _this$crypto$isRoomEn, _this$crypto3;
|
1974
|
-
var room = this.getRoom(roomId);
|
1975
|
-
if (!room) {
|
1976
|
-
// we don't know about this room, so can't determine if it should be
|
1977
|
-
// encrypted. Let's assume not.
|
1978
|
-
return false;
|
1979
|
-
}
|
1980
|
-
|
1981
|
-
// if there is an 'm.room.encryption' event in this room, it should be
|
1982
|
-
// encrypted (independently of whether we actually support encryption)
|
1983
|
-
if (room.hasEncryptionStateEvent()) {
|
1984
|
-
return true;
|
1985
|
-
}
|
1986
|
-
|
1987
|
-
// we don't have an m.room.encrypted event, but that might be because
|
1988
|
-
// the server is hiding it from us. Check the store to see if it was
|
1989
|
-
// previously encrypted.
|
1990
|
-
return (_this$crypto$isRoomEn = (_this$crypto3 = this.crypto) === null || _this$crypto3 === void 0 ? void 0 : _this$crypto3.isRoomEncrypted(roomId)) !== null && _this$crypto$isRoomEn !== void 0 ? _this$crypto$isRoomEn : false;
|
1991
|
-
}
|
1992
|
-
|
1993
|
-
/**
|
1994
|
-
* Encrypts and sends a given object via Olm to-device messages to a given
|
1995
|
-
* set of devices.
|
1996
|
-
*
|
1997
|
-
* @param userDeviceInfoArr - list of deviceInfo objects representing the devices to send to
|
1998
|
-
*
|
1999
|
-
* @param payload - fields to include in the encrypted payload
|
2000
|
-
*
|
2001
|
-
* @returns Promise which
|
2002
|
-
* resolves once the message has been encrypted and sent to the given
|
2003
|
-
* userDeviceMap, and returns the `{ contentMap, deviceInfoByDeviceId }`
|
2004
|
-
* of the successfully sent messages.
|
2005
|
-
*
|
2006
|
-
* @deprecated Instead use {@link CryptoApi.encryptToDeviceMessages} followed by {@link queueToDevice}.
|
2007
|
-
*/
|
2008
|
-
encryptAndSendToDevices(userDeviceInfoArr, payload) {
|
2009
|
-
if (!this.crypto) {
|
2010
|
-
throw new Error("End-to-End encryption disabled");
|
2011
|
-
}
|
2012
|
-
return this.crypto.encryptAndSendToDevices(userDeviceInfoArr, payload);
|
2013
|
-
}
|
2014
|
-
|
2015
|
-
/**
|
2016
|
-
* Forces the current outbound group session to be discarded such
|
2017
|
-
* that another one will be created next time an event is sent.
|
2018
|
-
*
|
2019
|
-
* @param roomId - The ID of the room to discard the session for
|
2020
|
-
*
|
2021
|
-
* @deprecated Prefer {@link CryptoApi.forceDiscardSession | `CryptoApi.forceDiscardSession`}:
|
2022
|
-
*/
|
2023
|
-
forceDiscardSession(roomId) {
|
2024
|
-
if (!this.cryptoBackend) {
|
2025
|
-
throw new Error("End-to-End encryption disabled");
|
2026
|
-
}
|
2027
|
-
this.cryptoBackend.forceDiscardSession(roomId);
|
2028
|
-
}
|
2029
|
-
|
2030
|
-
/**
|
2031
|
-
* Get a list containing all of the room keys
|
2032
|
-
*
|
2033
|
-
* This should be encrypted before returning it to the user.
|
2034
|
-
*
|
2035
|
-
* @returns a promise which resolves to a list of session export objects
|
2036
|
-
*
|
2037
|
-
* @deprecated Prefer {@link CryptoApi.exportRoomKeys | `CryptoApi.exportRoomKeys`}:
|
2038
|
-
*
|
2039
|
-
* ```javascript
|
2040
|
-
* sessionData = await client.getCrypto().exportRoomKeys();
|
2041
|
-
* ```
|
2042
|
-
*/
|
2043
|
-
exportRoomKeys() {
|
2044
|
-
if (!this.cryptoBackend) {
|
2045
|
-
return Promise.reject(new Error("End-to-end encryption disabled"));
|
2046
|
-
}
|
2047
|
-
return this.cryptoBackend.exportRoomKeys();
|
2048
|
-
}
|
2049
|
-
|
2050
|
-
/**
|
2051
|
-
* Import a list of room keys previously exported by exportRoomKeys
|
2052
|
-
*
|
2053
|
-
* @param keys - a list of session export objects
|
2054
|
-
* @param opts - options object
|
2055
|
-
*
|
2056
|
-
* @returns a promise which resolves when the keys have been imported
|
2057
|
-
*
|
2058
|
-
* @deprecated Prefer {@link CryptoApi.importRoomKeys | `CryptoApi.importRoomKeys`}:
|
2059
|
-
* ```javascript
|
2060
|
-
* await client.getCrypto()?.importRoomKeys([..]);
|
2061
|
-
* ```
|
2062
|
-
*/
|
2063
|
-
importRoomKeys(keys, opts) {
|
2064
|
-
if (!this.cryptoBackend) {
|
2065
|
-
throw new Error("End-to-end encryption disabled");
|
2066
|
-
}
|
2067
|
-
return this.cryptoBackend.importRoomKeys(keys, opts);
|
2068
|
-
}
|
2069
|
-
|
2070
|
-
/**
|
2071
|
-
* Force a re-check of the local key backup status against
|
2072
|
-
* what's on the server.
|
2073
|
-
*
|
2074
|
-
* @returns Object with backup info (as returned by
|
2075
|
-
* getKeyBackupVersion) in backupInfo and
|
2076
|
-
* trust information (as returned by isKeyBackupTrusted)
|
2077
|
-
* in trustInfo.
|
2078
|
-
*
|
2079
|
-
* @deprecated Prefer {@link Crypto.CryptoApi.checkKeyBackupAndEnable}.
|
2080
|
-
*/
|
2081
|
-
checkKeyBackup() {
|
2082
|
-
if (!this.crypto) {
|
2083
|
-
throw new Error("End-to-end encryption disabled");
|
2084
|
-
}
|
2085
|
-
return this.crypto.backupManager.checkKeyBackup();
|
2086
|
-
}
|
2087
|
-
|
2088
|
-
/**
|
2089
|
-
* Get information about the current key backup from the server.
|
2090
|
-
*
|
2091
|
-
* Performs some basic validity checks on the shape of the result, and raises an error if it is not as expected.
|
2092
|
-
*
|
2093
|
-
* **Note**: there is no (supported) way to distinguish between "failure to talk to the server" and "another client
|
2094
|
-
* uploaded a key backup version using an algorithm I don't understand.
|
2095
|
-
*
|
2096
|
-
* @returns Information object from API, or null if no backup is present on the server.
|
2097
|
-
*
|
2098
|
-
* @deprecated Prefer {@link CryptoApi.getKeyBackupInfo}.
|
2099
|
-
*/
|
2100
|
-
getKeyBackupVersion() {
|
2101
|
-
var _this16 = this;
|
2102
|
-
return _asyncToGenerator(function* () {
|
2103
|
-
var res;
|
2104
|
-
try {
|
2105
|
-
res = yield _this16.http.authedRequest(Method.Get, "/room_keys/version", undefined, undefined, {
|
2106
|
-
prefix: ClientPrefix.V3
|
2107
|
-
});
|
2108
|
-
} catch (e) {
|
2109
|
-
if (e.errcode === "M_NOT_FOUND") {
|
2110
|
-
return null;
|
2111
|
-
} else {
|
2112
|
-
throw e;
|
2113
|
-
}
|
2114
|
-
}
|
2115
|
-
BackupManager.checkBackupVersion(res);
|
2116
|
-
return res;
|
2117
|
-
})();
|
2118
|
-
}
|
2119
|
-
|
2120
|
-
/**
|
2121
|
-
* @param info - key backup info dict from getKeyBackupVersion()
|
2122
|
-
*
|
2123
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.isKeyBackupTrusted | `CryptoApi.isKeyBackupTrusted`}.
|
2124
|
-
*/
|
2125
|
-
isKeyBackupTrusted(info) {
|
2126
|
-
if (!this.crypto) {
|
2127
|
-
throw new Error("End-to-end encryption disabled");
|
2128
|
-
}
|
2129
|
-
return this.crypto.backupManager.isKeyBackupTrusted(info);
|
2130
|
-
}
|
2131
|
-
|
2132
|
-
/**
|
2133
|
-
* @returns true if the client is configured to back up keys to
|
2134
|
-
* the server, otherwise false. If we haven't completed a successful check
|
2135
|
-
* of key backup status yet, returns null.
|
2136
|
-
*
|
2137
|
-
* @deprecated Not supported for Rust Cryptography. Prefer direct access to {@link Crypto.CryptoApi.getActiveSessionBackupVersion}:
|
2138
|
-
*
|
2139
|
-
* ```javascript
|
2140
|
-
* let enabled = (await client.getCrypto().getActiveSessionBackupVersion()) !== null;
|
2141
|
-
* ```
|
2142
|
-
*/
|
2143
|
-
getKeyBackupEnabled() {
|
2144
|
-
if (!this.crypto) {
|
2145
|
-
throw new Error("End-to-end encryption disabled");
|
2146
|
-
}
|
2147
|
-
return this.crypto.backupManager.getKeyBackupEnabled();
|
2148
|
-
}
|
2149
|
-
|
2150
|
-
/**
|
2151
|
-
* Enable backing up of keys, using data previously returned from
|
2152
|
-
* getKeyBackupVersion.
|
2153
|
-
*
|
2154
|
-
* @param info - Backup information object as returned by getKeyBackupVersion
|
2155
|
-
* @returns Promise which resolves when complete.
|
2156
|
-
*
|
2157
|
-
* @deprecated Do not call this directly. Instead call {@link Crypto.CryptoApi.checkKeyBackupAndEnable}.
|
2158
|
-
*/
|
2159
|
-
enableKeyBackup(info) {
|
2160
|
-
if (!this.crypto) {
|
2161
|
-
throw new Error("End-to-end encryption disabled");
|
2162
|
-
}
|
2163
|
-
return this.crypto.backupManager.enableKeyBackup(info);
|
2164
|
-
}
|
2165
|
-
|
2166
|
-
/**
|
2167
|
-
* Disable backing up of keys.
|
2168
|
-
*
|
2169
|
-
* @deprecated Not supported for Rust Cryptography. It should be unnecessary to disable key backup.
|
2170
|
-
*/
|
2171
|
-
disableKeyBackup() {
|
2172
|
-
if (!this.crypto) {
|
2173
|
-
throw new Error("End-to-end encryption disabled");
|
2174
|
-
}
|
2175
|
-
this.crypto.backupManager.disableKeyBackup();
|
2176
|
-
}
|
2177
|
-
|
2178
|
-
/**
|
2179
|
-
* Set up the data required to create a new backup version. The backup version
|
2180
|
-
* will not be created and enabled until createKeyBackupVersion is called.
|
2181
|
-
*
|
2182
|
-
* @param password - Passphrase string that can be entered by the user
|
2183
|
-
* when restoring the backup as an alternative to entering the recovery key.
|
2184
|
-
* Optional.
|
2185
|
-
*
|
2186
|
-
* @returns Object that can be passed to createKeyBackupVersion and
|
2187
|
-
* additionally has a 'recovery_key' member with the user-facing recovery key string.
|
2188
|
-
*
|
2189
|
-
* @deprecated Not supported for Rust cryptography. Use {@link Crypto.CryptoApi.resetKeyBackup | `CryptoApi.resetKeyBackup`}.
|
2190
|
-
*/
|
2191
|
-
prepareKeyBackupVersion(password) {
|
2192
|
-
var _arguments2 = arguments,
|
2193
|
-
_this17 = this;
|
2194
|
-
return _asyncToGenerator(function* () {
|
2195
|
-
var opts = _arguments2.length > 1 && _arguments2[1] !== undefined ? _arguments2[1] : {
|
2196
|
-
secureSecretStorage: false
|
2197
|
-
};
|
2198
|
-
if (!_this17.crypto) {
|
2199
|
-
throw new Error("End-to-end encryption disabled");
|
2200
|
-
}
|
2201
|
-
|
2202
|
-
// eslint-disable-next-line camelcase
|
2203
|
-
var {
|
2204
|
-
algorithm,
|
2205
|
-
auth_data,
|
2206
|
-
recovery_key,
|
2207
|
-
privateKey
|
2208
|
-
} = yield _this17.crypto.backupManager.prepareKeyBackupVersion(password);
|
2209
|
-
if (opts.secureSecretStorage) {
|
2210
|
-
yield _this17.secretStorage.store("m.megolm_backup.v1", encodeBase64(privateKey));
|
2211
|
-
_this17.logger.info("Key backup private key stored in secret storage");
|
2212
|
-
}
|
2213
|
-
return {
|
2214
|
-
algorithm,
|
2215
|
-
/* eslint-disable camelcase */
|
2216
|
-
auth_data,
|
2217
|
-
recovery_key
|
2218
|
-
/* eslint-enable camelcase */
|
2219
|
-
};
|
2220
|
-
})();
|
2221
|
-
}
|
2222
|
-
|
2223
|
-
/**
|
2224
|
-
* Check whether the key backup private key is stored in secret storage.
|
2225
|
-
* @returns map of key name to key info the secret is
|
2226
|
-
* encrypted with, or null if it is not present or not encrypted with a
|
2227
|
-
* trusted key
|
2228
|
-
*/
|
2229
|
-
isKeyBackupKeyStored() {
|
2230
|
-
return Promise.resolve(this.secretStorage.isStored("m.megolm_backup.v1"));
|
2231
|
-
}
|
2232
|
-
|
2233
|
-
/**
|
2234
|
-
* Create a new key backup version and enable it, using the information return
|
2235
|
-
* from prepareKeyBackupVersion.
|
2236
|
-
*
|
2237
|
-
* @param info - Info object from prepareKeyBackupVersion
|
2238
|
-
* @returns Object with 'version' param indicating the version created
|
2239
|
-
*
|
2240
|
-
* @deprecated Use {@link Crypto.CryptoApi.resetKeyBackup | `CryptoApi.resetKeyBackup`}.
|
2241
|
-
*/
|
2242
|
-
createKeyBackupVersion(info) {
|
2243
|
-
var _this18 = this;
|
2244
|
-
return _asyncToGenerator(function* () {
|
2245
|
-
if (!_this18.crypto) {
|
2246
|
-
throw new Error("End-to-end encryption disabled");
|
2247
|
-
}
|
2248
|
-
yield _this18.crypto.backupManager.createKeyBackupVersion(info);
|
2249
|
-
var data = {
|
2250
|
-
algorithm: info.algorithm,
|
2251
|
-
auth_data: info.auth_data
|
2252
|
-
};
|
2253
|
-
|
2254
|
-
// Sign the backup auth data with the device key for backwards compat with
|
2255
|
-
// older devices with cross-signing. This can probably go away very soon in
|
2256
|
-
// favour of just signing with the cross-singing master key.
|
2257
|
-
// XXX: Private member access
|
2258
|
-
yield _this18.crypto.signObject(data.auth_data);
|
2259
|
-
if (_this18.cryptoCallbacks.getCrossSigningKey &&
|
2260
|
-
// XXX: Private member access
|
2261
|
-
_this18.crypto.crossSigningInfo.getId()) {
|
2262
|
-
// now also sign the auth data with the cross-signing master key
|
2263
|
-
// we check for the callback explicitly here because we still want to be able
|
2264
|
-
// to create an un-cross-signed key backup if there is a cross-signing key but
|
2265
|
-
// no callback supplied.
|
2266
|
-
// XXX: Private member access
|
2267
|
-
yield _this18.crypto.crossSigningInfo.signObject(data.auth_data, "master");
|
2268
|
-
}
|
2269
|
-
var res = yield _this18.http.authedRequest(Method.Post, "/room_keys/version", undefined, data);
|
2270
|
-
|
2271
|
-
// We could assume everything's okay and enable directly, but this ensures
|
2272
|
-
// we run the same signature verification that will be used for future
|
2273
|
-
// sessions.
|
2274
|
-
yield _this18.checkKeyBackup();
|
2275
|
-
if (!_this18.getKeyBackupEnabled()) {
|
2276
|
-
_this18.logger.error("Key backup not usable even though we just created it");
|
2277
|
-
}
|
2278
|
-
return res;
|
2279
|
-
})();
|
2280
|
-
}
|
2281
|
-
|
2282
|
-
/**
|
2283
|
-
* @deprecated Use {@link Crypto.CryptoApi.deleteKeyBackupVersion | `CryptoApi.deleteKeyBackupVersion`}.
|
2284
|
-
*/
|
2285
|
-
deleteKeyBackupVersion(version) {
|
2286
|
-
var _this19 = this;
|
2287
|
-
return _asyncToGenerator(function* () {
|
2288
|
-
if (!_this19.cryptoBackend) {
|
2289
|
-
throw new Error("End-to-end encryption disabled");
|
2290
|
-
}
|
2291
|
-
yield _this19.cryptoBackend.deleteKeyBackupVersion(version);
|
2292
|
-
})();
|
2293
|
-
}
|
2294
|
-
makeKeyBackupPath(roomId, sessionId, version) {
|
2295
|
-
var path;
|
2296
|
-
if (sessionId !== undefined) {
|
2297
|
-
path = utils.encodeUri("/room_keys/keys/$roomId/$sessionId", {
|
2298
|
-
$roomId: roomId,
|
2299
|
-
$sessionId: sessionId
|
2300
|
-
});
|
2301
|
-
} else if (roomId !== undefined) {
|
2302
|
-
path = utils.encodeUri("/room_keys/keys/$roomId", {
|
2303
|
-
$roomId: roomId
|
2304
|
-
});
|
2305
|
-
} else {
|
2306
|
-
path = "/room_keys/keys";
|
2307
|
-
}
|
2308
|
-
var queryData = version === undefined ? undefined : {
|
2309
|
-
version
|
2310
|
-
};
|
2311
|
-
return {
|
2312
|
-
path,
|
2313
|
-
queryData
|
2314
|
-
};
|
2315
|
-
}
|
2316
|
-
|
2317
|
-
/**
|
2318
|
-
* Back up session keys to the homeserver.
|
2319
|
-
* @param roomId - ID of the room that the keys are for Optional.
|
2320
|
-
* @param sessionId - ID of the session that the keys are for Optional.
|
2321
|
-
* @param version - backup version Optional.
|
2322
|
-
* @param data - Object keys to send
|
2323
|
-
* @returns a promise that will resolve when the keys
|
2324
|
-
* are uploaded
|
2325
|
-
*
|
2326
|
-
* @deprecated Not supported for Rust Cryptography.
|
2327
|
-
*/
|
2328
|
-
|
2329
|
-
sendKeyBackup(roomId, sessionId, version, data) {
|
2330
|
-
var _this20 = this;
|
2331
|
-
return _asyncToGenerator(function* () {
|
2332
|
-
if (!_this20.crypto) {
|
2333
|
-
throw new Error("End-to-end encryption disabled");
|
2334
|
-
}
|
2335
|
-
var path = _this20.makeKeyBackupPath(roomId, sessionId, version);
|
2336
|
-
yield _this20.http.authedRequest(Method.Put, path.path, path.queryData, data, {
|
2337
|
-
prefix: ClientPrefix.V3
|
2338
|
-
});
|
2339
|
-
})();
|
2340
|
-
}
|
2341
|
-
|
2342
|
-
/**
|
2343
|
-
* Marks all group sessions as needing to be backed up and schedules them to
|
2344
|
-
* upload in the background as soon as possible.
|
2345
|
-
*
|
2346
|
-
* @deprecated Not supported for Rust Cryptography. This is done automatically as part of
|
2347
|
-
* {@link CryptoApi.resetKeyBackup}, so there is probably no need to call this manually.
|
2348
|
-
*/
|
2349
|
-
scheduleAllGroupSessionsForBackup() {
|
2350
|
-
var _this21 = this;
|
2351
|
-
return _asyncToGenerator(function* () {
|
2352
|
-
if (!_this21.crypto) {
|
2353
|
-
throw new Error("End-to-end encryption disabled");
|
2354
|
-
}
|
2355
|
-
yield _this21.crypto.backupManager.scheduleAllGroupSessionsForBackup();
|
2356
|
-
})();
|
2357
|
-
}
|
2358
|
-
|
2359
|
-
/**
|
2360
|
-
* Marks all group sessions as needing to be backed up without scheduling
|
2361
|
-
* them to upload in the background.
|
2362
|
-
*
|
2363
|
-
* (This is done automatically as part of {@link CryptoApi.resetKeyBackup},
|
2364
|
-
* so there is probably no need to call this manually.)
|
2365
|
-
*
|
2366
|
-
* @returns Promise which resolves to the number of sessions requiring a backup.
|
2367
|
-
* @deprecated Not supported for Rust Cryptography.
|
2368
|
-
*/
|
2369
|
-
flagAllGroupSessionsForBackup() {
|
2370
|
-
if (!this.crypto) {
|
2371
|
-
throw new Error("End-to-end encryption disabled");
|
2372
|
-
}
|
2373
|
-
return this.crypto.backupManager.flagAllGroupSessionsForBackup();
|
2374
|
-
}
|
2375
|
-
|
2376
|
-
/**
|
2377
|
-
* Return true if recovery key is valid.
|
2378
|
-
* Try to decode the recovery key and check if it's successful.
|
2379
|
-
* @param recoveryKey
|
2380
|
-
* @deprecated Use {@link decodeRecoveryKey} directly
|
2381
|
-
*/
|
2382
|
-
isValidRecoveryKey(recoveryKey) {
|
2383
|
-
try {
|
2384
|
-
decodeRecoveryKey(recoveryKey);
|
2385
|
-
return true;
|
2386
|
-
} catch (_unused2) {
|
2387
|
-
return false;
|
2388
|
-
}
|
2389
|
-
}
|
2390
|
-
|
2391
|
-
/**
|
2392
|
-
* Get the raw key for a key backup from the password
|
2393
|
-
* Used when migrating key backups into SSSS
|
2394
|
-
*
|
2395
|
-
* The cross-signing API is currently UNSTABLE and may change without notice.
|
2396
|
-
*
|
2397
|
-
* @param password - Passphrase
|
2398
|
-
* @param backupInfo - Backup metadata from `checkKeyBackup`
|
2399
|
-
* @returns key backup key
|
2400
|
-
* @deprecated Deriving a backup key from a passphrase is not part of the matrix spec. Instead, a random key is generated and stored/shared via 4S.
|
2401
|
-
*/
|
2402
|
-
keyBackupKeyFromPassword(password, backupInfo) {
|
2403
|
-
return keyFromAuthData(backupInfo.auth_data, password);
|
2404
|
-
}
|
2405
|
-
|
2406
|
-
/**
|
2407
|
-
* Get the raw key for a key backup from the recovery key
|
2408
|
-
* Used when migrating key backups into SSSS
|
2409
|
-
*
|
2410
|
-
* The cross-signing API is currently UNSTABLE and may change without notice.
|
2411
|
-
*
|
2412
|
-
* @param recoveryKey - The recovery key
|
2413
|
-
* @returns key backup key
|
2414
|
-
* @deprecated Use {@link decodeRecoveryKey} directly
|
2415
|
-
*/
|
2416
|
-
keyBackupKeyFromRecoveryKey(recoveryKey) {
|
2417
|
-
return decodeRecoveryKey(recoveryKey);
|
2418
|
-
}
|
2419
|
-
|
2420
|
-
/**
|
2421
|
-
* Restore from an existing key backup via a passphrase.
|
2422
|
-
*
|
2423
|
-
* @param password - Passphrase
|
2424
|
-
* @param targetRoomId - Room ID to target a specific room.
|
2425
|
-
* Restores all rooms if omitted.
|
2426
|
-
* @param targetSessionId - Session ID to target a specific session.
|
2427
|
-
* Restores all sessions if omitted.
|
2428
|
-
* @param backupInfo - Backup metadata from `getKeyBackupVersion` or `checkKeyBackup`.`backupInfo`
|
2429
|
-
* @param opts - Optional params such as callbacks
|
2430
|
-
* @returns Status of restoration with `total` and `imported`
|
2431
|
-
* key counts.
|
2432
|
-
*
|
2433
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackupWithPassphrase | `CryptoApi.restoreKeyBackupWithPassphrase`}.
|
2434
|
-
*/
|
2435
|
-
|
2436
|
-
/**
|
2437
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackupWithPassphrase | `CryptoApi.restoreKeyBackupWithPassphrase`}.
|
2438
|
-
*/
|
2439
|
-
|
2440
|
-
/**
|
2441
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackupWithPassphrase | `CryptoApi.restoreKeyBackupWithPassphrase`}.
|
2442
|
-
*/
|
2443
|
-
|
2444
|
-
/**
|
2445
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackupWithPassphrase | `CryptoApi.restoreKeyBackupWithPassphrase`}.
|
2446
|
-
*/
|
2447
|
-
restoreKeyBackupWithPassword(password, targetRoomId, targetSessionId, backupInfo, opts) {
|
2448
|
-
var _this22 = this;
|
2449
|
-
return _asyncToGenerator(function* () {
|
2450
|
-
var privKey = yield keyFromAuthData(backupInfo.auth_data, password);
|
2451
|
-
return _this22.restoreKeyBackup(privKey, targetRoomId, targetSessionId, backupInfo, opts);
|
2452
|
-
})();
|
2453
|
-
}
|
2454
|
-
|
2455
|
-
/**
|
2456
|
-
* Restore from an existing key backup via a private key stored in secret
|
2457
|
-
* storage.
|
2458
|
-
*
|
2459
|
-
* @param backupInfo - Backup metadata from `checkKeyBackup`
|
2460
|
-
* @param targetRoomId - Room ID to target a specific room.
|
2461
|
-
* Restores all rooms if omitted.
|
2462
|
-
* @param targetSessionId - Session ID to target a specific session.
|
2463
|
-
* Restores all sessions if omitted.
|
2464
|
-
* @param opts - Optional params such as callbacks
|
2465
|
-
* @returns Status of restoration with `total` and `imported`
|
2466
|
-
* key counts.
|
2467
|
-
*
|
2468
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
2469
|
-
*/
|
2470
|
-
restoreKeyBackupWithSecretStorage(backupInfo, targetRoomId, targetSessionId, opts) {
|
2471
|
-
var _this23 = this;
|
2472
|
-
return _asyncToGenerator(function* () {
|
2473
|
-
if (!_this23.cryptoBackend) {
|
2474
|
-
throw new Error("End-to-end encryption disabled");
|
2475
|
-
}
|
2476
|
-
var storedKey = yield _this23.secretStorage.get("m.megolm_backup.v1");
|
2477
|
-
|
2478
|
-
// ensure that the key is in the right format. If not, fix the key and
|
2479
|
-
// store the fixed version
|
2480
|
-
var fixedKey = fixBackupKey(storedKey);
|
2481
|
-
if (fixedKey) {
|
2482
|
-
var keys = yield _this23.secretStorage.getKey();
|
2483
|
-
yield _this23.secretStorage.store("m.megolm_backup.v1", fixedKey, [keys[0]]);
|
2484
|
-
}
|
2485
|
-
var privKey = decodeBase64(fixedKey || storedKey);
|
2486
|
-
return _this23.restoreKeyBackup(privKey, targetRoomId, targetSessionId, backupInfo, opts);
|
2487
|
-
})();
|
2488
|
-
}
|
2489
|
-
|
2490
|
-
/**
|
2491
|
-
* Restore from an existing key backup via an encoded recovery key.
|
2492
|
-
*
|
2493
|
-
* @param recoveryKey - Encoded recovery key
|
2494
|
-
* @param targetRoomId - Room ID to target a specific room.
|
2495
|
-
* Restores all rooms if omitted.
|
2496
|
-
* @param targetSessionId - Session ID to target a specific session.
|
2497
|
-
* Restores all sessions if omitted.
|
2498
|
-
* @param backupInfo - Backup metadata from `checkKeyBackup`
|
2499
|
-
* @param opts - Optional params such as callbacks
|
2500
|
-
* @returns Status of restoration with `total` and `imported`
|
2501
|
-
* key counts.
|
2502
|
-
*
|
2503
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
2504
|
-
*/
|
2505
|
-
|
2506
|
-
/**
|
2507
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
2508
|
-
*/
|
2509
|
-
|
2510
|
-
/**
|
2511
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
2512
|
-
*/
|
2513
|
-
|
2514
|
-
/**
|
2515
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
2516
|
-
*/
|
2517
|
-
restoreKeyBackupWithRecoveryKey(recoveryKey, targetRoomId, targetSessionId, backupInfo, opts) {
|
2518
|
-
var privKey = decodeRecoveryKey(recoveryKey);
|
2519
|
-
return this.restoreKeyBackup(privKey, targetRoomId, targetSessionId, backupInfo, opts);
|
2520
|
-
}
|
2521
|
-
|
2522
|
-
/**
|
2523
|
-
* Restore from an existing key backup via a private key stored locally
|
2524
|
-
* @param targetRoomId
|
2525
|
-
* @param targetSessionId
|
2526
|
-
* @param backupInfo
|
2527
|
-
* @param opts
|
2528
|
-
*
|
2529
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
2530
|
-
*/
|
2531
|
-
|
2532
|
-
/**
|
2533
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
2534
|
-
*/
|
2535
|
-
|
2536
|
-
/**
|
2537
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
2538
|
-
*/
|
2539
|
-
|
2540
|
-
/**
|
2541
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
2542
|
-
*/
|
2543
|
-
restoreKeyBackupWithCache(targetRoomId, targetSessionId, backupInfo, opts) {
|
2544
|
-
var _this24 = this;
|
2545
|
-
return _asyncToGenerator(function* () {
|
2546
|
-
if (!_this24.cryptoBackend) {
|
2547
|
-
throw new Error("End-to-end encryption disabled");
|
2548
|
-
}
|
2549
|
-
var privKey = yield _this24.cryptoBackend.getSessionBackupPrivateKey();
|
2550
|
-
if (!privKey) {
|
2551
|
-
throw new Error("Couldn't get key");
|
2552
|
-
}
|
2553
|
-
return _this24.restoreKeyBackup(privKey, targetRoomId, targetSessionId, backupInfo, opts);
|
2554
|
-
})();
|
2555
|
-
}
|
2556
|
-
restoreKeyBackup(privKey, targetRoomId, targetSessionId, backupInfo, opts) {
|
2557
|
-
var _this25 = this;
|
2558
|
-
return _asyncToGenerator(function* () {
|
2559
|
-
var cacheCompleteCallback = opts === null || opts === void 0 ? void 0 : opts.cacheCompleteCallback;
|
2560
|
-
var progressCallback = opts === null || opts === void 0 ? void 0 : opts.progressCallback;
|
2561
|
-
if (!_this25.cryptoBackend) {
|
2562
|
-
throw new Error("End-to-end encryption disabled");
|
2563
|
-
}
|
2564
|
-
if (!backupInfo.version) {
|
2565
|
-
throw new Error("Backup version must be defined");
|
2566
|
-
}
|
2567
|
-
var backupVersion = backupInfo.version;
|
2568
|
-
var totalKeyCount = 0;
|
2569
|
-
var totalFailures = 0;
|
2570
|
-
var totalImported = 0;
|
2571
|
-
var path = _this25.makeKeyBackupPath(targetRoomId, targetSessionId, backupVersion);
|
2572
|
-
var backupDecryptor = yield _this25.cryptoBackend.getBackupDecryptor(backupInfo, privKey);
|
2573
|
-
var untrusted = !backupDecryptor.sourceTrusted;
|
2574
|
-
try {
|
2575
|
-
if (!(privKey instanceof Uint8Array)) {
|
2576
|
-
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
2577
|
-
throw new Error("restoreKeyBackup expects Uint8Array, got ".concat(privKey));
|
2578
|
-
}
|
2579
|
-
// Cache the key, if possible.
|
2580
|
-
// This is async.
|
2581
|
-
_this25.cryptoBackend.storeSessionBackupPrivateKey(privKey, backupVersion).catch(e => {
|
2582
|
-
_this25.logger.warn("Error caching session backup key:", e);
|
2583
|
-
}).then(cacheCompleteCallback);
|
2584
|
-
if (progressCallback) {
|
2585
|
-
progressCallback({
|
2586
|
-
stage: "fetch"
|
2587
|
-
});
|
2588
|
-
}
|
2589
|
-
var res = yield _this25.http.authedRequest(Method.Get, path.path, path.queryData, undefined, {
|
2590
|
-
prefix: ClientPrefix.V3
|
2591
|
-
});
|
2592
|
-
|
2593
|
-
// We have finished fetching the backup, go to next step
|
2594
|
-
if (progressCallback) {
|
2595
|
-
progressCallback({
|
2596
|
-
stage: "load_keys"
|
2597
|
-
});
|
2598
|
-
}
|
2599
|
-
if (res.rooms) {
|
2600
|
-
// We have a full backup here, it can get quite big, so we need to decrypt and import it in chunks.
|
2601
|
-
|
2602
|
-
// Get the total count as a first pass
|
2603
|
-
totalKeyCount = _this25.getTotalKeyCount(res);
|
2604
|
-
// Now decrypt and import the keys in chunks
|
2605
|
-
yield _this25.handleDecryptionOfAFullBackup(res, backupDecryptor, 200, /*#__PURE__*/function () {
|
2606
|
-
var _ref3 = _asyncToGenerator(function* (chunk) {
|
2607
|
-
// We have a chunk of decrypted keys: import them
|
2608
|
-
try {
|
2609
|
-
var _backupVersion = backupInfo.version;
|
2610
|
-
yield _this25.cryptoBackend.importBackedUpRoomKeys(chunk, _backupVersion, {
|
2611
|
-
untrusted
|
2612
|
-
});
|
2613
|
-
totalImported += chunk.length;
|
2614
|
-
} catch (e) {
|
2615
|
-
totalFailures += chunk.length;
|
2616
|
-
// We failed to import some keys, but we should still try to import the rest?
|
2617
|
-
// Log the error and continue
|
2618
|
-
logger.error("Error importing keys from backup", e);
|
2619
|
-
}
|
2620
|
-
if (progressCallback) {
|
2621
|
-
progressCallback({
|
2622
|
-
total: totalKeyCount,
|
2623
|
-
successes: totalImported,
|
2624
|
-
stage: "load_keys",
|
2625
|
-
failures: totalFailures
|
2626
|
-
});
|
2627
|
-
}
|
2628
|
-
});
|
2629
|
-
return function (_x2) {
|
2630
|
-
return _ref3.apply(this, arguments);
|
2631
|
-
};
|
2632
|
-
}());
|
2633
|
-
} else if (res.sessions) {
|
2634
|
-
// For now we don't chunk for a single room backup, but we could in the future.
|
2635
|
-
// Currently it is not used by the application.
|
2636
|
-
var sessions = res.sessions;
|
2637
|
-
totalKeyCount = Object.keys(sessions).length;
|
2638
|
-
var keys = yield backupDecryptor.decryptSessions(sessions);
|
2639
|
-
for (var _k of keys) {
|
2640
|
-
_k.room_id = targetRoomId;
|
2641
|
-
}
|
2642
|
-
yield _this25.cryptoBackend.importBackedUpRoomKeys(keys, backupVersion, {
|
2643
|
-
progressCallback,
|
2644
|
-
untrusted
|
2645
|
-
});
|
2646
|
-
totalImported = keys.length;
|
2647
|
-
} else {
|
2648
|
-
totalKeyCount = 1;
|
2649
|
-
try {
|
2650
|
-
var [_key2] = yield backupDecryptor.decryptSessions({
|
2651
|
-
[targetSessionId]: res
|
2652
|
-
});
|
2653
|
-
_key2.room_id = targetRoomId;
|
2654
|
-
_key2.session_id = targetSessionId;
|
2655
|
-
yield _this25.cryptoBackend.importBackedUpRoomKeys([_key2], backupVersion, {
|
2656
|
-
progressCallback,
|
2657
|
-
untrusted
|
2658
|
-
});
|
2659
|
-
totalImported = 1;
|
2660
|
-
} catch (e) {
|
2661
|
-
_this25.logger.debug("Failed to decrypt megolm session from backup", e);
|
2662
|
-
}
|
2663
|
-
}
|
2664
|
-
} finally {
|
2665
|
-
backupDecryptor.free();
|
2666
|
-
}
|
2667
|
-
|
2668
|
-
/// in case entering the passphrase would add a new signature?
|
2669
|
-
yield _this25.cryptoBackend.checkKeyBackupAndEnable();
|
2670
|
-
return {
|
2671
|
-
total: totalKeyCount,
|
2672
|
-
imported: totalImported
|
2673
|
-
};
|
579
|
+
/**
|
580
|
+
* Gets the cached capabilities of the homeserver, returning cached ones if available.
|
581
|
+
* If there are no cached capabilities and none can be fetched, throw an exception.
|
582
|
+
*
|
583
|
+
* @returns Promise resolving with The capabilities of the homeserver
|
584
|
+
*/
|
585
|
+
getCapabilities() {
|
586
|
+
var _this3 = this;
|
587
|
+
return _asyncToGenerator(function* () {
|
588
|
+
var caps = _this3.serverCapabilitiesService.getCachedCapabilities();
|
589
|
+
if (caps) return caps;
|
590
|
+
return _this3.serverCapabilitiesService.fetchCapabilities();
|
2674
591
|
})();
|
2675
592
|
}
|
2676
593
|
|
2677
594
|
/**
|
2678
|
-
*
|
2679
|
-
*
|
2680
|
-
* @param res - The response from the server containing the keys to be counted.
|
595
|
+
* Gets the cached capabilities of the homeserver. If none have been fetched yet,
|
596
|
+
* return undefined.
|
2681
597
|
*
|
2682
|
-
* @returns The
|
2683
|
-
*/
|
2684
|
-
|
2685
|
-
|
2686
|
-
var totalKeyCount = 0;
|
2687
|
-
for (var roomData of Object.values(rooms)) {
|
2688
|
-
if (!roomData.sessions) continue;
|
2689
|
-
totalKeyCount += Object.keys(roomData.sessions).length;
|
2690
|
-
}
|
2691
|
-
return totalKeyCount;
|
598
|
+
* @returns The capabilities of the homeserver
|
599
|
+
*/
|
600
|
+
getCachedCapabilities() {
|
601
|
+
return this.serverCapabilitiesService.getCachedCapabilities();
|
2692
602
|
}
|
2693
603
|
|
2694
604
|
/**
|
2695
|
-
*
|
2696
|
-
*
|
2697
|
-
*
|
2698
|
-
* @param res - The response from the server containing the keys to be decrypted.
|
2699
|
-
* @param backupDecryptor - An instance of the BackupDecryptor class used to decrypt the keys.
|
2700
|
-
* @param chunkSize - The size of the chunks to be processed at a time.
|
2701
|
-
* @param block - A callback function that is called for each chunk of keys.
|
605
|
+
* Fetches the latest capabilities from the homeserver, ignoring any cached
|
606
|
+
* versions. The newly returned version is cached.
|
2702
607
|
*
|
2703
|
-
* @returns A promise
|
608
|
+
* @returns A promise which resolves to the capabilities of the homeserver
|
2704
609
|
*/
|
2705
|
-
|
2706
|
-
return
|
2707
|
-
var rooms = res.rooms;
|
2708
|
-
var groupChunkCount = 0;
|
2709
|
-
var chunkGroupByRoom = new Map();
|
2710
|
-
var handleChunkCallback = /*#__PURE__*/function () {
|
2711
|
-
var _ref4 = _asyncToGenerator(function* (roomChunks) {
|
2712
|
-
var currentChunk = [];
|
2713
|
-
for (var _roomId of roomChunks.keys()) {
|
2714
|
-
var decryptedSessions = yield backupDecryptor.decryptSessions(roomChunks.get(_roomId));
|
2715
|
-
for (var _sessionId in decryptedSessions) {
|
2716
|
-
var _k2 = decryptedSessions[_sessionId];
|
2717
|
-
_k2.room_id = _roomId;
|
2718
|
-
currentChunk.push(_k2);
|
2719
|
-
}
|
2720
|
-
}
|
2721
|
-
yield block(currentChunk);
|
2722
|
-
});
|
2723
|
-
return function handleChunkCallback(_x3) {
|
2724
|
-
return _ref4.apply(this, arguments);
|
2725
|
-
};
|
2726
|
-
}();
|
2727
|
-
for (var [_roomId2, roomData] of Object.entries(rooms)) {
|
2728
|
-
if (!roomData.sessions) continue;
|
2729
|
-
chunkGroupByRoom.set(_roomId2, {});
|
2730
|
-
for (var [_sessionId2, session] of Object.entries(roomData.sessions)) {
|
2731
|
-
var sessionsForRoom = chunkGroupByRoom.get(_roomId2);
|
2732
|
-
sessionsForRoom[_sessionId2] = session;
|
2733
|
-
groupChunkCount += 1;
|
2734
|
-
if (groupChunkCount >= chunkSize) {
|
2735
|
-
// We have enough chunks to decrypt
|
2736
|
-
yield handleChunkCallback(chunkGroupByRoom);
|
2737
|
-
chunkGroupByRoom = new Map();
|
2738
|
-
// There might be remaining keys for that room, so add back an entry for the current room.
|
2739
|
-
chunkGroupByRoom.set(_roomId2, {});
|
2740
|
-
groupChunkCount = 0;
|
2741
|
-
}
|
2742
|
-
}
|
2743
|
-
}
|
2744
|
-
|
2745
|
-
// Handle remaining chunk if needed
|
2746
|
-
if (groupChunkCount > 0) {
|
2747
|
-
yield handleChunkCallback(chunkGroupByRoom);
|
2748
|
-
}
|
2749
|
-
})();
|
610
|
+
fetchCapabilities() {
|
611
|
+
return this.serverCapabilitiesService.fetchCapabilities();
|
2750
612
|
}
|
2751
|
-
|
2752
|
-
|
613
|
+
|
614
|
+
/**
|
615
|
+
* @deprecated Does nothing.
|
616
|
+
*/
|
617
|
+
uploadKeys() {
|
618
|
+
var _this4 = this;
|
2753
619
|
return _asyncToGenerator(function* () {
|
2754
|
-
|
2755
|
-
yield _this26.http.authedRequest(Method.Delete, path.path, path.queryData, undefined, {
|
2756
|
-
prefix: ClientPrefix.V3
|
2757
|
-
});
|
620
|
+
_this4.logger.warn("MatrixClient.uploadKeys is deprecated");
|
2758
621
|
})();
|
2759
622
|
}
|
2760
623
|
|
@@ -2876,10 +739,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
2876
739
|
* @returns Rejects: with an error response.
|
2877
740
|
*/
|
2878
741
|
getAccountDataFromServer(eventType) {
|
2879
|
-
var
|
742
|
+
var _this5 = this;
|
2880
743
|
return _asyncToGenerator(function* () {
|
2881
|
-
if (
|
2882
|
-
var _event =
|
744
|
+
if (_this5.isInitialSyncComplete()) {
|
745
|
+
var _event = _this5.store.getAccountData(eventType);
|
2883
746
|
if (!_event) {
|
2884
747
|
return null;
|
2885
748
|
}
|
@@ -2888,11 +751,11 @@ export class MatrixClient extends TypedEventEmitter {
|
|
2888
751
|
return _event.getContent();
|
2889
752
|
}
|
2890
753
|
var path = utils.encodeUri("/user/$userId/account_data/$type", {
|
2891
|
-
$userId:
|
754
|
+
$userId: _this5.credentials.userId,
|
2892
755
|
$type: eventType
|
2893
756
|
});
|
2894
757
|
try {
|
2895
|
-
return yield
|
758
|
+
return yield _this5.http.authedRequest(Method.Get, path);
|
2896
759
|
} catch (e) {
|
2897
760
|
var _data;
|
2898
761
|
if (((_data = e.data) === null || _data === void 0 ? void 0 : _data.errcode) === "M_NOT_FOUND") {
|
@@ -2903,22 +766,22 @@ export class MatrixClient extends TypedEventEmitter {
|
|
2903
766
|
})();
|
2904
767
|
}
|
2905
768
|
deleteAccountData(eventType) {
|
2906
|
-
var
|
769
|
+
var _this6 = this;
|
2907
770
|
return _asyncToGenerator(function* () {
|
2908
|
-
var msc3391DeleteAccountDataServerSupport =
|
771
|
+
var msc3391DeleteAccountDataServerSupport = _this6.canSupport.get(Feature.AccountDataDeletion);
|
2909
772
|
// if deletion is not supported overwrite with empty content
|
2910
773
|
if (msc3391DeleteAccountDataServerSupport === ServerSupport.Unsupported) {
|
2911
|
-
yield
|
774
|
+
yield _this6.setAccountData(eventType, {});
|
2912
775
|
return;
|
2913
776
|
}
|
2914
777
|
var path = utils.encodeUri("/user/$userId/account_data/$type", {
|
2915
|
-
$userId:
|
778
|
+
$userId: _this6.getSafeUserId(),
|
2916
779
|
$type: eventType
|
2917
780
|
});
|
2918
781
|
var options = msc3391DeleteAccountDataServerSupport === ServerSupport.Unstable ? {
|
2919
782
|
prefix: "/_matrix/client/unstable/org.matrix.msc3391"
|
2920
783
|
} : undefined;
|
2921
|
-
return yield
|
784
|
+
return yield _this6.http.authedRequest(Method.Delete, path, undefined, undefined, options);
|
2922
785
|
})();
|
2923
786
|
}
|
2924
787
|
|
@@ -2965,20 +828,20 @@ export class MatrixClient extends TypedEventEmitter {
|
|
2965
828
|
* @returns Rejects: with an error response.
|
2966
829
|
*/
|
2967
830
|
joinRoom(roomIdOrAlias) {
|
2968
|
-
var
|
2969
|
-
|
831
|
+
var _arguments = arguments,
|
832
|
+
_this7 = this;
|
2970
833
|
return _asyncToGenerator(function* () {
|
2971
|
-
var opts =
|
834
|
+
var opts = _arguments.length > 1 && _arguments[1] !== undefined ? _arguments[1] : {};
|
2972
835
|
if (opts.syncRoom === undefined) {
|
2973
836
|
opts.syncRoom = true;
|
2974
837
|
}
|
2975
|
-
var room =
|
2976
|
-
if (room !== null && room !== void 0 && room.hasMembershipState(
|
838
|
+
var room = _this7.getRoom(roomIdOrAlias);
|
839
|
+
if (room !== null && room !== void 0 && room.hasMembershipState(_this7.credentials.userId, KnownMembership.Join)) return room;
|
2977
840
|
var signPromise = Promise.resolve();
|
2978
841
|
if (opts.inviteSignUrl) {
|
2979
842
|
var _url = new URL(opts.inviteSignUrl);
|
2980
|
-
_url.searchParams.set("mxid",
|
2981
|
-
signPromise =
|
843
|
+
_url.searchParams.set("mxid", _this7.credentials.userId);
|
844
|
+
signPromise = _this7.http.requestOtherUrl(Method.Post, _url);
|
2982
845
|
}
|
2983
846
|
var queryParams = {};
|
2984
847
|
if (opts.viaServers) {
|
@@ -2994,14 +857,14 @@ export class MatrixClient extends TypedEventEmitter {
|
|
2994
857
|
var path = utils.encodeUri("/join/$roomid", {
|
2995
858
|
$roomid: roomIdOrAlias
|
2996
859
|
});
|
2997
|
-
var res = yield
|
860
|
+
var res = yield _this7.http.authedRequest(Method.Post, path, queryParams, data);
|
2998
861
|
var roomId = res.room_id;
|
2999
862
|
// In case we were originally given an alias, check the room cache again
|
3000
863
|
// with the resolved ID - this method is supposed to no-op if we already
|
3001
864
|
// were in the room, after all.
|
3002
|
-
var resolvedRoom =
|
3003
|
-
if (resolvedRoom !== null && resolvedRoom !== void 0 && resolvedRoom.hasMembershipState(
|
3004
|
-
var syncApi = new SyncApi(
|
865
|
+
var resolvedRoom = _this7.getRoom(roomId);
|
866
|
+
if (resolvedRoom !== null && resolvedRoom !== void 0 && resolvedRoom.hasMembershipState(_this7.credentials.userId, KnownMembership.Join)) return resolvedRoom;
|
867
|
+
var syncApi = new SyncApi(_this7, _this7.clientOpts, _this7.buildSyncApiOptions());
|
3005
868
|
var syncRoom = syncApi.createRoom(roomId);
|
3006
869
|
if (opts.syncRoom) {
|
3007
870
|
// v2 will do this for us
|
@@ -3171,17 +1034,17 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3171
1034
|
* @returns Rejects: with an error response.
|
3172
1035
|
*/
|
3173
1036
|
setPowerLevel(roomId, userId, powerLevel) {
|
3174
|
-
var
|
1037
|
+
var _this8 = this;
|
3175
1038
|
return _asyncToGenerator(function* () {
|
3176
1039
|
var _content;
|
3177
1040
|
var content;
|
3178
|
-
if (
|
3179
|
-
var
|
3180
|
-
content = (
|
1041
|
+
if (_this8.clientRunning && _this8.isInitialSyncComplete()) {
|
1042
|
+
var _this8$getRoom;
|
1043
|
+
content = (_this8$getRoom = _this8.getRoom(roomId)) === null || _this8$getRoom === void 0 || (_this8$getRoom = _this8$getRoom.currentState) === null || _this8$getRoom === void 0 || (_this8$getRoom = _this8$getRoom.getStateEvents(EventType.RoomPowerLevels, "")) === null || _this8$getRoom === void 0 ? void 0 : _this8$getRoom.getContent();
|
3181
1044
|
}
|
3182
1045
|
if (!content) {
|
3183
1046
|
try {
|
3184
|
-
content = yield
|
1047
|
+
content = yield _this8.getStateEvent(roomId, EventType.RoomPowerLevels, "");
|
3185
1048
|
} catch (e) {
|
3186
1049
|
// It is possible for a Matrix room to not have a power levels event
|
3187
1050
|
if (e instanceof MatrixError && e.errcode === "M_NOT_FOUND") {
|
@@ -3206,7 +1069,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3206
1069
|
content.users[user] = powerLevel;
|
3207
1070
|
}
|
3208
1071
|
}
|
3209
|
-
return
|
1072
|
+
return _this8.sendStateEvent(roomId, EventType.RoomPowerLevels, content, "");
|
3210
1073
|
})();
|
3211
1074
|
}
|
3212
1075
|
|
@@ -3216,9 +1079,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3216
1079
|
*/
|
3217
1080
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
3218
1081
|
unstable_createLiveBeacon(roomId, beaconInfoContent) {
|
3219
|
-
var
|
1082
|
+
var _this9 = this;
|
3220
1083
|
return _asyncToGenerator(function* () {
|
3221
|
-
return
|
1084
|
+
return _this9.unstable_setLiveBeacon(roomId, beaconInfoContent);
|
3222
1085
|
})();
|
3223
1086
|
}
|
3224
1087
|
|
@@ -3230,9 +1093,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3230
1093
|
*/
|
3231
1094
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
3232
1095
|
unstable_setLiveBeacon(roomId, beaconInfoContent) {
|
3233
|
-
var
|
1096
|
+
var _this10 = this;
|
3234
1097
|
return _asyncToGenerator(function* () {
|
3235
|
-
return
|
1098
|
+
return _this10.sendStateEvent(roomId, M_BEACON_INFO.name, beaconInfoContent, _this10.getUserId());
|
3236
1099
|
})();
|
3237
1100
|
}
|
3238
1101
|
sendEvent(roomId, threadIdOrEventType, eventTypeOrContent, contentOrTxnId, txnIdOrVoid) {
|
@@ -3380,44 +1243,34 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3380
1243
|
*/
|
3381
1244
|
|
3382
1245
|
encryptAndSendEvent(room, event, delayOpts) {
|
3383
|
-
var
|
1246
|
+
var _this11 = this;
|
3384
1247
|
return _asyncToGenerator(function* () {
|
3385
1248
|
if (delayOpts) {
|
3386
|
-
return
|
1249
|
+
return _this11.sendEventHttpRequest(event, delayOpts);
|
3387
1250
|
}
|
3388
1251
|
try {
|
3389
|
-
|
3390
|
-
_this33.eventsBeingEncrypted.add(event.getId());
|
3391
|
-
try {
|
3392
|
-
yield _this33.encryptEventIfNeeded(event, room !== null && room !== void 0 ? room : undefined);
|
3393
|
-
} finally {
|
3394
|
-
cancelled = !_this33.eventsBeingEncrypted.delete(event.getId());
|
3395
|
-
}
|
3396
|
-
if (cancelled) {
|
3397
|
-
// cancelled via MatrixClient::cancelPendingEvent
|
3398
|
-
return {};
|
3399
|
-
}
|
1252
|
+
_this11.eventsBeingEncrypted.add(event.getId());
|
3400
1253
|
|
3401
1254
|
// encryptEventIfNeeded may have updated the status from SENDING to ENCRYPTING. If so, we need
|
3402
1255
|
// to put it back.
|
3403
1256
|
if (event.status === EventStatus.ENCRYPTING) {
|
3404
|
-
|
1257
|
+
_this11.updatePendingEventStatus(room, event, EventStatus.SENDING);
|
3405
1258
|
}
|
3406
1259
|
var promise = null;
|
3407
|
-
if (
|
1260
|
+
if (_this11.scheduler) {
|
3408
1261
|
// if this returns a promise then the scheduler has control now and will
|
3409
1262
|
// resolve/reject when it is done. Internally, the scheduler will invoke
|
3410
1263
|
// processFn which is set to this._sendEventHttpRequest so the same code
|
3411
1264
|
// path is executed regardless.
|
3412
|
-
promise =
|
3413
|
-
if (promise &&
|
1265
|
+
promise = _this11.scheduler.queueEvent(event);
|
1266
|
+
if (promise && _this11.scheduler.getQueueForEvent(event).length > 1) {
|
3414
1267
|
// event is processed FIFO so if the length is 2 or more we know
|
3415
1268
|
// this event is stuck behind an earlier event.
|
3416
|
-
|
1269
|
+
_this11.updatePendingEventStatus(room, event, EventStatus.QUEUED);
|
3417
1270
|
}
|
3418
1271
|
}
|
3419
1272
|
if (!promise) {
|
3420
|
-
promise =
|
1273
|
+
promise = _this11.sendEventHttpRequest(event);
|
3421
1274
|
if (room) {
|
3422
1275
|
promise = promise.then(res => {
|
3423
1276
|
room.updatePendingEvent(event, EventStatus.SENT, res["event_id"]);
|
@@ -3427,15 +1280,15 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3427
1280
|
}
|
3428
1281
|
return yield promise;
|
3429
1282
|
} catch (err) {
|
3430
|
-
|
1283
|
+
_this11.logger.error("Error sending event", err);
|
3431
1284
|
try {
|
3432
1285
|
// set the error on the event before we update the status:
|
3433
1286
|
// updating the status emits the event, so the state should be
|
3434
1287
|
// consistent at that point.
|
3435
1288
|
event.error = err;
|
3436
|
-
|
1289
|
+
_this11.updatePendingEventStatus(room, event, EventStatus.NOT_SENT);
|
3437
1290
|
} catch (e) {
|
3438
|
-
|
1291
|
+
_this11.logger.error("Exception in error handler!", e);
|
3439
1292
|
}
|
3440
1293
|
if (err instanceof MatrixError) {
|
3441
1294
|
err.event = event;
|
@@ -3444,70 +1297,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3444
1297
|
}
|
3445
1298
|
})();
|
3446
1299
|
}
|
3447
|
-
encryptEventIfNeeded(event, room) {
|
3448
|
-
var _this34 = this;
|
3449
|
-
return _asyncToGenerator(function* () {
|
3450
|
-
// If the room is unknown, we cannot encrypt for it
|
3451
|
-
if (!room) return;
|
3452
|
-
if (!(yield _this34.shouldEncryptEventForRoom(event, room))) return;
|
3453
|
-
if (!_this34.cryptoBackend && _this34.usingExternalCrypto) {
|
3454
|
-
// The client has opted to allow sending messages to encrypted
|
3455
|
-
// rooms even if the room is encrypted, and we haven't set up
|
3456
|
-
// crypto. This is useful for users of matrix-org/pantalaimon
|
3457
|
-
return;
|
3458
|
-
}
|
3459
|
-
if (!_this34.cryptoBackend) {
|
3460
|
-
throw new Error("This room is configured to use encryption, but your client does not support encryption.");
|
3461
|
-
}
|
3462
|
-
_this34.updatePendingEventStatus(room, event, EventStatus.ENCRYPTING);
|
3463
|
-
yield _this34.cryptoBackend.encryptEvent(event, room);
|
3464
|
-
})();
|
3465
|
-
}
|
3466
|
-
|
3467
|
-
/**
|
3468
|
-
* Determine whether a given event should be encrypted when we send it to the given room.
|
3469
|
-
*
|
3470
|
-
* This takes into account event type and room configuration.
|
3471
|
-
*/
|
3472
|
-
shouldEncryptEventForRoom(event, room) {
|
3473
|
-
var _this35 = this;
|
3474
|
-
return _asyncToGenerator(function* () {
|
3475
|
-
var _this35$cryptoBackend;
|
3476
|
-
if (event.isEncrypted()) {
|
3477
|
-
// this event has already been encrypted; this happens if the
|
3478
|
-
// encryption step succeeded, but the send step failed on the first
|
3479
|
-
// attempt.
|
3480
|
-
return false;
|
3481
|
-
}
|
3482
|
-
if (event.getType() === EventType.Reaction) {
|
3483
|
-
// For reactions, there is a very little gained by encrypting the entire
|
3484
|
-
// event, as relation data is already kept in the clear. Event
|
3485
|
-
// encryption for a reaction effectively only obscures the event type,
|
3486
|
-
// but the purpose is still obvious from the relation data, so nothing
|
3487
|
-
// is really gained. It also causes quite a few problems, such as:
|
3488
|
-
// * triggers notifications via default push rules
|
3489
|
-
// * prevents server-side bundling for reactions
|
3490
|
-
// The reaction key / content / emoji value does warrant encrypting, but
|
3491
|
-
// this will be handled separately by encrypting just this value.
|
3492
|
-
// See https://github.com/matrix-org/matrix-doc/pull/1849#pullrequestreview-248763642
|
3493
|
-
return false;
|
3494
|
-
}
|
3495
|
-
if (event.isRedaction()) {
|
3496
|
-
// Redactions do not support encryption in the spec at this time.
|
3497
|
-
// Whilst it mostly worked in some clients, it wasn't compliant.
|
3498
|
-
return false;
|
3499
|
-
}
|
3500
|
-
|
3501
|
-
// If the room has an m.room.encryption event, we should encrypt.
|
3502
|
-
if (room.hasEncryptionStateEvent()) return true;
|
3503
|
-
|
3504
|
-
// If we have a crypto impl, and *it* thinks we should encrypt, then we should.
|
3505
|
-
if (yield (_this35$cryptoBackend = _this35.cryptoBackend) === null || _this35$cryptoBackend === void 0 ? void 0 : _this35$cryptoBackend.isEncryptionEnabledInRoom(room.roomId)) return true;
|
3506
|
-
|
3507
|
-
// Otherwise, no need to encrypt.
|
3508
|
-
return false;
|
3509
|
-
})();
|
3510
|
-
}
|
3511
1300
|
|
3512
1301
|
/**
|
3513
1302
|
* Returns the eventType that should be used taking encryption into account
|
@@ -3770,13 +1559,13 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3770
1559
|
*/
|
3771
1560
|
// eslint-disable-next-line
|
3772
1561
|
_unstable_sendDelayedEvent(roomId, delayOpts, threadId, eventType, content, txnId) {
|
3773
|
-
var
|
1562
|
+
var _this12 = this;
|
3774
1563
|
return _asyncToGenerator(function* () {
|
3775
|
-
if (!(yield
|
1564
|
+
if (!(yield _this12.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
|
3776
1565
|
throw Error("Server does not support the delayed events API");
|
3777
1566
|
}
|
3778
|
-
|
3779
|
-
return
|
1567
|
+
_this12.addThreadRelationIfNeeded(content, threadId, roomId);
|
1568
|
+
return _this12.sendCompleteEvent(roomId, threadId, {
|
3780
1569
|
type: eventType,
|
3781
1570
|
content
|
3782
1571
|
}, delayOpts, txnId);
|
@@ -3791,12 +1580,12 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3791
1580
|
*/
|
3792
1581
|
// eslint-disable-next-line
|
3793
1582
|
_unstable_sendDelayedStateEvent(roomId, delayOpts, eventType, content) {
|
3794
|
-
var
|
3795
|
-
|
1583
|
+
var _arguments2 = arguments,
|
1584
|
+
_this13 = this;
|
3796
1585
|
return _asyncToGenerator(function* () {
|
3797
|
-
var stateKey =
|
3798
|
-
var opts =
|
3799
|
-
if (!(yield
|
1586
|
+
var stateKey = _arguments2.length > 4 && _arguments2[4] !== undefined ? _arguments2[4] : "";
|
1587
|
+
var opts = _arguments2.length > 5 && _arguments2[5] !== undefined ? _arguments2[5] : {};
|
1588
|
+
if (!(yield _this13.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
|
3800
1589
|
throw Error("Server does not support the delayed events API");
|
3801
1590
|
}
|
3802
1591
|
var pathParams = {
|
@@ -3808,7 +1597,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3808
1597
|
if (stateKey !== undefined) {
|
3809
1598
|
path = utils.encodeUri(path + "/$stateKey", pathParams);
|
3810
1599
|
}
|
3811
|
-
return
|
1600
|
+
return _this13.http.authedRequest(Method.Put, path, getUnstableDelayQueryOpts(delayOpts), content, opts);
|
3812
1601
|
})();
|
3813
1602
|
}
|
3814
1603
|
|
@@ -3820,15 +1609,15 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3820
1609
|
*/
|
3821
1610
|
// eslint-disable-next-line
|
3822
1611
|
_unstable_getDelayedEvents(fromToken) {
|
3823
|
-
var
|
1612
|
+
var _this14 = this;
|
3824
1613
|
return _asyncToGenerator(function* () {
|
3825
|
-
if (!(yield
|
1614
|
+
if (!(yield _this14.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
|
3826
1615
|
throw Error("Server does not support the delayed events API");
|
3827
1616
|
}
|
3828
1617
|
var queryDict = fromToken ? {
|
3829
1618
|
from: fromToken
|
3830
1619
|
} : undefined;
|
3831
|
-
return yield
|
1620
|
+
return yield _this14.http.authedRequest(Method.Get, "/delayed_events", queryDict, undefined, {
|
3832
1621
|
prefix: "".concat(ClientPrefix.Unstable, "/").concat(UNSTABLE_MSC4140_DELAYED_EVENTS)
|
3833
1622
|
});
|
3834
1623
|
})();
|
@@ -3842,9 +1631,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3842
1631
|
*/
|
3843
1632
|
// eslint-disable-next-line
|
3844
1633
|
_unstable_updateDelayedEvent(delayId, action) {
|
3845
|
-
var
|
1634
|
+
var _this15 = this;
|
3846
1635
|
return _asyncToGenerator(function* () {
|
3847
|
-
if (!(yield
|
1636
|
+
if (!(yield _this15.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
|
3848
1637
|
throw Error("Server does not support the delayed events API");
|
3849
1638
|
}
|
3850
1639
|
var path = utils.encodeUri("/delayed_events/$delayId", {
|
@@ -3853,7 +1642,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3853
1642
|
var data = {
|
3854
1643
|
action
|
3855
1644
|
};
|
3856
|
-
return yield
|
1645
|
+
return yield _this15.http.authedRequest(Method.Post, path, undefined, data, {
|
3857
1646
|
prefix: "".concat(ClientPrefix.Unstable, "/").concat(UNSTABLE_MSC4140_DELAYED_EVENTS)
|
3858
1647
|
});
|
3859
1648
|
})();
|
@@ -3870,11 +1659,11 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3870
1659
|
* @returns Rejects: with an error response.
|
3871
1660
|
*/
|
3872
1661
|
sendReceipt(event, receiptType, body) {
|
3873
|
-
var
|
3874
|
-
|
1662
|
+
var _arguments3 = arguments,
|
1663
|
+
_this16 = this;
|
3875
1664
|
return _asyncToGenerator(function* () {
|
3876
|
-
var unthreaded =
|
3877
|
-
if (
|
1665
|
+
var unthreaded = _arguments3.length > 3 && _arguments3[3] !== undefined ? _arguments3[3] : false;
|
1666
|
+
if (_this16.isGuest()) {
|
3878
1667
|
return Promise.resolve({}); // guests cannot send receipts so don't bother.
|
3879
1668
|
}
|
3880
1669
|
var path = utils.encodeUri("/rooms/$roomId/receipt/$receiptType/$eventId", {
|
@@ -3885,14 +1674,14 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3885
1674
|
|
3886
1675
|
// Unless we're explicitly making an unthreaded receipt or we don't
|
3887
1676
|
// support threads, include the `thread_id` property in the body.
|
3888
|
-
var shouldAddThreadId = !unthreaded &&
|
1677
|
+
var shouldAddThreadId = !unthreaded && _this16.supportsThreads();
|
3889
1678
|
var fullBody = shouldAddThreadId ? _objectSpread(_objectSpread({}, body), {}, {
|
3890
1679
|
thread_id: threadIdForReceipt(event)
|
3891
1680
|
}) : body;
|
3892
|
-
var promise =
|
3893
|
-
var room =
|
3894
|
-
if (room &&
|
3895
|
-
room.addLocalEchoReceipt(
|
1681
|
+
var promise = _this16.http.authedRequest(Method.Post, path, undefined, fullBody || {});
|
1682
|
+
var room = _this16.getRoom(event.getRoomId());
|
1683
|
+
if (room && _this16.credentials.userId) {
|
1684
|
+
room.addLocalEchoReceipt(_this16.credentials.userId, event, receiptType, unthreaded);
|
3896
1685
|
}
|
3897
1686
|
return promise;
|
3898
1687
|
})();
|
@@ -3906,18 +1695,18 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3906
1695
|
* @returns Rejects: with an error response.
|
3907
1696
|
*/
|
3908
1697
|
sendReadReceipt(event) {
|
3909
|
-
var
|
3910
|
-
|
1698
|
+
var _arguments4 = arguments,
|
1699
|
+
_this17 = this;
|
3911
1700
|
return _asyncToGenerator(function* () {
|
3912
|
-
var receiptType =
|
3913
|
-
var unthreaded =
|
1701
|
+
var receiptType = _arguments4.length > 1 && _arguments4[1] !== undefined ? _arguments4[1] : ReceiptType.Read;
|
1702
|
+
var unthreaded = _arguments4.length > 2 && _arguments4[2] !== undefined ? _arguments4[2] : false;
|
3914
1703
|
if (!event) return;
|
3915
1704
|
var eventId = event.getId();
|
3916
|
-
var room =
|
1705
|
+
var room = _this17.getRoom(event.getRoomId());
|
3917
1706
|
if (room !== null && room !== void 0 && room.hasPendingEvent(eventId)) {
|
3918
1707
|
throw new Error("Cannot set read receipt to a pending event (".concat(eventId, ")"));
|
3919
1708
|
}
|
3920
|
-
return
|
1709
|
+
return _this17.sendReceipt(event, receiptType, {}, unthreaded);
|
3921
1710
|
})();
|
3922
1711
|
}
|
3923
1712
|
|
@@ -3936,9 +1725,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3936
1725
|
* @returns Promise which resolves: the empty object, `{}`.
|
3937
1726
|
*/
|
3938
1727
|
setRoomReadMarkers(roomId, rmEventId, rrEvent, rpEvent) {
|
3939
|
-
var
|
1728
|
+
var _this18 = this;
|
3940
1729
|
return _asyncToGenerator(function* () {
|
3941
|
-
var room =
|
1730
|
+
var room = _this18.getRoom(roomId);
|
3942
1731
|
if (room !== null && room !== void 0 && room.hasPendingEvent(rmEventId)) {
|
3943
1732
|
throw new Error("Cannot set read marker to a pending event (".concat(rmEventId, ")"));
|
3944
1733
|
}
|
@@ -3950,7 +1739,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3950
1739
|
if (room !== null && room !== void 0 && room.hasPendingEvent(rrEventId)) {
|
3951
1740
|
throw new Error("Cannot set read receipt to a pending event (".concat(rrEventId, ")"));
|
3952
1741
|
}
|
3953
|
-
room === null || room === void 0 || room.addLocalEchoReceipt(
|
1742
|
+
room === null || room === void 0 || room.addLocalEchoReceipt(_this18.credentials.userId, rrEvent, ReceiptType.Read);
|
3954
1743
|
}
|
3955
1744
|
|
3956
1745
|
// Add the optional private RR update, do local echo like `sendReceipt`
|
@@ -3960,9 +1749,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3960
1749
|
if (room !== null && room !== void 0 && room.hasPendingEvent(rpEventId)) {
|
3961
1750
|
throw new Error("Cannot set read receipt to a pending event (".concat(rpEventId, ")"));
|
3962
1751
|
}
|
3963
|
-
room === null || room === void 0 || room.addLocalEchoReceipt(
|
1752
|
+
room === null || room === void 0 || room.addLocalEchoReceipt(_this18.credentials.userId, rpEvent, ReceiptType.ReadPrivate);
|
3964
1753
|
}
|
3965
|
-
return yield
|
1754
|
+
return yield _this18.setRoomReadMarkersHttpRequest(roomId, rmEventId, rrEventId, rpEventId);
|
3966
1755
|
})();
|
3967
1756
|
}
|
3968
1757
|
|
@@ -4146,13 +1935,13 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4146
1935
|
* @returns Rejects: with an error response.
|
4147
1936
|
*/
|
4148
1937
|
inviteByThreePid(roomId, medium, address) {
|
4149
|
-
var
|
1938
|
+
var _this19 = this;
|
4150
1939
|
return _asyncToGenerator(function* () {
|
4151
|
-
var
|
1940
|
+
var _this19$identityServe;
|
4152
1941
|
var path = utils.encodeUri("/rooms/$roomId/invite", {
|
4153
1942
|
$roomId: roomId
|
4154
1943
|
});
|
4155
|
-
var identityServerUrl =
|
1944
|
+
var identityServerUrl = _this19.getIdentityServerUrl(true);
|
4156
1945
|
if (!identityServerUrl) {
|
4157
1946
|
return Promise.reject(new MatrixError({
|
4158
1947
|
error: "No supplied identity server URL",
|
@@ -4164,13 +1953,13 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4164
1953
|
medium: medium,
|
4165
1954
|
address: address
|
4166
1955
|
};
|
4167
|
-
if ((
|
4168
|
-
var identityAccessToken = yield
|
1956
|
+
if ((_this19$identityServe = _this19.identityServer) !== null && _this19$identityServe !== void 0 && _this19$identityServe.getAccessToken) {
|
1957
|
+
var identityAccessToken = yield _this19.identityServer.getAccessToken();
|
4169
1958
|
if (identityAccessToken) {
|
4170
1959
|
params["id_access_token"] = identityAccessToken;
|
4171
1960
|
}
|
4172
1961
|
}
|
4173
|
-
return
|
1962
|
+
return _this19.http.authedRequest(Method.Post, path, undefined, params);
|
4174
1963
|
})();
|
4175
1964
|
}
|
4176
1965
|
|
@@ -4238,18 +2027,18 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4238
2027
|
* @returns Rejects: with an error response.
|
4239
2028
|
*/
|
4240
2029
|
forget(roomId) {
|
4241
|
-
var
|
4242
|
-
|
2030
|
+
var _arguments5 = arguments,
|
2031
|
+
_this20 = this;
|
4243
2032
|
return _asyncToGenerator(function* () {
|
4244
|
-
var deleteRoom =
|
2033
|
+
var deleteRoom = _arguments5.length > 1 && _arguments5[1] !== undefined ? _arguments5[1] : true;
|
4245
2034
|
// API returns an empty object
|
4246
2035
|
var path = utils.encodeUri("/rooms/$room_id/forget", {
|
4247
2036
|
$room_id: roomId
|
4248
2037
|
});
|
4249
|
-
var response = yield
|
2038
|
+
var response = yield _this20.http.authedRequest(Method.Post, path);
|
4250
2039
|
if (deleteRoom) {
|
4251
|
-
|
4252
|
-
|
2040
|
+
_this20.store.removeRoom(roomId);
|
2041
|
+
_this20.emit(ClientEvent.DeleteRoom, roomId);
|
4253
2042
|
}
|
4254
2043
|
return response;
|
4255
2044
|
})();
|
@@ -4363,13 +2152,13 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4363
2152
|
* @returns Rejects: with an error response.
|
4364
2153
|
*/
|
4365
2154
|
setDisplayName(name) {
|
4366
|
-
var
|
2155
|
+
var _this21 = this;
|
4367
2156
|
return _asyncToGenerator(function* () {
|
4368
|
-
var prom = yield
|
2157
|
+
var prom = yield _this21.setProfileInfo("displayname", {
|
4369
2158
|
displayname: name
|
4370
2159
|
});
|
4371
2160
|
// XXX: synthesise a profile update for ourselves because Synapse is broken and won't
|
4372
|
-
var user =
|
2161
|
+
var user = _this21.getUser(_this21.getUserId());
|
4373
2162
|
if (user) {
|
4374
2163
|
user.displayName = name;
|
4375
2164
|
user.emit(UserEvent.DisplayName, user.events.presence, user);
|
@@ -4383,13 +2172,13 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4383
2172
|
* @returns Rejects: with an error response.
|
4384
2173
|
*/
|
4385
2174
|
setAvatarUrl(url) {
|
4386
|
-
var
|
2175
|
+
var _this22 = this;
|
4387
2176
|
return _asyncToGenerator(function* () {
|
4388
|
-
var prom = yield
|
2177
|
+
var prom = yield _this22.setProfileInfo("avatar_url", {
|
4389
2178
|
avatar_url: url
|
4390
2179
|
});
|
4391
2180
|
// XXX: synthesise a profile update for ourselves because Synapse is broken and won't
|
4392
|
-
var user =
|
2181
|
+
var user = _this22.getUser(_this22.getUserId());
|
4393
2182
|
if (user) {
|
4394
2183
|
user.avatarUrl = url;
|
4395
2184
|
user.emit(UserEvent.AvatarUrl, user.events.presence, user);
|
@@ -4430,10 +2219,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4430
2219
|
* @param presence - the presence to specify to set_presence of sync calls
|
4431
2220
|
*/
|
4432
2221
|
setSyncPresence(presence) {
|
4433
|
-
var
|
2222
|
+
var _this23 = this;
|
4434
2223
|
return _asyncToGenerator(function* () {
|
4435
|
-
var
|
4436
|
-
(
|
2224
|
+
var _this23$syncApi;
|
2225
|
+
(_this23$syncApi = _this23.syncApi) === null || _this23$syncApi === void 0 || _this23$syncApi.setPresence(presence);
|
4437
2226
|
})();
|
4438
2227
|
}
|
4439
2228
|
|
@@ -4444,16 +2233,16 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4444
2233
|
* @throws If 'presence' isn't a valid presence enum value.
|
4445
2234
|
*/
|
4446
2235
|
setPresence(opts) {
|
4447
|
-
var
|
2236
|
+
var _this24 = this;
|
4448
2237
|
return _asyncToGenerator(function* () {
|
4449
2238
|
var path = utils.encodeUri("/presence/$userId/status", {
|
4450
|
-
$userId:
|
2239
|
+
$userId: _this24.credentials.userId
|
4451
2240
|
});
|
4452
2241
|
var validStates = ["offline", "online", "unavailable"];
|
4453
2242
|
if (validStates.indexOf(opts.presence) === -1) {
|
4454
2243
|
throw new Error("Bad presence value: " + opts.presence);
|
4455
2244
|
}
|
4456
|
-
yield
|
2245
|
+
yield _this24.http.authedRequest(Method.Put, path, undefined, opts);
|
4457
2246
|
})();
|
4458
2247
|
}
|
4459
2248
|
|
@@ -4562,11 +2351,11 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4562
2351
|
* {@link EventTimeline} including the given event
|
4563
2352
|
*/
|
4564
2353
|
getEventTimeline(timelineSet, eventId) {
|
4565
|
-
var
|
2354
|
+
var _this25 = this;
|
4566
2355
|
return _asyncToGenerator(function* () {
|
4567
|
-
var
|
2356
|
+
var _this25$clientOpts, _ref2, _timelineSet$getTimel, _timelineSet$room$fin;
|
4568
2357
|
// don't allow any timeline support unless it's been enabled.
|
4569
|
-
if (!
|
2358
|
+
if (!_this25.timelineSupport) {
|
4570
2359
|
throw new Error("timeline support is disabled. Set the 'timelineSupport'" + " parameter to true when creating MatrixClient to enable it.");
|
4571
2360
|
}
|
4572
2361
|
if (!(timelineSet !== null && timelineSet !== void 0 && timelineSet.room)) {
|
@@ -4575,22 +2364,22 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4575
2364
|
if (timelineSet.getTimelineForEvent(eventId)) {
|
4576
2365
|
return timelineSet.getTimelineForEvent(eventId);
|
4577
2366
|
}
|
4578
|
-
if (timelineSet.thread &&
|
4579
|
-
return
|
2367
|
+
if (timelineSet.thread && _this25.supportsThreads()) {
|
2368
|
+
return _this25.getThreadTimeline(timelineSet, eventId);
|
4580
2369
|
}
|
4581
2370
|
var path = utils.encodeUri("/rooms/$roomId/context/$eventId", {
|
4582
2371
|
$roomId: timelineSet.room.roomId,
|
4583
2372
|
$eventId: eventId
|
4584
2373
|
});
|
4585
2374
|
var params = undefined;
|
4586
|
-
if ((
|
2375
|
+
if ((_this25$clientOpts = _this25.clientOpts) !== null && _this25$clientOpts !== void 0 && _this25$clientOpts.lazyLoadMembers) {
|
4587
2376
|
params = {
|
4588
2377
|
filter: JSON.stringify(Filter.LAZY_LOADING_MESSAGES_FILTER)
|
4589
2378
|
};
|
4590
2379
|
}
|
4591
2380
|
|
4592
2381
|
// TODO: we should implement a backoff (as per scrollback()) to deal more nicely with HTTP errors.
|
4593
|
-
var res = yield
|
2382
|
+
var res = yield _this25.http.authedRequest(Method.Get, path, params);
|
4594
2383
|
if (!res.event) {
|
4595
2384
|
throw new Error("'event' not in '/context' result - homeserver too old?");
|
4596
2385
|
}
|
@@ -4599,10 +2388,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4599
2388
|
if (timelineSet.getTimelineForEvent(eventId)) {
|
4600
2389
|
return timelineSet.getTimelineForEvent(eventId);
|
4601
2390
|
}
|
4602
|
-
var mapper =
|
2391
|
+
var mapper = _this25.getEventMapper();
|
4603
2392
|
var event = mapper(res.event);
|
4604
2393
|
if (event.isRelation(THREAD_RELATION_TYPE.name)) {
|
4605
|
-
|
2394
|
+
_this25.logger.warn("Tried loading a regular timeline at the position of a thread event");
|
4606
2395
|
return undefined;
|
4607
2396
|
}
|
4608
2397
|
var events = [
|
@@ -4623,23 +2412,23 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4623
2412
|
var [timelineEvents, threadedEvents, unknownRelations] = timelineSet.room.partitionThreadedEvents(events);
|
4624
2413
|
timelineSet.addEventsToTimeline(timelineEvents, true, timeline, res.start);
|
4625
2414
|
// The target event is not in a thread but process the contextual events, so we can show any threads around it.
|
4626
|
-
|
4627
|
-
|
2415
|
+
_this25.processThreadEvents(timelineSet.room, threadedEvents, true);
|
2416
|
+
_this25.processAggregatedTimelineEvents(timelineSet.room, timelineEvents);
|
4628
2417
|
unknownRelations.forEach(event => timelineSet.relations.aggregateChildEvent(event));
|
4629
2418
|
|
4630
2419
|
// There is no guarantee that the event ended up in "timeline" (we might have switched to a neighbouring
|
4631
2420
|
// timeline) - so check the room's index again. On the other hand, there's no guarantee the event ended up
|
4632
2421
|
// anywhere, if it was later redacted, so we just return the timeline we first thought of.
|
4633
|
-
return (
|
2422
|
+
return (_ref2 = (_timelineSet$getTimel = timelineSet.getTimelineForEvent(eventId)) !== null && _timelineSet$getTimel !== void 0 ? _timelineSet$getTimel : (_timelineSet$room$fin = timelineSet.room.findThreadForEvent(event)) === null || _timelineSet$room$fin === void 0 ? void 0 : _timelineSet$room$fin.liveTimeline) !== null && _ref2 !== void 0 ? _ref2 :
|
4634
2423
|
// for Threads degraded support
|
4635
2424
|
timeline;
|
4636
2425
|
})();
|
4637
2426
|
}
|
4638
2427
|
getThreadTimeline(timelineSet, eventId) {
|
4639
|
-
var
|
2428
|
+
var _this26 = this;
|
4640
2429
|
return _asyncToGenerator(function* () {
|
4641
|
-
var
|
4642
|
-
if (!
|
2430
|
+
var _this26$clientOpts;
|
2431
|
+
if (!_this26.supportsThreads()) {
|
4643
2432
|
throw new Error("could not get thread timeline: no client support");
|
4644
2433
|
}
|
4645
2434
|
if (!timelineSet.room) {
|
@@ -4655,18 +2444,18 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4655
2444
|
var params = {
|
4656
2445
|
limit: "0"
|
4657
2446
|
};
|
4658
|
-
if ((
|
2447
|
+
if ((_this26$clientOpts = _this26.clientOpts) !== null && _this26$clientOpts !== void 0 && _this26$clientOpts.lazyLoadMembers) {
|
4659
2448
|
params.filter = JSON.stringify(Filter.LAZY_LOADING_MESSAGES_FILTER);
|
4660
2449
|
}
|
4661
2450
|
|
4662
2451
|
// TODO: we should implement a backoff (as per scrollback()) to deal more nicely with HTTP errors.
|
4663
|
-
var res = yield
|
4664
|
-
var mapper =
|
2452
|
+
var res = yield _this26.http.authedRequest(Method.Get, path, params);
|
2453
|
+
var mapper = _this26.getEventMapper();
|
4665
2454
|
var event = mapper(res.event);
|
4666
2455
|
if (!timelineSet.canContain(event)) {
|
4667
2456
|
return undefined;
|
4668
2457
|
}
|
4669
|
-
var recurse =
|
2458
|
+
var recurse = _this26.canSupport.get(Feature.RelationsRecursion) !== ServerSupport.Unsupported;
|
4670
2459
|
if (Thread.hasServerSideSupport) {
|
4671
2460
|
if (Thread.hasServerSideFwdPaginationSupport) {
|
4672
2461
|
var _resOlder$next_batch, _resNewer$next_batch, _timelineSet$getTimel2;
|
@@ -4674,12 +2463,12 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4674
2463
|
throw new Error("could not get thread timeline: not a thread timeline");
|
4675
2464
|
}
|
4676
2465
|
var thread = timelineSet.thread;
|
4677
|
-
var resOlder = yield
|
2466
|
+
var resOlder = yield _this26.fetchRelations(timelineSet.room.roomId, thread.id, null, null, {
|
4678
2467
|
dir: Direction.Backward,
|
4679
2468
|
from: res.start,
|
4680
2469
|
recurse: recurse || undefined
|
4681
2470
|
});
|
4682
|
-
var resNewer = yield
|
2471
|
+
var resNewer = yield _this26.fetchRelations(timelineSet.room.roomId, thread.id, null, null, {
|
4683
2472
|
dir: Direction.Forward,
|
4684
2473
|
from: res.end,
|
4685
2474
|
recurse: recurse || undefined
|
@@ -4704,12 +2493,12 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4704
2493
|
}
|
4705
2494
|
timelineSet.addEventsToTimeline(events, true, timeline, resNewer.next_batch);
|
4706
2495
|
if (!resOlder.next_batch) {
|
4707
|
-
var originalEvent = yield
|
2496
|
+
var originalEvent = yield _this26.fetchRoomEvent(timelineSet.room.roomId, thread.id);
|
4708
2497
|
timelineSet.addEventsToTimeline([mapper(originalEvent)], true, timeline, null);
|
4709
2498
|
}
|
4710
2499
|
timeline.setPaginationToken((_resOlder$next_batch = resOlder.next_batch) !== null && _resOlder$next_batch !== void 0 ? _resOlder$next_batch : null, Direction.Backward);
|
4711
2500
|
timeline.setPaginationToken((_resNewer$next_batch = resNewer.next_batch) !== null && _resNewer$next_batch !== void 0 ? _resNewer$next_batch : null, Direction.Forward);
|
4712
|
-
|
2501
|
+
_this26.processAggregatedTimelineEvents(timelineSet.room, events);
|
4713
2502
|
|
4714
2503
|
// There is no guarantee that the event ended up in "timeline" (we might have switched to a neighbouring
|
4715
2504
|
// timeline) - so check the room's index again. On the other hand, there's no guarantee the event ended up
|
@@ -4722,7 +2511,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4722
2511
|
// XXX: workaround for https://github.com/vector-im/element-meta/issues/150
|
4723
2512
|
|
4724
2513
|
var _thread = timelineSet.thread;
|
4725
|
-
var _resOlder = yield
|
2514
|
+
var _resOlder = yield _this26.fetchRelations(timelineSet.room.roomId, _thread.id, THREAD_RELATION_TYPE.name, null, {
|
4726
2515
|
dir: Direction.Backward,
|
4727
2516
|
from: res.start,
|
4728
2517
|
recurse: recurse || undefined
|
@@ -4731,7 +2520,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4731
2520
|
var nextBatch = res.end;
|
4732
2521
|
while (nextBatch) {
|
4733
2522
|
var _resNewer$next_batch2;
|
4734
|
-
var _resNewer = yield
|
2523
|
+
var _resNewer = yield _this26.fetchRelations(timelineSet.room.roomId, _thread.id, THREAD_RELATION_TYPE.name, null, {
|
4735
2524
|
dir: Direction.Forward,
|
4736
2525
|
from: nextBatch,
|
4737
2526
|
recurse: recurse || undefined
|
@@ -4755,12 +2544,12 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4755
2544
|
_timeline.getState(EventTimeline.BACKWARDS).setUnknownStateEvents(res.state.map(mapper));
|
4756
2545
|
timelineSet.addEventsToTimeline(_events, true, _timeline, null);
|
4757
2546
|
if (!_resOlder.next_batch) {
|
4758
|
-
var _originalEvent = yield
|
2547
|
+
var _originalEvent = yield _this26.fetchRoomEvent(timelineSet.room.roomId, _thread.id);
|
4759
2548
|
timelineSet.addEventsToTimeline([mapper(_originalEvent)], true, _timeline, null);
|
4760
2549
|
}
|
4761
2550
|
_timeline.setPaginationToken((_resOlder$next_batch2 = _resOlder.next_batch) !== null && _resOlder$next_batch2 !== void 0 ? _resOlder$next_batch2 : null, Direction.Backward);
|
4762
2551
|
_timeline.setPaginationToken(null, Direction.Forward);
|
4763
|
-
|
2552
|
+
_this26.processAggregatedTimelineEvents(timelineSet.room, _events);
|
4764
2553
|
return _timeline;
|
4765
2554
|
}
|
4766
2555
|
}
|
@@ -4778,10 +2567,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4778
2567
|
* {@link EventTimeline} timeline with the latest events in the room
|
4779
2568
|
*/
|
4780
2569
|
getLatestTimeline(timelineSet) {
|
4781
|
-
var
|
2570
|
+
var _this27 = this;
|
4782
2571
|
return _asyncToGenerator(function* () {
|
4783
2572
|
// don't allow any timeline support unless it's been enabled.
|
4784
|
-
if (!
|
2573
|
+
if (!_this27.timelineSupport) {
|
4785
2574
|
throw new Error("timeline support is disabled. Set the 'timelineSupport'" + " parameter to true when creating MatrixClient to enable it.");
|
4786
2575
|
}
|
4787
2576
|
if (!timelineSet.room) {
|
@@ -4790,35 +2579,35 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4790
2579
|
var event;
|
4791
2580
|
if (timelineSet.threadListType !== null) {
|
4792
2581
|
var _res$chunk;
|
4793
|
-
var res = yield
|
2582
|
+
var res = yield _this27.createThreadListMessagesRequest(timelineSet.room.roomId, null, 1, Direction.Backward, timelineSet.threadListType, timelineSet.getFilter());
|
4794
2583
|
event = (_res$chunk = res.chunk) === null || _res$chunk === void 0 ? void 0 : _res$chunk[0];
|
4795
2584
|
} else if (timelineSet.thread && Thread.hasServerSideSupport) {
|
4796
2585
|
var _res$chunk2;
|
4797
|
-
var recurse =
|
4798
|
-
var _res = yield
|
2586
|
+
var recurse = _this27.canSupport.get(Feature.RelationsRecursion) !== ServerSupport.Unsupported;
|
2587
|
+
var _res = yield _this27.fetchRelations(timelineSet.room.roomId, timelineSet.thread.id, THREAD_RELATION_TYPE.name, null, {
|
4799
2588
|
dir: Direction.Backward,
|
4800
2589
|
limit: 1,
|
4801
2590
|
recurse: recurse || undefined
|
4802
2591
|
});
|
4803
2592
|
event = (_res$chunk2 = _res.chunk) === null || _res$chunk2 === void 0 ? void 0 : _res$chunk2[0];
|
4804
2593
|
} else {
|
4805
|
-
var
|
2594
|
+
var _this27$clientOpts, _res2$chunk;
|
4806
2595
|
var messagesPath = utils.encodeUri("/rooms/$roomId/messages", {
|
4807
2596
|
$roomId: timelineSet.room.roomId
|
4808
2597
|
});
|
4809
2598
|
var params = {
|
4810
2599
|
dir: "b"
|
4811
2600
|
};
|
4812
|
-
if ((
|
2601
|
+
if ((_this27$clientOpts = _this27.clientOpts) !== null && _this27$clientOpts !== void 0 && _this27$clientOpts.lazyLoadMembers) {
|
4813
2602
|
params.filter = JSON.stringify(Filter.LAZY_LOADING_MESSAGES_FILTER);
|
4814
2603
|
}
|
4815
|
-
var _res2 = yield
|
2604
|
+
var _res2 = yield _this27.http.authedRequest(Method.Get, messagesPath, params);
|
4816
2605
|
event = (_res2$chunk = _res2.chunk) === null || _res2$chunk === void 0 ? void 0 : _res2$chunk[0];
|
4817
2606
|
}
|
4818
2607
|
if (!event) {
|
4819
2608
|
throw new Error("No message returned when trying to construct getLatestTimeline");
|
4820
2609
|
}
|
4821
|
-
return
|
2610
|
+
return _this27.getEventTimeline(timelineSet, event.event_id);
|
4822
2611
|
})();
|
4823
2612
|
}
|
4824
2613
|
|
@@ -4930,7 +2719,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4930
2719
|
* events and we reached either end of the timeline; else true.
|
4931
2720
|
*/
|
4932
2721
|
paginateEventTimeline(eventTimeline, opts) {
|
4933
|
-
var
|
2722
|
+
var _this28 = this;
|
4934
2723
|
var isNotifTimeline = eventTimeline.getTimelineSet() === this.notifTimelineSet;
|
4935
2724
|
var room = this.getRoom(eventTimeline.getRoomId());
|
4936
2725
|
var threadListType = eventTimeline.getTimelineSet().threadListType;
|
@@ -4966,17 +2755,17 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4966
2755
|
params.from = token;
|
4967
2756
|
}
|
4968
2757
|
promise = this.http.authedRequest(Method.Get, path, params).then(/*#__PURE__*/function () {
|
4969
|
-
var
|
2758
|
+
var _ref3 = _asyncToGenerator(function* (res) {
|
4970
2759
|
var token = res.next_token;
|
4971
2760
|
var matrixEvents = [];
|
4972
2761
|
res.notifications = res.notifications.filter(noUnsafeEventProps);
|
4973
2762
|
for (var i = 0; i < res.notifications.length; i++) {
|
4974
2763
|
var notification = res.notifications[i];
|
4975
|
-
var _event4 =
|
2764
|
+
var _event4 = _this28.getEventMapper()(notification.event);
|
4976
2765
|
|
4977
2766
|
// @TODO(kerrya) reprocessing every notification is ugly
|
4978
2767
|
// remove if we get server MSC3994 support
|
4979
|
-
|
2768
|
+
_this28.getPushDetailsForEvent(_event4, true);
|
4980
2769
|
_event4.event.room_id = notification.room_id; // XXX: gutwrenching
|
4981
2770
|
matrixEvents[i] = _event4;
|
4982
2771
|
}
|
@@ -4985,7 +2774,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4985
2774
|
// in the notification timeline set
|
4986
2775
|
var timelineSet = eventTimeline.getTimelineSet();
|
4987
2776
|
timelineSet.addEventsToTimeline(matrixEvents, backwards, eventTimeline, token);
|
4988
|
-
|
2777
|
+
_this28.processAggregatedTimelineEvents(timelineSet.room, matrixEvents);
|
4989
2778
|
|
4990
2779
|
// if we've hit the end of the timeline, we need to stop trying to
|
4991
2780
|
// paginate. We need to keep the 'forwards' token though, to make sure
|
@@ -4995,8 +2784,8 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4995
2784
|
}
|
4996
2785
|
return Boolean(res.next_token);
|
4997
2786
|
});
|
4998
|
-
return function (
|
4999
|
-
return
|
2787
|
+
return function (_x2) {
|
2788
|
+
return _ref3.apply(this, arguments);
|
5000
2789
|
};
|
5001
2790
|
}()).finally(() => {
|
5002
2791
|
eventTimeline.paginationRequests[dir] = null;
|
@@ -5046,8 +2835,8 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5046
2835
|
from: token !== null && token !== void 0 ? token : undefined,
|
5047
2836
|
recurse: recurse || undefined
|
5048
2837
|
}).then(/*#__PURE__*/function () {
|
5049
|
-
var
|
5050
|
-
var mapper =
|
2838
|
+
var _ref4 = _asyncToGenerator(function* (res) {
|
2839
|
+
var mapper = _this28.getEventMapper();
|
5051
2840
|
var matrixEvents = res.chunk.filter(noUnsafeEventProps).filter(getRelationsThreadFilter(thread.id)).map(mapper);
|
5052
2841
|
|
5053
2842
|
// Process latest events first
|
@@ -5063,10 +2852,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5063
2852
|
timelineSet.addEventsToTimeline(matrixEvents, backwards, eventTimeline, newToken !== null && newToken !== void 0 ? newToken : null);
|
5064
2853
|
if (!newToken && backwards) {
|
5065
2854
|
var _thread$rootEvent, _eventTimeline$getRoo3;
|
5066
|
-
var originalEvent = (_thread$rootEvent = thread.rootEvent) !== null && _thread$rootEvent !== void 0 ? _thread$rootEvent : mapper(yield
|
2855
|
+
var originalEvent = (_thread$rootEvent = thread.rootEvent) !== null && _thread$rootEvent !== void 0 ? _thread$rootEvent : mapper(yield _this28.fetchRoomEvent((_eventTimeline$getRoo3 = eventTimeline.getRoomId()) !== null && _eventTimeline$getRoo3 !== void 0 ? _eventTimeline$getRoo3 : "", thread.id));
|
5067
2856
|
timelineSet.addEventsToTimeline([originalEvent], true, eventTimeline, null);
|
5068
2857
|
}
|
5069
|
-
|
2858
|
+
_this28.processAggregatedTimelineEvents(timelineSet.room, matrixEvents);
|
5070
2859
|
|
5071
2860
|
// if we've hit the end of the timeline, we need to stop trying to
|
5072
2861
|
// paginate. We need to keep the 'forwards' token though, to make sure
|
@@ -5076,8 +2865,8 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5076
2865
|
}
|
5077
2866
|
return Boolean(newToken);
|
5078
2867
|
});
|
5079
|
-
return function (
|
5080
|
-
return
|
2868
|
+
return function (_x3) {
|
2869
|
+
return _ref4.apply(this, arguments);
|
5081
2870
|
};
|
5082
2871
|
}()).finally(() => {
|
5083
2872
|
eventTimeline.paginationRequests[dir] = null;
|
@@ -5352,10 +3141,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5352
3141
|
* @returns Promise which resolves: As requestEmailToken
|
5353
3142
|
*/
|
5354
3143
|
requestTokenFromEndpoint(endpoint, params) {
|
5355
|
-
var
|
3144
|
+
var _this29 = this;
|
5356
3145
|
return _asyncToGenerator(function* () {
|
5357
3146
|
var postParams = Object.assign({}, params);
|
5358
|
-
return
|
3147
|
+
return _this29.http.request(Method.Post, endpoint, undefined, postParams);
|
5359
3148
|
})();
|
5360
3149
|
}
|
5361
3150
|
|
@@ -5650,14 +3439,14 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5650
3439
|
* @returns Filter ID
|
5651
3440
|
*/
|
5652
3441
|
getOrCreateFilter(filterName, filter) {
|
5653
|
-
var
|
3442
|
+
var _this30 = this;
|
5654
3443
|
return _asyncToGenerator(function* () {
|
5655
|
-
var filterId =
|
3444
|
+
var filterId = _this30.store.getFilterIdByName(filterName);
|
5656
3445
|
var existingId;
|
5657
3446
|
if (filterId) {
|
5658
3447
|
// check that the existing filter matches our expectations
|
5659
3448
|
try {
|
5660
|
-
var existingFilter = yield
|
3449
|
+
var existingFilter = yield _this30.getFilter(_this30.credentials.userId, filterId, true);
|
5661
3450
|
if (existingFilter) {
|
5662
3451
|
var oldDef = existingFilter.getDefinition();
|
5663
3452
|
var newDef = filter.getDefinition();
|
@@ -5681,7 +3470,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5681
3470
|
}
|
5682
3471
|
// if the filter doesn't exist anymore on the server, remove from store
|
5683
3472
|
if (!existingId) {
|
5684
|
-
|
3473
|
+
_this30.store.setFilterIdByName(filterName, undefined);
|
5685
3474
|
}
|
5686
3475
|
}
|
5687
3476
|
if (existingId) {
|
@@ -5689,8 +3478,8 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5689
3478
|
}
|
5690
3479
|
|
5691
3480
|
// create a new filter
|
5692
|
-
var createdFilter = yield
|
5693
|
-
|
3481
|
+
var createdFilter = yield _this30.createFilter(filter.getDefinition());
|
3482
|
+
_this30.store.setFilterIdByName(filterName, createdFilter.filterId);
|
5694
3483
|
return createdFilter.filterId;
|
5695
3484
|
})();
|
5696
3485
|
}
|
@@ -5708,84 +3497,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5708
3497
|
});
|
5709
3498
|
return this.http.authedRequest(Method.Post, path, undefined, {});
|
5710
3499
|
}
|
5711
|
-
/**
|
5712
|
-
* @returns Promise which resolves: ITurnServerResponse object
|
5713
|
-
* @returns Rejects: with an error response.
|
5714
|
-
*/
|
5715
|
-
turnServer() {
|
5716
|
-
return this.http.authedRequest(Method.Get, "/voip/turnServer");
|
5717
|
-
}
|
5718
|
-
|
5719
|
-
/**
|
5720
|
-
* Get the TURN servers for this homeserver.
|
5721
|
-
* @returns The servers or an empty list.
|
5722
|
-
*/
|
5723
|
-
getTurnServers() {
|
5724
|
-
return this.turnServers || [];
|
5725
|
-
}
|
5726
|
-
|
5727
|
-
/**
|
5728
|
-
* Get the unix timestamp (in milliseconds) at which the current
|
5729
|
-
* TURN credentials (from getTurnServers) expire
|
5730
|
-
* @returns The expiry timestamp in milliseconds
|
5731
|
-
*/
|
5732
|
-
getTurnServersExpiry() {
|
5733
|
-
return this.turnServersExpiry;
|
5734
|
-
}
|
5735
|
-
get pollingTurnServers() {
|
5736
|
-
return this.checkTurnServersIntervalID !== undefined;
|
5737
|
-
}
|
5738
|
-
|
5739
|
-
// XXX: Intended private, used in code.
|
5740
|
-
checkTurnServers() {
|
5741
|
-
var _this55 = this;
|
5742
|
-
return _asyncToGenerator(function* () {
|
5743
|
-
if (!_this55.canSupportVoip) {
|
5744
|
-
return;
|
5745
|
-
}
|
5746
|
-
var credentialsGood = false;
|
5747
|
-
var remainingTime = _this55.turnServersExpiry - Date.now();
|
5748
|
-
if (remainingTime > TURN_CHECK_INTERVAL) {
|
5749
|
-
_this55.logger.debug("TURN creds are valid for another " + remainingTime + " ms: not fetching new ones.");
|
5750
|
-
credentialsGood = true;
|
5751
|
-
} else {
|
5752
|
-
_this55.logger.debug("Fetching new TURN credentials");
|
5753
|
-
try {
|
5754
|
-
var res = yield _this55.turnServer();
|
5755
|
-
if (res.uris) {
|
5756
|
-
_this55.logger.debug("Got TURN URIs: " + res.uris + " refresh in " + res.ttl + " secs");
|
5757
|
-
// map the response to a format that can be fed to RTCPeerConnection
|
5758
|
-
var servers = {
|
5759
|
-
urls: res.uris,
|
5760
|
-
username: res.username,
|
5761
|
-
credential: res.password
|
5762
|
-
};
|
5763
|
-
_this55.turnServers = [servers];
|
5764
|
-
// The TTL is in seconds but we work in ms
|
5765
|
-
_this55.turnServersExpiry = Date.now() + res.ttl * 1000;
|
5766
|
-
credentialsGood = true;
|
5767
|
-
_this55.emit(ClientEvent.TurnServers, _this55.turnServers);
|
5768
|
-
}
|
5769
|
-
} catch (err) {
|
5770
|
-
_this55.logger.error("Failed to get TURN URIs", err);
|
5771
|
-
if (err.httpStatus === 403) {
|
5772
|
-
// We got a 403, so there's no point in looping forever.
|
5773
|
-
_this55.logger.info("TURN access unavailable for this account: stopping credentials checks");
|
5774
|
-
if (_this55.checkTurnServersIntervalID !== null) {
|
5775
|
-
globalThis.clearInterval(_this55.checkTurnServersIntervalID);
|
5776
|
-
}
|
5777
|
-
_this55.checkTurnServersIntervalID = undefined;
|
5778
|
-
_this55.emit(ClientEvent.TurnServersError, err, true); // fatal
|
5779
|
-
} else {
|
5780
|
-
// otherwise, if we failed for whatever reason, try again the next time we're called.
|
5781
|
-
_this55.emit(ClientEvent.TurnServersError, err, false); // non-fatal
|
5782
|
-
}
|
5783
|
-
}
|
5784
|
-
}
|
5785
|
-
return credentialsGood;
|
5786
|
-
})();
|
5787
|
-
}
|
5788
|
-
|
5789
3500
|
/**
|
5790
3501
|
* Set whether to allow a fallback ICE server should be used for negotiating a
|
5791
3502
|
* WebRTC connection if the homeserver doesn't provide any servers. Defaults to
|
@@ -5854,14 +3565,14 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5854
3565
|
});
|
5855
3566
|
}
|
5856
3567
|
fetchClientWellKnown() {
|
5857
|
-
var
|
3568
|
+
var _this31 = this;
|
5858
3569
|
return _asyncToGenerator(function* () {
|
5859
|
-
var
|
3570
|
+
var _this31$getDomain;
|
5860
3571
|
// `getRawClientConfig` does not throw or reject on network errors, instead
|
5861
3572
|
// it absorbs errors and returns `{}`.
|
5862
|
-
|
5863
|
-
|
5864
|
-
|
3573
|
+
_this31.clientWellKnownPromise = AutoDiscovery.getRawClientConfig((_this31$getDomain = _this31.getDomain()) !== null && _this31$getDomain !== void 0 ? _this31$getDomain : undefined);
|
3574
|
+
_this31.clientWellKnown = yield _this31.clientWellKnownPromise;
|
3575
|
+
_this31.emit(ClientEvent.ClientWellKnown, _this31.clientWellKnown);
|
5865
3576
|
})();
|
5866
3577
|
}
|
5867
3578
|
getClientWellKnown() {
|
@@ -5883,11 +3594,11 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5883
3594
|
storeClientOptions() {
|
5884
3595
|
// XXX: Intended private, used in code
|
5885
3596
|
var primTypes = ["boolean", "string", "number"];
|
5886
|
-
var serializableOpts = Object.entries(this.clientOpts).filter(
|
5887
|
-
var [key, value] =
|
3597
|
+
var serializableOpts = Object.entries(this.clientOpts).filter(_ref5 => {
|
3598
|
+
var [key, value] = _ref5;
|
5888
3599
|
return primTypes.includes(typeof value);
|
5889
|
-
}).reduce((obj,
|
5890
|
-
var [key, value] =
|
3600
|
+
}).reduce((obj, _ref6) => {
|
3601
|
+
var [key, value] = _ref6;
|
5891
3602
|
obj[key] = value;
|
5892
3603
|
return obj;
|
5893
3604
|
}, {});
|
@@ -5907,16 +3618,16 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5907
3618
|
// TODO: on spec release, rename this to getMutualRooms
|
5908
3619
|
// eslint-disable-next-line
|
5909
3620
|
_unstable_getSharedRooms(userId) {
|
5910
|
-
var
|
3621
|
+
var _this32 = this;
|
5911
3622
|
return _asyncToGenerator(function* () {
|
5912
3623
|
// Initial variant of the MSC
|
5913
|
-
var sharedRoomsSupport = yield
|
3624
|
+
var sharedRoomsSupport = yield _this32.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_SHARED_ROOMS);
|
5914
3625
|
|
5915
3626
|
// Newer variant that renamed shared rooms to mutual rooms
|
5916
|
-
var mutualRoomsSupport = yield
|
3627
|
+
var mutualRoomsSupport = yield _this32.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_MUTUAL_ROOMS);
|
5917
3628
|
|
5918
3629
|
// Latest variant that changed from path elements to query elements
|
5919
|
-
var queryMutualRoomsSupport = yield
|
3630
|
+
var queryMutualRoomsSupport = yield _this32.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_QUERY_MUTUAL_ROOMS);
|
5920
3631
|
if (!sharedRoomsSupport && !mutualRoomsSupport && !queryMutualRoomsSupport) {
|
5921
3632
|
throw Error("Server does not support the Mutual Rooms API");
|
5922
3633
|
}
|
@@ -5944,7 +3655,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5944
3655
|
if (token != null && queryMutualRoomsSupport) {
|
5945
3656
|
tokenQuery["batch_token"] = token;
|
5946
3657
|
}
|
5947
|
-
var res = yield
|
3658
|
+
var res = yield _this32.http.authedRequest(Method.Get, path, _objectSpread(_objectSpread({}, query), tokenQuery), undefined, {
|
5948
3659
|
prefix: ClientPrefix.Unstable
|
5949
3660
|
});
|
5950
3661
|
rooms.push(...res.joined);
|
@@ -5964,24 +3675,24 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5964
3675
|
* @returns The server /versions response
|
5965
3676
|
*/
|
5966
3677
|
getVersions() {
|
5967
|
-
var
|
3678
|
+
var _this33 = this;
|
5968
3679
|
return _asyncToGenerator(function* () {
|
5969
|
-
if (
|
5970
|
-
return
|
3680
|
+
if (_this33.serverVersionsPromise) {
|
3681
|
+
return _this33.serverVersionsPromise;
|
5971
3682
|
}
|
5972
3683
|
|
5973
3684
|
// We send an authenticated request as of MSC4026
|
5974
|
-
|
3685
|
+
_this33.serverVersionsPromise = _this33.http.authedRequest(Method.Get, "/_matrix/client/versions", undefined, undefined, {
|
5975
3686
|
prefix: ""
|
5976
3687
|
}).catch(e => {
|
5977
3688
|
// Need to unset this if it fails, otherwise we'll never retry
|
5978
|
-
|
3689
|
+
_this33.serverVersionsPromise = undefined;
|
5979
3690
|
// but rethrow the exception to anything that was waiting
|
5980
3691
|
throw e;
|
5981
3692
|
});
|
5982
|
-
var serverVersions = yield
|
5983
|
-
|
5984
|
-
return
|
3693
|
+
var serverVersions = yield _this33.serverVersionsPromise;
|
3694
|
+
_this33.canSupport = yield buildFeatureSupportMap(serverVersions);
|
3695
|
+
return _this33.serverVersionsPromise;
|
5985
3696
|
})();
|
5986
3697
|
}
|
5987
3698
|
|
@@ -5991,11 +3702,11 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5991
3702
|
* @returns Whether it is supported
|
5992
3703
|
*/
|
5993
3704
|
isVersionSupported(version) {
|
5994
|
-
var
|
3705
|
+
var _this34 = this;
|
5995
3706
|
return _asyncToGenerator(function* () {
|
5996
3707
|
var {
|
5997
3708
|
versions
|
5998
|
-
} = yield
|
3709
|
+
} = yield _this34.getVersions();
|
5999
3710
|
return versions && versions.includes(version);
|
6000
3711
|
})();
|
6001
3712
|
}
|
@@ -6007,9 +3718,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6007
3718
|
* @returns true if the feature is supported
|
6008
3719
|
*/
|
6009
3720
|
doesServerSupportUnstableFeature(feature) {
|
6010
|
-
var
|
3721
|
+
var _this35 = this;
|
6011
3722
|
return _asyncToGenerator(function* () {
|
6012
|
-
var response = yield
|
3723
|
+
var response = yield _this35.getVersions();
|
6013
3724
|
if (!response) return false;
|
6014
3725
|
var unstableFeatures = response["unstable_features"];
|
6015
3726
|
return unstableFeatures && !!unstableFeatures[feature];
|
@@ -6024,9 +3735,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6024
3735
|
* for the preset.
|
6025
3736
|
*/
|
6026
3737
|
doesServerForceEncryptionForPreset(presetName) {
|
6027
|
-
var
|
3738
|
+
var _this36 = this;
|
6028
3739
|
return _asyncToGenerator(function* () {
|
6029
|
-
var response = yield
|
3740
|
+
var response = yield _this36.getVersions();
|
6030
3741
|
if (!response) return false;
|
6031
3742
|
var unstableFeatures = response["unstable_features"];
|
6032
3743
|
|
@@ -6036,9 +3747,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6036
3747
|
})();
|
6037
3748
|
}
|
6038
3749
|
doesServerSupportThread() {
|
6039
|
-
var
|
3750
|
+
var _this37 = this;
|
6040
3751
|
return _asyncToGenerator(function* () {
|
6041
|
-
if (yield
|
3752
|
+
if (yield _this37.isVersionSupported("v1.4")) {
|
6042
3753
|
return {
|
6043
3754
|
threads: FeatureSupport.Stable,
|
6044
3755
|
list: FeatureSupport.Stable,
|
@@ -6046,13 +3757,13 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6046
3757
|
};
|
6047
3758
|
}
|
6048
3759
|
try {
|
6049
|
-
var [threadUnstable, threadStable, listUnstable, listStable, fwdPaginationUnstable, fwdPaginationStable] = yield Promise.all([
|
3760
|
+
var [threadUnstable, threadStable, listUnstable, listStable, fwdPaginationUnstable, fwdPaginationStable] = yield Promise.all([_this37.doesServerSupportUnstableFeature("org.matrix.msc3440"), _this37.doesServerSupportUnstableFeature("org.matrix.msc3440.stable"), _this37.doesServerSupportUnstableFeature("org.matrix.msc3856"), _this37.doesServerSupportUnstableFeature("org.matrix.msc3856.stable"), _this37.doesServerSupportUnstableFeature("org.matrix.msc3715"), _this37.doesServerSupportUnstableFeature("org.matrix.msc3715.stable")]);
|
6050
3761
|
return {
|
6051
3762
|
threads: determineFeatureSupport(threadStable, threadUnstable),
|
6052
3763
|
list: determineFeatureSupport(listStable, listUnstable),
|
6053
3764
|
fwdPagination: determineFeatureSupport(fwdPaginationStable, fwdPaginationUnstable)
|
6054
3765
|
};
|
6055
|
-
} catch (
|
3766
|
+
} catch (_unused) {
|
6056
3767
|
return {
|
6057
3768
|
threads: FeatureSupport.None,
|
6058
3769
|
list: FeatureSupport.None,
|
@@ -6104,21 +3815,19 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6104
3815
|
* @returns an object with `events` as `MatrixEvent[]` and optionally `nextBatch` if more relations are available.
|
6105
3816
|
*/
|
6106
3817
|
relations(roomId, eventId, relationType, eventType) {
|
6107
|
-
var
|
6108
|
-
|
3818
|
+
var _arguments6 = arguments,
|
3819
|
+
_this38 = this;
|
6109
3820
|
return _asyncToGenerator(function* () {
|
6110
3821
|
var _result$next_batch, _result$prev_batch;
|
6111
|
-
var opts =
|
3822
|
+
var opts = _arguments6.length > 4 && _arguments6[4] !== undefined ? _arguments6[4] : {
|
6112
3823
|
dir: Direction.Backward
|
6113
3824
|
};
|
6114
|
-
var fetchedEventType = eventType ?
|
6115
|
-
var [eventResult, result] = yield Promise.all([
|
6116
|
-
var mapper =
|
3825
|
+
var fetchedEventType = eventType ? _this38.getEncryptedIfNeededEventType(roomId, eventType) : null;
|
3826
|
+
var [eventResult, result] = yield Promise.all([_this38.fetchRoomEvent(roomId, eventId), _this38.fetchRelations(roomId, eventId, relationType, fetchedEventType, opts)]);
|
3827
|
+
var mapper = _this38.getEventMapper();
|
6117
3828
|
var originalEvent = eventResult ? mapper(eventResult) : undefined;
|
6118
3829
|
var events = result.chunk.map(mapper);
|
6119
3830
|
if (fetchedEventType === EventType.RoomMessageEncrypted) {
|
6120
|
-
var allEvents = originalEvent ? events.concat(originalEvent) : events;
|
6121
|
-
yield Promise.all(allEvents.map(e => _this63.decryptEventIfNeeded(e)));
|
6122
3831
|
if (eventType !== null) {
|
6123
3832
|
events = events.filter(e => e.getType() === eventType);
|
6124
3833
|
}
|
@@ -6135,18 +3844,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6135
3844
|
})();
|
6136
3845
|
}
|
6137
3846
|
|
6138
|
-
/**
|
6139
|
-
* The app may wish to see if we have a key cached without
|
6140
|
-
* triggering a user interaction.
|
6141
|
-
*
|
6142
|
-
* @deprecated Not supported for Rust Cryptography.
|
6143
|
-
*/
|
6144
|
-
getCrossSigningCacheCallbacks() {
|
6145
|
-
var _this$crypto4;
|
6146
|
-
// XXX: Private member access
|
6147
|
-
return (_this$crypto4 = this.crypto) === null || _this$crypto4 === void 0 ? void 0 : _this$crypto4.crossSigningInfo.getCacheCallbacks();
|
6148
|
-
}
|
6149
|
-
|
6150
3847
|
/**
|
6151
3848
|
* Generates a random string suitable for use as a client secret. <strong>This
|
6152
3849
|
* method is experimental and may change.</strong>
|
@@ -6162,14 +3859,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6162
3859
|
* @returns A decryption promise
|
6163
3860
|
*/
|
6164
3861
|
decryptEventIfNeeded(event, options) {
|
6165
|
-
|
6166
|
-
event.attemptDecryption(this.cryptoBackend, options);
|
6167
|
-
}
|
6168
|
-
if (event.isBeingDecrypted()) {
|
6169
|
-
return event.getDecryptionPromise();
|
6170
|
-
} else {
|
6171
|
-
return Promise.resolve();
|
6172
|
-
}
|
3862
|
+
return Promise.resolve();
|
6173
3863
|
}
|
6174
3864
|
termsUrlForService(serviceType, baseUrl) {
|
6175
3865
|
switch (serviceType) {
|
@@ -6468,23 +4158,15 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6468
4158
|
* @returns Promise which resolves: On success, the empty object `{}`
|
6469
4159
|
*/
|
6470
4160
|
logout() {
|
6471
|
-
var
|
6472
|
-
|
4161
|
+
var _arguments7 = arguments,
|
4162
|
+
_this39 = this;
|
6473
4163
|
return _asyncToGenerator(function* () {
|
6474
|
-
var
|
6475
|
-
var stopClient = _arguments9.length > 0 && _arguments9[0] !== undefined ? _arguments9[0] : false;
|
6476
|
-
if ((_this64$crypto = _this64.crypto) !== null && _this64$crypto !== void 0 && (_this64$crypto = _this64$crypto.backupManager) !== null && _this64$crypto !== void 0 && _this64$crypto.getKeyBackupEnabled()) {
|
6477
|
-
try {
|
6478
|
-
while ((yield _this64.crypto.backupManager.backupPendingKeys(200)) > 0);
|
6479
|
-
} catch (err) {
|
6480
|
-
_this64.logger.error("Key backup request failed when logging out. Some keys may be missing from backup", err);
|
6481
|
-
}
|
6482
|
-
}
|
4164
|
+
var stopClient = _arguments7.length > 0 && _arguments7[0] !== undefined ? _arguments7[0] : false;
|
6483
4165
|
if (stopClient) {
|
6484
|
-
|
6485
|
-
|
4166
|
+
_this39.stopClient();
|
4167
|
+
_this39.http.abort();
|
6486
4168
|
}
|
6487
|
-
return
|
4169
|
+
return _this39.http.authedRequest(Method.Post, "/logout");
|
6488
4170
|
})();
|
6489
4171
|
}
|
6490
4172
|
|
@@ -6522,12 +4204,12 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6522
4204
|
* or UIA auth data.
|
6523
4205
|
*/
|
6524
4206
|
requestLoginToken(auth) {
|
6525
|
-
var
|
4207
|
+
var _this40 = this;
|
6526
4208
|
return _asyncToGenerator(function* () {
|
6527
4209
|
var body = {
|
6528
4210
|
auth
|
6529
4211
|
};
|
6530
|
-
return
|
4212
|
+
return _this40.http.authedRequest(Method.Post, "/login/get_token", undefined,
|
6531
4213
|
// no query params
|
6532
4214
|
body, {
|
6533
4215
|
prefix: ClientPrefix.V1
|
@@ -6559,23 +4241,23 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6559
4241
|
* @returns Rejects: with an error response.
|
6560
4242
|
*/
|
6561
4243
|
createRoom(options) {
|
6562
|
-
var
|
4244
|
+
var _this41 = this;
|
6563
4245
|
return _asyncToGenerator(function* () {
|
6564
|
-
var
|
4246
|
+
var _this41$identityServe;
|
6565
4247
|
// eslint-disable-line camelcase
|
6566
4248
|
// some valid options include: room_alias_name, visibility, invite
|
6567
4249
|
|
6568
4250
|
// inject the id_access_token if inviting 3rd party addresses
|
6569
4251
|
var invitesNeedingToken = (options.invite_3pid || []).filter(i => !i.id_access_token);
|
6570
|
-
if (invitesNeedingToken.length > 0 && (
|
6571
|
-
var identityAccessToken = yield
|
4252
|
+
if (invitesNeedingToken.length > 0 && (_this41$identityServe = _this41.identityServer) !== null && _this41$identityServe !== void 0 && _this41$identityServe.getAccessToken) {
|
4253
|
+
var identityAccessToken = yield _this41.identityServer.getAccessToken();
|
6572
4254
|
if (identityAccessToken) {
|
6573
4255
|
for (var invite of invitesNeedingToken) {
|
6574
4256
|
invite.id_access_token = identityAccessToken;
|
6575
4257
|
}
|
6576
4258
|
}
|
6577
4259
|
}
|
6578
|
-
return
|
4260
|
+
return _this41.http.authedRequest(Method.Post, "/createRoom", undefined, options);
|
6579
4261
|
})();
|
6580
4262
|
}
|
6581
4263
|
|
@@ -6759,7 +4441,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6759
4441
|
* @returns Promise which resolves: the empty object, `{}`.
|
6760
4442
|
*/
|
6761
4443
|
setRoomReadMarkersHttpRequest(roomId, rmEventId, rrEventId, rpEventId) {
|
6762
|
-
var
|
4444
|
+
var _this42 = this;
|
6763
4445
|
return _asyncToGenerator(function* () {
|
6764
4446
|
var path = utils.encodeUri("/rooms/$roomId/read_markers", {
|
6765
4447
|
$roomId: roomId
|
@@ -6768,10 +4450,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6768
4450
|
[ReceiptType.FullyRead]: rmEventId,
|
6769
4451
|
[ReceiptType.Read]: rrEventId
|
6770
4452
|
};
|
6771
|
-
if ((yield
|
4453
|
+
if ((yield _this42.doesServerSupportUnstableFeature("org.matrix.msc2285.stable")) || (yield _this42.isVersionSupported("v1.4"))) {
|
6772
4454
|
content[ReceiptType.ReadPrivate] = rpEventId;
|
6773
4455
|
}
|
6774
|
-
return
|
4456
|
+
return _this42.http.authedRequest(Method.Post, path, undefined, content);
|
6775
4457
|
})();
|
6776
4458
|
}
|
6777
4459
|
|
@@ -6804,13 +4486,13 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6804
4486
|
* @returns Rejects: with an error response.
|
6805
4487
|
*/
|
6806
4488
|
publicRooms() {
|
6807
|
-
var
|
4489
|
+
var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
6808
4490
|
var {
|
6809
4491
|
server,
|
6810
4492
|
limit,
|
6811
4493
|
since
|
6812
|
-
} =
|
6813
|
-
options = _objectWithoutProperties(
|
4494
|
+
} = _ref7,
|
4495
|
+
options = _objectWithoutProperties(_ref7, _excluded);
|
6814
4496
|
if (Object.keys(options).length === 0) {
|
6815
4497
|
var queryParams = {
|
6816
4498
|
server,
|
@@ -6928,11 +4610,11 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6928
4610
|
* @param options.limit - the maximum number of results to return. The server will apply a limit if unspecified.
|
6929
4611
|
* @returns Promise which resolves: an array of results.
|
6930
4612
|
*/
|
6931
|
-
searchUserDirectory(
|
4613
|
+
searchUserDirectory(_ref8) {
|
6932
4614
|
var {
|
6933
4615
|
term,
|
6934
4616
|
limit
|
6935
|
-
} =
|
4617
|
+
} = _ref8;
|
6936
4618
|
var body = {
|
6937
4619
|
search_term: term
|
6938
4620
|
};
|
@@ -7004,9 +4686,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7004
4686
|
* @returns `true` if supported, otherwise `false`
|
7005
4687
|
*/
|
7006
4688
|
doesServerSupportExtendedProfiles() {
|
7007
|
-
var
|
4689
|
+
var _this43 = this;
|
7008
4690
|
return _asyncToGenerator(function* () {
|
7009
|
-
return
|
4691
|
+
return _this43.doesServerSupportUnstableFeature(UNSTABLE_MSC4133_EXTENDED_PROFILES);
|
7010
4692
|
})();
|
7011
4693
|
}
|
7012
4694
|
|
@@ -7016,9 +4698,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7016
4698
|
* @returns The prefix for use with `authedRequest`
|
7017
4699
|
*/
|
7018
4700
|
getExtendedProfileRequestPrefix() {
|
7019
|
-
var
|
4701
|
+
var _this44 = this;
|
7020
4702
|
return _asyncToGenerator(function* () {
|
7021
|
-
if (yield
|
4703
|
+
if (yield _this44.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable")) {
|
7022
4704
|
return ClientPrefix.V3;
|
7023
4705
|
}
|
7024
4706
|
return "/_matrix/client/unstable/uk.tcpip.msc4133";
|
@@ -7036,15 +4718,15 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7036
4718
|
* @throws A M_NOT_FOUND error if the profile could not be found.
|
7037
4719
|
*/
|
7038
4720
|
getExtendedProfile(userId) {
|
7039
|
-
var
|
4721
|
+
var _this45 = this;
|
7040
4722
|
return _asyncToGenerator(function* () {
|
7041
|
-
if (!(yield
|
4723
|
+
if (!(yield _this45.doesServerSupportExtendedProfiles())) {
|
7042
4724
|
throw new Error("Server does not support extended profiles");
|
7043
4725
|
}
|
7044
|
-
return
|
4726
|
+
return _this45.http.authedRequest(Method.Get, utils.encodeUri("/profile/$userId", {
|
7045
4727
|
$userId: userId
|
7046
4728
|
}), undefined, undefined, {
|
7047
|
-
prefix: yield
|
4729
|
+
prefix: yield _this45.getExtendedProfileRequestPrefix()
|
7048
4730
|
});
|
7049
4731
|
})();
|
7050
4732
|
}
|
@@ -7061,16 +4743,16 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7061
4743
|
* @throws A M_NOT_FOUND error if the key was not set OR the profile could not be found.
|
7062
4744
|
*/
|
7063
4745
|
getExtendedProfileProperty(userId, key) {
|
7064
|
-
var
|
4746
|
+
var _this46 = this;
|
7065
4747
|
return _asyncToGenerator(function* () {
|
7066
|
-
if (!(yield
|
4748
|
+
if (!(yield _this46.doesServerSupportExtendedProfiles())) {
|
7067
4749
|
throw new Error("Server does not support extended profiles");
|
7068
4750
|
}
|
7069
|
-
var profile = yield
|
4751
|
+
var profile = yield _this46.http.authedRequest(Method.Get, utils.encodeUri("/profile/$userId/$key", {
|
7070
4752
|
$userId: userId,
|
7071
4753
|
$key: key
|
7072
4754
|
}), undefined, undefined, {
|
7073
|
-
prefix: yield
|
4755
|
+
prefix: yield _this46.getExtendedProfileRequestPrefix()
|
7074
4756
|
});
|
7075
4757
|
return profile[key];
|
7076
4758
|
})();
|
@@ -7086,19 +4768,19 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7086
4768
|
* @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
|
7087
4769
|
*/
|
7088
4770
|
setExtendedProfileProperty(key, value) {
|
7089
|
-
var
|
4771
|
+
var _this47 = this;
|
7090
4772
|
return _asyncToGenerator(function* () {
|
7091
|
-
if (!(yield
|
4773
|
+
if (!(yield _this47.doesServerSupportExtendedProfiles())) {
|
7092
4774
|
throw new Error("Server does not support extended profiles");
|
7093
4775
|
}
|
7094
|
-
var userId =
|
7095
|
-
yield
|
4776
|
+
var userId = _this47.getUserId();
|
4777
|
+
yield _this47.http.authedRequest(Method.Put, utils.encodeUri("/profile/$userId/$key", {
|
7096
4778
|
$userId: userId,
|
7097
4779
|
$key: key
|
7098
4780
|
}), undefined, {
|
7099
4781
|
[key]: value
|
7100
4782
|
}, {
|
7101
|
-
prefix: yield
|
4783
|
+
prefix: yield _this47.getExtendedProfileRequestPrefix()
|
7102
4784
|
});
|
7103
4785
|
})();
|
7104
4786
|
}
|
@@ -7112,17 +4794,17 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7112
4794
|
* @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
|
7113
4795
|
*/
|
7114
4796
|
deleteExtendedProfileProperty(key) {
|
7115
|
-
var
|
4797
|
+
var _this48 = this;
|
7116
4798
|
return _asyncToGenerator(function* () {
|
7117
|
-
if (!(yield
|
4799
|
+
if (!(yield _this48.doesServerSupportExtendedProfiles())) {
|
7118
4800
|
throw new Error("Server does not support extended profiles");
|
7119
4801
|
}
|
7120
|
-
var userId =
|
7121
|
-
yield
|
4802
|
+
var userId = _this48.getUserId();
|
4803
|
+
yield _this48.http.authedRequest(Method.Delete, utils.encodeUri("/profile/$userId/$key", {
|
7122
4804
|
$userId: userId,
|
7123
4805
|
$key: key
|
7124
4806
|
}), undefined, undefined, {
|
7125
|
-
prefix: yield
|
4807
|
+
prefix: yield _this48.getExtendedProfileRequestPrefix()
|
7126
4808
|
});
|
7127
4809
|
})();
|
7128
4810
|
}
|
@@ -7138,16 +4820,16 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7138
4820
|
* @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
|
7139
4821
|
*/
|
7140
4822
|
patchExtendedProfile(profile) {
|
7141
|
-
var
|
4823
|
+
var _this49 = this;
|
7142
4824
|
return _asyncToGenerator(function* () {
|
7143
|
-
if (!(yield
|
4825
|
+
if (!(yield _this49.doesServerSupportExtendedProfiles())) {
|
7144
4826
|
throw new Error("Server does not support extended profiles");
|
7145
4827
|
}
|
7146
|
-
var userId =
|
7147
|
-
return
|
4828
|
+
var userId = _this49.getUserId();
|
4829
|
+
return _this49.http.authedRequest(Method.Patch, utils.encodeUri("/profile/$userId", {
|
7148
4830
|
$userId: userId
|
7149
4831
|
}), {}, profile, {
|
7150
|
-
prefix: yield
|
4832
|
+
prefix: yield _this49.getExtendedProfileRequestPrefix()
|
7151
4833
|
});
|
7152
4834
|
})();
|
7153
4835
|
}
|
@@ -7162,16 +4844,16 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7162
4844
|
* @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
|
7163
4845
|
*/
|
7164
4846
|
setExtendedProfile(profile) {
|
7165
|
-
var
|
4847
|
+
var _this50 = this;
|
7166
4848
|
return _asyncToGenerator(function* () {
|
7167
|
-
if (!(yield
|
4849
|
+
if (!(yield _this50.doesServerSupportExtendedProfiles())) {
|
7168
4850
|
throw new Error("Server does not support extended profiles");
|
7169
4851
|
}
|
7170
|
-
var userId =
|
7171
|
-
yield
|
4852
|
+
var userId = _this50.getUserId();
|
4853
|
+
yield _this50.http.authedRequest(Method.Put, utils.encodeUri("/profile/$userId", {
|
7172
4854
|
$userId: userId
|
7173
4855
|
}), {}, profile, {
|
7174
|
-
prefix: yield
|
4856
|
+
prefix: yield _this50.getExtendedProfileRequestPrefix()
|
7175
4857
|
});
|
7176
4858
|
})();
|
7177
4859
|
}
|
@@ -7194,10 +4876,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7194
4876
|
* @returns Rejects: with an error response.
|
7195
4877
|
*/
|
7196
4878
|
addThreePidOnly(data) {
|
7197
|
-
var
|
4879
|
+
var _this51 = this;
|
7198
4880
|
return _asyncToGenerator(function* () {
|
7199
4881
|
var path = "/account/3pid/add";
|
7200
|
-
return
|
4882
|
+
return _this51.http.authedRequest(Method.Post, path, undefined, data);
|
7201
4883
|
})();
|
7202
4884
|
}
|
7203
4885
|
|
@@ -7213,10 +4895,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7213
4895
|
* @returns Rejects: with an error response.
|
7214
4896
|
*/
|
7215
4897
|
bindThreePid(data) {
|
7216
|
-
var
|
4898
|
+
var _this52 = this;
|
7217
4899
|
return _asyncToGenerator(function* () {
|
7218
4900
|
var path = "/account/3pid/bind";
|
7219
|
-
return
|
4901
|
+
return _this52.http.authedRequest(Method.Post, path, undefined, data);
|
7220
4902
|
})();
|
7221
4903
|
}
|
7222
4904
|
|
@@ -7234,15 +4916,15 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7234
4916
|
unbindThreePid(medium, address
|
7235
4917
|
// eslint-disable-next-line camelcase
|
7236
4918
|
) {
|
7237
|
-
var
|
4919
|
+
var _this53 = this;
|
7238
4920
|
return _asyncToGenerator(function* () {
|
7239
4921
|
var path = "/account/3pid/unbind";
|
7240
4922
|
var data = {
|
7241
4923
|
medium,
|
7242
4924
|
address,
|
7243
|
-
id_server:
|
4925
|
+
id_server: _this53.getIdentityServerUrl(true)
|
7244
4926
|
};
|
7245
|
-
return
|
4927
|
+
return _this53.http.authedRequest(Method.Post, path, undefined, data);
|
7246
4928
|
})();
|
7247
4929
|
}
|
7248
4930
|
|
@@ -7364,13 +5046,13 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7364
5046
|
* @returns Rejects: with an error response.
|
7365
5047
|
*/
|
7366
5048
|
getPushers() {
|
7367
|
-
var
|
5049
|
+
var _this54 = this;
|
7368
5050
|
return _asyncToGenerator(function* () {
|
7369
|
-
var response = yield
|
5051
|
+
var response = yield _this54.http.authedRequest(Method.Get, "/pushers");
|
7370
5052
|
|
7371
5053
|
// Migration path for clients that connect to a homeserver that does not support
|
7372
5054
|
// MSC3881 yet, see https://github.com/matrix-org/matrix-spec-proposals/blob/kerry/remote-push-toggle/proposals/3881-remote-push-notification-toggling.md#migration
|
7373
|
-
if (!(yield
|
5055
|
+
if (!(yield _this54.doesServerSupportUnstableFeature("org.matrix.msc3881"))) {
|
7374
5056
|
response.pushers = response.pushers.map(pusher => {
|
7375
5057
|
if (!pusher.hasOwnProperty(PUSHER_ENABLED.name)) {
|
7376
5058
|
pusher[PUSHER_ENABLED.name] = true;
|
@@ -7509,11 +5191,11 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7509
5191
|
* @returns Promise which resolves to the search response object.
|
7510
5192
|
* @returns Rejects: with an error response.
|
7511
5193
|
*/
|
7512
|
-
search(
|
5194
|
+
search(_ref9, abortSignal) {
|
7513
5195
|
var {
|
7514
5196
|
body,
|
7515
5197
|
next_batch: nextBatch
|
7516
|
-
} =
|
5198
|
+
} = _ref9;
|
7517
5199
|
var queryParams = {};
|
7518
5200
|
if (nextBatch) {
|
7519
5201
|
queryParams.next_batch = nextBatch;
|
@@ -7523,86 +5205,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7523
5205
|
});
|
7524
5206
|
}
|
7525
5207
|
|
7526
|
-
/**
|
7527
|
-
* Upload keys
|
7528
|
-
*
|
7529
|
-
* @param content - body of upload request
|
7530
|
-
*
|
7531
|
-
* @param opts - this method no longer takes any opts,
|
7532
|
-
* used to take opts.device_id but this was not removed from the spec as a redundant parameter
|
7533
|
-
*
|
7534
|
-
* @returns Promise which resolves: result object. Rejects: with
|
7535
|
-
* an error response ({@link MatrixError}).
|
7536
|
-
*/
|
7537
|
-
uploadKeysRequest(content, opts) {
|
7538
|
-
return this.http.authedRequest(Method.Post, "/keys/upload", undefined, content);
|
7539
|
-
}
|
7540
|
-
uploadKeySignatures(content) {
|
7541
|
-
return this.http.authedRequest(Method.Post, "/keys/signatures/upload", undefined, content);
|
7542
|
-
}
|
7543
|
-
|
7544
|
-
/**
|
7545
|
-
* Download device keys
|
7546
|
-
*
|
7547
|
-
* @param userIds - list of users to get keys for
|
7548
|
-
*
|
7549
|
-
* @param token - sync token to pass in the query request, to help
|
7550
|
-
* the HS give the most recent results
|
7551
|
-
*
|
7552
|
-
* @returns Promise which resolves: result object. Rejects: with
|
7553
|
-
* an error response ({@link MatrixError}).
|
7554
|
-
*/
|
7555
|
-
downloadKeysForUsers(userIds) {
|
7556
|
-
var {
|
7557
|
-
token
|
7558
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
7559
|
-
var content = {
|
7560
|
-
device_keys: {}
|
7561
|
-
};
|
7562
|
-
if (token !== undefined) {
|
7563
|
-
content.token = token;
|
7564
|
-
}
|
7565
|
-
userIds.forEach(u => {
|
7566
|
-
content.device_keys[u] = [];
|
7567
|
-
});
|
7568
|
-
return this.http.authedRequest(Method.Post, "/keys/query", undefined, content);
|
7569
|
-
}
|
7570
|
-
|
7571
|
-
/**
|
7572
|
-
* Claim one-time keys
|
7573
|
-
*
|
7574
|
-
* @param devices - a list of [userId, deviceId] pairs
|
7575
|
-
*
|
7576
|
-
* @param keyAlgorithm - desired key type
|
7577
|
-
*
|
7578
|
-
* @param timeout - the time (in milliseconds) to wait for keys from remote
|
7579
|
-
* servers
|
7580
|
-
*
|
7581
|
-
* @returns Promise which resolves: result object. Rejects: with
|
7582
|
-
* an error response ({@link MatrixError}).
|
7583
|
-
*/
|
7584
|
-
claimOneTimeKeys(devices) {
|
7585
|
-
var keyAlgorithm = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "signed_curve25519";
|
7586
|
-
var timeout = arguments.length > 2 ? arguments[2] : undefined;
|
7587
|
-
var queries = {};
|
7588
|
-
if (keyAlgorithm === undefined) {
|
7589
|
-
keyAlgorithm = "signed_curve25519";
|
7590
|
-
}
|
7591
|
-
for (var [userId, _deviceId] of devices) {
|
7592
|
-
var query = queries[userId] || {};
|
7593
|
-
safeSet(queries, userId, query);
|
7594
|
-
safeSet(query, _deviceId, keyAlgorithm);
|
7595
|
-
}
|
7596
|
-
var content = {
|
7597
|
-
one_time_keys: queries
|
7598
|
-
};
|
7599
|
-
if (timeout) {
|
7600
|
-
content.timeout = timeout;
|
7601
|
-
}
|
7602
|
-
var path = "/keys/claim";
|
7603
|
-
return this.http.authedRequest(Method.Post, path, undefined, content);
|
7604
|
-
}
|
7605
|
-
|
7606
5208
|
/**
|
7607
5209
|
* Ask the server for a list of users who have changed their device lists
|
7608
5210
|
* between a pair of sync tokens
|
@@ -7618,16 +5220,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7618
5220
|
};
|
7619
5221
|
return this.http.authedRequest(Method.Get, "/keys/changes", qps);
|
7620
5222
|
}
|
7621
|
-
uploadDeviceSigningKeys(auth, keys) {
|
7622
|
-
// API returns empty object
|
7623
|
-
var data = Object.assign({}, keys);
|
7624
|
-
if (auth) Object.assign(data, {
|
7625
|
-
auth
|
7626
|
-
});
|
7627
|
-
return this.http.authedRequest(Method.Post, "/keys/device_signing/upload", undefined, data, {
|
7628
|
-
prefix: ClientPrefix.Unstable
|
7629
|
-
});
|
7630
|
-
}
|
7631
5223
|
|
7632
5224
|
/**
|
7633
5225
|
* Register with an identity server using the OpenID token from the user's
|
@@ -7800,7 +5392,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7800
5392
|
* found MXIDs. Results where no user could be found will not be listed.
|
7801
5393
|
*/
|
7802
5394
|
identityHashedLookup(addressPairs, identityAccessToken) {
|
7803
|
-
var
|
5395
|
+
var _this55 = this;
|
7804
5396
|
return _asyncToGenerator(function* () {
|
7805
5397
|
var params = {
|
7806
5398
|
// addresses: ["email@example.org", "10005550000"],
|
@@ -7809,7 +5401,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7809
5401
|
};
|
7810
5402
|
|
7811
5403
|
// Get hash information first before trying to do a lookup
|
7812
|
-
var hashes = yield
|
5404
|
+
var hashes = yield _this55.getIdentityHashDetails(identityAccessToken);
|
7813
5405
|
if (!hashes || !hashes["lookup_pepper"] || !hashes["algorithms"]) {
|
7814
5406
|
throw new Error("Unsupported identity server: bad response");
|
7815
5407
|
}
|
@@ -7822,7 +5414,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7822
5414
|
// When picking an algorithm, we pick the hashed over no hashes
|
7823
5415
|
if (hashes["algorithms"].includes("sha256")) {
|
7824
5416
|
params["addresses"] = yield Promise.all(addressPairs.map(/*#__PURE__*/function () {
|
7825
|
-
var
|
5417
|
+
var _ref10 = _asyncToGenerator(function* (p) {
|
7826
5418
|
var addr = p[0].toLowerCase(); // lowercase to get consistent hashes
|
7827
5419
|
var med = p[1].toLowerCase();
|
7828
5420
|
var hashBuffer = yield sha256("".concat(addr, " ").concat(med, " ").concat(params["pepper"]));
|
@@ -7833,8 +5425,8 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7833
5425
|
localMapping[hashed] = p[0];
|
7834
5426
|
return hashed;
|
7835
5427
|
});
|
7836
|
-
return function (
|
7837
|
-
return
|
5428
|
+
return function (_x4) {
|
5429
|
+
return _ref10.apply(this, arguments);
|
7838
5430
|
};
|
7839
5431
|
}()));
|
7840
5432
|
params["algorithm"] = "sha256";
|
@@ -7852,7 +5444,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7852
5444
|
} else {
|
7853
5445
|
throw new Error("Unsupported identity server: unknown hash algorithm");
|
7854
5446
|
}
|
7855
|
-
var response = yield
|
5447
|
+
var response = yield _this55.http.idServerRequest(Method.Post, "/lookup", params, IdentityPrefix.V2, identityAccessToken);
|
7856
5448
|
if (!(response !== null && response !== void 0 && response["mappings"])) return []; // no results
|
7857
5449
|
|
7858
5450
|
var foundAddresses = [];
|
@@ -7886,12 +5478,12 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7886
5478
|
* @returns Rejects: with an error response.
|
7887
5479
|
*/
|
7888
5480
|
lookupThreePid(medium, address, identityAccessToken) {
|
7889
|
-
var
|
5481
|
+
var _this56 = this;
|
7890
5482
|
return _asyncToGenerator(function* () {
|
7891
5483
|
// Note: we're using the V2 API by calling this function, but our
|
7892
5484
|
// function contract requires a V1 response. We therefore have to
|
7893
5485
|
// convert it manually.
|
7894
|
-
var response = yield
|
5486
|
+
var response = yield _this56.identityHashedLookup([[address, medium]], identityAccessToken);
|
7895
5487
|
var result = response.find(p => p.address === address);
|
7896
5488
|
if (!result) {
|
7897
5489
|
return {};
|
@@ -7923,16 +5515,16 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7923
5515
|
* @returns Rejects: with an error response.
|
7924
5516
|
*/
|
7925
5517
|
bulkLookupThreePids(query, identityAccessToken) {
|
7926
|
-
var
|
5518
|
+
var _this57 = this;
|
7927
5519
|
return _asyncToGenerator(function* () {
|
7928
5520
|
// Note: we're using the V2 API by calling this function, but our
|
7929
5521
|
// function contract requires a V1 response. We therefore have to
|
7930
5522
|
// convert it manually.
|
7931
|
-
var response = yield
|
5523
|
+
var response = yield _this57.identityHashedLookup(
|
7932
5524
|
// We have to reverse the query order to get [address, medium] pairs
|
7933
5525
|
query.map(p => [p[1], p[0]]), identityAccessToken);
|
7934
5526
|
var v1results = [];
|
7935
|
-
var
|
5527
|
+
var _loop = function* _loop(mapping) {
|
7936
5528
|
var originalQuery = query.find(p => p[1] === mapping.address);
|
7937
5529
|
if (!originalQuery) {
|
7938
5530
|
throw new Error("Identity sever returned unexpected results");
|
@@ -7942,7 +5534,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7942
5534
|
mapping.address, mapping.mxid]);
|
7943
5535
|
};
|
7944
5536
|
for (var mapping of response) {
|
7945
|
-
yield*
|
5537
|
+
yield* _loop(mapping);
|
7946
5538
|
}
|
7947
5539
|
return {
|
7948
5540
|
threepids: v1results
|
@@ -8129,16 +5721,16 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8129
5721
|
* @returns Promise which resolves to the created space.
|
8130
5722
|
*/
|
8131
5723
|
unstableCreateFileTree(name) {
|
8132
|
-
var
|
5724
|
+
var _this58 = this;
|
8133
5725
|
return _asyncToGenerator(function* () {
|
8134
5726
|
var {
|
8135
5727
|
room_id: roomId
|
8136
|
-
} = yield
|
5728
|
+
} = yield _this58.createRoom({
|
8137
5729
|
name: name,
|
8138
5730
|
preset: Preset.PrivateChat,
|
8139
5731
|
power_level_content_override: _objectSpread(_objectSpread({}, DEFAULT_TREE_POWER_LEVELS_TEMPLATE), {}, {
|
8140
5732
|
users: {
|
8141
|
-
[
|
5733
|
+
[_this58.getUserId()]: 100
|
8142
5734
|
}
|
8143
5735
|
}),
|
8144
5736
|
creation_content: {
|
@@ -8150,15 +5742,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8150
5742
|
content: {
|
8151
5743
|
[UNSTABLE_MSC3088_ENABLED.name]: true
|
8152
5744
|
}
|
8153
|
-
}, {
|
8154
|
-
type: EventType.RoomEncryption,
|
8155
|
-
state_key: "",
|
8156
|
-
content: {
|
8157
|
-
algorithm: olmlib.MEGOLM_ALGORITHM
|
8158
|
-
}
|
8159
5745
|
}]
|
8160
5746
|
});
|
8161
|
-
return new MSC3089TreeSpace(
|
5747
|
+
return new MSC3089TreeSpace(_this58, roomId);
|
8162
5748
|
})();
|
8163
5749
|
}
|
8164
5750
|
|
@@ -8235,7 +5821,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8235
5821
|
* @param via - The list of servers which know about the room if only an ID was provided.
|
8236
5822
|
*/
|
8237
5823
|
getRoomSummary(roomIdOrAlias, via) {
|
8238
|
-
var
|
5824
|
+
var _this59 = this;
|
8239
5825
|
return _asyncToGenerator(function* () {
|
8240
5826
|
var paramOpts = {
|
8241
5827
|
prefix: "/_matrix/client/unstable/im.nheko.summary"
|
@@ -8244,7 +5830,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8244
5830
|
var path = utils.encodeUri("/summary/$roomid", {
|
8245
5831
|
$roomid: roomIdOrAlias
|
8246
5832
|
});
|
8247
|
-
return yield
|
5833
|
+
return yield _this59.http.authedRequest(Method.Get, path, {
|
8248
5834
|
via
|
8249
5835
|
}, undefined, paramOpts);
|
8250
5836
|
} catch (e) {
|
@@ -8252,7 +5838,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8252
5838
|
var _path = utils.encodeUri("/rooms/$roomid/summary", {
|
8253
5839
|
$roomid: roomIdOrAlias
|
8254
5840
|
});
|
8255
|
-
return yield
|
5841
|
+
return yield _this59.http.authedRequest(Method.Get, _path, {
|
8256
5842
|
via
|
8257
5843
|
}, undefined, paramOpts);
|
8258
5844
|
} else {
|
@@ -8304,9 +5890,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8304
5890
|
* Fetches information about the user for the configured access token.
|
8305
5891
|
*/
|
8306
5892
|
whoami() {
|
8307
|
-
var
|
5893
|
+
var _this60 = this;
|
8308
5894
|
return _asyncToGenerator(function* () {
|
8309
|
-
return
|
5895
|
+
return _this60.http.authedRequest(Method.Get, "/account/whoami");
|
8310
5896
|
})();
|
8311
5897
|
}
|
8312
5898
|
|
@@ -8317,7 +5903,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8317
5903
|
* @returns Rejects: when the request fails (module:http-api.MatrixError)
|
8318
5904
|
*/
|
8319
5905
|
timestampToEvent(roomId, timestamp, dir) {
|
8320
|
-
var
|
5906
|
+
var _this61 = this;
|
8321
5907
|
return _asyncToGenerator(function* () {
|
8322
5908
|
var path = utils.encodeUri("/rooms/$roomId/timestamp_to_event", {
|
8323
5909
|
$roomId: roomId
|
@@ -8327,7 +5913,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8327
5913
|
dir: dir
|
8328
5914
|
};
|
8329
5915
|
try {
|
8330
|
-
return yield
|
5916
|
+
return yield _this61.http.authedRequest(Method.Get, path, queryParams, undefined, {
|
8331
5917
|
prefix: ClientPrefix.V1
|
8332
5918
|
});
|
8333
5919
|
} catch (err) {
|
@@ -8343,7 +5929,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8343
5929
|
// both indicate that this endpoint+verb combination is
|
8344
5930
|
// not supported.
|
8345
5931
|
err.httpStatus === 404 || err.httpStatus === 405)) {
|
8346
|
-
return yield
|
5932
|
+
return yield _this61.http.authedRequest(Method.Get, path, queryParams, undefined, {
|
8347
5933
|
prefix: "/_matrix/client/unstable/org.matrix.msc3030"
|
8348
5934
|
});
|
8349
5935
|
}
|
@@ -8359,9 +5945,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8359
5945
|
* @experimental - part of MSC2965
|
8360
5946
|
*/
|
8361
5947
|
getAuthIssuer() {
|
8362
|
-
var
|
5948
|
+
var _this62 = this;
|
8363
5949
|
return _asyncToGenerator(function* () {
|
8364
|
-
return
|
5950
|
+
return _this62.http.request(Method.Get, "/auth_issuer", undefined, undefined, {
|
8365
5951
|
prefix: ClientPrefix.Unstable + "/org.matrix.msc2965"
|
8366
5952
|
});
|
8367
5953
|
})();
|
@@ -8369,88 +5955,12 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8369
5955
|
}
|
8370
5956
|
_defineProperty(MatrixClient, "RESTORE_BACKUP_ERROR_BAD_KEY", "RESTORE_BACKUP_ERROR_BAD_KEY");
|
8371
5957
|
function getUnstableDelayQueryOpts(delayOpts) {
|
8372
|
-
return Object.fromEntries(Object.entries(delayOpts).map(
|
8373
|
-
var [k, v] =
|
5958
|
+
return Object.fromEntries(Object.entries(delayOpts).map(_ref11 => {
|
5959
|
+
var [k, v] = _ref11;
|
8374
5960
|
return ["".concat(UNSTABLE_MSC4140_DELAYED_EVENTS, ".").concat(k), v];
|
8375
5961
|
}));
|
8376
5962
|
}
|
8377
5963
|
|
8378
|
-
/**
|
8379
|
-
* recalculates an accurate notifications count on event decryption.
|
8380
|
-
* Servers do not have enough knowledge about encrypted events to calculate an
|
8381
|
-
* accurate notification_count
|
8382
|
-
*/
|
8383
|
-
export function fixNotificationCountOnDecryption(cli, event) {
|
8384
|
-
var _actions$tweaks;
|
8385
|
-
var ourUserId = cli.getUserId();
|
8386
|
-
var eventId = event.getId();
|
8387
|
-
var room = cli.getRoom(event.getRoomId());
|
8388
|
-
if (!room || !ourUserId || !eventId) return;
|
8389
|
-
|
8390
|
-
// Due to threads, we can get relation events (eg. edits & reactions) that never get
|
8391
|
-
// added to a timeline and so cannot be found in their own room (their edit / reaction
|
8392
|
-
// still applies to the event it needs to, so it doesn't matter too much). However, if
|
8393
|
-
// we try to process notification about this event, we'll get very confused because we
|
8394
|
-
// won't be able to find the event in the room, so will assume it must be unread, even
|
8395
|
-
// if it's actually read. We therefore skip anything that isn't in the room. This isn't
|
8396
|
-
// *great*, so if we can fix the homeless events (eg. with MSC4023) then we should probably
|
8397
|
-
// remove this workaround.
|
8398
|
-
if (!room.findEventById(eventId)) {
|
8399
|
-
logger.info("Decrypted event ".concat(event.getId(), " is not in room ").concat(room.roomId, ": ignoring"));
|
8400
|
-
return;
|
8401
|
-
}
|
8402
|
-
var isThreadEvent = !!event.threadRootId && !event.isThreadRoot;
|
8403
|
-
var hasReadEvent;
|
8404
|
-
if (isThreadEvent) {
|
8405
|
-
var thread = room.getThread(event.threadRootId);
|
8406
|
-
hasReadEvent = thread ? thread.hasUserReadEvent(ourUserId, eventId) :
|
8407
|
-
// If the thread object does not exist in the room yet, we don't
|
8408
|
-
// want to calculate notification for this event yet. We have not
|
8409
|
-
// restored the read receipts yet and can't accurately calculate
|
8410
|
-
// notifications at this stage.
|
8411
|
-
//
|
8412
|
-
// This issue can likely go away when MSC3874 is implemented
|
8413
|
-
true;
|
8414
|
-
} else {
|
8415
|
-
hasReadEvent = room.hasUserReadEvent(ourUserId, eventId);
|
8416
|
-
}
|
8417
|
-
if (hasReadEvent) {
|
8418
|
-
// If the event has been read, ignore it.
|
8419
|
-
return;
|
8420
|
-
}
|
8421
|
-
var actions = cli.getPushActionsForEvent(event, true);
|
8422
|
-
|
8423
|
-
// Ensure the unread counts are kept up to date if the event is encrypted
|
8424
|
-
// We also want to make sure that the notification count goes up if we already
|
8425
|
-
// have encrypted events to avoid other code from resetting 'highlight' to zero.
|
8426
|
-
var newHighlight = !!(actions !== null && actions !== void 0 && (_actions$tweaks = actions.tweaks) !== null && _actions$tweaks !== void 0 && _actions$tweaks.highlight);
|
8427
|
-
if (newHighlight) {
|
8428
|
-
// TODO: Handle mentions received while the client is offline
|
8429
|
-
// See also https://github.com/vector-im/element-web/issues/9069
|
8430
|
-
var newCount = room.getUnreadCountForEventContext(NotificationCountType.Highlight, event) + 1;
|
8431
|
-
if (isThreadEvent) {
|
8432
|
-
room.setThreadUnreadNotificationCount(event.threadRootId, NotificationCountType.Highlight, newCount);
|
8433
|
-
} else {
|
8434
|
-
room.setUnreadNotificationCount(NotificationCountType.Highlight, newCount);
|
8435
|
-
}
|
8436
|
-
}
|
8437
|
-
|
8438
|
-
// `notify` is used in practice for incrementing the total count
|
8439
|
-
var newNotify = !!(actions !== null && actions !== void 0 && actions.notify);
|
8440
|
-
|
8441
|
-
// The room total count is NEVER incremented by the server for encrypted rooms. We basically ignore
|
8442
|
-
// the server here as it's always going to tell us to increment for encrypted events.
|
8443
|
-
if (newNotify) {
|
8444
|
-
// Total count is used to typically increment a room notification counter, but not loudly highlight it.
|
8445
|
-
var _newCount = room.getUnreadCountForEventContext(NotificationCountType.Total, event) + 1;
|
8446
|
-
if (isThreadEvent) {
|
8447
|
-
room.setThreadUnreadNotificationCount(event.threadRootId, NotificationCountType.Total, _newCount);
|
8448
|
-
} else {
|
8449
|
-
room.setUnreadNotificationCount(NotificationCountType.Total, _newCount);
|
8450
|
-
}
|
8451
|
-
}
|
8452
|
-
}
|
8453
|
-
|
8454
5964
|
/**
|
8455
5965
|
* Given an event, figure out the thread ID we should use for it in a receipt.
|
8456
5966
|
*
|