@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/src/client.ts
CHANGED
@@ -20,7 +20,6 @@ limitations under the License.
|
|
20
20
|
|
21
21
|
import { Optional } from "matrix-events-sdk";
|
22
22
|
|
23
|
-
import type { IDeviceKeys, IMegolmSessionData, IOneTimeKey } from "./@types/crypto.ts";
|
24
23
|
import { ISyncStateData, SetPresence, SyncApi, SyncApiOptions, SyncState } from "./sync.ts";
|
25
24
|
import {
|
26
25
|
EventStatus,
|
@@ -33,25 +32,14 @@ import {
|
|
33
32
|
PushDetails,
|
34
33
|
} from "./models/event.ts";
|
35
34
|
import { StubStore } from "./store/stub.ts";
|
36
|
-
import { CallEvent, CallEventHandlerMap, createNewMatrixCall, MatrixCall, supportsMatrixCall } from "./webrtc/call.ts";
|
37
35
|
import { Filter, IFilterDefinition, IRoomEventFilter } from "./filter.ts";
|
38
|
-
import { CallEventHandler, CallEventHandlerEvent, CallEventHandlerEventHandlerMap } from "./webrtc/callEventHandler.ts";
|
39
|
-
import {
|
40
|
-
GroupCallEventHandler,
|
41
|
-
GroupCallEventHandlerEvent,
|
42
|
-
GroupCallEventHandlerEventHandlerMap,
|
43
|
-
} from "./webrtc/groupCallEventHandler.ts";
|
44
36
|
import * as utils from "./utils.ts";
|
45
|
-
import { noUnsafeEventProps, QueryDict, replaceParam,
|
37
|
+
import { noUnsafeEventProps, QueryDict, replaceParam, sleep } from "./utils.ts";
|
46
38
|
import { Direction, EventTimeline } from "./models/event-timeline.ts";
|
47
39
|
import { IActionsObject, PushProcessor } from "./pushprocessor.ts";
|
48
40
|
import { AutoDiscovery, AutoDiscoveryAction } from "./autodiscovery.ts";
|
49
|
-
import
|
50
|
-
import { decodeBase64, encodeBase64, encodeUnpaddedBase64Url } from "./base64.ts";
|
51
|
-
import { IExportedDevice as IExportedOlmDevice } from "./crypto/OlmDevice.ts";
|
52
|
-
import { IOlmDevice } from "./crypto/algorithms/megolm.ts";
|
41
|
+
import { encodeUnpaddedBase64Url } from "./base64.ts";
|
53
42
|
import { TypedReEmitter } from "./ReEmitter.ts";
|
54
|
-
import { IRoomEncryption } from "./crypto/RoomList.ts";
|
55
43
|
import { logger, Logger } from "./logger.ts";
|
56
44
|
import { SERVICE_TYPES } from "./service-types.ts";
|
57
45
|
import {
|
@@ -60,7 +48,6 @@ import {
|
|
60
48
|
FileType,
|
61
49
|
HttpApiEvent,
|
62
50
|
HttpApiEventHandlerMap,
|
63
|
-
HTTPError,
|
64
51
|
IdentityPrefix,
|
65
52
|
IHttpOpts,
|
66
53
|
IRequestOpts,
|
@@ -74,38 +61,16 @@ import {
|
|
74
61
|
UploadOpts,
|
75
62
|
UploadResponse,
|
76
63
|
} from "./http-api/index.ts";
|
77
|
-
import {
|
78
|
-
Crypto,
|
79
|
-
CryptoEvent as LegacyCryptoEvent,
|
80
|
-
CryptoEventHandlerMap as LegacyCryptoEventHandlerMap,
|
81
|
-
fixBackupKey,
|
82
|
-
ICheckOwnCrossSigningTrustOpts,
|
83
|
-
IRoomKeyRequestBody,
|
84
|
-
} from "./crypto/index.ts";
|
85
|
-
import { DeviceInfo } from "./crypto/deviceinfo.ts";
|
86
64
|
import { User, UserEvent, UserEventHandlerMap } from "./models/user.ts";
|
87
65
|
import { getHttpUriForMxc } from "./content-repo.ts";
|
88
66
|
import { SearchResult } from "./models/search-result.ts";
|
89
|
-
import { DEHYDRATION_ALGORITHM, IDehydratedDevice, IDehydratedDeviceKeyInfo } from "./crypto/dehydration.ts";
|
90
|
-
import {
|
91
|
-
IKeyBackupInfo,
|
92
|
-
IKeyBackupPrepareOpts,
|
93
|
-
IKeyBackupRestoreOpts,
|
94
|
-
IKeyBackupRestoreResult,
|
95
|
-
IKeyBackupRoomSessions,
|
96
|
-
IKeyBackupSession,
|
97
|
-
} from "./crypto/keybackup.ts";
|
98
67
|
import { IIdentityServerProvider } from "./@types/IIdentityServerProvider.ts";
|
99
68
|
import { MatrixScheduler } from "./scheduler.ts";
|
100
69
|
import { BeaconEvent, BeaconEventHandlerMap } from "./models/beacon.ts";
|
101
70
|
import { AuthDict } from "./interactive-auth.ts";
|
102
71
|
import { IMinimalEvent, IRoomEvent, IStateEvent } from "./sync-accumulator.ts";
|
103
|
-
import { CrossSigningKey, ICreateSecretStorageOpts, IEncryptedEventInfo, IRecoveryKey } from "./crypto/api.ts";
|
104
72
|
import { EventTimelineSet } from "./models/event-timeline-set.ts";
|
105
|
-
import { VerificationRequest } from "./crypto/verification/request/VerificationRequest.ts";
|
106
|
-
import { VerificationBase as Verification } from "./crypto/verification/Base.ts";
|
107
73
|
import * as ContentHelpers from "./content-helpers.ts";
|
108
|
-
import { CrossSigningInfo, DeviceTrustLevel, ICacheCallbacks, UserTrustLevel } from "./crypto/CrossSigning.ts";
|
109
74
|
import { NotificationCountType, Room, RoomEvent, RoomEventHandlerMap, RoomNameState } from "./models/room.ts";
|
110
75
|
import { RoomMemberEvent, RoomMemberEventHandlerMap } from "./models/room-member.ts";
|
111
76
|
import { IPowerLevelsContent, RoomStateEvent, RoomStateEventHandlerMap } from "./models/room-state.ts";
|
@@ -160,11 +125,9 @@ import {
|
|
160
125
|
} from "./@types/partials.ts";
|
161
126
|
import { EventMapper, eventMapperFor, MapperOpts } from "./event-mapper.ts";
|
162
127
|
import { randomString } from "./randomstring.ts";
|
163
|
-
import { BackupManager, IKeyBackup, IKeyBackupCheck, IPreparedKeyBackupVersion, TrustInfo } from "./crypto/backup.ts";
|
164
128
|
import { DEFAULT_TREE_POWER_LEVELS_TEMPLATE, MSC3089TreeSpace } from "./models/MSC3089TreeSpace.ts";
|
165
129
|
import { ISignatures } from "./@types/signed.ts";
|
166
130
|
import { IStore } from "./store/index.ts";
|
167
|
-
import { ISecretRequest } from "./crypto/SecretStorage.ts";
|
168
131
|
import {
|
169
132
|
IEventWithRoomId,
|
170
133
|
ISearchRequestBody,
|
@@ -186,9 +149,6 @@ import {
|
|
186
149
|
RuleId,
|
187
150
|
} from "./@types/PushRules.ts";
|
188
151
|
import { IThreepid } from "./@types/threepids.ts";
|
189
|
-
import { CryptoStore, OutgoingRoomKeyRequest } from "./crypto/store/base.ts";
|
190
|
-
import { GroupCall, GroupCallIntent, GroupCallType, IGroupCallDataChannelOptions } from "./webrtc/groupCall.ts";
|
191
|
-
import { MediaHandler } from "./webrtc/mediaHandler.ts";
|
192
152
|
import {
|
193
153
|
ILoginFlowsResponse,
|
194
154
|
IRefreshTokenResponse,
|
@@ -217,41 +177,19 @@ import { IgnoredInvites } from "./models/invites-ignorer.ts";
|
|
217
177
|
import { UIARequest, UIAResponse } from "./@types/uia.ts";
|
218
178
|
import { LocalNotificationSettings } from "./@types/local_notifications.ts";
|
219
179
|
import { buildFeatureSupportMap, Feature, ServerSupport } from "./feature.ts";
|
220
|
-
import { BackupDecryptor, CryptoBackend } from "./common-crypto/CryptoBackend.ts";
|
221
|
-
import { RUST_SDK_STORE_PREFIX } from "./rust-crypto/constants.ts";
|
222
|
-
import {
|
223
|
-
BootstrapCrossSigningOpts,
|
224
|
-
CrossSigningKeyInfo,
|
225
|
-
CryptoApi,
|
226
|
-
decodeRecoveryKey,
|
227
|
-
ImportRoomKeysOpts,
|
228
|
-
CryptoEvent,
|
229
|
-
CryptoEventHandlerMap,
|
230
|
-
CryptoCallbacks,
|
231
|
-
} from "./crypto-api/index.ts";
|
232
|
-
import { DeviceInfoMap } from "./crypto/DeviceList.ts";
|
233
|
-
import {
|
234
|
-
AddSecretStorageKeyOpts,
|
235
|
-
SecretStorageKeyDescription,
|
236
|
-
ServerSideSecretStorage,
|
237
|
-
ServerSideSecretStorageImpl,
|
238
|
-
} from "./secret-storage.ts";
|
239
180
|
import { RegisterRequest, RegisterResponse } from "./@types/registration.ts";
|
240
|
-
import { MatrixRTCSessionManager } from "./matrixrtc/MatrixRTCSessionManager.ts";
|
241
181
|
import { getRelationsThreadFilter } from "./thread-utils.ts";
|
242
182
|
import { KnownMembership, Membership } from "./@types/membership.ts";
|
243
183
|
import { RoomMessageEventContent, StickerEventContent } from "./@types/events.ts";
|
244
184
|
import { ImageInfo } from "./@types/media.ts";
|
245
185
|
import { Capabilities, ServerCapabilities } from "./serverCapabilities.ts";
|
246
186
|
import { sha256 } from "./digest.ts";
|
247
|
-
import { keyFromAuthData } from "./common-crypto/key-passphrase.ts";
|
248
187
|
|
249
188
|
export type Store = IStore;
|
250
189
|
|
251
190
|
export type ResetTimelineCallback = (roomId: string) => boolean;
|
252
191
|
|
253
192
|
const SCROLLBACK_DELAY_MS = 3000;
|
254
|
-
const TURN_CHECK_INTERVAL = 10 * 60 * 1000; // poll for turn credentials every 10 minutes
|
255
193
|
|
256
194
|
export const UNSTABLE_MSC3852_LAST_SEEN_UA = new UnstableValue(
|
257
195
|
"last_seen_user_agent",
|
@@ -259,7 +197,6 @@ export const UNSTABLE_MSC3852_LAST_SEEN_UA = new UnstableValue(
|
|
259
197
|
);
|
260
198
|
|
261
199
|
interface IExportedDevice {
|
262
|
-
olmDevice: IExportedOlmDevice;
|
263
200
|
userId: string;
|
264
201
|
deviceId: string;
|
265
202
|
}
|
@@ -283,20 +220,6 @@ export interface ICreateClientOpts {
|
|
283
220
|
*/
|
284
221
|
store?: Store;
|
285
222
|
|
286
|
-
/**
|
287
|
-
* A store to be used for end-to-end crypto session data.
|
288
|
-
* The `createClient` helper will create a default store if needed. Calls the factory supplied to
|
289
|
-
* {@link setCryptoStoreFactory} if unspecified; or if no factory has been
|
290
|
-
* specified, uses a default implementation (indexeddb in the browser,
|
291
|
-
* in-memory otherwise).
|
292
|
-
*
|
293
|
-
* This is only used for the legacy crypto implementation (as used by {@link MatrixClient#initCrypto}),
|
294
|
-
* but if you use the rust crypto implementation ({@link MatrixClient#initRustCrypto}) and the device
|
295
|
-
* previously used legacy crypto (so must be migrated), then this must still be provided, so that the
|
296
|
-
* data can be migrated from the legacy store.
|
297
|
-
*/
|
298
|
-
cryptoStore?: CryptoStore;
|
299
|
-
|
300
223
|
/**
|
301
224
|
* The scheduler to use. If not
|
302
225
|
* specified, this client will not retry requests on failure. This client
|
@@ -432,11 +355,6 @@ export interface ICreateClientOpts {
|
|
432
355
|
|
433
356
|
livekitServiceURL?: string;
|
434
357
|
|
435
|
-
/**
|
436
|
-
* Crypto callbacks provided by the application
|
437
|
-
*/
|
438
|
-
cryptoCallbacks?: CryptoCallbacks;
|
439
|
-
|
440
358
|
/**
|
441
359
|
* Method to generate room names for empty rooms and rooms names based on membership.
|
442
360
|
* Defaults to a built-in English handler with basic pluralisation.
|
@@ -555,14 +473,6 @@ export const UNSTABLE_MSC4140_DELAYED_EVENTS = "org.matrix.msc4140";
|
|
555
473
|
|
556
474
|
export const UNSTABLE_MSC4133_EXTENDED_PROFILES = "uk.tcpip.msc4133";
|
557
475
|
|
558
|
-
enum CrossSigningKeyType {
|
559
|
-
MasterKey = "master_key",
|
560
|
-
SelfSigningKey = "self_signing_key",
|
561
|
-
UserSigningKey = "user_signing_key",
|
562
|
-
}
|
563
|
-
|
564
|
-
export type CrossSigningKeys = Record<CrossSigningKeyType, CrossSigningKeyInfo>;
|
565
|
-
|
566
476
|
export type SendToDeviceContentMap = Map<string, Map<string, Record<string, any>>>;
|
567
477
|
|
568
478
|
export interface ISignedKey {
|
@@ -573,7 +483,6 @@ export interface ISignedKey {
|
|
573
483
|
device_id: string;
|
574
484
|
}
|
575
485
|
|
576
|
-
export type KeySignatures = Record<string, Record<string, CrossSigningKeyInfo | ISignedKey>>;
|
577
486
|
export interface IUploadKeySignaturesResponse {
|
578
487
|
failures: Record<
|
579
488
|
string,
|
@@ -635,13 +544,6 @@ export interface IWellKnownConfig<T = IClientWellKnown> {
|
|
635
544
|
server_name?: string;
|
636
545
|
}
|
637
546
|
|
638
|
-
interface IKeyBackupPath {
|
639
|
-
path: string;
|
640
|
-
queryData?: {
|
641
|
-
version: string;
|
642
|
-
};
|
643
|
-
}
|
644
|
-
|
645
547
|
interface IMediaConfig {
|
646
548
|
[key: string]: any; // extensible
|
647
549
|
"m.upload.size"?: number;
|
@@ -688,12 +590,6 @@ export interface IRequestMsisdnTokenResponse extends IRequestTokenResponse {
|
|
688
590
|
intl_fmt: string;
|
689
591
|
}
|
690
592
|
|
691
|
-
export interface IUploadKeysRequest {
|
692
|
-
"device_keys"?: Required<IDeviceKeys>;
|
693
|
-
"one_time_keys"?: Record<string, IOneTimeKey>;
|
694
|
-
"org.matrix.msc2732.fallback_keys"?: Record<string, IOneTimeKey>;
|
695
|
-
}
|
696
|
-
|
697
593
|
export interface IQueryKeysRequest {
|
698
594
|
device_keys: { [userId: string]: string[] };
|
699
595
|
timeout?: number;
|
@@ -788,27 +684,6 @@ export interface Keys {
|
|
788
684
|
user_id: string;
|
789
685
|
}
|
790
686
|
|
791
|
-
export interface SigningKeys extends Keys {
|
792
|
-
signatures: ISignatures;
|
793
|
-
}
|
794
|
-
|
795
|
-
export interface DeviceKeys {
|
796
|
-
[deviceId: string]: IDeviceKeys & {
|
797
|
-
unsigned?: {
|
798
|
-
device_display_name: string;
|
799
|
-
};
|
800
|
-
};
|
801
|
-
}
|
802
|
-
|
803
|
-
export interface IDownloadKeyResult {
|
804
|
-
failures: { [serverName: string]: object };
|
805
|
-
device_keys: { [userId: string]: DeviceKeys };
|
806
|
-
// the following three fields were added in 1.1
|
807
|
-
master_keys?: { [userId: string]: Keys };
|
808
|
-
self_signing_keys?: { [userId: string]: SigningKeys };
|
809
|
-
user_signing_keys?: { [userId: string]: SigningKeys };
|
810
|
-
}
|
811
|
-
|
812
687
|
export interface IClaimOTKsResult {
|
813
688
|
failures: { [serverName: string]: object };
|
814
689
|
one_time_keys: {
|
@@ -877,14 +752,6 @@ export interface RoomSummary extends Omit<IPublicRoomsChunkRoom, "canonical_alia
|
|
877
752
|
"im.nheko.summary.encryption"?: string;
|
878
753
|
}
|
879
754
|
|
880
|
-
interface IRoomKeysResponse {
|
881
|
-
sessions: IKeyBackupRoomSessions;
|
882
|
-
}
|
883
|
-
|
884
|
-
interface IRoomsKeysResponse {
|
885
|
-
rooms: Record<string, IRoomKeysResponse>;
|
886
|
-
}
|
887
|
-
|
888
755
|
interface IRoomHierarchy {
|
889
756
|
rooms: IHierarchyRoom[];
|
890
757
|
next_batch?: string;
|
@@ -943,26 +810,6 @@ type RoomStateEvents =
|
|
943
810
|
| RoomStateEvent.Update
|
944
811
|
| RoomStateEvent.Marker;
|
945
812
|
|
946
|
-
type LegacyCryptoEvents =
|
947
|
-
| LegacyCryptoEvent.KeySignatureUploadFailure
|
948
|
-
| LegacyCryptoEvent.KeyBackupStatus
|
949
|
-
| LegacyCryptoEvent.KeyBackupFailed
|
950
|
-
| LegacyCryptoEvent.KeyBackupSessionsRemaining
|
951
|
-
| LegacyCryptoEvent.KeyBackupDecryptionKeyCached
|
952
|
-
| LegacyCryptoEvent.RoomKeyRequest
|
953
|
-
| LegacyCryptoEvent.RoomKeyRequestCancellation
|
954
|
-
| LegacyCryptoEvent.VerificationRequest
|
955
|
-
| LegacyCryptoEvent.VerificationRequestReceived
|
956
|
-
| LegacyCryptoEvent.DeviceVerificationChanged
|
957
|
-
| LegacyCryptoEvent.UserTrustStatusChanged
|
958
|
-
| LegacyCryptoEvent.KeysChanged
|
959
|
-
| LegacyCryptoEvent.Warning
|
960
|
-
| LegacyCryptoEvent.DevicesUpdated
|
961
|
-
| LegacyCryptoEvent.WillUpdateDevices
|
962
|
-
| LegacyCryptoEvent.LegacyCryptoStoreMigrationProgress;
|
963
|
-
|
964
|
-
type CryptoEvents = (typeof CryptoEvent)[keyof typeof CryptoEvent];
|
965
|
-
|
966
813
|
type MatrixEventEvents = MatrixEventEvent.Decrypted | MatrixEventEvent.Replaced | MatrixEventEvent.VisibilityChange;
|
967
814
|
|
968
815
|
type RoomMemberEvents =
|
@@ -982,17 +829,9 @@ export type EmittedEvents =
|
|
982
829
|
| ClientEvent
|
983
830
|
| RoomEvents
|
984
831
|
| RoomStateEvents
|
985
|
-
| LegacyCryptoEvents
|
986
|
-
| CryptoEvents
|
987
832
|
| MatrixEventEvents
|
988
833
|
| RoomMemberEvents
|
989
834
|
| UserEvents
|
990
|
-
| CallEvent // re-emitted by call.ts using Object.values
|
991
|
-
| CallEventHandlerEvent.Incoming
|
992
|
-
| GroupCallEventHandlerEvent.Incoming
|
993
|
-
| GroupCallEventHandlerEvent.Outgoing
|
994
|
-
| GroupCallEventHandlerEvent.Ended
|
995
|
-
| GroupCallEventHandlerEvent.Participants
|
996
835
|
| HttpApiEvent.SessionLoggedOut
|
997
836
|
| HttpApiEvent.NoConsent
|
998
837
|
| BeaconEvent;
|
@@ -1194,14 +1033,9 @@ export type ClientEventHandlerMap = {
|
|
1194
1033
|
[ClientEvent.TurnServersError]: (error: Error, fatal: boolean) => void;
|
1195
1034
|
} & RoomEventHandlerMap &
|
1196
1035
|
RoomStateEventHandlerMap &
|
1197
|
-
LegacyCryptoEventHandlerMap &
|
1198
|
-
CryptoEventHandlerMap &
|
1199
1036
|
MatrixEventHandlerMap &
|
1200
1037
|
RoomMemberEventHandlerMap &
|
1201
1038
|
UserEventHandlerMap &
|
1202
|
-
CallEventHandlerEventHandlerMap &
|
1203
|
-
GroupCallEventHandlerEventHandlerMap &
|
1204
|
-
CallEventHandlerMap &
|
1205
1039
|
HttpApiEventHandlerMap &
|
1206
1040
|
BeaconEventHandlerMap;
|
1207
1041
|
|
@@ -1242,18 +1076,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
1242
1076
|
public identityServer?: IIdentityServerProvider;
|
1243
1077
|
public http: MatrixHttpApi<IHttpOpts & { onlyData: true }>; // XXX: Intended private, used in code.
|
1244
1078
|
|
1245
|
-
/**
|
1246
|
-
* The libolm crypto implementation, if it is in use.
|
1247
|
-
*
|
1248
|
-
* @deprecated This should not be used. Instead, use the methods exposed directly on this class or
|
1249
|
-
* (where they are available) via {@link getCrypto}.
|
1250
|
-
*/
|
1251
|
-
public crypto?: Crypto; // XXX: Intended private, used in code. Being replaced by cryptoBackend
|
1252
|
-
|
1253
|
-
private cryptoBackend?: CryptoBackend; // one of crypto or rustCrypto
|
1254
|
-
public cryptoCallbacks: CryptoCallbacks; // XXX: Intended private, used in code.
|
1255
|
-
public callEventHandler?: CallEventHandler; // XXX: Intended private, used in code.
|
1256
|
-
public groupCallEventHandler?: GroupCallEventHandler;
|
1257
1079
|
public supportsCallTransfer = false; // XXX: Intended private, used in code.
|
1258
1080
|
public forceTURN = false; // XXX: Intended private, used in code.
|
1259
1081
|
public iceCandidatePoolSize = 0; // XXX: Intended private, used in code.
|
@@ -1266,13 +1088,11 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
1266
1088
|
// Note: these are all `protected` to let downstream consumers make mistakes if they want to.
|
1267
1089
|
// We don't technically support this usage, but have reasons to do this.
|
1268
1090
|
|
1269
|
-
protected canSupportVoip = false;
|
1270
1091
|
protected peekSync: SyncApi | null = null;
|
1271
1092
|
protected isGuestAccount = false;
|
1272
1093
|
protected ongoingScrollbacks: { [roomId: string]: { promise?: Promise<Room>; errorTs?: number } } = {};
|
1273
1094
|
protected notifTimelineSet: EventTimelineSet | null = null;
|
1274
1095
|
/* @deprecated */
|
1275
|
-
protected cryptoStore?: CryptoStore;
|
1276
1096
|
protected verificationMethods?: string[];
|
1277
1097
|
protected fallbackICEServerAllowed = false;
|
1278
1098
|
protected syncApi?: SlidingSyncSdk | SyncApi;
|
@@ -1295,12 +1115,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
1295
1115
|
|
1296
1116
|
protected clientWellKnown?: IClientWellKnown;
|
1297
1117
|
protected clientWellKnownPromise?: Promise<IClientWellKnown>;
|
1298
|
-
protected turnServers: ITurnServer[] = [];
|
1299
|
-
protected turnServersExpiry = 0;
|
1300
|
-
protected checkTurnServersIntervalID?: ReturnType<typeof setInterval>;
|
1301
|
-
protected exportedOlmDeviceToImport?: IExportedOlmDevice;
|
1302
1118
|
protected txnCtr = 0;
|
1303
|
-
protected mediaHandler = new MediaHandler(this);
|
1304
1119
|
protected sessionId: string;
|
1305
1120
|
|
1306
1121
|
/** IDs of events which are currently being encrypted.
|
@@ -1314,13 +1129,9 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
1314
1129
|
private toDeviceMessageQueue: ToDeviceMessageQueue;
|
1315
1130
|
public livekitServiceURL?: string;
|
1316
1131
|
|
1317
|
-
private _secretStorage: ServerSideSecretStorageImpl;
|
1318
|
-
|
1319
1132
|
// A manager for determining which invites should be ignored.
|
1320
1133
|
public readonly ignoredInvites: IgnoredInvites;
|
1321
1134
|
|
1322
|
-
public readonly matrixRTC: MatrixRTCSessionManager;
|
1323
|
-
|
1324
1135
|
private serverCapabilitiesService: ServerCapabilities;
|
1325
1136
|
|
1326
1137
|
public constructor(opts: IMatrixClientCreateOpts) {
|
@@ -1376,8 +1187,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
1376
1187
|
} else {
|
1377
1188
|
this.deviceId = opts.deviceToImport.deviceId;
|
1378
1189
|
this.credentials.userId = opts.deviceToImport.userId;
|
1379
|
-
// will be used during async initialization of the crypto
|
1380
|
-
this.exportedOlmDeviceToImport = opts.deviceToImport.olmDevice;
|
1381
1190
|
}
|
1382
1191
|
} else if (opts.pickleKey) {
|
1383
1192
|
this.pickleKey = opts.pickleKey;
|
@@ -1402,29 +1211,13 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
1402
1211
|
});
|
1403
1212
|
}
|
1404
1213
|
|
1405
|
-
if (supportsMatrixCall()) {
|
1406
|
-
this.callEventHandler = new CallEventHandler(this);
|
1407
|
-
this.groupCallEventHandler = new GroupCallEventHandler(this);
|
1408
|
-
this.canSupportVoip = true;
|
1409
|
-
// Start listening for calls after the initial sync is done
|
1410
|
-
// We do not need to backfill the call event buffer
|
1411
|
-
// with encrypted events that might never get decrypted
|
1412
|
-
this.on(ClientEvent.Sync, this.startCallEventHandler);
|
1413
|
-
}
|
1414
|
-
|
1415
|
-
// NB. We initialise MatrixRTC whether we have call support or not: this is just
|
1416
|
-
// the underlying session management and doesn't use any actual media capabilities
|
1417
|
-
this.matrixRTC = new MatrixRTCSessionManager(this);
|
1418
|
-
|
1419
1214
|
this.serverCapabilitiesService = new ServerCapabilities(this.http);
|
1420
1215
|
|
1421
1216
|
this.on(ClientEvent.Sync, this.fixupRoomNotifications);
|
1422
1217
|
|
1423
1218
|
this.timelineSupport = Boolean(opts.timelineSupport);
|
1424
1219
|
|
1425
|
-
this.cryptoStore = opts.cryptoStore;
|
1426
1220
|
this.verificationMethods = opts.verificationMethods;
|
1427
|
-
this.cryptoCallbacks = opts.cryptoCallbacks || {};
|
1428
1221
|
|
1429
1222
|
this.forceTURN = opts.forceTURN || false;
|
1430
1223
|
this.iceCandidatePoolSize = opts.iceCandidatePoolSize === undefined ? 0 : opts.iceCandidatePoolSize;
|
@@ -1449,7 +1242,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
1449
1242
|
});
|
1450
1243
|
|
1451
1244
|
this.ignoredInvites = new IgnoredInvites(this);
|
1452
|
-
this._secretStorage = new ServerSideSecretStorageImpl(this, opts.cryptoCallbacks ?? {});
|
1453
1245
|
|
1454
1246
|
// having lots of event listeners is not unusual. 0 means "unlimited".
|
1455
1247
|
this.setMaxListeners(0);
|
@@ -1478,8 +1270,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
1478
1270
|
}
|
1479
1271
|
this.clientRunning = true;
|
1480
1272
|
|
1481
|
-
this.on(ClientEvent.Sync, this.startMatrixRTC);
|
1482
|
-
|
1483
1273
|
// Create our own user object artificially (instead of waiting for sync)
|
1484
1274
|
// so it's always available, even if the user is not in any rooms etc.
|
1485
1275
|
const userId = this.getUserId();
|
@@ -1487,15 +1277,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
1487
1277
|
this.store.storeUser(new User(userId));
|
1488
1278
|
}
|
1489
1279
|
|
1490
|
-
// periodically poll for turn servers if we support voip
|
1491
|
-
if (this.canSupportVoip) {
|
1492
|
-
this.checkTurnServersIntervalID = setInterval(() => {
|
1493
|
-
this.checkTurnServers();
|
1494
|
-
}, TURN_CHECK_INTERVAL);
|
1495
|
-
// noinspection ES6MissingAwait
|
1496
|
-
this.checkTurnServers();
|
1497
|
-
}
|
1498
|
-
|
1499
1280
|
if (this.syncApi) {
|
1500
1281
|
// This shouldn't happen since we thought the client was not running
|
1501
1282
|
this.logger.error("Still have sync object whilst not running: stopping old one");
|
@@ -1524,7 +1305,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
1524
1305
|
this.clientOpts.slidingSync,
|
1525
1306
|
this,
|
1526
1307
|
this.clientOpts,
|
1527
|
-
this.buildSyncApiOptions(),
|
1528
1308
|
);
|
1529
1309
|
} else {
|
1530
1310
|
this.syncApi = new SyncApi(this, this.clientOpts, this.buildSyncApiOptions());
|
@@ -1548,8 +1328,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
1548
1328
|
*/
|
1549
1329
|
protected buildSyncApiOptions(): SyncApiOptions {
|
1550
1330
|
return {
|
1551
|
-
crypto: this.crypto,
|
1552
|
-
cryptoCallbacks: this.cryptoBackend,
|
1553
1331
|
canResetEntireTimeline: (roomId: string): boolean => {
|
1554
1332
|
if (!this.canResetTimelineCallback) {
|
1555
1333
|
return false;
|
@@ -1564,10 +1342,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
1564
1342
|
* clean shutdown.
|
1565
1343
|
*/
|
1566
1344
|
public stopClient(): void {
|
1567
|
-
this.cryptoBackend?.stop(); // crypto might have been initialised even if the client wasn't fully started
|
1568
|
-
|
1569
|
-
this.off(ClientEvent.Sync, this.startMatrixRTC);
|
1570
|
-
|
1571
1345
|
if (!this.clientRunning) return; // already stopped
|
1572
1346
|
|
1573
1347
|
this.logger.debug("stopping MatrixClient");
|
@@ -1579,190 +1353,15 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
1579
1353
|
|
1580
1354
|
this.peekSync?.stopPeeking();
|
1581
1355
|
|
1582
|
-
this.callEventHandler?.stop();
|
1583
|
-
this.groupCallEventHandler?.stop();
|
1584
|
-
this.callEventHandler = undefined;
|
1585
|
-
this.groupCallEventHandler = undefined;
|
1586
|
-
|
1587
|
-
globalThis.clearInterval(this.checkTurnServersIntervalID);
|
1588
|
-
this.checkTurnServersIntervalID = undefined;
|
1589
|
-
|
1590
1356
|
if (this.clientWellKnownIntervalID !== undefined) {
|
1591
1357
|
globalThis.clearInterval(this.clientWellKnownIntervalID);
|
1592
1358
|
}
|
1593
1359
|
|
1594
1360
|
this.toDeviceMessageQueue.stop();
|
1595
1361
|
|
1596
|
-
this.matrixRTC.stop();
|
1597
|
-
|
1598
1362
|
this.serverCapabilitiesService.stop();
|
1599
1363
|
}
|
1600
1364
|
|
1601
|
-
/**
|
1602
|
-
* Try to rehydrate a device if available. The client must have been
|
1603
|
-
* initialized with a `cryptoCallback.getDehydrationKey` option, and this
|
1604
|
-
* function must be called before initCrypto and startClient are called.
|
1605
|
-
*
|
1606
|
-
* @returns Promise which resolves to undefined if a device could not be dehydrated, or
|
1607
|
-
* to the new device ID if the dehydration was successful.
|
1608
|
-
* @returns Rejects: with an error response.
|
1609
|
-
*
|
1610
|
-
* @deprecated MSC2697 device dehydration is not supported for rust cryptography.
|
1611
|
-
*/
|
1612
|
-
public async rehydrateDevice(): Promise<string | undefined> {
|
1613
|
-
if (this.crypto) {
|
1614
|
-
throw new Error("Cannot rehydrate device after crypto is initialized");
|
1615
|
-
}
|
1616
|
-
|
1617
|
-
if (!this.cryptoCallbacks.getDehydrationKey) {
|
1618
|
-
return;
|
1619
|
-
}
|
1620
|
-
|
1621
|
-
const getDeviceResult = await this.getDehydratedDevice();
|
1622
|
-
if (!getDeviceResult) {
|
1623
|
-
return;
|
1624
|
-
}
|
1625
|
-
|
1626
|
-
if (!getDeviceResult.device_data || !getDeviceResult.device_id) {
|
1627
|
-
this.logger.info("no dehydrated device found");
|
1628
|
-
return;
|
1629
|
-
}
|
1630
|
-
|
1631
|
-
const account = new globalThis.Olm.Account();
|
1632
|
-
try {
|
1633
|
-
const deviceData = getDeviceResult.device_data;
|
1634
|
-
if (deviceData.algorithm !== DEHYDRATION_ALGORITHM) {
|
1635
|
-
this.logger.warn("Wrong algorithm for dehydrated device");
|
1636
|
-
return;
|
1637
|
-
}
|
1638
|
-
this.logger.debug("unpickling dehydrated device");
|
1639
|
-
const key = await this.cryptoCallbacks.getDehydrationKey(deviceData, (k) => {
|
1640
|
-
// copy the key so that it doesn't get clobbered
|
1641
|
-
account.unpickle(new Uint8Array(k), deviceData.account);
|
1642
|
-
});
|
1643
|
-
account.unpickle(key, deviceData.account);
|
1644
|
-
this.logger.debug("unpickled device");
|
1645
|
-
|
1646
|
-
const rehydrateResult = await this.http.authedRequest<{ success: boolean }>(
|
1647
|
-
Method.Post,
|
1648
|
-
"/dehydrated_device/claim",
|
1649
|
-
undefined,
|
1650
|
-
{
|
1651
|
-
device_id: getDeviceResult.device_id,
|
1652
|
-
},
|
1653
|
-
{
|
1654
|
-
prefix: "/_matrix/client/unstable/org.matrix.msc2697.v2",
|
1655
|
-
},
|
1656
|
-
);
|
1657
|
-
|
1658
|
-
if (rehydrateResult.success) {
|
1659
|
-
this.deviceId = getDeviceResult.device_id;
|
1660
|
-
this.logger.info("using dehydrated device");
|
1661
|
-
const pickleKey = this.pickleKey || "DEFAULT_KEY";
|
1662
|
-
this.exportedOlmDeviceToImport = {
|
1663
|
-
pickledAccount: account.pickle(pickleKey),
|
1664
|
-
sessions: [],
|
1665
|
-
pickleKey: pickleKey,
|
1666
|
-
};
|
1667
|
-
account.free();
|
1668
|
-
return this.deviceId;
|
1669
|
-
} else {
|
1670
|
-
account.free();
|
1671
|
-
this.logger.info("not using dehydrated device");
|
1672
|
-
return;
|
1673
|
-
}
|
1674
|
-
} catch (e) {
|
1675
|
-
account.free();
|
1676
|
-
this.logger.warn("could not unpickle", e);
|
1677
|
-
}
|
1678
|
-
}
|
1679
|
-
|
1680
|
-
/**
|
1681
|
-
* Get the current dehydrated device, if any
|
1682
|
-
* @returns A promise of an object containing the dehydrated device
|
1683
|
-
*
|
1684
|
-
* @deprecated MSC2697 device dehydration is not supported for rust cryptography.
|
1685
|
-
*/
|
1686
|
-
public async getDehydratedDevice(): Promise<IDehydratedDevice | undefined> {
|
1687
|
-
try {
|
1688
|
-
return await this.http.authedRequest<IDehydratedDevice>(
|
1689
|
-
Method.Get,
|
1690
|
-
"/dehydrated_device",
|
1691
|
-
undefined,
|
1692
|
-
undefined,
|
1693
|
-
{
|
1694
|
-
prefix: "/_matrix/client/unstable/org.matrix.msc2697.v2",
|
1695
|
-
},
|
1696
|
-
);
|
1697
|
-
} catch (e) {
|
1698
|
-
this.logger.info("could not get dehydrated device", e);
|
1699
|
-
return;
|
1700
|
-
}
|
1701
|
-
}
|
1702
|
-
|
1703
|
-
/**
|
1704
|
-
* Set the dehydration key. This will also periodically dehydrate devices to
|
1705
|
-
* the server.
|
1706
|
-
*
|
1707
|
-
* @param key - the dehydration key
|
1708
|
-
* @param keyInfo - Information about the key. Primarily for
|
1709
|
-
* information about how to generate the key from a passphrase.
|
1710
|
-
* @param deviceDisplayName - The device display name for the
|
1711
|
-
* dehydrated device.
|
1712
|
-
* @returns A promise that resolves when the dehydrated device is stored.
|
1713
|
-
*
|
1714
|
-
* @deprecated Not supported for Rust Cryptography.
|
1715
|
-
*/
|
1716
|
-
public async setDehydrationKey(
|
1717
|
-
key: Uint8Array,
|
1718
|
-
keyInfo: IDehydratedDeviceKeyInfo,
|
1719
|
-
deviceDisplayName?: string,
|
1720
|
-
): Promise<void> {
|
1721
|
-
if (!this.crypto) {
|
1722
|
-
this.logger.warn("not dehydrating device if crypto is not enabled");
|
1723
|
-
return;
|
1724
|
-
}
|
1725
|
-
return this.crypto.dehydrationManager.setKeyAndQueueDehydration(key, keyInfo, deviceDisplayName);
|
1726
|
-
}
|
1727
|
-
|
1728
|
-
/**
|
1729
|
-
* Creates a new MSC2967 dehydrated device (without queuing periodic dehydration)
|
1730
|
-
* @param key - the dehydration key
|
1731
|
-
* @param keyInfo - Information about the key. Primarily for
|
1732
|
-
* information about how to generate the key from a passphrase.
|
1733
|
-
* @param deviceDisplayName - The device display name for the
|
1734
|
-
* dehydrated device.
|
1735
|
-
* @returns the device id of the newly created dehydrated device
|
1736
|
-
*
|
1737
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.startDehydration}.
|
1738
|
-
*/
|
1739
|
-
public async createDehydratedDevice(
|
1740
|
-
key: Uint8Array,
|
1741
|
-
keyInfo: IDehydratedDeviceKeyInfo,
|
1742
|
-
deviceDisplayName?: string,
|
1743
|
-
): Promise<string | undefined> {
|
1744
|
-
if (!this.crypto) {
|
1745
|
-
this.logger.warn("not dehydrating device if crypto is not enabled");
|
1746
|
-
return;
|
1747
|
-
}
|
1748
|
-
await this.crypto.dehydrationManager.setKey(key, keyInfo, deviceDisplayName);
|
1749
|
-
return this.crypto.dehydrationManager.dehydrateDevice();
|
1750
|
-
}
|
1751
|
-
|
1752
|
-
/** @deprecated Not supported for Rust Cryptography. */
|
1753
|
-
public async exportDevice(): Promise<IExportedDevice | undefined> {
|
1754
|
-
if (!this.crypto) {
|
1755
|
-
this.logger.warn("not exporting device if crypto is not enabled");
|
1756
|
-
return;
|
1757
|
-
}
|
1758
|
-
return {
|
1759
|
-
userId: this.credentials.userId!,
|
1760
|
-
deviceId: this.deviceId!,
|
1761
|
-
// XXX: Private member access.
|
1762
|
-
olmDevice: await this.crypto.olmDevice.export(),
|
1763
|
-
};
|
1764
|
-
}
|
1765
|
-
|
1766
1365
|
/**
|
1767
1366
|
* Clear any data out of the persistent stores used by the client.
|
1768
1367
|
*
|
@@ -1776,48 +1375,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
1776
1375
|
const promises: Promise<void>[] = [];
|
1777
1376
|
|
1778
1377
|
promises.push(this.store.deleteAllData());
|
1779
|
-
if (this.cryptoStore) {
|
1780
|
-
promises.push(this.cryptoStore.deleteAllData());
|
1781
|
-
}
|
1782
|
-
|
1783
|
-
// delete the stores used by the rust matrix-sdk-crypto, in case they were used
|
1784
|
-
const deleteRustSdkStore = async (): Promise<void> => {
|
1785
|
-
let indexedDB: IDBFactory;
|
1786
|
-
try {
|
1787
|
-
indexedDB = globalThis.indexedDB;
|
1788
|
-
if (!indexedDB) return; // No indexedDB support
|
1789
|
-
} catch {
|
1790
|
-
// No indexedDB support
|
1791
|
-
return;
|
1792
|
-
}
|
1793
|
-
for (const dbname of [
|
1794
|
-
`${RUST_SDK_STORE_PREFIX}::matrix-sdk-crypto`,
|
1795
|
-
`${RUST_SDK_STORE_PREFIX}::matrix-sdk-crypto-meta`,
|
1796
|
-
]) {
|
1797
|
-
const prom = new Promise((resolve, reject) => {
|
1798
|
-
this.logger.info(`Removing IndexedDB instance ${dbname}`);
|
1799
|
-
const req = indexedDB.deleteDatabase(dbname);
|
1800
|
-
req.onsuccess = (_): void => {
|
1801
|
-
this.logger.info(`Removed IndexedDB instance ${dbname}`);
|
1802
|
-
resolve(0);
|
1803
|
-
};
|
1804
|
-
req.onerror = (e): void => {
|
1805
|
-
// In private browsing, Firefox has a globalThis.indexedDB, but attempts to delete an indexeddb
|
1806
|
-
// (even a non-existent one) fail with "DOMException: A mutation operation was attempted on a
|
1807
|
-
// database that did not allow mutations."
|
1808
|
-
//
|
1809
|
-
// it seems like the only thing we can really do is ignore the error.
|
1810
|
-
this.logger.warn(`Failed to remove IndexedDB instance ${dbname}:`, e);
|
1811
|
-
resolve(0);
|
1812
|
-
};
|
1813
|
-
req.onblocked = (e): void => {
|
1814
|
-
this.logger.info(`cannot yet remove IndexedDB instance ${dbname}`);
|
1815
|
-
};
|
1816
|
-
});
|
1817
|
-
await prom;
|
1818
|
-
}
|
1819
|
-
};
|
1820
|
-
promises.push(deleteRustSdkStore());
|
1821
1378
|
|
1822
1379
|
return Promise.all(promises).then(); // .then to fix types
|
1823
1380
|
}
|
@@ -1886,21 +1443,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
1886
1443
|
return this.sessionId;
|
1887
1444
|
}
|
1888
1445
|
|
1889
|
-
/**
|
1890
|
-
* Check if the runtime environment supports VoIP calling.
|
1891
|
-
* @returns True if VoIP is supported.
|
1892
|
-
*/
|
1893
|
-
public supportsVoip(): boolean {
|
1894
|
-
return this.canSupportVoip;
|
1895
|
-
}
|
1896
|
-
|
1897
|
-
/**
|
1898
|
-
* @returns
|
1899
|
-
*/
|
1900
|
-
public getMediaHandler(): MediaHandler {
|
1901
|
-
return this.mediaHandler;
|
1902
|
-
}
|
1903
|
-
|
1904
1446
|
/**
|
1905
1447
|
* Set whether VoIP calls are forced to use only TURN
|
1906
1448
|
* candidates. This is the same as the forceTURN option
|
@@ -1928,58 +1470,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
1928
1470
|
return this.useE2eForGroupCall;
|
1929
1471
|
}
|
1930
1472
|
|
1931
|
-
/**
|
1932
|
-
* Creates a new call.
|
1933
|
-
* The place*Call methods on the returned call can be used to actually place a call
|
1934
|
-
*
|
1935
|
-
* @param roomId - The room the call is to be placed in.
|
1936
|
-
* @returns the call or null if the browser doesn't support calling.
|
1937
|
-
*/
|
1938
|
-
public createCall(roomId: string): MatrixCall | null {
|
1939
|
-
return createNewMatrixCall(this, roomId);
|
1940
|
-
}
|
1941
|
-
|
1942
|
-
/**
|
1943
|
-
* Creates a new group call and sends the associated state event
|
1944
|
-
* to alert other members that the room now has a group call.
|
1945
|
-
*
|
1946
|
-
* @param roomId - The room the call is to be placed in.
|
1947
|
-
*/
|
1948
|
-
public async createGroupCall(
|
1949
|
-
roomId: string,
|
1950
|
-
type: GroupCallType,
|
1951
|
-
isPtt: boolean,
|
1952
|
-
intent: GroupCallIntent,
|
1953
|
-
dataChannelsEnabled?: boolean,
|
1954
|
-
dataChannelOptions?: IGroupCallDataChannelOptions,
|
1955
|
-
): Promise<GroupCall> {
|
1956
|
-
if (this.getGroupCallForRoom(roomId)) {
|
1957
|
-
throw new Error(`${roomId} already has an existing group call`);
|
1958
|
-
}
|
1959
|
-
|
1960
|
-
const room = this.getRoom(roomId);
|
1961
|
-
|
1962
|
-
if (!room) {
|
1963
|
-
throw new Error(`Cannot find room ${roomId}`);
|
1964
|
-
}
|
1965
|
-
|
1966
|
-
// Because without Media section a WebRTC connection is not possible, so need a RTCDataChannel to set up a
|
1967
|
-
// no media WebRTC connection anyway.
|
1968
|
-
return new GroupCall(
|
1969
|
-
this,
|
1970
|
-
room,
|
1971
|
-
type,
|
1972
|
-
isPtt,
|
1973
|
-
intent,
|
1974
|
-
undefined,
|
1975
|
-
dataChannelsEnabled || this.isVoipWithNoMediaAllowed,
|
1976
|
-
dataChannelOptions,
|
1977
|
-
this.isVoipWithNoMediaAllowed,
|
1978
|
-
this.useLivekitForGroupCalls,
|
1979
|
-
this.livekitServiceURL,
|
1980
|
-
).create();
|
1981
|
-
}
|
1982
|
-
|
1983
1473
|
public getLivekitServiceURL(): string | undefined {
|
1984
1474
|
return this.livekitServiceURL;
|
1985
1475
|
}
|
@@ -1990,29 +1480,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
1990
1480
|
this.livekitServiceURL = newURL;
|
1991
1481
|
}
|
1992
1482
|
|
1993
|
-
/**
|
1994
|
-
* Wait until an initial state for the given room has been processed by the
|
1995
|
-
* client and the client is aware of any ongoing group calls. Awaiting on
|
1996
|
-
* the promise returned by this method before calling getGroupCallForRoom()
|
1997
|
-
* avoids races where getGroupCallForRoom is called before the state for that
|
1998
|
-
* room has been processed. It does not, however, fix other races, eg. two
|
1999
|
-
* clients both creating a group call at the same time.
|
2000
|
-
* @param roomId - The room ID to wait for
|
2001
|
-
* @returns A promise that resolves once existing group calls in the room
|
2002
|
-
* have been processed.
|
2003
|
-
*/
|
2004
|
-
public waitUntilRoomReadyForGroupCalls(roomId: string): Promise<void> {
|
2005
|
-
return this.groupCallEventHandler!.waitUntilRoomReadyForGroupCalls(roomId);
|
2006
|
-
}
|
2007
|
-
|
2008
|
-
/**
|
2009
|
-
* Get an existing group call for the provided room.
|
2010
|
-
* @returns The group call or null if it doesn't already exist.
|
2011
|
-
*/
|
2012
|
-
public getGroupCallForRoom(roomId: string): GroupCall | null {
|
2013
|
-
return this.groupCallEventHandler!.groupCalls.get(roomId) || null;
|
2014
|
-
}
|
2015
|
-
|
2016
1483
|
/**
|
2017
1484
|
* Get the current sync state.
|
2018
1485
|
* @returns the sync state, which may be null.
|
@@ -2058,2081 +1525,91 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
2058
1525
|
|
2059
1526
|
/**
|
2060
1527
|
* Set whether this client is a guest account. <b>This method is experimental
|
2061
|
-
* and may change without warning.</b>
|
2062
|
-
* @param guest - True if this is a guest account.
|
2063
|
-
* @experimental if the token is a macaroon, it should be encoded in it that it is a 'guest'
|
2064
|
-
* access token, which means that the SDK can determine this entirely without
|
2065
|
-
* the dev manually flipping this flag.
|
2066
|
-
*/
|
2067
|
-
public setGuest(guest: boolean): void {
|
2068
|
-
this.isGuestAccount = guest;
|
2069
|
-
}
|
2070
|
-
|
2071
|
-
/**
|
2072
|
-
* Return the provided scheduler, if any.
|
2073
|
-
* @returns The scheduler or undefined
|
2074
|
-
*/
|
2075
|
-
public getScheduler(): MatrixScheduler | undefined {
|
2076
|
-
return this.scheduler;
|
2077
|
-
}
|
2078
|
-
|
2079
|
-
/**
|
2080
|
-
* Retry a backed off syncing request immediately. This should only be used when
|
2081
|
-
* the user <b>explicitly</b> attempts to retry their lost connection.
|
2082
|
-
* Will also retry any outbound to-device messages currently in the queue to be sent
|
2083
|
-
* (retries of regular outgoing events are handled separately, per-event).
|
2084
|
-
* @returns True if this resulted in a request being retried.
|
2085
|
-
*/
|
2086
|
-
public retryImmediately(): boolean {
|
2087
|
-
// don't await for this promise: we just want to kick it off
|
2088
|
-
this.toDeviceMessageQueue.sendQueue();
|
2089
|
-
return this.syncApi?.retryImmediately() ?? false;
|
2090
|
-
}
|
2091
|
-
|
2092
|
-
/**
|
2093
|
-
* Return the global notification EventTimelineSet, if any
|
2094
|
-
*
|
2095
|
-
* @returns the globl notification EventTimelineSet
|
2096
|
-
*/
|
2097
|
-
public getNotifTimelineSet(): EventTimelineSet | null {
|
2098
|
-
return this.notifTimelineSet;
|
2099
|
-
}
|
2100
|
-
|
2101
|
-
/**
|
2102
|
-
* Set the global notification EventTimelineSet
|
2103
|
-
*
|
2104
|
-
*/
|
2105
|
-
public setNotifTimelineSet(set: EventTimelineSet): void {
|
2106
|
-
this.notifTimelineSet = set;
|
2107
|
-
}
|
2108
|
-
|
2109
|
-
/**
|
2110
|
-
* Gets the cached capabilities of the homeserver, returning cached ones if available.
|
2111
|
-
* If there are no cached capabilities and none can be fetched, throw an exception.
|
2112
|
-
*
|
2113
|
-
* @returns Promise resolving with The capabilities of the homeserver
|
2114
|
-
*/
|
2115
|
-
public async getCapabilities(): Promise<Capabilities> {
|
2116
|
-
const caps = this.serverCapabilitiesService.getCachedCapabilities();
|
2117
|
-
if (caps) return caps;
|
2118
|
-
return this.serverCapabilitiesService.fetchCapabilities();
|
2119
|
-
}
|
2120
|
-
|
2121
|
-
/**
|
2122
|
-
* Gets the cached capabilities of the homeserver. If none have been fetched yet,
|
2123
|
-
* return undefined.
|
2124
|
-
*
|
2125
|
-
* @returns The capabilities of the homeserver
|
2126
|
-
*/
|
2127
|
-
public getCachedCapabilities(): Capabilities | undefined {
|
2128
|
-
return this.serverCapabilitiesService.getCachedCapabilities();
|
2129
|
-
}
|
2130
|
-
|
2131
|
-
/**
|
2132
|
-
* Fetches the latest capabilities from the homeserver, ignoring any cached
|
2133
|
-
* versions. The newly returned version is cached.
|
2134
|
-
*
|
2135
|
-
* @returns A promise which resolves to the capabilities of the homeserver
|
2136
|
-
*/
|
2137
|
-
public fetchCapabilities(): Promise<Capabilities> {
|
2138
|
-
return this.serverCapabilitiesService.fetchCapabilities();
|
2139
|
-
}
|
2140
|
-
|
2141
|
-
/**
|
2142
|
-
* Initialise support for end-to-end encryption in this client, using libolm.
|
2143
|
-
*
|
2144
|
-
* You should call this method after creating the matrixclient, but *before*
|
2145
|
-
* calling `startClient`, if you want to support end-to-end encryption.
|
2146
|
-
*
|
2147
|
-
* It will return a Promise which will resolve when the crypto layer has been
|
2148
|
-
* successfully initialised.
|
2149
|
-
*
|
2150
|
-
* @deprecated libolm is deprecated. Prefer {@link initRustCrypto}.
|
2151
|
-
*/
|
2152
|
-
public async initCrypto(): Promise<void> {
|
2153
|
-
if (this.cryptoBackend) {
|
2154
|
-
this.logger.warn("Attempt to re-initialise e2e encryption on MatrixClient");
|
2155
|
-
return;
|
2156
|
-
}
|
2157
|
-
|
2158
|
-
if (!this.cryptoStore) {
|
2159
|
-
// the cryptostore is provided by sdk.createClient, so this shouldn't happen
|
2160
|
-
throw new Error(`Cannot enable encryption: no cryptoStore provided`);
|
2161
|
-
}
|
2162
|
-
|
2163
|
-
this.logger.debug("Crypto: Starting up crypto store...");
|
2164
|
-
await this.cryptoStore.startup();
|
2165
|
-
|
2166
|
-
const userId = this.getUserId();
|
2167
|
-
if (userId === null) {
|
2168
|
-
throw new Error(
|
2169
|
-
`Cannot enable encryption on MatrixClient with unknown userId: ` +
|
2170
|
-
`ensure userId is passed in createClient().`,
|
2171
|
-
);
|
2172
|
-
}
|
2173
|
-
if (this.deviceId === null) {
|
2174
|
-
throw new Error(
|
2175
|
-
`Cannot enable encryption on MatrixClient with unknown deviceId: ` +
|
2176
|
-
`ensure deviceId is passed in createClient().`,
|
2177
|
-
);
|
2178
|
-
}
|
2179
|
-
|
2180
|
-
const crypto = new Crypto(this, userId, this.deviceId, this.store, this.cryptoStore, this.verificationMethods!);
|
2181
|
-
|
2182
|
-
this.reEmitter.reEmit(crypto, [
|
2183
|
-
LegacyCryptoEvent.KeyBackupFailed,
|
2184
|
-
LegacyCryptoEvent.KeyBackupSessionsRemaining,
|
2185
|
-
LegacyCryptoEvent.RoomKeyRequest,
|
2186
|
-
LegacyCryptoEvent.RoomKeyRequestCancellation,
|
2187
|
-
LegacyCryptoEvent.Warning,
|
2188
|
-
LegacyCryptoEvent.DevicesUpdated,
|
2189
|
-
LegacyCryptoEvent.WillUpdateDevices,
|
2190
|
-
LegacyCryptoEvent.DeviceVerificationChanged,
|
2191
|
-
LegacyCryptoEvent.UserTrustStatusChanged,
|
2192
|
-
LegacyCryptoEvent.KeysChanged,
|
2193
|
-
]);
|
2194
|
-
|
2195
|
-
this.logger.debug("Crypto: initialising crypto object...");
|
2196
|
-
await crypto.init({
|
2197
|
-
exportedOlmDevice: this.exportedOlmDeviceToImport,
|
2198
|
-
pickleKey: this.pickleKey,
|
2199
|
-
});
|
2200
|
-
delete this.exportedOlmDeviceToImport;
|
2201
|
-
|
2202
|
-
this.olmVersion = Crypto.getOlmVersion();
|
2203
|
-
|
2204
|
-
// if crypto initialisation was successful, tell it to attach its event handlers.
|
2205
|
-
crypto.registerEventHandlers(this as Parameters<Crypto["registerEventHandlers"]>[0]);
|
2206
|
-
this.cryptoBackend = this.crypto = crypto;
|
2207
|
-
|
2208
|
-
// upload our keys in the background
|
2209
|
-
this.crypto.uploadDeviceKeys().catch((e) => {
|
2210
|
-
// TODO: throwing away this error is a really bad idea.
|
2211
|
-
this.logger.error("Error uploading device keys", e);
|
2212
|
-
});
|
2213
|
-
}
|
2214
|
-
|
2215
|
-
/**
|
2216
|
-
* Initialise support for end-to-end encryption in this client, using the rust matrix-sdk-crypto.
|
2217
|
-
*
|
2218
|
-
* An alternative to {@link initCrypto}.
|
2219
|
-
*
|
2220
|
-
* @param args.useIndexedDB - True to use an indexeddb store, false to use an in-memory store. Defaults to 'true'.
|
2221
|
-
* @param args.storageKey - A key with which to encrypt the indexeddb store. If provided, it must be exactly
|
2222
|
-
* 32 bytes of data, and must be the same each time the client is initialised for a given device.
|
2223
|
-
* If both this and `storagePassword` are unspecified, the store will be unencrypted.
|
2224
|
-
* @param args.storagePassword - An alternative to `storageKey`. A password which will be used to derive a key to
|
2225
|
-
* encrypt the store with. Deriving a key from a password is (deliberately) a slow operation, so prefer
|
2226
|
-
* to pass a `storageKey` directly where possible.
|
2227
|
-
*
|
2228
|
-
* @returns a Promise which will resolve when the crypto layer has been
|
2229
|
-
* successfully initialised.
|
2230
|
-
*/
|
2231
|
-
public async initRustCrypto(
|
2232
|
-
args: {
|
2233
|
-
useIndexedDB?: boolean;
|
2234
|
-
storageKey?: Uint8Array;
|
2235
|
-
storagePassword?: string;
|
2236
|
-
} = {},
|
2237
|
-
): Promise<void> {
|
2238
|
-
if (this.cryptoBackend) {
|
2239
|
-
this.logger.warn("Attempt to re-initialise e2e encryption on MatrixClient");
|
2240
|
-
return;
|
2241
|
-
}
|
2242
|
-
|
2243
|
-
const userId = this.getUserId();
|
2244
|
-
if (userId === null) {
|
2245
|
-
throw new Error(
|
2246
|
-
`Cannot enable encryption on MatrixClient with unknown userId: ` +
|
2247
|
-
`ensure userId is passed in createClient().`,
|
2248
|
-
);
|
2249
|
-
}
|
2250
|
-
const deviceId = this.getDeviceId();
|
2251
|
-
if (deviceId === null) {
|
2252
|
-
throw new Error(
|
2253
|
-
`Cannot enable encryption on MatrixClient with unknown deviceId: ` +
|
2254
|
-
`ensure deviceId is passed in createClient().`,
|
2255
|
-
);
|
2256
|
-
}
|
2257
|
-
|
2258
|
-
// importing rust-crypto will download the webassembly, so we delay it until we know it will be
|
2259
|
-
// needed.
|
2260
|
-
this.logger.debug("Downloading Rust crypto library");
|
2261
|
-
const RustCrypto = await import("./rust-crypto/index.ts");
|
2262
|
-
|
2263
|
-
const rustCrypto = await RustCrypto.initRustCrypto({
|
2264
|
-
logger: this.logger,
|
2265
|
-
http: this.http,
|
2266
|
-
userId: userId,
|
2267
|
-
deviceId: deviceId,
|
2268
|
-
secretStorage: this.secretStorage,
|
2269
|
-
cryptoCallbacks: this.cryptoCallbacks,
|
2270
|
-
storePrefix: args.useIndexedDB === false ? null : RUST_SDK_STORE_PREFIX,
|
2271
|
-
storeKey: args.storageKey,
|
2272
|
-
storePassphrase: args.storagePassword,
|
2273
|
-
|
2274
|
-
legacyCryptoStore: this.cryptoStore,
|
2275
|
-
legacyPickleKey: this.pickleKey ?? "DEFAULT_KEY",
|
2276
|
-
legacyMigrationProgressListener: (progress: number, total: number): void => {
|
2277
|
-
this.emit(CryptoEvent.LegacyCryptoStoreMigrationProgress, progress, total);
|
2278
|
-
},
|
2279
|
-
});
|
2280
|
-
|
2281
|
-
rustCrypto.setSupportedVerificationMethods(this.verificationMethods);
|
2282
|
-
|
2283
|
-
this.cryptoBackend = rustCrypto;
|
2284
|
-
|
2285
|
-
// attach the event listeners needed by RustCrypto
|
2286
|
-
this.on(RoomMemberEvent.Membership, rustCrypto.onRoomMembership.bind(rustCrypto));
|
2287
|
-
this.on(ClientEvent.Event, (event) => {
|
2288
|
-
rustCrypto.onLiveEventFromSync(event);
|
2289
|
-
});
|
2290
|
-
|
2291
|
-
// re-emit the events emitted by the crypto impl
|
2292
|
-
this.reEmitter.reEmit(rustCrypto, [
|
2293
|
-
CryptoEvent.VerificationRequestReceived,
|
2294
|
-
CryptoEvent.UserTrustStatusChanged,
|
2295
|
-
CryptoEvent.KeyBackupStatus,
|
2296
|
-
CryptoEvent.KeyBackupSessionsRemaining,
|
2297
|
-
CryptoEvent.KeyBackupFailed,
|
2298
|
-
CryptoEvent.KeyBackupDecryptionKeyCached,
|
2299
|
-
CryptoEvent.KeysChanged,
|
2300
|
-
CryptoEvent.DevicesUpdated,
|
2301
|
-
CryptoEvent.WillUpdateDevices,
|
2302
|
-
]);
|
2303
|
-
}
|
2304
|
-
|
2305
|
-
/**
|
2306
|
-
* Access the server-side secret storage API for this client.
|
2307
|
-
*/
|
2308
|
-
public get secretStorage(): ServerSideSecretStorage {
|
2309
|
-
return this._secretStorage;
|
2310
|
-
}
|
2311
|
-
|
2312
|
-
/**
|
2313
|
-
* Access the crypto API for this client.
|
2314
|
-
*
|
2315
|
-
* If end-to-end encryption has been enabled for this client (via {@link initCrypto} or {@link initRustCrypto}),
|
2316
|
-
* returns an object giving access to the crypto API. Otherwise, returns `undefined`.
|
2317
|
-
*/
|
2318
|
-
public getCrypto(): CryptoApi | undefined {
|
2319
|
-
return this.cryptoBackend;
|
2320
|
-
}
|
2321
|
-
|
2322
|
-
/**
|
2323
|
-
* Is end-to-end crypto enabled for this client.
|
2324
|
-
* @returns True if end-to-end is enabled.
|
2325
|
-
* @deprecated prefer {@link getCrypto}
|
2326
|
-
*/
|
2327
|
-
public isCryptoEnabled(): boolean {
|
2328
|
-
return !!this.cryptoBackend;
|
2329
|
-
}
|
2330
|
-
|
2331
|
-
/**
|
2332
|
-
* Get the Ed25519 key for this device
|
2333
|
-
*
|
2334
|
-
* @returns base64-encoded ed25519 key. Null if crypto is
|
2335
|
-
* disabled.
|
2336
|
-
*
|
2337
|
-
* @deprecated Not supported for Rust Cryptography.Prefer {@link CryptoApi.getOwnDeviceKeys}
|
2338
|
-
*/
|
2339
|
-
public getDeviceEd25519Key(): string | null {
|
2340
|
-
return this.crypto?.getDeviceEd25519Key() ?? null;
|
2341
|
-
}
|
2342
|
-
|
2343
|
-
/**
|
2344
|
-
* Get the Curve25519 key for this device
|
2345
|
-
*
|
2346
|
-
* @returns base64-encoded curve25519 key. Null if crypto is
|
2347
|
-
* disabled.
|
2348
|
-
*
|
2349
|
-
* @deprecated Not supported for Rust Cryptography. Use {@link CryptoApi.getOwnDeviceKeys}
|
2350
|
-
*/
|
2351
|
-
public getDeviceCurve25519Key(): string | null {
|
2352
|
-
return this.crypto?.getDeviceCurve25519Key() ?? null;
|
2353
|
-
}
|
2354
|
-
|
2355
|
-
/**
|
2356
|
-
* @deprecated Does nothing.
|
2357
|
-
*/
|
2358
|
-
public async uploadKeys(): Promise<void> {
|
2359
|
-
this.logger.warn("MatrixClient.uploadKeys is deprecated");
|
2360
|
-
}
|
2361
|
-
|
2362
|
-
/**
|
2363
|
-
* Download the keys for a list of users and stores the keys in the session
|
2364
|
-
* store.
|
2365
|
-
* @param userIds - The users to fetch.
|
2366
|
-
* @param forceDownload - Always download the keys even if cached.
|
2367
|
-
*
|
2368
|
-
* @returns A promise which resolves to a map userId-\>deviceId-\>`DeviceInfo`
|
2369
|
-
*
|
2370
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.getUserDeviceInfo}
|
2371
|
-
*/
|
2372
|
-
public downloadKeys(userIds: string[], forceDownload?: boolean): Promise<DeviceInfoMap> {
|
2373
|
-
if (!this.crypto) {
|
2374
|
-
return Promise.reject(new Error("End-to-end encryption disabled"));
|
2375
|
-
}
|
2376
|
-
return this.crypto.downloadKeys(userIds, forceDownload);
|
2377
|
-
}
|
2378
|
-
|
2379
|
-
/**
|
2380
|
-
* Get the stored device keys for a user id
|
2381
|
-
*
|
2382
|
-
* @param userId - the user to list keys for.
|
2383
|
-
*
|
2384
|
-
* @returns list of devices
|
2385
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.getUserDeviceInfo}
|
2386
|
-
*/
|
2387
|
-
public getStoredDevicesForUser(userId: string): DeviceInfo[] {
|
2388
|
-
if (!this.crypto) {
|
2389
|
-
throw new Error("End-to-end encryption disabled");
|
2390
|
-
}
|
2391
|
-
return this.crypto.getStoredDevicesForUser(userId) || [];
|
2392
|
-
}
|
2393
|
-
|
2394
|
-
/**
|
2395
|
-
* Get the stored device key for a user id and device id
|
2396
|
-
*
|
2397
|
-
* @param userId - the user to list keys for.
|
2398
|
-
* @param deviceId - unique identifier for the device
|
2399
|
-
*
|
2400
|
-
* @returns device or null
|
2401
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.getUserDeviceInfo}
|
2402
|
-
*/
|
2403
|
-
public getStoredDevice(userId: string, deviceId: string): DeviceInfo | null {
|
2404
|
-
if (!this.crypto) {
|
2405
|
-
throw new Error("End-to-end encryption disabled");
|
2406
|
-
}
|
2407
|
-
return this.crypto.getStoredDevice(userId, deviceId) || null;
|
2408
|
-
}
|
2409
|
-
|
2410
|
-
/**
|
2411
|
-
* Mark the given device as verified
|
2412
|
-
*
|
2413
|
-
* @param userId - owner of the device
|
2414
|
-
* @param deviceId - unique identifier for the device or user's
|
2415
|
-
* cross-signing public key ID.
|
2416
|
-
*
|
2417
|
-
* @param verified - whether to mark the device as verified. defaults
|
2418
|
-
* to 'true'.
|
2419
|
-
*
|
2420
|
-
* @returns
|
2421
|
-
*
|
2422
|
-
* @remarks
|
2423
|
-
* Fires {@link CryptoEvent#DeviceVerificationChanged}
|
2424
|
-
*/
|
2425
|
-
public setDeviceVerified(userId: string, deviceId: string, verified = true): Promise<void> {
|
2426
|
-
const prom = this.setDeviceVerification(userId, deviceId, verified, null, null);
|
2427
|
-
|
2428
|
-
// if one of the user's own devices is being marked as verified / unverified,
|
2429
|
-
// check the key backup status, since whether or not we use this depends on
|
2430
|
-
// whether it has a signature from a verified device
|
2431
|
-
if (userId == this.credentials.userId) {
|
2432
|
-
this.checkKeyBackup();
|
2433
|
-
}
|
2434
|
-
return prom;
|
2435
|
-
}
|
2436
|
-
|
2437
|
-
/**
|
2438
|
-
* Mark the given device as blocked/unblocked
|
2439
|
-
*
|
2440
|
-
* @param userId - owner of the device
|
2441
|
-
* @param deviceId - unique identifier for the device or user's
|
2442
|
-
* cross-signing public key ID.
|
2443
|
-
*
|
2444
|
-
* @param blocked - whether to mark the device as blocked. defaults
|
2445
|
-
* to 'true'.
|
2446
|
-
*
|
2447
|
-
* @returns
|
2448
|
-
*
|
2449
|
-
* @remarks
|
2450
|
-
* Fires {@link LegacyCryptoEvent.DeviceVerificationChanged}
|
2451
|
-
*
|
2452
|
-
* @deprecated Not supported for Rust Cryptography.
|
2453
|
-
*/
|
2454
|
-
public setDeviceBlocked(userId: string, deviceId: string, blocked = true): Promise<void> {
|
2455
|
-
return this.setDeviceVerification(userId, deviceId, null, blocked, null);
|
2456
|
-
}
|
2457
|
-
|
2458
|
-
/**
|
2459
|
-
* Mark the given device as known/unknown
|
2460
|
-
*
|
2461
|
-
* @param userId - owner of the device
|
2462
|
-
* @param deviceId - unique identifier for the device or user's
|
2463
|
-
* cross-signing public key ID.
|
2464
|
-
*
|
2465
|
-
* @param known - whether to mark the device as known. defaults
|
2466
|
-
* to 'true'.
|
2467
|
-
*
|
2468
|
-
* @returns
|
2469
|
-
*
|
2470
|
-
* @remarks
|
2471
|
-
* Fires {@link CryptoEvent#DeviceVerificationChanged}
|
2472
|
-
*
|
2473
|
-
* @deprecated Not supported for Rust Cryptography.
|
2474
|
-
*/
|
2475
|
-
public setDeviceKnown(userId: string, deviceId: string, known = true): Promise<void> {
|
2476
|
-
return this.setDeviceVerification(userId, deviceId, null, null, known);
|
2477
|
-
}
|
2478
|
-
|
2479
|
-
private async setDeviceVerification(
|
2480
|
-
userId: string,
|
2481
|
-
deviceId: string,
|
2482
|
-
verified?: boolean | null,
|
2483
|
-
blocked?: boolean | null,
|
2484
|
-
known?: boolean | null,
|
2485
|
-
): Promise<void> {
|
2486
|
-
if (!this.crypto) {
|
2487
|
-
throw new Error("End-to-end encryption disabled");
|
2488
|
-
}
|
2489
|
-
await this.crypto.setDeviceVerification(userId, deviceId, verified, blocked, known);
|
2490
|
-
}
|
2491
|
-
|
2492
|
-
/**
|
2493
|
-
* Request a key verification from another user, using a DM.
|
2494
|
-
*
|
2495
|
-
* @param userId - the user to request verification with
|
2496
|
-
* @param roomId - the room to use for verification
|
2497
|
-
*
|
2498
|
-
* @returns resolves to a VerificationRequest
|
2499
|
-
* when the request has been sent to the other party.
|
2500
|
-
*
|
2501
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.requestVerificationDM}.
|
2502
|
-
*/
|
2503
|
-
public requestVerificationDM(userId: string, roomId: string): Promise<VerificationRequest> {
|
2504
|
-
if (!this.crypto) {
|
2505
|
-
throw new Error("End-to-end encryption disabled");
|
2506
|
-
}
|
2507
|
-
return this.crypto.requestVerificationDM(userId, roomId);
|
2508
|
-
}
|
2509
|
-
|
2510
|
-
/**
|
2511
|
-
* Finds a DM verification request that is already in progress for the given room id
|
2512
|
-
*
|
2513
|
-
* @param roomId - the room to use for verification
|
2514
|
-
*
|
2515
|
-
* @returns the VerificationRequest that is in progress, if any
|
2516
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.findVerificationRequestDMInProgress}.
|
2517
|
-
*/
|
2518
|
-
public findVerificationRequestDMInProgress(roomId: string): VerificationRequest | undefined {
|
2519
|
-
if (!this.cryptoBackend) {
|
2520
|
-
throw new Error("End-to-end encryption disabled");
|
2521
|
-
} else if (!this.crypto) {
|
2522
|
-
// Hack for element-R to avoid breaking the cypress tests. We can get rid of this once the react-sdk is
|
2523
|
-
// updated to use CryptoApi.findVerificationRequestDMInProgress.
|
2524
|
-
return undefined;
|
2525
|
-
}
|
2526
|
-
return this.crypto.findVerificationRequestDMInProgress(roomId);
|
2527
|
-
}
|
2528
|
-
|
2529
|
-
/**
|
2530
|
-
* Returns all to-device verification requests that are already in progress for the given user id
|
2531
|
-
*
|
2532
|
-
* @param userId - the ID of the user to query
|
2533
|
-
*
|
2534
|
-
* @returns the VerificationRequests that are in progress
|
2535
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.getVerificationRequestsToDeviceInProgress}.
|
2536
|
-
*/
|
2537
|
-
public getVerificationRequestsToDeviceInProgress(userId: string): VerificationRequest[] {
|
2538
|
-
if (!this.crypto) {
|
2539
|
-
throw new Error("End-to-end encryption disabled");
|
2540
|
-
}
|
2541
|
-
return this.crypto.getVerificationRequestsToDeviceInProgress(userId);
|
2542
|
-
}
|
2543
|
-
|
2544
|
-
/**
|
2545
|
-
* Request a key verification from another user.
|
2546
|
-
*
|
2547
|
-
* @param userId - the user to request verification with
|
2548
|
-
* @param devices - array of device IDs to send requests to. Defaults to
|
2549
|
-
* all devices owned by the user
|
2550
|
-
*
|
2551
|
-
* @returns resolves to a VerificationRequest
|
2552
|
-
* when the request has been sent to the other party.
|
2553
|
-
*
|
2554
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi#requestOwnUserVerification} or {@link CryptoApi#requestDeviceVerification}.
|
2555
|
-
*/
|
2556
|
-
public requestVerification(userId: string, devices?: string[]): Promise<VerificationRequest> {
|
2557
|
-
if (!this.crypto) {
|
2558
|
-
throw new Error("End-to-end encryption disabled");
|
2559
|
-
}
|
2560
|
-
return this.crypto.requestVerification(userId, devices);
|
2561
|
-
}
|
2562
|
-
|
2563
|
-
/**
|
2564
|
-
* Begin a key verification.
|
2565
|
-
*
|
2566
|
-
* @param method - the verification method to use
|
2567
|
-
* @param userId - the user to verify keys with
|
2568
|
-
* @param deviceId - the device to verify
|
2569
|
-
*
|
2570
|
-
* @returns a verification object
|
2571
|
-
* @deprecated Prefer {@link CryptoApi#requestOwnUserVerification} or {@link CryptoApi#requestDeviceVerification}.
|
2572
|
-
*/
|
2573
|
-
public beginKeyVerification(method: string, userId: string, deviceId: string): Verification<any, any> {
|
2574
|
-
if (!this.crypto) {
|
2575
|
-
throw new Error("End-to-end encryption disabled");
|
2576
|
-
}
|
2577
|
-
return this.crypto.beginKeyVerification(method, userId, deviceId);
|
2578
|
-
}
|
2579
|
-
|
2580
|
-
/**
|
2581
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#checkKey}.
|
2582
|
-
*/
|
2583
|
-
public checkSecretStorageKey(key: Uint8Array, info: SecretStorageKeyDescription): Promise<boolean> {
|
2584
|
-
return this.secretStorage.checkKey(key, info);
|
2585
|
-
}
|
2586
|
-
|
2587
|
-
/**
|
2588
|
-
* Set the global override for whether the client should ever send encrypted
|
2589
|
-
* messages to unverified devices. This provides the default for rooms which
|
2590
|
-
* do not specify a value.
|
2591
|
-
*
|
2592
|
-
* @param value - whether to blacklist all unverified devices by default
|
2593
|
-
*
|
2594
|
-
* @deprecated Prefer direct access to {@link CryptoApi.globalBlacklistUnverifiedDevices}:
|
2595
|
-
*
|
2596
|
-
* ```javascript
|
2597
|
-
* client.getCrypto().globalBlacklistUnverifiedDevices = value;
|
2598
|
-
* ```
|
2599
|
-
*/
|
2600
|
-
public setGlobalBlacklistUnverifiedDevices(value: boolean): boolean {
|
2601
|
-
if (!this.cryptoBackend) {
|
2602
|
-
throw new Error("End-to-end encryption disabled");
|
2603
|
-
}
|
2604
|
-
this.cryptoBackend.globalBlacklistUnverifiedDevices = value;
|
2605
|
-
return value;
|
2606
|
-
}
|
2607
|
-
|
2608
|
-
/**
|
2609
|
-
* @returns whether to blacklist all unverified devices by default
|
2610
|
-
*
|
2611
|
-
* @deprecated Prefer direct access to {@link CryptoApi.globalBlacklistUnverifiedDevices}:
|
2612
|
-
*
|
2613
|
-
* ```javascript
|
2614
|
-
* value = client.getCrypto().globalBlacklistUnverifiedDevices;
|
2615
|
-
* ```
|
2616
|
-
*/
|
2617
|
-
public getGlobalBlacklistUnverifiedDevices(): boolean {
|
2618
|
-
if (!this.cryptoBackend) {
|
2619
|
-
throw new Error("End-to-end encryption disabled");
|
2620
|
-
}
|
2621
|
-
return this.cryptoBackend.globalBlacklistUnverifiedDevices;
|
2622
|
-
}
|
2623
|
-
|
2624
|
-
/**
|
2625
|
-
* Set whether sendMessage in a room with unknown and unverified devices
|
2626
|
-
* should throw an error and not send them message. This has 'Global' for
|
2627
|
-
* symmetry with setGlobalBlacklistUnverifiedDevices but there is currently
|
2628
|
-
* no room-level equivalent for this setting.
|
2629
|
-
*
|
2630
|
-
* This API is currently UNSTABLE and may change or be removed without notice.
|
2631
|
-
*
|
2632
|
-
* It has no effect with the Rust crypto implementation.
|
2633
|
-
*
|
2634
|
-
* @param value - whether error on unknown devices
|
2635
|
-
*
|
2636
|
-
* ```ts
|
2637
|
-
* client.getCrypto().globalErrorOnUnknownDevices = value;
|
2638
|
-
* ```
|
2639
|
-
*/
|
2640
|
-
public setGlobalErrorOnUnknownDevices(value: boolean): void {
|
2641
|
-
if (!this.cryptoBackend) {
|
2642
|
-
throw new Error("End-to-end encryption disabled");
|
2643
|
-
}
|
2644
|
-
this.cryptoBackend.globalErrorOnUnknownDevices = value;
|
2645
|
-
}
|
2646
|
-
|
2647
|
-
/**
|
2648
|
-
* @returns whether to error on unknown devices
|
2649
|
-
*
|
2650
|
-
* This API is currently UNSTABLE and may change or be removed without notice.
|
2651
|
-
*/
|
2652
|
-
public getGlobalErrorOnUnknownDevices(): boolean {
|
2653
|
-
if (!this.cryptoBackend) {
|
2654
|
-
throw new Error("End-to-end encryption disabled");
|
2655
|
-
}
|
2656
|
-
return this.cryptoBackend.globalErrorOnUnknownDevices;
|
2657
|
-
}
|
2658
|
-
|
2659
|
-
/**
|
2660
|
-
* Get the ID of one of the user's cross-signing keys
|
2661
|
-
*
|
2662
|
-
* @param type - The type of key to get the ID of. One of
|
2663
|
-
* "master", "self_signing", or "user_signing". Defaults to "master".
|
2664
|
-
*
|
2665
|
-
* @returns the key ID
|
2666
|
-
* @deprecated Not supported for Rust Cryptography. prefer {@link Crypto.CryptoApi#getCrossSigningKeyId}
|
2667
|
-
*/
|
2668
|
-
public getCrossSigningId(type: CrossSigningKey | string = CrossSigningKey.Master): string | null {
|
2669
|
-
if (!this.crypto) {
|
2670
|
-
throw new Error("End-to-end encryption disabled");
|
2671
|
-
}
|
2672
|
-
return this.crypto.getCrossSigningId(type);
|
2673
|
-
}
|
2674
|
-
|
2675
|
-
/**
|
2676
|
-
* Get the cross signing information for a given user.
|
2677
|
-
*
|
2678
|
-
* The cross-signing API is currently UNSTABLE and may change without notice.
|
2679
|
-
*
|
2680
|
-
* @param userId - the user ID to get the cross-signing info for.
|
2681
|
-
*
|
2682
|
-
* @returns the cross signing information for the user.
|
2683
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi#userHasCrossSigningKeys}
|
2684
|
-
*/
|
2685
|
-
public getStoredCrossSigningForUser(userId: string): CrossSigningInfo | null {
|
2686
|
-
if (!this.cryptoBackend) {
|
2687
|
-
throw new Error("End-to-end encryption disabled");
|
2688
|
-
}
|
2689
|
-
return this.cryptoBackend.getStoredCrossSigningForUser(userId);
|
2690
|
-
}
|
2691
|
-
|
2692
|
-
/**
|
2693
|
-
* Check whether a given user is trusted.
|
2694
|
-
*
|
2695
|
-
* The cross-signing API is currently UNSTABLE and may change without notice.
|
2696
|
-
*
|
2697
|
-
* @param userId - The ID of the user to check.
|
2698
|
-
*
|
2699
|
-
* @deprecated Use {@link Crypto.CryptoApi.getUserVerificationStatus | `CryptoApi.getUserVerificationStatus`}
|
2700
|
-
*/
|
2701
|
-
public checkUserTrust(userId: string): UserTrustLevel {
|
2702
|
-
if (!this.cryptoBackend) {
|
2703
|
-
throw new Error("End-to-end encryption disabled");
|
2704
|
-
}
|
2705
|
-
return this.cryptoBackend.checkUserTrust(userId);
|
2706
|
-
}
|
2707
|
-
|
2708
|
-
/**
|
2709
|
-
* Check whether a given device is trusted.
|
2710
|
-
*
|
2711
|
-
* The cross-signing API is currently UNSTABLE and may change without notice.
|
2712
|
-
*
|
2713
|
-
* @param userId - The ID of the user whose devices is to be checked.
|
2714
|
-
* @param deviceId - The ID of the device to check
|
2715
|
-
*
|
2716
|
-
* @deprecated Use {@link Crypto.CryptoApi.getDeviceVerificationStatus | `CryptoApi.getDeviceVerificationStatus`}
|
2717
|
-
*/
|
2718
|
-
public checkDeviceTrust(userId: string, deviceId: string): DeviceTrustLevel {
|
2719
|
-
if (!this.crypto) {
|
2720
|
-
throw new Error("End-to-end encryption disabled");
|
2721
|
-
}
|
2722
|
-
return this.crypto.checkDeviceTrust(userId, deviceId);
|
2723
|
-
}
|
2724
|
-
|
2725
|
-
/**
|
2726
|
-
* Check whether one of our own devices is cross-signed by our
|
2727
|
-
* user's stored keys, regardless of whether we trust those keys yet.
|
2728
|
-
*
|
2729
|
-
* @param deviceId - The ID of the device to check
|
2730
|
-
*
|
2731
|
-
* @returns true if the device is cross-signed
|
2732
|
-
*
|
2733
|
-
* @deprecated Not supported for Rust Cryptography.
|
2734
|
-
*/
|
2735
|
-
public checkIfOwnDeviceCrossSigned(deviceId: string): boolean {
|
2736
|
-
if (!this.crypto) {
|
2737
|
-
throw new Error("End-to-end encryption disabled");
|
2738
|
-
}
|
2739
|
-
return this.crypto.checkIfOwnDeviceCrossSigned(deviceId);
|
2740
|
-
}
|
2741
|
-
|
2742
|
-
/**
|
2743
|
-
* Check the copy of our cross-signing key that we have in the device list and
|
2744
|
-
* see if we can get the private key. If so, mark it as trusted.
|
2745
|
-
* @param opts - ICheckOwnCrossSigningTrustOpts object
|
2746
|
-
*
|
2747
|
-
* @deprecated Unneeded for the new crypto
|
2748
|
-
*/
|
2749
|
-
public checkOwnCrossSigningTrust(opts?: ICheckOwnCrossSigningTrustOpts): Promise<void> {
|
2750
|
-
if (!this.cryptoBackend) {
|
2751
|
-
throw new Error("End-to-end encryption disabled");
|
2752
|
-
}
|
2753
|
-
return this.cryptoBackend.checkOwnCrossSigningTrust(opts);
|
2754
|
-
}
|
2755
|
-
|
2756
|
-
/**
|
2757
|
-
* Checks that a given cross-signing private key matches a given public key.
|
2758
|
-
* This can be used by the getCrossSigningKey callback to verify that the
|
2759
|
-
* private key it is about to supply is the one that was requested.
|
2760
|
-
* @param privateKey - The private key
|
2761
|
-
* @param expectedPublicKey - The public key
|
2762
|
-
* @returns true if the key matches, otherwise false
|
2763
|
-
*
|
2764
|
-
* @deprecated Not supported for Rust Cryptography.
|
2765
|
-
*/
|
2766
|
-
public checkCrossSigningPrivateKey(privateKey: Uint8Array, expectedPublicKey: string): boolean {
|
2767
|
-
if (!this.crypto) {
|
2768
|
-
throw new Error("End-to-end encryption disabled");
|
2769
|
-
}
|
2770
|
-
return this.crypto.checkCrossSigningPrivateKey(privateKey, expectedPublicKey);
|
2771
|
-
}
|
2772
|
-
|
2773
|
-
/**
|
2774
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi#requestDeviceVerification}.
|
2775
|
-
*/
|
2776
|
-
public legacyDeviceVerification(userId: string, deviceId: string, method: string): Promise<VerificationRequest> {
|
2777
|
-
if (!this.crypto) {
|
2778
|
-
throw new Error("End-to-end encryption disabled");
|
2779
|
-
}
|
2780
|
-
return this.crypto.legacyDeviceVerification(userId, deviceId, method);
|
2781
|
-
}
|
2782
|
-
|
2783
|
-
/**
|
2784
|
-
* Perform any background tasks that can be done before a message is ready to
|
2785
|
-
* send, in order to speed up sending of the message.
|
2786
|
-
* @param room - the room the event is in
|
2787
|
-
*
|
2788
|
-
* @deprecated Prefer {@link CryptoApi.prepareToEncrypt | `CryptoApi.prepareToEncrypt`}:
|
2789
|
-
*
|
2790
|
-
* ```javascript
|
2791
|
-
* client.getCrypto().prepareToEncrypt(room);
|
2792
|
-
* ```
|
2793
|
-
*/
|
2794
|
-
public prepareToEncrypt(room: Room): void {
|
2795
|
-
if (!this.cryptoBackend) {
|
2796
|
-
throw new Error("End-to-end encryption disabled");
|
2797
|
-
}
|
2798
|
-
this.cryptoBackend.prepareToEncrypt(room);
|
2799
|
-
}
|
2800
|
-
|
2801
|
-
/**
|
2802
|
-
* Checks if the user has previously published cross-signing keys
|
2803
|
-
*
|
2804
|
-
* This means downloading the devicelist for the user and checking if the list includes
|
2805
|
-
* the cross-signing pseudo-device.
|
2806
|
-
*
|
2807
|
-
* @deprecated Prefer {@link CryptoApi.userHasCrossSigningKeys | `CryptoApi.userHasCrossSigningKeys`}:
|
2808
|
-
*
|
2809
|
-
* ```javascript
|
2810
|
-
* result = client.getCrypto().userHasCrossSigningKeys();
|
2811
|
-
* ```
|
2812
|
-
*/
|
2813
|
-
public userHasCrossSigningKeys(): Promise<boolean> {
|
2814
|
-
if (!this.cryptoBackend) {
|
2815
|
-
throw new Error("End-to-end encryption disabled");
|
2816
|
-
}
|
2817
|
-
return this.cryptoBackend.userHasCrossSigningKeys();
|
2818
|
-
}
|
2819
|
-
|
2820
|
-
/**
|
2821
|
-
* Checks whether cross signing:
|
2822
|
-
* - is enabled on this account and trusted by this device
|
2823
|
-
* - has private keys either cached locally or stored in secret storage
|
2824
|
-
*
|
2825
|
-
* If this function returns false, bootstrapCrossSigning() can be used
|
2826
|
-
* to fix things such that it returns true. That is to say, after
|
2827
|
-
* bootstrapCrossSigning() completes successfully, this function should
|
2828
|
-
* return true.
|
2829
|
-
* @returns True if cross-signing is ready to be used on this device
|
2830
|
-
* @deprecated Prefer {@link CryptoApi.isCrossSigningReady | `CryptoApi.isCrossSigningReady`}:
|
2831
|
-
*/
|
2832
|
-
public isCrossSigningReady(): Promise<boolean> {
|
2833
|
-
if (!this.cryptoBackend) {
|
2834
|
-
throw new Error("End-to-end encryption disabled");
|
2835
|
-
}
|
2836
|
-
return this.cryptoBackend.isCrossSigningReady();
|
2837
|
-
}
|
2838
|
-
|
2839
|
-
/**
|
2840
|
-
* Bootstrap cross-signing by creating keys if needed. If everything is already
|
2841
|
-
* set up, then no changes are made, so this is safe to run to ensure
|
2842
|
-
* cross-signing is ready for use.
|
2843
|
-
*
|
2844
|
-
* This function:
|
2845
|
-
* - creates new cross-signing keys if they are not found locally cached nor in
|
2846
|
-
* secret storage (if it has been set up)
|
2847
|
-
*
|
2848
|
-
* @deprecated Prefer {@link CryptoApi.bootstrapCrossSigning | `CryptoApi.bootstrapCrossSigning`}.
|
2849
|
-
*/
|
2850
|
-
public bootstrapCrossSigning(opts: BootstrapCrossSigningOpts): Promise<void> {
|
2851
|
-
if (!this.cryptoBackend) {
|
2852
|
-
throw new Error("End-to-end encryption disabled");
|
2853
|
-
}
|
2854
|
-
return this.cryptoBackend.bootstrapCrossSigning(opts);
|
2855
|
-
}
|
2856
|
-
|
2857
|
-
/**
|
2858
|
-
* Whether to trust a others users signatures of their devices.
|
2859
|
-
* If false, devices will only be considered 'verified' if we have
|
2860
|
-
* verified that device individually (effectively disabling cross-signing).
|
2861
|
-
*
|
2862
|
-
* Default: true
|
2863
|
-
*
|
2864
|
-
* @returns True if trusting cross-signed devices
|
2865
|
-
*
|
2866
|
-
* @deprecated Prefer {@link CryptoApi.getTrustCrossSignedDevices | `CryptoApi.getTrustCrossSignedDevices`}.
|
2867
|
-
*/
|
2868
|
-
public getCryptoTrustCrossSignedDevices(): boolean {
|
2869
|
-
if (!this.cryptoBackend) {
|
2870
|
-
throw new Error("End-to-end encryption disabled");
|
2871
|
-
}
|
2872
|
-
return this.cryptoBackend.getTrustCrossSignedDevices();
|
2873
|
-
}
|
2874
|
-
|
2875
|
-
/**
|
2876
|
-
* See getCryptoTrustCrossSignedDevices
|
2877
|
-
*
|
2878
|
-
* @param val - True to trust cross-signed devices
|
2879
|
-
*
|
2880
|
-
* @deprecated Prefer {@link CryptoApi.setTrustCrossSignedDevices | `CryptoApi.setTrustCrossSignedDevices`}.
|
2881
|
-
*/
|
2882
|
-
public setCryptoTrustCrossSignedDevices(val: boolean): void {
|
2883
|
-
if (!this.cryptoBackend) {
|
2884
|
-
throw new Error("End-to-end encryption disabled");
|
2885
|
-
}
|
2886
|
-
this.cryptoBackend.setTrustCrossSignedDevices(val);
|
2887
|
-
}
|
2888
|
-
|
2889
|
-
/**
|
2890
|
-
* Counts the number of end to end session keys that are waiting to be backed up
|
2891
|
-
* @returns Promise which resolves to the number of sessions requiring backup
|
2892
|
-
*
|
2893
|
-
* @deprecated Not supported for Rust Cryptography.
|
2894
|
-
*/
|
2895
|
-
public countSessionsNeedingBackup(): Promise<number> {
|
2896
|
-
if (!this.crypto) {
|
2897
|
-
throw new Error("End-to-end encryption disabled");
|
2898
|
-
}
|
2899
|
-
return this.crypto.countSessionsNeedingBackup();
|
2900
|
-
}
|
2901
|
-
|
2902
|
-
/**
|
2903
|
-
* Get information about the encryption of an event
|
2904
|
-
*
|
2905
|
-
* @param event - event to be checked
|
2906
|
-
* @returns The event information.
|
2907
|
-
* @deprecated Prefer {@link Crypto.CryptoApi.getEncryptionInfoForEvent | `CryptoApi.getEncryptionInfoForEvent`}.
|
2908
|
-
*/
|
2909
|
-
public getEventEncryptionInfo(event: MatrixEvent): IEncryptedEventInfo {
|
2910
|
-
if (!this.cryptoBackend) {
|
2911
|
-
throw new Error("End-to-end encryption disabled");
|
2912
|
-
}
|
2913
|
-
return this.cryptoBackend.getEventEncryptionInfo(event);
|
2914
|
-
}
|
2915
|
-
|
2916
|
-
/**
|
2917
|
-
* Create a recovery key from a user-supplied passphrase.
|
2918
|
-
*
|
2919
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
2920
|
-
*
|
2921
|
-
* @param password - Passphrase string that can be entered by the user
|
2922
|
-
* when restoring the backup as an alternative to entering the recovery key.
|
2923
|
-
* Optional.
|
2924
|
-
* @returns Object with public key metadata, encoded private
|
2925
|
-
* recovery key which should be disposed of after displaying to the user,
|
2926
|
-
* and raw private key to avoid round tripping if needed.
|
2927
|
-
*
|
2928
|
-
* @deprecated Prefer {@link CryptoApi.createRecoveryKeyFromPassphrase | `CryptoApi.createRecoveryKeyFromPassphrase`}.
|
2929
|
-
*/
|
2930
|
-
public createRecoveryKeyFromPassphrase(password?: string): Promise<IRecoveryKey> {
|
2931
|
-
if (!this.cryptoBackend) {
|
2932
|
-
throw new Error("End-to-end encryption disabled");
|
2933
|
-
}
|
2934
|
-
return this.cryptoBackend.createRecoveryKeyFromPassphrase(password);
|
2935
|
-
}
|
2936
|
-
|
2937
|
-
/**
|
2938
|
-
* Checks whether secret storage:
|
2939
|
-
* - is enabled on this account
|
2940
|
-
* - is storing cross-signing private keys
|
2941
|
-
* - is storing session backup key (if enabled)
|
2942
|
-
*
|
2943
|
-
* If this function returns false, bootstrapSecretStorage() can be used
|
2944
|
-
* to fix things such that it returns true. That is to say, after
|
2945
|
-
* bootstrapSecretStorage() completes successfully, this function should
|
2946
|
-
* return true.
|
2947
|
-
*
|
2948
|
-
* @returns True if secret storage is ready to be used on this device
|
2949
|
-
* @deprecated Prefer {@link CryptoApi.isSecretStorageReady | `CryptoApi.isSecretStorageReady`}.
|
2950
|
-
*/
|
2951
|
-
public isSecretStorageReady(): Promise<boolean> {
|
2952
|
-
if (!this.cryptoBackend) {
|
2953
|
-
throw new Error("End-to-end encryption disabled");
|
2954
|
-
}
|
2955
|
-
return this.cryptoBackend.isSecretStorageReady();
|
2956
|
-
}
|
2957
|
-
|
2958
|
-
/**
|
2959
|
-
* Bootstrap Secure Secret Storage if needed by creating a default key. If everything is
|
2960
|
-
* already set up, then no changes are made, so this is safe to run to ensure secret
|
2961
|
-
* storage is ready for use.
|
2962
|
-
*
|
2963
|
-
* This function
|
2964
|
-
* - creates a new Secure Secret Storage key if no default key exists
|
2965
|
-
* - if a key backup exists, it is migrated to store the key in the Secret
|
2966
|
-
* Storage
|
2967
|
-
* - creates a backup if none exists, and one is requested
|
2968
|
-
* - migrates Secure Secret Storage to use the latest algorithm, if an outdated
|
2969
|
-
* algorithm is found
|
2970
|
-
*
|
2971
|
-
* @deprecated Use {@link CryptoApi.bootstrapSecretStorage | `CryptoApi.bootstrapSecretStorage`}.
|
2972
|
-
*/
|
2973
|
-
public bootstrapSecretStorage(opts: ICreateSecretStorageOpts): Promise<void> {
|
2974
|
-
if (!this.cryptoBackend) {
|
2975
|
-
throw new Error("End-to-end encryption disabled");
|
2976
|
-
}
|
2977
|
-
return this.cryptoBackend.bootstrapSecretStorage(opts);
|
2978
|
-
}
|
2979
|
-
|
2980
|
-
/**
|
2981
|
-
* Add a key for encrypting secrets.
|
2982
|
-
*
|
2983
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
2984
|
-
*
|
2985
|
-
* @param algorithm - the algorithm used by the key
|
2986
|
-
* @param opts - the options for the algorithm. The properties used
|
2987
|
-
* depend on the algorithm given.
|
2988
|
-
* @param keyName - the name of the key. If not given, a random name will be generated.
|
2989
|
-
*
|
2990
|
-
* @returns An object with:
|
2991
|
-
* keyId: the ID of the key
|
2992
|
-
* keyInfo: details about the key (iv, mac, passphrase)
|
2993
|
-
*
|
2994
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#addKey}.
|
2995
|
-
*/
|
2996
|
-
public addSecretStorageKey(
|
2997
|
-
algorithm: string,
|
2998
|
-
opts: AddSecretStorageKeyOpts,
|
2999
|
-
keyName?: string,
|
3000
|
-
): Promise<{ keyId: string; keyInfo: SecretStorageKeyDescription }> {
|
3001
|
-
return this.secretStorage.addKey(algorithm, opts, keyName);
|
3002
|
-
}
|
3003
|
-
|
3004
|
-
/**
|
3005
|
-
* Check whether we have a key with a given ID.
|
3006
|
-
*
|
3007
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
3008
|
-
*
|
3009
|
-
* @param keyId - The ID of the key to check
|
3010
|
-
* for. Defaults to the default key ID if not provided.
|
3011
|
-
* @returns Whether we have the key.
|
3012
|
-
*
|
3013
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#hasKey}.
|
3014
|
-
*/
|
3015
|
-
public hasSecretStorageKey(keyId?: string): Promise<boolean> {
|
3016
|
-
return this.secretStorage.hasKey(keyId);
|
3017
|
-
}
|
3018
|
-
|
3019
|
-
/**
|
3020
|
-
* Store an encrypted secret on the server.
|
3021
|
-
*
|
3022
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
3023
|
-
*
|
3024
|
-
* @param name - The name of the secret
|
3025
|
-
* @param secret - The secret contents.
|
3026
|
-
* @param keys - The IDs of the keys to use to encrypt the secret or null/undefined
|
3027
|
-
* to use the default (will throw if no default key is set).
|
3028
|
-
*
|
3029
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#store}.
|
3030
|
-
*/
|
3031
|
-
public storeSecret(name: string, secret: string, keys?: string[]): Promise<void> {
|
3032
|
-
return this.secretStorage.store(name, secret, keys);
|
3033
|
-
}
|
3034
|
-
|
3035
|
-
/**
|
3036
|
-
* Get a secret from storage.
|
3037
|
-
*
|
3038
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
3039
|
-
*
|
3040
|
-
* @param name - the name of the secret
|
3041
|
-
*
|
3042
|
-
* @returns the contents of the secret
|
3043
|
-
*
|
3044
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#get}.
|
3045
|
-
*/
|
3046
|
-
public getSecret(name: string): Promise<string | undefined> {
|
3047
|
-
return this.secretStorage.get(name);
|
3048
|
-
}
|
3049
|
-
|
3050
|
-
/**
|
3051
|
-
* Check if a secret is stored on the server.
|
3052
|
-
*
|
3053
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
3054
|
-
*
|
3055
|
-
* @param name - the name of the secret
|
3056
|
-
* @returns map of key name to key info the secret is encrypted
|
3057
|
-
* with, or null if it is not present or not encrypted with a trusted
|
3058
|
-
* key
|
3059
|
-
*
|
3060
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#isStored}.
|
3061
|
-
*/
|
3062
|
-
public isSecretStored(name: string): Promise<Record<string, SecretStorageKeyDescription> | null> {
|
3063
|
-
return this.secretStorage.isStored(name);
|
3064
|
-
}
|
3065
|
-
|
3066
|
-
/**
|
3067
|
-
* Request a secret from another device.
|
3068
|
-
*
|
3069
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
3070
|
-
*
|
3071
|
-
* @param name - the name of the secret to request
|
3072
|
-
* @param devices - the devices to request the secret from
|
3073
|
-
*
|
3074
|
-
* @returns the secret request object
|
3075
|
-
* @deprecated Not supported for Rust Cryptography.
|
3076
|
-
*/
|
3077
|
-
public requestSecret(name: string, devices: string[]): ISecretRequest {
|
3078
|
-
if (!this.crypto) {
|
3079
|
-
throw new Error("End-to-end encryption disabled");
|
3080
|
-
}
|
3081
|
-
return this.crypto.requestSecret(name, devices);
|
3082
|
-
}
|
3083
|
-
|
3084
|
-
/**
|
3085
|
-
* Get the current default key ID for encrypting secrets.
|
3086
|
-
*
|
3087
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
3088
|
-
*
|
3089
|
-
* @returns The default key ID or null if no default key ID is set
|
3090
|
-
*
|
3091
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#getDefaultKeyId}.
|
3092
|
-
*/
|
3093
|
-
public getDefaultSecretStorageKeyId(): Promise<string | null> {
|
3094
|
-
return this.secretStorage.getDefaultKeyId();
|
3095
|
-
}
|
3096
|
-
|
3097
|
-
/**
|
3098
|
-
* Set the current default key ID for encrypting secrets.
|
3099
|
-
*
|
3100
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
3101
|
-
*
|
3102
|
-
* @param keyId - The new default key ID
|
3103
|
-
*
|
3104
|
-
* @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#setDefaultKeyId}.
|
3105
|
-
*/
|
3106
|
-
public setDefaultSecretStorageKeyId(keyId: string): Promise<void> {
|
3107
|
-
return this.secretStorage.setDefaultKeyId(keyId);
|
3108
|
-
}
|
3109
|
-
|
3110
|
-
/**
|
3111
|
-
* Checks that a given secret storage private key matches a given public key.
|
3112
|
-
* This can be used by the getSecretStorageKey callback to verify that the
|
3113
|
-
* private key it is about to supply is the one that was requested.
|
3114
|
-
*
|
3115
|
-
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
3116
|
-
*
|
3117
|
-
* @param privateKey - The private key
|
3118
|
-
* @param expectedPublicKey - The public key
|
3119
|
-
* @returns true if the key matches, otherwise false
|
3120
|
-
*
|
3121
|
-
* @deprecated The use of asymmetric keys for SSSS is deprecated.
|
3122
|
-
* Use {@link SecretStorage.ServerSideSecretStorage#checkKey} for symmetric keys.
|
3123
|
-
*/
|
3124
|
-
public checkSecretStoragePrivateKey(privateKey: Uint8Array, expectedPublicKey: string): boolean {
|
3125
|
-
if (!this.crypto) {
|
3126
|
-
throw new Error("End-to-end encryption disabled");
|
3127
|
-
}
|
3128
|
-
return this.crypto.checkSecretStoragePrivateKey(privateKey, expectedPublicKey);
|
3129
|
-
}
|
3130
|
-
|
3131
|
-
/**
|
3132
|
-
* Get e2e information on the device that sent an event
|
3133
|
-
*
|
3134
|
-
* @param event - event to be checked
|
3135
|
-
* @deprecated Not supported for Rust Cryptography.
|
3136
|
-
*/
|
3137
|
-
public async getEventSenderDeviceInfo(event: MatrixEvent): Promise<DeviceInfo | null> {
|
3138
|
-
if (!this.crypto) {
|
3139
|
-
return null;
|
3140
|
-
}
|
3141
|
-
return this.crypto.getEventSenderDeviceInfo(event);
|
3142
|
-
}
|
3143
|
-
|
3144
|
-
/**
|
3145
|
-
* Check if the sender of an event is verified
|
3146
|
-
*
|
3147
|
-
* @param event - event to be checked
|
3148
|
-
*
|
3149
|
-
* @returns true if the sender of this event has been verified using
|
3150
|
-
* {@link MatrixClient#setDeviceVerified}.
|
3151
|
-
*
|
3152
|
-
* @deprecated Not supported for Rust Cryptography.
|
3153
|
-
*/
|
3154
|
-
public async isEventSenderVerified(event: MatrixEvent): Promise<boolean> {
|
3155
|
-
const device = await this.getEventSenderDeviceInfo(event);
|
3156
|
-
if (!device) {
|
3157
|
-
return false;
|
3158
|
-
}
|
3159
|
-
return device.isVerified();
|
3160
|
-
}
|
3161
|
-
|
3162
|
-
/**
|
3163
|
-
* Get outgoing room key request for this event if there is one.
|
3164
|
-
* @param event - The event to check for
|
3165
|
-
*
|
3166
|
-
* @returns A room key request, or null if there is none
|
3167
|
-
*
|
3168
|
-
* @deprecated Not supported for Rust Cryptography.
|
3169
|
-
*/
|
3170
|
-
public getOutgoingRoomKeyRequest(event: MatrixEvent): Promise<OutgoingRoomKeyRequest | null> {
|
3171
|
-
if (!this.crypto) {
|
3172
|
-
throw new Error("End-to-End encryption disabled");
|
3173
|
-
}
|
3174
|
-
const wireContent = event.getWireContent();
|
3175
|
-
const requestBody: IRoomKeyRequestBody = {
|
3176
|
-
session_id: wireContent.session_id,
|
3177
|
-
sender_key: wireContent.sender_key,
|
3178
|
-
algorithm: wireContent.algorithm,
|
3179
|
-
room_id: event.getRoomId()!,
|
3180
|
-
};
|
3181
|
-
if (!requestBody.session_id || !requestBody.sender_key || !requestBody.algorithm || !requestBody.room_id) {
|
3182
|
-
return Promise.resolve(null);
|
3183
|
-
}
|
3184
|
-
return this.crypto.cryptoStore.getOutgoingRoomKeyRequest(requestBody);
|
3185
|
-
}
|
3186
|
-
|
3187
|
-
/**
|
3188
|
-
* Cancel a room key request for this event if one is ongoing and resend the
|
3189
|
-
* request.
|
3190
|
-
* @param event - event of which to cancel and resend the room
|
3191
|
-
* key request.
|
3192
|
-
* @returns A promise that will resolve when the key request is queued
|
3193
|
-
*
|
3194
|
-
* @deprecated Not supported for Rust Cryptography.
|
3195
|
-
*/
|
3196
|
-
public cancelAndResendEventRoomKeyRequest(event: MatrixEvent): Promise<void> {
|
3197
|
-
if (!this.crypto) {
|
3198
|
-
throw new Error("End-to-End encryption disabled");
|
3199
|
-
}
|
3200
|
-
return event.cancelAndResendKeyRequest(this.crypto, this.getUserId()!);
|
3201
|
-
}
|
3202
|
-
|
3203
|
-
/**
|
3204
|
-
* Enable end-to-end encryption for a room. This does not modify room state.
|
3205
|
-
* Any messages sent before the returned promise resolves will be sent unencrypted.
|
3206
|
-
* @param roomId - The room ID to enable encryption in.
|
3207
|
-
* @param config - The encryption config for the room.
|
3208
|
-
* @returns A promise that will resolve when encryption is set up.
|
3209
|
-
*
|
3210
|
-
* @deprecated Not supported for Rust Cryptography. To enable encryption in a room, send an `m.room.encryption`
|
3211
|
-
* state event.
|
3212
|
-
*/
|
3213
|
-
public setRoomEncryption(roomId: string, config: IRoomEncryption): Promise<void> {
|
3214
|
-
if (!this.crypto) {
|
3215
|
-
throw new Error("End-to-End encryption disabled");
|
3216
|
-
}
|
3217
|
-
return this.crypto.setRoomEncryption(roomId, config);
|
3218
|
-
}
|
3219
|
-
|
3220
|
-
/**
|
3221
|
-
* Whether encryption is enabled for a room.
|
3222
|
-
* @param roomId - the room id to query.
|
3223
|
-
* @returns whether encryption is enabled.
|
3224
|
-
*
|
3225
|
-
* @deprecated Not correctly supported for Rust Cryptography. Use {@link CryptoApi.isEncryptionEnabledInRoom} and/or
|
3226
|
-
* {@link Room.hasEncryptionStateEvent}.
|
3227
|
-
*/
|
3228
|
-
public isRoomEncrypted(roomId: string): boolean {
|
3229
|
-
const room = this.getRoom(roomId);
|
3230
|
-
if (!room) {
|
3231
|
-
// we don't know about this room, so can't determine if it should be
|
3232
|
-
// encrypted. Let's assume not.
|
3233
|
-
return false;
|
3234
|
-
}
|
3235
|
-
|
3236
|
-
// if there is an 'm.room.encryption' event in this room, it should be
|
3237
|
-
// encrypted (independently of whether we actually support encryption)
|
3238
|
-
if (room.hasEncryptionStateEvent()) {
|
3239
|
-
return true;
|
3240
|
-
}
|
3241
|
-
|
3242
|
-
// we don't have an m.room.encrypted event, but that might be because
|
3243
|
-
// the server is hiding it from us. Check the store to see if it was
|
3244
|
-
// previously encrypted.
|
3245
|
-
return this.crypto?.isRoomEncrypted(roomId) ?? false;
|
3246
|
-
}
|
3247
|
-
|
3248
|
-
/**
|
3249
|
-
* Encrypts and sends a given object via Olm to-device messages to a given
|
3250
|
-
* set of devices.
|
3251
|
-
*
|
3252
|
-
* @param userDeviceInfoArr - list of deviceInfo objects representing the devices to send to
|
3253
|
-
*
|
3254
|
-
* @param payload - fields to include in the encrypted payload
|
3255
|
-
*
|
3256
|
-
* @returns Promise which
|
3257
|
-
* resolves once the message has been encrypted and sent to the given
|
3258
|
-
* userDeviceMap, and returns the `{ contentMap, deviceInfoByDeviceId }`
|
3259
|
-
* of the successfully sent messages.
|
3260
|
-
*
|
3261
|
-
* @deprecated Instead use {@link CryptoApi.encryptToDeviceMessages} followed by {@link queueToDevice}.
|
3262
|
-
*/
|
3263
|
-
public encryptAndSendToDevices(userDeviceInfoArr: IOlmDevice<DeviceInfo>[], payload: object): Promise<void> {
|
3264
|
-
if (!this.crypto) {
|
3265
|
-
throw new Error("End-to-End encryption disabled");
|
3266
|
-
}
|
3267
|
-
return this.crypto.encryptAndSendToDevices(userDeviceInfoArr, payload);
|
3268
|
-
}
|
3269
|
-
|
3270
|
-
/**
|
3271
|
-
* Forces the current outbound group session to be discarded such
|
3272
|
-
* that another one will be created next time an event is sent.
|
3273
|
-
*
|
3274
|
-
* @param roomId - The ID of the room to discard the session for
|
3275
|
-
*
|
3276
|
-
* @deprecated Prefer {@link CryptoApi.forceDiscardSession | `CryptoApi.forceDiscardSession`}:
|
3277
|
-
*/
|
3278
|
-
public forceDiscardSession(roomId: string): void {
|
3279
|
-
if (!this.cryptoBackend) {
|
3280
|
-
throw new Error("End-to-End encryption disabled");
|
3281
|
-
}
|
3282
|
-
this.cryptoBackend.forceDiscardSession(roomId);
|
3283
|
-
}
|
3284
|
-
|
3285
|
-
/**
|
3286
|
-
* Get a list containing all of the room keys
|
3287
|
-
*
|
3288
|
-
* This should be encrypted before returning it to the user.
|
3289
|
-
*
|
3290
|
-
* @returns a promise which resolves to a list of session export objects
|
3291
|
-
*
|
3292
|
-
* @deprecated Prefer {@link CryptoApi.exportRoomKeys | `CryptoApi.exportRoomKeys`}:
|
3293
|
-
*
|
3294
|
-
* ```javascript
|
3295
|
-
* sessionData = await client.getCrypto().exportRoomKeys();
|
3296
|
-
* ```
|
3297
|
-
*/
|
3298
|
-
public exportRoomKeys(): Promise<IMegolmSessionData[]> {
|
3299
|
-
if (!this.cryptoBackend) {
|
3300
|
-
return Promise.reject(new Error("End-to-end encryption disabled"));
|
3301
|
-
}
|
3302
|
-
return this.cryptoBackend.exportRoomKeys();
|
3303
|
-
}
|
3304
|
-
|
3305
|
-
/**
|
3306
|
-
* Import a list of room keys previously exported by exportRoomKeys
|
3307
|
-
*
|
3308
|
-
* @param keys - a list of session export objects
|
3309
|
-
* @param opts - options object
|
3310
|
-
*
|
3311
|
-
* @returns a promise which resolves when the keys have been imported
|
3312
|
-
*
|
3313
|
-
* @deprecated Prefer {@link CryptoApi.importRoomKeys | `CryptoApi.importRoomKeys`}:
|
3314
|
-
* ```javascript
|
3315
|
-
* await client.getCrypto()?.importRoomKeys([..]);
|
3316
|
-
* ```
|
3317
|
-
*/
|
3318
|
-
public importRoomKeys(keys: IMegolmSessionData[], opts?: ImportRoomKeysOpts): Promise<void> {
|
3319
|
-
if (!this.cryptoBackend) {
|
3320
|
-
throw new Error("End-to-end encryption disabled");
|
3321
|
-
}
|
3322
|
-
return this.cryptoBackend.importRoomKeys(keys, opts);
|
3323
|
-
}
|
3324
|
-
|
3325
|
-
/**
|
3326
|
-
* Force a re-check of the local key backup status against
|
3327
|
-
* what's on the server.
|
3328
|
-
*
|
3329
|
-
* @returns Object with backup info (as returned by
|
3330
|
-
* getKeyBackupVersion) in backupInfo and
|
3331
|
-
* trust information (as returned by isKeyBackupTrusted)
|
3332
|
-
* in trustInfo.
|
3333
|
-
*
|
3334
|
-
* @deprecated Prefer {@link Crypto.CryptoApi.checkKeyBackupAndEnable}.
|
3335
|
-
*/
|
3336
|
-
public checkKeyBackup(): Promise<IKeyBackupCheck | null> {
|
3337
|
-
if (!this.crypto) {
|
3338
|
-
throw new Error("End-to-end encryption disabled");
|
3339
|
-
}
|
3340
|
-
return this.crypto.backupManager.checkKeyBackup();
|
3341
|
-
}
|
3342
|
-
|
3343
|
-
/**
|
3344
|
-
* Get information about the current key backup from the server.
|
3345
|
-
*
|
3346
|
-
* Performs some basic validity checks on the shape of the result, and raises an error if it is not as expected.
|
3347
|
-
*
|
3348
|
-
* **Note**: there is no (supported) way to distinguish between "failure to talk to the server" and "another client
|
3349
|
-
* uploaded a key backup version using an algorithm I don't understand.
|
3350
|
-
*
|
3351
|
-
* @returns Information object from API, or null if no backup is present on the server.
|
3352
|
-
*
|
3353
|
-
* @deprecated Prefer {@link CryptoApi.getKeyBackupInfo}.
|
3354
|
-
*/
|
3355
|
-
public async getKeyBackupVersion(): Promise<IKeyBackupInfo | null> {
|
3356
|
-
let res: IKeyBackupInfo;
|
3357
|
-
try {
|
3358
|
-
res = await this.http.authedRequest<IKeyBackupInfo>(
|
3359
|
-
Method.Get,
|
3360
|
-
"/room_keys/version",
|
3361
|
-
undefined,
|
3362
|
-
undefined,
|
3363
|
-
{ prefix: ClientPrefix.V3 },
|
3364
|
-
);
|
3365
|
-
} catch (e) {
|
3366
|
-
if ((<MatrixError>e).errcode === "M_NOT_FOUND") {
|
3367
|
-
return null;
|
3368
|
-
} else {
|
3369
|
-
throw e;
|
3370
|
-
}
|
3371
|
-
}
|
3372
|
-
BackupManager.checkBackupVersion(res);
|
3373
|
-
return res;
|
3374
|
-
}
|
3375
|
-
|
3376
|
-
/**
|
3377
|
-
* @param info - key backup info dict from getKeyBackupVersion()
|
3378
|
-
*
|
3379
|
-
* @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.isKeyBackupTrusted | `CryptoApi.isKeyBackupTrusted`}.
|
3380
|
-
*/
|
3381
|
-
public isKeyBackupTrusted(info: IKeyBackupInfo): Promise<TrustInfo> {
|
3382
|
-
if (!this.crypto) {
|
3383
|
-
throw new Error("End-to-end encryption disabled");
|
3384
|
-
}
|
3385
|
-
return this.crypto.backupManager.isKeyBackupTrusted(info);
|
3386
|
-
}
|
3387
|
-
|
3388
|
-
/**
|
3389
|
-
* @returns true if the client is configured to back up keys to
|
3390
|
-
* the server, otherwise false. If we haven't completed a successful check
|
3391
|
-
* of key backup status yet, returns null.
|
3392
|
-
*
|
3393
|
-
* @deprecated Not supported for Rust Cryptography. Prefer direct access to {@link Crypto.CryptoApi.getActiveSessionBackupVersion}:
|
3394
|
-
*
|
3395
|
-
* ```javascript
|
3396
|
-
* let enabled = (await client.getCrypto().getActiveSessionBackupVersion()) !== null;
|
3397
|
-
* ```
|
3398
|
-
*/
|
3399
|
-
public getKeyBackupEnabled(): boolean | null {
|
3400
|
-
if (!this.crypto) {
|
3401
|
-
throw new Error("End-to-end encryption disabled");
|
3402
|
-
}
|
3403
|
-
return this.crypto.backupManager.getKeyBackupEnabled();
|
3404
|
-
}
|
3405
|
-
|
3406
|
-
/**
|
3407
|
-
* Enable backing up of keys, using data previously returned from
|
3408
|
-
* getKeyBackupVersion.
|
3409
|
-
*
|
3410
|
-
* @param info - Backup information object as returned by getKeyBackupVersion
|
3411
|
-
* @returns Promise which resolves when complete.
|
3412
|
-
*
|
3413
|
-
* @deprecated Do not call this directly. Instead call {@link Crypto.CryptoApi.checkKeyBackupAndEnable}.
|
3414
|
-
*/
|
3415
|
-
public enableKeyBackup(info: IKeyBackupInfo): Promise<void> {
|
3416
|
-
if (!this.crypto) {
|
3417
|
-
throw new Error("End-to-end encryption disabled");
|
3418
|
-
}
|
3419
|
-
|
3420
|
-
return this.crypto.backupManager.enableKeyBackup(info);
|
3421
|
-
}
|
3422
|
-
|
3423
|
-
/**
|
3424
|
-
* Disable backing up of keys.
|
3425
|
-
*
|
3426
|
-
* @deprecated Not supported for Rust Cryptography. It should be unnecessary to disable key backup.
|
3427
|
-
*/
|
3428
|
-
public disableKeyBackup(): void {
|
3429
|
-
if (!this.crypto) {
|
3430
|
-
throw new Error("End-to-end encryption disabled");
|
3431
|
-
}
|
3432
|
-
|
3433
|
-
this.crypto.backupManager.disableKeyBackup();
|
3434
|
-
}
|
3435
|
-
|
3436
|
-
/**
|
3437
|
-
* Set up the data required to create a new backup version. The backup version
|
3438
|
-
* will not be created and enabled until createKeyBackupVersion is called.
|
3439
|
-
*
|
3440
|
-
* @param password - Passphrase string that can be entered by the user
|
3441
|
-
* when restoring the backup as an alternative to entering the recovery key.
|
3442
|
-
* Optional.
|
3443
|
-
*
|
3444
|
-
* @returns Object that can be passed to createKeyBackupVersion and
|
3445
|
-
* additionally has a 'recovery_key' member with the user-facing recovery key string.
|
3446
|
-
*
|
3447
|
-
* @deprecated Not supported for Rust cryptography. Use {@link Crypto.CryptoApi.resetKeyBackup | `CryptoApi.resetKeyBackup`}.
|
3448
|
-
*/
|
3449
|
-
public async prepareKeyBackupVersion(
|
3450
|
-
password?: string | Uint8Array | null,
|
3451
|
-
opts: IKeyBackupPrepareOpts = { secureSecretStorage: false },
|
3452
|
-
): Promise<Pick<IPreparedKeyBackupVersion, "algorithm" | "auth_data" | "recovery_key">> {
|
3453
|
-
if (!this.crypto) {
|
3454
|
-
throw new Error("End-to-end encryption disabled");
|
3455
|
-
}
|
3456
|
-
|
3457
|
-
// eslint-disable-next-line camelcase
|
3458
|
-
const { algorithm, auth_data, recovery_key, privateKey } =
|
3459
|
-
await this.crypto.backupManager.prepareKeyBackupVersion(password);
|
3460
|
-
|
3461
|
-
if (opts.secureSecretStorage) {
|
3462
|
-
await this.secretStorage.store("m.megolm_backup.v1", encodeBase64(privateKey));
|
3463
|
-
this.logger.info("Key backup private key stored in secret storage");
|
3464
|
-
}
|
3465
|
-
|
3466
|
-
return {
|
3467
|
-
algorithm,
|
3468
|
-
/* eslint-disable camelcase */
|
3469
|
-
auth_data,
|
3470
|
-
recovery_key,
|
3471
|
-
/* eslint-enable camelcase */
|
3472
|
-
};
|
3473
|
-
}
|
3474
|
-
|
3475
|
-
/**
|
3476
|
-
* Check whether the key backup private key is stored in secret storage.
|
3477
|
-
* @returns map of key name to key info the secret is
|
3478
|
-
* encrypted with, or null if it is not present or not encrypted with a
|
3479
|
-
* trusted key
|
3480
|
-
*/
|
3481
|
-
public isKeyBackupKeyStored(): Promise<Record<string, SecretStorageKeyDescription> | null> {
|
3482
|
-
return Promise.resolve(this.secretStorage.isStored("m.megolm_backup.v1"));
|
3483
|
-
}
|
3484
|
-
|
3485
|
-
/**
|
3486
|
-
* Create a new key backup version and enable it, using the information return
|
3487
|
-
* from prepareKeyBackupVersion.
|
3488
|
-
*
|
3489
|
-
* @param info - Info object from prepareKeyBackupVersion
|
3490
|
-
* @returns Object with 'version' param indicating the version created
|
3491
|
-
*
|
3492
|
-
* @deprecated Use {@link Crypto.CryptoApi.resetKeyBackup | `CryptoApi.resetKeyBackup`}.
|
3493
|
-
*/
|
3494
|
-
public async createKeyBackupVersion(info: IKeyBackupInfo): Promise<IKeyBackupInfo> {
|
3495
|
-
if (!this.crypto) {
|
3496
|
-
throw new Error("End-to-end encryption disabled");
|
3497
|
-
}
|
3498
|
-
|
3499
|
-
await this.crypto.backupManager.createKeyBackupVersion(info);
|
3500
|
-
|
3501
|
-
const data = {
|
3502
|
-
algorithm: info.algorithm,
|
3503
|
-
auth_data: info.auth_data,
|
3504
|
-
};
|
3505
|
-
|
3506
|
-
// Sign the backup auth data with the device key for backwards compat with
|
3507
|
-
// older devices with cross-signing. This can probably go away very soon in
|
3508
|
-
// favour of just signing with the cross-singing master key.
|
3509
|
-
// XXX: Private member access
|
3510
|
-
await this.crypto.signObject(data.auth_data);
|
3511
|
-
|
3512
|
-
if (
|
3513
|
-
this.cryptoCallbacks.getCrossSigningKey &&
|
3514
|
-
// XXX: Private member access
|
3515
|
-
this.crypto.crossSigningInfo.getId()
|
3516
|
-
) {
|
3517
|
-
// now also sign the auth data with the cross-signing master key
|
3518
|
-
// we check for the callback explicitly here because we still want to be able
|
3519
|
-
// to create an un-cross-signed key backup if there is a cross-signing key but
|
3520
|
-
// no callback supplied.
|
3521
|
-
// XXX: Private member access
|
3522
|
-
await this.crypto.crossSigningInfo.signObject(data.auth_data, "master");
|
3523
|
-
}
|
3524
|
-
|
3525
|
-
const res = await this.http.authedRequest<IKeyBackupInfo>(Method.Post, "/room_keys/version", undefined, data);
|
3526
|
-
|
3527
|
-
// We could assume everything's okay and enable directly, but this ensures
|
3528
|
-
// we run the same signature verification that will be used for future
|
3529
|
-
// sessions.
|
3530
|
-
await this.checkKeyBackup();
|
3531
|
-
if (!this.getKeyBackupEnabled()) {
|
3532
|
-
this.logger.error("Key backup not usable even though we just created it");
|
3533
|
-
}
|
3534
|
-
|
3535
|
-
return res;
|
3536
|
-
}
|
3537
|
-
|
3538
|
-
/**
|
3539
|
-
* @deprecated Use {@link Crypto.CryptoApi.deleteKeyBackupVersion | `CryptoApi.deleteKeyBackupVersion`}.
|
3540
|
-
*/
|
3541
|
-
public async deleteKeyBackupVersion(version: string): Promise<void> {
|
3542
|
-
if (!this.cryptoBackend) {
|
3543
|
-
throw new Error("End-to-end encryption disabled");
|
3544
|
-
}
|
3545
|
-
|
3546
|
-
await this.cryptoBackend.deleteKeyBackupVersion(version);
|
3547
|
-
}
|
3548
|
-
|
3549
|
-
private makeKeyBackupPath(roomId?: string, sessionId?: string, version?: string): IKeyBackupPath {
|
3550
|
-
let path: string;
|
3551
|
-
if (sessionId !== undefined) {
|
3552
|
-
path = utils.encodeUri("/room_keys/keys/$roomId/$sessionId", {
|
3553
|
-
$roomId: roomId!,
|
3554
|
-
$sessionId: sessionId,
|
3555
|
-
});
|
3556
|
-
} else if (roomId !== undefined) {
|
3557
|
-
path = utils.encodeUri("/room_keys/keys/$roomId", {
|
3558
|
-
$roomId: roomId,
|
3559
|
-
});
|
3560
|
-
} else {
|
3561
|
-
path = "/room_keys/keys";
|
3562
|
-
}
|
3563
|
-
const queryData = version === undefined ? undefined : { version };
|
3564
|
-
return { path, queryData };
|
3565
|
-
}
|
3566
|
-
|
3567
|
-
/**
|
3568
|
-
* Back up session keys to the homeserver.
|
3569
|
-
* @param roomId - ID of the room that the keys are for Optional.
|
3570
|
-
* @param sessionId - ID of the session that the keys are for Optional.
|
3571
|
-
* @param version - backup version Optional.
|
3572
|
-
* @param data - Object keys to send
|
3573
|
-
* @returns a promise that will resolve when the keys
|
3574
|
-
* are uploaded
|
3575
|
-
*
|
3576
|
-
* @deprecated Not supported for Rust Cryptography.
|
3577
|
-
*/
|
3578
|
-
public sendKeyBackup(
|
3579
|
-
roomId: undefined,
|
3580
|
-
sessionId: undefined,
|
3581
|
-
version: string | undefined,
|
3582
|
-
data: IKeyBackup,
|
3583
|
-
): Promise<void>;
|
3584
|
-
public sendKeyBackup(
|
3585
|
-
roomId: string,
|
3586
|
-
sessionId: undefined,
|
3587
|
-
version: string | undefined,
|
3588
|
-
data: IKeyBackup,
|
3589
|
-
): Promise<void>;
|
3590
|
-
public sendKeyBackup(
|
3591
|
-
roomId: string,
|
3592
|
-
sessionId: string,
|
3593
|
-
version: string | undefined,
|
3594
|
-
data: IKeyBackup,
|
3595
|
-
): Promise<void>;
|
3596
|
-
public async sendKeyBackup(
|
3597
|
-
roomId: string | undefined,
|
3598
|
-
sessionId: string | undefined,
|
3599
|
-
version: string | undefined,
|
3600
|
-
data: IKeyBackup,
|
3601
|
-
): Promise<void> {
|
3602
|
-
if (!this.crypto) {
|
3603
|
-
throw new Error("End-to-end encryption disabled");
|
3604
|
-
}
|
3605
|
-
|
3606
|
-
const path = this.makeKeyBackupPath(roomId!, sessionId!, version);
|
3607
|
-
await this.http.authedRequest(Method.Put, path.path, path.queryData, data, { prefix: ClientPrefix.V3 });
|
3608
|
-
}
|
3609
|
-
|
3610
|
-
/**
|
3611
|
-
* Marks all group sessions as needing to be backed up and schedules them to
|
3612
|
-
* upload in the background as soon as possible.
|
3613
|
-
*
|
3614
|
-
* @deprecated Not supported for Rust Cryptography. This is done automatically as part of
|
3615
|
-
* {@link CryptoApi.resetKeyBackup}, so there is probably no need to call this manually.
|
1528
|
+
* and may change without warning.</b>
|
1529
|
+
* @param guest - True if this is a guest account.
|
1530
|
+
* @experimental if the token is a macaroon, it should be encoded in it that it is a 'guest'
|
1531
|
+
* access token, which means that the SDK can determine this entirely without
|
1532
|
+
* the dev manually flipping this flag.
|
3616
1533
|
*/
|
3617
|
-
public
|
3618
|
-
|
3619
|
-
throw new Error("End-to-end encryption disabled");
|
3620
|
-
}
|
3621
|
-
|
3622
|
-
await this.crypto.backupManager.scheduleAllGroupSessionsForBackup();
|
1534
|
+
public setGuest(guest: boolean): void {
|
1535
|
+
this.isGuestAccount = guest;
|
3623
1536
|
}
|
3624
1537
|
|
3625
1538
|
/**
|
3626
|
-
*
|
3627
|
-
*
|
3628
|
-
*
|
3629
|
-
* (This is done automatically as part of {@link CryptoApi.resetKeyBackup},
|
3630
|
-
* so there is probably no need to call this manually.)
|
3631
|
-
*
|
3632
|
-
* @returns Promise which resolves to the number of sessions requiring a backup.
|
3633
|
-
* @deprecated Not supported for Rust Cryptography.
|
1539
|
+
* Return the provided scheduler, if any.
|
1540
|
+
* @returns The scheduler or undefined
|
3634
1541
|
*/
|
3635
|
-
public
|
3636
|
-
|
3637
|
-
throw new Error("End-to-end encryption disabled");
|
3638
|
-
}
|
3639
|
-
|
3640
|
-
return this.crypto.backupManager.flagAllGroupSessionsForBackup();
|
1542
|
+
public getScheduler(): MatrixScheduler | undefined {
|
1543
|
+
return this.scheduler;
|
3641
1544
|
}
|
3642
1545
|
|
3643
1546
|
/**
|
3644
|
-
*
|
3645
|
-
*
|
3646
|
-
*
|
3647
|
-
*
|
1547
|
+
* Retry a backed off syncing request immediately. This should only be used when
|
1548
|
+
* the user <b>explicitly</b> attempts to retry their lost connection.
|
1549
|
+
* Will also retry any outbound to-device messages currently in the queue to be sent
|
1550
|
+
* (retries of regular outgoing events are handled separately, per-event).
|
1551
|
+
* @returns True if this resulted in a request being retried.
|
3648
1552
|
*/
|
3649
|
-
public
|
3650
|
-
|
3651
|
-
|
3652
|
-
|
3653
|
-
} catch {
|
3654
|
-
return false;
|
3655
|
-
}
|
1553
|
+
public retryImmediately(): boolean {
|
1554
|
+
// don't await for this promise: we just want to kick it off
|
1555
|
+
this.toDeviceMessageQueue.sendQueue();
|
1556
|
+
return this.syncApi?.retryImmediately() ?? false;
|
3656
1557
|
}
|
3657
1558
|
|
3658
1559
|
/**
|
3659
|
-
*
|
3660
|
-
* Used when migrating key backups into SSSS
|
3661
|
-
*
|
3662
|
-
* The cross-signing API is currently UNSTABLE and may change without notice.
|
1560
|
+
* Return the global notification EventTimelineSet, if any
|
3663
1561
|
*
|
3664
|
-
* @
|
3665
|
-
* @param backupInfo - Backup metadata from `checkKeyBackup`
|
3666
|
-
* @returns key backup key
|
3667
|
-
* @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.
|
1562
|
+
* @returns the globl notification EventTimelineSet
|
3668
1563
|
*/
|
3669
|
-
public
|
3670
|
-
return
|
1564
|
+
public getNotifTimelineSet(): EventTimelineSet | null {
|
1565
|
+
return this.notifTimelineSet;
|
3671
1566
|
}
|
3672
1567
|
|
3673
1568
|
/**
|
3674
|
-
*
|
3675
|
-
* Used when migrating key backups into SSSS
|
3676
|
-
*
|
3677
|
-
* The cross-signing API is currently UNSTABLE and may change without notice.
|
1569
|
+
* Set the global notification EventTimelineSet
|
3678
1570
|
*
|
3679
|
-
* @param recoveryKey - The recovery key
|
3680
|
-
* @returns key backup key
|
3681
|
-
* @deprecated Use {@link decodeRecoveryKey} directly
|
3682
1571
|
*/
|
3683
|
-
public
|
3684
|
-
|
1572
|
+
public setNotifTimelineSet(set: EventTimelineSet): void {
|
1573
|
+
this.notifTimelineSet = set;
|
3685
1574
|
}
|
3686
1575
|
|
3687
1576
|
/**
|
3688
|
-
*
|
3689
|
-
*
|
3690
|
-
* @param password - Passphrase
|
3691
|
-
* @param targetRoomId - Room ID to target a specific room.
|
3692
|
-
* Restores all rooms if omitted.
|
3693
|
-
* @param targetSessionId - Session ID to target a specific session.
|
3694
|
-
* Restores all sessions if omitted.
|
3695
|
-
* @param backupInfo - Backup metadata from `getKeyBackupVersion` or `checkKeyBackup`.`backupInfo`
|
3696
|
-
* @param opts - Optional params such as callbacks
|
3697
|
-
* @returns Status of restoration with `total` and `imported`
|
3698
|
-
* key counts.
|
1577
|
+
* Gets the cached capabilities of the homeserver, returning cached ones if available.
|
1578
|
+
* If there are no cached capabilities and none can be fetched, throw an exception.
|
3699
1579
|
*
|
3700
|
-
* @
|
3701
|
-
*/
|
3702
|
-
public async restoreKeyBackupWithPassword(
|
3703
|
-
password: string,
|
3704
|
-
targetRoomId: undefined,
|
3705
|
-
targetSessionId: undefined,
|
3706
|
-
backupInfo: IKeyBackupInfo,
|
3707
|
-
opts: IKeyBackupRestoreOpts,
|
3708
|
-
): Promise<IKeyBackupRestoreResult>;
|
3709
|
-
/**
|
3710
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackupWithPassphrase | `CryptoApi.restoreKeyBackupWithPassphrase`}.
|
3711
|
-
*/
|
3712
|
-
public async restoreKeyBackupWithPassword(
|
3713
|
-
password: string,
|
3714
|
-
targetRoomId: string,
|
3715
|
-
targetSessionId: undefined,
|
3716
|
-
backupInfo: IKeyBackupInfo,
|
3717
|
-
opts: IKeyBackupRestoreOpts,
|
3718
|
-
): Promise<IKeyBackupRestoreResult>;
|
3719
|
-
/**
|
3720
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackupWithPassphrase | `CryptoApi.restoreKeyBackupWithPassphrase`}.
|
3721
|
-
*/
|
3722
|
-
public async restoreKeyBackupWithPassword(
|
3723
|
-
password: string,
|
3724
|
-
targetRoomId: string,
|
3725
|
-
targetSessionId: string,
|
3726
|
-
backupInfo: IKeyBackupInfo,
|
3727
|
-
opts: IKeyBackupRestoreOpts,
|
3728
|
-
): Promise<IKeyBackupRestoreResult>;
|
3729
|
-
/**
|
3730
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackupWithPassphrase | `CryptoApi.restoreKeyBackupWithPassphrase`}.
|
1580
|
+
* @returns Promise resolving with The capabilities of the homeserver
|
3731
1581
|
*/
|
3732
|
-
public async
|
3733
|
-
|
3734
|
-
|
3735
|
-
|
3736
|
-
backupInfo: IKeyBackupInfo,
|
3737
|
-
opts: IKeyBackupRestoreOpts,
|
3738
|
-
): Promise<IKeyBackupRestoreResult> {
|
3739
|
-
const privKey = await keyFromAuthData(backupInfo.auth_data, password);
|
3740
|
-
return this.restoreKeyBackup(privKey, targetRoomId!, targetSessionId!, backupInfo, opts);
|
3741
|
-
}
|
3742
|
-
|
3743
|
-
/**
|
3744
|
-
* Restore from an existing key backup via a private key stored in secret
|
3745
|
-
* storage.
|
3746
|
-
*
|
3747
|
-
* @param backupInfo - Backup metadata from `checkKeyBackup`
|
3748
|
-
* @param targetRoomId - Room ID to target a specific room.
|
3749
|
-
* Restores all rooms if omitted.
|
3750
|
-
* @param targetSessionId - Session ID to target a specific session.
|
3751
|
-
* Restores all sessions if omitted.
|
3752
|
-
* @param opts - Optional params such as callbacks
|
3753
|
-
* @returns Status of restoration with `total` and `imported`
|
3754
|
-
* key counts.
|
3755
|
-
*
|
3756
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
3757
|
-
*/
|
3758
|
-
public async restoreKeyBackupWithSecretStorage(
|
3759
|
-
backupInfo: IKeyBackupInfo,
|
3760
|
-
targetRoomId?: string,
|
3761
|
-
targetSessionId?: string,
|
3762
|
-
opts?: IKeyBackupRestoreOpts,
|
3763
|
-
): Promise<IKeyBackupRestoreResult> {
|
3764
|
-
if (!this.cryptoBackend) {
|
3765
|
-
throw new Error("End-to-end encryption disabled");
|
3766
|
-
}
|
3767
|
-
const storedKey = await this.secretStorage.get("m.megolm_backup.v1");
|
3768
|
-
|
3769
|
-
// ensure that the key is in the right format. If not, fix the key and
|
3770
|
-
// store the fixed version
|
3771
|
-
const fixedKey = fixBackupKey(storedKey);
|
3772
|
-
if (fixedKey) {
|
3773
|
-
const keys = await this.secretStorage.getKey();
|
3774
|
-
await this.secretStorage.store("m.megolm_backup.v1", fixedKey, [keys![0]]);
|
3775
|
-
}
|
3776
|
-
|
3777
|
-
const privKey = decodeBase64(fixedKey || storedKey!);
|
3778
|
-
return this.restoreKeyBackup(privKey, targetRoomId!, targetSessionId!, backupInfo, opts);
|
3779
|
-
}
|
3780
|
-
|
3781
|
-
/**
|
3782
|
-
* Restore from an existing key backup via an encoded recovery key.
|
3783
|
-
*
|
3784
|
-
* @param recoveryKey - Encoded recovery key
|
3785
|
-
* @param targetRoomId - Room ID to target a specific room.
|
3786
|
-
* Restores all rooms if omitted.
|
3787
|
-
* @param targetSessionId - Session ID to target a specific session.
|
3788
|
-
* Restores all sessions if omitted.
|
3789
|
-
* @param backupInfo - Backup metadata from `checkKeyBackup`
|
3790
|
-
* @param opts - Optional params such as callbacks
|
3791
|
-
|
3792
|
-
* @returns Status of restoration with `total` and `imported`
|
3793
|
-
* key counts.
|
3794
|
-
*
|
3795
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
3796
|
-
*/
|
3797
|
-
public restoreKeyBackupWithRecoveryKey(
|
3798
|
-
recoveryKey: string,
|
3799
|
-
targetRoomId: undefined,
|
3800
|
-
targetSessionId: undefined,
|
3801
|
-
backupInfo: IKeyBackupInfo,
|
3802
|
-
opts?: IKeyBackupRestoreOpts,
|
3803
|
-
): Promise<IKeyBackupRestoreResult>;
|
3804
|
-
/**
|
3805
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
3806
|
-
*/
|
3807
|
-
public restoreKeyBackupWithRecoveryKey(
|
3808
|
-
recoveryKey: string,
|
3809
|
-
targetRoomId: string,
|
3810
|
-
targetSessionId: undefined,
|
3811
|
-
backupInfo: IKeyBackupInfo,
|
3812
|
-
opts?: IKeyBackupRestoreOpts,
|
3813
|
-
): Promise<IKeyBackupRestoreResult>;
|
3814
|
-
/**
|
3815
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
3816
|
-
*/
|
3817
|
-
public restoreKeyBackupWithRecoveryKey(
|
3818
|
-
recoveryKey: string,
|
3819
|
-
targetRoomId: string,
|
3820
|
-
targetSessionId: string,
|
3821
|
-
backupInfo: IKeyBackupInfo,
|
3822
|
-
opts?: IKeyBackupRestoreOpts,
|
3823
|
-
): Promise<IKeyBackupRestoreResult>;
|
3824
|
-
/**
|
3825
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
3826
|
-
*/
|
3827
|
-
public restoreKeyBackupWithRecoveryKey(
|
3828
|
-
recoveryKey: string,
|
3829
|
-
targetRoomId: string | undefined,
|
3830
|
-
targetSessionId: string | undefined,
|
3831
|
-
backupInfo: IKeyBackupInfo,
|
3832
|
-
opts?: IKeyBackupRestoreOpts,
|
3833
|
-
): Promise<IKeyBackupRestoreResult> {
|
3834
|
-
const privKey = decodeRecoveryKey(recoveryKey);
|
3835
|
-
return this.restoreKeyBackup(privKey, targetRoomId!, targetSessionId!, backupInfo, opts);
|
3836
|
-
}
|
3837
|
-
|
3838
|
-
/**
|
3839
|
-
* Restore from an existing key backup via a private key stored locally
|
3840
|
-
* @param targetRoomId
|
3841
|
-
* @param targetSessionId
|
3842
|
-
* @param backupInfo
|
3843
|
-
* @param opts
|
3844
|
-
*
|
3845
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
3846
|
-
*/
|
3847
|
-
public async restoreKeyBackupWithCache(
|
3848
|
-
targetRoomId: undefined,
|
3849
|
-
targetSessionId: undefined,
|
3850
|
-
backupInfo: IKeyBackupInfo,
|
3851
|
-
opts?: IKeyBackupRestoreOpts,
|
3852
|
-
): Promise<IKeyBackupRestoreResult>;
|
3853
|
-
/**
|
3854
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
3855
|
-
*/
|
3856
|
-
public async restoreKeyBackupWithCache(
|
3857
|
-
targetRoomId: string,
|
3858
|
-
targetSessionId: undefined,
|
3859
|
-
backupInfo: IKeyBackupInfo,
|
3860
|
-
opts?: IKeyBackupRestoreOpts,
|
3861
|
-
): Promise<IKeyBackupRestoreResult>;
|
3862
|
-
/**
|
3863
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
3864
|
-
*/
|
3865
|
-
public async restoreKeyBackupWithCache(
|
3866
|
-
targetRoomId: string,
|
3867
|
-
targetSessionId: string,
|
3868
|
-
backupInfo: IKeyBackupInfo,
|
3869
|
-
opts?: IKeyBackupRestoreOpts,
|
3870
|
-
): Promise<IKeyBackupRestoreResult>;
|
3871
|
-
/**
|
3872
|
-
* @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
|
3873
|
-
*/
|
3874
|
-
public async restoreKeyBackupWithCache(
|
3875
|
-
targetRoomId: string | undefined,
|
3876
|
-
targetSessionId: string | undefined,
|
3877
|
-
backupInfo: IKeyBackupInfo,
|
3878
|
-
opts?: IKeyBackupRestoreOpts,
|
3879
|
-
): Promise<IKeyBackupRestoreResult> {
|
3880
|
-
if (!this.cryptoBackend) {
|
3881
|
-
throw new Error("End-to-end encryption disabled");
|
3882
|
-
}
|
3883
|
-
const privKey = await this.cryptoBackend.getSessionBackupPrivateKey();
|
3884
|
-
if (!privKey) {
|
3885
|
-
throw new Error("Couldn't get key");
|
3886
|
-
}
|
3887
|
-
return this.restoreKeyBackup(privKey, targetRoomId!, targetSessionId!, backupInfo, opts);
|
3888
|
-
}
|
3889
|
-
|
3890
|
-
private async restoreKeyBackup(
|
3891
|
-
privKey: ArrayLike<number>,
|
3892
|
-
targetRoomId: undefined,
|
3893
|
-
targetSessionId: undefined,
|
3894
|
-
backupInfo: IKeyBackupInfo,
|
3895
|
-
opts?: IKeyBackupRestoreOpts,
|
3896
|
-
): Promise<IKeyBackupRestoreResult>;
|
3897
|
-
private async restoreKeyBackup(
|
3898
|
-
privKey: ArrayLike<number>,
|
3899
|
-
targetRoomId: string,
|
3900
|
-
targetSessionId: undefined,
|
3901
|
-
backupInfo: IKeyBackupInfo,
|
3902
|
-
opts?: IKeyBackupRestoreOpts,
|
3903
|
-
): Promise<IKeyBackupRestoreResult>;
|
3904
|
-
private async restoreKeyBackup(
|
3905
|
-
privKey: ArrayLike<number>,
|
3906
|
-
targetRoomId: string,
|
3907
|
-
targetSessionId: string,
|
3908
|
-
backupInfo: IKeyBackupInfo,
|
3909
|
-
opts?: IKeyBackupRestoreOpts,
|
3910
|
-
): Promise<IKeyBackupRestoreResult>;
|
3911
|
-
private async restoreKeyBackup(
|
3912
|
-
privKey: ArrayLike<number>,
|
3913
|
-
targetRoomId: string | undefined,
|
3914
|
-
targetSessionId: string | undefined,
|
3915
|
-
backupInfo: IKeyBackupInfo,
|
3916
|
-
opts?: IKeyBackupRestoreOpts,
|
3917
|
-
): Promise<IKeyBackupRestoreResult> {
|
3918
|
-
const cacheCompleteCallback = opts?.cacheCompleteCallback;
|
3919
|
-
const progressCallback = opts?.progressCallback;
|
3920
|
-
|
3921
|
-
if (!this.cryptoBackend) {
|
3922
|
-
throw new Error("End-to-end encryption disabled");
|
3923
|
-
}
|
3924
|
-
|
3925
|
-
if (!backupInfo.version) {
|
3926
|
-
throw new Error("Backup version must be defined");
|
3927
|
-
}
|
3928
|
-
const backupVersion = backupInfo.version!;
|
3929
|
-
|
3930
|
-
let totalKeyCount = 0;
|
3931
|
-
let totalFailures = 0;
|
3932
|
-
let totalImported = 0;
|
3933
|
-
|
3934
|
-
const path = this.makeKeyBackupPath(targetRoomId, targetSessionId, backupVersion);
|
3935
|
-
|
3936
|
-
const backupDecryptor = await this.cryptoBackend.getBackupDecryptor(backupInfo, privKey);
|
3937
|
-
|
3938
|
-
const untrusted = !backupDecryptor.sourceTrusted;
|
3939
|
-
|
3940
|
-
try {
|
3941
|
-
if (!(privKey instanceof Uint8Array)) {
|
3942
|
-
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
3943
|
-
throw new Error(`restoreKeyBackup expects Uint8Array, got ${privKey}`);
|
3944
|
-
}
|
3945
|
-
// Cache the key, if possible.
|
3946
|
-
// This is async.
|
3947
|
-
this.cryptoBackend
|
3948
|
-
.storeSessionBackupPrivateKey(privKey, backupVersion)
|
3949
|
-
.catch((e) => {
|
3950
|
-
this.logger.warn("Error caching session backup key:", e);
|
3951
|
-
})
|
3952
|
-
.then(cacheCompleteCallback);
|
3953
|
-
|
3954
|
-
if (progressCallback) {
|
3955
|
-
progressCallback({
|
3956
|
-
stage: "fetch",
|
3957
|
-
});
|
3958
|
-
}
|
3959
|
-
|
3960
|
-
const res = await this.http.authedRequest<IRoomsKeysResponse | IRoomKeysResponse | IKeyBackupSession>(
|
3961
|
-
Method.Get,
|
3962
|
-
path.path,
|
3963
|
-
path.queryData,
|
3964
|
-
undefined,
|
3965
|
-
{ prefix: ClientPrefix.V3 },
|
3966
|
-
);
|
3967
|
-
|
3968
|
-
// We have finished fetching the backup, go to next step
|
3969
|
-
if (progressCallback) {
|
3970
|
-
progressCallback({
|
3971
|
-
stage: "load_keys",
|
3972
|
-
});
|
3973
|
-
}
|
3974
|
-
|
3975
|
-
if ((res as IRoomsKeysResponse).rooms) {
|
3976
|
-
// We have a full backup here, it can get quite big, so we need to decrypt and import it in chunks.
|
3977
|
-
|
3978
|
-
// Get the total count as a first pass
|
3979
|
-
totalKeyCount = this.getTotalKeyCount(res as IRoomsKeysResponse);
|
3980
|
-
// Now decrypt and import the keys in chunks
|
3981
|
-
await this.handleDecryptionOfAFullBackup(
|
3982
|
-
res as IRoomsKeysResponse,
|
3983
|
-
backupDecryptor,
|
3984
|
-
200,
|
3985
|
-
async (chunk) => {
|
3986
|
-
// We have a chunk of decrypted keys: import them
|
3987
|
-
try {
|
3988
|
-
const backupVersion = backupInfo.version!;
|
3989
|
-
await this.cryptoBackend!.importBackedUpRoomKeys(chunk, backupVersion, {
|
3990
|
-
untrusted,
|
3991
|
-
});
|
3992
|
-
totalImported += chunk.length;
|
3993
|
-
} catch (e) {
|
3994
|
-
totalFailures += chunk.length;
|
3995
|
-
// We failed to import some keys, but we should still try to import the rest?
|
3996
|
-
// Log the error and continue
|
3997
|
-
logger.error("Error importing keys from backup", e);
|
3998
|
-
}
|
3999
|
-
|
4000
|
-
if (progressCallback) {
|
4001
|
-
progressCallback({
|
4002
|
-
total: totalKeyCount,
|
4003
|
-
successes: totalImported,
|
4004
|
-
stage: "load_keys",
|
4005
|
-
failures: totalFailures,
|
4006
|
-
});
|
4007
|
-
}
|
4008
|
-
},
|
4009
|
-
);
|
4010
|
-
} else if ((res as IRoomKeysResponse).sessions) {
|
4011
|
-
// For now we don't chunk for a single room backup, but we could in the future.
|
4012
|
-
// Currently it is not used by the application.
|
4013
|
-
const sessions = (res as IRoomKeysResponse).sessions;
|
4014
|
-
totalKeyCount = Object.keys(sessions).length;
|
4015
|
-
const keys = await backupDecryptor.decryptSessions(sessions);
|
4016
|
-
for (const k of keys) {
|
4017
|
-
k.room_id = targetRoomId!;
|
4018
|
-
}
|
4019
|
-
await this.cryptoBackend.importBackedUpRoomKeys(keys, backupVersion, {
|
4020
|
-
progressCallback,
|
4021
|
-
untrusted,
|
4022
|
-
});
|
4023
|
-
totalImported = keys.length;
|
4024
|
-
} else {
|
4025
|
-
totalKeyCount = 1;
|
4026
|
-
try {
|
4027
|
-
const [key] = await backupDecryptor.decryptSessions({
|
4028
|
-
[targetSessionId!]: res as IKeyBackupSession,
|
4029
|
-
});
|
4030
|
-
key.room_id = targetRoomId!;
|
4031
|
-
key.session_id = targetSessionId!;
|
4032
|
-
|
4033
|
-
await this.cryptoBackend.importBackedUpRoomKeys([key], backupVersion, {
|
4034
|
-
progressCallback,
|
4035
|
-
untrusted,
|
4036
|
-
});
|
4037
|
-
totalImported = 1;
|
4038
|
-
} catch (e) {
|
4039
|
-
this.logger.debug("Failed to decrypt megolm session from backup", e);
|
4040
|
-
}
|
4041
|
-
}
|
4042
|
-
} finally {
|
4043
|
-
backupDecryptor.free();
|
4044
|
-
}
|
4045
|
-
|
4046
|
-
/// in case entering the passphrase would add a new signature?
|
4047
|
-
await this.cryptoBackend.checkKeyBackupAndEnable();
|
4048
|
-
|
4049
|
-
return { total: totalKeyCount, imported: totalImported };
|
1582
|
+
public async getCapabilities(): Promise<Capabilities> {
|
1583
|
+
const caps = this.serverCapabilitiesService.getCachedCapabilities();
|
1584
|
+
if (caps) return caps;
|
1585
|
+
return this.serverCapabilitiesService.fetchCapabilities();
|
4050
1586
|
}
|
4051
1587
|
|
4052
1588
|
/**
|
4053
|
-
*
|
4054
|
-
*
|
4055
|
-
* @param res - The response from the server containing the keys to be counted.
|
1589
|
+
* Gets the cached capabilities of the homeserver. If none have been fetched yet,
|
1590
|
+
* return undefined.
|
4056
1591
|
*
|
4057
|
-
* @returns The
|
1592
|
+
* @returns The capabilities of the homeserver
|
4058
1593
|
*/
|
4059
|
-
|
4060
|
-
|
4061
|
-
let totalKeyCount = 0;
|
4062
|
-
for (const roomData of Object.values(rooms)) {
|
4063
|
-
if (!roomData.sessions) continue;
|
4064
|
-
totalKeyCount += Object.keys(roomData.sessions).length;
|
4065
|
-
}
|
4066
|
-
return totalKeyCount;
|
1594
|
+
public getCachedCapabilities(): Capabilities | undefined {
|
1595
|
+
return this.serverCapabilitiesService.getCachedCapabilities();
|
4067
1596
|
}
|
4068
1597
|
|
4069
1598
|
/**
|
4070
|
-
*
|
4071
|
-
*
|
4072
|
-
*
|
4073
|
-
* @param res - The response from the server containing the keys to be decrypted.
|
4074
|
-
* @param backupDecryptor - An instance of the BackupDecryptor class used to decrypt the keys.
|
4075
|
-
* @param chunkSize - The size of the chunks to be processed at a time.
|
4076
|
-
* @param block - A callback function that is called for each chunk of keys.
|
1599
|
+
* Fetches the latest capabilities from the homeserver, ignoring any cached
|
1600
|
+
* versions. The newly returned version is cached.
|
4077
1601
|
*
|
4078
|
-
* @returns A promise
|
1602
|
+
* @returns A promise which resolves to the capabilities of the homeserver
|
4079
1603
|
*/
|
4080
|
-
|
4081
|
-
|
4082
|
-
backupDecryptor: BackupDecryptor,
|
4083
|
-
chunkSize: number,
|
4084
|
-
block: (chunk: IMegolmSessionData[]) => Promise<void>,
|
4085
|
-
): Promise<void> {
|
4086
|
-
const rooms = (res as IRoomsKeysResponse).rooms;
|
4087
|
-
|
4088
|
-
let groupChunkCount = 0;
|
4089
|
-
let chunkGroupByRoom: Map<string, IKeyBackupRoomSessions> = new Map();
|
4090
|
-
|
4091
|
-
const handleChunkCallback = async (roomChunks: Map<string, IKeyBackupRoomSessions>): Promise<void> => {
|
4092
|
-
const currentChunk: IMegolmSessionData[] = [];
|
4093
|
-
for (const roomId of roomChunks.keys()) {
|
4094
|
-
const decryptedSessions = await backupDecryptor.decryptSessions(roomChunks.get(roomId)!);
|
4095
|
-
for (const sessionId in decryptedSessions) {
|
4096
|
-
const k = decryptedSessions[sessionId];
|
4097
|
-
k.room_id = roomId;
|
4098
|
-
currentChunk.push(k);
|
4099
|
-
}
|
4100
|
-
}
|
4101
|
-
await block(currentChunk);
|
4102
|
-
};
|
4103
|
-
|
4104
|
-
for (const [roomId, roomData] of Object.entries(rooms)) {
|
4105
|
-
if (!roomData.sessions) continue;
|
4106
|
-
|
4107
|
-
chunkGroupByRoom.set(roomId, {});
|
4108
|
-
|
4109
|
-
for (const [sessionId, session] of Object.entries(roomData.sessions)) {
|
4110
|
-
const sessionsForRoom = chunkGroupByRoom.get(roomId)!;
|
4111
|
-
sessionsForRoom[sessionId] = session;
|
4112
|
-
groupChunkCount += 1;
|
4113
|
-
if (groupChunkCount >= chunkSize) {
|
4114
|
-
// We have enough chunks to decrypt
|
4115
|
-
await handleChunkCallback(chunkGroupByRoom);
|
4116
|
-
chunkGroupByRoom = new Map();
|
4117
|
-
// There might be remaining keys for that room, so add back an entry for the current room.
|
4118
|
-
chunkGroupByRoom.set(roomId, {});
|
4119
|
-
groupChunkCount = 0;
|
4120
|
-
}
|
4121
|
-
}
|
4122
|
-
}
|
4123
|
-
|
4124
|
-
// Handle remaining chunk if needed
|
4125
|
-
if (groupChunkCount > 0) {
|
4126
|
-
await handleChunkCallback(chunkGroupByRoom);
|
4127
|
-
}
|
1604
|
+
public fetchCapabilities(): Promise<Capabilities> {
|
1605
|
+
return this.serverCapabilitiesService.fetchCapabilities();
|
4128
1606
|
}
|
4129
1607
|
|
4130
|
-
|
4131
|
-
|
4132
|
-
|
4133
|
-
public async
|
4134
|
-
|
4135
|
-
await this.http.authedRequest(Method.Delete, path.path, path.queryData, undefined, { prefix: ClientPrefix.V3 });
|
1608
|
+
/**
|
1609
|
+
* @deprecated Does nothing.
|
1610
|
+
*/
|
1611
|
+
public async uploadKeys(): Promise<void> {
|
1612
|
+
this.logger.warn("MatrixClient.uploadKeys is deprecated");
|
4136
1613
|
}
|
4137
1614
|
|
4138
1615
|
/**
|
@@ -4808,18 +2285,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
4808
2285
|
}
|
4809
2286
|
|
4810
2287
|
try {
|
4811
|
-
let cancelled: boolean;
|
4812
2288
|
this.eventsBeingEncrypted.add(event.getId()!);
|
4813
|
-
try {
|
4814
|
-
await this.encryptEventIfNeeded(event, room ?? undefined);
|
4815
|
-
} finally {
|
4816
|
-
cancelled = !this.eventsBeingEncrypted.delete(event.getId()!);
|
4817
|
-
}
|
4818
|
-
|
4819
|
-
if (cancelled) {
|
4820
|
-
// cancelled via MatrixClient::cancelPendingEvent
|
4821
|
-
return {} as ISendEventResponse;
|
4822
|
-
}
|
4823
2289
|
|
4824
2290
|
// encryptEventIfNeeded may have updated the status from SENDING to ENCRYPTING. If so, we need
|
4825
2291
|
// to put it back.
|
@@ -4870,70 +2336,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
4870
2336
|
}
|
4871
2337
|
}
|
4872
2338
|
|
4873
|
-
private async encryptEventIfNeeded(event: MatrixEvent, room?: Room): Promise<void> {
|
4874
|
-
// If the room is unknown, we cannot encrypt for it
|
4875
|
-
if (!room) return;
|
4876
|
-
|
4877
|
-
if (!(await this.shouldEncryptEventForRoom(event, room))) return;
|
4878
|
-
|
4879
|
-
if (!this.cryptoBackend && this.usingExternalCrypto) {
|
4880
|
-
// The client has opted to allow sending messages to encrypted
|
4881
|
-
// rooms even if the room is encrypted, and we haven't set up
|
4882
|
-
// crypto. This is useful for users of matrix-org/pantalaimon
|
4883
|
-
return;
|
4884
|
-
}
|
4885
|
-
|
4886
|
-
if (!this.cryptoBackend) {
|
4887
|
-
throw new Error("This room is configured to use encryption, but your client does not support encryption.");
|
4888
|
-
}
|
4889
|
-
|
4890
|
-
this.updatePendingEventStatus(room, event, EventStatus.ENCRYPTING);
|
4891
|
-
await this.cryptoBackend.encryptEvent(event, room);
|
4892
|
-
}
|
4893
|
-
|
4894
|
-
/**
|
4895
|
-
* Determine whether a given event should be encrypted when we send it to the given room.
|
4896
|
-
*
|
4897
|
-
* This takes into account event type and room configuration.
|
4898
|
-
*/
|
4899
|
-
private async shouldEncryptEventForRoom(event: MatrixEvent, room: Room): Promise<boolean> {
|
4900
|
-
if (event.isEncrypted()) {
|
4901
|
-
// this event has already been encrypted; this happens if the
|
4902
|
-
// encryption step succeeded, but the send step failed on the first
|
4903
|
-
// attempt.
|
4904
|
-
return false;
|
4905
|
-
}
|
4906
|
-
|
4907
|
-
if (event.getType() === EventType.Reaction) {
|
4908
|
-
// For reactions, there is a very little gained by encrypting the entire
|
4909
|
-
// event, as relation data is already kept in the clear. Event
|
4910
|
-
// encryption for a reaction effectively only obscures the event type,
|
4911
|
-
// but the purpose is still obvious from the relation data, so nothing
|
4912
|
-
// is really gained. It also causes quite a few problems, such as:
|
4913
|
-
// * triggers notifications via default push rules
|
4914
|
-
// * prevents server-side bundling for reactions
|
4915
|
-
// The reaction key / content / emoji value does warrant encrypting, but
|
4916
|
-
// this will be handled separately by encrypting just this value.
|
4917
|
-
// See https://github.com/matrix-org/matrix-doc/pull/1849#pullrequestreview-248763642
|
4918
|
-
return false;
|
4919
|
-
}
|
4920
|
-
|
4921
|
-
if (event.isRedaction()) {
|
4922
|
-
// Redactions do not support encryption in the spec at this time.
|
4923
|
-
// Whilst it mostly worked in some clients, it wasn't compliant.
|
4924
|
-
return false;
|
4925
|
-
}
|
4926
|
-
|
4927
|
-
// If the room has an m.room.encryption event, we should encrypt.
|
4928
|
-
if (room.hasEncryptionStateEvent()) return true;
|
4929
|
-
|
4930
|
-
// If we have a crypto impl, and *it* thinks we should encrypt, then we should.
|
4931
|
-
if (await this.cryptoBackend?.isEncryptionEnabledInRoom(room.roomId)) return true;
|
4932
|
-
|
4933
|
-
// Otherwise, no need to encrypt.
|
4934
|
-
return false;
|
4935
|
-
}
|
4936
|
-
|
4937
2339
|
/**
|
4938
2340
|
* Returns the eventType that should be used taking encryption into account
|
4939
2341
|
* for a given eventType.
|
@@ -7484,25 +4886,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
7484
4886
|
return this.http.authedRequest(Method.Post, path, undefined, {});
|
7485
4887
|
}
|
7486
4888
|
|
7487
|
-
private startCallEventHandler = (): void => {
|
7488
|
-
if (this.isInitialSyncComplete()) {
|
7489
|
-
if (supportsMatrixCall()) {
|
7490
|
-
this.callEventHandler!.start();
|
7491
|
-
this.groupCallEventHandler!.start();
|
7492
|
-
}
|
7493
|
-
|
7494
|
-
this.off(ClientEvent.Sync, this.startCallEventHandler);
|
7495
|
-
}
|
7496
|
-
};
|
7497
|
-
|
7498
|
-
private startMatrixRTC = (): void => {
|
7499
|
-
if (this.isInitialSyncComplete()) {
|
7500
|
-
this.matrixRTC.start();
|
7501
|
-
|
7502
|
-
this.off(ClientEvent.Sync, this.startMatrixRTC);
|
7503
|
-
}
|
7504
|
-
};
|
7505
|
-
|
7506
4889
|
/**
|
7507
4890
|
* Once the client has been initialised, we want to clear notifications we
|
7508
4891
|
* know for a fact should be here.
|
@@ -7528,84 +4911,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
7528
4911
|
}
|
7529
4912
|
};
|
7530
4913
|
|
7531
|
-
/**
|
7532
|
-
* @returns Promise which resolves: ITurnServerResponse object
|
7533
|
-
* @returns Rejects: with an error response.
|
7534
|
-
*/
|
7535
|
-
public turnServer(): Promise<ITurnServerResponse> {
|
7536
|
-
return this.http.authedRequest(Method.Get, "/voip/turnServer");
|
7537
|
-
}
|
7538
|
-
|
7539
|
-
/**
|
7540
|
-
* Get the TURN servers for this homeserver.
|
7541
|
-
* @returns The servers or an empty list.
|
7542
|
-
*/
|
7543
|
-
public getTurnServers(): ITurnServer[] {
|
7544
|
-
return this.turnServers || [];
|
7545
|
-
}
|
7546
|
-
|
7547
|
-
/**
|
7548
|
-
* Get the unix timestamp (in milliseconds) at which the current
|
7549
|
-
* TURN credentials (from getTurnServers) expire
|
7550
|
-
* @returns The expiry timestamp in milliseconds
|
7551
|
-
*/
|
7552
|
-
public getTurnServersExpiry(): number {
|
7553
|
-
return this.turnServersExpiry;
|
7554
|
-
}
|
7555
|
-
|
7556
|
-
public get pollingTurnServers(): boolean {
|
7557
|
-
return this.checkTurnServersIntervalID !== undefined;
|
7558
|
-
}
|
7559
|
-
|
7560
|
-
// XXX: Intended private, used in code.
|
7561
|
-
public async checkTurnServers(): Promise<boolean | undefined> {
|
7562
|
-
if (!this.canSupportVoip) {
|
7563
|
-
return;
|
7564
|
-
}
|
7565
|
-
|
7566
|
-
let credentialsGood = false;
|
7567
|
-
const remainingTime = this.turnServersExpiry - Date.now();
|
7568
|
-
if (remainingTime > TURN_CHECK_INTERVAL) {
|
7569
|
-
this.logger.debug("TURN creds are valid for another " + remainingTime + " ms: not fetching new ones.");
|
7570
|
-
credentialsGood = true;
|
7571
|
-
} else {
|
7572
|
-
this.logger.debug("Fetching new TURN credentials");
|
7573
|
-
try {
|
7574
|
-
const res = await this.turnServer();
|
7575
|
-
if (res.uris) {
|
7576
|
-
this.logger.debug("Got TURN URIs: " + res.uris + " refresh in " + res.ttl + " secs");
|
7577
|
-
// map the response to a format that can be fed to RTCPeerConnection
|
7578
|
-
const servers: ITurnServer = {
|
7579
|
-
urls: res.uris,
|
7580
|
-
username: res.username,
|
7581
|
-
credential: res.password,
|
7582
|
-
};
|
7583
|
-
this.turnServers = [servers];
|
7584
|
-
// The TTL is in seconds but we work in ms
|
7585
|
-
this.turnServersExpiry = Date.now() + res.ttl * 1000;
|
7586
|
-
credentialsGood = true;
|
7587
|
-
this.emit(ClientEvent.TurnServers, this.turnServers);
|
7588
|
-
}
|
7589
|
-
} catch (err) {
|
7590
|
-
this.logger.error("Failed to get TURN URIs", err);
|
7591
|
-
if ((<HTTPError>err).httpStatus === 403) {
|
7592
|
-
// We got a 403, so there's no point in looping forever.
|
7593
|
-
this.logger.info("TURN access unavailable for this account: stopping credentials checks");
|
7594
|
-
if (this.checkTurnServersIntervalID !== null) {
|
7595
|
-
globalThis.clearInterval(this.checkTurnServersIntervalID);
|
7596
|
-
}
|
7597
|
-
this.checkTurnServersIntervalID = undefined;
|
7598
|
-
this.emit(ClientEvent.TurnServersError, <HTTPError>err, true); // fatal
|
7599
|
-
} else {
|
7600
|
-
// otherwise, if we failed for whatever reason, try again the next time we're called.
|
7601
|
-
this.emit(ClientEvent.TurnServersError, <Error>err, false); // non-fatal
|
7602
|
-
}
|
7603
|
-
}
|
7604
|
-
}
|
7605
|
-
|
7606
|
-
return credentialsGood;
|
7607
|
-
}
|
7608
|
-
|
7609
4914
|
/**
|
7610
4915
|
* Set whether to allow a fallback ICE server should be used for negotiating a
|
7611
4916
|
* WebRTC connection if the homeserver doesn't provide any servers. Defaults to
|
@@ -7947,8 +5252,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
7947
5252
|
let events = result.chunk.map(mapper);
|
7948
5253
|
|
7949
5254
|
if (fetchedEventType === EventType.RoomMessageEncrypted) {
|
7950
|
-
const allEvents = originalEvent ? events.concat(originalEvent) : events;
|
7951
|
-
await Promise.all(allEvents.map((e) => this.decryptEventIfNeeded(e)));
|
7952
5255
|
if (eventType !== null) {
|
7953
5256
|
events = events.filter((e) => e.getType() === eventType);
|
7954
5257
|
}
|
@@ -7965,17 +5268,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
7965
5268
|
};
|
7966
5269
|
}
|
7967
5270
|
|
7968
|
-
/**
|
7969
|
-
* The app may wish to see if we have a key cached without
|
7970
|
-
* triggering a user interaction.
|
7971
|
-
*
|
7972
|
-
* @deprecated Not supported for Rust Cryptography.
|
7973
|
-
*/
|
7974
|
-
public getCrossSigningCacheCallbacks(): ICacheCallbacks | undefined {
|
7975
|
-
// XXX: Private member access
|
7976
|
-
return this.crypto?.crossSigningInfo.getCacheCallbacks();
|
7977
|
-
}
|
7978
|
-
|
7979
5271
|
/**
|
7980
5272
|
* Generates a random string suitable for use as a client secret. <strong>This
|
7981
5273
|
* method is experimental and may change.</strong>
|
@@ -7991,15 +5283,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
7991
5283
|
* @returns A decryption promise
|
7992
5284
|
*/
|
7993
5285
|
public decryptEventIfNeeded(event: MatrixEvent, options?: IDecryptOptions): Promise<void> {
|
7994
|
-
|
7995
|
-
event.attemptDecryption(this.cryptoBackend!, options);
|
7996
|
-
}
|
7997
|
-
|
7998
|
-
if (event.isBeingDecrypted()) {
|
7999
|
-
return event.getDecryptionPromise()!;
|
8000
|
-
} else {
|
8001
|
-
return Promise.resolve();
|
8002
|
-
}
|
5286
|
+
return Promise.resolve();
|
8003
5287
|
}
|
8004
5288
|
|
8005
5289
|
private termsUrlForService(serviceType: SERVICE_TYPES, baseUrl: string): URL {
|
@@ -8312,17 +5596,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
8312
5596
|
* @returns Promise which resolves: On success, the empty object `{}`
|
8313
5597
|
*/
|
8314
5598
|
public async logout(stopClient = false): Promise<{}> {
|
8315
|
-
if (this.crypto?.backupManager?.getKeyBackupEnabled()) {
|
8316
|
-
try {
|
8317
|
-
while ((await this.crypto.backupManager.backupPendingKeys(200)) > 0);
|
8318
|
-
} catch (err) {
|
8319
|
-
this.logger.error(
|
8320
|
-
"Key backup request failed when logging out. Some keys may be missing from backup",
|
8321
|
-
err,
|
8322
|
-
);
|
8323
|
-
}
|
8324
|
-
}
|
8325
|
-
|
8326
5599
|
if (stopClient) {
|
8327
5600
|
this.stopClient();
|
8328
5601
|
this.http.abort();
|
@@ -9367,87 +6640,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
9367
6640
|
return this.http.authedRequest(Method.Post, "/search", queryParams, body, { abortSignal });
|
9368
6641
|
}
|
9369
6642
|
|
9370
|
-
/**
|
9371
|
-
* Upload keys
|
9372
|
-
*
|
9373
|
-
* @param content - body of upload request
|
9374
|
-
*
|
9375
|
-
* @param opts - this method no longer takes any opts,
|
9376
|
-
* used to take opts.device_id but this was not removed from the spec as a redundant parameter
|
9377
|
-
*
|
9378
|
-
* @returns Promise which resolves: result object. Rejects: with
|
9379
|
-
* an error response ({@link MatrixError}).
|
9380
|
-
*/
|
9381
|
-
public uploadKeysRequest(content: IUploadKeysRequest, opts?: void): Promise<IKeysUploadResponse> {
|
9382
|
-
return this.http.authedRequest(Method.Post, "/keys/upload", undefined, content);
|
9383
|
-
}
|
9384
|
-
|
9385
|
-
public uploadKeySignatures(content: KeySignatures): Promise<IUploadKeySignaturesResponse> {
|
9386
|
-
return this.http.authedRequest(Method.Post, "/keys/signatures/upload", undefined, content);
|
9387
|
-
}
|
9388
|
-
|
9389
|
-
/**
|
9390
|
-
* Download device keys
|
9391
|
-
*
|
9392
|
-
* @param userIds - list of users to get keys for
|
9393
|
-
*
|
9394
|
-
* @param token - sync token to pass in the query request, to help
|
9395
|
-
* the HS give the most recent results
|
9396
|
-
*
|
9397
|
-
* @returns Promise which resolves: result object. Rejects: with
|
9398
|
-
* an error response ({@link MatrixError}).
|
9399
|
-
*/
|
9400
|
-
public downloadKeysForUsers(userIds: string[], { token }: { token?: string } = {}): Promise<IDownloadKeyResult> {
|
9401
|
-
const content: IQueryKeysRequest = {
|
9402
|
-
device_keys: {},
|
9403
|
-
};
|
9404
|
-
if (token !== undefined) {
|
9405
|
-
content.token = token;
|
9406
|
-
}
|
9407
|
-
userIds.forEach((u) => {
|
9408
|
-
content.device_keys[u] = [];
|
9409
|
-
});
|
9410
|
-
|
9411
|
-
return this.http.authedRequest(Method.Post, "/keys/query", undefined, content);
|
9412
|
-
}
|
9413
|
-
|
9414
|
-
/**
|
9415
|
-
* Claim one-time keys
|
9416
|
-
*
|
9417
|
-
* @param devices - a list of [userId, deviceId] pairs
|
9418
|
-
*
|
9419
|
-
* @param keyAlgorithm - desired key type
|
9420
|
-
*
|
9421
|
-
* @param timeout - the time (in milliseconds) to wait for keys from remote
|
9422
|
-
* servers
|
9423
|
-
*
|
9424
|
-
* @returns Promise which resolves: result object. Rejects: with
|
9425
|
-
* an error response ({@link MatrixError}).
|
9426
|
-
*/
|
9427
|
-
public claimOneTimeKeys(
|
9428
|
-
devices: [string, string][],
|
9429
|
-
keyAlgorithm = "signed_curve25519",
|
9430
|
-
timeout?: number,
|
9431
|
-
): Promise<IClaimOTKsResult> {
|
9432
|
-
const queries: Record<string, Record<string, string>> = {};
|
9433
|
-
|
9434
|
-
if (keyAlgorithm === undefined) {
|
9435
|
-
keyAlgorithm = "signed_curve25519";
|
9436
|
-
}
|
9437
|
-
|
9438
|
-
for (const [userId, deviceId] of devices) {
|
9439
|
-
const query = queries[userId] || {};
|
9440
|
-
safeSet(queries, userId, query);
|
9441
|
-
safeSet(query, deviceId, keyAlgorithm);
|
9442
|
-
}
|
9443
|
-
const content: IClaimKeysRequest = { one_time_keys: queries };
|
9444
|
-
if (timeout) {
|
9445
|
-
content.timeout = timeout;
|
9446
|
-
}
|
9447
|
-
const path = "/keys/claim";
|
9448
|
-
return this.http.authedRequest(Method.Post, path, undefined, content);
|
9449
|
-
}
|
9450
|
-
|
9451
6643
|
/**
|
9452
6644
|
* Ask the server for a list of users who have changed their device lists
|
9453
6645
|
* between a pair of sync tokens
|
@@ -9465,15 +6657,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
9465
6657
|
return this.http.authedRequest(Method.Get, "/keys/changes", qps);
|
9466
6658
|
}
|
9467
6659
|
|
9468
|
-
public uploadDeviceSigningKeys(auth?: AuthDict, keys?: CrossSigningKeys): Promise<{}> {
|
9469
|
-
// API returns empty object
|
9470
|
-
const data = Object.assign({}, keys);
|
9471
|
-
if (auth) Object.assign(data, { auth });
|
9472
|
-
return this.http.authedRequest(Method.Post, "/keys/device_signing/upload", undefined, data, {
|
9473
|
-
prefix: ClientPrefix.Unstable,
|
9474
|
-
});
|
9475
|
-
}
|
9476
|
-
|
9477
6660
|
/**
|
9478
6661
|
* Register with an identity server using the OpenID token from the user's
|
9479
6662
|
* Homeserver, which can be retrieved via
|
@@ -10102,13 +7285,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|
10102
7285
|
[UNSTABLE_MSC3088_ENABLED.name]: true,
|
10103
7286
|
},
|
10104
7287
|
},
|
10105
|
-
{
|
10106
|
-
type: EventType.RoomEncryption,
|
10107
|
-
state_key: "",
|
10108
|
-
content: {
|
10109
|
-
algorithm: olmlib.MEGOLM_ALGORITHM,
|
10110
|
-
},
|
10111
|
-
},
|
10112
7288
|
],
|
10113
7289
|
});
|
10114
7290
|
return new MSC3089TreeSpace(this, roomId);
|