@unwanted/matrix-sdk-mini 34.12.0-1 → 34.12.0-3
Sign up to get free protection for your applications and to get access to all the features.
- package/git-revision.txt +1 -1
- package/lib/@types/event.d.ts +0 -19
- package/lib/@types/event.d.ts.map +1 -1
- package/lib/@types/event.js.map +1 -1
- package/lib/@types/global.d.js +0 -2
- package/lib/@types/global.d.js.map +1 -1
- package/lib/browser-index.d.ts.map +1 -1
- package/lib/browser-index.js +0 -11
- package/lib/browser-index.js.map +1 -1
- package/lib/client.d.ts +2 -1224
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +345 -2826
- package/lib/client.js.map +1 -1
- package/lib/embedded.d.ts +0 -22
- package/lib/embedded.d.ts.map +1 -1
- package/lib/embedded.js +24 -167
- package/lib/embedded.js.map +1 -1
- package/lib/event-mapper.d.ts.map +1 -1
- package/lib/event-mapper.js +0 -4
- package/lib/event-mapper.js.map +1 -1
- package/lib/matrix.d.ts +0 -25
- package/lib/matrix.d.ts.map +1 -1
- package/lib/matrix.js +1 -30
- package/lib/matrix.js.map +1 -1
- package/lib/models/MSC3089Branch.d.ts.map +1 -1
- package/lib/models/MSC3089Branch.js +0 -3
- package/lib/models/MSC3089Branch.js.map +1 -1
- package/lib/models/event.d.ts +0 -94
- package/lib/models/event.d.ts.map +1 -1
- package/lib/models/event.js +0 -274
- package/lib/models/event.js.map +1 -1
- package/lib/models/poll.d.ts.map +1 -1
- package/lib/models/poll.js +1 -5
- package/lib/models/poll.js.map +1 -1
- package/lib/models/relations-container.d.ts.map +1 -1
- package/lib/models/relations-container.js +1 -7
- package/lib/models/relations-container.js.map +1 -1
- package/lib/models/relations.d.ts +0 -1
- package/lib/models/relations.d.ts.map +1 -1
- package/lib/models/relations.js +0 -8
- package/lib/models/relations.js.map +1 -1
- package/lib/models/room-state.d.ts.map +1 -1
- package/lib/models/room-state.js +10 -26
- package/lib/models/room-state.js.map +1 -1
- package/lib/models/room.d.ts +0 -18
- package/lib/models/room.d.ts.map +1 -1
- package/lib/models/room.js +94 -148
- package/lib/models/room.js.map +1 -1
- package/lib/models/thread.d.ts.map +1 -1
- package/lib/models/thread.js +0 -1
- package/lib/models/thread.js.map +1 -1
- package/lib/sliding-sync-sdk.d.ts +2 -3
- package/lib/sliding-sync-sdk.d.ts.map +1 -1
- package/lib/sliding-sync-sdk.js +41 -90
- package/lib/sliding-sync-sdk.js.map +1 -1
- package/lib/sync.d.ts +0 -12
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +1 -73
- package/lib/sync.js.map +1 -1
- package/lib/testing.d.ts +0 -48
- package/lib/testing.d.ts.map +1 -1
- package/lib/testing.js +0 -105
- package/lib/testing.js.map +1 -1
- package/package.json +1 -3
- package/src/@types/event.ts +2 -36
- package/src/@types/global.d.ts +0 -3
- package/src/browser-index.ts +0 -11
- package/src/client.ts +52 -2876
- package/src/embedded.ts +3 -132
- package/src/event-mapper.ts +0 -4
- package/src/matrix.ts +0 -41
- package/src/models/MSC3089Branch.ts +0 -3
- package/src/models/event.ts +0 -289
- package/src/models/poll.ts +0 -6
- package/src/models/relations-container.ts +1 -8
- package/src/models/relations.ts +0 -8
- package/src/models/room-state.ts +2 -8
- package/src/models/room.ts +0 -62
- package/src/models/thread.ts +0 -1
- package/src/sliding-sync-sdk.ts +2 -72
- package/src/sync.ts +1 -98
- package/src/testing.ts +0 -108
- package/lib/@types/crypto.d.ts +0 -47
- package/lib/@types/crypto.d.ts.map +0 -1
- package/lib/@types/crypto.js +0 -1
- package/lib/@types/crypto.js.map +0 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js +0 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js.map +0 -1
- package/lib/common-crypto/CryptoBackend.d.ts +0 -240
- package/lib/common-crypto/CryptoBackend.d.ts.map +0 -1
- package/lib/common-crypto/CryptoBackend.js +0 -73
- package/lib/common-crypto/CryptoBackend.js.map +0 -1
- package/lib/common-crypto/key-passphrase.d.ts +0 -14
- package/lib/common-crypto/key-passphrase.d.ts.map +0 -1
- package/lib/common-crypto/key-passphrase.js +0 -33
- package/lib/common-crypto/key-passphrase.js.map +0 -1
- package/lib/crypto/CrossSigning.d.ts +0 -184
- package/lib/crypto/CrossSigning.d.ts.map +0 -1
- package/lib/crypto/CrossSigning.js +0 -718
- package/lib/crypto/CrossSigning.js.map +0 -1
- package/lib/crypto/DeviceList.d.ts +0 -216
- package/lib/crypto/DeviceList.d.ts.map +0 -1
- package/lib/crypto/DeviceList.js +0 -892
- package/lib/crypto/DeviceList.js.map +0 -1
- package/lib/crypto/EncryptionSetup.d.ts +0 -152
- package/lib/crypto/EncryptionSetup.d.ts.map +0 -1
- package/lib/crypto/EncryptionSetup.js +0 -356
- package/lib/crypto/EncryptionSetup.js.map +0 -1
- package/lib/crypto/OlmDevice.d.ts +0 -457
- package/lib/crypto/OlmDevice.d.ts.map +0 -1
- package/lib/crypto/OlmDevice.js +0 -1241
- package/lib/crypto/OlmDevice.js.map +0 -1
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts +0 -109
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts.map +0 -1
- package/lib/crypto/OutgoingRoomKeyRequestManager.js +0 -415
- package/lib/crypto/OutgoingRoomKeyRequestManager.js.map +0 -1
- package/lib/crypto/RoomList.d.ts +0 -26
- package/lib/crypto/RoomList.d.ts.map +0 -1
- package/lib/crypto/RoomList.js +0 -71
- package/lib/crypto/RoomList.js.map +0 -1
- package/lib/crypto/SecretSharing.d.ts +0 -24
- package/lib/crypto/SecretSharing.d.ts.map +0 -1
- package/lib/crypto/SecretSharing.js +0 -194
- package/lib/crypto/SecretSharing.js.map +0 -1
- package/lib/crypto/SecretStorage.d.ts +0 -55
- package/lib/crypto/SecretStorage.d.ts.map +0 -1
- package/lib/crypto/SecretStorage.js +0 -118
- package/lib/crypto/SecretStorage.js.map +0 -1
- package/lib/crypto/aes.d.ts +0 -6
- package/lib/crypto/aes.d.ts.map +0 -1
- package/lib/crypto/aes.js +0 -24
- package/lib/crypto/aes.js.map +0 -1
- package/lib/crypto/algorithms/base.d.ts +0 -156
- package/lib/crypto/algorithms/base.d.ts.map +0 -1
- package/lib/crypto/algorithms/base.js +0 -187
- package/lib/crypto/algorithms/base.js.map +0 -1
- package/lib/crypto/algorithms/index.d.ts +0 -4
- package/lib/crypto/algorithms/index.d.ts.map +0 -1
- package/lib/crypto/algorithms/index.js +0 -20
- package/lib/crypto/algorithms/index.js.map +0 -1
- package/lib/crypto/algorithms/megolm.d.ts +0 -385
- package/lib/crypto/algorithms/megolm.d.ts.map +0 -1
- package/lib/crypto/algorithms/megolm.js +0 -1822
- package/lib/crypto/algorithms/megolm.js.map +0 -1
- package/lib/crypto/algorithms/olm.d.ts +0 -5
- package/lib/crypto/algorithms/olm.d.ts.map +0 -1
- package/lib/crypto/algorithms/olm.js +0 -299
- package/lib/crypto/algorithms/olm.js.map +0 -1
- package/lib/crypto/api.d.ts +0 -32
- package/lib/crypto/api.d.ts.map +0 -1
- package/lib/crypto/api.js +0 -22
- package/lib/crypto/api.js.map +0 -1
- package/lib/crypto/backup.d.ts +0 -227
- package/lib/crypto/backup.d.ts.map +0 -1
- package/lib/crypto/backup.js +0 -824
- package/lib/crypto/backup.js.map +0 -1
- package/lib/crypto/crypto.d.ts +0 -3
- package/lib/crypto/crypto.d.ts.map +0 -1
- package/lib/crypto/crypto.js +0 -19
- package/lib/crypto/crypto.js.map +0 -1
- package/lib/crypto/dehydration.d.ts +0 -34
- package/lib/crypto/dehydration.d.ts.map +0 -1
- package/lib/crypto/dehydration.js +0 -252
- package/lib/crypto/dehydration.js.map +0 -1
- package/lib/crypto/device-converter.d.ts +0 -9
- package/lib/crypto/device-converter.d.ts.map +0 -1
- package/lib/crypto/device-converter.js +0 -42
- package/lib/crypto/device-converter.js.map +0 -1
- package/lib/crypto/deviceinfo.d.ts +0 -99
- package/lib/crypto/deviceinfo.d.ts.map +0 -1
- package/lib/crypto/deviceinfo.js +0 -148
- package/lib/crypto/deviceinfo.js.map +0 -1
- package/lib/crypto/index.d.ts +0 -1209
- package/lib/crypto/index.d.ts.map +0 -1
- package/lib/crypto/index.js +0 -4097
- package/lib/crypto/index.js.map +0 -1
- package/lib/crypto/key_passphrase.d.ts +0 -14
- package/lib/crypto/key_passphrase.d.ts.map +0 -1
- package/lib/crypto/key_passphrase.js +0 -44
- package/lib/crypto/key_passphrase.js.map +0 -1
- package/lib/crypto/keybackup.d.ts +0 -18
- package/lib/crypto/keybackup.d.ts.map +0 -1
- package/lib/crypto/keybackup.js +0 -1
- package/lib/crypto/keybackup.js.map +0 -1
- package/lib/crypto/olmlib.d.ts +0 -129
- package/lib/crypto/olmlib.d.ts.map +0 -1
- package/lib/crypto/olmlib.js +0 -492
- package/lib/crypto/olmlib.js.map +0 -1
- package/lib/crypto/recoverykey.d.ts +0 -2
- package/lib/crypto/recoverykey.d.ts.map +0 -1
- package/lib/crypto/recoverykey.js +0 -19
- package/lib/crypto/recoverykey.js.map +0 -1
- package/lib/crypto/store/base.d.ts +0 -252
- package/lib/crypto/store/base.d.ts.map +0 -1
- package/lib/crypto/store/base.js +0 -64
- package/lib/crypto/store/base.js.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts +0 -187
- package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.js +0 -1145
- package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store.d.ts +0 -432
- package/lib/crypto/store/indexeddb-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store.js +0 -728
- package/lib/crypto/store/indexeddb-crypto-store.js.map +0 -1
- package/lib/crypto/store/localStorage-crypto-store.d.ts +0 -119
- package/lib/crypto/store/localStorage-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/localStorage-crypto-store.js +0 -531
- package/lib/crypto/store/localStorage-crypto-store.js.map +0 -1
- package/lib/crypto/store/memory-crypto-store.d.ts +0 -215
- package/lib/crypto/store/memory-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/memory-crypto-store.js +0 -622
- package/lib/crypto/store/memory-crypto-store.js.map +0 -1
- package/lib/crypto/verification/Base.d.ts +0 -105
- package/lib/crypto/verification/Base.d.ts.map +0 -1
- package/lib/crypto/verification/Base.js +0 -372
- package/lib/crypto/verification/Base.js.map +0 -1
- package/lib/crypto/verification/Error.d.ts +0 -35
- package/lib/crypto/verification/Error.d.ts.map +0 -1
- package/lib/crypto/verification/Error.js +0 -86
- package/lib/crypto/verification/Error.js.map +0 -1
- package/lib/crypto/verification/IllegalMethod.d.ts +0 -15
- package/lib/crypto/verification/IllegalMethod.d.ts.map +0 -1
- package/lib/crypto/verification/IllegalMethod.js +0 -43
- package/lib/crypto/verification/IllegalMethod.js.map +0 -1
- package/lib/crypto/verification/QRCode.d.ts +0 -51
- package/lib/crypto/verification/QRCode.d.ts.map +0 -1
- package/lib/crypto/verification/QRCode.js +0 -277
- package/lib/crypto/verification/QRCode.js.map +0 -1
- package/lib/crypto/verification/SAS.d.ts +0 -27
- package/lib/crypto/verification/SAS.d.ts.map +0 -1
- package/lib/crypto/verification/SAS.js +0 -485
- package/lib/crypto/verification/SAS.js.map +0 -1
- package/lib/crypto/verification/SASDecimal.d.ts +0 -8
- package/lib/crypto/verification/SASDecimal.d.ts.map +0 -1
- package/lib/crypto/verification/SASDecimal.js +0 -34
- package/lib/crypto/verification/SASDecimal.js.map +0 -1
- package/lib/crypto/verification/request/Channel.d.ts +0 -18
- package/lib/crypto/verification/request/Channel.d.ts.map +0 -1
- package/lib/crypto/verification/request/Channel.js +0 -1
- package/lib/crypto/verification/request/Channel.js.map +0 -1
- package/lib/crypto/verification/request/InRoomChannel.d.ts +0 -113
- package/lib/crypto/verification/request/InRoomChannel.d.ts.map +0 -1
- package/lib/crypto/verification/request/InRoomChannel.js +0 -351
- package/lib/crypto/verification/request/InRoomChannel.js.map +0 -1
- package/lib/crypto/verification/request/ToDeviceChannel.d.ts +0 -105
- package/lib/crypto/verification/request/ToDeviceChannel.d.ts.map +0 -1
- package/lib/crypto/verification/request/ToDeviceChannel.js +0 -328
- package/lib/crypto/verification/request/ToDeviceChannel.js.map +0 -1
- package/lib/crypto/verification/request/VerificationRequest.d.ts +0 -227
- package/lib/crypto/verification/request/VerificationRequest.d.ts.map +0 -1
- package/lib/crypto/verification/request/VerificationRequest.js +0 -937
- package/lib/crypto/verification/request/VerificationRequest.js.map +0 -1
- package/lib/crypto-api/CryptoEvent.d.ts +0 -69
- package/lib/crypto-api/CryptoEvent.d.ts.map +0 -1
- package/lib/crypto-api/CryptoEvent.js +0 -33
- package/lib/crypto-api/CryptoEvent.js.map +0 -1
- package/lib/crypto-api/CryptoEventHandlerMap.d.ts +0 -16
- package/lib/crypto-api/CryptoEventHandlerMap.d.ts.map +0 -1
- package/lib/crypto-api/CryptoEventHandlerMap.js +0 -22
- package/lib/crypto-api/CryptoEventHandlerMap.js.map +0 -1
- package/lib/crypto-api/index.d.ts +0 -978
- package/lib/crypto-api/index.d.ts.map +0 -1
- package/lib/crypto-api/index.js +0 -304
- package/lib/crypto-api/index.js.map +0 -1
- package/lib/crypto-api/key-passphrase.d.ts +0 -11
- package/lib/crypto-api/key-passphrase.d.ts.map +0 -1
- package/lib/crypto-api/key-passphrase.js +0 -51
- package/lib/crypto-api/key-passphrase.js.map +0 -1
- package/lib/crypto-api/keybackup.d.ts +0 -88
- package/lib/crypto-api/keybackup.d.ts.map +0 -1
- package/lib/crypto-api/keybackup.js +0 -1
- package/lib/crypto-api/keybackup.js.map +0 -1
- package/lib/crypto-api/recovery-key.d.ts +0 -11
- package/lib/crypto-api/recovery-key.d.ts.map +0 -1
- package/lib/crypto-api/recovery-key.js +0 -65
- package/lib/crypto-api/recovery-key.js.map +0 -1
- package/lib/crypto-api/verification.d.ts +0 -344
- package/lib/crypto-api/verification.d.ts.map +0 -1
- package/lib/crypto-api/verification.js +0 -91
- package/lib/crypto-api/verification.js.map +0 -1
- package/lib/matrixrtc/CallMembership.d.ts +0 -66
- package/lib/matrixrtc/CallMembership.d.ts.map +0 -1
- package/lib/matrixrtc/CallMembership.js +0 -197
- package/lib/matrixrtc/CallMembership.js.map +0 -1
- package/lib/matrixrtc/LivekitFocus.d.ts +0 -16
- package/lib/matrixrtc/LivekitFocus.d.ts.map +0 -1
- package/lib/matrixrtc/LivekitFocus.js +0 -20
- package/lib/matrixrtc/LivekitFocus.js.map +0 -1
- package/lib/matrixrtc/MatrixRTCSession.d.ts +0 -295
- package/lib/matrixrtc/MatrixRTCSession.d.ts.map +0 -1
- package/lib/matrixrtc/MatrixRTCSession.js +0 -1043
- package/lib/matrixrtc/MatrixRTCSession.js.map +0 -1
- package/lib/matrixrtc/MatrixRTCSessionManager.d.ts +0 -40
- package/lib/matrixrtc/MatrixRTCSessionManager.d.ts.map +0 -1
- package/lib/matrixrtc/MatrixRTCSessionManager.js +0 -146
- package/lib/matrixrtc/MatrixRTCSessionManager.js.map +0 -1
- package/lib/matrixrtc/focus.d.ts +0 -10
- package/lib/matrixrtc/focus.d.ts.map +0 -1
- package/lib/matrixrtc/focus.js +0 -1
- package/lib/matrixrtc/focus.js.map +0 -1
- package/lib/matrixrtc/index.d.ts +0 -7
- package/lib/matrixrtc/index.d.ts.map +0 -1
- package/lib/matrixrtc/index.js +0 -21
- package/lib/matrixrtc/index.js.map +0 -1
- package/lib/matrixrtc/types.d.ts +0 -19
- package/lib/matrixrtc/types.d.ts.map +0 -1
- package/lib/matrixrtc/types.js +0 -1
- package/lib/matrixrtc/types.js.map +0 -1
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts +0 -112
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts.map +0 -1
- package/lib/rendezvous/MSC4108SignInWithQR.js +0 -392
- package/lib/rendezvous/MSC4108SignInWithQR.js.map +0 -1
- package/lib/rendezvous/RendezvousChannel.d.ts +0 -27
- package/lib/rendezvous/RendezvousChannel.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousChannel.js +0 -1
- package/lib/rendezvous/RendezvousChannel.js.map +0 -1
- package/lib/rendezvous/RendezvousCode.d.ts +0 -9
- package/lib/rendezvous/RendezvousCode.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousCode.js +0 -1
- package/lib/rendezvous/RendezvousCode.js.map +0 -1
- package/lib/rendezvous/RendezvousError.d.ts +0 -6
- package/lib/rendezvous/RendezvousError.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousError.js +0 -23
- package/lib/rendezvous/RendezvousError.js.map +0 -1
- package/lib/rendezvous/RendezvousFailureReason.d.ts +0 -31
- package/lib/rendezvous/RendezvousFailureReason.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousFailureReason.js +0 -38
- package/lib/rendezvous/RendezvousFailureReason.js.map +0 -1
- package/lib/rendezvous/RendezvousIntent.d.ts +0 -5
- package/lib/rendezvous/RendezvousIntent.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousIntent.js +0 -22
- package/lib/rendezvous/RendezvousIntent.js.map +0 -1
- package/lib/rendezvous/RendezvousTransport.d.ts +0 -36
- package/lib/rendezvous/RendezvousTransport.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousTransport.js +0 -1
- package/lib/rendezvous/RendezvousTransport.js.map +0 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts +0 -58
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts.map +0 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.js +0 -246
- package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +0 -1
- package/lib/rendezvous/channels/index.d.ts +0 -2
- package/lib/rendezvous/channels/index.d.ts.map +0 -1
- package/lib/rendezvous/channels/index.js +0 -18
- package/lib/rendezvous/channels/index.js.map +0 -1
- package/lib/rendezvous/index.d.ts +0 -10
- package/lib/rendezvous/index.d.ts.map +0 -1
- package/lib/rendezvous/index.js +0 -23
- package/lib/rendezvous/index.js.map +0 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +0 -61
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts.map +0 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js +0 -253
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +0 -1
- package/lib/rendezvous/transports/index.d.ts +0 -2
- package/lib/rendezvous/transports/index.d.ts.map +0 -1
- package/lib/rendezvous/transports/index.js +0 -18
- package/lib/rendezvous/transports/index.js.map +0 -1
- package/lib/rust-crypto/CrossSigningIdentity.d.ts +0 -33
- package/lib/rust-crypto/CrossSigningIdentity.d.ts.map +0 -1
- package/lib/rust-crypto/CrossSigningIdentity.js +0 -157
- package/lib/rust-crypto/CrossSigningIdentity.js.map +0 -1
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts +0 -98
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts.map +0 -1
- package/lib/rust-crypto/DehydratedDeviceManager.js +0 -285
- package/lib/rust-crypto/DehydratedDeviceManager.js.map +0 -1
- package/lib/rust-crypto/KeyClaimManager.d.ts +0 -33
- package/lib/rust-crypto/KeyClaimManager.d.ts.map +0 -1
- package/lib/rust-crypto/KeyClaimManager.js +0 -82
- package/lib/rust-crypto/KeyClaimManager.js.map +0 -1
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts +0 -43
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts.map +0 -1
- package/lib/rust-crypto/OutgoingRequestProcessor.js +0 -195
- package/lib/rust-crypto/OutgoingRequestProcessor.js.map +0 -1
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts +0 -47
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts.map +0 -1
- package/lib/rust-crypto/OutgoingRequestsManager.js +0 -148
- package/lib/rust-crypto/OutgoingRequestsManager.js.map +0 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +0 -120
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts.map +0 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +0 -467
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +0 -1
- package/lib/rust-crypto/RoomEncryptor.d.ts +0 -98
- package/lib/rust-crypto/RoomEncryptor.d.ts.map +0 -1
- package/lib/rust-crypto/RoomEncryptor.js +0 -299
- package/lib/rust-crypto/RoomEncryptor.js.map +0 -1
- package/lib/rust-crypto/backup.d.ts +0 -254
- package/lib/rust-crypto/backup.d.ts.map +0 -1
- package/lib/rust-crypto/backup.js +0 -837
- package/lib/rust-crypto/backup.js.map +0 -1
- package/lib/rust-crypto/constants.d.ts +0 -3
- package/lib/rust-crypto/constants.d.ts.map +0 -1
- package/lib/rust-crypto/constants.js +0 -19
- package/lib/rust-crypto/constants.js.map +0 -1
- package/lib/rust-crypto/device-converter.d.ts +0 -28
- package/lib/rust-crypto/device-converter.d.ts.map +0 -1
- package/lib/rust-crypto/device-converter.js +0 -123
- package/lib/rust-crypto/device-converter.js.map +0 -1
- package/lib/rust-crypto/index.d.ts +0 -61
- package/lib/rust-crypto/index.d.ts.map +0 -1
- package/lib/rust-crypto/index.js +0 -152
- package/lib/rust-crypto/index.js.map +0 -1
- package/lib/rust-crypto/libolm_migration.d.ts +0 -81
- package/lib/rust-crypto/libolm_migration.d.ts.map +0 -1
- package/lib/rust-crypto/libolm_migration.js +0 -459
- package/lib/rust-crypto/libolm_migration.js.map +0 -1
- package/lib/rust-crypto/rust-crypto.d.ts +0 -556
- package/lib/rust-crypto/rust-crypto.d.ts.map +0 -1
- package/lib/rust-crypto/rust-crypto.js +0 -2016
- package/lib/rust-crypto/rust-crypto.js.map +0 -1
- package/lib/rust-crypto/secret-storage.d.ts +0 -22
- package/lib/rust-crypto/secret-storage.d.ts.map +0 -1
- package/lib/rust-crypto/secret-storage.js +0 -63
- package/lib/rust-crypto/secret-storage.js.map +0 -1
- package/lib/rust-crypto/verification.d.ts +0 -319
- package/lib/rust-crypto/verification.d.ts.map +0 -1
- package/lib/rust-crypto/verification.js +0 -816
- package/lib/rust-crypto/verification.js.map +0 -1
- package/lib/secret-storage.d.ts +0 -370
- package/lib/secret-storage.d.ts.map +0 -1
- package/lib/secret-storage.js +0 -466
- package/lib/secret-storage.js.map +0 -1
- package/lib/webrtc/audioContext.d.ts +0 -15
- package/lib/webrtc/audioContext.d.ts.map +0 -1
- package/lib/webrtc/audioContext.js +0 -46
- package/lib/webrtc/audioContext.js.map +0 -1
- package/lib/webrtc/call.d.ts +0 -560
- package/lib/webrtc/call.d.ts.map +0 -1
- package/lib/webrtc/call.js +0 -2541
- package/lib/webrtc/call.js.map +0 -1
- package/lib/webrtc/callEventHandler.d.ts +0 -37
- package/lib/webrtc/callEventHandler.d.ts.map +0 -1
- package/lib/webrtc/callEventHandler.js +0 -344
- package/lib/webrtc/callEventHandler.js.map +0 -1
- package/lib/webrtc/callEventTypes.d.ts +0 -73
- package/lib/webrtc/callEventTypes.d.ts.map +0 -1
- package/lib/webrtc/callEventTypes.js +0 -13
- package/lib/webrtc/callEventTypes.js.map +0 -1
- package/lib/webrtc/callFeed.d.ts +0 -128
- package/lib/webrtc/callFeed.d.ts.map +0 -1
- package/lib/webrtc/callFeed.js +0 -289
- package/lib/webrtc/callFeed.js.map +0 -1
- package/lib/webrtc/groupCall.d.ts +0 -323
- package/lib/webrtc/groupCall.d.ts.map +0 -1
- package/lib/webrtc/groupCall.js +0 -1337
- package/lib/webrtc/groupCall.js.map +0 -1
- package/lib/webrtc/groupCallEventHandler.d.ts +0 -31
- package/lib/webrtc/groupCallEventHandler.d.ts.map +0 -1
- package/lib/webrtc/groupCallEventHandler.js +0 -178
- package/lib/webrtc/groupCallEventHandler.js.map +0 -1
- package/lib/webrtc/mediaHandler.d.ts +0 -89
- package/lib/webrtc/mediaHandler.d.ts.map +0 -1
- package/lib/webrtc/mediaHandler.js +0 -437
- package/lib/webrtc/mediaHandler.js.map +0 -1
- package/lib/webrtc/stats/callFeedStatsReporter.d.ts +0 -8
- package/lib/webrtc/stats/callFeedStatsReporter.d.ts.map +0 -1
- package/lib/webrtc/stats/callFeedStatsReporter.js +0 -82
- package/lib/webrtc/stats/callFeedStatsReporter.js.map +0 -1
- package/lib/webrtc/stats/callStatsReportGatherer.d.ts +0 -25
- package/lib/webrtc/stats/callStatsReportGatherer.d.ts.map +0 -1
- package/lib/webrtc/stats/callStatsReportGatherer.js +0 -199
- package/lib/webrtc/stats/callStatsReportGatherer.js.map +0 -1
- package/lib/webrtc/stats/callStatsReportSummary.d.ts +0 -17
- package/lib/webrtc/stats/callStatsReportSummary.d.ts.map +0 -1
- package/lib/webrtc/stats/callStatsReportSummary.js +0 -1
- package/lib/webrtc/stats/callStatsReportSummary.js.map +0 -1
- package/lib/webrtc/stats/connectionStats.d.ts +0 -28
- package/lib/webrtc/stats/connectionStats.d.ts.map +0 -1
- package/lib/webrtc/stats/connectionStats.js +0 -26
- package/lib/webrtc/stats/connectionStats.js.map +0 -1
- package/lib/webrtc/stats/connectionStatsBuilder.d.ts +0 -5
- package/lib/webrtc/stats/connectionStatsBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/connectionStatsBuilder.js +0 -27
- package/lib/webrtc/stats/connectionStatsBuilder.js.map +0 -1
- package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts +0 -7
- package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/connectionStatsReportBuilder.js +0 -121
- package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +0 -1
- package/lib/webrtc/stats/groupCallStats.d.ts +0 -22
- package/lib/webrtc/stats/groupCallStats.d.ts.map +0 -1
- package/lib/webrtc/stats/groupCallStats.js +0 -78
- package/lib/webrtc/stats/groupCallStats.js.map +0 -1
- package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts +0 -10
- package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaSsrcHandler.js +0 -57
- package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackHandler.d.ts +0 -12
- package/lib/webrtc/stats/media/mediaTrackHandler.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackHandler.js +0 -62
- package/lib/webrtc/stats/media/mediaTrackHandler.js.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStats.d.ts +0 -86
- package/lib/webrtc/stats/media/mediaTrackStats.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStats.js +0 -142
- package/lib/webrtc/stats/media/mediaTrackStats.js.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts +0 -22
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +0 -76
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +0 -1
- package/lib/webrtc/stats/statsReport.d.ts +0 -99
- package/lib/webrtc/stats/statsReport.d.ts.map +0 -1
- package/lib/webrtc/stats/statsReport.js +0 -32
- package/lib/webrtc/stats/statsReport.js.map +0 -1
- package/lib/webrtc/stats/statsReportEmitter.d.ts +0 -15
- package/lib/webrtc/stats/statsReportEmitter.d.ts.map +0 -1
- package/lib/webrtc/stats/statsReportEmitter.js +0 -33
- package/lib/webrtc/stats/statsReportEmitter.js.map +0 -1
- package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts +0 -16
- package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts.map +0 -1
- package/lib/webrtc/stats/summaryStatsReportGatherer.js +0 -116
- package/lib/webrtc/stats/summaryStatsReportGatherer.js.map +0 -1
- package/lib/webrtc/stats/trackStatsBuilder.d.ts +0 -19
- package/lib/webrtc/stats/trackStatsBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/trackStatsBuilder.js +0 -168
- package/lib/webrtc/stats/trackStatsBuilder.js.map +0 -1
- package/lib/webrtc/stats/transportStats.d.ts +0 -11
- package/lib/webrtc/stats/transportStats.d.ts.map +0 -1
- package/lib/webrtc/stats/transportStats.js +0 -1
- package/lib/webrtc/stats/transportStats.js.map +0 -1
- package/lib/webrtc/stats/transportStatsBuilder.d.ts +0 -5
- package/lib/webrtc/stats/transportStatsBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/transportStatsBuilder.js +0 -34
- package/lib/webrtc/stats/transportStatsBuilder.js.map +0 -1
- package/lib/webrtc/stats/valueFormatter.d.ts +0 -4
- package/lib/webrtc/stats/valueFormatter.d.ts.map +0 -1
- package/lib/webrtc/stats/valueFormatter.js +0 -25
- package/lib/webrtc/stats/valueFormatter.js.map +0 -1
- package/src/@types/crypto.ts +0 -73
- package/src/@types/matrix-sdk-crypto-wasm.d.ts +0 -44
- package/src/common-crypto/CryptoBackend.ts +0 -302
- package/src/common-crypto/README.md +0 -4
- package/src/common-crypto/key-passphrase.ts +0 -43
- package/src/crypto/CrossSigning.ts +0 -773
- package/src/crypto/DeviceList.ts +0 -989
- package/src/crypto/EncryptionSetup.ts +0 -351
- package/src/crypto/OlmDevice.ts +0 -1500
- package/src/crypto/OutgoingRoomKeyRequestManager.ts +0 -485
- package/src/crypto/RoomList.ts +0 -70
- package/src/crypto/SecretSharing.ts +0 -240
- package/src/crypto/SecretStorage.ts +0 -136
- package/src/crypto/aes.ts +0 -23
- package/src/crypto/algorithms/base.ts +0 -236
- package/src/crypto/algorithms/index.ts +0 -20
- package/src/crypto/algorithms/megolm.ts +0 -2216
- package/src/crypto/algorithms/olm.ts +0 -381
- package/src/crypto/api.ts +0 -70
- package/src/crypto/backup.ts +0 -922
- package/src/crypto/crypto.ts +0 -18
- package/src/crypto/dehydration.ts +0 -272
- package/src/crypto/device-converter.ts +0 -45
- package/src/crypto/deviceinfo.ts +0 -158
- package/src/crypto/index.ts +0 -4414
- package/src/crypto/key_passphrase.ts +0 -42
- package/src/crypto/keybackup.ts +0 -47
- package/src/crypto/olmlib.ts +0 -539
- package/src/crypto/recoverykey.ts +0 -18
- package/src/crypto/store/base.ts +0 -348
- package/src/crypto/store/indexeddb-crypto-store-backend.ts +0 -1250
- package/src/crypto/store/indexeddb-crypto-store.ts +0 -845
- package/src/crypto/store/localStorage-crypto-store.ts +0 -579
- package/src/crypto/store/memory-crypto-store.ts +0 -680
- package/src/crypto/verification/Base.ts +0 -409
- package/src/crypto/verification/Error.ts +0 -76
- package/src/crypto/verification/IllegalMethod.ts +0 -50
- package/src/crypto/verification/QRCode.ts +0 -310
- package/src/crypto/verification/SAS.ts +0 -494
- package/src/crypto/verification/SASDecimal.ts +0 -37
- package/src/crypto/verification/request/Channel.ts +0 -34
- package/src/crypto/verification/request/InRoomChannel.ts +0 -371
- package/src/crypto/verification/request/ToDeviceChannel.ts +0 -354
- package/src/crypto/verification/request/VerificationRequest.ts +0 -976
- package/src/crypto-api/CryptoEvent.ts +0 -93
- package/src/crypto-api/CryptoEventHandlerMap.ts +0 -32
- package/src/crypto-api/index.ts +0 -1175
- package/src/crypto-api/key-passphrase.ts +0 -58
- package/src/crypto-api/keybackup.ts +0 -115
- package/src/crypto-api/recovery-key.ts +0 -69
- package/src/crypto-api/verification.ts +0 -408
- package/src/matrixrtc/CallMembership.ts +0 -247
- package/src/matrixrtc/LivekitFocus.ts +0 -39
- package/src/matrixrtc/MatrixRTCSession.ts +0 -1319
- package/src/matrixrtc/MatrixRTCSessionManager.ts +0 -166
- package/src/matrixrtc/focus.ts +0 -25
- package/src/matrixrtc/index.ts +0 -22
- package/src/matrixrtc/types.ts +0 -36
- package/src/rendezvous/MSC4108SignInWithQR.ts +0 -444
- package/src/rendezvous/RendezvousChannel.ts +0 -48
- package/src/rendezvous/RendezvousCode.ts +0 -25
- package/src/rendezvous/RendezvousError.ts +0 -26
- package/src/rendezvous/RendezvousFailureReason.ts +0 -49
- package/src/rendezvous/RendezvousIntent.ts +0 -20
- package/src/rendezvous/RendezvousTransport.ts +0 -58
- package/src/rendezvous/channels/MSC4108SecureChannel.ts +0 -270
- package/src/rendezvous/channels/index.ts +0 -17
- package/src/rendezvous/index.ts +0 -25
- package/src/rendezvous/transports/MSC4108RendezvousSession.ts +0 -270
- package/src/rendezvous/transports/index.ts +0 -17
- package/src/rust-crypto/CrossSigningIdentity.ts +0 -183
- package/src/rust-crypto/DehydratedDeviceManager.ts +0 -306
- package/src/rust-crypto/KeyClaimManager.ts +0 -86
- package/src/rust-crypto/OutgoingRequestProcessor.ts +0 -236
- package/src/rust-crypto/OutgoingRequestsManager.ts +0 -143
- package/src/rust-crypto/PerSessionKeyBackupDownloader.ts +0 -501
- package/src/rust-crypto/RoomEncryptor.ts +0 -352
- package/src/rust-crypto/backup.ts +0 -881
- package/src/rust-crypto/constants.ts +0 -18
- package/src/rust-crypto/device-converter.ts +0 -128
- package/src/rust-crypto/index.ts +0 -237
- package/src/rust-crypto/libolm_migration.ts +0 -530
- package/src/rust-crypto/rust-crypto.ts +0 -2205
- package/src/rust-crypto/secret-storage.ts +0 -60
- package/src/rust-crypto/verification.ts +0 -830
- package/src/secret-storage.ts +0 -693
- package/src/webrtc/audioContext.ts +0 -44
- package/src/webrtc/call.ts +0 -3074
- package/src/webrtc/callEventHandler.ts +0 -425
- package/src/webrtc/callEventTypes.ts +0 -93
- package/src/webrtc/callFeed.ts +0 -364
- package/src/webrtc/groupCall.ts +0 -1735
- package/src/webrtc/groupCallEventHandler.ts +0 -234
- package/src/webrtc/mediaHandler.ts +0 -484
- package/src/webrtc/stats/callFeedStatsReporter.ts +0 -94
- package/src/webrtc/stats/callStatsReportGatherer.ts +0 -219
- package/src/webrtc/stats/callStatsReportSummary.ts +0 -30
- package/src/webrtc/stats/connectionStats.ts +0 -47
- package/src/webrtc/stats/connectionStatsBuilder.ts +0 -28
- package/src/webrtc/stats/connectionStatsReportBuilder.ts +0 -140
- package/src/webrtc/stats/groupCallStats.ts +0 -93
- package/src/webrtc/stats/media/mediaSsrcHandler.ts +0 -57
- package/src/webrtc/stats/media/mediaTrackHandler.ts +0 -76
- package/src/webrtc/stats/media/mediaTrackStats.ts +0 -176
- package/src/webrtc/stats/media/mediaTrackStatsHandler.ts +0 -90
- package/src/webrtc/stats/statsReport.ts +0 -133
- package/src/webrtc/stats/statsReportEmitter.ts +0 -49
- package/src/webrtc/stats/summaryStatsReportGatherer.ts +0 -148
- package/src/webrtc/stats/trackStatsBuilder.ts +0 -207
- package/src/webrtc/stats/transportStats.ts +0 -26
- package/src/webrtc/stats/transportStatsBuilder.ts +0 -48
- package/src/webrtc/stats/valueFormatter.ts +0 -27
package/lib/client.js
CHANGED
@@ -27,40 +27,29 @@ limitations under the License.
|
|
27
27
|
import { SyncApi, SyncState } from "./sync.js";
|
28
28
|
import { EventStatus, MatrixEvent, MatrixEventEvent } from "./models/event.js";
|
29
29
|
import { StubStore } from "./store/stub.js";
|
30
|
-
import { createNewMatrixCall, supportsMatrixCall } from "./webrtc/call.js";
|
31
30
|
import { Filter } from "./filter.js";
|
32
|
-
import { CallEventHandler } from "./webrtc/callEventHandler.js";
|
33
|
-
import { GroupCallEventHandler } from "./webrtc/groupCallEventHandler.js";
|
34
31
|
import * as utils from "./utils.js";
|
35
|
-
import { noUnsafeEventProps, replaceParam,
|
32
|
+
import { noUnsafeEventProps, replaceParam, sleep } from "./utils.js";
|
36
33
|
import { Direction, EventTimeline } from "./models/event-timeline.js";
|
37
34
|
import { PushProcessor } from "./pushprocessor.js";
|
38
35
|
import { AutoDiscovery } from "./autodiscovery.js";
|
39
|
-
import
|
40
|
-
import { decodeBase64, encodeBase64, encodeUnpaddedBase64Url } from "./base64.js";
|
36
|
+
import { encodeUnpaddedBase64Url } from "./base64.js";
|
41
37
|
import { TypedReEmitter } from "./ReEmitter.js";
|
42
38
|
import { logger } from "./logger.js";
|
43
39
|
import { SERVICE_TYPES } from "./service-types.js";
|
44
40
|
import { ClientPrefix, IdentityPrefix, MatrixError, MatrixHttpApi, MediaPrefix, Method, retryNetworkOperation } from "./http-api/index.js";
|
45
|
-
import { Crypto, CryptoEvent as LegacyCryptoEvent, fixBackupKey } from "./crypto/index.js";
|
46
41
|
import { User, UserEvent } from "./models/user.js";
|
47
42
|
import { getHttpUriForMxc } from "./content-repo.js";
|
48
43
|
import { SearchResult } from "./models/search-result.js";
|
49
|
-
import { DEHYDRATION_ALGORITHM } from "./crypto/dehydration.js";
|
50
|
-
import { CrossSigningKey } from "./crypto/api.js";
|
51
44
|
import * as ContentHelpers from "./content-helpers.js";
|
52
45
|
import { NotificationCountType } from "./models/room.js";
|
53
|
-
import { RoomMemberEvent } from "./models/room-member.js";
|
54
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";
|
55
47
|
import { GuestAccess, HistoryVisibility, Preset } from "./@types/partials.js";
|
56
48
|
import { eventMapperFor } from "./event-mapper.js";
|
57
49
|
import { randomString } from "./randomstring.js";
|
58
|
-
import { BackupManager } from "./crypto/backup.js";
|
59
50
|
import { DEFAULT_TREE_POWER_LEVELS_TEMPLATE, MSC3089TreeSpace } from "./models/MSC3089TreeSpace.js";
|
60
51
|
import { SearchOrderBy } from "./@types/search.js";
|
61
52
|
import { PushRuleActionName, PushRuleKind } from "./@types/PushRules.js";
|
62
|
-
import { GroupCall } from "./webrtc/groupCall.js";
|
63
|
-
import { MediaHandler } from "./webrtc/mediaHandler.js";
|
64
53
|
import { TypedEventEmitter } from "./models/typed-event-emitter.js";
|
65
54
|
import { MAIN_ROOM_TIMELINE, ReceiptType } from "./@types/read_receipts.js";
|
66
55
|
import { SlidingSyncSdk } from "./sliding-sync-sdk.js";
|
@@ -70,18 +59,11 @@ import { NamespacedValue, UnstableValue } from "./NamespacedValue.js";
|
|
70
59
|
import { ToDeviceMessageQueue } from "./ToDeviceMessageQueue.js";
|
71
60
|
import { IgnoredInvites } from "./models/invites-ignorer.js";
|
72
61
|
import { buildFeatureSupportMap, Feature, ServerSupport } from "./feature.js";
|
73
|
-
import { RUST_SDK_STORE_PREFIX } from "./rust-crypto/constants.js";
|
74
|
-
import { decodeRecoveryKey, CryptoEvent } from "./crypto-api/index.js";
|
75
|
-
import { ServerSideSecretStorageImpl } from "./secret-storage.js";
|
76
|
-
import { MatrixRTCSessionManager } from "./matrixrtc/MatrixRTCSessionManager.js";
|
77
62
|
import { getRelationsThreadFilter } from "./thread-utils.js";
|
78
63
|
import { KnownMembership } from "./@types/membership.js";
|
79
64
|
import { ServerCapabilities } from "./serverCapabilities.js";
|
80
65
|
import { sha256 } from "./digest.js";
|
81
|
-
import { keyFromAuthData } from "./common-crypto/key-passphrase.js";
|
82
66
|
var SCROLLBACK_DELAY_MS = 3000;
|
83
|
-
var TURN_CHECK_INTERVAL = 10 * 60 * 1000; // poll for turn credentials every 10 minutes
|
84
|
-
|
85
67
|
export var UNSTABLE_MSC3852_LAST_SEEN_UA = new UnstableValue("last_seen_user_agent", "org.matrix.msc3852.last_seen_user_agent");
|
86
68
|
export var PendingEventOrdering = /*#__PURE__*/function (PendingEventOrdering) {
|
87
69
|
PendingEventOrdering["Chronological"] = "chronological";
|
@@ -94,16 +76,14 @@ export var UNSTABLE_MSC2666_MUTUAL_ROOMS = "uk.half-shot.msc2666.mutual_rooms";
|
|
94
76
|
export var UNSTABLE_MSC2666_QUERY_MUTUAL_ROOMS = "uk.half-shot.msc2666.query_mutual_rooms";
|
95
77
|
export var UNSTABLE_MSC4140_DELAYED_EVENTS = "org.matrix.msc4140";
|
96
78
|
export var UNSTABLE_MSC4133_EXTENDED_PROFILES = "uk.tcpip.msc4133";
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
CrossSigningKeyType["UserSigningKey"] = "user_signing_key";
|
101
|
-
return CrossSigningKeyType;
|
102
|
-
}(CrossSigningKeyType || {}); // Re-export for backwards compatibility
|
79
|
+
|
80
|
+
// Re-export for backwards compatibility
|
81
|
+
|
103
82
|
/**
|
104
83
|
* The summary of a room as defined by an initial version of MSC3266 and implemented in Synapse
|
105
84
|
* Proposed at https://github.com/matrix-org/matrix-doc/pull/3266
|
106
85
|
*/
|
86
|
+
|
107
87
|
/* eslint-enable camelcase */
|
108
88
|
|
109
89
|
// We're using this constant for methods overloading and inspect whether a variable
|
@@ -135,7 +115,7 @@ var SSO_ACTION_PARAM = new UnstableValue("action", "org.matrix.msc3824.action");
|
|
135
115
|
*/
|
136
116
|
export class MatrixClient extends TypedEventEmitter {
|
137
117
|
constructor(opts) {
|
138
|
-
var _opts$logger, _opts$usingExternalCr, _this
|
118
|
+
var _opts$logger, _opts$usingExternalCr, _this;
|
139
119
|
// If a custom logger is provided, use it. Otherwise, default to the global
|
140
120
|
// one in logger.ts.
|
141
121
|
super();
|
@@ -165,21 +145,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
165
145
|
_defineProperty(this, "identityServer", void 0);
|
166
146
|
_defineProperty(this, "http", void 0);
|
167
147
|
// XXX: Intended private, used in code.
|
168
|
-
/**
|
169
|
-
* The libolm crypto implementation, if it is in use.
|
170
|
-
*
|
171
|
-
* @deprecated This should not be used. Instead, use the methods exposed directly on this class or
|
172
|
-
* (where they are available) via {@link getCrypto}.
|
173
|
-
*/
|
174
|
-
_defineProperty(this, "crypto", void 0);
|
175
|
-
// XXX: Intended private, used in code. Being replaced by cryptoBackend
|
176
|
-
_defineProperty(this, "cryptoBackend", void 0);
|
177
|
-
// one of crypto or rustCrypto
|
178
|
-
_defineProperty(this, "cryptoCallbacks", void 0);
|
179
|
-
// XXX: Intended private, used in code.
|
180
|
-
_defineProperty(this, "callEventHandler", void 0);
|
181
|
-
// XXX: Intended private, used in code.
|
182
|
-
_defineProperty(this, "groupCallEventHandler", void 0);
|
183
148
|
_defineProperty(this, "supportsCallTransfer", false);
|
184
149
|
// XXX: Intended private, used in code.
|
185
150
|
_defineProperty(this, "forceTURN", false);
|
@@ -192,13 +157,11 @@ export class MatrixClient extends TypedEventEmitter {
|
|
192
157
|
_defineProperty(this, "useLivekitForGroupCalls", void 0);
|
193
158
|
// Note: these are all `protected` to let downstream consumers make mistakes if they want to.
|
194
159
|
// We don't technically support this usage, but have reasons to do this.
|
195
|
-
_defineProperty(this, "canSupportVoip", false);
|
196
160
|
_defineProperty(this, "peekSync", null);
|
197
161
|
_defineProperty(this, "isGuestAccount", false);
|
198
162
|
_defineProperty(this, "ongoingScrollbacks", {});
|
199
163
|
_defineProperty(this, "notifTimelineSet", null);
|
200
164
|
/* @deprecated */
|
201
|
-
_defineProperty(this, "cryptoStore", void 0);
|
202
165
|
_defineProperty(this, "verificationMethods", void 0);
|
203
166
|
_defineProperty(this, "fallbackICEServerAllowed", false);
|
204
167
|
_defineProperty(this, "syncApi", void 0);
|
@@ -217,12 +180,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
217
180
|
_defineProperty(this, "serverVersionsPromise", void 0);
|
218
181
|
_defineProperty(this, "clientWellKnown", void 0);
|
219
182
|
_defineProperty(this, "clientWellKnownPromise", void 0);
|
220
|
-
_defineProperty(this, "turnServers", []);
|
221
|
-
_defineProperty(this, "turnServersExpiry", 0);
|
222
|
-
_defineProperty(this, "checkTurnServersIntervalID", void 0);
|
223
|
-
_defineProperty(this, "exportedOlmDeviceToImport", void 0);
|
224
183
|
_defineProperty(this, "txnCtr", 0);
|
225
|
-
_defineProperty(this, "mediaHandler", new MediaHandler(this));
|
226
184
|
_defineProperty(this, "sessionId", void 0);
|
227
185
|
/** IDs of events which are currently being encrypted.
|
228
186
|
*
|
@@ -233,26 +191,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
233
191
|
_defineProperty(this, "useE2eForGroupCall", true);
|
234
192
|
_defineProperty(this, "toDeviceMessageQueue", void 0);
|
235
193
|
_defineProperty(this, "livekitServiceURL", void 0);
|
236
|
-
_defineProperty(this, "_secretStorage", void 0);
|
237
194
|
// A manager for determining which invites should be ignored.
|
238
195
|
_defineProperty(this, "ignoredInvites", void 0);
|
239
|
-
_defineProperty(this, "matrixRTC", void 0);
|
240
196
|
_defineProperty(this, "serverCapabilitiesService", void 0);
|
241
|
-
_defineProperty(this, "startCallEventHandler", () => {
|
242
|
-
if (this.isInitialSyncComplete()) {
|
243
|
-
if (supportsMatrixCall()) {
|
244
|
-
this.callEventHandler.start();
|
245
|
-
this.groupCallEventHandler.start();
|
246
|
-
}
|
247
|
-
this.off(ClientEvent.Sync, this.startCallEventHandler);
|
248
|
-
}
|
249
|
-
});
|
250
|
-
_defineProperty(this, "startMatrixRTC", () => {
|
251
|
-
if (this.isInitialSyncComplete()) {
|
252
|
-
this.matrixRTC.start();
|
253
|
-
this.off(ClientEvent.Sync, this.startMatrixRTC);
|
254
|
-
}
|
255
|
-
});
|
256
197
|
/**
|
257
198
|
* Once the client has been initialised, we want to clear notifications we
|
258
199
|
* know for a fact should be here.
|
@@ -314,8 +255,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
314
255
|
} else {
|
315
256
|
this.deviceId = opts.deviceToImport.deviceId;
|
316
257
|
this.credentials.userId = opts.deviceToImport.userId;
|
317
|
-
// will be used during async initialization of the crypto
|
318
|
-
this.exportedOlmDeviceToImport = opts.deviceToImport.olmDevice;
|
319
258
|
}
|
320
259
|
} else if (opts.pickleKey) {
|
321
260
|
this.pickleKey = opts.pickleKey;
|
@@ -342,25 +281,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
342
281
|
};
|
343
282
|
}());
|
344
283
|
}
|
345
|
-
if (supportsMatrixCall()) {
|
346
|
-
this.callEventHandler = new CallEventHandler(this);
|
347
|
-
this.groupCallEventHandler = new GroupCallEventHandler(this);
|
348
|
-
this.canSupportVoip = true;
|
349
|
-
// Start listening for calls after the initial sync is done
|
350
|
-
// We do not need to backfill the call event buffer
|
351
|
-
// with encrypted events that might never get decrypted
|
352
|
-
this.on(ClientEvent.Sync, this.startCallEventHandler);
|
353
|
-
}
|
354
|
-
|
355
|
-
// NB. We initialise MatrixRTC whether we have call support or not: this is just
|
356
|
-
// the underlying session management and doesn't use any actual media capabilities
|
357
|
-
this.matrixRTC = new MatrixRTCSessionManager(this);
|
358
284
|
this.serverCapabilitiesService = new ServerCapabilities(this.http);
|
359
285
|
this.on(ClientEvent.Sync, this.fixupRoomNotifications);
|
360
286
|
this.timelineSupport = Boolean(opts.timelineSupport);
|
361
|
-
this.cryptoStore = opts.cryptoStore;
|
362
287
|
this.verificationMethods = opts.verificationMethods;
|
363
|
-
this.cryptoCallbacks = opts.cryptoCallbacks || {};
|
364
288
|
this.forceTURN = opts.forceTURN || false;
|
365
289
|
this.iceCandidatePoolSize = opts.iceCandidatePoolSize === undefined ? 0 : opts.iceCandidatePoolSize;
|
366
290
|
this.supportsCallTransfer = opts.supportsCallTransfer || false;
|
@@ -379,7 +303,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
379
303
|
fixNotificationCountOnDecryption(this, event);
|
380
304
|
});
|
381
305
|
this.ignoredInvites = new IgnoredInvites(this);
|
382
|
-
this._secretStorage = new ServerSideSecretStorageImpl(this, (_opts$cryptoCallbacks = opts.cryptoCallbacks) !== null && _opts$cryptoCallbacks !== void 0 ? _opts$cryptoCallbacks : {});
|
383
306
|
|
384
307
|
// having lots of event listeners is not unusual. 0 means "unlimited".
|
385
308
|
this.setMaxListeners(0);
|
@@ -407,7 +330,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
407
330
|
return;
|
408
331
|
}
|
409
332
|
_this2.clientRunning = true;
|
410
|
-
_this2.on(ClientEvent.Sync, _this2.startMatrixRTC);
|
411
333
|
|
412
334
|
// Create our own user object artificially (instead of waiting for sync)
|
413
335
|
// so it's always available, even if the user is not in any rooms etc.
|
@@ -415,15 +337,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
415
337
|
if (userId) {
|
416
338
|
_this2.store.storeUser(new User(userId));
|
417
339
|
}
|
418
|
-
|
419
|
-
// periodically poll for turn servers if we support voip
|
420
|
-
if (_this2.canSupportVoip) {
|
421
|
-
_this2.checkTurnServersIntervalID = setInterval(() => {
|
422
|
-
_this2.checkTurnServers();
|
423
|
-
}, TURN_CHECK_INTERVAL);
|
424
|
-
// noinspection ES6MissingAwait
|
425
|
-
_this2.checkTurnServers();
|
426
|
-
}
|
427
340
|
if (_this2.syncApi) {
|
428
341
|
// This shouldn't happen since we thought the client was not running
|
429
342
|
_this2.logger.error("Still have sync object whilst not running: stopping old one");
|
@@ -447,7 +360,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
447
360
|
}
|
448
361
|
_this2.clientOpts = opts !== null && opts !== void 0 ? opts : {};
|
449
362
|
if (_this2.clientOpts.slidingSync) {
|
450
|
-
_this2.syncApi = new SlidingSyncSdk(_this2.clientOpts.slidingSync, _this2, _this2.clientOpts
|
363
|
+
_this2.syncApi = new SlidingSyncSdk(_this2.clientOpts.slidingSync, _this2, _this2.clientOpts);
|
451
364
|
} else {
|
452
365
|
_this2.syncApi = new SyncApi(_this2, _this2.clientOpts, _this2.buildSyncApiOptions());
|
453
366
|
}
|
@@ -468,8 +381,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
468
381
|
*/
|
469
382
|
buildSyncApiOptions() {
|
470
383
|
return {
|
471
|
-
crypto: this.crypto,
|
472
|
-
cryptoCallbacks: this.cryptoBackend,
|
473
384
|
canResetEntireTimeline: roomId => {
|
474
385
|
if (!this.canResetTimelineCallback) {
|
475
386
|
return false;
|
@@ -484,10 +395,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
484
395
|
* clean shutdown.
|
485
396
|
*/
|
486
397
|
stopClient() {
|
487
|
-
var _this$
|
488
|
-
(_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
|
489
|
-
|
490
|
-
this.off(ClientEvent.Sync, this.startMatrixRTC);
|
398
|
+
var _this$syncApi, _this$peekSync;
|
491
399
|
if (!this.clientRunning) return; // already stopped
|
492
400
|
|
493
401
|
this.logger.debug("stopping MatrixClient");
|
@@ -495,233 +403,24 @@ export class MatrixClient extends TypedEventEmitter {
|
|
495
403
|
(_this$syncApi = this.syncApi) === null || _this$syncApi === void 0 || _this$syncApi.stop();
|
496
404
|
this.syncApi = undefined;
|
497
405
|
(_this$peekSync = this.peekSync) === null || _this$peekSync === void 0 || _this$peekSync.stopPeeking();
|
498
|
-
(_this$callEventHandle = this.callEventHandler) === null || _this$callEventHandle === void 0 || _this$callEventHandle.stop();
|
499
|
-
(_this$groupCallEventH = this.groupCallEventHandler) === null || _this$groupCallEventH === void 0 || _this$groupCallEventH.stop();
|
500
|
-
this.callEventHandler = undefined;
|
501
|
-
this.groupCallEventHandler = undefined;
|
502
|
-
globalThis.clearInterval(this.checkTurnServersIntervalID);
|
503
|
-
this.checkTurnServersIntervalID = undefined;
|
504
406
|
if (this.clientWellKnownIntervalID !== undefined) {
|
505
407
|
globalThis.clearInterval(this.clientWellKnownIntervalID);
|
506
408
|
}
|
507
409
|
this.toDeviceMessageQueue.stop();
|
508
|
-
this.matrixRTC.stop();
|
509
410
|
this.serverCapabilitiesService.stop();
|
510
411
|
}
|
511
412
|
|
512
|
-
/**
|
513
|
-
* Try to rehydrate a device if available. The client must have been
|
514
|
-
* initialized with a `cryptoCallback.getDehydrationKey` option, and this
|
515
|
-
* function must be called before initCrypto and startClient are called.
|
516
|
-
*
|
517
|
-
* @returns Promise which resolves to undefined if a device could not be dehydrated, or
|
518
|
-
* to the new device ID if the dehydration was successful.
|
519
|
-
* @returns Rejects: with an error response.
|
520
|
-
*
|
521
|
-
* @deprecated MSC2697 device dehydration is not supported for rust cryptography.
|
522
|
-
*/
|
523
|
-
rehydrateDevice() {
|
524
|
-
var _this3 = this;
|
525
|
-
return _asyncToGenerator(function* () {
|
526
|
-
if (_this3.crypto) {
|
527
|
-
throw new Error("Cannot rehydrate device after crypto is initialized");
|
528
|
-
}
|
529
|
-
if (!_this3.cryptoCallbacks.getDehydrationKey) {
|
530
|
-
return;
|
531
|
-
}
|
532
|
-
var getDeviceResult = yield _this3.getDehydratedDevice();
|
533
|
-
if (!getDeviceResult) {
|
534
|
-
return;
|
535
|
-
}
|
536
|
-
if (!getDeviceResult.device_data || !getDeviceResult.device_id) {
|
537
|
-
_this3.logger.info("no dehydrated device found");
|
538
|
-
return;
|
539
|
-
}
|
540
|
-
var account = new globalThis.Olm.Account();
|
541
|
-
try {
|
542
|
-
var deviceData = getDeviceResult.device_data;
|
543
|
-
if (deviceData.algorithm !== DEHYDRATION_ALGORITHM) {
|
544
|
-
_this3.logger.warn("Wrong algorithm for dehydrated device");
|
545
|
-
return;
|
546
|
-
}
|
547
|
-
_this3.logger.debug("unpickling dehydrated device");
|
548
|
-
var _key = yield _this3.cryptoCallbacks.getDehydrationKey(deviceData, k => {
|
549
|
-
// copy the key so that it doesn't get clobbered
|
550
|
-
account.unpickle(new Uint8Array(k), deviceData.account);
|
551
|
-
});
|
552
|
-
account.unpickle(_key, deviceData.account);
|
553
|
-
_this3.logger.debug("unpickled device");
|
554
|
-
var rehydrateResult = yield _this3.http.authedRequest(Method.Post, "/dehydrated_device/claim", undefined, {
|
555
|
-
device_id: getDeviceResult.device_id
|
556
|
-
}, {
|
557
|
-
prefix: "/_matrix/client/unstable/org.matrix.msc2697.v2"
|
558
|
-
});
|
559
|
-
if (rehydrateResult.success) {
|
560
|
-
_this3.deviceId = getDeviceResult.device_id;
|
561
|
-
_this3.logger.info("using dehydrated device");
|
562
|
-
var pickleKey = _this3.pickleKey || "DEFAULT_KEY";
|
563
|
-
_this3.exportedOlmDeviceToImport = {
|
564
|
-
pickledAccount: account.pickle(pickleKey),
|
565
|
-
sessions: [],
|
566
|
-
pickleKey: pickleKey
|
567
|
-
};
|
568
|
-
account.free();
|
569
|
-
return _this3.deviceId;
|
570
|
-
} else {
|
571
|
-
account.free();
|
572
|
-
_this3.logger.info("not using dehydrated device");
|
573
|
-
return;
|
574
|
-
}
|
575
|
-
} catch (e) {
|
576
|
-
account.free();
|
577
|
-
_this3.logger.warn("could not unpickle", e);
|
578
|
-
}
|
579
|
-
})();
|
580
|
-
}
|
581
|
-
|
582
|
-
/**
|
583
|
-
* Get the current dehydrated device, if any
|
584
|
-
* @returns A promise of an object containing the dehydrated device
|
585
|
-
*
|
586
|
-
* @deprecated MSC2697 device dehydration is not supported for rust cryptography.
|
587
|
-
*/
|
588
|
-
getDehydratedDevice() {
|
589
|
-
var _this4 = this;
|
590
|
-
return _asyncToGenerator(function* () {
|
591
|
-
try {
|
592
|
-
return yield _this4.http.authedRequest(Method.Get, "/dehydrated_device", undefined, undefined, {
|
593
|
-
prefix: "/_matrix/client/unstable/org.matrix.msc2697.v2"
|
594
|
-
});
|
595
|
-
} catch (e) {
|
596
|
-
_this4.logger.info("could not get dehydrated device", e);
|
597
|
-
return;
|
598
|
-
}
|
599
|
-
})();
|
600
|
-
}
|
601
|
-
|
602
|
-
/**
|
603
|
-
* Set the dehydration key. This will also periodically dehydrate devices to
|
604
|
-
* the server.
|
605
|
-
*
|
606
|
-
* @param key - the dehydration key
|
607
|
-
* @param keyInfo - Information about the key. Primarily for
|
608
|
-
* information about how to generate the key from a passphrase.
|
609
|
-
* @param deviceDisplayName - The device display name for the
|
610
|
-
* dehydrated device.
|
611
|
-
* @returns A promise that resolves when the dehydrated device is stored.
|
612
|
-
*
|
613
|
-
* @deprecated Not supported for Rust Cryptography.
|
614
|
-
*/
|
615
|
-
setDehydrationKey(key, keyInfo, deviceDisplayName) {
|
616
|
-
var _this5 = this;
|
617
|
-
return _asyncToGenerator(function* () {
|
618
|
-
if (!_this5.crypto) {
|
619
|
-
_this5.logger.warn("not dehydrating device if crypto is not enabled");
|
620
|
-
return;
|
621
|
-
}
|
622
|
-
return _this5.crypto.dehydrationManager.setKeyAndQueueDehydration(key, keyInfo, deviceDisplayName);
|
623
|
-
})();
|
624
|
-
}
|
625
|
-
|
626
|
-
/**
|
627
|
-
* Creates a new MSC2967 dehydrated device (without queuing periodic dehydration)
|
628
|
-
* @param key - the dehydration key
|
629
|
-
* @param keyInfo - Information about the key. Primarily for
|
630
|
-
* information about how to generate the key from a passphrase.
|
631
|
-
* @param deviceDisplayName - The device display name for the
|
632
|
-
* dehydrated device.
|
633
|
-
* @returns the device id of the newly created dehydrated device
|
634
|
-
*
|
635
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.startDehydration}.
|
636
|
-
*/
|
637
|
-
createDehydratedDevice(key, keyInfo, deviceDisplayName) {
|
638
|
-
var _this6 = this;
|
639
|
-
return _asyncToGenerator(function* () {
|
640
|
-
if (!_this6.crypto) {
|
641
|
-
_this6.logger.warn("not dehydrating device if crypto is not enabled");
|
642
|
-
return;
|
643
|
-
}
|
644
|
-
yield _this6.crypto.dehydrationManager.setKey(key, keyInfo, deviceDisplayName);
|
645
|
-
return _this6.crypto.dehydrationManager.dehydrateDevice();
|
646
|
-
})();
|
647
|
-
}
|
648
|
-
|
649
|
-
/** @deprecated Not supported for Rust Cryptography. */
|
650
|
-
exportDevice() {
|
651
|
-
var _this7 = this;
|
652
|
-
return _asyncToGenerator(function* () {
|
653
|
-
if (!_this7.crypto) {
|
654
|
-
_this7.logger.warn("not exporting device if crypto is not enabled");
|
655
|
-
return;
|
656
|
-
}
|
657
|
-
return {
|
658
|
-
userId: _this7.credentials.userId,
|
659
|
-
deviceId: _this7.deviceId,
|
660
|
-
// XXX: Private member access.
|
661
|
-
olmDevice: yield _this7.crypto.olmDevice.export()
|
662
|
-
};
|
663
|
-
})();
|
664
|
-
}
|
665
|
-
|
666
413
|
/**
|
667
414
|
* Clear any data out of the persistent stores used by the client.
|
668
415
|
*
|
669
416
|
* @returns Promise which resolves when the stores have been cleared.
|
670
417
|
*/
|
671
418
|
clearStores() {
|
672
|
-
var _this8 = this;
|
673
419
|
if (this.clientRunning) {
|
674
420
|
throw new Error("Cannot clear stores while client is running");
|
675
421
|
}
|
676
422
|
var promises = [];
|
677
423
|
promises.push(this.store.deleteAllData());
|
678
|
-
if (this.cryptoStore) {
|
679
|
-
promises.push(this.cryptoStore.deleteAllData());
|
680
|
-
}
|
681
|
-
|
682
|
-
// delete the stores used by the rust matrix-sdk-crypto, in case they were used
|
683
|
-
var deleteRustSdkStore = /*#__PURE__*/function () {
|
684
|
-
var _ref2 = _asyncToGenerator(function* () {
|
685
|
-
var indexedDB;
|
686
|
-
try {
|
687
|
-
indexedDB = globalThis.indexedDB;
|
688
|
-
if (!indexedDB) return; // No indexedDB support
|
689
|
-
} catch (_unused) {
|
690
|
-
// No indexedDB support
|
691
|
-
return;
|
692
|
-
}
|
693
|
-
var _loop = function* _loop(dbname) {
|
694
|
-
var prom = new Promise((resolve, reject) => {
|
695
|
-
_this8.logger.info("Removing IndexedDB instance ".concat(dbname));
|
696
|
-
var req = indexedDB.deleteDatabase(dbname);
|
697
|
-
req.onsuccess = _ => {
|
698
|
-
_this8.logger.info("Removed IndexedDB instance ".concat(dbname));
|
699
|
-
resolve(0);
|
700
|
-
};
|
701
|
-
req.onerror = e => {
|
702
|
-
// In private browsing, Firefox has a globalThis.indexedDB, but attempts to delete an indexeddb
|
703
|
-
// (even a non-existent one) fail with "DOMException: A mutation operation was attempted on a
|
704
|
-
// database that did not allow mutations."
|
705
|
-
//
|
706
|
-
// it seems like the only thing we can really do is ignore the error.
|
707
|
-
_this8.logger.warn("Failed to remove IndexedDB instance ".concat(dbname, ":"), e);
|
708
|
-
resolve(0);
|
709
|
-
};
|
710
|
-
req.onblocked = e => {
|
711
|
-
_this8.logger.info("cannot yet remove IndexedDB instance ".concat(dbname));
|
712
|
-
};
|
713
|
-
});
|
714
|
-
yield prom;
|
715
|
-
};
|
716
|
-
for (var dbname of ["".concat(RUST_SDK_STORE_PREFIX, "::matrix-sdk-crypto"), "".concat(RUST_SDK_STORE_PREFIX, "::matrix-sdk-crypto-meta")]) {
|
717
|
-
yield* _loop(dbname);
|
718
|
-
}
|
719
|
-
});
|
720
|
-
return function deleteRustSdkStore() {
|
721
|
-
return _ref2.apply(this, arguments);
|
722
|
-
};
|
723
|
-
}();
|
724
|
-
promises.push(deleteRustSdkStore());
|
725
424
|
return Promise.all(promises).then(); // .then to fix types
|
726
425
|
}
|
727
426
|
|
@@ -789,21 +488,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
789
488
|
return this.sessionId;
|
790
489
|
}
|
791
490
|
|
792
|
-
/**
|
793
|
-
* Check if the runtime environment supports VoIP calling.
|
794
|
-
* @returns True if VoIP is supported.
|
795
|
-
*/
|
796
|
-
supportsVoip() {
|
797
|
-
return this.canSupportVoip;
|
798
|
-
}
|
799
|
-
|
800
|
-
/**
|
801
|
-
* @returns
|
802
|
-
*/
|
803
|
-
getMediaHandler() {
|
804
|
-
return this.mediaHandler;
|
805
|
-
}
|
806
|
-
|
807
491
|
/**
|
808
492
|
* Set whether VoIP calls are forced to use only TURN
|
809
493
|
* candidates. This is the same as the forceTURN option
|
@@ -830,40 +514,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
830
514
|
getUseE2eForGroupCall() {
|
831
515
|
return this.useE2eForGroupCall;
|
832
516
|
}
|
833
|
-
|
834
|
-
/**
|
835
|
-
* Creates a new call.
|
836
|
-
* The place*Call methods on the returned call can be used to actually place a call
|
837
|
-
*
|
838
|
-
* @param roomId - The room the call is to be placed in.
|
839
|
-
* @returns the call or null if the browser doesn't support calling.
|
840
|
-
*/
|
841
|
-
createCall(roomId) {
|
842
|
-
return createNewMatrixCall(this, roomId);
|
843
|
-
}
|
844
|
-
|
845
|
-
/**
|
846
|
-
* Creates a new group call and sends the associated state event
|
847
|
-
* to alert other members that the room now has a group call.
|
848
|
-
*
|
849
|
-
* @param roomId - The room the call is to be placed in.
|
850
|
-
*/
|
851
|
-
createGroupCall(roomId, type, isPtt, intent, dataChannelsEnabled, dataChannelOptions) {
|
852
|
-
var _this9 = this;
|
853
|
-
return _asyncToGenerator(function* () {
|
854
|
-
if (_this9.getGroupCallForRoom(roomId)) {
|
855
|
-
throw new Error("".concat(roomId, " already has an existing group call"));
|
856
|
-
}
|
857
|
-
var room = _this9.getRoom(roomId);
|
858
|
-
if (!room) {
|
859
|
-
throw new Error("Cannot find room ".concat(roomId));
|
860
|
-
}
|
861
|
-
|
862
|
-
// Because without Media section a WebRTC connection is not possible, so need a RTCDataChannel to set up a
|
863
|
-
// no media WebRTC connection anyway.
|
864
|
-
return new GroupCall(_this9, room, type, isPtt, intent, undefined, dataChannelsEnabled || _this9.isVoipWithNoMediaAllowed, dataChannelOptions, _this9.isVoipWithNoMediaAllowed, _this9.useLivekitForGroupCalls, _this9.livekitServiceURL).create();
|
865
|
-
})();
|
866
|
-
}
|
867
517
|
getLivekitServiceURL() {
|
868
518
|
return this.livekitServiceURL;
|
869
519
|
}
|
@@ -874,29 +524,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
874
524
|
this.livekitServiceURL = newURL;
|
875
525
|
}
|
876
526
|
|
877
|
-
/**
|
878
|
-
* Wait until an initial state for the given room has been processed by the
|
879
|
-
* client and the client is aware of any ongoing group calls. Awaiting on
|
880
|
-
* the promise returned by this method before calling getGroupCallForRoom()
|
881
|
-
* avoids races where getGroupCallForRoom is called before the state for that
|
882
|
-
* room has been processed. It does not, however, fix other races, eg. two
|
883
|
-
* clients both creating a group call at the same time.
|
884
|
-
* @param roomId - The room ID to wait for
|
885
|
-
* @returns A promise that resolves once existing group calls in the room
|
886
|
-
* have been processed.
|
887
|
-
*/
|
888
|
-
waitUntilRoomReadyForGroupCalls(roomId) {
|
889
|
-
return this.groupCallEventHandler.waitUntilRoomReadyForGroupCalls(roomId);
|
890
|
-
}
|
891
|
-
|
892
|
-
/**
|
893
|
-
* Get an existing group call for the provided room.
|
894
|
-
* @returns The group call or null if it doesn't already exist.
|
895
|
-
*/
|
896
|
-
getGroupCallForRoom(roomId) {
|
897
|
-
return this.groupCallEventHandler.groupCalls.get(roomId) || null;
|
898
|
-
}
|
899
|
-
|
900
527
|
/**
|
901
528
|
* Get the current sync state.
|
902
529
|
* @returns the sync state, which may be null.
|
@@ -977,1894 +604,63 @@ export class MatrixClient extends TypedEventEmitter {
|
|
977
604
|
|
978
605
|
/**
|
979
606
|
* Return the global notification EventTimelineSet, if any
|
980
|
-
*
|
981
|
-
* @returns the globl notification EventTimelineSet
|
982
|
-
*/
|
983
|
-
getNotifTimelineSet() {
|
984
|
-
return this.notifTimelineSet;
|
985
|
-
}
|
986
|
-
|
987
|
-
/**
|
988
|
-
* Set the global notification EventTimelineSet
|
989
|
-
*
|
990
|
-
*/
|
991
|
-
setNotifTimelineSet(set) {
|
992
|
-
this.notifTimelineSet = set;
|
993
|
-
}
|
994
|
-
|
995
|
-
/**
|
996
|
-
* Gets the cached capabilities of the homeserver, returning cached ones if available.
|
997
|
-
* If there are no cached capabilities and none can be fetched, throw an exception.
|
998
|
-
*
|
999
|
-
* @returns Promise resolving with The capabilities of the homeserver
|
1000
|
-
*/
|
1001
|
-
getCapabilities() {
|
1002
|
-
var _this10 = this;
|
1003
|
-
return _asyncToGenerator(function* () {
|
1004
|
-
var caps = _this10.serverCapabilitiesService.getCachedCapabilities();
|
1005
|
-
if (caps) return caps;
|
1006
|
-
return _this10.serverCapabilitiesService.fetchCapabilities();
|
1007
|
-
})();
|
1008
|
-
}
|
1009
|
-
|
1010
|
-
/**
|
1011
|
-
* Gets the cached capabilities of the homeserver. If none have been fetched yet,
|
1012
|
-
* return undefined.
|
1013
|
-
*
|
1014
|
-
* @returns The capabilities of the homeserver
|
1015
|
-
*/
|
1016
|
-
getCachedCapabilities() {
|
1017
|
-
return this.serverCapabilitiesService.getCachedCapabilities();
|
1018
|
-
}
|
1019
|
-
|
1020
|
-
/**
|
1021
|
-
* Fetches the latest capabilities from the homeserver, ignoring any cached
|
1022
|
-
* versions. The newly returned version is cached.
|
1023
|
-
*
|
1024
|
-
* @returns A promise which resolves to the capabilities of the homeserver
|
1025
|
-
*/
|
1026
|
-
fetchCapabilities() {
|
1027
|
-
return this.serverCapabilitiesService.fetchCapabilities();
|
1028
|
-
}
|
1029
|
-
|
1030
|
-
/**
|
1031
|
-
* Initialise support for end-to-end encryption in this client, using libolm.
|
1032
|
-
*
|
1033
|
-
* You should call this method after creating the matrixclient, but *before*
|
1034
|
-
* calling `startClient`, if you want to support end-to-end encryption.
|
1035
|
-
*
|
1036
|
-
* It will return a Promise which will resolve when the crypto layer has been
|
1037
|
-
* successfully initialised.
|
1038
|
-
*
|
1039
|
-
* @deprecated libolm is deprecated. Prefer {@link initRustCrypto}.
|
1040
|
-
*/
|
1041
|
-
initCrypto() {
|
1042
|
-
var _this11 = this;
|
1043
|
-
return _asyncToGenerator(function* () {
|
1044
|
-
if (_this11.cryptoBackend) {
|
1045
|
-
_this11.logger.warn("Attempt to re-initialise e2e encryption on MatrixClient");
|
1046
|
-
return;
|
1047
|
-
}
|
1048
|
-
if (!_this11.cryptoStore) {
|
1049
|
-
// the cryptostore is provided by sdk.createClient, so this shouldn't happen
|
1050
|
-
throw new Error("Cannot enable encryption: no cryptoStore provided");
|
1051
|
-
}
|
1052
|
-
_this11.logger.debug("Crypto: Starting up crypto store...");
|
1053
|
-
yield _this11.cryptoStore.startup();
|
1054
|
-
var userId = _this11.getUserId();
|
1055
|
-
if (userId === null) {
|
1056
|
-
throw new Error("Cannot enable encryption on MatrixClient with unknown userId: " + "ensure userId is passed in createClient().");
|
1057
|
-
}
|
1058
|
-
if (_this11.deviceId === null) {
|
1059
|
-
throw new Error("Cannot enable encryption on MatrixClient with unknown deviceId: " + "ensure deviceId is passed in createClient().");
|
1060
|
-
}
|
1061
|
-
var crypto = new Crypto(_this11, userId, _this11.deviceId, _this11.store, _this11.cryptoStore, _this11.verificationMethods);
|
1062
|
-
_this11.reEmitter.reEmit(crypto, [LegacyCryptoEvent.KeyBackupFailed, LegacyCryptoEvent.KeyBackupSessionsRemaining, LegacyCryptoEvent.RoomKeyRequest, LegacyCryptoEvent.RoomKeyRequestCancellation, LegacyCryptoEvent.Warning, LegacyCryptoEvent.DevicesUpdated, LegacyCryptoEvent.WillUpdateDevices, LegacyCryptoEvent.DeviceVerificationChanged, LegacyCryptoEvent.UserTrustStatusChanged, LegacyCryptoEvent.KeysChanged]);
|
1063
|
-
_this11.logger.debug("Crypto: initialising crypto object...");
|
1064
|
-
yield crypto.init({
|
1065
|
-
exportedOlmDevice: _this11.exportedOlmDeviceToImport,
|
1066
|
-
pickleKey: _this11.pickleKey
|
1067
|
-
});
|
1068
|
-
delete _this11.exportedOlmDeviceToImport;
|
1069
|
-
_this11.olmVersion = Crypto.getOlmVersion();
|
1070
|
-
|
1071
|
-
// if crypto initialisation was successful, tell it to attach its event handlers.
|
1072
|
-
crypto.registerEventHandlers(_this11);
|
1073
|
-
_this11.cryptoBackend = _this11.crypto = crypto;
|
1074
|
-
|
1075
|
-
// upload our keys in the background
|
1076
|
-
_this11.crypto.uploadDeviceKeys().catch(e => {
|
1077
|
-
// TODO: throwing away this error is a really bad idea.
|
1078
|
-
_this11.logger.error("Error uploading device keys", e);
|
1079
|
-
});
|
1080
|
-
})();
|
1081
|
-
}
|
1082
|
-
|
1083
|
-
/**
|
1084
|
-
* Initialise support for end-to-end encryption in this client, using the rust matrix-sdk-crypto.
|
1085
|
-
*
|
1086
|
-
* An alternative to {@link initCrypto}.
|
1087
|
-
*
|
1088
|
-
* @param args.useIndexedDB - True to use an indexeddb store, false to use an in-memory store. Defaults to 'true'.
|
1089
|
-
* @param args.storageKey - A key with which to encrypt the indexeddb store. If provided, it must be exactly
|
1090
|
-
* 32 bytes of data, and must be the same each time the client is initialised for a given device.
|
1091
|
-
* If both this and `storagePassword` are unspecified, the store will be unencrypted.
|
1092
|
-
* @param args.storagePassword - An alternative to `storageKey`. A password which will be used to derive a key to
|
1093
|
-
* encrypt the store with. Deriving a key from a password is (deliberately) a slow operation, so prefer
|
1094
|
-
* to pass a `storageKey` directly where possible.
|
1095
|
-
*
|
1096
|
-
* @returns a Promise which will resolve when the crypto layer has been
|
1097
|
-
* successfully initialised.
|
1098
|
-
*/
|
1099
|
-
initRustCrypto() {
|
1100
|
-
var _arguments = arguments,
|
1101
|
-
_this12 = this;
|
1102
|
-
return _asyncToGenerator(function* () {
|
1103
|
-
var _this12$pickleKey;
|
1104
|
-
var args = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : {};
|
1105
|
-
if (_this12.cryptoBackend) {
|
1106
|
-
_this12.logger.warn("Attempt to re-initialise e2e encryption on MatrixClient");
|
1107
|
-
return;
|
1108
|
-
}
|
1109
|
-
var userId = _this12.getUserId();
|
1110
|
-
if (userId === null) {
|
1111
|
-
throw new Error("Cannot enable encryption on MatrixClient with unknown userId: " + "ensure userId is passed in createClient().");
|
1112
|
-
}
|
1113
|
-
var deviceId = _this12.getDeviceId();
|
1114
|
-
if (deviceId === null) {
|
1115
|
-
throw new Error("Cannot enable encryption on MatrixClient with unknown deviceId: " + "ensure deviceId is passed in createClient().");
|
1116
|
-
}
|
1117
|
-
|
1118
|
-
// importing rust-crypto will download the webassembly, so we delay it until we know it will be
|
1119
|
-
// needed.
|
1120
|
-
_this12.logger.debug("Downloading Rust crypto library");
|
1121
|
-
var RustCrypto = yield import("./rust-crypto/index.js");
|
1122
|
-
var rustCrypto = yield RustCrypto.initRustCrypto({
|
1123
|
-
logger: _this12.logger,
|
1124
|
-
http: _this12.http,
|
1125
|
-
userId: userId,
|
1126
|
-
deviceId: deviceId,
|
1127
|
-
secretStorage: _this12.secretStorage,
|
1128
|
-
cryptoCallbacks: _this12.cryptoCallbacks,
|
1129
|
-
storePrefix: args.useIndexedDB === false ? null : RUST_SDK_STORE_PREFIX,
|
1130
|
-
storeKey: args.storageKey,
|
1131
|
-
storePassphrase: args.storagePassword,
|
1132
|
-
legacyCryptoStore: _this12.cryptoStore,
|
1133
|
-
legacyPickleKey: (_this12$pickleKey = _this12.pickleKey) !== null && _this12$pickleKey !== void 0 ? _this12$pickleKey : "DEFAULT_KEY",
|
1134
|
-
legacyMigrationProgressListener: (progress, total) => {
|
1135
|
-
_this12.emit(CryptoEvent.LegacyCryptoStoreMigrationProgress, progress, total);
|
1136
|
-
}
|
1137
|
-
});
|
1138
|
-
rustCrypto.setSupportedVerificationMethods(_this12.verificationMethods);
|
1139
|
-
_this12.cryptoBackend = rustCrypto;
|
1140
|
-
|
1141
|
-
// attach the event listeners needed by RustCrypto
|
1142
|
-
_this12.on(RoomMemberEvent.Membership, rustCrypto.onRoomMembership.bind(rustCrypto));
|
1143
|
-
_this12.on(ClientEvent.Event, event => {
|
1144
|
-
rustCrypto.onLiveEventFromSync(event);
|
1145
|
-
});
|
1146
|
-
|
1147
|
-
// re-emit the events emitted by the crypto impl
|
1148
|
-
_this12.reEmitter.reEmit(rustCrypto, [CryptoEvent.VerificationRequestReceived, CryptoEvent.UserTrustStatusChanged, CryptoEvent.KeyBackupStatus, CryptoEvent.KeyBackupSessionsRemaining, CryptoEvent.KeyBackupFailed, CryptoEvent.KeyBackupDecryptionKeyCached, CryptoEvent.KeysChanged, CryptoEvent.DevicesUpdated, CryptoEvent.WillUpdateDevices]);
|
1149
|
-
})();
|
1150
|
-
}
|
1151
|
-
|
1152
|
-
/**
|
1153
|
-
* Access the server-side secret storage API for this client.
|
1154
|
-
*/
|
1155
|
-
get secretStorage() {
|
1156
|
-
return this._secretStorage;
|
1157
|
-
}
|
1158
|
-
|
1159
|
-
/**
|
1160
|
-
* Access the crypto API for this client.
|
1161
|
-
*
|
1162
|
-
* If end-to-end encryption has been enabled for this client (via {@link initCrypto} or {@link initRustCrypto}),
|
1163
|
-
* returns an object giving access to the crypto API. Otherwise, returns `undefined`.
|
1164
|
-
*/
|
1165
|
-
getCrypto() {
|
1166
|
-
return this.cryptoBackend;
|
1167
|
-
}
|
1168
|
-
|
1169
|
-
/**
|
1170
|
-
* Is end-to-end crypto enabled for this client.
|
1171
|
-
* @returns True if end-to-end is enabled.
|
1172
|
-
* @deprecated prefer {@link getCrypto}
|
1173
|
-
*/
|
1174
|
-
isCryptoEnabled() {
|
1175
|
-
return !!this.cryptoBackend;
|
1176
|
-
}
|
1177
|
-
|
1178
|
-
/**
|
1179
|
-
* Get the Ed25519 key for this device
|
1180
|
-
*
|
1181
|
-
* @returns base64-encoded ed25519 key. Null if crypto is
|
1182
|
-
* disabled.
|
1183
|
-
*
|
1184
|
-
* @deprecated Not supported for Rust Cryptography.Prefer {@link CryptoApi.getOwnDeviceKeys}
|
1185
|
-
*/
|
1186
|
-
getDeviceEd25519Key() {
|
1187
|
-
var _this$crypto$getDevic, _this$crypto;
|
1188
|
-
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;
|
1189
|
-
}
|
1190
|
-
|
1191
|
-
/**
|
1192
|
-
* Get the Curve25519 key for this device
|
1193
|
-
*
|
1194
|
-
* @returns base64-encoded curve25519 key. Null if crypto is
|
1195
|
-
* disabled.
|
1196
|
-
*
|
1197
|
-
* @deprecated Not supported for Rust Cryptography. Use {@link CryptoApi.getOwnDeviceKeys}
|
1198
|
-
*/
|
1199
|
-
getDeviceCurve25519Key() {
|
1200
|
-
var _this$crypto$getDevic2, _this$crypto2;
|
1201
|
-
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;
|
1202
|
-
}
|
1203
|
-
|
1204
|
-
/**
|
1205
|
-
* @deprecated Does nothing.
|
1206
|
-
*/
|
1207
|
-
uploadKeys() {
|
1208
|
-
var _this13 = this;
|
1209
|
-
return _asyncToGenerator(function* () {
|
1210
|
-
_this13.logger.warn("MatrixClient.uploadKeys is deprecated");
|
1211
|
-
})();
|
1212
|
-
}
|
1213
|
-
|
1214
|
-
/**
|
1215
|
-
* Download the keys for a list of users and stores the keys in the session
|
1216
|
-
* store.
|
1217
|
-
* @param userIds - The users to fetch.
|
1218
|
-
* @param forceDownload - Always download the keys even if cached.
|
1219
|
-
*
|
1220
|
-
* @returns A promise which resolves to a map userId-\>deviceId-\>`DeviceInfo`
|
1221
|
-
*
|
1222
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.getUserDeviceInfo}
|
1223
|
-
*/
|
1224
|
-
downloadKeys(userIds, forceDownload) {
|
1225
|
-
if (!this.crypto) {
|
1226
|
-
return Promise.reject(new Error("End-to-end encryption disabled"));
|
1227
|
-
}
|
1228
|
-
return this.crypto.downloadKeys(userIds, forceDownload);
|
1229
|
-
}
|
1230
|
-
|
1231
|
-
/**
|
1232
|
-
* Get the stored device keys for a user id
|
1233
|
-
*
|
1234
|
-
* @param userId - the user to list keys for.
|
1235
|
-
*
|
1236
|
-
* @returns list of devices
|
1237
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.getUserDeviceInfo}
|
1238
|
-
*/
|
1239
|
-
getStoredDevicesForUser(userId) {
|
1240
|
-
if (!this.crypto) {
|
1241
|
-
throw new Error("End-to-end encryption disabled");
|
1242
|
-
}
|
1243
|
-
return this.crypto.getStoredDevicesForUser(userId) || [];
|
1244
|
-
}
|
1245
|
-
|
1246
|
-
/**
|
1247
|
-
* Get the stored device key for a user id and device id
|
1248
|
-
*
|
1249
|
-
* @param userId - the user to list keys for.
|
1250
|
-
* @param deviceId - unique identifier for the device
|
1251
|
-
*
|
1252
|
-
* @returns device or null
|
1253
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.getUserDeviceInfo}
|
1254
|
-
*/
|
1255
|
-
getStoredDevice(userId, deviceId) {
|
1256
|
-
if (!this.crypto) {
|
1257
|
-
throw new Error("End-to-end encryption disabled");
|
1258
|
-
}
|
1259
|
-
return this.crypto.getStoredDevice(userId, deviceId) || null;
|
1260
|
-
}
|
1261
|
-
|
1262
|
-
/**
|
1263
|
-
* Mark the given device as verified
|
1264
|
-
*
|
1265
|
-
* @param userId - owner of the device
|
1266
|
-
* @param deviceId - unique identifier for the device or user's
|
1267
|
-
* cross-signing public key ID.
|
1268
|
-
*
|
1269
|
-
* @param verified - whether to mark the device as verified. defaults
|
1270
|
-
* to 'true'.
|
1271
|
-
*
|
1272
|
-
* @returns
|
1273
|
-
*
|
1274
|
-
* @remarks
|
1275
|
-
* Fires {@link CryptoEvent#DeviceVerificationChanged}
|
1276
|
-
*/
|
1277
|
-
setDeviceVerified(userId, deviceId) {
|
1278
|
-
var verified = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
1279
|
-
var prom = this.setDeviceVerification(userId, deviceId, verified, null, null);
|
1280
|
-
|
1281
|
-
// if one of the user's own devices is being marked as verified / unverified,
|
1282
|
-
// check the key backup status, since whether or not we use this depends on
|
1283
|
-
// whether it has a signature from a verified device
|
1284
|
-
if (userId == this.credentials.userId) {
|
1285
|
-
this.checkKeyBackup();
|
1286
|
-
}
|
1287
|
-
return prom;
|
1288
|
-
}
|
1289
|
-
|
1290
|
-
/**
|
1291
|
-
* Mark the given device as blocked/unblocked
|
1292
|
-
*
|
1293
|
-
* @param userId - owner of the device
|
1294
|
-
* @param deviceId - unique identifier for the device or user's
|
1295
|
-
* cross-signing public key ID.
|
1296
|
-
*
|
1297
|
-
* @param blocked - whether to mark the device as blocked. defaults
|
1298
|
-
* to 'true'.
|
1299
|
-
*
|
1300
|
-
* @returns
|
1301
|
-
*
|
1302
|
-
* @remarks
|
1303
|
-
* Fires {@link LegacyCryptoEvent.DeviceVerificationChanged}
|
1304
|
-
*
|
1305
|
-
* @deprecated Not supported for Rust Cryptography.
|
1306
|
-
*/
|
1307
|
-
setDeviceBlocked(userId, deviceId) {
|
1308
|
-
var blocked = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
1309
|
-
return this.setDeviceVerification(userId, deviceId, null, blocked, null);
|
1310
|
-
}
|
1311
|
-
|
1312
|
-
/**
|
1313
|
-
* Mark the given device as known/unknown
|
1314
|
-
*
|
1315
|
-
* @param userId - owner of the device
|
1316
|
-
* @param deviceId - unique identifier for the device or user's
|
1317
|
-
* cross-signing public key ID.
|
1318
|
-
*
|
1319
|
-
* @param known - whether to mark the device as known. defaults
|
1320
|
-
* to 'true'.
|
1321
|
-
*
|
1322
|
-
* @returns
|
1323
|
-
*
|
1324
|
-
* @remarks
|
1325
|
-
* Fires {@link CryptoEvent#DeviceVerificationChanged}
|
1326
|
-
*
|
1327
|
-
* @deprecated Not supported for Rust Cryptography.
|
1328
|
-
*/
|
1329
|
-
setDeviceKnown(userId, deviceId) {
|
1330
|
-
var known = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
1331
|
-
return this.setDeviceVerification(userId, deviceId, null, null, known);
|
1332
|
-
}
|
1333
|
-
setDeviceVerification(userId, deviceId, verified, blocked, known) {
|
1334
|
-
var _this14 = this;
|
1335
|
-
return _asyncToGenerator(function* () {
|
1336
|
-
if (!_this14.crypto) {
|
1337
|
-
throw new Error("End-to-end encryption disabled");
|
1338
|
-
}
|
1339
|
-
yield _this14.crypto.setDeviceVerification(userId, deviceId, verified, blocked, known);
|
1340
|
-
})();
|
1341
|
-
}
|
1342
|
-
|
1343
|
-
/**
|
1344
|
-
* Request a key verification from another user, using a DM.
|
1345
|
-
*
|
1346
|
-
* @param userId - the user to request verification with
|
1347
|
-
* @param roomId - the room to use for verification
|
1348
|
-
*
|
1349
|
-
* @returns resolves to a VerificationRequest
|
1350
|
-
* when the request has been sent to the other party.
|
1351
|
-
*
|
1352
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.requestVerificationDM}.
|
1353
|
-
*/
|
1354
|
-
requestVerificationDM(userId, roomId) {
|
1355
|
-
if (!this.crypto) {
|
1356
|
-
throw new Error("End-to-end encryption disabled");
|
1357
|
-
}
|
1358
|
-
return this.crypto.requestVerificationDM(userId, roomId);
|
1359
|
-
}
|
1360
|
-
|
1361
|
-
/**
|
1362
|
-
* Finds a DM verification request that is already in progress for the given room id
|
1363
|
-
*
|
1364
|
-
* @param roomId - the room to use for verification
|
1365
|
-
*
|
1366
|
-
* @returns the VerificationRequest that is in progress, if any
|
1367
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.findVerificationRequestDMInProgress}.
|
1368
|
-
*/
|
1369
|
-
findVerificationRequestDMInProgress(roomId) {
|
1370
|
-
if (!this.cryptoBackend) {
|
1371
|
-
throw new Error("End-to-end encryption disabled");
|
1372
|
-
} else if (!this.crypto) {
|
1373
|
-
// Hack for element-R to avoid breaking the cypress tests. We can get rid of this once the react-sdk is
|
1374
|
-
// updated to use CryptoApi.findVerificationRequestDMInProgress.
|
1375
|
-
return undefined;
|
1376
|
-
}
|
1377
|
-
return this.crypto.findVerificationRequestDMInProgress(roomId);
|
1378
|
-
}
|
1379
|
-
|
1380
|
-
/**
|
1381
|
-
* Returns all to-device verification requests that are already in progress for the given user id
|
1382
|
-
*
|
1383
|
-
* @param userId - the ID of the user to query
|
1384
|
-
*
|
1385
|
-
* @returns the VerificationRequests that are in progress
|
1386
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.getVerificationRequestsToDeviceInProgress}.
|
1387
|
-
*/
|
1388
|
-
getVerificationRequestsToDeviceInProgress(userId) {
|
1389
|
-
if (!this.crypto) {
|
1390
|
-
throw new Error("End-to-end encryption disabled");
|
1391
|
-
}
|
1392
|
-
return this.crypto.getVerificationRequestsToDeviceInProgress(userId);
|
1393
|
-
}
|
1394
|
-
|
1395
|
-
/**
|
1396
|
-
* Request a key verification from another user.
|
1397
|
-
*
|
1398
|
-
* @param userId - the user to request verification with
|
1399
|
-
* @param devices - array of device IDs to send requests to. Defaults to
|
1400
|
-
* all devices owned by the user
|
1401
|
-
*
|
1402
|
-
* @returns resolves to a VerificationRequest
|
1403
|
-
* when the request has been sent to the other party.
|
1404
|
-
*
|
1405
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi#requestOwnUserVerification} or {@link CryptoApi#requestDeviceVerification}.
|
1406
|
-
*/
|
1407
|
-
requestVerification(userId, devices) {
|
1408
|
-
if (!this.crypto) {
|
1409
|
-
throw new Error("End-to-end encryption disabled");
|
1410
|
-
}
|
1411
|
-
return this.crypto.requestVerification(userId, devices);
|
1412
|
-
}
|
1413
|
-
|
1414
|
-
/**
|
1415
|
-
* Begin a key verification.
|
1416
|
-
*
|
1417
|
-
* @param method - the verification method to use
|
1418
|
-
* @param userId - the user to verify keys with
|
1419
|
-
* @param deviceId - the device to verify
|
1420
|
-
*
|
1421
|
-
* @returns a verification object
|
1422
|
-
* @deprecated Prefer {@link CryptoApi#requestOwnUserVerification} or {@link CryptoApi#requestDeviceVerification}.
|
1423
|
-
*/
|
1424
|
-
beginKeyVerification(method, userId, deviceId) {
|
1425
|
-
if (!this.crypto) {
|
1426
|
-
throw new Error("End-to-end encryption disabled");
|
1427
|
-
}
|
1428
|
-
return this.crypto.beginKeyVerification(method, userId, deviceId);
|
1429
|
-
}
|
1430
|
-
|
1431
|
-
/**
|
1432
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#checkKey}.
|
1433
|
-
*/
|
1434
|
-
checkSecretStorageKey(key, info) {
|
1435
|
-
return this.secretStorage.checkKey(key, info);
|
1436
|
-
}
|
1437
|
-
|
1438
|
-
/**
|
1439
|
-
* Set the global override for whether the client should ever send encrypted
|
1440
|
-
* messages to unverified devices. This provides the default for rooms which
|
1441
|
-
* do not specify a value.
|
1442
|
-
*
|
1443
|
-
* @param value - whether to blacklist all unverified devices by default
|
1444
|
-
*
|
1445
|
-
* @deprecated Prefer direct access to {@link CryptoApi.globalBlacklistUnverifiedDevices}:
|
1446
|
-
*
|
1447
|
-
* ```javascript
|
1448
|
-
* client.getCrypto().globalBlacklistUnverifiedDevices = value;
|
1449
|
-
* ```
|
1450
|
-
*/
|
1451
|
-
setGlobalBlacklistUnverifiedDevices(value) {
|
1452
|
-
if (!this.cryptoBackend) {
|
1453
|
-
throw new Error("End-to-end encryption disabled");
|
1454
|
-
}
|
1455
|
-
this.cryptoBackend.globalBlacklistUnverifiedDevices = value;
|
1456
|
-
return value;
|
1457
|
-
}
|
1458
|
-
|
1459
|
-
/**
|
1460
|
-
* @returns whether to blacklist all unverified devices by default
|
1461
|
-
*
|
1462
|
-
* @deprecated Prefer direct access to {@link CryptoApi.globalBlacklistUnverifiedDevices}:
|
1463
|
-
*
|
1464
|
-
* ```javascript
|
1465
|
-
* value = client.getCrypto().globalBlacklistUnverifiedDevices;
|
1466
|
-
* ```
|
1467
|
-
*/
|
1468
|
-
getGlobalBlacklistUnverifiedDevices() {
|
1469
|
-
if (!this.cryptoBackend) {
|
1470
|
-
throw new Error("End-to-end encryption disabled");
|
1471
|
-
}
|
1472
|
-
return this.cryptoBackend.globalBlacklistUnverifiedDevices;
|
1473
|
-
}
|
1474
|
-
|
1475
|
-
/**
|
1476
|
-
* Set whether sendMessage in a room with unknown and unverified devices
|
1477
|
-
* should throw an error and not send them message. This has 'Global' for
|
1478
|
-
* symmetry with setGlobalBlacklistUnverifiedDevices but there is currently
|
1479
|
-
* no room-level equivalent for this setting.
|
1480
|
-
*
|
1481
|
-
* This API is currently UNSTABLE and may change or be removed without notice.
|
1482
|
-
*
|
1483
|
-
* It has no effect with the Rust crypto implementation.
|
1484
|
-
*
|
1485
|
-
* @param value - whether error on unknown devices
|
1486
|
-
*
|
1487
|
-
* ```ts
|
1488
|
-
* client.getCrypto().globalErrorOnUnknownDevices = value;
|
1489
|
-
* ```
|
1490
|
-
*/
|
1491
|
-
setGlobalErrorOnUnknownDevices(value) {
|
1492
|
-
if (!this.cryptoBackend) {
|
1493
|
-
throw new Error("End-to-end encryption disabled");
|
1494
|
-
}
|
1495
|
-
this.cryptoBackend.globalErrorOnUnknownDevices = value;
|
1496
|
-
}
|
1497
|
-
|
1498
|
-
/**
|
1499
|
-
* @returns whether to error on unknown devices
|
1500
|
-
*
|
1501
|
-
* This API is currently UNSTABLE and may change or be removed without notice.
|
1502
|
-
*/
|
1503
|
-
getGlobalErrorOnUnknownDevices() {
|
1504
|
-
if (!this.cryptoBackend) {
|
1505
|
-
throw new Error("End-to-end encryption disabled");
|
1506
|
-
}
|
1507
|
-
return this.cryptoBackend.globalErrorOnUnknownDevices;
|
1508
|
-
}
|
1509
|
-
|
1510
|
-
/**
|
1511
|
-
* Get the ID of one of the user's cross-signing keys
|
1512
|
-
*
|
1513
|
-
* @param type - The type of key to get the ID of. One of
|
1514
|
-
* "master", "self_signing", or "user_signing". Defaults to "master".
|
1515
|
-
*
|
1516
|
-
* @returns the key ID
|
1517
|
-
* @deprecated Not supported for Rust Cryptography. prefer {@link Crypto.CryptoApi#getCrossSigningKeyId}
|
1518
|
-
*/
|
1519
|
-
getCrossSigningId() {
|
1520
|
-
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : CrossSigningKey.Master;
|
1521
|
-
if (!this.crypto) {
|
1522
|
-
throw new Error("End-to-end encryption disabled");
|
1523
|
-
}
|
1524
|
-
return this.crypto.getCrossSigningId(type);
|
1525
|
-
}
|
1526
|
-
|
1527
|
-
/**
|
1528
|
-
* Get the cross signing information for a given user.
|
1529
|
-
*
|
1530
|
-
* The cross-signing API is currently UNSTABLE and may change without notice.
|
1531
|
-
*
|
1532
|
-
* @param userId - the user ID to get the cross-signing info for.
|
1533
|
-
*
|
1534
|
-
* @returns the cross signing information for the user.
|
1535
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi#userHasCrossSigningKeys}
|
1536
|
-
*/
|
1537
|
-
getStoredCrossSigningForUser(userId) {
|
1538
|
-
if (!this.cryptoBackend) {
|
1539
|
-
throw new Error("End-to-end encryption disabled");
|
1540
|
-
}
|
1541
|
-
return this.cryptoBackend.getStoredCrossSigningForUser(userId);
|
1542
|
-
}
|
1543
|
-
|
1544
|
-
/**
|
1545
|
-
* Check whether a given user is trusted.
|
1546
|
-
*
|
1547
|
-
* The cross-signing API is currently UNSTABLE and may change without notice.
|
1548
|
-
*
|
1549
|
-
* @param userId - The ID of the user to check.
|
1550
|
-
*
|
1551
|
-
* @deprecated Use {@link Crypto.CryptoApi.getUserVerificationStatus | `CryptoApi.getUserVerificationStatus`}
|
1552
|
-
*/
|
1553
|
-
checkUserTrust(userId) {
|
1554
|
-
if (!this.cryptoBackend) {
|
1555
|
-
throw new Error("End-to-end encryption disabled");
|
1556
|
-
}
|
1557
|
-
return this.cryptoBackend.checkUserTrust(userId);
|
1558
|
-
}
|
1559
|
-
|
1560
|
-
/**
|
1561
|
-
* Check whether a given device is trusted.
|
1562
|
-
*
|
1563
|
-
* The cross-signing API is currently UNSTABLE and may change without notice.
|
1564
|
-
*
|
1565
|
-
* @param userId - The ID of the user whose devices is to be checked.
|
1566
|
-
* @param deviceId - The ID of the device to check
|
1567
|
-
*
|
1568
|
-
* @deprecated Use {@link Crypto.CryptoApi.getDeviceVerificationStatus | `CryptoApi.getDeviceVerificationStatus`}
|
1569
|
-
*/
|
1570
|
-
checkDeviceTrust(userId, deviceId) {
|
1571
|
-
if (!this.crypto) {
|
1572
|
-
throw new Error("End-to-end encryption disabled");
|
1573
|
-
}
|
1574
|
-
return this.crypto.checkDeviceTrust(userId, deviceId);
|
1575
|
-
}
|
1576
|
-
|
1577
|
-
/**
|
1578
|
-
* Check whether one of our own devices is cross-signed by our
|
1579
|
-
* user's stored keys, regardless of whether we trust those keys yet.
|
1580
|
-
*
|
1581
|
-
* @param deviceId - The ID of the device to check
|
1582
|
-
*
|
1583
|
-
* @returns true if the device is cross-signed
|
1584
|
-
*
|
1585
|
-
* @deprecated Not supported for Rust Cryptography.
|
1586
|
-
*/
|
1587
|
-
checkIfOwnDeviceCrossSigned(deviceId) {
|
1588
|
-
if (!this.crypto) {
|
1589
|
-
throw new Error("End-to-end encryption disabled");
|
1590
|
-
}
|
1591
|
-
return this.crypto.checkIfOwnDeviceCrossSigned(deviceId);
|
1592
|
-
}
|
1593
|
-
|
1594
|
-
/**
|
1595
|
-
* Check the copy of our cross-signing key that we have in the device list and
|
1596
|
-
* see if we can get the private key. If so, mark it as trusted.
|
1597
|
-
* @param opts - ICheckOwnCrossSigningTrustOpts object
|
1598
|
-
*
|
1599
|
-
* @deprecated Unneeded for the new crypto
|
1600
|
-
*/
|
1601
|
-
checkOwnCrossSigningTrust(opts) {
|
1602
|
-
if (!this.cryptoBackend) {
|
1603
|
-
throw new Error("End-to-end encryption disabled");
|
1604
|
-
}
|
1605
|
-
return this.cryptoBackend.checkOwnCrossSigningTrust(opts);
|
1606
|
-
}
|
1607
|
-
|
1608
|
-
/**
|
1609
|
-
* Checks that a given cross-signing private key matches a given public key.
|
1610
|
-
* This can be used by the getCrossSigningKey callback to verify that the
|
1611
|
-
* private key it is about to supply is the one that was requested.
|
1612
|
-
* @param privateKey - The private key
|
1613
|
-
* @param expectedPublicKey - The public key
|
1614
|
-
* @returns true if the key matches, otherwise false
|
1615
|
-
*
|
1616
|
-
* @deprecated Not supported for Rust Cryptography.
|
1617
|
-
*/
|
1618
|
-
checkCrossSigningPrivateKey(privateKey, expectedPublicKey) {
|
1619
|
-
if (!this.crypto) {
|
1620
|
-
throw new Error("End-to-end encryption disabled");
|
1621
|
-
}
|
1622
|
-
return this.crypto.checkCrossSigningPrivateKey(privateKey, expectedPublicKey);
|
1623
|
-
}
|
1624
|
-
|
1625
|
-
/**
|
1626
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi#requestDeviceVerification}.
|
1627
|
-
*/
|
1628
|
-
legacyDeviceVerification(userId, deviceId, method) {
|
1629
|
-
if (!this.crypto) {
|
1630
|
-
throw new Error("End-to-end encryption disabled");
|
1631
|
-
}
|
1632
|
-
return this.crypto.legacyDeviceVerification(userId, deviceId, method);
|
1633
|
-
}
|
1634
|
-
|
1635
|
-
/**
|
1636
|
-
* Perform any background tasks that can be done before a message is ready to
|
1637
|
-
* send, in order to speed up sending of the message.
|
1638
|
-
* @param room - the room the event is in
|
1639
|
-
*
|
1640
|
-
* @deprecated Prefer {@link CryptoApi.prepareToEncrypt | `CryptoApi.prepareToEncrypt`}:
|
1641
|
-
*
|
1642
|
-
* ```javascript
|
1643
|
-
* client.getCrypto().prepareToEncrypt(room);
|
1644
|
-
* ```
|
1645
|
-
*/
|
1646
|
-
prepareToEncrypt(room) {
|
1647
|
-
if (!this.cryptoBackend) {
|
1648
|
-
throw new Error("End-to-end encryption disabled");
|
1649
|
-
}
|
1650
|
-
this.cryptoBackend.prepareToEncrypt(room);
|
1651
|
-
}
|
1652
|
-
|
1653
|
-
/**
|
1654
|
-
* Checks if the user has previously published cross-signing keys
|
1655
|
-
*
|
1656
|
-
* This means downloading the devicelist for the user and checking if the list includes
|
1657
|
-
* the cross-signing pseudo-device.
|
1658
|
-
*
|
1659
|
-
* @deprecated Prefer {@link CryptoApi.userHasCrossSigningKeys | `CryptoApi.userHasCrossSigningKeys`}:
|
1660
|
-
*
|
1661
|
-
* ```javascript
|
1662
|
-
* result = client.getCrypto().userHasCrossSigningKeys();
|
1663
|
-
* ```
|
1664
|
-
*/
|
1665
|
-
userHasCrossSigningKeys() {
|
1666
|
-
if (!this.cryptoBackend) {
|
1667
|
-
throw new Error("End-to-end encryption disabled");
|
1668
|
-
}
|
1669
|
-
return this.cryptoBackend.userHasCrossSigningKeys();
|
1670
|
-
}
|
1671
|
-
|
1672
|
-
/**
|
1673
|
-
* Checks whether cross signing:
|
1674
|
-
* - is enabled on this account and trusted by this device
|
1675
|
-
* - has private keys either cached locally or stored in secret storage
|
1676
|
-
*
|
1677
|
-
* If this function returns false, bootstrapCrossSigning() can be used
|
1678
|
-
* to fix things such that it returns true. That is to say, after
|
1679
|
-
* bootstrapCrossSigning() completes successfully, this function should
|
1680
|
-
* return true.
|
1681
|
-
* @returns True if cross-signing is ready to be used on this device
|
1682
|
-
* @deprecated Prefer {@link CryptoApi.isCrossSigningReady | `CryptoApi.isCrossSigningReady`}:
|
1683
|
-
*/
|
1684
|
-
isCrossSigningReady() {
|
1685
|
-
if (!this.cryptoBackend) {
|
1686
|
-
throw new Error("End-to-end encryption disabled");
|
1687
|
-
}
|
1688
|
-
return this.cryptoBackend.isCrossSigningReady();
|
1689
|
-
}
|
1690
|
-
|
1691
|
-
/**
|
1692
|
-
* Bootstrap cross-signing by creating keys if needed. If everything is already
|
1693
|
-
* set up, then no changes are made, so this is safe to run to ensure
|
1694
|
-
* cross-signing is ready for use.
|
1695
|
-
*
|
1696
|
-
* This function:
|
1697
|
-
* - creates new cross-signing keys if they are not found locally cached nor in
|
1698
|
-
* secret storage (if it has been set up)
|
1699
|
-
*
|
1700
|
-
* @deprecated Prefer {@link CryptoApi.bootstrapCrossSigning | `CryptoApi.bootstrapCrossSigning`}.
|
1701
|
-
*/
|
1702
|
-
bootstrapCrossSigning(opts) {
|
1703
|
-
if (!this.cryptoBackend) {
|
1704
|
-
throw new Error("End-to-end encryption disabled");
|
1705
|
-
}
|
1706
|
-
return this.cryptoBackend.bootstrapCrossSigning(opts);
|
1707
|
-
}
|
1708
|
-
|
1709
|
-
/**
|
1710
|
-
* Whether to trust a others users signatures of their devices.
|
1711
|
-
* If false, devices will only be considered 'verified' if we have
|
1712
|
-
* verified that device individually (effectively disabling cross-signing).
|
1713
|
-
*
|
1714
|
-
* Default: true
|
1715
|
-
*
|
1716
|
-
* @returns True if trusting cross-signed devices
|
1717
|
-
*
|
1718
|
-
* @deprecated Prefer {@link CryptoApi.getTrustCrossSignedDevices | `CryptoApi.getTrustCrossSignedDevices`}.
|
1719
|
-
*/
|
1720
|
-
getCryptoTrustCrossSignedDevices() {
|
1721
|
-
if (!this.cryptoBackend) {
|
1722
|
-
throw new Error("End-to-end encryption disabled");
|
1723
|
-
}
|
1724
|
-
return this.cryptoBackend.getTrustCrossSignedDevices();
|
1725
|
-
}
|
1726
|
-
|
1727
|
-
/**
|
1728
|
-
* See getCryptoTrustCrossSignedDevices
|
1729
|
-
*
|
1730
|
-
* @param val - True to trust cross-signed devices
|
1731
|
-
*
|
1732
|
-
* @deprecated Prefer {@link CryptoApi.setTrustCrossSignedDevices | `CryptoApi.setTrustCrossSignedDevices`}.
|
1733
|
-
*/
|
1734
|
-
setCryptoTrustCrossSignedDevices(val) {
|
1735
|
-
if (!this.cryptoBackend) {
|
1736
|
-
throw new Error("End-to-end encryption disabled");
|
1737
|
-
}
|
1738
|
-
this.cryptoBackend.setTrustCrossSignedDevices(val);
|
1739
|
-
}
|
1740
|
-
|
1741
|
-
/**
|
1742
|
-
* Counts the number of end to end session keys that are waiting to be backed up
|
1743
|
-
* @returns Promise which resolves to the number of sessions requiring backup
|
1744
|
-
*
|
1745
|
-
* @deprecated Not supported for Rust Cryptography.
|
1746
|
-
*/
|
1747
|
-
countSessionsNeedingBackup() {
|
1748
|
-
if (!this.crypto) {
|
1749
|
-
throw new Error("End-to-end encryption disabled");
|
1750
|
-
}
|
1751
|
-
return this.crypto.countSessionsNeedingBackup();
|
1752
|
-
}
|
1753
|
-
|
1754
|
-
/**
|
1755
|
-
* Get information about the encryption of an event
|
1756
|
-
*
|
1757
|
-
* @param event - event to be checked
|
1758
|
-
* @returns The event information.
|
1759
|
-
* @deprecated Prefer {@link Crypto.CryptoApi.getEncryptionInfoForEvent | `CryptoApi.getEncryptionInfoForEvent`}.
|
1760
|
-
*/
|
1761
|
-
getEventEncryptionInfo(event) {
|
1762
|
-
if (!this.cryptoBackend) {
|
1763
|
-
throw new Error("End-to-end encryption disabled");
|
1764
|
-
}
|
1765
|
-
return this.cryptoBackend.getEventEncryptionInfo(event);
|
1766
|
-
}
|
1767
|
-
|
1768
|
-
/**
|
1769
|
-
* Create a recovery key from a user-supplied passphrase.
|
1770
|
-
*
|
1771
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
1772
|
-
*
|
1773
|
-
* @param password - Passphrase string that can be entered by the user
|
1774
|
-
* when restoring the backup as an alternative to entering the recovery key.
|
1775
|
-
* Optional.
|
1776
|
-
* @returns Object with public key metadata, encoded private
|
1777
|
-
* recovery key which should be disposed of after displaying to the user,
|
1778
|
-
* and raw private key to avoid round tripping if needed.
|
1779
|
-
*
|
1780
|
-
* @deprecated Prefer {@link CryptoApi.createRecoveryKeyFromPassphrase | `CryptoApi.createRecoveryKeyFromPassphrase`}.
|
1781
|
-
*/
|
1782
|
-
createRecoveryKeyFromPassphrase(password) {
|
1783
|
-
if (!this.cryptoBackend) {
|
1784
|
-
throw new Error("End-to-end encryption disabled");
|
1785
|
-
}
|
1786
|
-
return this.cryptoBackend.createRecoveryKeyFromPassphrase(password);
|
1787
|
-
}
|
1788
|
-
|
1789
|
-
/**
|
1790
|
-
* Checks whether secret storage:
|
1791
|
-
* - is enabled on this account
|
1792
|
-
* - is storing cross-signing private keys
|
1793
|
-
* - is storing session backup key (if enabled)
|
1794
|
-
*
|
1795
|
-
* If this function returns false, bootstrapSecretStorage() can be used
|
1796
|
-
* to fix things such that it returns true. That is to say, after
|
1797
|
-
* bootstrapSecretStorage() completes successfully, this function should
|
1798
|
-
* return true.
|
1799
|
-
*
|
1800
|
-
* @returns True if secret storage is ready to be used on this device
|
1801
|
-
* @deprecated Prefer {@link CryptoApi.isSecretStorageReady | `CryptoApi.isSecretStorageReady`}.
|
1802
|
-
*/
|
1803
|
-
isSecretStorageReady() {
|
1804
|
-
if (!this.cryptoBackend) {
|
1805
|
-
throw new Error("End-to-end encryption disabled");
|
1806
|
-
}
|
1807
|
-
return this.cryptoBackend.isSecretStorageReady();
|
1808
|
-
}
|
1809
|
-
|
1810
|
-
/**
|
1811
|
-
* Bootstrap Secure Secret Storage if needed by creating a default key. If everything is
|
1812
|
-
* already set up, then no changes are made, so this is safe to run to ensure secret
|
1813
|
-
* storage is ready for use.
|
1814
|
-
*
|
1815
|
-
* This function
|
1816
|
-
* - creates a new Secure Secret Storage key if no default key exists
|
1817
|
-
* - if a key backup exists, it is migrated to store the key in the Secret
|
1818
|
-
* Storage
|
1819
|
-
* - creates a backup if none exists, and one is requested
|
1820
|
-
* - migrates Secure Secret Storage to use the latest algorithm, if an outdated
|
1821
|
-
* algorithm is found
|
1822
|
-
*
|
1823
|
-
* @deprecated Use {@link CryptoApi.bootstrapSecretStorage | `CryptoApi.bootstrapSecretStorage`}.
|
1824
|
-
*/
|
1825
|
-
bootstrapSecretStorage(opts) {
|
1826
|
-
if (!this.cryptoBackend) {
|
1827
|
-
throw new Error("End-to-end encryption disabled");
|
1828
|
-
}
|
1829
|
-
return this.cryptoBackend.bootstrapSecretStorage(opts);
|
1830
|
-
}
|
1831
|
-
|
1832
|
-
/**
|
1833
|
-
* Add a key for encrypting secrets.
|
1834
|
-
*
|
1835
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
1836
|
-
*
|
1837
|
-
* @param algorithm - the algorithm used by the key
|
1838
|
-
* @param opts - the options for the algorithm. The properties used
|
1839
|
-
* depend on the algorithm given.
|
1840
|
-
* @param keyName - the name of the key. If not given, a random name will be generated.
|
1841
|
-
*
|
1842
|
-
* @returns An object with:
|
1843
|
-
* keyId: the ID of the key
|
1844
|
-
* keyInfo: details about the key (iv, mac, passphrase)
|
1845
|
-
*
|
1846
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#addKey}.
|
1847
|
-
*/
|
1848
|
-
addSecretStorageKey(algorithm, opts, keyName) {
|
1849
|
-
return this.secretStorage.addKey(algorithm, opts, keyName);
|
1850
|
-
}
|
1851
|
-
|
1852
|
-
/**
|
1853
|
-
* Check whether we have a key with a given ID.
|
1854
|
-
*
|
1855
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
1856
|
-
*
|
1857
|
-
* @param keyId - The ID of the key to check
|
1858
|
-
* for. Defaults to the default key ID if not provided.
|
1859
|
-
* @returns Whether we have the key.
|
1860
|
-
*
|
1861
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#hasKey}.
|
1862
|
-
*/
|
1863
|
-
hasSecretStorageKey(keyId) {
|
1864
|
-
return this.secretStorage.hasKey(keyId);
|
1865
|
-
}
|
1866
|
-
|
1867
|
-
/**
|
1868
|
-
* Store an encrypted secret on the server.
|
1869
|
-
*
|
1870
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
1871
|
-
*
|
1872
|
-
* @param name - The name of the secret
|
1873
|
-
* @param secret - The secret contents.
|
1874
|
-
* @param keys - The IDs of the keys to use to encrypt the secret or null/undefined
|
1875
|
-
* to use the default (will throw if no default key is set).
|
1876
|
-
*
|
1877
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#store}.
|
1878
|
-
*/
|
1879
|
-
storeSecret(name, secret, keys) {
|
1880
|
-
return this.secretStorage.store(name, secret, keys);
|
1881
|
-
}
|
1882
|
-
|
1883
|
-
/**
|
1884
|
-
* Get a secret from storage.
|
1885
|
-
*
|
1886
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
1887
|
-
*
|
1888
|
-
* @param name - the name of the secret
|
1889
|
-
*
|
1890
|
-
* @returns the contents of the secret
|
1891
|
-
*
|
1892
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#get}.
|
1893
|
-
*/
|
1894
|
-
getSecret(name) {
|
1895
|
-
return this.secretStorage.get(name);
|
1896
|
-
}
|
1897
|
-
|
1898
|
-
/**
|
1899
|
-
* Check if a secret is stored on the server.
|
1900
|
-
*
|
1901
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
1902
|
-
*
|
1903
|
-
* @param name - the name of the secret
|
1904
|
-
* @returns map of key name to key info the secret is encrypted
|
1905
|
-
* with, or null if it is not present or not encrypted with a trusted
|
1906
|
-
* key
|
1907
|
-
*
|
1908
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#isStored}.
|
1909
|
-
*/
|
1910
|
-
isSecretStored(name) {
|
1911
|
-
return this.secretStorage.isStored(name);
|
1912
|
-
}
|
1913
|
-
|
1914
|
-
/**
|
1915
|
-
* Request a secret from another device.
|
1916
|
-
*
|
1917
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
1918
|
-
*
|
1919
|
-
* @param name - the name of the secret to request
|
1920
|
-
* @param devices - the devices to request the secret from
|
1921
|
-
*
|
1922
|
-
* @returns the secret request object
|
1923
|
-
* @deprecated Not supported for Rust Cryptography.
|
1924
|
-
*/
|
1925
|
-
requestSecret(name, devices) {
|
1926
|
-
if (!this.crypto) {
|
1927
|
-
throw new Error("End-to-end encryption disabled");
|
1928
|
-
}
|
1929
|
-
return this.crypto.requestSecret(name, devices);
|
1930
|
-
}
|
1931
|
-
|
1932
|
-
/**
|
1933
|
-
* Get the current default key ID for encrypting secrets.
|
1934
|
-
*
|
1935
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
1936
|
-
*
|
1937
|
-
* @returns The default key ID or null if no default key ID is set
|
1938
|
-
*
|
1939
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#getDefaultKeyId}.
|
1940
|
-
*/
|
1941
|
-
getDefaultSecretStorageKeyId() {
|
1942
|
-
return this.secretStorage.getDefaultKeyId();
|
1943
|
-
}
|
1944
|
-
|
1945
|
-
/**
|
1946
|
-
* Set the current default key ID for encrypting secrets.
|
1947
|
-
*
|
1948
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
1949
|
-
*
|
1950
|
-
* @param keyId - The new default key ID
|
1951
|
-
*
|
1952
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#setDefaultKeyId}.
|
1953
|
-
*/
|
1954
|
-
setDefaultSecretStorageKeyId(keyId) {
|
1955
|
-
return this.secretStorage.setDefaultKeyId(keyId);
|
1956
|
-
}
|
1957
|
-
|
1958
|
-
/**
|
1959
|
-
* Checks that a given secret storage private key matches a given public key.
|
1960
|
-
* This can be used by the getSecretStorageKey callback to verify that the
|
1961
|
-
* private key it is about to supply is the one that was requested.
|
1962
|
-
*
|
1963
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
1964
|
-
*
|
1965
|
-
* @param privateKey - The private key
|
1966
|
-
* @param expectedPublicKey - The public key
|
1967
|
-
* @returns true if the key matches, otherwise false
|
1968
|
-
*
|
1969
|
-
* @deprecated The use of asymmetric keys for SSSS is deprecated.
|
1970
|
-
* Use {@link SecretStorage.ServerSideSecretStorage#checkKey} for symmetric keys.
|
1971
|
-
*/
|
1972
|
-
checkSecretStoragePrivateKey(privateKey, expectedPublicKey) {
|
1973
|
-
if (!this.crypto) {
|
1974
|
-
throw new Error("End-to-end encryption disabled");
|
1975
|
-
}
|
1976
|
-
return this.crypto.checkSecretStoragePrivateKey(privateKey, expectedPublicKey);
|
1977
|
-
}
|
1978
|
-
|
1979
|
-
/**
|
1980
|
-
* Get e2e information on the device that sent an event
|
1981
|
-
*
|
1982
|
-
* @param event - event to be checked
|
1983
|
-
* @deprecated Not supported for Rust Cryptography.
|
1984
|
-
*/
|
1985
|
-
getEventSenderDeviceInfo(event) {
|
1986
|
-
var _this15 = this;
|
1987
|
-
return _asyncToGenerator(function* () {
|
1988
|
-
if (!_this15.crypto) {
|
1989
|
-
return null;
|
1990
|
-
}
|
1991
|
-
return _this15.crypto.getEventSenderDeviceInfo(event);
|
1992
|
-
})();
|
1993
|
-
}
|
1994
|
-
|
1995
|
-
/**
|
1996
|
-
* Check if the sender of an event is verified
|
1997
|
-
*
|
1998
|
-
* @param event - event to be checked
|
1999
|
-
*
|
2000
|
-
* @returns true if the sender of this event has been verified using
|
2001
|
-
* {@link MatrixClient#setDeviceVerified}.
|
2002
|
-
*
|
2003
|
-
* @deprecated Not supported for Rust Cryptography.
|
2004
|
-
*/
|
2005
|
-
isEventSenderVerified(event) {
|
2006
|
-
var _this16 = this;
|
2007
|
-
return _asyncToGenerator(function* () {
|
2008
|
-
var device = yield _this16.getEventSenderDeviceInfo(event);
|
2009
|
-
if (!device) {
|
2010
|
-
return false;
|
2011
|
-
}
|
2012
|
-
return device.isVerified();
|
2013
|
-
})();
|
2014
|
-
}
|
2015
|
-
|
2016
|
-
/**
|
2017
|
-
* Get outgoing room key request for this event if there is one.
|
2018
|
-
* @param event - The event to check for
|
2019
|
-
*
|
2020
|
-
* @returns A room key request, or null if there is none
|
2021
|
-
*
|
2022
|
-
* @deprecated Not supported for Rust Cryptography.
|
2023
|
-
*/
|
2024
|
-
getOutgoingRoomKeyRequest(event) {
|
2025
|
-
if (!this.crypto) {
|
2026
|
-
throw new Error("End-to-End encryption disabled");
|
2027
|
-
}
|
2028
|
-
var wireContent = event.getWireContent();
|
2029
|
-
var requestBody = {
|
2030
|
-
session_id: wireContent.session_id,
|
2031
|
-
sender_key: wireContent.sender_key,
|
2032
|
-
algorithm: wireContent.algorithm,
|
2033
|
-
room_id: event.getRoomId()
|
2034
|
-
};
|
2035
|
-
if (!requestBody.session_id || !requestBody.sender_key || !requestBody.algorithm || !requestBody.room_id) {
|
2036
|
-
return Promise.resolve(null);
|
2037
|
-
}
|
2038
|
-
return this.crypto.cryptoStore.getOutgoingRoomKeyRequest(requestBody);
|
2039
|
-
}
|
2040
|
-
|
2041
|
-
/**
|
2042
|
-
* Cancel a room key request for this event if one is ongoing and resend the
|
2043
|
-
* request.
|
2044
|
-
* @param event - event of which to cancel and resend the room
|
2045
|
-
* key request.
|
2046
|
-
* @returns A promise that will resolve when the key request is queued
|
2047
|
-
*
|
2048
|
-
* @deprecated Not supported for Rust Cryptography.
|
2049
|
-
*/
|
2050
|
-
cancelAndResendEventRoomKeyRequest(event) {
|
2051
|
-
if (!this.crypto) {
|
2052
|
-
throw new Error("End-to-End encryption disabled");
|
2053
|
-
}
|
2054
|
-
return event.cancelAndResendKeyRequest(this.crypto, this.getUserId());
|
2055
|
-
}
|
2056
|
-
|
2057
|
-
/**
|
2058
|
-
* Enable end-to-end encryption for a room. This does not modify room state.
|
2059
|
-
* Any messages sent before the returned promise resolves will be sent unencrypted.
|
2060
|
-
* @param roomId - The room ID to enable encryption in.
|
2061
|
-
* @param config - The encryption config for the room.
|
2062
|
-
* @returns A promise that will resolve when encryption is set up.
|
2063
|
-
*
|
2064
|
-
* @deprecated Not supported for Rust Cryptography. To enable encryption in a room, send an `m.room.encryption`
|
2065
|
-
* state event.
|
2066
|
-
*/
|
2067
|
-
setRoomEncryption(roomId, config) {
|
2068
|
-
if (!this.crypto) {
|
2069
|
-
throw new Error("End-to-End encryption disabled");
|
2070
|
-
}
|
2071
|
-
return this.crypto.setRoomEncryption(roomId, config);
|
2072
|
-
}
|
2073
|
-
|
2074
|
-
/**
|
2075
|
-
* Whether encryption is enabled for a room.
|
2076
|
-
* @param roomId - the room id to query.
|
2077
|
-
* @returns whether encryption is enabled.
|
2078
|
-
*
|
2079
|
-
* @deprecated Not correctly supported for Rust Cryptography. Use {@link CryptoApi.isEncryptionEnabledInRoom} and/or
|
2080
|
-
* {@link Room.hasEncryptionStateEvent}.
|
2081
|
-
*/
|
2082
|
-
isRoomEncrypted(roomId) {
|
2083
|
-
var _this$crypto$isRoomEn, _this$crypto3;
|
2084
|
-
var room = this.getRoom(roomId);
|
2085
|
-
if (!room) {
|
2086
|
-
// we don't know about this room, so can't determine if it should be
|
2087
|
-
// encrypted. Let's assume not.
|
2088
|
-
return false;
|
2089
|
-
}
|
2090
|
-
|
2091
|
-
// if there is an 'm.room.encryption' event in this room, it should be
|
2092
|
-
// encrypted (independently of whether we actually support encryption)
|
2093
|
-
if (room.hasEncryptionStateEvent()) {
|
2094
|
-
return true;
|
2095
|
-
}
|
2096
|
-
|
2097
|
-
// we don't have an m.room.encrypted event, but that might be because
|
2098
|
-
// the server is hiding it from us. Check the store to see if it was
|
2099
|
-
// previously encrypted.
|
2100
|
-
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;
|
2101
|
-
}
|
2102
|
-
|
2103
|
-
/**
|
2104
|
-
* Encrypts and sends a given object via Olm to-device messages to a given
|
2105
|
-
* set of devices.
|
2106
|
-
*
|
2107
|
-
* @param userDeviceInfoArr - list of deviceInfo objects representing the devices to send to
|
2108
|
-
*
|
2109
|
-
* @param payload - fields to include in the encrypted payload
|
2110
|
-
*
|
2111
|
-
* @returns Promise which
|
2112
|
-
* resolves once the message has been encrypted and sent to the given
|
2113
|
-
* userDeviceMap, and returns the `{ contentMap, deviceInfoByDeviceId }`
|
2114
|
-
* of the successfully sent messages.
|
2115
|
-
*
|
2116
|
-
* @deprecated Instead use {@link CryptoApi.encryptToDeviceMessages} followed by {@link queueToDevice}.
|
2117
|
-
*/
|
2118
|
-
encryptAndSendToDevices(userDeviceInfoArr, payload) {
|
2119
|
-
if (!this.crypto) {
|
2120
|
-
throw new Error("End-to-End encryption disabled");
|
2121
|
-
}
|
2122
|
-
return this.crypto.encryptAndSendToDevices(userDeviceInfoArr, payload);
|
2123
|
-
}
|
2124
|
-
|
2125
|
-
/**
|
2126
|
-
* Forces the current outbound group session to be discarded such
|
2127
|
-
* that another one will be created next time an event is sent.
|
2128
|
-
*
|
2129
|
-
* @param roomId - The ID of the room to discard the session for
|
2130
|
-
*
|
2131
|
-
* @deprecated Prefer {@link CryptoApi.forceDiscardSession | `CryptoApi.forceDiscardSession`}:
|
2132
|
-
*/
|
2133
|
-
forceDiscardSession(roomId) {
|
2134
|
-
if (!this.cryptoBackend) {
|
2135
|
-
throw new Error("End-to-End encryption disabled");
|
2136
|
-
}
|
2137
|
-
this.cryptoBackend.forceDiscardSession(roomId);
|
2138
|
-
}
|
2139
|
-
|
2140
|
-
/**
|
2141
|
-
* Get a list containing all of the room keys
|
2142
|
-
*
|
2143
|
-
* This should be encrypted before returning it to the user.
|
2144
|
-
*
|
2145
|
-
* @returns a promise which resolves to a list of session export objects
|
2146
|
-
*
|
2147
|
-
* @deprecated Prefer {@link CryptoApi.exportRoomKeys | `CryptoApi.exportRoomKeys`}:
|
2148
|
-
*
|
2149
|
-
* ```javascript
|
2150
|
-
* sessionData = await client.getCrypto().exportRoomKeys();
|
2151
|
-
* ```
|
2152
|
-
*/
|
2153
|
-
exportRoomKeys() {
|
2154
|
-
if (!this.cryptoBackend) {
|
2155
|
-
return Promise.reject(new Error("End-to-end encryption disabled"));
|
2156
|
-
}
|
2157
|
-
return this.cryptoBackend.exportRoomKeys();
|
2158
|
-
}
|
2159
|
-
|
2160
|
-
/**
|
2161
|
-
* Import a list of room keys previously exported by exportRoomKeys
|
2162
|
-
*
|
2163
|
-
* @param keys - a list of session export objects
|
2164
|
-
* @param opts - options object
|
2165
|
-
*
|
2166
|
-
* @returns a promise which resolves when the keys have been imported
|
2167
|
-
*
|
2168
|
-
* @deprecated Prefer {@link CryptoApi.importRoomKeys | `CryptoApi.importRoomKeys`}:
|
2169
|
-
* ```javascript
|
2170
|
-
* await client.getCrypto()?.importRoomKeys([..]);
|
2171
|
-
* ```
|
2172
|
-
*/
|
2173
|
-
importRoomKeys(keys, opts) {
|
2174
|
-
if (!this.cryptoBackend) {
|
2175
|
-
throw new Error("End-to-end encryption disabled");
|
2176
|
-
}
|
2177
|
-
return this.cryptoBackend.importRoomKeys(keys, opts);
|
2178
|
-
}
|
2179
|
-
|
2180
|
-
/**
|
2181
|
-
* Force a re-check of the local key backup status against
|
2182
|
-
* what's on the server.
|
2183
|
-
*
|
2184
|
-
* @returns Object with backup info (as returned by
|
2185
|
-
* getKeyBackupVersion) in backupInfo and
|
2186
|
-
* trust information (as returned by isKeyBackupTrusted)
|
2187
|
-
* in trustInfo.
|
2188
|
-
*
|
2189
|
-
* @deprecated Prefer {@link Crypto.CryptoApi.checkKeyBackupAndEnable}.
|
2190
|
-
*/
|
2191
|
-
checkKeyBackup() {
|
2192
|
-
if (!this.crypto) {
|
2193
|
-
throw new Error("End-to-end encryption disabled");
|
2194
|
-
}
|
2195
|
-
return this.crypto.backupManager.checkKeyBackup();
|
2196
|
-
}
|
2197
|
-
|
2198
|
-
/**
|
2199
|
-
* Get information about the current key backup from the server.
|
2200
|
-
*
|
2201
|
-
* Performs some basic validity checks on the shape of the result, and raises an error if it is not as expected.
|
2202
|
-
*
|
2203
|
-
* **Note**: there is no (supported) way to distinguish between "failure to talk to the server" and "another client
|
2204
|
-
* uploaded a key backup version using an algorithm I don't understand.
|
2205
|
-
*
|
2206
|
-
* @returns Information object from API, or null if no backup is present on the server.
|
2207
|
-
*
|
2208
|
-
* @deprecated Prefer {@link CryptoApi.getKeyBackupInfo}.
|
2209
|
-
*/
|
2210
|
-
getKeyBackupVersion() {
|
2211
|
-
var _this17 = this;
|
2212
|
-
return _asyncToGenerator(function* () {
|
2213
|
-
var res;
|
2214
|
-
try {
|
2215
|
-
res = yield _this17.http.authedRequest(Method.Get, "/room_keys/version", undefined, undefined, {
|
2216
|
-
prefix: ClientPrefix.V3
|
2217
|
-
});
|
2218
|
-
} catch (e) {
|
2219
|
-
if (e.errcode === "M_NOT_FOUND") {
|
2220
|
-
return null;
|
2221
|
-
} else {
|
2222
|
-
throw e;
|
2223
|
-
}
|
2224
|
-
}
|
2225
|
-
BackupManager.checkBackupVersion(res);
|
2226
|
-
return res;
|
2227
|
-
})();
|
2228
|
-
}
|
2229
|
-
|
2230
|
-
/**
|
2231
|
-
* @param info - key backup info dict from getKeyBackupVersion()
|
2232
|
-
*
|
2233
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.isKeyBackupTrusted | `CryptoApi.isKeyBackupTrusted`}.
|
2234
|
-
*/
|
2235
|
-
isKeyBackupTrusted(info) {
|
2236
|
-
if (!this.crypto) {
|
2237
|
-
throw new Error("End-to-end encryption disabled");
|
2238
|
-
}
|
2239
|
-
return this.crypto.backupManager.isKeyBackupTrusted(info);
|
2240
|
-
}
|
2241
|
-
|
2242
|
-
/**
|
2243
|
-
* @returns true if the client is configured to back up keys to
|
2244
|
-
* the server, otherwise false. If we haven't completed a successful check
|
2245
|
-
* of key backup status yet, returns null.
|
2246
|
-
*
|
2247
|
-
* @deprecated Not supported for Rust Cryptography. Prefer direct access to {@link Crypto.CryptoApi.getActiveSessionBackupVersion}:
|
2248
|
-
*
|
2249
|
-
* ```javascript
|
2250
|
-
* let enabled = (await client.getCrypto().getActiveSessionBackupVersion()) !== null;
|
2251
|
-
* ```
|
2252
|
-
*/
|
2253
|
-
getKeyBackupEnabled() {
|
2254
|
-
if (!this.crypto) {
|
2255
|
-
throw new Error("End-to-end encryption disabled");
|
2256
|
-
}
|
2257
|
-
return this.crypto.backupManager.getKeyBackupEnabled();
|
2258
|
-
}
|
2259
|
-
|
2260
|
-
/**
|
2261
|
-
* Enable backing up of keys, using data previously returned from
|
2262
|
-
* getKeyBackupVersion.
|
2263
|
-
*
|
2264
|
-
* @param info - Backup information object as returned by getKeyBackupVersion
|
2265
|
-
* @returns Promise which resolves when complete.
|
2266
|
-
*
|
2267
|
-
* @deprecated Do not call this directly. Instead call {@link Crypto.CryptoApi.checkKeyBackupAndEnable}.
|
2268
|
-
*/
|
2269
|
-
enableKeyBackup(info) {
|
2270
|
-
if (!this.crypto) {
|
2271
|
-
throw new Error("End-to-end encryption disabled");
|
2272
|
-
}
|
2273
|
-
return this.crypto.backupManager.enableKeyBackup(info);
|
2274
|
-
}
|
2275
|
-
|
2276
|
-
/**
|
2277
|
-
* Disable backing up of keys.
|
2278
|
-
*
|
2279
|
-
* @deprecated Not supported for Rust Cryptography. It should be unnecessary to disable key backup.
|
2280
|
-
*/
|
2281
|
-
disableKeyBackup() {
|
2282
|
-
if (!this.crypto) {
|
2283
|
-
throw new Error("End-to-end encryption disabled");
|
2284
|
-
}
|
2285
|
-
this.crypto.backupManager.disableKeyBackup();
|
2286
|
-
}
|
2287
|
-
|
2288
|
-
/**
|
2289
|
-
* Set up the data required to create a new backup version. The backup version
|
2290
|
-
* will not be created and enabled until createKeyBackupVersion is called.
|
2291
|
-
*
|
2292
|
-
* @param password - Passphrase string that can be entered by the user
|
2293
|
-
* when restoring the backup as an alternative to entering the recovery key.
|
2294
|
-
* Optional.
|
2295
|
-
*
|
2296
|
-
* @returns Object that can be passed to createKeyBackupVersion and
|
2297
|
-
* additionally has a 'recovery_key' member with the user-facing recovery key string.
|
2298
|
-
*
|
2299
|
-
* @deprecated Not supported for Rust cryptography. Use {@link Crypto.CryptoApi.resetKeyBackup | `CryptoApi.resetKeyBackup`}.
|
2300
|
-
*/
|
2301
|
-
prepareKeyBackupVersion(password) {
|
2302
|
-
var _arguments2 = arguments,
|
2303
|
-
_this18 = this;
|
2304
|
-
return _asyncToGenerator(function* () {
|
2305
|
-
var opts = _arguments2.length > 1 && _arguments2[1] !== undefined ? _arguments2[1] : {
|
2306
|
-
secureSecretStorage: false
|
2307
|
-
};
|
2308
|
-
if (!_this18.crypto) {
|
2309
|
-
throw new Error("End-to-end encryption disabled");
|
2310
|
-
}
|
2311
|
-
|
2312
|
-
// eslint-disable-next-line camelcase
|
2313
|
-
var {
|
2314
|
-
algorithm,
|
2315
|
-
auth_data,
|
2316
|
-
recovery_key,
|
2317
|
-
privateKey
|
2318
|
-
} = yield _this18.crypto.backupManager.prepareKeyBackupVersion(password);
|
2319
|
-
if (opts.secureSecretStorage) {
|
2320
|
-
yield _this18.secretStorage.store("m.megolm_backup.v1", encodeBase64(privateKey));
|
2321
|
-
_this18.logger.info("Key backup private key stored in secret storage");
|
2322
|
-
}
|
2323
|
-
return {
|
2324
|
-
algorithm,
|
2325
|
-
/* eslint-disable camelcase */
|
2326
|
-
auth_data,
|
2327
|
-
recovery_key
|
2328
|
-
/* eslint-enable camelcase */
|
2329
|
-
};
|
2330
|
-
})();
|
2331
|
-
}
|
2332
|
-
|
2333
|
-
/**
|
2334
|
-
* Check whether the key backup private key is stored in secret storage.
|
2335
|
-
* @returns map of key name to key info the secret is
|
2336
|
-
* encrypted with, or null if it is not present or not encrypted with a
|
2337
|
-
* trusted key
|
2338
|
-
*/
|
2339
|
-
isKeyBackupKeyStored() {
|
2340
|
-
return Promise.resolve(this.secretStorage.isStored("m.megolm_backup.v1"));
|
2341
|
-
}
|
2342
|
-
|
2343
|
-
/**
|
2344
|
-
* Create a new key backup version and enable it, using the information return
|
2345
|
-
* from prepareKeyBackupVersion.
|
2346
|
-
*
|
2347
|
-
* @param info - Info object from prepareKeyBackupVersion
|
2348
|
-
* @returns Object with 'version' param indicating the version created
|
2349
|
-
*
|
2350
|
-
* @deprecated Use {@link Crypto.CryptoApi.resetKeyBackup | `CryptoApi.resetKeyBackup`}.
|
2351
|
-
*/
|
2352
|
-
createKeyBackupVersion(info) {
|
2353
|
-
var _this19 = this;
|
2354
|
-
return _asyncToGenerator(function* () {
|
2355
|
-
if (!_this19.crypto) {
|
2356
|
-
throw new Error("End-to-end encryption disabled");
|
2357
|
-
}
|
2358
|
-
yield _this19.crypto.backupManager.createKeyBackupVersion(info);
|
2359
|
-
var data = {
|
2360
|
-
algorithm: info.algorithm,
|
2361
|
-
auth_data: info.auth_data
|
2362
|
-
};
|
2363
|
-
|
2364
|
-
// Sign the backup auth data with the device key for backwards compat with
|
2365
|
-
// older devices with cross-signing. This can probably go away very soon in
|
2366
|
-
// favour of just signing with the cross-singing master key.
|
2367
|
-
// XXX: Private member access
|
2368
|
-
yield _this19.crypto.signObject(data.auth_data);
|
2369
|
-
if (_this19.cryptoCallbacks.getCrossSigningKey &&
|
2370
|
-
// XXX: Private member access
|
2371
|
-
_this19.crypto.crossSigningInfo.getId()) {
|
2372
|
-
// now also sign the auth data with the cross-signing master key
|
2373
|
-
// we check for the callback explicitly here because we still want to be able
|
2374
|
-
// to create an un-cross-signed key backup if there is a cross-signing key but
|
2375
|
-
// no callback supplied.
|
2376
|
-
// XXX: Private member access
|
2377
|
-
yield _this19.crypto.crossSigningInfo.signObject(data.auth_data, "master");
|
2378
|
-
}
|
2379
|
-
var res = yield _this19.http.authedRequest(Method.Post, "/room_keys/version", undefined, data);
|
2380
|
-
|
2381
|
-
// We could assume everything's okay and enable directly, but this ensures
|
2382
|
-
// we run the same signature verification that will be used for future
|
2383
|
-
// sessions.
|
2384
|
-
yield _this19.checkKeyBackup();
|
2385
|
-
if (!_this19.getKeyBackupEnabled()) {
|
2386
|
-
_this19.logger.error("Key backup not usable even though we just created it");
|
2387
|
-
}
|
2388
|
-
return res;
|
2389
|
-
})();
|
2390
|
-
}
|
2391
|
-
|
2392
|
-
/**
|
2393
|
-
* @deprecated Use {@link Crypto.CryptoApi.deleteKeyBackupVersion | `CryptoApi.deleteKeyBackupVersion`}.
|
2394
|
-
*/
|
2395
|
-
deleteKeyBackupVersion(version) {
|
2396
|
-
var _this20 = this;
|
2397
|
-
return _asyncToGenerator(function* () {
|
2398
|
-
if (!_this20.cryptoBackend) {
|
2399
|
-
throw new Error("End-to-end encryption disabled");
|
2400
|
-
}
|
2401
|
-
yield _this20.cryptoBackend.deleteKeyBackupVersion(version);
|
2402
|
-
})();
|
2403
|
-
}
|
2404
|
-
makeKeyBackupPath(roomId, sessionId, version) {
|
2405
|
-
var path;
|
2406
|
-
if (sessionId !== undefined) {
|
2407
|
-
path = utils.encodeUri("/room_keys/keys/$roomId/$sessionId", {
|
2408
|
-
$roomId: roomId,
|
2409
|
-
$sessionId: sessionId
|
2410
|
-
});
|
2411
|
-
} else if (roomId !== undefined) {
|
2412
|
-
path = utils.encodeUri("/room_keys/keys/$roomId", {
|
2413
|
-
$roomId: roomId
|
2414
|
-
});
|
2415
|
-
} else {
|
2416
|
-
path = "/room_keys/keys";
|
2417
|
-
}
|
2418
|
-
var queryData = version === undefined ? undefined : {
|
2419
|
-
version
|
2420
|
-
};
|
2421
|
-
return {
|
2422
|
-
path,
|
2423
|
-
queryData
|
2424
|
-
};
|
2425
|
-
}
|
2426
|
-
|
2427
|
-
/**
|
2428
|
-
* Back up session keys to the homeserver.
|
2429
|
-
* @param roomId - ID of the room that the keys are for Optional.
|
2430
|
-
* @param sessionId - ID of the session that the keys are for Optional.
|
2431
|
-
* @param version - backup version Optional.
|
2432
|
-
* @param data - Object keys to send
|
2433
|
-
* @returns a promise that will resolve when the keys
|
2434
|
-
* are uploaded
|
2435
|
-
*
|
2436
|
-
* @deprecated Not supported for Rust Cryptography.
|
2437
|
-
*/
|
2438
|
-
|
2439
|
-
sendKeyBackup(roomId, sessionId, version, data) {
|
2440
|
-
var _this21 = this;
|
2441
|
-
return _asyncToGenerator(function* () {
|
2442
|
-
if (!_this21.crypto) {
|
2443
|
-
throw new Error("End-to-end encryption disabled");
|
2444
|
-
}
|
2445
|
-
var path = _this21.makeKeyBackupPath(roomId, sessionId, version);
|
2446
|
-
yield _this21.http.authedRequest(Method.Put, path.path, path.queryData, data, {
|
2447
|
-
prefix: ClientPrefix.V3
|
2448
|
-
});
|
2449
|
-
})();
|
2450
|
-
}
|
2451
|
-
|
2452
|
-
/**
|
2453
|
-
* Marks all group sessions as needing to be backed up and schedules them to
|
2454
|
-
* upload in the background as soon as possible.
|
2455
|
-
*
|
2456
|
-
* @deprecated Not supported for Rust Cryptography. This is done automatically as part of
|
2457
|
-
* {@link CryptoApi.resetKeyBackup}, so there is probably no need to call this manually.
|
2458
|
-
*/
|
2459
|
-
scheduleAllGroupSessionsForBackup() {
|
2460
|
-
var _this22 = this;
|
2461
|
-
return _asyncToGenerator(function* () {
|
2462
|
-
if (!_this22.crypto) {
|
2463
|
-
throw new Error("End-to-end encryption disabled");
|
2464
|
-
}
|
2465
|
-
yield _this22.crypto.backupManager.scheduleAllGroupSessionsForBackup();
|
2466
|
-
})();
|
2467
|
-
}
|
2468
|
-
|
2469
|
-
/**
|
2470
|
-
* Marks all group sessions as needing to be backed up without scheduling
|
2471
|
-
* them to upload in the background.
|
2472
|
-
*
|
2473
|
-
* (This is done automatically as part of {@link CryptoApi.resetKeyBackup},
|
2474
|
-
* so there is probably no need to call this manually.)
|
2475
|
-
*
|
2476
|
-
* @returns Promise which resolves to the number of sessions requiring a backup.
|
2477
|
-
* @deprecated Not supported for Rust Cryptography.
|
2478
|
-
*/
|
2479
|
-
flagAllGroupSessionsForBackup() {
|
2480
|
-
if (!this.crypto) {
|
2481
|
-
throw new Error("End-to-end encryption disabled");
|
2482
|
-
}
|
2483
|
-
return this.crypto.backupManager.flagAllGroupSessionsForBackup();
|
2484
|
-
}
|
2485
|
-
|
2486
|
-
/**
|
2487
|
-
* Return true if recovery key is valid.
|
2488
|
-
* Try to decode the recovery key and check if it's successful.
|
2489
|
-
* @param recoveryKey
|
2490
|
-
* @deprecated Use {@link decodeRecoveryKey} directly
|
2491
|
-
*/
|
2492
|
-
isValidRecoveryKey(recoveryKey) {
|
2493
|
-
try {
|
2494
|
-
decodeRecoveryKey(recoveryKey);
|
2495
|
-
return true;
|
2496
|
-
} catch (_unused2) {
|
2497
|
-
return false;
|
2498
|
-
}
|
2499
|
-
}
|
2500
|
-
|
2501
|
-
/**
|
2502
|
-
* Get the raw key for a key backup from the password
|
2503
|
-
* Used when migrating key backups into SSSS
|
2504
|
-
*
|
2505
|
-
* The cross-signing API is currently UNSTABLE and may change without notice.
|
2506
|
-
*
|
2507
|
-
* @param password - Passphrase
|
2508
|
-
* @param backupInfo - Backup metadata from `checkKeyBackup`
|
2509
|
-
* @returns key backup key
|
2510
|
-
* @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.
|
2511
|
-
*/
|
2512
|
-
keyBackupKeyFromPassword(password, backupInfo) {
|
2513
|
-
return keyFromAuthData(backupInfo.auth_data, password);
|
2514
|
-
}
|
2515
|
-
|
2516
|
-
/**
|
2517
|
-
* Get the raw key for a key backup from the recovery key
|
2518
|
-
* Used when migrating key backups into SSSS
|
2519
|
-
*
|
2520
|
-
* The cross-signing API is currently UNSTABLE and may change without notice.
|
2521
|
-
*
|
2522
|
-
* @param recoveryKey - The recovery key
|
2523
|
-
* @returns key backup key
|
2524
|
-
* @deprecated Use {@link decodeRecoveryKey} directly
|
2525
|
-
*/
|
2526
|
-
keyBackupKeyFromRecoveryKey(recoveryKey) {
|
2527
|
-
return decodeRecoveryKey(recoveryKey);
|
2528
|
-
}
|
2529
|
-
|
2530
|
-
/**
|
2531
|
-
* Restore from an existing key backup via a passphrase.
|
2532
|
-
*
|
2533
|
-
* @param password - Passphrase
|
2534
|
-
* @param targetRoomId - Room ID to target a specific room.
|
2535
|
-
* Restores all rooms if omitted.
|
2536
|
-
* @param targetSessionId - Session ID to target a specific session.
|
2537
|
-
* Restores all sessions if omitted.
|
2538
|
-
* @param backupInfo - Backup metadata from `getKeyBackupVersion` or `checkKeyBackup`.`backupInfo`
|
2539
|
-
* @param opts - Optional params such as callbacks
|
2540
|
-
* @returns Status of restoration with `total` and `imported`
|
2541
|
-
* key counts.
|
2542
|
-
*
|
2543
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackupWithPassphrase | `CryptoApi.restoreKeyBackupWithPassphrase`}.
|
2544
|
-
*/
|
2545
|
-
|
2546
|
-
/**
|
2547
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackupWithPassphrase | `CryptoApi.restoreKeyBackupWithPassphrase`}.
|
2548
|
-
*/
|
2549
|
-
|
2550
|
-
/**
|
2551
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackupWithPassphrase | `CryptoApi.restoreKeyBackupWithPassphrase`}.
|
2552
|
-
*/
|
2553
|
-
|
2554
|
-
/**
|
2555
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackupWithPassphrase | `CryptoApi.restoreKeyBackupWithPassphrase`}.
|
2556
|
-
*/
|
2557
|
-
restoreKeyBackupWithPassword(password, targetRoomId, targetSessionId, backupInfo, opts) {
|
2558
|
-
var _this23 = this;
|
2559
|
-
return _asyncToGenerator(function* () {
|
2560
|
-
var privKey = yield keyFromAuthData(backupInfo.auth_data, password);
|
2561
|
-
return _this23.restoreKeyBackup(privKey, targetRoomId, targetSessionId, backupInfo, opts);
|
2562
|
-
})();
|
2563
|
-
}
|
2564
|
-
|
2565
|
-
/**
|
2566
|
-
* Restore from an existing key backup via a private key stored in secret
|
2567
|
-
* storage.
|
2568
|
-
*
|
2569
|
-
* @param backupInfo - Backup metadata from `checkKeyBackup`
|
2570
|
-
* @param targetRoomId - Room ID to target a specific room.
|
2571
|
-
* Restores all rooms if omitted.
|
2572
|
-
* @param targetSessionId - Session ID to target a specific session.
|
2573
|
-
* Restores all sessions if omitted.
|
2574
|
-
* @param opts - Optional params such as callbacks
|
2575
|
-
* @returns Status of restoration with `total` and `imported`
|
2576
|
-
* key counts.
|
2577
|
-
*
|
2578
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
2579
|
-
*/
|
2580
|
-
restoreKeyBackupWithSecretStorage(backupInfo, targetRoomId, targetSessionId, opts) {
|
2581
|
-
var _this24 = this;
|
2582
|
-
return _asyncToGenerator(function* () {
|
2583
|
-
if (!_this24.cryptoBackend) {
|
2584
|
-
throw new Error("End-to-end encryption disabled");
|
2585
|
-
}
|
2586
|
-
var storedKey = yield _this24.secretStorage.get("m.megolm_backup.v1");
|
2587
|
-
|
2588
|
-
// ensure that the key is in the right format. If not, fix the key and
|
2589
|
-
// store the fixed version
|
2590
|
-
var fixedKey = fixBackupKey(storedKey);
|
2591
|
-
if (fixedKey) {
|
2592
|
-
var keys = yield _this24.secretStorage.getKey();
|
2593
|
-
yield _this24.secretStorage.store("m.megolm_backup.v1", fixedKey, [keys[0]]);
|
2594
|
-
}
|
2595
|
-
var privKey = decodeBase64(fixedKey || storedKey);
|
2596
|
-
return _this24.restoreKeyBackup(privKey, targetRoomId, targetSessionId, backupInfo, opts);
|
2597
|
-
})();
|
2598
|
-
}
|
2599
|
-
|
2600
|
-
/**
|
2601
|
-
* Restore from an existing key backup via an encoded recovery key.
|
2602
|
-
*
|
2603
|
-
* @param recoveryKey - Encoded recovery key
|
2604
|
-
* @param targetRoomId - Room ID to target a specific room.
|
2605
|
-
* Restores all rooms if omitted.
|
2606
|
-
* @param targetSessionId - Session ID to target a specific session.
|
2607
|
-
* Restores all sessions if omitted.
|
2608
|
-
* @param backupInfo - Backup metadata from `checkKeyBackup`
|
2609
|
-
* @param opts - Optional params such as callbacks
|
2610
|
-
* @returns Status of restoration with `total` and `imported`
|
2611
|
-
* key counts.
|
2612
|
-
*
|
2613
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
2614
|
-
*/
|
2615
|
-
|
2616
|
-
/**
|
2617
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
2618
|
-
*/
|
2619
|
-
|
2620
|
-
/**
|
2621
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
2622
|
-
*/
|
2623
|
-
|
2624
|
-
/**
|
2625
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
2626
|
-
*/
|
2627
|
-
restoreKeyBackupWithRecoveryKey(recoveryKey, targetRoomId, targetSessionId, backupInfo, opts) {
|
2628
|
-
var privKey = decodeRecoveryKey(recoveryKey);
|
2629
|
-
return this.restoreKeyBackup(privKey, targetRoomId, targetSessionId, backupInfo, opts);
|
2630
|
-
}
|
2631
|
-
|
2632
|
-
/**
|
2633
|
-
* Restore from an existing key backup via a private key stored locally
|
2634
|
-
* @param targetRoomId
|
2635
|
-
* @param targetSessionId
|
2636
|
-
* @param backupInfo
|
2637
|
-
* @param opts
|
2638
|
-
*
|
2639
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
2640
|
-
*/
|
2641
|
-
|
2642
|
-
/**
|
2643
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
2644
|
-
*/
|
2645
|
-
|
2646
|
-
/**
|
2647
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
2648
|
-
*/
|
2649
|
-
|
2650
|
-
/**
|
2651
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
2652
|
-
*/
|
2653
|
-
restoreKeyBackupWithCache(targetRoomId, targetSessionId, backupInfo, opts) {
|
2654
|
-
var _this25 = this;
|
2655
|
-
return _asyncToGenerator(function* () {
|
2656
|
-
if (!_this25.cryptoBackend) {
|
2657
|
-
throw new Error("End-to-end encryption disabled");
|
2658
|
-
}
|
2659
|
-
var privKey = yield _this25.cryptoBackend.getSessionBackupPrivateKey();
|
2660
|
-
if (!privKey) {
|
2661
|
-
throw new Error("Couldn't get key");
|
2662
|
-
}
|
2663
|
-
return _this25.restoreKeyBackup(privKey, targetRoomId, targetSessionId, backupInfo, opts);
|
2664
|
-
})();
|
2665
|
-
}
|
2666
|
-
restoreKeyBackup(privKey, targetRoomId, targetSessionId, backupInfo, opts) {
|
2667
|
-
var _this26 = this;
|
2668
|
-
return _asyncToGenerator(function* () {
|
2669
|
-
var cacheCompleteCallback = opts === null || opts === void 0 ? void 0 : opts.cacheCompleteCallback;
|
2670
|
-
var progressCallback = opts === null || opts === void 0 ? void 0 : opts.progressCallback;
|
2671
|
-
if (!_this26.cryptoBackend) {
|
2672
|
-
throw new Error("End-to-end encryption disabled");
|
2673
|
-
}
|
2674
|
-
if (!backupInfo.version) {
|
2675
|
-
throw new Error("Backup version must be defined");
|
2676
|
-
}
|
2677
|
-
var backupVersion = backupInfo.version;
|
2678
|
-
var totalKeyCount = 0;
|
2679
|
-
var totalFailures = 0;
|
2680
|
-
var totalImported = 0;
|
2681
|
-
var path = _this26.makeKeyBackupPath(targetRoomId, targetSessionId, backupVersion);
|
2682
|
-
var backupDecryptor = yield _this26.cryptoBackend.getBackupDecryptor(backupInfo, privKey);
|
2683
|
-
var untrusted = !backupDecryptor.sourceTrusted;
|
2684
|
-
try {
|
2685
|
-
if (!(privKey instanceof Uint8Array)) {
|
2686
|
-
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
2687
|
-
throw new Error("restoreKeyBackup expects Uint8Array, got ".concat(privKey));
|
2688
|
-
}
|
2689
|
-
// Cache the key, if possible.
|
2690
|
-
// This is async.
|
2691
|
-
_this26.cryptoBackend.storeSessionBackupPrivateKey(privKey, backupVersion).catch(e => {
|
2692
|
-
_this26.logger.warn("Error caching session backup key:", e);
|
2693
|
-
}).then(cacheCompleteCallback);
|
2694
|
-
if (progressCallback) {
|
2695
|
-
progressCallback({
|
2696
|
-
stage: "fetch"
|
2697
|
-
});
|
2698
|
-
}
|
2699
|
-
var res = yield _this26.http.authedRequest(Method.Get, path.path, path.queryData, undefined, {
|
2700
|
-
prefix: ClientPrefix.V3
|
2701
|
-
});
|
2702
|
-
|
2703
|
-
// We have finished fetching the backup, go to next step
|
2704
|
-
if (progressCallback) {
|
2705
|
-
progressCallback({
|
2706
|
-
stage: "load_keys"
|
2707
|
-
});
|
2708
|
-
}
|
2709
|
-
if (res.rooms) {
|
2710
|
-
// We have a full backup here, it can get quite big, so we need to decrypt and import it in chunks.
|
2711
|
-
|
2712
|
-
// Get the total count as a first pass
|
2713
|
-
totalKeyCount = _this26.getTotalKeyCount(res);
|
2714
|
-
// Now decrypt and import the keys in chunks
|
2715
|
-
yield _this26.handleDecryptionOfAFullBackup(res, backupDecryptor, 200, /*#__PURE__*/function () {
|
2716
|
-
var _ref3 = _asyncToGenerator(function* (chunk) {
|
2717
|
-
// We have a chunk of decrypted keys: import them
|
2718
|
-
try {
|
2719
|
-
var _backupVersion = backupInfo.version;
|
2720
|
-
yield _this26.cryptoBackend.importBackedUpRoomKeys(chunk, _backupVersion, {
|
2721
|
-
untrusted
|
2722
|
-
});
|
2723
|
-
totalImported += chunk.length;
|
2724
|
-
} catch (e) {
|
2725
|
-
totalFailures += chunk.length;
|
2726
|
-
// We failed to import some keys, but we should still try to import the rest?
|
2727
|
-
// Log the error and continue
|
2728
|
-
logger.error("Error importing keys from backup", e);
|
2729
|
-
}
|
2730
|
-
if (progressCallback) {
|
2731
|
-
progressCallback({
|
2732
|
-
total: totalKeyCount,
|
2733
|
-
successes: totalImported,
|
2734
|
-
stage: "load_keys",
|
2735
|
-
failures: totalFailures
|
2736
|
-
});
|
2737
|
-
}
|
2738
|
-
});
|
2739
|
-
return function (_x2) {
|
2740
|
-
return _ref3.apply(this, arguments);
|
2741
|
-
};
|
2742
|
-
}());
|
2743
|
-
} else if (res.sessions) {
|
2744
|
-
// For now we don't chunk for a single room backup, but we could in the future.
|
2745
|
-
// Currently it is not used by the application.
|
2746
|
-
var sessions = res.sessions;
|
2747
|
-
totalKeyCount = Object.keys(sessions).length;
|
2748
|
-
var keys = yield backupDecryptor.decryptSessions(sessions);
|
2749
|
-
for (var _k of keys) {
|
2750
|
-
_k.room_id = targetRoomId;
|
2751
|
-
}
|
2752
|
-
yield _this26.cryptoBackend.importBackedUpRoomKeys(keys, backupVersion, {
|
2753
|
-
progressCallback,
|
2754
|
-
untrusted
|
2755
|
-
});
|
2756
|
-
totalImported = keys.length;
|
2757
|
-
} else {
|
2758
|
-
totalKeyCount = 1;
|
2759
|
-
try {
|
2760
|
-
var [_key2] = yield backupDecryptor.decryptSessions({
|
2761
|
-
[targetSessionId]: res
|
2762
|
-
});
|
2763
|
-
_key2.room_id = targetRoomId;
|
2764
|
-
_key2.session_id = targetSessionId;
|
2765
|
-
yield _this26.cryptoBackend.importBackedUpRoomKeys([_key2], backupVersion, {
|
2766
|
-
progressCallback,
|
2767
|
-
untrusted
|
2768
|
-
});
|
2769
|
-
totalImported = 1;
|
2770
|
-
} catch (e) {
|
2771
|
-
_this26.logger.debug("Failed to decrypt megolm session from backup", e);
|
2772
|
-
}
|
2773
|
-
}
|
2774
|
-
} finally {
|
2775
|
-
backupDecryptor.free();
|
2776
|
-
}
|
2777
|
-
|
2778
|
-
/// in case entering the passphrase would add a new signature?
|
2779
|
-
yield _this26.cryptoBackend.checkKeyBackupAndEnable();
|
2780
|
-
return {
|
2781
|
-
total: totalKeyCount,
|
2782
|
-
imported: totalImported
|
2783
|
-
};
|
2784
|
-
})();
|
607
|
+
*
|
608
|
+
* @returns the globl notification EventTimelineSet
|
609
|
+
*/
|
610
|
+
getNotifTimelineSet() {
|
611
|
+
return this.notifTimelineSet;
|
2785
612
|
}
|
2786
613
|
|
2787
614
|
/**
|
2788
|
-
*
|
2789
|
-
*
|
2790
|
-
* @param res - The response from the server containing the keys to be counted.
|
615
|
+
* Set the global notification EventTimelineSet
|
2791
616
|
*
|
2792
|
-
|
2793
|
-
|
2794
|
-
|
2795
|
-
var rooms = res.rooms;
|
2796
|
-
var totalKeyCount = 0;
|
2797
|
-
for (var roomData of Object.values(rooms)) {
|
2798
|
-
if (!roomData.sessions) continue;
|
2799
|
-
totalKeyCount += Object.keys(roomData.sessions).length;
|
2800
|
-
}
|
2801
|
-
return totalKeyCount;
|
617
|
+
*/
|
618
|
+
setNotifTimelineSet(set) {
|
619
|
+
this.notifTimelineSet = set;
|
2802
620
|
}
|
2803
621
|
|
2804
622
|
/**
|
2805
|
-
*
|
2806
|
-
*
|
2807
|
-
*
|
2808
|
-
* @param res - The response from the server containing the keys to be decrypted.
|
2809
|
-
* @param backupDecryptor - An instance of the BackupDecryptor class used to decrypt the keys.
|
2810
|
-
* @param chunkSize - The size of the chunks to be processed at a time.
|
2811
|
-
* @param block - A callback function that is called for each chunk of keys.
|
623
|
+
* Gets the cached capabilities of the homeserver, returning cached ones if available.
|
624
|
+
* If there are no cached capabilities and none can be fetched, throw an exception.
|
2812
625
|
*
|
2813
|
-
* @returns
|
626
|
+
* @returns Promise resolving with The capabilities of the homeserver
|
2814
627
|
*/
|
2815
|
-
|
628
|
+
getCapabilities() {
|
629
|
+
var _this3 = this;
|
2816
630
|
return _asyncToGenerator(function* () {
|
2817
|
-
var
|
2818
|
-
|
2819
|
-
|
2820
|
-
var handleChunkCallback = /*#__PURE__*/function () {
|
2821
|
-
var _ref4 = _asyncToGenerator(function* (roomChunks) {
|
2822
|
-
var currentChunk = [];
|
2823
|
-
for (var _roomId of roomChunks.keys()) {
|
2824
|
-
var decryptedSessions = yield backupDecryptor.decryptSessions(roomChunks.get(_roomId));
|
2825
|
-
for (var _sessionId in decryptedSessions) {
|
2826
|
-
var _k2 = decryptedSessions[_sessionId];
|
2827
|
-
_k2.room_id = _roomId;
|
2828
|
-
currentChunk.push(_k2);
|
2829
|
-
}
|
2830
|
-
}
|
2831
|
-
yield block(currentChunk);
|
2832
|
-
});
|
2833
|
-
return function handleChunkCallback(_x3) {
|
2834
|
-
return _ref4.apply(this, arguments);
|
2835
|
-
};
|
2836
|
-
}();
|
2837
|
-
for (var [_roomId2, roomData] of Object.entries(rooms)) {
|
2838
|
-
if (!roomData.sessions) continue;
|
2839
|
-
chunkGroupByRoom.set(_roomId2, {});
|
2840
|
-
for (var [_sessionId2, session] of Object.entries(roomData.sessions)) {
|
2841
|
-
var sessionsForRoom = chunkGroupByRoom.get(_roomId2);
|
2842
|
-
sessionsForRoom[_sessionId2] = session;
|
2843
|
-
groupChunkCount += 1;
|
2844
|
-
if (groupChunkCount >= chunkSize) {
|
2845
|
-
// We have enough chunks to decrypt
|
2846
|
-
yield handleChunkCallback(chunkGroupByRoom);
|
2847
|
-
chunkGroupByRoom = new Map();
|
2848
|
-
// There might be remaining keys for that room, so add back an entry for the current room.
|
2849
|
-
chunkGroupByRoom.set(_roomId2, {});
|
2850
|
-
groupChunkCount = 0;
|
2851
|
-
}
|
2852
|
-
}
|
2853
|
-
}
|
2854
|
-
|
2855
|
-
// Handle remaining chunk if needed
|
2856
|
-
if (groupChunkCount > 0) {
|
2857
|
-
yield handleChunkCallback(chunkGroupByRoom);
|
2858
|
-
}
|
631
|
+
var caps = _this3.serverCapabilitiesService.getCachedCapabilities();
|
632
|
+
if (caps) return caps;
|
633
|
+
return _this3.serverCapabilitiesService.fetchCapabilities();
|
2859
634
|
})();
|
2860
635
|
}
|
2861
|
-
|
2862
|
-
|
636
|
+
|
637
|
+
/**
|
638
|
+
* Gets the cached capabilities of the homeserver. If none have been fetched yet,
|
639
|
+
* return undefined.
|
640
|
+
*
|
641
|
+
* @returns The capabilities of the homeserver
|
642
|
+
*/
|
643
|
+
getCachedCapabilities() {
|
644
|
+
return this.serverCapabilitiesService.getCachedCapabilities();
|
645
|
+
}
|
646
|
+
|
647
|
+
/**
|
648
|
+
* Fetches the latest capabilities from the homeserver, ignoring any cached
|
649
|
+
* versions. The newly returned version is cached.
|
650
|
+
*
|
651
|
+
* @returns A promise which resolves to the capabilities of the homeserver
|
652
|
+
*/
|
653
|
+
fetchCapabilities() {
|
654
|
+
return this.serverCapabilitiesService.fetchCapabilities();
|
655
|
+
}
|
656
|
+
|
657
|
+
/**
|
658
|
+
* @deprecated Does nothing.
|
659
|
+
*/
|
660
|
+
uploadKeys() {
|
661
|
+
var _this4 = this;
|
2863
662
|
return _asyncToGenerator(function* () {
|
2864
|
-
|
2865
|
-
yield _this27.http.authedRequest(Method.Delete, path.path, path.queryData, undefined, {
|
2866
|
-
prefix: ClientPrefix.V3
|
2867
|
-
});
|
663
|
+
_this4.logger.warn("MatrixClient.uploadKeys is deprecated");
|
2868
664
|
})();
|
2869
665
|
}
|
2870
666
|
|
@@ -2986,10 +782,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
2986
782
|
* @returns Rejects: with an error response.
|
2987
783
|
*/
|
2988
784
|
getAccountDataFromServer(eventType) {
|
2989
|
-
var
|
785
|
+
var _this5 = this;
|
2990
786
|
return _asyncToGenerator(function* () {
|
2991
|
-
if (
|
2992
|
-
var _event =
|
787
|
+
if (_this5.isInitialSyncComplete()) {
|
788
|
+
var _event = _this5.store.getAccountData(eventType);
|
2993
789
|
if (!_event) {
|
2994
790
|
return null;
|
2995
791
|
}
|
@@ -2998,11 +794,11 @@ export class MatrixClient extends TypedEventEmitter {
|
|
2998
794
|
return _event.getContent();
|
2999
795
|
}
|
3000
796
|
var path = utils.encodeUri("/user/$userId/account_data/$type", {
|
3001
|
-
$userId:
|
797
|
+
$userId: _this5.credentials.userId,
|
3002
798
|
$type: eventType
|
3003
799
|
});
|
3004
800
|
try {
|
3005
|
-
return yield
|
801
|
+
return yield _this5.http.authedRequest(Method.Get, path);
|
3006
802
|
} catch (e) {
|
3007
803
|
var _data;
|
3008
804
|
if (((_data = e.data) === null || _data === void 0 ? void 0 : _data.errcode) === "M_NOT_FOUND") {
|
@@ -3013,22 +809,22 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3013
809
|
})();
|
3014
810
|
}
|
3015
811
|
deleteAccountData(eventType) {
|
3016
|
-
var
|
812
|
+
var _this6 = this;
|
3017
813
|
return _asyncToGenerator(function* () {
|
3018
|
-
var msc3391DeleteAccountDataServerSupport =
|
814
|
+
var msc3391DeleteAccountDataServerSupport = _this6.canSupport.get(Feature.AccountDataDeletion);
|
3019
815
|
// if deletion is not supported overwrite with empty content
|
3020
816
|
if (msc3391DeleteAccountDataServerSupport === ServerSupport.Unsupported) {
|
3021
|
-
yield
|
817
|
+
yield _this6.setAccountData(eventType, {});
|
3022
818
|
return;
|
3023
819
|
}
|
3024
820
|
var path = utils.encodeUri("/user/$userId/account_data/$type", {
|
3025
|
-
$userId:
|
821
|
+
$userId: _this6.getSafeUserId(),
|
3026
822
|
$type: eventType
|
3027
823
|
});
|
3028
824
|
var options = msc3391DeleteAccountDataServerSupport === ServerSupport.Unstable ? {
|
3029
825
|
prefix: "/_matrix/client/unstable/org.matrix.msc3391"
|
3030
826
|
} : undefined;
|
3031
|
-
return yield
|
827
|
+
return yield _this6.http.authedRequest(Method.Delete, path, undefined, undefined, options);
|
3032
828
|
})();
|
3033
829
|
}
|
3034
830
|
|
@@ -3075,20 +871,20 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3075
871
|
* @returns Rejects: with an error response.
|
3076
872
|
*/
|
3077
873
|
joinRoom(roomIdOrAlias) {
|
3078
|
-
var
|
3079
|
-
|
874
|
+
var _arguments = arguments,
|
875
|
+
_this7 = this;
|
3080
876
|
return _asyncToGenerator(function* () {
|
3081
|
-
var opts =
|
877
|
+
var opts = _arguments.length > 1 && _arguments[1] !== undefined ? _arguments[1] : {};
|
3082
878
|
if (opts.syncRoom === undefined) {
|
3083
879
|
opts.syncRoom = true;
|
3084
880
|
}
|
3085
|
-
var room =
|
3086
|
-
if (room !== null && room !== void 0 && room.hasMembershipState(
|
881
|
+
var room = _this7.getRoom(roomIdOrAlias);
|
882
|
+
if (room !== null && room !== void 0 && room.hasMembershipState(_this7.credentials.userId, KnownMembership.Join)) return room;
|
3087
883
|
var signPromise = Promise.resolve();
|
3088
884
|
if (opts.inviteSignUrl) {
|
3089
885
|
var _url = new URL(opts.inviteSignUrl);
|
3090
|
-
_url.searchParams.set("mxid",
|
3091
|
-
signPromise =
|
886
|
+
_url.searchParams.set("mxid", _this7.credentials.userId);
|
887
|
+
signPromise = _this7.http.requestOtherUrl(Method.Post, _url);
|
3092
888
|
}
|
3093
889
|
var queryParams = {};
|
3094
890
|
if (opts.viaServers) {
|
@@ -3104,14 +900,14 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3104
900
|
var path = utils.encodeUri("/join/$roomid", {
|
3105
901
|
$roomid: roomIdOrAlias
|
3106
902
|
});
|
3107
|
-
var res = yield
|
903
|
+
var res = yield _this7.http.authedRequest(Method.Post, path, queryParams, data);
|
3108
904
|
var roomId = res.room_id;
|
3109
905
|
// In case we were originally given an alias, check the room cache again
|
3110
906
|
// with the resolved ID - this method is supposed to no-op if we already
|
3111
907
|
// were in the room, after all.
|
3112
|
-
var resolvedRoom =
|
3113
|
-
if (resolvedRoom !== null && resolvedRoom !== void 0 && resolvedRoom.hasMembershipState(
|
3114
|
-
var syncApi = new SyncApi(
|
908
|
+
var resolvedRoom = _this7.getRoom(roomId);
|
909
|
+
if (resolvedRoom !== null && resolvedRoom !== void 0 && resolvedRoom.hasMembershipState(_this7.credentials.userId, KnownMembership.Join)) return resolvedRoom;
|
910
|
+
var syncApi = new SyncApi(_this7, _this7.clientOpts, _this7.buildSyncApiOptions());
|
3115
911
|
var syncRoom = syncApi.createRoom(roomId);
|
3116
912
|
if (opts.syncRoom) {
|
3117
913
|
// v2 will do this for us
|
@@ -3281,17 +1077,17 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3281
1077
|
* @returns Rejects: with an error response.
|
3282
1078
|
*/
|
3283
1079
|
setPowerLevel(roomId, userId, powerLevel) {
|
3284
|
-
var
|
1080
|
+
var _this8 = this;
|
3285
1081
|
return _asyncToGenerator(function* () {
|
3286
1082
|
var _content;
|
3287
1083
|
var content;
|
3288
|
-
if (
|
3289
|
-
var
|
3290
|
-
content = (
|
1084
|
+
if (_this8.clientRunning && _this8.isInitialSyncComplete()) {
|
1085
|
+
var _this8$getRoom;
|
1086
|
+
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();
|
3291
1087
|
}
|
3292
1088
|
if (!content) {
|
3293
1089
|
try {
|
3294
|
-
content = yield
|
1090
|
+
content = yield _this8.getStateEvent(roomId, EventType.RoomPowerLevels, "");
|
3295
1091
|
} catch (e) {
|
3296
1092
|
// It is possible for a Matrix room to not have a power levels event
|
3297
1093
|
if (e instanceof MatrixError && e.errcode === "M_NOT_FOUND") {
|
@@ -3316,7 +1112,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3316
1112
|
content.users[user] = powerLevel;
|
3317
1113
|
}
|
3318
1114
|
}
|
3319
|
-
return
|
1115
|
+
return _this8.sendStateEvent(roomId, EventType.RoomPowerLevels, content, "");
|
3320
1116
|
})();
|
3321
1117
|
}
|
3322
1118
|
|
@@ -3326,9 +1122,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3326
1122
|
*/
|
3327
1123
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
3328
1124
|
unstable_createLiveBeacon(roomId, beaconInfoContent) {
|
3329
|
-
var
|
1125
|
+
var _this9 = this;
|
3330
1126
|
return _asyncToGenerator(function* () {
|
3331
|
-
return
|
1127
|
+
return _this9.unstable_setLiveBeacon(roomId, beaconInfoContent);
|
3332
1128
|
})();
|
3333
1129
|
}
|
3334
1130
|
|
@@ -3340,9 +1136,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3340
1136
|
*/
|
3341
1137
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
3342
1138
|
unstable_setLiveBeacon(roomId, beaconInfoContent) {
|
3343
|
-
var
|
1139
|
+
var _this10 = this;
|
3344
1140
|
return _asyncToGenerator(function* () {
|
3345
|
-
return
|
1141
|
+
return _this10.sendStateEvent(roomId, M_BEACON_INFO.name, beaconInfoContent, _this10.getUserId());
|
3346
1142
|
})();
|
3347
1143
|
}
|
3348
1144
|
sendEvent(roomId, threadIdOrEventType, eventTypeOrContent, contentOrTxnId, txnIdOrVoid) {
|
@@ -3490,44 +1286,34 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3490
1286
|
*/
|
3491
1287
|
|
3492
1288
|
encryptAndSendEvent(room, event, delayOpts) {
|
3493
|
-
var
|
1289
|
+
var _this11 = this;
|
3494
1290
|
return _asyncToGenerator(function* () {
|
3495
1291
|
if (delayOpts) {
|
3496
|
-
return
|
1292
|
+
return _this11.sendEventHttpRequest(event, delayOpts);
|
3497
1293
|
}
|
3498
1294
|
try {
|
3499
|
-
|
3500
|
-
_this34.eventsBeingEncrypted.add(event.getId());
|
3501
|
-
try {
|
3502
|
-
yield _this34.encryptEventIfNeeded(event, room !== null && room !== void 0 ? room : undefined);
|
3503
|
-
} finally {
|
3504
|
-
cancelled = !_this34.eventsBeingEncrypted.delete(event.getId());
|
3505
|
-
}
|
3506
|
-
if (cancelled) {
|
3507
|
-
// cancelled via MatrixClient::cancelPendingEvent
|
3508
|
-
return {};
|
3509
|
-
}
|
1295
|
+
_this11.eventsBeingEncrypted.add(event.getId());
|
3510
1296
|
|
3511
1297
|
// encryptEventIfNeeded may have updated the status from SENDING to ENCRYPTING. If so, we need
|
3512
1298
|
// to put it back.
|
3513
1299
|
if (event.status === EventStatus.ENCRYPTING) {
|
3514
|
-
|
1300
|
+
_this11.updatePendingEventStatus(room, event, EventStatus.SENDING);
|
3515
1301
|
}
|
3516
1302
|
var promise = null;
|
3517
|
-
if (
|
1303
|
+
if (_this11.scheduler) {
|
3518
1304
|
// if this returns a promise then the scheduler has control now and will
|
3519
1305
|
// resolve/reject when it is done. Internally, the scheduler will invoke
|
3520
1306
|
// processFn which is set to this._sendEventHttpRequest so the same code
|
3521
1307
|
// path is executed regardless.
|
3522
|
-
promise =
|
3523
|
-
if (promise &&
|
1308
|
+
promise = _this11.scheduler.queueEvent(event);
|
1309
|
+
if (promise && _this11.scheduler.getQueueForEvent(event).length > 1) {
|
3524
1310
|
// event is processed FIFO so if the length is 2 or more we know
|
3525
1311
|
// this event is stuck behind an earlier event.
|
3526
|
-
|
1312
|
+
_this11.updatePendingEventStatus(room, event, EventStatus.QUEUED);
|
3527
1313
|
}
|
3528
1314
|
}
|
3529
1315
|
if (!promise) {
|
3530
|
-
promise =
|
1316
|
+
promise = _this11.sendEventHttpRequest(event);
|
3531
1317
|
if (room) {
|
3532
1318
|
promise = promise.then(res => {
|
3533
1319
|
room.updatePendingEvent(event, EventStatus.SENT, res["event_id"]);
|
@@ -3537,15 +1323,15 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3537
1323
|
}
|
3538
1324
|
return yield promise;
|
3539
1325
|
} catch (err) {
|
3540
|
-
|
1326
|
+
_this11.logger.error("Error sending event", err);
|
3541
1327
|
try {
|
3542
1328
|
// set the error on the event before we update the status:
|
3543
1329
|
// updating the status emits the event, so the state should be
|
3544
1330
|
// consistent at that point.
|
3545
1331
|
event.error = err;
|
3546
|
-
|
1332
|
+
_this11.updatePendingEventStatus(room, event, EventStatus.NOT_SENT);
|
3547
1333
|
} catch (e) {
|
3548
|
-
|
1334
|
+
_this11.logger.error("Exception in error handler!", e);
|
3549
1335
|
}
|
3550
1336
|
if (err instanceof MatrixError) {
|
3551
1337
|
err.event = event;
|
@@ -3554,70 +1340,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3554
1340
|
}
|
3555
1341
|
})();
|
3556
1342
|
}
|
3557
|
-
encryptEventIfNeeded(event, room) {
|
3558
|
-
var _this35 = this;
|
3559
|
-
return _asyncToGenerator(function* () {
|
3560
|
-
// If the room is unknown, we cannot encrypt for it
|
3561
|
-
if (!room) return;
|
3562
|
-
if (!(yield _this35.shouldEncryptEventForRoom(event, room))) return;
|
3563
|
-
if (!_this35.cryptoBackend && _this35.usingExternalCrypto) {
|
3564
|
-
// The client has opted to allow sending messages to encrypted
|
3565
|
-
// rooms even if the room is encrypted, and we haven't set up
|
3566
|
-
// crypto. This is useful for users of matrix-org/pantalaimon
|
3567
|
-
return;
|
3568
|
-
}
|
3569
|
-
if (!_this35.cryptoBackend) {
|
3570
|
-
throw new Error("This room is configured to use encryption, but your client does not support encryption.");
|
3571
|
-
}
|
3572
|
-
_this35.updatePendingEventStatus(room, event, EventStatus.ENCRYPTING);
|
3573
|
-
yield _this35.cryptoBackend.encryptEvent(event, room);
|
3574
|
-
})();
|
3575
|
-
}
|
3576
|
-
|
3577
|
-
/**
|
3578
|
-
* Determine whether a given event should be encrypted when we send it to the given room.
|
3579
|
-
*
|
3580
|
-
* This takes into account event type and room configuration.
|
3581
|
-
*/
|
3582
|
-
shouldEncryptEventForRoom(event, room) {
|
3583
|
-
var _this36 = this;
|
3584
|
-
return _asyncToGenerator(function* () {
|
3585
|
-
var _this36$cryptoBackend;
|
3586
|
-
if (event.isEncrypted()) {
|
3587
|
-
// this event has already been encrypted; this happens if the
|
3588
|
-
// encryption step succeeded, but the send step failed on the first
|
3589
|
-
// attempt.
|
3590
|
-
return false;
|
3591
|
-
}
|
3592
|
-
if (event.getType() === EventType.Reaction) {
|
3593
|
-
// For reactions, there is a very little gained by encrypting the entire
|
3594
|
-
// event, as relation data is already kept in the clear. Event
|
3595
|
-
// encryption for a reaction effectively only obscures the event type,
|
3596
|
-
// but the purpose is still obvious from the relation data, so nothing
|
3597
|
-
// is really gained. It also causes quite a few problems, such as:
|
3598
|
-
// * triggers notifications via default push rules
|
3599
|
-
// * prevents server-side bundling for reactions
|
3600
|
-
// The reaction key / content / emoji value does warrant encrypting, but
|
3601
|
-
// this will be handled separately by encrypting just this value.
|
3602
|
-
// See https://github.com/matrix-org/matrix-doc/pull/1849#pullrequestreview-248763642
|
3603
|
-
return false;
|
3604
|
-
}
|
3605
|
-
if (event.isRedaction()) {
|
3606
|
-
// Redactions do not support encryption in the spec at this time.
|
3607
|
-
// Whilst it mostly worked in some clients, it wasn't compliant.
|
3608
|
-
return false;
|
3609
|
-
}
|
3610
|
-
|
3611
|
-
// If the room has an m.room.encryption event, we should encrypt.
|
3612
|
-
if (room.hasEncryptionStateEvent()) return true;
|
3613
|
-
|
3614
|
-
// If we have a crypto impl, and *it* thinks we should encrypt, then we should.
|
3615
|
-
if (yield (_this36$cryptoBackend = _this36.cryptoBackend) === null || _this36$cryptoBackend === void 0 ? void 0 : _this36$cryptoBackend.isEncryptionEnabledInRoom(room.roomId)) return true;
|
3616
|
-
|
3617
|
-
// Otherwise, no need to encrypt.
|
3618
|
-
return false;
|
3619
|
-
})();
|
3620
|
-
}
|
3621
1343
|
|
3622
1344
|
/**
|
3623
1345
|
* Returns the eventType that should be used taking encryption into account
|
@@ -3880,13 +1602,13 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3880
1602
|
*/
|
3881
1603
|
// eslint-disable-next-line
|
3882
1604
|
_unstable_sendDelayedEvent(roomId, delayOpts, threadId, eventType, content, txnId) {
|
3883
|
-
var
|
1605
|
+
var _this12 = this;
|
3884
1606
|
return _asyncToGenerator(function* () {
|
3885
|
-
if (!(yield
|
1607
|
+
if (!(yield _this12.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
|
3886
1608
|
throw Error("Server does not support the delayed events API");
|
3887
1609
|
}
|
3888
|
-
|
3889
|
-
return
|
1610
|
+
_this12.addThreadRelationIfNeeded(content, threadId, roomId);
|
1611
|
+
return _this12.sendCompleteEvent(roomId, threadId, {
|
3890
1612
|
type: eventType,
|
3891
1613
|
content
|
3892
1614
|
}, delayOpts, txnId);
|
@@ -3901,12 +1623,12 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3901
1623
|
*/
|
3902
1624
|
// eslint-disable-next-line
|
3903
1625
|
_unstable_sendDelayedStateEvent(roomId, delayOpts, eventType, content) {
|
3904
|
-
var
|
3905
|
-
|
1626
|
+
var _arguments2 = arguments,
|
1627
|
+
_this13 = this;
|
3906
1628
|
return _asyncToGenerator(function* () {
|
3907
|
-
var stateKey =
|
3908
|
-
var opts =
|
3909
|
-
if (!(yield
|
1629
|
+
var stateKey = _arguments2.length > 4 && _arguments2[4] !== undefined ? _arguments2[4] : "";
|
1630
|
+
var opts = _arguments2.length > 5 && _arguments2[5] !== undefined ? _arguments2[5] : {};
|
1631
|
+
if (!(yield _this13.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
|
3910
1632
|
throw Error("Server does not support the delayed events API");
|
3911
1633
|
}
|
3912
1634
|
var pathParams = {
|
@@ -3918,7 +1640,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3918
1640
|
if (stateKey !== undefined) {
|
3919
1641
|
path = utils.encodeUri(path + "/$stateKey", pathParams);
|
3920
1642
|
}
|
3921
|
-
return
|
1643
|
+
return _this13.http.authedRequest(Method.Put, path, getUnstableDelayQueryOpts(delayOpts), content, opts);
|
3922
1644
|
})();
|
3923
1645
|
}
|
3924
1646
|
|
@@ -3930,15 +1652,15 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3930
1652
|
*/
|
3931
1653
|
// eslint-disable-next-line
|
3932
1654
|
_unstable_getDelayedEvents(fromToken) {
|
3933
|
-
var
|
1655
|
+
var _this14 = this;
|
3934
1656
|
return _asyncToGenerator(function* () {
|
3935
|
-
if (!(yield
|
1657
|
+
if (!(yield _this14.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
|
3936
1658
|
throw Error("Server does not support the delayed events API");
|
3937
1659
|
}
|
3938
1660
|
var queryDict = fromToken ? {
|
3939
1661
|
from: fromToken
|
3940
1662
|
} : undefined;
|
3941
|
-
return yield
|
1663
|
+
return yield _this14.http.authedRequest(Method.Get, "/delayed_events", queryDict, undefined, {
|
3942
1664
|
prefix: "".concat(ClientPrefix.Unstable, "/").concat(UNSTABLE_MSC4140_DELAYED_EVENTS)
|
3943
1665
|
});
|
3944
1666
|
})();
|
@@ -3952,9 +1674,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3952
1674
|
*/
|
3953
1675
|
// eslint-disable-next-line
|
3954
1676
|
_unstable_updateDelayedEvent(delayId, action) {
|
3955
|
-
var
|
1677
|
+
var _this15 = this;
|
3956
1678
|
return _asyncToGenerator(function* () {
|
3957
|
-
if (!(yield
|
1679
|
+
if (!(yield _this15.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
|
3958
1680
|
throw Error("Server does not support the delayed events API");
|
3959
1681
|
}
|
3960
1682
|
var path = utils.encodeUri("/delayed_events/$delayId", {
|
@@ -3963,7 +1685,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3963
1685
|
var data = {
|
3964
1686
|
action
|
3965
1687
|
};
|
3966
|
-
return yield
|
1688
|
+
return yield _this15.http.authedRequest(Method.Post, path, undefined, data, {
|
3967
1689
|
prefix: "".concat(ClientPrefix.Unstable, "/").concat(UNSTABLE_MSC4140_DELAYED_EVENTS)
|
3968
1690
|
});
|
3969
1691
|
})();
|
@@ -3980,11 +1702,11 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3980
1702
|
* @returns Rejects: with an error response.
|
3981
1703
|
*/
|
3982
1704
|
sendReceipt(event, receiptType, body) {
|
3983
|
-
var
|
3984
|
-
|
1705
|
+
var _arguments3 = arguments,
|
1706
|
+
_this16 = this;
|
3985
1707
|
return _asyncToGenerator(function* () {
|
3986
|
-
var unthreaded =
|
3987
|
-
if (
|
1708
|
+
var unthreaded = _arguments3.length > 3 && _arguments3[3] !== undefined ? _arguments3[3] : false;
|
1709
|
+
if (_this16.isGuest()) {
|
3988
1710
|
return Promise.resolve({}); // guests cannot send receipts so don't bother.
|
3989
1711
|
}
|
3990
1712
|
var path = utils.encodeUri("/rooms/$roomId/receipt/$receiptType/$eventId", {
|
@@ -3995,14 +1717,14 @@ export class MatrixClient extends TypedEventEmitter {
|
|
3995
1717
|
|
3996
1718
|
// Unless we're explicitly making an unthreaded receipt or we don't
|
3997
1719
|
// support threads, include the `thread_id` property in the body.
|
3998
|
-
var shouldAddThreadId = !unthreaded &&
|
1720
|
+
var shouldAddThreadId = !unthreaded && _this16.supportsThreads();
|
3999
1721
|
var fullBody = shouldAddThreadId ? _objectSpread(_objectSpread({}, body), {}, {
|
4000
1722
|
thread_id: threadIdForReceipt(event)
|
4001
1723
|
}) : body;
|
4002
|
-
var promise =
|
4003
|
-
var room =
|
4004
|
-
if (room &&
|
4005
|
-
room.addLocalEchoReceipt(
|
1724
|
+
var promise = _this16.http.authedRequest(Method.Post, path, undefined, fullBody || {});
|
1725
|
+
var room = _this16.getRoom(event.getRoomId());
|
1726
|
+
if (room && _this16.credentials.userId) {
|
1727
|
+
room.addLocalEchoReceipt(_this16.credentials.userId, event, receiptType, unthreaded);
|
4006
1728
|
}
|
4007
1729
|
return promise;
|
4008
1730
|
})();
|
@@ -4016,18 +1738,18 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4016
1738
|
* @returns Rejects: with an error response.
|
4017
1739
|
*/
|
4018
1740
|
sendReadReceipt(event) {
|
4019
|
-
var
|
4020
|
-
|
1741
|
+
var _arguments4 = arguments,
|
1742
|
+
_this17 = this;
|
4021
1743
|
return _asyncToGenerator(function* () {
|
4022
|
-
var receiptType =
|
4023
|
-
var unthreaded =
|
1744
|
+
var receiptType = _arguments4.length > 1 && _arguments4[1] !== undefined ? _arguments4[1] : ReceiptType.Read;
|
1745
|
+
var unthreaded = _arguments4.length > 2 && _arguments4[2] !== undefined ? _arguments4[2] : false;
|
4024
1746
|
if (!event) return;
|
4025
1747
|
var eventId = event.getId();
|
4026
|
-
var room =
|
1748
|
+
var room = _this17.getRoom(event.getRoomId());
|
4027
1749
|
if (room !== null && room !== void 0 && room.hasPendingEvent(eventId)) {
|
4028
1750
|
throw new Error("Cannot set read receipt to a pending event (".concat(eventId, ")"));
|
4029
1751
|
}
|
4030
|
-
return
|
1752
|
+
return _this17.sendReceipt(event, receiptType, {}, unthreaded);
|
4031
1753
|
})();
|
4032
1754
|
}
|
4033
1755
|
|
@@ -4046,9 +1768,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4046
1768
|
* @returns Promise which resolves: the empty object, `{}`.
|
4047
1769
|
*/
|
4048
1770
|
setRoomReadMarkers(roomId, rmEventId, rrEvent, rpEvent) {
|
4049
|
-
var
|
1771
|
+
var _this18 = this;
|
4050
1772
|
return _asyncToGenerator(function* () {
|
4051
|
-
var room =
|
1773
|
+
var room = _this18.getRoom(roomId);
|
4052
1774
|
if (room !== null && room !== void 0 && room.hasPendingEvent(rmEventId)) {
|
4053
1775
|
throw new Error("Cannot set read marker to a pending event (".concat(rmEventId, ")"));
|
4054
1776
|
}
|
@@ -4060,7 +1782,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4060
1782
|
if (room !== null && room !== void 0 && room.hasPendingEvent(rrEventId)) {
|
4061
1783
|
throw new Error("Cannot set read receipt to a pending event (".concat(rrEventId, ")"));
|
4062
1784
|
}
|
4063
|
-
room === null || room === void 0 || room.addLocalEchoReceipt(
|
1785
|
+
room === null || room === void 0 || room.addLocalEchoReceipt(_this18.credentials.userId, rrEvent, ReceiptType.Read);
|
4064
1786
|
}
|
4065
1787
|
|
4066
1788
|
// Add the optional private RR update, do local echo like `sendReceipt`
|
@@ -4070,9 +1792,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4070
1792
|
if (room !== null && room !== void 0 && room.hasPendingEvent(rpEventId)) {
|
4071
1793
|
throw new Error("Cannot set read receipt to a pending event (".concat(rpEventId, ")"));
|
4072
1794
|
}
|
4073
|
-
room === null || room === void 0 || room.addLocalEchoReceipt(
|
1795
|
+
room === null || room === void 0 || room.addLocalEchoReceipt(_this18.credentials.userId, rpEvent, ReceiptType.ReadPrivate);
|
4074
1796
|
}
|
4075
|
-
return yield
|
1797
|
+
return yield _this18.setRoomReadMarkersHttpRequest(roomId, rmEventId, rrEventId, rpEventId);
|
4076
1798
|
})();
|
4077
1799
|
}
|
4078
1800
|
|
@@ -4256,13 +1978,13 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4256
1978
|
* @returns Rejects: with an error response.
|
4257
1979
|
*/
|
4258
1980
|
inviteByThreePid(roomId, medium, address) {
|
4259
|
-
var
|
1981
|
+
var _this19 = this;
|
4260
1982
|
return _asyncToGenerator(function* () {
|
4261
|
-
var
|
1983
|
+
var _this19$identityServe;
|
4262
1984
|
var path = utils.encodeUri("/rooms/$roomId/invite", {
|
4263
1985
|
$roomId: roomId
|
4264
1986
|
});
|
4265
|
-
var identityServerUrl =
|
1987
|
+
var identityServerUrl = _this19.getIdentityServerUrl(true);
|
4266
1988
|
if (!identityServerUrl) {
|
4267
1989
|
return Promise.reject(new MatrixError({
|
4268
1990
|
error: "No supplied identity server URL",
|
@@ -4274,13 +1996,13 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4274
1996
|
medium: medium,
|
4275
1997
|
address: address
|
4276
1998
|
};
|
4277
|
-
if ((
|
4278
|
-
var identityAccessToken = yield
|
1999
|
+
if ((_this19$identityServe = _this19.identityServer) !== null && _this19$identityServe !== void 0 && _this19$identityServe.getAccessToken) {
|
2000
|
+
var identityAccessToken = yield _this19.identityServer.getAccessToken();
|
4279
2001
|
if (identityAccessToken) {
|
4280
2002
|
params["id_access_token"] = identityAccessToken;
|
4281
2003
|
}
|
4282
2004
|
}
|
4283
|
-
return
|
2005
|
+
return _this19.http.authedRequest(Method.Post, path, undefined, params);
|
4284
2006
|
})();
|
4285
2007
|
}
|
4286
2008
|
|
@@ -4348,18 +2070,18 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4348
2070
|
* @returns Rejects: with an error response.
|
4349
2071
|
*/
|
4350
2072
|
forget(roomId) {
|
4351
|
-
var
|
4352
|
-
|
2073
|
+
var _arguments5 = arguments,
|
2074
|
+
_this20 = this;
|
4353
2075
|
return _asyncToGenerator(function* () {
|
4354
|
-
var deleteRoom =
|
2076
|
+
var deleteRoom = _arguments5.length > 1 && _arguments5[1] !== undefined ? _arguments5[1] : true;
|
4355
2077
|
// API returns an empty object
|
4356
2078
|
var path = utils.encodeUri("/rooms/$room_id/forget", {
|
4357
2079
|
$room_id: roomId
|
4358
2080
|
});
|
4359
|
-
var response = yield
|
2081
|
+
var response = yield _this20.http.authedRequest(Method.Post, path);
|
4360
2082
|
if (deleteRoom) {
|
4361
|
-
|
4362
|
-
|
2083
|
+
_this20.store.removeRoom(roomId);
|
2084
|
+
_this20.emit(ClientEvent.DeleteRoom, roomId);
|
4363
2085
|
}
|
4364
2086
|
return response;
|
4365
2087
|
})();
|
@@ -4473,13 +2195,13 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4473
2195
|
* @returns Rejects: with an error response.
|
4474
2196
|
*/
|
4475
2197
|
setDisplayName(name) {
|
4476
|
-
var
|
2198
|
+
var _this21 = this;
|
4477
2199
|
return _asyncToGenerator(function* () {
|
4478
|
-
var prom = yield
|
2200
|
+
var prom = yield _this21.setProfileInfo("displayname", {
|
4479
2201
|
displayname: name
|
4480
2202
|
});
|
4481
2203
|
// XXX: synthesise a profile update for ourselves because Synapse is broken and won't
|
4482
|
-
var user =
|
2204
|
+
var user = _this21.getUser(_this21.getUserId());
|
4483
2205
|
if (user) {
|
4484
2206
|
user.displayName = name;
|
4485
2207
|
user.emit(UserEvent.DisplayName, user.events.presence, user);
|
@@ -4493,13 +2215,13 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4493
2215
|
* @returns Rejects: with an error response.
|
4494
2216
|
*/
|
4495
2217
|
setAvatarUrl(url) {
|
4496
|
-
var
|
2218
|
+
var _this22 = this;
|
4497
2219
|
return _asyncToGenerator(function* () {
|
4498
|
-
var prom = yield
|
2220
|
+
var prom = yield _this22.setProfileInfo("avatar_url", {
|
4499
2221
|
avatar_url: url
|
4500
2222
|
});
|
4501
2223
|
// XXX: synthesise a profile update for ourselves because Synapse is broken and won't
|
4502
|
-
var user =
|
2224
|
+
var user = _this22.getUser(_this22.getUserId());
|
4503
2225
|
if (user) {
|
4504
2226
|
user.avatarUrl = url;
|
4505
2227
|
user.emit(UserEvent.AvatarUrl, user.events.presence, user);
|
@@ -4540,10 +2262,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4540
2262
|
* @param presence - the presence to specify to set_presence of sync calls
|
4541
2263
|
*/
|
4542
2264
|
setSyncPresence(presence) {
|
4543
|
-
var
|
2265
|
+
var _this23 = this;
|
4544
2266
|
return _asyncToGenerator(function* () {
|
4545
|
-
var
|
4546
|
-
(
|
2267
|
+
var _this23$syncApi;
|
2268
|
+
(_this23$syncApi = _this23.syncApi) === null || _this23$syncApi === void 0 || _this23$syncApi.setPresence(presence);
|
4547
2269
|
})();
|
4548
2270
|
}
|
4549
2271
|
|
@@ -4554,16 +2276,16 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4554
2276
|
* @throws If 'presence' isn't a valid presence enum value.
|
4555
2277
|
*/
|
4556
2278
|
setPresence(opts) {
|
4557
|
-
var
|
2279
|
+
var _this24 = this;
|
4558
2280
|
return _asyncToGenerator(function* () {
|
4559
2281
|
var path = utils.encodeUri("/presence/$userId/status", {
|
4560
|
-
$userId:
|
2282
|
+
$userId: _this24.credentials.userId
|
4561
2283
|
});
|
4562
2284
|
var validStates = ["offline", "online", "unavailable"];
|
4563
2285
|
if (validStates.indexOf(opts.presence) === -1) {
|
4564
2286
|
throw new Error("Bad presence value: " + opts.presence);
|
4565
2287
|
}
|
4566
|
-
yield
|
2288
|
+
yield _this24.http.authedRequest(Method.Put, path, undefined, opts);
|
4567
2289
|
})();
|
4568
2290
|
}
|
4569
2291
|
|
@@ -4672,11 +2394,11 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4672
2394
|
* {@link EventTimeline} including the given event
|
4673
2395
|
*/
|
4674
2396
|
getEventTimeline(timelineSet, eventId) {
|
4675
|
-
var
|
2397
|
+
var _this25 = this;
|
4676
2398
|
return _asyncToGenerator(function* () {
|
4677
|
-
var
|
2399
|
+
var _this25$clientOpts, _ref2, _timelineSet$getTimel, _timelineSet$room$fin;
|
4678
2400
|
// don't allow any timeline support unless it's been enabled.
|
4679
|
-
if (!
|
2401
|
+
if (!_this25.timelineSupport) {
|
4680
2402
|
throw new Error("timeline support is disabled. Set the 'timelineSupport'" + " parameter to true when creating MatrixClient to enable it.");
|
4681
2403
|
}
|
4682
2404
|
if (!(timelineSet !== null && timelineSet !== void 0 && timelineSet.room)) {
|
@@ -4685,22 +2407,22 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4685
2407
|
if (timelineSet.getTimelineForEvent(eventId)) {
|
4686
2408
|
return timelineSet.getTimelineForEvent(eventId);
|
4687
2409
|
}
|
4688
|
-
if (timelineSet.thread &&
|
4689
|
-
return
|
2410
|
+
if (timelineSet.thread && _this25.supportsThreads()) {
|
2411
|
+
return _this25.getThreadTimeline(timelineSet, eventId);
|
4690
2412
|
}
|
4691
2413
|
var path = utils.encodeUri("/rooms/$roomId/context/$eventId", {
|
4692
2414
|
$roomId: timelineSet.room.roomId,
|
4693
2415
|
$eventId: eventId
|
4694
2416
|
});
|
4695
2417
|
var params = undefined;
|
4696
|
-
if ((
|
2418
|
+
if ((_this25$clientOpts = _this25.clientOpts) !== null && _this25$clientOpts !== void 0 && _this25$clientOpts.lazyLoadMembers) {
|
4697
2419
|
params = {
|
4698
2420
|
filter: JSON.stringify(Filter.LAZY_LOADING_MESSAGES_FILTER)
|
4699
2421
|
};
|
4700
2422
|
}
|
4701
2423
|
|
4702
2424
|
// TODO: we should implement a backoff (as per scrollback()) to deal more nicely with HTTP errors.
|
4703
|
-
var res = yield
|
2425
|
+
var res = yield _this25.http.authedRequest(Method.Get, path, params);
|
4704
2426
|
if (!res.event) {
|
4705
2427
|
throw new Error("'event' not in '/context' result - homeserver too old?");
|
4706
2428
|
}
|
@@ -4709,10 +2431,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4709
2431
|
if (timelineSet.getTimelineForEvent(eventId)) {
|
4710
2432
|
return timelineSet.getTimelineForEvent(eventId);
|
4711
2433
|
}
|
4712
|
-
var mapper =
|
2434
|
+
var mapper = _this25.getEventMapper();
|
4713
2435
|
var event = mapper(res.event);
|
4714
2436
|
if (event.isRelation(THREAD_RELATION_TYPE.name)) {
|
4715
|
-
|
2437
|
+
_this25.logger.warn("Tried loading a regular timeline at the position of a thread event");
|
4716
2438
|
return undefined;
|
4717
2439
|
}
|
4718
2440
|
var events = [
|
@@ -4733,23 +2455,23 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4733
2455
|
var [timelineEvents, threadedEvents, unknownRelations] = timelineSet.room.partitionThreadedEvents(events);
|
4734
2456
|
timelineSet.addEventsToTimeline(timelineEvents, true, timeline, res.start);
|
4735
2457
|
// The target event is not in a thread but process the contextual events, so we can show any threads around it.
|
4736
|
-
|
4737
|
-
|
2458
|
+
_this25.processThreadEvents(timelineSet.room, threadedEvents, true);
|
2459
|
+
_this25.processAggregatedTimelineEvents(timelineSet.room, timelineEvents);
|
4738
2460
|
unknownRelations.forEach(event => timelineSet.relations.aggregateChildEvent(event));
|
4739
2461
|
|
4740
2462
|
// There is no guarantee that the event ended up in "timeline" (we might have switched to a neighbouring
|
4741
2463
|
// timeline) - so check the room's index again. On the other hand, there's no guarantee the event ended up
|
4742
2464
|
// anywhere, if it was later redacted, so we just return the timeline we first thought of.
|
4743
|
-
return (
|
2465
|
+
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 :
|
4744
2466
|
// for Threads degraded support
|
4745
2467
|
timeline;
|
4746
2468
|
})();
|
4747
2469
|
}
|
4748
2470
|
getThreadTimeline(timelineSet, eventId) {
|
4749
|
-
var
|
2471
|
+
var _this26 = this;
|
4750
2472
|
return _asyncToGenerator(function* () {
|
4751
|
-
var
|
4752
|
-
if (!
|
2473
|
+
var _this26$clientOpts;
|
2474
|
+
if (!_this26.supportsThreads()) {
|
4753
2475
|
throw new Error("could not get thread timeline: no client support");
|
4754
2476
|
}
|
4755
2477
|
if (!timelineSet.room) {
|
@@ -4765,18 +2487,18 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4765
2487
|
var params = {
|
4766
2488
|
limit: "0"
|
4767
2489
|
};
|
4768
|
-
if ((
|
2490
|
+
if ((_this26$clientOpts = _this26.clientOpts) !== null && _this26$clientOpts !== void 0 && _this26$clientOpts.lazyLoadMembers) {
|
4769
2491
|
params.filter = JSON.stringify(Filter.LAZY_LOADING_MESSAGES_FILTER);
|
4770
2492
|
}
|
4771
2493
|
|
4772
2494
|
// TODO: we should implement a backoff (as per scrollback()) to deal more nicely with HTTP errors.
|
4773
|
-
var res = yield
|
4774
|
-
var mapper =
|
2495
|
+
var res = yield _this26.http.authedRequest(Method.Get, path, params);
|
2496
|
+
var mapper = _this26.getEventMapper();
|
4775
2497
|
var event = mapper(res.event);
|
4776
2498
|
if (!timelineSet.canContain(event)) {
|
4777
2499
|
return undefined;
|
4778
2500
|
}
|
4779
|
-
var recurse =
|
2501
|
+
var recurse = _this26.canSupport.get(Feature.RelationsRecursion) !== ServerSupport.Unsupported;
|
4780
2502
|
if (Thread.hasServerSideSupport) {
|
4781
2503
|
if (Thread.hasServerSideFwdPaginationSupport) {
|
4782
2504
|
var _resOlder$next_batch, _resNewer$next_batch, _timelineSet$getTimel2;
|
@@ -4784,12 +2506,12 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4784
2506
|
throw new Error("could not get thread timeline: not a thread timeline");
|
4785
2507
|
}
|
4786
2508
|
var thread = timelineSet.thread;
|
4787
|
-
var resOlder = yield
|
2509
|
+
var resOlder = yield _this26.fetchRelations(timelineSet.room.roomId, thread.id, null, null, {
|
4788
2510
|
dir: Direction.Backward,
|
4789
2511
|
from: res.start,
|
4790
2512
|
recurse: recurse || undefined
|
4791
2513
|
});
|
4792
|
-
var resNewer = yield
|
2514
|
+
var resNewer = yield _this26.fetchRelations(timelineSet.room.roomId, thread.id, null, null, {
|
4793
2515
|
dir: Direction.Forward,
|
4794
2516
|
from: res.end,
|
4795
2517
|
recurse: recurse || undefined
|
@@ -4814,12 +2536,12 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4814
2536
|
}
|
4815
2537
|
timelineSet.addEventsToTimeline(events, true, timeline, resNewer.next_batch);
|
4816
2538
|
if (!resOlder.next_batch) {
|
4817
|
-
var originalEvent = yield
|
2539
|
+
var originalEvent = yield _this26.fetchRoomEvent(timelineSet.room.roomId, thread.id);
|
4818
2540
|
timelineSet.addEventsToTimeline([mapper(originalEvent)], true, timeline, null);
|
4819
2541
|
}
|
4820
2542
|
timeline.setPaginationToken((_resOlder$next_batch = resOlder.next_batch) !== null && _resOlder$next_batch !== void 0 ? _resOlder$next_batch : null, Direction.Backward);
|
4821
2543
|
timeline.setPaginationToken((_resNewer$next_batch = resNewer.next_batch) !== null && _resNewer$next_batch !== void 0 ? _resNewer$next_batch : null, Direction.Forward);
|
4822
|
-
|
2544
|
+
_this26.processAggregatedTimelineEvents(timelineSet.room, events);
|
4823
2545
|
|
4824
2546
|
// There is no guarantee that the event ended up in "timeline" (we might have switched to a neighbouring
|
4825
2547
|
// timeline) - so check the room's index again. On the other hand, there's no guarantee the event ended up
|
@@ -4832,7 +2554,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4832
2554
|
// XXX: workaround for https://github.com/vector-im/element-meta/issues/150
|
4833
2555
|
|
4834
2556
|
var _thread = timelineSet.thread;
|
4835
|
-
var _resOlder = yield
|
2557
|
+
var _resOlder = yield _this26.fetchRelations(timelineSet.room.roomId, _thread.id, THREAD_RELATION_TYPE.name, null, {
|
4836
2558
|
dir: Direction.Backward,
|
4837
2559
|
from: res.start,
|
4838
2560
|
recurse: recurse || undefined
|
@@ -4841,7 +2563,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4841
2563
|
var nextBatch = res.end;
|
4842
2564
|
while (nextBatch) {
|
4843
2565
|
var _resNewer$next_batch2;
|
4844
|
-
var _resNewer = yield
|
2566
|
+
var _resNewer = yield _this26.fetchRelations(timelineSet.room.roomId, _thread.id, THREAD_RELATION_TYPE.name, null, {
|
4845
2567
|
dir: Direction.Forward,
|
4846
2568
|
from: nextBatch,
|
4847
2569
|
recurse: recurse || undefined
|
@@ -4865,12 +2587,12 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4865
2587
|
_timeline.getState(EventTimeline.BACKWARDS).setUnknownStateEvents(res.state.map(mapper));
|
4866
2588
|
timelineSet.addEventsToTimeline(_events, true, _timeline, null);
|
4867
2589
|
if (!_resOlder.next_batch) {
|
4868
|
-
var _originalEvent = yield
|
2590
|
+
var _originalEvent = yield _this26.fetchRoomEvent(timelineSet.room.roomId, _thread.id);
|
4869
2591
|
timelineSet.addEventsToTimeline([mapper(_originalEvent)], true, _timeline, null);
|
4870
2592
|
}
|
4871
2593
|
_timeline.setPaginationToken((_resOlder$next_batch2 = _resOlder.next_batch) !== null && _resOlder$next_batch2 !== void 0 ? _resOlder$next_batch2 : null, Direction.Backward);
|
4872
2594
|
_timeline.setPaginationToken(null, Direction.Forward);
|
4873
|
-
|
2595
|
+
_this26.processAggregatedTimelineEvents(timelineSet.room, _events);
|
4874
2596
|
return _timeline;
|
4875
2597
|
}
|
4876
2598
|
}
|
@@ -4888,10 +2610,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4888
2610
|
* {@link EventTimeline} timeline with the latest events in the room
|
4889
2611
|
*/
|
4890
2612
|
getLatestTimeline(timelineSet) {
|
4891
|
-
var
|
2613
|
+
var _this27 = this;
|
4892
2614
|
return _asyncToGenerator(function* () {
|
4893
2615
|
// don't allow any timeline support unless it's been enabled.
|
4894
|
-
if (!
|
2616
|
+
if (!_this27.timelineSupport) {
|
4895
2617
|
throw new Error("timeline support is disabled. Set the 'timelineSupport'" + " parameter to true when creating MatrixClient to enable it.");
|
4896
2618
|
}
|
4897
2619
|
if (!timelineSet.room) {
|
@@ -4900,35 +2622,35 @@ export class MatrixClient extends TypedEventEmitter {
|
|
4900
2622
|
var event;
|
4901
2623
|
if (timelineSet.threadListType !== null) {
|
4902
2624
|
var _res$chunk;
|
4903
|
-
var res = yield
|
2625
|
+
var res = yield _this27.createThreadListMessagesRequest(timelineSet.room.roomId, null, 1, Direction.Backward, timelineSet.threadListType, timelineSet.getFilter());
|
4904
2626
|
event = (_res$chunk = res.chunk) === null || _res$chunk === void 0 ? void 0 : _res$chunk[0];
|
4905
2627
|
} else if (timelineSet.thread && Thread.hasServerSideSupport) {
|
4906
2628
|
var _res$chunk2;
|
4907
|
-
var recurse =
|
4908
|
-
var _res = yield
|
2629
|
+
var recurse = _this27.canSupport.get(Feature.RelationsRecursion) !== ServerSupport.Unsupported;
|
2630
|
+
var _res = yield _this27.fetchRelations(timelineSet.room.roomId, timelineSet.thread.id, THREAD_RELATION_TYPE.name, null, {
|
4909
2631
|
dir: Direction.Backward,
|
4910
2632
|
limit: 1,
|
4911
2633
|
recurse: recurse || undefined
|
4912
2634
|
});
|
4913
2635
|
event = (_res$chunk2 = _res.chunk) === null || _res$chunk2 === void 0 ? void 0 : _res$chunk2[0];
|
4914
2636
|
} else {
|
4915
|
-
var
|
2637
|
+
var _this27$clientOpts, _res2$chunk;
|
4916
2638
|
var messagesPath = utils.encodeUri("/rooms/$roomId/messages", {
|
4917
2639
|
$roomId: timelineSet.room.roomId
|
4918
2640
|
});
|
4919
2641
|
var params = {
|
4920
2642
|
dir: "b"
|
4921
2643
|
};
|
4922
|
-
if ((
|
2644
|
+
if ((_this27$clientOpts = _this27.clientOpts) !== null && _this27$clientOpts !== void 0 && _this27$clientOpts.lazyLoadMembers) {
|
4923
2645
|
params.filter = JSON.stringify(Filter.LAZY_LOADING_MESSAGES_FILTER);
|
4924
2646
|
}
|
4925
|
-
var _res2 = yield
|
2647
|
+
var _res2 = yield _this27.http.authedRequest(Method.Get, messagesPath, params);
|
4926
2648
|
event = (_res2$chunk = _res2.chunk) === null || _res2$chunk === void 0 ? void 0 : _res2$chunk[0];
|
4927
2649
|
}
|
4928
2650
|
if (!event) {
|
4929
2651
|
throw new Error("No message returned when trying to construct getLatestTimeline");
|
4930
2652
|
}
|
4931
|
-
return
|
2653
|
+
return _this27.getEventTimeline(timelineSet, event.event_id);
|
4932
2654
|
})();
|
4933
2655
|
}
|
4934
2656
|
|
@@ -5040,7 +2762,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5040
2762
|
* events and we reached either end of the timeline; else true.
|
5041
2763
|
*/
|
5042
2764
|
paginateEventTimeline(eventTimeline, opts) {
|
5043
|
-
var
|
2765
|
+
var _this28 = this;
|
5044
2766
|
var isNotifTimeline = eventTimeline.getTimelineSet() === this.notifTimelineSet;
|
5045
2767
|
var room = this.getRoom(eventTimeline.getRoomId());
|
5046
2768
|
var threadListType = eventTimeline.getTimelineSet().threadListType;
|
@@ -5076,17 +2798,17 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5076
2798
|
params.from = token;
|
5077
2799
|
}
|
5078
2800
|
promise = this.http.authedRequest(Method.Get, path, params).then(/*#__PURE__*/function () {
|
5079
|
-
var
|
2801
|
+
var _ref3 = _asyncToGenerator(function* (res) {
|
5080
2802
|
var token = res.next_token;
|
5081
2803
|
var matrixEvents = [];
|
5082
2804
|
res.notifications = res.notifications.filter(noUnsafeEventProps);
|
5083
2805
|
for (var i = 0; i < res.notifications.length; i++) {
|
5084
2806
|
var notification = res.notifications[i];
|
5085
|
-
var _event4 =
|
2807
|
+
var _event4 = _this28.getEventMapper()(notification.event);
|
5086
2808
|
|
5087
2809
|
// @TODO(kerrya) reprocessing every notification is ugly
|
5088
2810
|
// remove if we get server MSC3994 support
|
5089
|
-
|
2811
|
+
_this28.getPushDetailsForEvent(_event4, true);
|
5090
2812
|
_event4.event.room_id = notification.room_id; // XXX: gutwrenching
|
5091
2813
|
matrixEvents[i] = _event4;
|
5092
2814
|
}
|
@@ -5095,7 +2817,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5095
2817
|
// in the notification timeline set
|
5096
2818
|
var timelineSet = eventTimeline.getTimelineSet();
|
5097
2819
|
timelineSet.addEventsToTimeline(matrixEvents, backwards, eventTimeline, token);
|
5098
|
-
|
2820
|
+
_this28.processAggregatedTimelineEvents(timelineSet.room, matrixEvents);
|
5099
2821
|
|
5100
2822
|
// if we've hit the end of the timeline, we need to stop trying to
|
5101
2823
|
// paginate. We need to keep the 'forwards' token though, to make sure
|
@@ -5105,8 +2827,8 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5105
2827
|
}
|
5106
2828
|
return Boolean(res.next_token);
|
5107
2829
|
});
|
5108
|
-
return function (
|
5109
|
-
return
|
2830
|
+
return function (_x2) {
|
2831
|
+
return _ref3.apply(this, arguments);
|
5110
2832
|
};
|
5111
2833
|
}()).finally(() => {
|
5112
2834
|
eventTimeline.paginationRequests[dir] = null;
|
@@ -5156,8 +2878,8 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5156
2878
|
from: token !== null && token !== void 0 ? token : undefined,
|
5157
2879
|
recurse: recurse || undefined
|
5158
2880
|
}).then(/*#__PURE__*/function () {
|
5159
|
-
var
|
5160
|
-
var mapper =
|
2881
|
+
var _ref4 = _asyncToGenerator(function* (res) {
|
2882
|
+
var mapper = _this28.getEventMapper();
|
5161
2883
|
var matrixEvents = res.chunk.filter(noUnsafeEventProps).filter(getRelationsThreadFilter(thread.id)).map(mapper);
|
5162
2884
|
|
5163
2885
|
// Process latest events first
|
@@ -5173,10 +2895,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5173
2895
|
timelineSet.addEventsToTimeline(matrixEvents, backwards, eventTimeline, newToken !== null && newToken !== void 0 ? newToken : null);
|
5174
2896
|
if (!newToken && backwards) {
|
5175
2897
|
var _thread$rootEvent, _eventTimeline$getRoo3;
|
5176
|
-
var originalEvent = (_thread$rootEvent = thread.rootEvent) !== null && _thread$rootEvent !== void 0 ? _thread$rootEvent : mapper(yield
|
2898
|
+
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));
|
5177
2899
|
timelineSet.addEventsToTimeline([originalEvent], true, eventTimeline, null);
|
5178
2900
|
}
|
5179
|
-
|
2901
|
+
_this28.processAggregatedTimelineEvents(timelineSet.room, matrixEvents);
|
5180
2902
|
|
5181
2903
|
// if we've hit the end of the timeline, we need to stop trying to
|
5182
2904
|
// paginate. We need to keep the 'forwards' token though, to make sure
|
@@ -5186,8 +2908,8 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5186
2908
|
}
|
5187
2909
|
return Boolean(newToken);
|
5188
2910
|
});
|
5189
|
-
return function (
|
5190
|
-
return
|
2911
|
+
return function (_x3) {
|
2912
|
+
return _ref4.apply(this, arguments);
|
5191
2913
|
};
|
5192
2914
|
}()).finally(() => {
|
5193
2915
|
eventTimeline.paginationRequests[dir] = null;
|
@@ -5462,10 +3184,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5462
3184
|
* @returns Promise which resolves: As requestEmailToken
|
5463
3185
|
*/
|
5464
3186
|
requestTokenFromEndpoint(endpoint, params) {
|
5465
|
-
var
|
3187
|
+
var _this29 = this;
|
5466
3188
|
return _asyncToGenerator(function* () {
|
5467
3189
|
var postParams = Object.assign({}, params);
|
5468
|
-
return
|
3190
|
+
return _this29.http.request(Method.Post, endpoint, undefined, postParams);
|
5469
3191
|
})();
|
5470
3192
|
}
|
5471
3193
|
|
@@ -5760,14 +3482,14 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5760
3482
|
* @returns Filter ID
|
5761
3483
|
*/
|
5762
3484
|
getOrCreateFilter(filterName, filter) {
|
5763
|
-
var
|
3485
|
+
var _this30 = this;
|
5764
3486
|
return _asyncToGenerator(function* () {
|
5765
|
-
var filterId =
|
3487
|
+
var filterId = _this30.store.getFilterIdByName(filterName);
|
5766
3488
|
var existingId;
|
5767
3489
|
if (filterId) {
|
5768
3490
|
// check that the existing filter matches our expectations
|
5769
3491
|
try {
|
5770
|
-
var existingFilter = yield
|
3492
|
+
var existingFilter = yield _this30.getFilter(_this30.credentials.userId, filterId, true);
|
5771
3493
|
if (existingFilter) {
|
5772
3494
|
var oldDef = existingFilter.getDefinition();
|
5773
3495
|
var newDef = filter.getDefinition();
|
@@ -5791,7 +3513,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5791
3513
|
}
|
5792
3514
|
// if the filter doesn't exist anymore on the server, remove from store
|
5793
3515
|
if (!existingId) {
|
5794
|
-
|
3516
|
+
_this30.store.setFilterIdByName(filterName, undefined);
|
5795
3517
|
}
|
5796
3518
|
}
|
5797
3519
|
if (existingId) {
|
@@ -5799,8 +3521,8 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5799
3521
|
}
|
5800
3522
|
|
5801
3523
|
// create a new filter
|
5802
|
-
var createdFilter = yield
|
5803
|
-
|
3524
|
+
var createdFilter = yield _this30.createFilter(filter.getDefinition());
|
3525
|
+
_this30.store.setFilterIdByName(filterName, createdFilter.filterId);
|
5804
3526
|
return createdFilter.filterId;
|
5805
3527
|
})();
|
5806
3528
|
}
|
@@ -5818,84 +3540,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5818
3540
|
});
|
5819
3541
|
return this.http.authedRequest(Method.Post, path, undefined, {});
|
5820
3542
|
}
|
5821
|
-
/**
|
5822
|
-
* @returns Promise which resolves: ITurnServerResponse object
|
5823
|
-
* @returns Rejects: with an error response.
|
5824
|
-
*/
|
5825
|
-
turnServer() {
|
5826
|
-
return this.http.authedRequest(Method.Get, "/voip/turnServer");
|
5827
|
-
}
|
5828
|
-
|
5829
|
-
/**
|
5830
|
-
* Get the TURN servers for this homeserver.
|
5831
|
-
* @returns The servers or an empty list.
|
5832
|
-
*/
|
5833
|
-
getTurnServers() {
|
5834
|
-
return this.turnServers || [];
|
5835
|
-
}
|
5836
|
-
|
5837
|
-
/**
|
5838
|
-
* Get the unix timestamp (in milliseconds) at which the current
|
5839
|
-
* TURN credentials (from getTurnServers) expire
|
5840
|
-
* @returns The expiry timestamp in milliseconds
|
5841
|
-
*/
|
5842
|
-
getTurnServersExpiry() {
|
5843
|
-
return this.turnServersExpiry;
|
5844
|
-
}
|
5845
|
-
get pollingTurnServers() {
|
5846
|
-
return this.checkTurnServersIntervalID !== undefined;
|
5847
|
-
}
|
5848
|
-
|
5849
|
-
// XXX: Intended private, used in code.
|
5850
|
-
checkTurnServers() {
|
5851
|
-
var _this56 = this;
|
5852
|
-
return _asyncToGenerator(function* () {
|
5853
|
-
if (!_this56.canSupportVoip) {
|
5854
|
-
return;
|
5855
|
-
}
|
5856
|
-
var credentialsGood = false;
|
5857
|
-
var remainingTime = _this56.turnServersExpiry - Date.now();
|
5858
|
-
if (remainingTime > TURN_CHECK_INTERVAL) {
|
5859
|
-
_this56.logger.debug("TURN creds are valid for another " + remainingTime + " ms: not fetching new ones.");
|
5860
|
-
credentialsGood = true;
|
5861
|
-
} else {
|
5862
|
-
_this56.logger.debug("Fetching new TURN credentials");
|
5863
|
-
try {
|
5864
|
-
var res = yield _this56.turnServer();
|
5865
|
-
if (res.uris) {
|
5866
|
-
_this56.logger.debug("Got TURN URIs: " + res.uris + " refresh in " + res.ttl + " secs");
|
5867
|
-
// map the response to a format that can be fed to RTCPeerConnection
|
5868
|
-
var servers = {
|
5869
|
-
urls: res.uris,
|
5870
|
-
username: res.username,
|
5871
|
-
credential: res.password
|
5872
|
-
};
|
5873
|
-
_this56.turnServers = [servers];
|
5874
|
-
// The TTL is in seconds but we work in ms
|
5875
|
-
_this56.turnServersExpiry = Date.now() + res.ttl * 1000;
|
5876
|
-
credentialsGood = true;
|
5877
|
-
_this56.emit(ClientEvent.TurnServers, _this56.turnServers);
|
5878
|
-
}
|
5879
|
-
} catch (err) {
|
5880
|
-
_this56.logger.error("Failed to get TURN URIs", err);
|
5881
|
-
if (err.httpStatus === 403) {
|
5882
|
-
// We got a 403, so there's no point in looping forever.
|
5883
|
-
_this56.logger.info("TURN access unavailable for this account: stopping credentials checks");
|
5884
|
-
if (_this56.checkTurnServersIntervalID !== null) {
|
5885
|
-
globalThis.clearInterval(_this56.checkTurnServersIntervalID);
|
5886
|
-
}
|
5887
|
-
_this56.checkTurnServersIntervalID = undefined;
|
5888
|
-
_this56.emit(ClientEvent.TurnServersError, err, true); // fatal
|
5889
|
-
} else {
|
5890
|
-
// otherwise, if we failed for whatever reason, try again the next time we're called.
|
5891
|
-
_this56.emit(ClientEvent.TurnServersError, err, false); // non-fatal
|
5892
|
-
}
|
5893
|
-
}
|
5894
|
-
}
|
5895
|
-
return credentialsGood;
|
5896
|
-
})();
|
5897
|
-
}
|
5898
|
-
|
5899
3543
|
/**
|
5900
3544
|
* Set whether to allow a fallback ICE server should be used for negotiating a
|
5901
3545
|
* WebRTC connection if the homeserver doesn't provide any servers. Defaults to
|
@@ -5964,14 +3608,14 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5964
3608
|
});
|
5965
3609
|
}
|
5966
3610
|
fetchClientWellKnown() {
|
5967
|
-
var
|
3611
|
+
var _this31 = this;
|
5968
3612
|
return _asyncToGenerator(function* () {
|
5969
|
-
var
|
3613
|
+
var _this31$getDomain;
|
5970
3614
|
// `getRawClientConfig` does not throw or reject on network errors, instead
|
5971
3615
|
// it absorbs errors and returns `{}`.
|
5972
|
-
|
5973
|
-
|
5974
|
-
|
3616
|
+
_this31.clientWellKnownPromise = AutoDiscovery.getRawClientConfig((_this31$getDomain = _this31.getDomain()) !== null && _this31$getDomain !== void 0 ? _this31$getDomain : undefined);
|
3617
|
+
_this31.clientWellKnown = yield _this31.clientWellKnownPromise;
|
3618
|
+
_this31.emit(ClientEvent.ClientWellKnown, _this31.clientWellKnown);
|
5975
3619
|
})();
|
5976
3620
|
}
|
5977
3621
|
getClientWellKnown() {
|
@@ -5993,11 +3637,11 @@ export class MatrixClient extends TypedEventEmitter {
|
|
5993
3637
|
storeClientOptions() {
|
5994
3638
|
// XXX: Intended private, used in code
|
5995
3639
|
var primTypes = ["boolean", "string", "number"];
|
5996
|
-
var serializableOpts = Object.entries(this.clientOpts).filter(
|
5997
|
-
var [key, value] =
|
3640
|
+
var serializableOpts = Object.entries(this.clientOpts).filter(_ref5 => {
|
3641
|
+
var [key, value] = _ref5;
|
5998
3642
|
return primTypes.includes(typeof value);
|
5999
|
-
}).reduce((obj,
|
6000
|
-
var [key, value] =
|
3643
|
+
}).reduce((obj, _ref6) => {
|
3644
|
+
var [key, value] = _ref6;
|
6001
3645
|
obj[key] = value;
|
6002
3646
|
return obj;
|
6003
3647
|
}, {});
|
@@ -6017,16 +3661,16 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6017
3661
|
// TODO: on spec release, rename this to getMutualRooms
|
6018
3662
|
// eslint-disable-next-line
|
6019
3663
|
_unstable_getSharedRooms(userId) {
|
6020
|
-
var
|
3664
|
+
var _this32 = this;
|
6021
3665
|
return _asyncToGenerator(function* () {
|
6022
3666
|
// Initial variant of the MSC
|
6023
|
-
var sharedRoomsSupport = yield
|
3667
|
+
var sharedRoomsSupport = yield _this32.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_SHARED_ROOMS);
|
6024
3668
|
|
6025
3669
|
// Newer variant that renamed shared rooms to mutual rooms
|
6026
|
-
var mutualRoomsSupport = yield
|
3670
|
+
var mutualRoomsSupport = yield _this32.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_MUTUAL_ROOMS);
|
6027
3671
|
|
6028
3672
|
// Latest variant that changed from path elements to query elements
|
6029
|
-
var queryMutualRoomsSupport = yield
|
3673
|
+
var queryMutualRoomsSupport = yield _this32.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_QUERY_MUTUAL_ROOMS);
|
6030
3674
|
if (!sharedRoomsSupport && !mutualRoomsSupport && !queryMutualRoomsSupport) {
|
6031
3675
|
throw Error("Server does not support the Mutual Rooms API");
|
6032
3676
|
}
|
@@ -6054,7 +3698,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6054
3698
|
if (token != null && queryMutualRoomsSupport) {
|
6055
3699
|
tokenQuery["batch_token"] = token;
|
6056
3700
|
}
|
6057
|
-
var res = yield
|
3701
|
+
var res = yield _this32.http.authedRequest(Method.Get, path, _objectSpread(_objectSpread({}, query), tokenQuery), undefined, {
|
6058
3702
|
prefix: ClientPrefix.Unstable
|
6059
3703
|
});
|
6060
3704
|
rooms.push(...res.joined);
|
@@ -6074,24 +3718,24 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6074
3718
|
* @returns The server /versions response
|
6075
3719
|
*/
|
6076
3720
|
getVersions() {
|
6077
|
-
var
|
3721
|
+
var _this33 = this;
|
6078
3722
|
return _asyncToGenerator(function* () {
|
6079
|
-
if (
|
6080
|
-
return
|
3723
|
+
if (_this33.serverVersionsPromise) {
|
3724
|
+
return _this33.serverVersionsPromise;
|
6081
3725
|
}
|
6082
3726
|
|
6083
3727
|
// We send an authenticated request as of MSC4026
|
6084
|
-
|
3728
|
+
_this33.serverVersionsPromise = _this33.http.authedRequest(Method.Get, "/_matrix/client/versions", undefined, undefined, {
|
6085
3729
|
prefix: ""
|
6086
3730
|
}).catch(e => {
|
6087
3731
|
// Need to unset this if it fails, otherwise we'll never retry
|
6088
|
-
|
3732
|
+
_this33.serverVersionsPromise = undefined;
|
6089
3733
|
// but rethrow the exception to anything that was waiting
|
6090
3734
|
throw e;
|
6091
3735
|
});
|
6092
|
-
var serverVersions = yield
|
6093
|
-
|
6094
|
-
return
|
3736
|
+
var serverVersions = yield _this33.serverVersionsPromise;
|
3737
|
+
_this33.canSupport = yield buildFeatureSupportMap(serverVersions);
|
3738
|
+
return _this33.serverVersionsPromise;
|
6095
3739
|
})();
|
6096
3740
|
}
|
6097
3741
|
|
@@ -6101,11 +3745,11 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6101
3745
|
* @returns Whether it is supported
|
6102
3746
|
*/
|
6103
3747
|
isVersionSupported(version) {
|
6104
|
-
var
|
3748
|
+
var _this34 = this;
|
6105
3749
|
return _asyncToGenerator(function* () {
|
6106
3750
|
var {
|
6107
3751
|
versions
|
6108
|
-
} = yield
|
3752
|
+
} = yield _this34.getVersions();
|
6109
3753
|
return versions && versions.includes(version);
|
6110
3754
|
})();
|
6111
3755
|
}
|
@@ -6117,9 +3761,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6117
3761
|
* @returns true if the feature is supported
|
6118
3762
|
*/
|
6119
3763
|
doesServerSupportUnstableFeature(feature) {
|
6120
|
-
var
|
3764
|
+
var _this35 = this;
|
6121
3765
|
return _asyncToGenerator(function* () {
|
6122
|
-
var response = yield
|
3766
|
+
var response = yield _this35.getVersions();
|
6123
3767
|
if (!response) return false;
|
6124
3768
|
var unstableFeatures = response["unstable_features"];
|
6125
3769
|
return unstableFeatures && !!unstableFeatures[feature];
|
@@ -6134,9 +3778,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6134
3778
|
* for the preset.
|
6135
3779
|
*/
|
6136
3780
|
doesServerForceEncryptionForPreset(presetName) {
|
6137
|
-
var
|
3781
|
+
var _this36 = this;
|
6138
3782
|
return _asyncToGenerator(function* () {
|
6139
|
-
var response = yield
|
3783
|
+
var response = yield _this36.getVersions();
|
6140
3784
|
if (!response) return false;
|
6141
3785
|
var unstableFeatures = response["unstable_features"];
|
6142
3786
|
|
@@ -6146,9 +3790,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6146
3790
|
})();
|
6147
3791
|
}
|
6148
3792
|
doesServerSupportThread() {
|
6149
|
-
var
|
3793
|
+
var _this37 = this;
|
6150
3794
|
return _asyncToGenerator(function* () {
|
6151
|
-
if (yield
|
3795
|
+
if (yield _this37.isVersionSupported("v1.4")) {
|
6152
3796
|
return {
|
6153
3797
|
threads: FeatureSupport.Stable,
|
6154
3798
|
list: FeatureSupport.Stable,
|
@@ -6156,13 +3800,13 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6156
3800
|
};
|
6157
3801
|
}
|
6158
3802
|
try {
|
6159
|
-
var [threadUnstable, threadStable, listUnstable, listStable, fwdPaginationUnstable, fwdPaginationStable] = yield Promise.all([
|
3803
|
+
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")]);
|
6160
3804
|
return {
|
6161
3805
|
threads: determineFeatureSupport(threadStable, threadUnstable),
|
6162
3806
|
list: determineFeatureSupport(listStable, listUnstable),
|
6163
3807
|
fwdPagination: determineFeatureSupport(fwdPaginationStable, fwdPaginationUnstable)
|
6164
3808
|
};
|
6165
|
-
} catch (
|
3809
|
+
} catch (_unused) {
|
6166
3810
|
return {
|
6167
3811
|
threads: FeatureSupport.None,
|
6168
3812
|
list: FeatureSupport.None,
|
@@ -6214,21 +3858,19 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6214
3858
|
* @returns an object with `events` as `MatrixEvent[]` and optionally `nextBatch` if more relations are available.
|
6215
3859
|
*/
|
6216
3860
|
relations(roomId, eventId, relationType, eventType) {
|
6217
|
-
var
|
6218
|
-
|
3861
|
+
var _arguments6 = arguments,
|
3862
|
+
_this38 = this;
|
6219
3863
|
return _asyncToGenerator(function* () {
|
6220
3864
|
var _result$next_batch, _result$prev_batch;
|
6221
|
-
var opts =
|
3865
|
+
var opts = _arguments6.length > 4 && _arguments6[4] !== undefined ? _arguments6[4] : {
|
6222
3866
|
dir: Direction.Backward
|
6223
3867
|
};
|
6224
|
-
var fetchedEventType = eventType ?
|
6225
|
-
var [eventResult, result] = yield Promise.all([
|
6226
|
-
var mapper =
|
3868
|
+
var fetchedEventType = eventType ? _this38.getEncryptedIfNeededEventType(roomId, eventType) : null;
|
3869
|
+
var [eventResult, result] = yield Promise.all([_this38.fetchRoomEvent(roomId, eventId), _this38.fetchRelations(roomId, eventId, relationType, fetchedEventType, opts)]);
|
3870
|
+
var mapper = _this38.getEventMapper();
|
6227
3871
|
var originalEvent = eventResult ? mapper(eventResult) : undefined;
|
6228
3872
|
var events = result.chunk.map(mapper);
|
6229
3873
|
if (fetchedEventType === EventType.RoomMessageEncrypted) {
|
6230
|
-
var allEvents = originalEvent ? events.concat(originalEvent) : events;
|
6231
|
-
yield Promise.all(allEvents.map(e => _this64.decryptEventIfNeeded(e)));
|
6232
3874
|
if (eventType !== null) {
|
6233
3875
|
events = events.filter(e => e.getType() === eventType);
|
6234
3876
|
}
|
@@ -6245,18 +3887,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6245
3887
|
})();
|
6246
3888
|
}
|
6247
3889
|
|
6248
|
-
/**
|
6249
|
-
* The app may wish to see if we have a key cached without
|
6250
|
-
* triggering a user interaction.
|
6251
|
-
*
|
6252
|
-
* @deprecated Not supported for Rust Cryptography.
|
6253
|
-
*/
|
6254
|
-
getCrossSigningCacheCallbacks() {
|
6255
|
-
var _this$crypto4;
|
6256
|
-
// XXX: Private member access
|
6257
|
-
return (_this$crypto4 = this.crypto) === null || _this$crypto4 === void 0 ? void 0 : _this$crypto4.crossSigningInfo.getCacheCallbacks();
|
6258
|
-
}
|
6259
|
-
|
6260
3890
|
/**
|
6261
3891
|
* Generates a random string suitable for use as a client secret. <strong>This
|
6262
3892
|
* method is experimental and may change.</strong>
|
@@ -6272,14 +3902,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6272
3902
|
* @returns A decryption promise
|
6273
3903
|
*/
|
6274
3904
|
decryptEventIfNeeded(event, options) {
|
6275
|
-
|
6276
|
-
event.attemptDecryption(this.cryptoBackend, options);
|
6277
|
-
}
|
6278
|
-
if (event.isBeingDecrypted()) {
|
6279
|
-
return event.getDecryptionPromise();
|
6280
|
-
} else {
|
6281
|
-
return Promise.resolve();
|
6282
|
-
}
|
3905
|
+
return Promise.resolve();
|
6283
3906
|
}
|
6284
3907
|
termsUrlForService(serviceType, baseUrl) {
|
6285
3908
|
switch (serviceType) {
|
@@ -6578,23 +4201,15 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6578
4201
|
* @returns Promise which resolves: On success, the empty object `{}`
|
6579
4202
|
*/
|
6580
4203
|
logout() {
|
6581
|
-
var
|
6582
|
-
|
4204
|
+
var _arguments7 = arguments,
|
4205
|
+
_this39 = this;
|
6583
4206
|
return _asyncToGenerator(function* () {
|
6584
|
-
var
|
6585
|
-
var stopClient = _arguments9.length > 0 && _arguments9[0] !== undefined ? _arguments9[0] : false;
|
6586
|
-
if ((_this65$crypto = _this65.crypto) !== null && _this65$crypto !== void 0 && (_this65$crypto = _this65$crypto.backupManager) !== null && _this65$crypto !== void 0 && _this65$crypto.getKeyBackupEnabled()) {
|
6587
|
-
try {
|
6588
|
-
while ((yield _this65.crypto.backupManager.backupPendingKeys(200)) > 0);
|
6589
|
-
} catch (err) {
|
6590
|
-
_this65.logger.error("Key backup request failed when logging out. Some keys may be missing from backup", err);
|
6591
|
-
}
|
6592
|
-
}
|
4207
|
+
var stopClient = _arguments7.length > 0 && _arguments7[0] !== undefined ? _arguments7[0] : false;
|
6593
4208
|
if (stopClient) {
|
6594
|
-
|
6595
|
-
|
4209
|
+
_this39.stopClient();
|
4210
|
+
_this39.http.abort();
|
6596
4211
|
}
|
6597
|
-
return
|
4212
|
+
return _this39.http.authedRequest(Method.Post, "/logout");
|
6598
4213
|
})();
|
6599
4214
|
}
|
6600
4215
|
|
@@ -6632,12 +4247,12 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6632
4247
|
* or UIA auth data.
|
6633
4248
|
*/
|
6634
4249
|
requestLoginToken(auth) {
|
6635
|
-
var
|
4250
|
+
var _this40 = this;
|
6636
4251
|
return _asyncToGenerator(function* () {
|
6637
4252
|
var body = {
|
6638
4253
|
auth
|
6639
4254
|
};
|
6640
|
-
return
|
4255
|
+
return _this40.http.authedRequest(Method.Post, "/login/get_token", undefined,
|
6641
4256
|
// no query params
|
6642
4257
|
body, {
|
6643
4258
|
prefix: ClientPrefix.V1
|
@@ -6669,23 +4284,23 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6669
4284
|
* @returns Rejects: with an error response.
|
6670
4285
|
*/
|
6671
4286
|
createRoom(options) {
|
6672
|
-
var
|
4287
|
+
var _this41 = this;
|
6673
4288
|
return _asyncToGenerator(function* () {
|
6674
|
-
var
|
4289
|
+
var _this41$identityServe;
|
6675
4290
|
// eslint-disable-line camelcase
|
6676
4291
|
// some valid options include: room_alias_name, visibility, invite
|
6677
4292
|
|
6678
4293
|
// inject the id_access_token if inviting 3rd party addresses
|
6679
4294
|
var invitesNeedingToken = (options.invite_3pid || []).filter(i => !i.id_access_token);
|
6680
|
-
if (invitesNeedingToken.length > 0 && (
|
6681
|
-
var identityAccessToken = yield
|
4295
|
+
if (invitesNeedingToken.length > 0 && (_this41$identityServe = _this41.identityServer) !== null && _this41$identityServe !== void 0 && _this41$identityServe.getAccessToken) {
|
4296
|
+
var identityAccessToken = yield _this41.identityServer.getAccessToken();
|
6682
4297
|
if (identityAccessToken) {
|
6683
4298
|
for (var invite of invitesNeedingToken) {
|
6684
4299
|
invite.id_access_token = identityAccessToken;
|
6685
4300
|
}
|
6686
4301
|
}
|
6687
4302
|
}
|
6688
|
-
return
|
4303
|
+
return _this41.http.authedRequest(Method.Post, "/createRoom", undefined, options);
|
6689
4304
|
})();
|
6690
4305
|
}
|
6691
4306
|
|
@@ -6869,7 +4484,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6869
4484
|
* @returns Promise which resolves: the empty object, `{}`.
|
6870
4485
|
*/
|
6871
4486
|
setRoomReadMarkersHttpRequest(roomId, rmEventId, rrEventId, rpEventId) {
|
6872
|
-
var
|
4487
|
+
var _this42 = this;
|
6873
4488
|
return _asyncToGenerator(function* () {
|
6874
4489
|
var path = utils.encodeUri("/rooms/$roomId/read_markers", {
|
6875
4490
|
$roomId: roomId
|
@@ -6878,10 +4493,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6878
4493
|
[ReceiptType.FullyRead]: rmEventId,
|
6879
4494
|
[ReceiptType.Read]: rrEventId
|
6880
4495
|
};
|
6881
|
-
if ((yield
|
4496
|
+
if ((yield _this42.doesServerSupportUnstableFeature("org.matrix.msc2285.stable")) || (yield _this42.isVersionSupported("v1.4"))) {
|
6882
4497
|
content[ReceiptType.ReadPrivate] = rpEventId;
|
6883
4498
|
}
|
6884
|
-
return
|
4499
|
+
return _this42.http.authedRequest(Method.Post, path, undefined, content);
|
6885
4500
|
})();
|
6886
4501
|
}
|
6887
4502
|
|
@@ -6914,13 +4529,13 @@ export class MatrixClient extends TypedEventEmitter {
|
|
6914
4529
|
* @returns Rejects: with an error response.
|
6915
4530
|
*/
|
6916
4531
|
publicRooms() {
|
6917
|
-
var
|
4532
|
+
var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
6918
4533
|
var {
|
6919
4534
|
server,
|
6920
4535
|
limit,
|
6921
4536
|
since
|
6922
|
-
} =
|
6923
|
-
options = _objectWithoutProperties(
|
4537
|
+
} = _ref7,
|
4538
|
+
options = _objectWithoutProperties(_ref7, _excluded);
|
6924
4539
|
if (Object.keys(options).length === 0) {
|
6925
4540
|
var queryParams = {
|
6926
4541
|
server,
|
@@ -7038,11 +4653,11 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7038
4653
|
* @param options.limit - the maximum number of results to return. The server will apply a limit if unspecified.
|
7039
4654
|
* @returns Promise which resolves: an array of results.
|
7040
4655
|
*/
|
7041
|
-
searchUserDirectory(
|
4656
|
+
searchUserDirectory(_ref8) {
|
7042
4657
|
var {
|
7043
4658
|
term,
|
7044
4659
|
limit
|
7045
|
-
} =
|
4660
|
+
} = _ref8;
|
7046
4661
|
var body = {
|
7047
4662
|
search_term: term
|
7048
4663
|
};
|
@@ -7114,9 +4729,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7114
4729
|
* @returns `true` if supported, otherwise `false`
|
7115
4730
|
*/
|
7116
4731
|
doesServerSupportExtendedProfiles() {
|
7117
|
-
var
|
4732
|
+
var _this43 = this;
|
7118
4733
|
return _asyncToGenerator(function* () {
|
7119
|
-
return
|
4734
|
+
return _this43.doesServerSupportUnstableFeature(UNSTABLE_MSC4133_EXTENDED_PROFILES);
|
7120
4735
|
})();
|
7121
4736
|
}
|
7122
4737
|
|
@@ -7126,9 +4741,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7126
4741
|
* @returns The prefix for use with `authedRequest`
|
7127
4742
|
*/
|
7128
4743
|
getExtendedProfileRequestPrefix() {
|
7129
|
-
var
|
4744
|
+
var _this44 = this;
|
7130
4745
|
return _asyncToGenerator(function* () {
|
7131
|
-
if (yield
|
4746
|
+
if (yield _this44.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable")) {
|
7132
4747
|
return ClientPrefix.V3;
|
7133
4748
|
}
|
7134
4749
|
return "/_matrix/client/unstable/uk.tcpip.msc4133";
|
@@ -7146,15 +4761,15 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7146
4761
|
* @throws A M_NOT_FOUND error if the profile could not be found.
|
7147
4762
|
*/
|
7148
4763
|
getExtendedProfile(userId) {
|
7149
|
-
var
|
4764
|
+
var _this45 = this;
|
7150
4765
|
return _asyncToGenerator(function* () {
|
7151
|
-
if (!(yield
|
4766
|
+
if (!(yield _this45.doesServerSupportExtendedProfiles())) {
|
7152
4767
|
throw new Error("Server does not support extended profiles");
|
7153
4768
|
}
|
7154
|
-
return
|
4769
|
+
return _this45.http.authedRequest(Method.Get, utils.encodeUri("/profile/$userId", {
|
7155
4770
|
$userId: userId
|
7156
4771
|
}), undefined, undefined, {
|
7157
|
-
prefix: yield
|
4772
|
+
prefix: yield _this45.getExtendedProfileRequestPrefix()
|
7158
4773
|
});
|
7159
4774
|
})();
|
7160
4775
|
}
|
@@ -7171,16 +4786,16 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7171
4786
|
* @throws A M_NOT_FOUND error if the key was not set OR the profile could not be found.
|
7172
4787
|
*/
|
7173
4788
|
getExtendedProfileProperty(userId, key) {
|
7174
|
-
var
|
4789
|
+
var _this46 = this;
|
7175
4790
|
return _asyncToGenerator(function* () {
|
7176
|
-
if (!(yield
|
4791
|
+
if (!(yield _this46.doesServerSupportExtendedProfiles())) {
|
7177
4792
|
throw new Error("Server does not support extended profiles");
|
7178
4793
|
}
|
7179
|
-
var profile = yield
|
4794
|
+
var profile = yield _this46.http.authedRequest(Method.Get, utils.encodeUri("/profile/$userId/$key", {
|
7180
4795
|
$userId: userId,
|
7181
4796
|
$key: key
|
7182
4797
|
}), undefined, undefined, {
|
7183
|
-
prefix: yield
|
4798
|
+
prefix: yield _this46.getExtendedProfileRequestPrefix()
|
7184
4799
|
});
|
7185
4800
|
return profile[key];
|
7186
4801
|
})();
|
@@ -7196,19 +4811,19 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7196
4811
|
* @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
|
7197
4812
|
*/
|
7198
4813
|
setExtendedProfileProperty(key, value) {
|
7199
|
-
var
|
4814
|
+
var _this47 = this;
|
7200
4815
|
return _asyncToGenerator(function* () {
|
7201
|
-
if (!(yield
|
4816
|
+
if (!(yield _this47.doesServerSupportExtendedProfiles())) {
|
7202
4817
|
throw new Error("Server does not support extended profiles");
|
7203
4818
|
}
|
7204
|
-
var userId =
|
7205
|
-
yield
|
4819
|
+
var userId = _this47.getUserId();
|
4820
|
+
yield _this47.http.authedRequest(Method.Put, utils.encodeUri("/profile/$userId/$key", {
|
7206
4821
|
$userId: userId,
|
7207
4822
|
$key: key
|
7208
4823
|
}), undefined, {
|
7209
4824
|
[key]: value
|
7210
4825
|
}, {
|
7211
|
-
prefix: yield
|
4826
|
+
prefix: yield _this47.getExtendedProfileRequestPrefix()
|
7212
4827
|
});
|
7213
4828
|
})();
|
7214
4829
|
}
|
@@ -7222,17 +4837,17 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7222
4837
|
* @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
|
7223
4838
|
*/
|
7224
4839
|
deleteExtendedProfileProperty(key) {
|
7225
|
-
var
|
4840
|
+
var _this48 = this;
|
7226
4841
|
return _asyncToGenerator(function* () {
|
7227
|
-
if (!(yield
|
4842
|
+
if (!(yield _this48.doesServerSupportExtendedProfiles())) {
|
7228
4843
|
throw new Error("Server does not support extended profiles");
|
7229
4844
|
}
|
7230
|
-
var userId =
|
7231
|
-
yield
|
4845
|
+
var userId = _this48.getUserId();
|
4846
|
+
yield _this48.http.authedRequest(Method.Delete, utils.encodeUri("/profile/$userId/$key", {
|
7232
4847
|
$userId: userId,
|
7233
4848
|
$key: key
|
7234
4849
|
}), undefined, undefined, {
|
7235
|
-
prefix: yield
|
4850
|
+
prefix: yield _this48.getExtendedProfileRequestPrefix()
|
7236
4851
|
});
|
7237
4852
|
})();
|
7238
4853
|
}
|
@@ -7248,16 +4863,16 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7248
4863
|
* @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
|
7249
4864
|
*/
|
7250
4865
|
patchExtendedProfile(profile) {
|
7251
|
-
var
|
4866
|
+
var _this49 = this;
|
7252
4867
|
return _asyncToGenerator(function* () {
|
7253
|
-
if (!(yield
|
4868
|
+
if (!(yield _this49.doesServerSupportExtendedProfiles())) {
|
7254
4869
|
throw new Error("Server does not support extended profiles");
|
7255
4870
|
}
|
7256
|
-
var userId =
|
7257
|
-
return
|
4871
|
+
var userId = _this49.getUserId();
|
4872
|
+
return _this49.http.authedRequest(Method.Patch, utils.encodeUri("/profile/$userId", {
|
7258
4873
|
$userId: userId
|
7259
4874
|
}), {}, profile, {
|
7260
|
-
prefix: yield
|
4875
|
+
prefix: yield _this49.getExtendedProfileRequestPrefix()
|
7261
4876
|
});
|
7262
4877
|
})();
|
7263
4878
|
}
|
@@ -7272,16 +4887,16 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7272
4887
|
* @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
|
7273
4888
|
*/
|
7274
4889
|
setExtendedProfile(profile) {
|
7275
|
-
var
|
4890
|
+
var _this50 = this;
|
7276
4891
|
return _asyncToGenerator(function* () {
|
7277
|
-
if (!(yield
|
4892
|
+
if (!(yield _this50.doesServerSupportExtendedProfiles())) {
|
7278
4893
|
throw new Error("Server does not support extended profiles");
|
7279
4894
|
}
|
7280
|
-
var userId =
|
7281
|
-
yield
|
4895
|
+
var userId = _this50.getUserId();
|
4896
|
+
yield _this50.http.authedRequest(Method.Put, utils.encodeUri("/profile/$userId", {
|
7282
4897
|
$userId: userId
|
7283
4898
|
}), {}, profile, {
|
7284
|
-
prefix: yield
|
4899
|
+
prefix: yield _this50.getExtendedProfileRequestPrefix()
|
7285
4900
|
});
|
7286
4901
|
})();
|
7287
4902
|
}
|
@@ -7304,10 +4919,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7304
4919
|
* @returns Rejects: with an error response.
|
7305
4920
|
*/
|
7306
4921
|
addThreePidOnly(data) {
|
7307
|
-
var
|
4922
|
+
var _this51 = this;
|
7308
4923
|
return _asyncToGenerator(function* () {
|
7309
4924
|
var path = "/account/3pid/add";
|
7310
|
-
return
|
4925
|
+
return _this51.http.authedRequest(Method.Post, path, undefined, data);
|
7311
4926
|
})();
|
7312
4927
|
}
|
7313
4928
|
|
@@ -7323,10 +4938,10 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7323
4938
|
* @returns Rejects: with an error response.
|
7324
4939
|
*/
|
7325
4940
|
bindThreePid(data) {
|
7326
|
-
var
|
4941
|
+
var _this52 = this;
|
7327
4942
|
return _asyncToGenerator(function* () {
|
7328
4943
|
var path = "/account/3pid/bind";
|
7329
|
-
return
|
4944
|
+
return _this52.http.authedRequest(Method.Post, path, undefined, data);
|
7330
4945
|
})();
|
7331
4946
|
}
|
7332
4947
|
|
@@ -7344,15 +4959,15 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7344
4959
|
unbindThreePid(medium, address
|
7345
4960
|
// eslint-disable-next-line camelcase
|
7346
4961
|
) {
|
7347
|
-
var
|
4962
|
+
var _this53 = this;
|
7348
4963
|
return _asyncToGenerator(function* () {
|
7349
4964
|
var path = "/account/3pid/unbind";
|
7350
4965
|
var data = {
|
7351
4966
|
medium,
|
7352
4967
|
address,
|
7353
|
-
id_server:
|
4968
|
+
id_server: _this53.getIdentityServerUrl(true)
|
7354
4969
|
};
|
7355
|
-
return
|
4970
|
+
return _this53.http.authedRequest(Method.Post, path, undefined, data);
|
7356
4971
|
})();
|
7357
4972
|
}
|
7358
4973
|
|
@@ -7474,13 +5089,13 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7474
5089
|
* @returns Rejects: with an error response.
|
7475
5090
|
*/
|
7476
5091
|
getPushers() {
|
7477
|
-
var
|
5092
|
+
var _this54 = this;
|
7478
5093
|
return _asyncToGenerator(function* () {
|
7479
|
-
var response = yield
|
5094
|
+
var response = yield _this54.http.authedRequest(Method.Get, "/pushers");
|
7480
5095
|
|
7481
5096
|
// Migration path for clients that connect to a homeserver that does not support
|
7482
5097
|
// MSC3881 yet, see https://github.com/matrix-org/matrix-spec-proposals/blob/kerry/remote-push-toggle/proposals/3881-remote-push-notification-toggling.md#migration
|
7483
|
-
if (!(yield
|
5098
|
+
if (!(yield _this54.doesServerSupportUnstableFeature("org.matrix.msc3881"))) {
|
7484
5099
|
response.pushers = response.pushers.map(pusher => {
|
7485
5100
|
if (!pusher.hasOwnProperty(PUSHER_ENABLED.name)) {
|
7486
5101
|
pusher[PUSHER_ENABLED.name] = true;
|
@@ -7619,11 +5234,11 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7619
5234
|
* @returns Promise which resolves to the search response object.
|
7620
5235
|
* @returns Rejects: with an error response.
|
7621
5236
|
*/
|
7622
|
-
search(
|
5237
|
+
search(_ref9, abortSignal) {
|
7623
5238
|
var {
|
7624
5239
|
body,
|
7625
5240
|
next_batch: nextBatch
|
7626
|
-
} =
|
5241
|
+
} = _ref9;
|
7627
5242
|
var queryParams = {};
|
7628
5243
|
if (nextBatch) {
|
7629
5244
|
queryParams.next_batch = nextBatch;
|
@@ -7633,86 +5248,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7633
5248
|
});
|
7634
5249
|
}
|
7635
5250
|
|
7636
|
-
/**
|
7637
|
-
* Upload keys
|
7638
|
-
*
|
7639
|
-
* @param content - body of upload request
|
7640
|
-
*
|
7641
|
-
* @param opts - this method no longer takes any opts,
|
7642
|
-
* used to take opts.device_id but this was not removed from the spec as a redundant parameter
|
7643
|
-
*
|
7644
|
-
* @returns Promise which resolves: result object. Rejects: with
|
7645
|
-
* an error response ({@link MatrixError}).
|
7646
|
-
*/
|
7647
|
-
uploadKeysRequest(content, opts) {
|
7648
|
-
return this.http.authedRequest(Method.Post, "/keys/upload", undefined, content);
|
7649
|
-
}
|
7650
|
-
uploadKeySignatures(content) {
|
7651
|
-
return this.http.authedRequest(Method.Post, "/keys/signatures/upload", undefined, content);
|
7652
|
-
}
|
7653
|
-
|
7654
|
-
/**
|
7655
|
-
* Download device keys
|
7656
|
-
*
|
7657
|
-
* @param userIds - list of users to get keys for
|
7658
|
-
*
|
7659
|
-
* @param token - sync token to pass in the query request, to help
|
7660
|
-
* the HS give the most recent results
|
7661
|
-
*
|
7662
|
-
* @returns Promise which resolves: result object. Rejects: with
|
7663
|
-
* an error response ({@link MatrixError}).
|
7664
|
-
*/
|
7665
|
-
downloadKeysForUsers(userIds) {
|
7666
|
-
var {
|
7667
|
-
token
|
7668
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
7669
|
-
var content = {
|
7670
|
-
device_keys: {}
|
7671
|
-
};
|
7672
|
-
if (token !== undefined) {
|
7673
|
-
content.token = token;
|
7674
|
-
}
|
7675
|
-
userIds.forEach(u => {
|
7676
|
-
content.device_keys[u] = [];
|
7677
|
-
});
|
7678
|
-
return this.http.authedRequest(Method.Post, "/keys/query", undefined, content);
|
7679
|
-
}
|
7680
|
-
|
7681
|
-
/**
|
7682
|
-
* Claim one-time keys
|
7683
|
-
*
|
7684
|
-
* @param devices - a list of [userId, deviceId] pairs
|
7685
|
-
*
|
7686
|
-
* @param keyAlgorithm - desired key type
|
7687
|
-
*
|
7688
|
-
* @param timeout - the time (in milliseconds) to wait for keys from remote
|
7689
|
-
* servers
|
7690
|
-
*
|
7691
|
-
* @returns Promise which resolves: result object. Rejects: with
|
7692
|
-
* an error response ({@link MatrixError}).
|
7693
|
-
*/
|
7694
|
-
claimOneTimeKeys(devices) {
|
7695
|
-
var keyAlgorithm = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "signed_curve25519";
|
7696
|
-
var timeout = arguments.length > 2 ? arguments[2] : undefined;
|
7697
|
-
var queries = {};
|
7698
|
-
if (keyAlgorithm === undefined) {
|
7699
|
-
keyAlgorithm = "signed_curve25519";
|
7700
|
-
}
|
7701
|
-
for (var [userId, _deviceId] of devices) {
|
7702
|
-
var query = queries[userId] || {};
|
7703
|
-
safeSet(queries, userId, query);
|
7704
|
-
safeSet(query, _deviceId, keyAlgorithm);
|
7705
|
-
}
|
7706
|
-
var content = {
|
7707
|
-
one_time_keys: queries
|
7708
|
-
};
|
7709
|
-
if (timeout) {
|
7710
|
-
content.timeout = timeout;
|
7711
|
-
}
|
7712
|
-
var path = "/keys/claim";
|
7713
|
-
return this.http.authedRequest(Method.Post, path, undefined, content);
|
7714
|
-
}
|
7715
|
-
|
7716
5251
|
/**
|
7717
5252
|
* Ask the server for a list of users who have changed their device lists
|
7718
5253
|
* between a pair of sync tokens
|
@@ -7728,16 +5263,6 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7728
5263
|
};
|
7729
5264
|
return this.http.authedRequest(Method.Get, "/keys/changes", qps);
|
7730
5265
|
}
|
7731
|
-
uploadDeviceSigningKeys(auth, keys) {
|
7732
|
-
// API returns empty object
|
7733
|
-
var data = Object.assign({}, keys);
|
7734
|
-
if (auth) Object.assign(data, {
|
7735
|
-
auth
|
7736
|
-
});
|
7737
|
-
return this.http.authedRequest(Method.Post, "/keys/device_signing/upload", undefined, data, {
|
7738
|
-
prefix: ClientPrefix.Unstable
|
7739
|
-
});
|
7740
|
-
}
|
7741
5266
|
|
7742
5267
|
/**
|
7743
5268
|
* Register with an identity server using the OpenID token from the user's
|
@@ -7910,7 +5435,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7910
5435
|
* found MXIDs. Results where no user could be found will not be listed.
|
7911
5436
|
*/
|
7912
5437
|
identityHashedLookup(addressPairs, identityAccessToken) {
|
7913
|
-
var
|
5438
|
+
var _this55 = this;
|
7914
5439
|
return _asyncToGenerator(function* () {
|
7915
5440
|
var params = {
|
7916
5441
|
// addresses: ["email@example.org", "10005550000"],
|
@@ -7919,7 +5444,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7919
5444
|
};
|
7920
5445
|
|
7921
5446
|
// Get hash information first before trying to do a lookup
|
7922
|
-
var hashes = yield
|
5447
|
+
var hashes = yield _this55.getIdentityHashDetails(identityAccessToken);
|
7923
5448
|
if (!hashes || !hashes["lookup_pepper"] || !hashes["algorithms"]) {
|
7924
5449
|
throw new Error("Unsupported identity server: bad response");
|
7925
5450
|
}
|
@@ -7932,7 +5457,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7932
5457
|
// When picking an algorithm, we pick the hashed over no hashes
|
7933
5458
|
if (hashes["algorithms"].includes("sha256")) {
|
7934
5459
|
params["addresses"] = yield Promise.all(addressPairs.map(/*#__PURE__*/function () {
|
7935
|
-
var
|
5460
|
+
var _ref10 = _asyncToGenerator(function* (p) {
|
7936
5461
|
var addr = p[0].toLowerCase(); // lowercase to get consistent hashes
|
7937
5462
|
var med = p[1].toLowerCase();
|
7938
5463
|
var hashBuffer = yield sha256("".concat(addr, " ").concat(med, " ").concat(params["pepper"]));
|
@@ -7943,8 +5468,8 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7943
5468
|
localMapping[hashed] = p[0];
|
7944
5469
|
return hashed;
|
7945
5470
|
});
|
7946
|
-
return function (
|
7947
|
-
return
|
5471
|
+
return function (_x4) {
|
5472
|
+
return _ref10.apply(this, arguments);
|
7948
5473
|
};
|
7949
5474
|
}()));
|
7950
5475
|
params["algorithm"] = "sha256";
|
@@ -7962,7 +5487,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7962
5487
|
} else {
|
7963
5488
|
throw new Error("Unsupported identity server: unknown hash algorithm");
|
7964
5489
|
}
|
7965
|
-
var response = yield
|
5490
|
+
var response = yield _this55.http.idServerRequest(Method.Post, "/lookup", params, IdentityPrefix.V2, identityAccessToken);
|
7966
5491
|
if (!(response !== null && response !== void 0 && response["mappings"])) return []; // no results
|
7967
5492
|
|
7968
5493
|
var foundAddresses = [];
|
@@ -7996,12 +5521,12 @@ export class MatrixClient extends TypedEventEmitter {
|
|
7996
5521
|
* @returns Rejects: with an error response.
|
7997
5522
|
*/
|
7998
5523
|
lookupThreePid(medium, address, identityAccessToken) {
|
7999
|
-
var
|
5524
|
+
var _this56 = this;
|
8000
5525
|
return _asyncToGenerator(function* () {
|
8001
5526
|
// Note: we're using the V2 API by calling this function, but our
|
8002
5527
|
// function contract requires a V1 response. We therefore have to
|
8003
5528
|
// convert it manually.
|
8004
|
-
var response = yield
|
5529
|
+
var response = yield _this56.identityHashedLookup([[address, medium]], identityAccessToken);
|
8005
5530
|
var result = response.find(p => p.address === address);
|
8006
5531
|
if (!result) {
|
8007
5532
|
return {};
|
@@ -8033,16 +5558,16 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8033
5558
|
* @returns Rejects: with an error response.
|
8034
5559
|
*/
|
8035
5560
|
bulkLookupThreePids(query, identityAccessToken) {
|
8036
|
-
var
|
5561
|
+
var _this57 = this;
|
8037
5562
|
return _asyncToGenerator(function* () {
|
8038
5563
|
// Note: we're using the V2 API by calling this function, but our
|
8039
5564
|
// function contract requires a V1 response. We therefore have to
|
8040
5565
|
// convert it manually.
|
8041
|
-
var response = yield
|
5566
|
+
var response = yield _this57.identityHashedLookup(
|
8042
5567
|
// We have to reverse the query order to get [address, medium] pairs
|
8043
5568
|
query.map(p => [p[1], p[0]]), identityAccessToken);
|
8044
5569
|
var v1results = [];
|
8045
|
-
var
|
5570
|
+
var _loop = function* _loop(mapping) {
|
8046
5571
|
var originalQuery = query.find(p => p[1] === mapping.address);
|
8047
5572
|
if (!originalQuery) {
|
8048
5573
|
throw new Error("Identity sever returned unexpected results");
|
@@ -8052,7 +5577,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8052
5577
|
mapping.address, mapping.mxid]);
|
8053
5578
|
};
|
8054
5579
|
for (var mapping of response) {
|
8055
|
-
yield*
|
5580
|
+
yield* _loop(mapping);
|
8056
5581
|
}
|
8057
5582
|
return {
|
8058
5583
|
threepids: v1results
|
@@ -8239,16 +5764,16 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8239
5764
|
* @returns Promise which resolves to the created space.
|
8240
5765
|
*/
|
8241
5766
|
unstableCreateFileTree(name) {
|
8242
|
-
var
|
5767
|
+
var _this58 = this;
|
8243
5768
|
return _asyncToGenerator(function* () {
|
8244
5769
|
var {
|
8245
5770
|
room_id: roomId
|
8246
|
-
} = yield
|
5771
|
+
} = yield _this58.createRoom({
|
8247
5772
|
name: name,
|
8248
5773
|
preset: Preset.PrivateChat,
|
8249
5774
|
power_level_content_override: _objectSpread(_objectSpread({}, DEFAULT_TREE_POWER_LEVELS_TEMPLATE), {}, {
|
8250
5775
|
users: {
|
8251
|
-
[
|
5776
|
+
[_this58.getUserId()]: 100
|
8252
5777
|
}
|
8253
5778
|
}),
|
8254
5779
|
creation_content: {
|
@@ -8260,15 +5785,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8260
5785
|
content: {
|
8261
5786
|
[UNSTABLE_MSC3088_ENABLED.name]: true
|
8262
5787
|
}
|
8263
|
-
}, {
|
8264
|
-
type: EventType.RoomEncryption,
|
8265
|
-
state_key: "",
|
8266
|
-
content: {
|
8267
|
-
algorithm: olmlib.MEGOLM_ALGORITHM
|
8268
|
-
}
|
8269
5788
|
}]
|
8270
5789
|
});
|
8271
|
-
return new MSC3089TreeSpace(
|
5790
|
+
return new MSC3089TreeSpace(_this58, roomId);
|
8272
5791
|
})();
|
8273
5792
|
}
|
8274
5793
|
|
@@ -8345,7 +5864,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8345
5864
|
* @param via - The list of servers which know about the room if only an ID was provided.
|
8346
5865
|
*/
|
8347
5866
|
getRoomSummary(roomIdOrAlias, via) {
|
8348
|
-
var
|
5867
|
+
var _this59 = this;
|
8349
5868
|
return _asyncToGenerator(function* () {
|
8350
5869
|
var paramOpts = {
|
8351
5870
|
prefix: "/_matrix/client/unstable/im.nheko.summary"
|
@@ -8354,7 +5873,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8354
5873
|
var path = utils.encodeUri("/summary/$roomid", {
|
8355
5874
|
$roomid: roomIdOrAlias
|
8356
5875
|
});
|
8357
|
-
return yield
|
5876
|
+
return yield _this59.http.authedRequest(Method.Get, path, {
|
8358
5877
|
via
|
8359
5878
|
}, undefined, paramOpts);
|
8360
5879
|
} catch (e) {
|
@@ -8362,7 +5881,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8362
5881
|
var _path = utils.encodeUri("/rooms/$roomid/summary", {
|
8363
5882
|
$roomid: roomIdOrAlias
|
8364
5883
|
});
|
8365
|
-
return yield
|
5884
|
+
return yield _this59.http.authedRequest(Method.Get, _path, {
|
8366
5885
|
via
|
8367
5886
|
}, undefined, paramOpts);
|
8368
5887
|
} else {
|
@@ -8414,9 +5933,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8414
5933
|
* Fetches information about the user for the configured access token.
|
8415
5934
|
*/
|
8416
5935
|
whoami() {
|
8417
|
-
var
|
5936
|
+
var _this60 = this;
|
8418
5937
|
return _asyncToGenerator(function* () {
|
8419
|
-
return
|
5938
|
+
return _this60.http.authedRequest(Method.Get, "/account/whoami");
|
8420
5939
|
})();
|
8421
5940
|
}
|
8422
5941
|
|
@@ -8427,7 +5946,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8427
5946
|
* @returns Rejects: when the request fails (module:http-api.MatrixError)
|
8428
5947
|
*/
|
8429
5948
|
timestampToEvent(roomId, timestamp, dir) {
|
8430
|
-
var
|
5949
|
+
var _this61 = this;
|
8431
5950
|
return _asyncToGenerator(function* () {
|
8432
5951
|
var path = utils.encodeUri("/rooms/$roomId/timestamp_to_event", {
|
8433
5952
|
$roomId: roomId
|
@@ -8437,7 +5956,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8437
5956
|
dir: dir
|
8438
5957
|
};
|
8439
5958
|
try {
|
8440
|
-
return yield
|
5959
|
+
return yield _this61.http.authedRequest(Method.Get, path, queryParams, undefined, {
|
8441
5960
|
prefix: ClientPrefix.V1
|
8442
5961
|
});
|
8443
5962
|
} catch (err) {
|
@@ -8453,7 +5972,7 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8453
5972
|
// both indicate that this endpoint+verb combination is
|
8454
5973
|
// not supported.
|
8455
5974
|
err.httpStatus === 404 || err.httpStatus === 405)) {
|
8456
|
-
return yield
|
5975
|
+
return yield _this61.http.authedRequest(Method.Get, path, queryParams, undefined, {
|
8457
5976
|
prefix: "/_matrix/client/unstable/org.matrix.msc3030"
|
8458
5977
|
});
|
8459
5978
|
}
|
@@ -8469,9 +5988,9 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8469
5988
|
* @experimental - part of MSC2965
|
8470
5989
|
*/
|
8471
5990
|
getAuthIssuer() {
|
8472
|
-
var
|
5991
|
+
var _this62 = this;
|
8473
5992
|
return _asyncToGenerator(function* () {
|
8474
|
-
return
|
5993
|
+
return _this62.http.request(Method.Get, "/auth_issuer", undefined, undefined, {
|
8475
5994
|
prefix: ClientPrefix.Unstable + "/org.matrix.msc2965"
|
8476
5995
|
});
|
8477
5996
|
})();
|
@@ -8479,8 +5998,8 @@ export class MatrixClient extends TypedEventEmitter {
|
|
8479
5998
|
}
|
8480
5999
|
_defineProperty(MatrixClient, "RESTORE_BACKUP_ERROR_BAD_KEY", "RESTORE_BACKUP_ERROR_BAD_KEY");
|
8481
6000
|
function getUnstableDelayQueryOpts(delayOpts) {
|
8482
|
-
return Object.fromEntries(Object.entries(delayOpts).map(
|
8483
|
-
var [k, v] =
|
6001
|
+
return Object.fromEntries(Object.entries(delayOpts).map(_ref11 => {
|
6002
|
+
var [k, v] = _ref11;
|
8484
6003
|
return ["".concat(UNSTABLE_MSC4140_DELAYED_EVENTS, ".").concat(k), v];
|
8485
6004
|
}));
|
8486
6005
|
}
|