@unwanted/matrix-sdk-mini 34.12.0-2 → 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/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 -1176
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +346 -2717
- package/lib/client.js.map +1 -1
- package/lib/embedded.d.ts +0 -22
- package/lib/embedded.d.ts.map +1 -1
- package/lib/embedded.js +24 -166
- package/lib/embedded.js.map +1 -1
- package/lib/event-mapper.d.ts.map +1 -1
- package/lib/event-mapper.js +0 -4
- package/lib/event-mapper.js.map +1 -1
- package/lib/matrix.d.ts +0 -19
- package/lib/matrix.d.ts.map +1 -1
- package/lib/matrix.js +1 -26
- package/lib/matrix.js.map +1 -1
- package/lib/models/MSC3089Branch.d.ts.map +1 -1
- package/lib/models/MSC3089Branch.js +0 -3
- package/lib/models/MSC3089Branch.js.map +1 -1
- package/lib/models/event.d.ts +0 -94
- package/lib/models/event.d.ts.map +1 -1
- package/lib/models/event.js +0 -274
- package/lib/models/event.js.map +1 -1
- package/lib/models/poll.d.ts.map +1 -1
- package/lib/models/poll.js +1 -5
- package/lib/models/poll.js.map +1 -1
- package/lib/models/relations-container.d.ts.map +1 -1
- package/lib/models/relations-container.js +1 -7
- package/lib/models/relations-container.js.map +1 -1
- package/lib/models/relations.d.ts +0 -1
- package/lib/models/relations.d.ts.map +1 -1
- package/lib/models/relations.js +0 -8
- package/lib/models/relations.js.map +1 -1
- package/lib/models/room-state.d.ts.map +1 -1
- package/lib/models/room-state.js +10 -26
- package/lib/models/room-state.js.map +1 -1
- package/lib/models/room.d.ts +0 -18
- package/lib/models/room.d.ts.map +1 -1
- package/lib/models/room.js +94 -148
- package/lib/models/room.js.map +1 -1
- package/lib/models/thread.d.ts.map +1 -1
- package/lib/models/thread.js +0 -1
- package/lib/models/thread.js.map +1 -1
- package/lib/sliding-sync-sdk.d.ts +2 -3
- package/lib/sliding-sync-sdk.d.ts.map +1 -1
- package/lib/sliding-sync-sdk.js +41 -90
- package/lib/sliding-sync-sdk.js.map +1 -1
- package/lib/sync.d.ts +0 -12
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +1 -73
- package/lib/sync.js.map +1 -1
- package/lib/testing.d.ts +0 -48
- package/lib/testing.d.ts.map +1 -1
- package/lib/testing.js +0 -105
- package/lib/testing.js.map +1 -1
- package/package.json +1 -3
- package/src/@types/global.d.ts +0 -3
- package/src/browser-index.ts +0 -11
- package/src/client.ts +57 -2732
- package/src/embedded.ts +3 -130
- package/src/event-mapper.ts +0 -4
- package/src/matrix.ts +0 -28
- package/src/models/MSC3089Branch.ts +0 -3
- package/src/models/event.ts +0 -289
- package/src/models/poll.ts +0 -6
- package/src/models/relations-container.ts +1 -8
- package/src/models/relations.ts +0 -8
- package/src/models/room-state.ts +2 -8
- package/src/models/room.ts +0 -62
- package/src/models/thread.ts +0 -1
- package/src/sliding-sync-sdk.ts +2 -72
- package/src/sync.ts +1 -98
- package/src/testing.ts +0 -108
- package/lib/@types/crypto.d.ts +0 -47
- package/lib/@types/crypto.d.ts.map +0 -1
- package/lib/@types/crypto.js +0 -1
- package/lib/@types/crypto.js.map +0 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js +0 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js.map +0 -1
- package/lib/common-crypto/CryptoBackend.d.ts +0 -240
- package/lib/common-crypto/CryptoBackend.d.ts.map +0 -1
- package/lib/common-crypto/CryptoBackend.js +0 -73
- package/lib/common-crypto/CryptoBackend.js.map +0 -1
- package/lib/common-crypto/key-passphrase.d.ts +0 -14
- package/lib/common-crypto/key-passphrase.d.ts.map +0 -1
- package/lib/common-crypto/key-passphrase.js +0 -33
- package/lib/common-crypto/key-passphrase.js.map +0 -1
- package/lib/crypto/CrossSigning.d.ts +0 -184
- package/lib/crypto/CrossSigning.d.ts.map +0 -1
- package/lib/crypto/CrossSigning.js +0 -718
- package/lib/crypto/CrossSigning.js.map +0 -1
- package/lib/crypto/DeviceList.d.ts +0 -216
- package/lib/crypto/DeviceList.d.ts.map +0 -1
- package/lib/crypto/DeviceList.js +0 -892
- package/lib/crypto/DeviceList.js.map +0 -1
- package/lib/crypto/EncryptionSetup.d.ts +0 -152
- package/lib/crypto/EncryptionSetup.d.ts.map +0 -1
- package/lib/crypto/EncryptionSetup.js +0 -356
- package/lib/crypto/EncryptionSetup.js.map +0 -1
- package/lib/crypto/OlmDevice.d.ts +0 -457
- package/lib/crypto/OlmDevice.d.ts.map +0 -1
- package/lib/crypto/OlmDevice.js +0 -1241
- package/lib/crypto/OlmDevice.js.map +0 -1
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts +0 -109
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts.map +0 -1
- package/lib/crypto/OutgoingRoomKeyRequestManager.js +0 -415
- package/lib/crypto/OutgoingRoomKeyRequestManager.js.map +0 -1
- package/lib/crypto/RoomList.d.ts +0 -26
- package/lib/crypto/RoomList.d.ts.map +0 -1
- package/lib/crypto/RoomList.js +0 -71
- package/lib/crypto/RoomList.js.map +0 -1
- package/lib/crypto/SecretSharing.d.ts +0 -24
- package/lib/crypto/SecretSharing.d.ts.map +0 -1
- package/lib/crypto/SecretSharing.js +0 -194
- package/lib/crypto/SecretSharing.js.map +0 -1
- package/lib/crypto/SecretStorage.d.ts +0 -55
- package/lib/crypto/SecretStorage.d.ts.map +0 -1
- package/lib/crypto/SecretStorage.js +0 -118
- package/lib/crypto/SecretStorage.js.map +0 -1
- package/lib/crypto/aes.d.ts +0 -6
- package/lib/crypto/aes.d.ts.map +0 -1
- package/lib/crypto/aes.js +0 -24
- package/lib/crypto/aes.js.map +0 -1
- package/lib/crypto/algorithms/base.d.ts +0 -156
- package/lib/crypto/algorithms/base.d.ts.map +0 -1
- package/lib/crypto/algorithms/base.js +0 -187
- package/lib/crypto/algorithms/base.js.map +0 -1
- package/lib/crypto/algorithms/index.d.ts +0 -4
- package/lib/crypto/algorithms/index.d.ts.map +0 -1
- package/lib/crypto/algorithms/index.js +0 -20
- package/lib/crypto/algorithms/index.js.map +0 -1
- package/lib/crypto/algorithms/megolm.d.ts +0 -385
- package/lib/crypto/algorithms/megolm.d.ts.map +0 -1
- package/lib/crypto/algorithms/megolm.js +0 -1822
- package/lib/crypto/algorithms/megolm.js.map +0 -1
- package/lib/crypto/algorithms/olm.d.ts +0 -5
- package/lib/crypto/algorithms/olm.d.ts.map +0 -1
- package/lib/crypto/algorithms/olm.js +0 -299
- package/lib/crypto/algorithms/olm.js.map +0 -1
- package/lib/crypto/api.d.ts +0 -32
- package/lib/crypto/api.d.ts.map +0 -1
- package/lib/crypto/api.js +0 -22
- package/lib/crypto/api.js.map +0 -1
- package/lib/crypto/backup.d.ts +0 -227
- package/lib/crypto/backup.d.ts.map +0 -1
- package/lib/crypto/backup.js +0 -824
- package/lib/crypto/backup.js.map +0 -1
- package/lib/crypto/crypto.d.ts +0 -3
- package/lib/crypto/crypto.d.ts.map +0 -1
- package/lib/crypto/crypto.js +0 -19
- package/lib/crypto/crypto.js.map +0 -1
- package/lib/crypto/dehydration.d.ts +0 -34
- package/lib/crypto/dehydration.d.ts.map +0 -1
- package/lib/crypto/dehydration.js +0 -252
- package/lib/crypto/dehydration.js.map +0 -1
- package/lib/crypto/device-converter.d.ts +0 -9
- package/lib/crypto/device-converter.d.ts.map +0 -1
- package/lib/crypto/device-converter.js +0 -42
- package/lib/crypto/device-converter.js.map +0 -1
- package/lib/crypto/deviceinfo.d.ts +0 -99
- package/lib/crypto/deviceinfo.d.ts.map +0 -1
- package/lib/crypto/deviceinfo.js +0 -148
- package/lib/crypto/deviceinfo.js.map +0 -1
- package/lib/crypto/index.d.ts +0 -1209
- package/lib/crypto/index.d.ts.map +0 -1
- package/lib/crypto/index.js +0 -4097
- package/lib/crypto/index.js.map +0 -1
- package/lib/crypto/key_passphrase.d.ts +0 -14
- package/lib/crypto/key_passphrase.d.ts.map +0 -1
- package/lib/crypto/key_passphrase.js +0 -44
- package/lib/crypto/key_passphrase.js.map +0 -1
- package/lib/crypto/keybackup.d.ts +0 -18
- package/lib/crypto/keybackup.d.ts.map +0 -1
- package/lib/crypto/keybackup.js +0 -1
- package/lib/crypto/keybackup.js.map +0 -1
- package/lib/crypto/olmlib.d.ts +0 -129
- package/lib/crypto/olmlib.d.ts.map +0 -1
- package/lib/crypto/olmlib.js +0 -492
- package/lib/crypto/olmlib.js.map +0 -1
- package/lib/crypto/recoverykey.d.ts +0 -2
- package/lib/crypto/recoverykey.d.ts.map +0 -1
- package/lib/crypto/recoverykey.js +0 -19
- package/lib/crypto/recoverykey.js.map +0 -1
- package/lib/crypto/store/base.d.ts +0 -252
- package/lib/crypto/store/base.d.ts.map +0 -1
- package/lib/crypto/store/base.js +0 -64
- package/lib/crypto/store/base.js.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts +0 -187
- package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.js +0 -1145
- package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store.d.ts +0 -432
- package/lib/crypto/store/indexeddb-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store.js +0 -728
- package/lib/crypto/store/indexeddb-crypto-store.js.map +0 -1
- package/lib/crypto/store/localStorage-crypto-store.d.ts +0 -119
- package/lib/crypto/store/localStorage-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/localStorage-crypto-store.js +0 -531
- package/lib/crypto/store/localStorage-crypto-store.js.map +0 -1
- package/lib/crypto/store/memory-crypto-store.d.ts +0 -215
- package/lib/crypto/store/memory-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/memory-crypto-store.js +0 -622
- package/lib/crypto/store/memory-crypto-store.js.map +0 -1
- package/lib/crypto/verification/Base.d.ts +0 -105
- package/lib/crypto/verification/Base.d.ts.map +0 -1
- package/lib/crypto/verification/Base.js +0 -372
- package/lib/crypto/verification/Base.js.map +0 -1
- package/lib/crypto/verification/Error.d.ts +0 -35
- package/lib/crypto/verification/Error.d.ts.map +0 -1
- package/lib/crypto/verification/Error.js +0 -86
- package/lib/crypto/verification/Error.js.map +0 -1
- package/lib/crypto/verification/IllegalMethod.d.ts +0 -15
- package/lib/crypto/verification/IllegalMethod.d.ts.map +0 -1
- package/lib/crypto/verification/IllegalMethod.js +0 -43
- package/lib/crypto/verification/IllegalMethod.js.map +0 -1
- package/lib/crypto/verification/QRCode.d.ts +0 -51
- package/lib/crypto/verification/QRCode.d.ts.map +0 -1
- package/lib/crypto/verification/QRCode.js +0 -277
- package/lib/crypto/verification/QRCode.js.map +0 -1
- package/lib/crypto/verification/SAS.d.ts +0 -27
- package/lib/crypto/verification/SAS.d.ts.map +0 -1
- package/lib/crypto/verification/SAS.js +0 -485
- package/lib/crypto/verification/SAS.js.map +0 -1
- package/lib/crypto/verification/SASDecimal.d.ts +0 -8
- package/lib/crypto/verification/SASDecimal.d.ts.map +0 -1
- package/lib/crypto/verification/SASDecimal.js +0 -34
- package/lib/crypto/verification/SASDecimal.js.map +0 -1
- package/lib/crypto/verification/request/Channel.d.ts +0 -18
- package/lib/crypto/verification/request/Channel.d.ts.map +0 -1
- package/lib/crypto/verification/request/Channel.js +0 -1
- package/lib/crypto/verification/request/Channel.js.map +0 -1
- package/lib/crypto/verification/request/InRoomChannel.d.ts +0 -113
- package/lib/crypto/verification/request/InRoomChannel.d.ts.map +0 -1
- package/lib/crypto/verification/request/InRoomChannel.js +0 -351
- package/lib/crypto/verification/request/InRoomChannel.js.map +0 -1
- package/lib/crypto/verification/request/ToDeviceChannel.d.ts +0 -105
- package/lib/crypto/verification/request/ToDeviceChannel.d.ts.map +0 -1
- package/lib/crypto/verification/request/ToDeviceChannel.js +0 -328
- package/lib/crypto/verification/request/ToDeviceChannel.js.map +0 -1
- package/lib/crypto/verification/request/VerificationRequest.d.ts +0 -227
- package/lib/crypto/verification/request/VerificationRequest.d.ts.map +0 -1
- package/lib/crypto/verification/request/VerificationRequest.js +0 -937
- package/lib/crypto/verification/request/VerificationRequest.js.map +0 -1
- package/lib/crypto-api/CryptoEvent.d.ts +0 -69
- package/lib/crypto-api/CryptoEvent.d.ts.map +0 -1
- package/lib/crypto-api/CryptoEvent.js +0 -33
- package/lib/crypto-api/CryptoEvent.js.map +0 -1
- package/lib/crypto-api/CryptoEventHandlerMap.d.ts +0 -16
- package/lib/crypto-api/CryptoEventHandlerMap.d.ts.map +0 -1
- package/lib/crypto-api/CryptoEventHandlerMap.js +0 -22
- package/lib/crypto-api/CryptoEventHandlerMap.js.map +0 -1
- package/lib/crypto-api/index.d.ts +0 -978
- package/lib/crypto-api/index.d.ts.map +0 -1
- package/lib/crypto-api/index.js +0 -304
- package/lib/crypto-api/index.js.map +0 -1
- package/lib/crypto-api/key-passphrase.d.ts +0 -11
- package/lib/crypto-api/key-passphrase.d.ts.map +0 -1
- package/lib/crypto-api/key-passphrase.js +0 -51
- package/lib/crypto-api/key-passphrase.js.map +0 -1
- package/lib/crypto-api/keybackup.d.ts +0 -88
- package/lib/crypto-api/keybackup.d.ts.map +0 -1
- package/lib/crypto-api/keybackup.js +0 -1
- package/lib/crypto-api/keybackup.js.map +0 -1
- package/lib/crypto-api/recovery-key.d.ts +0 -11
- package/lib/crypto-api/recovery-key.d.ts.map +0 -1
- package/lib/crypto-api/recovery-key.js +0 -65
- package/lib/crypto-api/recovery-key.js.map +0 -1
- package/lib/crypto-api/verification.d.ts +0 -344
- package/lib/crypto-api/verification.d.ts.map +0 -1
- package/lib/crypto-api/verification.js +0 -91
- package/lib/crypto-api/verification.js.map +0 -1
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts +0 -112
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts.map +0 -1
- package/lib/rendezvous/MSC4108SignInWithQR.js +0 -392
- package/lib/rendezvous/MSC4108SignInWithQR.js.map +0 -1
- package/lib/rendezvous/RendezvousChannel.d.ts +0 -27
- package/lib/rendezvous/RendezvousChannel.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousChannel.js +0 -1
- package/lib/rendezvous/RendezvousChannel.js.map +0 -1
- package/lib/rendezvous/RendezvousCode.d.ts +0 -9
- package/lib/rendezvous/RendezvousCode.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousCode.js +0 -1
- package/lib/rendezvous/RendezvousCode.js.map +0 -1
- package/lib/rendezvous/RendezvousError.d.ts +0 -6
- package/lib/rendezvous/RendezvousError.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousError.js +0 -23
- package/lib/rendezvous/RendezvousError.js.map +0 -1
- package/lib/rendezvous/RendezvousFailureReason.d.ts +0 -31
- package/lib/rendezvous/RendezvousFailureReason.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousFailureReason.js +0 -38
- package/lib/rendezvous/RendezvousFailureReason.js.map +0 -1
- package/lib/rendezvous/RendezvousIntent.d.ts +0 -5
- package/lib/rendezvous/RendezvousIntent.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousIntent.js +0 -22
- package/lib/rendezvous/RendezvousIntent.js.map +0 -1
- package/lib/rendezvous/RendezvousTransport.d.ts +0 -36
- package/lib/rendezvous/RendezvousTransport.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousTransport.js +0 -1
- package/lib/rendezvous/RendezvousTransport.js.map +0 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts +0 -58
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts.map +0 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.js +0 -246
- package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +0 -1
- package/lib/rendezvous/channels/index.d.ts +0 -2
- package/lib/rendezvous/channels/index.d.ts.map +0 -1
- package/lib/rendezvous/channels/index.js +0 -18
- package/lib/rendezvous/channels/index.js.map +0 -1
- package/lib/rendezvous/index.d.ts +0 -10
- package/lib/rendezvous/index.d.ts.map +0 -1
- package/lib/rendezvous/index.js +0 -23
- package/lib/rendezvous/index.js.map +0 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +0 -61
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts.map +0 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js +0 -253
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +0 -1
- package/lib/rendezvous/transports/index.d.ts +0 -2
- package/lib/rendezvous/transports/index.d.ts.map +0 -1
- package/lib/rendezvous/transports/index.js +0 -18
- package/lib/rendezvous/transports/index.js.map +0 -1
- package/lib/rust-crypto/CrossSigningIdentity.d.ts +0 -33
- package/lib/rust-crypto/CrossSigningIdentity.d.ts.map +0 -1
- package/lib/rust-crypto/CrossSigningIdentity.js +0 -157
- package/lib/rust-crypto/CrossSigningIdentity.js.map +0 -1
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts +0 -98
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts.map +0 -1
- package/lib/rust-crypto/DehydratedDeviceManager.js +0 -285
- package/lib/rust-crypto/DehydratedDeviceManager.js.map +0 -1
- package/lib/rust-crypto/KeyClaimManager.d.ts +0 -33
- package/lib/rust-crypto/KeyClaimManager.d.ts.map +0 -1
- package/lib/rust-crypto/KeyClaimManager.js +0 -82
- package/lib/rust-crypto/KeyClaimManager.js.map +0 -1
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts +0 -43
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts.map +0 -1
- package/lib/rust-crypto/OutgoingRequestProcessor.js +0 -195
- package/lib/rust-crypto/OutgoingRequestProcessor.js.map +0 -1
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts +0 -47
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts.map +0 -1
- package/lib/rust-crypto/OutgoingRequestsManager.js +0 -148
- package/lib/rust-crypto/OutgoingRequestsManager.js.map +0 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +0 -120
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts.map +0 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +0 -467
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +0 -1
- package/lib/rust-crypto/RoomEncryptor.d.ts +0 -98
- package/lib/rust-crypto/RoomEncryptor.d.ts.map +0 -1
- package/lib/rust-crypto/RoomEncryptor.js +0 -299
- package/lib/rust-crypto/RoomEncryptor.js.map +0 -1
- package/lib/rust-crypto/backup.d.ts +0 -254
- package/lib/rust-crypto/backup.d.ts.map +0 -1
- package/lib/rust-crypto/backup.js +0 -837
- package/lib/rust-crypto/backup.js.map +0 -1
- package/lib/rust-crypto/constants.d.ts +0 -3
- package/lib/rust-crypto/constants.d.ts.map +0 -1
- package/lib/rust-crypto/constants.js +0 -19
- package/lib/rust-crypto/constants.js.map +0 -1
- package/lib/rust-crypto/device-converter.d.ts +0 -28
- package/lib/rust-crypto/device-converter.d.ts.map +0 -1
- package/lib/rust-crypto/device-converter.js +0 -123
- package/lib/rust-crypto/device-converter.js.map +0 -1
- package/lib/rust-crypto/index.d.ts +0 -61
- package/lib/rust-crypto/index.d.ts.map +0 -1
- package/lib/rust-crypto/index.js +0 -152
- package/lib/rust-crypto/index.js.map +0 -1
- package/lib/rust-crypto/libolm_migration.d.ts +0 -81
- package/lib/rust-crypto/libolm_migration.d.ts.map +0 -1
- package/lib/rust-crypto/libolm_migration.js +0 -459
- package/lib/rust-crypto/libolm_migration.js.map +0 -1
- package/lib/rust-crypto/rust-crypto.d.ts +0 -556
- package/lib/rust-crypto/rust-crypto.d.ts.map +0 -1
- package/lib/rust-crypto/rust-crypto.js +0 -2016
- package/lib/rust-crypto/rust-crypto.js.map +0 -1
- package/lib/rust-crypto/secret-storage.d.ts +0 -22
- package/lib/rust-crypto/secret-storage.d.ts.map +0 -1
- package/lib/rust-crypto/secret-storage.js +0 -63
- package/lib/rust-crypto/secret-storage.js.map +0 -1
- package/lib/rust-crypto/verification.d.ts +0 -319
- package/lib/rust-crypto/verification.d.ts.map +0 -1
- package/lib/rust-crypto/verification.js +0 -816
- package/lib/rust-crypto/verification.js.map +0 -1
- package/lib/secret-storage.d.ts +0 -370
- package/lib/secret-storage.d.ts.map +0 -1
- package/lib/secret-storage.js +0 -466
- package/lib/secret-storage.js.map +0 -1
- package/src/@types/crypto.ts +0 -73
- package/src/@types/matrix-sdk-crypto-wasm.d.ts +0 -44
- package/src/common-crypto/CryptoBackend.ts +0 -302
- package/src/common-crypto/README.md +0 -4
- package/src/common-crypto/key-passphrase.ts +0 -43
- package/src/crypto/CrossSigning.ts +0 -773
- package/src/crypto/DeviceList.ts +0 -989
- package/src/crypto/EncryptionSetup.ts +0 -351
- package/src/crypto/OlmDevice.ts +0 -1500
- package/src/crypto/OutgoingRoomKeyRequestManager.ts +0 -485
- package/src/crypto/RoomList.ts +0 -70
- package/src/crypto/SecretSharing.ts +0 -240
- package/src/crypto/SecretStorage.ts +0 -136
- package/src/crypto/aes.ts +0 -23
- package/src/crypto/algorithms/base.ts +0 -236
- package/src/crypto/algorithms/index.ts +0 -20
- package/src/crypto/algorithms/megolm.ts +0 -2216
- package/src/crypto/algorithms/olm.ts +0 -381
- package/src/crypto/api.ts +0 -70
- package/src/crypto/backup.ts +0 -922
- package/src/crypto/crypto.ts +0 -18
- package/src/crypto/dehydration.ts +0 -272
- package/src/crypto/device-converter.ts +0 -45
- package/src/crypto/deviceinfo.ts +0 -158
- package/src/crypto/index.ts +0 -4414
- package/src/crypto/key_passphrase.ts +0 -42
- package/src/crypto/keybackup.ts +0 -47
- package/src/crypto/olmlib.ts +0 -539
- package/src/crypto/recoverykey.ts +0 -18
- package/src/crypto/store/base.ts +0 -348
- package/src/crypto/store/indexeddb-crypto-store-backend.ts +0 -1250
- package/src/crypto/store/indexeddb-crypto-store.ts +0 -845
- package/src/crypto/store/localStorage-crypto-store.ts +0 -579
- package/src/crypto/store/memory-crypto-store.ts +0 -680
- package/src/crypto/verification/Base.ts +0 -409
- package/src/crypto/verification/Error.ts +0 -76
- package/src/crypto/verification/IllegalMethod.ts +0 -50
- package/src/crypto/verification/QRCode.ts +0 -310
- package/src/crypto/verification/SAS.ts +0 -494
- package/src/crypto/verification/SASDecimal.ts +0 -37
- package/src/crypto/verification/request/Channel.ts +0 -34
- package/src/crypto/verification/request/InRoomChannel.ts +0 -371
- package/src/crypto/verification/request/ToDeviceChannel.ts +0 -354
- package/src/crypto/verification/request/VerificationRequest.ts +0 -976
- package/src/crypto-api/CryptoEvent.ts +0 -93
- package/src/crypto-api/CryptoEventHandlerMap.ts +0 -32
- package/src/crypto-api/index.ts +0 -1175
- package/src/crypto-api/key-passphrase.ts +0 -58
- package/src/crypto-api/keybackup.ts +0 -115
- package/src/crypto-api/recovery-key.ts +0 -69
- package/src/crypto-api/verification.ts +0 -408
- package/src/rendezvous/MSC4108SignInWithQR.ts +0 -444
- package/src/rendezvous/RendezvousChannel.ts +0 -48
- package/src/rendezvous/RendezvousCode.ts +0 -25
- package/src/rendezvous/RendezvousError.ts +0 -26
- package/src/rendezvous/RendezvousFailureReason.ts +0 -49
- package/src/rendezvous/RendezvousIntent.ts +0 -20
- package/src/rendezvous/RendezvousTransport.ts +0 -58
- package/src/rendezvous/channels/MSC4108SecureChannel.ts +0 -270
- package/src/rendezvous/channels/index.ts +0 -17
- package/src/rendezvous/index.ts +0 -25
- package/src/rendezvous/transports/MSC4108RendezvousSession.ts +0 -270
- package/src/rendezvous/transports/index.ts +0 -17
- package/src/rust-crypto/CrossSigningIdentity.ts +0 -183
- package/src/rust-crypto/DehydratedDeviceManager.ts +0 -306
- package/src/rust-crypto/KeyClaimManager.ts +0 -86
- package/src/rust-crypto/OutgoingRequestProcessor.ts +0 -236
- package/src/rust-crypto/OutgoingRequestsManager.ts +0 -143
- package/src/rust-crypto/PerSessionKeyBackupDownloader.ts +0 -501
- package/src/rust-crypto/RoomEncryptor.ts +0 -352
- package/src/rust-crypto/backup.ts +0 -881
- package/src/rust-crypto/constants.ts +0 -18
- package/src/rust-crypto/device-converter.ts +0 -128
- package/src/rust-crypto/index.ts +0 -237
- package/src/rust-crypto/libolm_migration.ts +0 -530
- package/src/rust-crypto/rust-crypto.ts +0 -2205
- package/src/rust-crypto/secret-storage.ts +0 -60
- package/src/rust-crypto/verification.ts +0 -830
- package/src/secret-storage.ts +0 -693
@@ -1,467 +0,0 @@
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
-
/*
|
4
|
-
Copyright 2023 - 2024 The Matrix.org Foundation C.I.C.
|
5
|
-
|
6
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
you may not use this file except in compliance with the License.
|
8
|
-
You may obtain a copy of the License at
|
9
|
-
|
10
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
|
12
|
-
Unless required by applicable law or agreed to in writing, software
|
13
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
See the License for the specific language governing permissions and
|
16
|
-
limitations under the License.
|
17
|
-
*/
|
18
|
-
|
19
|
-
import { CryptoEvent } from "../crypto-api/index.js";
|
20
|
-
import { ClientPrefix, MatrixError, Method } from "../http-api/index.js";
|
21
|
-
import { encodeUri, sleep } from "../utils.js";
|
22
|
-
// The minimum time to wait between two retries in case of errors. To avoid hammering the server.
|
23
|
-
var KEY_BACKUP_BACKOFF = 5000; // ms
|
24
|
-
|
25
|
-
/**
|
26
|
-
* Enumerates the different kind of errors that can occurs when downloading and importing a key from backup.
|
27
|
-
*/
|
28
|
-
var KeyDownloadErrorCode = /*#__PURE__*/function (KeyDownloadErrorCode) {
|
29
|
-
KeyDownloadErrorCode["MISSING_DECRYPTION_KEY"] = "MISSING_DECRYPTION_KEY";
|
30
|
-
KeyDownloadErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
|
31
|
-
KeyDownloadErrorCode["STOPPED"] = "STOPPED";
|
32
|
-
return KeyDownloadErrorCode;
|
33
|
-
}(KeyDownloadErrorCode || {});
|
34
|
-
class KeyDownloadError extends Error {
|
35
|
-
constructor(code) {
|
36
|
-
super("Failed to get key from backup: ".concat(code));
|
37
|
-
this.code = code;
|
38
|
-
this.name = "KeyDownloadError";
|
39
|
-
}
|
40
|
-
}
|
41
|
-
class KeyDownloadRateLimitError extends Error {
|
42
|
-
constructor(retryMillis) {
|
43
|
-
super("Failed to get key from backup: rate limited");
|
44
|
-
this.retryMillis = retryMillis;
|
45
|
-
this.name = "KeyDownloadRateLimitError";
|
46
|
-
}
|
47
|
-
}
|
48
|
-
|
49
|
-
/** Details of a megolm session whose key we are trying to fetch. */
|
50
|
-
|
51
|
-
/** Holds the current backup decryptor and version that should be used.
|
52
|
-
*
|
53
|
-
* This is intended to be used as an immutable object (a new instance should be created if the configuration changes),
|
54
|
-
* and some of the logic relies on that, so the properties are marked as `readonly`.
|
55
|
-
*/
|
56
|
-
|
57
|
-
/**
|
58
|
-
* Used when an 'unable to decrypt' error occurs. It attempts to download the key from the backup.
|
59
|
-
*
|
60
|
-
* The current backup API lacks pagination, which can lead to lengthy key retrieval times for large histories (several 10s of minutes).
|
61
|
-
* To mitigate this, keys are downloaded on demand as decryption errors occurs.
|
62
|
-
* While this approach may result in numerous requests, it improves user experience by reducing wait times for message decryption.
|
63
|
-
*
|
64
|
-
* The PerSessionKeyBackupDownloader is resistant to backup configuration changes: it will automatically resume querying when
|
65
|
-
* the backup is configured correctly.
|
66
|
-
*/
|
67
|
-
export class PerSessionKeyBackupDownloader {
|
68
|
-
/**
|
69
|
-
* Creates a new instance of PerSessionKeyBackupDownloader.
|
70
|
-
*
|
71
|
-
* @param backupManager - The backup manager to use.
|
72
|
-
* @param olmMachine - The olm machine to use.
|
73
|
-
* @param http - The http instance to use.
|
74
|
-
* @param logger - The logger to use.
|
75
|
-
*/
|
76
|
-
constructor(logger, olmMachine, http, backupManager) {
|
77
|
-
this.olmMachine = olmMachine;
|
78
|
-
this.http = http;
|
79
|
-
this.backupManager = backupManager;
|
80
|
-
_defineProperty(this, "stopped", false);
|
81
|
-
/**
|
82
|
-
* The version and decryption key to use with current backup if all set up correctly.
|
83
|
-
*
|
84
|
-
* Will not be set unless `hasConfigurationProblem` is `false`.
|
85
|
-
*/
|
86
|
-
_defineProperty(this, "configuration", null);
|
87
|
-
/** We remember when a session was requested and not found in backup to avoid query again too soon.
|
88
|
-
* Map of session_id to timestamp */
|
89
|
-
_defineProperty(this, "sessionLastCheckAttemptedTime", new Map());
|
90
|
-
/** The logger to use */
|
91
|
-
_defineProperty(this, "logger", void 0);
|
92
|
-
/** Whether the download loop is running. */
|
93
|
-
_defineProperty(this, "downloadLoopRunning", false);
|
94
|
-
/** The list of requests that are queued. */
|
95
|
-
_defineProperty(this, "queuedRequests", []);
|
96
|
-
/** Remembers if we have a configuration problem. */
|
97
|
-
_defineProperty(this, "hasConfigurationProblem", false);
|
98
|
-
/** The current server backup version check promise. To avoid doing a server call if one is in flight. */
|
99
|
-
_defineProperty(this, "currentBackupVersionCheck", null);
|
100
|
-
/**
|
101
|
-
* Called when the backup status changes (CryptoEvents)
|
102
|
-
* This will trigger a check of the backup configuration.
|
103
|
-
*/
|
104
|
-
_defineProperty(this, "onBackupStatusChanged", () => {
|
105
|
-
// we want to force check configuration, so we clear the current one.
|
106
|
-
this.hasConfigurationProblem = false;
|
107
|
-
this.configuration = null;
|
108
|
-
this.getOrCreateBackupConfiguration().then(configuration => {
|
109
|
-
if (configuration) {
|
110
|
-
// restart the download loop if it was stopped
|
111
|
-
this.downloadKeysLoop();
|
112
|
-
}
|
113
|
-
});
|
114
|
-
});
|
115
|
-
this.logger = logger.getChild("[PerSessionKeyBackupDownloader]");
|
116
|
-
backupManager.on(CryptoEvent.KeyBackupStatus, this.onBackupStatusChanged);
|
117
|
-
backupManager.on(CryptoEvent.KeyBackupFailed, this.onBackupStatusChanged);
|
118
|
-
backupManager.on(CryptoEvent.KeyBackupDecryptionKeyCached, this.onBackupStatusChanged);
|
119
|
-
}
|
120
|
-
|
121
|
-
/**
|
122
|
-
* Check if key download is successfully configured and active.
|
123
|
-
*
|
124
|
-
* @return `true` if key download is correctly configured and active; otherwise `false`.
|
125
|
-
*/
|
126
|
-
isKeyBackupDownloadConfigured() {
|
127
|
-
return this.configuration !== null;
|
128
|
-
}
|
129
|
-
|
130
|
-
/**
|
131
|
-
* Return the details of the latest backup on the server, when we last checked.
|
132
|
-
*
|
133
|
-
* This is just a convenience method to expose {@link RustBackupManager.getServerBackupInfo}.
|
134
|
-
*/
|
135
|
-
getServerBackupInfo() {
|
136
|
-
var _this = this;
|
137
|
-
return _asyncToGenerator(function* () {
|
138
|
-
return yield _this.backupManager.getServerBackupInfo();
|
139
|
-
})();
|
140
|
-
}
|
141
|
-
|
142
|
-
/**
|
143
|
-
* Called when a MissingRoomKey or UnknownMessageIndex decryption error is encountered.
|
144
|
-
*
|
145
|
-
* This will try to download the key from the backup if there is a trusted active backup.
|
146
|
-
* In case of success the key will be imported and the onRoomKeysUpdated callback will be called
|
147
|
-
* internally by the rust-sdk and decryption will be retried.
|
148
|
-
*
|
149
|
-
* @param roomId - The room ID of the room where the error occurred.
|
150
|
-
* @param megolmSessionId - The megolm session ID that is missing.
|
151
|
-
*/
|
152
|
-
onDecryptionKeyMissingError(roomId, megolmSessionId) {
|
153
|
-
// Several messages encrypted with the same session may be decrypted at the same time,
|
154
|
-
// so we need to be resistant and not query several time the same session.
|
155
|
-
if (this.isAlreadyInQueue(roomId, megolmSessionId)) {
|
156
|
-
// There is already a request queued for this session, no need to queue another one.
|
157
|
-
this.logger.trace("Not checking key backup for session ".concat(megolmSessionId, " as it is already queued"));
|
158
|
-
return;
|
159
|
-
}
|
160
|
-
if (this.wasRequestedRecently(megolmSessionId)) {
|
161
|
-
// We already tried to download this session recently and it was not in backup, no need to try again.
|
162
|
-
this.logger.trace("Not checking key backup for session ".concat(megolmSessionId, " as it was already requested recently"));
|
163
|
-
return;
|
164
|
-
}
|
165
|
-
|
166
|
-
// We always add the request to the queue, even if we have a configuration problem (can't access backup).
|
167
|
-
// This is to make sure that if the configuration problem is resolved, we will try to download the key.
|
168
|
-
// This will happen after an initial sync, at this point the backup will not yet be trusted and the decryption
|
169
|
-
// key will not be available, but it will be just after the verification.
|
170
|
-
// We don't need to persist it because currently on refresh the sdk will retry to decrypt the messages in error.
|
171
|
-
this.queuedRequests.push({
|
172
|
-
roomId,
|
173
|
-
megolmSessionId
|
174
|
-
});
|
175
|
-
|
176
|
-
// Start the download loop if it's not already running.
|
177
|
-
this.downloadKeysLoop();
|
178
|
-
}
|
179
|
-
stop() {
|
180
|
-
this.stopped = true;
|
181
|
-
this.backupManager.off(CryptoEvent.KeyBackupStatus, this.onBackupStatusChanged);
|
182
|
-
this.backupManager.off(CryptoEvent.KeyBackupFailed, this.onBackupStatusChanged);
|
183
|
-
this.backupManager.off(CryptoEvent.KeyBackupDecryptionKeyCached, this.onBackupStatusChanged);
|
184
|
-
}
|
185
|
-
/** Returns true if the megolm session is already queued for download. */
|
186
|
-
isAlreadyInQueue(roomId, megolmSessionId) {
|
187
|
-
return this.queuedRequests.some(info => {
|
188
|
-
return info.roomId == roomId && info.megolmSessionId == megolmSessionId;
|
189
|
-
});
|
190
|
-
}
|
191
|
-
|
192
|
-
/**
|
193
|
-
* Marks the session as not found in backup, to avoid retrying to soon for a key not in backup
|
194
|
-
*
|
195
|
-
* @param megolmSessionId - The megolm session ID that is missing.
|
196
|
-
*/
|
197
|
-
markAsNotFoundInBackup(megolmSessionId) {
|
198
|
-
var now = Date.now();
|
199
|
-
this.sessionLastCheckAttemptedTime.set(megolmSessionId, now);
|
200
|
-
// if too big make some cleaning to keep under control
|
201
|
-
if (this.sessionLastCheckAttemptedTime.size > 100) {
|
202
|
-
this.sessionLastCheckAttemptedTime = new Map(Array.from(this.sessionLastCheckAttemptedTime).filter((sid, ts) => {
|
203
|
-
return Math.max(now - ts, 0) < KEY_BACKUP_BACKOFF;
|
204
|
-
}));
|
205
|
-
}
|
206
|
-
}
|
207
|
-
|
208
|
-
/** Returns true if the session was requested recently. */
|
209
|
-
wasRequestedRecently(megolmSessionId) {
|
210
|
-
var lastCheck = this.sessionLastCheckAttemptedTime.get(megolmSessionId);
|
211
|
-
if (!lastCheck) return false;
|
212
|
-
return Math.max(Date.now() - lastCheck, 0) < KEY_BACKUP_BACKOFF;
|
213
|
-
}
|
214
|
-
getBackupDecryptionKey() {
|
215
|
-
var _this2 = this;
|
216
|
-
return _asyncToGenerator(function* () {
|
217
|
-
try {
|
218
|
-
return yield _this2.olmMachine.getBackupKeys();
|
219
|
-
} catch (_unused) {
|
220
|
-
return null;
|
221
|
-
}
|
222
|
-
})();
|
223
|
-
}
|
224
|
-
|
225
|
-
/**
|
226
|
-
* Requests a key from the server side backup.
|
227
|
-
*
|
228
|
-
* @param version - The backup version to use.
|
229
|
-
* @param roomId - The room ID of the room where the error occurred.
|
230
|
-
* @param sessionId - The megolm session ID that is missing.
|
231
|
-
*/
|
232
|
-
requestRoomKeyFromBackup(version, roomId, sessionId) {
|
233
|
-
var _this3 = this;
|
234
|
-
return _asyncToGenerator(function* () {
|
235
|
-
var path = encodeUri("/room_keys/keys/$roomId/$sessionId", {
|
236
|
-
$roomId: roomId,
|
237
|
-
$sessionId: sessionId
|
238
|
-
});
|
239
|
-
return yield _this3.http.authedRequest(Method.Get, path, {
|
240
|
-
version
|
241
|
-
}, undefined, {
|
242
|
-
prefix: ClientPrefix.V3
|
243
|
-
});
|
244
|
-
})();
|
245
|
-
}
|
246
|
-
downloadKeysLoop() {
|
247
|
-
var _this4 = this;
|
248
|
-
return _asyncToGenerator(function* () {
|
249
|
-
if (_this4.downloadLoopRunning) return;
|
250
|
-
|
251
|
-
// If we have a configuration problem, we don't want to try to download.
|
252
|
-
// If any configuration change is detected, we will retry and restart the loop.
|
253
|
-
if (_this4.hasConfigurationProblem) return;
|
254
|
-
_this4.downloadLoopRunning = true;
|
255
|
-
try {
|
256
|
-
while (_this4.queuedRequests.length > 0) {
|
257
|
-
// we just peek the first one without removing it, so if a new request for same key comes in while we're
|
258
|
-
// processing this one, it won't queue another request.
|
259
|
-
var request = _this4.queuedRequests[0];
|
260
|
-
try {
|
261
|
-
// The backup could have changed between the time we queued the request and now, so we need to check
|
262
|
-
var configuration = yield _this4.getOrCreateBackupConfiguration();
|
263
|
-
if (!configuration) {
|
264
|
-
// Backup is not configured correctly, so stop the loop.
|
265
|
-
_this4.downloadLoopRunning = false;
|
266
|
-
return;
|
267
|
-
}
|
268
|
-
var result = yield _this4.queryKeyBackup(request.roomId, request.megolmSessionId, configuration);
|
269
|
-
if (_this4.stopped) {
|
270
|
-
return;
|
271
|
-
}
|
272
|
-
// We got the encrypted key from backup, let's try to decrypt and import it.
|
273
|
-
try {
|
274
|
-
yield _this4.decryptAndImport(request, result, configuration);
|
275
|
-
} catch (e) {
|
276
|
-
_this4.logger.error("Error while decrypting and importing key backup for session ".concat(request.megolmSessionId), e);
|
277
|
-
}
|
278
|
-
// now remove the request from the queue as we've processed it.
|
279
|
-
_this4.queuedRequests.shift();
|
280
|
-
} catch (err) {
|
281
|
-
if (err instanceof KeyDownloadError) {
|
282
|
-
switch (err.code) {
|
283
|
-
case KeyDownloadErrorCode.MISSING_DECRYPTION_KEY:
|
284
|
-
_this4.markAsNotFoundInBackup(request.megolmSessionId);
|
285
|
-
// continue for next one
|
286
|
-
_this4.queuedRequests.shift();
|
287
|
-
break;
|
288
|
-
case KeyDownloadErrorCode.NETWORK_ERROR:
|
289
|
-
// We don't want to hammer if there is a problem, so wait a bit.
|
290
|
-
yield sleep(KEY_BACKUP_BACKOFF);
|
291
|
-
break;
|
292
|
-
case KeyDownloadErrorCode.STOPPED:
|
293
|
-
// If the downloader was stopped, we don't want to retry.
|
294
|
-
_this4.downloadLoopRunning = false;
|
295
|
-
return;
|
296
|
-
}
|
297
|
-
} else if (err instanceof KeyDownloadRateLimitError) {
|
298
|
-
// we want to retry after the backoff time
|
299
|
-
yield sleep(err.retryMillis);
|
300
|
-
}
|
301
|
-
}
|
302
|
-
}
|
303
|
-
} finally {
|
304
|
-
// all pending request have been processed, we can stop the loop.
|
305
|
-
_this4.downloadLoopRunning = false;
|
306
|
-
}
|
307
|
-
})();
|
308
|
-
}
|
309
|
-
|
310
|
-
/**
|
311
|
-
* Query the backup for a key.
|
312
|
-
*
|
313
|
-
* @param targetRoomId - ID of the room that the session is used in.
|
314
|
-
* @param targetSessionId - ID of the session for which to check backup.
|
315
|
-
* @param configuration - The backup configuration to use.
|
316
|
-
*/
|
317
|
-
queryKeyBackup(targetRoomId, targetSessionId, configuration) {
|
318
|
-
var _this5 = this;
|
319
|
-
return _asyncToGenerator(function* () {
|
320
|
-
_this5.logger.debug("Checking key backup for session ".concat(targetSessionId));
|
321
|
-
if (_this5.stopped) throw new KeyDownloadError(KeyDownloadErrorCode.STOPPED);
|
322
|
-
try {
|
323
|
-
var res = yield _this5.requestRoomKeyFromBackup(configuration.backupVersion, targetRoomId, targetSessionId);
|
324
|
-
_this5.logger.debug("Got key from backup for sessionId:".concat(targetSessionId));
|
325
|
-
return res;
|
326
|
-
} catch (e) {
|
327
|
-
if (_this5.stopped) throw new KeyDownloadError(KeyDownloadErrorCode.STOPPED);
|
328
|
-
_this5.logger.info("No luck requesting key backup for session ".concat(targetSessionId, ": ").concat(e));
|
329
|
-
if (e instanceof MatrixError) {
|
330
|
-
var errCode = e.data.errcode;
|
331
|
-
if (errCode == "M_NOT_FOUND") {
|
332
|
-
// Unfortunately the spec doesn't give us a way to differentiate between a missing key and a wrong version.
|
333
|
-
// Synapse will return:
|
334
|
-
// - "error": "Unknown backup version" if the version is wrong.
|
335
|
-
// - "error": "No room_keys found" if the key is missing.
|
336
|
-
// It's useful to know if the key is missing or if the version is wrong.
|
337
|
-
// As it's not spec'ed, we fall back on considering the key is not in backup.
|
338
|
-
// Notice that this request will be lost if instead the backup got out of sync (updated from other session).
|
339
|
-
throw new KeyDownloadError(KeyDownloadErrorCode.MISSING_DECRYPTION_KEY);
|
340
|
-
}
|
341
|
-
if (e.isRateLimitError()) {
|
342
|
-
var _waitTime;
|
343
|
-
var waitTime;
|
344
|
-
try {
|
345
|
-
var _e$getRetryAfterMs;
|
346
|
-
waitTime = (_e$getRetryAfterMs = e.getRetryAfterMs()) !== null && _e$getRetryAfterMs !== void 0 ? _e$getRetryAfterMs : undefined;
|
347
|
-
} catch (error) {
|
348
|
-
_this5.logger.warn("Error while retrieving a rate-limit retry delay", error);
|
349
|
-
}
|
350
|
-
if (waitTime && waitTime > 0) {
|
351
|
-
_this5.logger.info("Rate limited by server, waiting ".concat(waitTime, "ms"));
|
352
|
-
}
|
353
|
-
throw new KeyDownloadRateLimitError((_waitTime = waitTime) !== null && _waitTime !== void 0 ? _waitTime : KEY_BACKUP_BACKOFF);
|
354
|
-
}
|
355
|
-
}
|
356
|
-
throw new KeyDownloadError(KeyDownloadErrorCode.NETWORK_ERROR);
|
357
|
-
}
|
358
|
-
})();
|
359
|
-
}
|
360
|
-
decryptAndImport(sessionInfo, data, configuration) {
|
361
|
-
var _this6 = this;
|
362
|
-
return _asyncToGenerator(function* () {
|
363
|
-
var sessionsToImport = {
|
364
|
-
[sessionInfo.megolmSessionId]: data
|
365
|
-
};
|
366
|
-
var keys = yield configuration.decryptor.decryptSessions(sessionsToImport);
|
367
|
-
for (var k of keys) {
|
368
|
-
k.room_id = sessionInfo.roomId;
|
369
|
-
}
|
370
|
-
yield _this6.backupManager.importBackedUpRoomKeys(keys, configuration.backupVersion);
|
371
|
-
})();
|
372
|
-
}
|
373
|
-
|
374
|
-
/**
|
375
|
-
* Gets the current backup configuration or create one if it doesn't exist.
|
376
|
-
*
|
377
|
-
* When a valid configuration is found it is cached and returned for subsequent calls.
|
378
|
-
* Otherwise, if a check is forced or a check has not yet been done, a new check is done.
|
379
|
-
*
|
380
|
-
* @returns The backup configuration to use or null if there is a configuration problem.
|
381
|
-
*/
|
382
|
-
getOrCreateBackupConfiguration() {
|
383
|
-
var _this7 = this;
|
384
|
-
return _asyncToGenerator(function* () {
|
385
|
-
if (_this7.configuration) {
|
386
|
-
return _this7.configuration;
|
387
|
-
}
|
388
|
-
|
389
|
-
// We already tried to check the configuration and it failed.
|
390
|
-
// We don't want to try again immediately, we will retry if a configuration change is detected.
|
391
|
-
if (_this7.hasConfigurationProblem) {
|
392
|
-
return null;
|
393
|
-
}
|
394
|
-
|
395
|
-
// This method can be called rapidly by several emitted CryptoEvent, so we need to make sure that we don't
|
396
|
-
// query the server several times.
|
397
|
-
if (_this7.currentBackupVersionCheck != null) {
|
398
|
-
_this7.logger.debug("Already checking server version, use current promise");
|
399
|
-
return yield _this7.currentBackupVersionCheck;
|
400
|
-
}
|
401
|
-
_this7.currentBackupVersionCheck = _this7.internalCheckFromServer();
|
402
|
-
try {
|
403
|
-
return yield _this7.currentBackupVersionCheck;
|
404
|
-
} finally {
|
405
|
-
_this7.currentBackupVersionCheck = null;
|
406
|
-
}
|
407
|
-
})();
|
408
|
-
}
|
409
|
-
internalCheckFromServer() {
|
410
|
-
var _this8 = this;
|
411
|
-
return _asyncToGenerator(function* () {
|
412
|
-
var _currentServerVersion, _currentServerVersion2, _currentServerVersion4;
|
413
|
-
var currentServerVersion = null;
|
414
|
-
try {
|
415
|
-
currentServerVersion = yield _this8.backupManager.getServerBackupInfo();
|
416
|
-
} catch (e) {
|
417
|
-
_this8.logger.debug("Backup: error while checking server version: ".concat(e));
|
418
|
-
_this8.hasConfigurationProblem = true;
|
419
|
-
return null;
|
420
|
-
}
|
421
|
-
_this8.logger.debug("Got current backup version from server: ".concat((_currentServerVersion = currentServerVersion) === null || _currentServerVersion === void 0 ? void 0 : _currentServerVersion.version));
|
422
|
-
if (((_currentServerVersion2 = currentServerVersion) === null || _currentServerVersion2 === void 0 ? void 0 : _currentServerVersion2.algorithm) != "m.megolm_backup.v1.curve25519-aes-sha2") {
|
423
|
-
var _currentServerVersion3;
|
424
|
-
_this8.logger.info("Unsupported algorithm ".concat((_currentServerVersion3 = currentServerVersion) === null || _currentServerVersion3 === void 0 ? void 0 : _currentServerVersion3.algorithm));
|
425
|
-
_this8.hasConfigurationProblem = true;
|
426
|
-
return null;
|
427
|
-
}
|
428
|
-
if (!((_currentServerVersion4 = currentServerVersion) !== null && _currentServerVersion4 !== void 0 && _currentServerVersion4.version)) {
|
429
|
-
_this8.logger.info("No current key backup");
|
430
|
-
_this8.hasConfigurationProblem = true;
|
431
|
-
return null;
|
432
|
-
}
|
433
|
-
var activeVersion = yield _this8.backupManager.getActiveBackupVersion();
|
434
|
-
if (activeVersion == null || currentServerVersion.version != activeVersion) {
|
435
|
-
// Either the current backup version on server side is not trusted, or it is out of sync with the active version on the client side.
|
436
|
-
_this8.logger.info("The current backup version on the server (".concat(currentServerVersion.version, ") is not trusted. Version we are currently backing up to: ").concat(activeVersion));
|
437
|
-
_this8.hasConfigurationProblem = true;
|
438
|
-
return null;
|
439
|
-
}
|
440
|
-
var backupKeys = yield _this8.getBackupDecryptionKey();
|
441
|
-
if (!(backupKeys !== null && backupKeys !== void 0 && backupKeys.decryptionKey)) {
|
442
|
-
_this8.logger.debug("Not checking key backup for session (no decryption key)");
|
443
|
-
_this8.hasConfigurationProblem = true;
|
444
|
-
return null;
|
445
|
-
}
|
446
|
-
if (activeVersion != backupKeys.backupVersion) {
|
447
|
-
_this8.logger.debug("Version for which we have a decryption key (".concat(backupKeys.backupVersion, ") doesn't match the version we are backing up to (").concat(activeVersion, ")"));
|
448
|
-
_this8.hasConfigurationProblem = true;
|
449
|
-
return null;
|
450
|
-
}
|
451
|
-
var authData = currentServerVersion.auth_data;
|
452
|
-
if (authData.public_key != backupKeys.decryptionKey.megolmV1PublicKey.publicKeyBase64) {
|
453
|
-
_this8.logger.debug("Key backup on server does not match our decryption key");
|
454
|
-
_this8.hasConfigurationProblem = true;
|
455
|
-
return null;
|
456
|
-
}
|
457
|
-
var backupDecryptor = _this8.backupManager.createBackupDecryptor(backupKeys.decryptionKey);
|
458
|
-
_this8.hasConfigurationProblem = false;
|
459
|
-
_this8.configuration = {
|
460
|
-
decryptor: backupDecryptor,
|
461
|
-
backupVersion: activeVersion
|
462
|
-
};
|
463
|
-
return _this8.configuration;
|
464
|
-
})();
|
465
|
-
}
|
466
|
-
}
|
467
|
-
//# sourceMappingURL=PerSessionKeyBackupDownloader.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"PerSessionKeyBackupDownloader.js","names":["CryptoEvent","ClientPrefix","MatrixError","Method","encodeUri","sleep","KEY_BACKUP_BACKOFF","KeyDownloadErrorCode","KeyDownloadError","Error","constructor","code","concat","name","KeyDownloadRateLimitError","retryMillis","PerSessionKeyBackupDownloader","logger","olmMachine","http","backupManager","_defineProperty","Map","hasConfigurationProblem","configuration","getOrCreateBackupConfiguration","then","downloadKeysLoop","getChild","on","KeyBackupStatus","onBackupStatusChanged","KeyBackupFailed","KeyBackupDecryptionKeyCached","isKeyBackupDownloadConfigured","getServerBackupInfo","_this","_asyncToGenerator","onDecryptionKeyMissingError","roomId","megolmSessionId","isAlreadyInQueue","trace","wasRequestedRecently","queuedRequests","push","stop","stopped","off","some","info","markAsNotFoundInBackup","now","Date","sessionLastCheckAttemptedTime","set","size","Array","from","filter","sid","ts","Math","max","lastCheck","get","getBackupDecryptionKey","_this2","getBackupKeys","_unused","requestRoomKeyFromBackup","version","sessionId","_this3","path","$roomId","$sessionId","authedRequest","Get","undefined","prefix","V3","_this4","downloadLoopRunning","length","request","result","queryKeyBackup","decryptAndImport","e","error","shift","err","MISSING_DECRYPTION_KEY","NETWORK_ERROR","STOPPED","targetRoomId","targetSessionId","_this5","debug","res","backupVersion","errCode","data","errcode","isRateLimitError","_waitTime","waitTime","_e$getRetryAfterMs","getRetryAfterMs","warn","sessionInfo","_this6","sessionsToImport","keys","decryptor","decryptSessions","k","room_id","importBackedUpRoomKeys","_this7","currentBackupVersionCheck","internalCheckFromServer","_this8","_currentServerVersion","_currentServerVersion2","_currentServerVersion4","currentServerVersion","algorithm","_currentServerVersion3","activeVersion","getActiveBackupVersion","backupKeys","decryptionKey","authData","auth_data","public_key","megolmV1PublicKey","publicKeyBase64","backupDecryptor","createBackupDecryptor"],"sources":["../../src/rust-crypto/PerSessionKeyBackupDownloader.ts"],"sourcesContent":["/*\nCopyright 2023 - 2024 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport * as RustSdkCryptoJs from \"@matrix-org/matrix-sdk-crypto-wasm\";\nimport { OlmMachine } from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport { Curve25519AuthData, KeyBackupInfo, KeyBackupSession } from \"../crypto-api/keybackup.ts\";\nimport { CryptoEvent } from \"../crypto-api/index.ts\";\nimport { Logger } from \"../logger.ts\";\nimport { ClientPrefix, IHttpOpts, MatrixError, MatrixHttpApi, Method } from \"../http-api/index.ts\";\nimport { RustBackupManager } from \"./backup.ts\";\nimport { encodeUri, sleep } from \"../utils.ts\";\nimport { BackupDecryptor } from \"../common-crypto/CryptoBackend.ts\";\n\n// The minimum time to wait between two retries in case of errors. To avoid hammering the server.\nconst KEY_BACKUP_BACKOFF = 5000; // ms\n\n/**\n * Enumerates the different kind of errors that can occurs when downloading and importing a key from backup.\n */\nenum KeyDownloadErrorCode {\n /** The requested key is not in the backup. */\n MISSING_DECRYPTION_KEY = \"MISSING_DECRYPTION_KEY\",\n /** A network error occurred while trying to download the key from backup. */\n NETWORK_ERROR = \"NETWORK_ERROR\",\n /** The loop has been stopped. */\n STOPPED = \"STOPPED\",\n}\n\nclass KeyDownloadError extends Error {\n public constructor(public readonly code: KeyDownloadErrorCode) {\n super(`Failed to get key from backup: ${code}`);\n this.name = \"KeyDownloadError\";\n }\n}\n\nclass KeyDownloadRateLimitError extends Error {\n public constructor(public readonly retryMillis: number) {\n super(`Failed to get key from backup: rate limited`);\n this.name = \"KeyDownloadRateLimitError\";\n }\n}\n\n/** Details of a megolm session whose key we are trying to fetch. */\ntype SessionInfo = { roomId: string; megolmSessionId: string };\n\n/** Holds the current backup decryptor and version that should be used.\n *\n * This is intended to be used as an immutable object (a new instance should be created if the configuration changes),\n * and some of the logic relies on that, so the properties are marked as `readonly`.\n */\ntype Configuration = {\n readonly backupVersion: string;\n readonly decryptor: BackupDecryptor;\n};\n\n/**\n * Used when an 'unable to decrypt' error occurs. It attempts to download the key from the backup.\n *\n * The current backup API lacks pagination, which can lead to lengthy key retrieval times for large histories (several 10s of minutes).\n * To mitigate this, keys are downloaded on demand as decryption errors occurs.\n * While this approach may result in numerous requests, it improves user experience by reducing wait times for message decryption.\n *\n * The PerSessionKeyBackupDownloader is resistant to backup configuration changes: it will automatically resume querying when\n * the backup is configured correctly.\n */\nexport class PerSessionKeyBackupDownloader {\n private stopped = false;\n\n /**\n * The version and decryption key to use with current backup if all set up correctly.\n *\n * Will not be set unless `hasConfigurationProblem` is `false`.\n */\n private configuration: Configuration | null = null;\n\n /** We remember when a session was requested and not found in backup to avoid query again too soon.\n * Map of session_id to timestamp */\n private sessionLastCheckAttemptedTime: Map<string, number> = new Map();\n\n /** The logger to use */\n private readonly logger: Logger;\n\n /** Whether the download loop is running. */\n private downloadLoopRunning = false;\n\n /** The list of requests that are queued. */\n private queuedRequests: SessionInfo[] = [];\n\n /** Remembers if we have a configuration problem. */\n private hasConfigurationProblem = false;\n\n /** The current server backup version check promise. To avoid doing a server call if one is in flight. */\n private currentBackupVersionCheck: Promise<Configuration | null> | null = null;\n\n /**\n * Creates a new instance of PerSessionKeyBackupDownloader.\n *\n * @param backupManager - The backup manager to use.\n * @param olmMachine - The olm machine to use.\n * @param http - The http instance to use.\n * @param logger - The logger to use.\n */\n public constructor(\n logger: Logger,\n private readonly olmMachine: OlmMachine,\n private readonly http: MatrixHttpApi<IHttpOpts & { onlyData: true }>,\n private readonly backupManager: RustBackupManager,\n ) {\n this.logger = logger.getChild(\"[PerSessionKeyBackupDownloader]\");\n\n backupManager.on(CryptoEvent.KeyBackupStatus, this.onBackupStatusChanged);\n backupManager.on(CryptoEvent.KeyBackupFailed, this.onBackupStatusChanged);\n backupManager.on(CryptoEvent.KeyBackupDecryptionKeyCached, this.onBackupStatusChanged);\n }\n\n /**\n * Check if key download is successfully configured and active.\n *\n * @return `true` if key download is correctly configured and active; otherwise `false`.\n */\n public isKeyBackupDownloadConfigured(): boolean {\n return this.configuration !== null;\n }\n\n /**\n * Return the details of the latest backup on the server, when we last checked.\n *\n * This is just a convenience method to expose {@link RustBackupManager.getServerBackupInfo}.\n */\n public async getServerBackupInfo(): Promise<KeyBackupInfo | null | undefined> {\n return await this.backupManager.getServerBackupInfo();\n }\n\n /**\n * Called when a MissingRoomKey or UnknownMessageIndex decryption error is encountered.\n *\n * This will try to download the key from the backup if there is a trusted active backup.\n * In case of success the key will be imported and the onRoomKeysUpdated callback will be called\n * internally by the rust-sdk and decryption will be retried.\n *\n * @param roomId - The room ID of the room where the error occurred.\n * @param megolmSessionId - The megolm session ID that is missing.\n */\n public onDecryptionKeyMissingError(roomId: string, megolmSessionId: string): void {\n // Several messages encrypted with the same session may be decrypted at the same time,\n // so we need to be resistant and not query several time the same session.\n if (this.isAlreadyInQueue(roomId, megolmSessionId)) {\n // There is already a request queued for this session, no need to queue another one.\n this.logger.trace(`Not checking key backup for session ${megolmSessionId} as it is already queued`);\n return;\n }\n\n if (this.wasRequestedRecently(megolmSessionId)) {\n // We already tried to download this session recently and it was not in backup, no need to try again.\n this.logger.trace(\n `Not checking key backup for session ${megolmSessionId} as it was already requested recently`,\n );\n return;\n }\n\n // We always add the request to the queue, even if we have a configuration problem (can't access backup).\n // This is to make sure that if the configuration problem is resolved, we will try to download the key.\n // This will happen after an initial sync, at this point the backup will not yet be trusted and the decryption\n // key will not be available, but it will be just after the verification.\n // We don't need to persist it because currently on refresh the sdk will retry to decrypt the messages in error.\n this.queuedRequests.push({ roomId, megolmSessionId });\n\n // Start the download loop if it's not already running.\n this.downloadKeysLoop();\n }\n\n public stop(): void {\n this.stopped = true;\n this.backupManager.off(CryptoEvent.KeyBackupStatus, this.onBackupStatusChanged);\n this.backupManager.off(CryptoEvent.KeyBackupFailed, this.onBackupStatusChanged);\n this.backupManager.off(CryptoEvent.KeyBackupDecryptionKeyCached, this.onBackupStatusChanged);\n }\n\n /**\n * Called when the backup status changes (CryptoEvents)\n * This will trigger a check of the backup configuration.\n */\n private onBackupStatusChanged = (): void => {\n // we want to force check configuration, so we clear the current one.\n this.hasConfigurationProblem = false;\n this.configuration = null;\n this.getOrCreateBackupConfiguration().then((configuration) => {\n if (configuration) {\n // restart the download loop if it was stopped\n this.downloadKeysLoop();\n }\n });\n };\n\n /** Returns true if the megolm session is already queued for download. */\n private isAlreadyInQueue(roomId: string, megolmSessionId: string): boolean {\n return this.queuedRequests.some((info) => {\n return info.roomId == roomId && info.megolmSessionId == megolmSessionId;\n });\n }\n\n /**\n * Marks the session as not found in backup, to avoid retrying to soon for a key not in backup\n *\n * @param megolmSessionId - The megolm session ID that is missing.\n */\n private markAsNotFoundInBackup(megolmSessionId: string): void {\n const now = Date.now();\n this.sessionLastCheckAttemptedTime.set(megolmSessionId, now);\n // if too big make some cleaning to keep under control\n if (this.sessionLastCheckAttemptedTime.size > 100) {\n this.sessionLastCheckAttemptedTime = new Map(\n Array.from(this.sessionLastCheckAttemptedTime).filter((sid, ts) => {\n return Math.max(now - ts, 0) < KEY_BACKUP_BACKOFF;\n }),\n );\n }\n }\n\n /** Returns true if the session was requested recently. */\n private wasRequestedRecently(megolmSessionId: string): boolean {\n const lastCheck = this.sessionLastCheckAttemptedTime.get(megolmSessionId);\n if (!lastCheck) return false;\n return Math.max(Date.now() - lastCheck, 0) < KEY_BACKUP_BACKOFF;\n }\n\n private async getBackupDecryptionKey(): Promise<RustSdkCryptoJs.BackupKeys | null> {\n try {\n return await this.olmMachine.getBackupKeys();\n } catch {\n return null;\n }\n }\n\n /**\n * Requests a key from the server side backup.\n *\n * @param version - The backup version to use.\n * @param roomId - The room ID of the room where the error occurred.\n * @param sessionId - The megolm session ID that is missing.\n */\n private async requestRoomKeyFromBackup(\n version: string,\n roomId: string,\n sessionId: string,\n ): Promise<KeyBackupSession> {\n const path = encodeUri(\"/room_keys/keys/$roomId/$sessionId\", {\n $roomId: roomId,\n $sessionId: sessionId,\n });\n\n return await this.http.authedRequest<KeyBackupSession>(Method.Get, path, { version }, undefined, {\n prefix: ClientPrefix.V3,\n });\n }\n\n private async downloadKeysLoop(): Promise<void> {\n if (this.downloadLoopRunning) return;\n\n // If we have a configuration problem, we don't want to try to download.\n // If any configuration change is detected, we will retry and restart the loop.\n if (this.hasConfigurationProblem) return;\n\n this.downloadLoopRunning = true;\n\n try {\n while (this.queuedRequests.length > 0) {\n // we just peek the first one without removing it, so if a new request for same key comes in while we're\n // processing this one, it won't queue another request.\n const request = this.queuedRequests[0];\n try {\n // The backup could have changed between the time we queued the request and now, so we need to check\n const configuration = await this.getOrCreateBackupConfiguration();\n if (!configuration) {\n // Backup is not configured correctly, so stop the loop.\n this.downloadLoopRunning = false;\n return;\n }\n\n const result = await this.queryKeyBackup(request.roomId, request.megolmSessionId, configuration);\n\n if (this.stopped) {\n return;\n }\n // We got the encrypted key from backup, let's try to decrypt and import it.\n try {\n await this.decryptAndImport(request, result, configuration);\n } catch (e) {\n this.logger.error(\n `Error while decrypting and importing key backup for session ${request.megolmSessionId}`,\n e,\n );\n }\n // now remove the request from the queue as we've processed it.\n this.queuedRequests.shift();\n } catch (err) {\n if (err instanceof KeyDownloadError) {\n switch (err.code) {\n case KeyDownloadErrorCode.MISSING_DECRYPTION_KEY:\n this.markAsNotFoundInBackup(request.megolmSessionId);\n // continue for next one\n this.queuedRequests.shift();\n break;\n case KeyDownloadErrorCode.NETWORK_ERROR:\n // We don't want to hammer if there is a problem, so wait a bit.\n await sleep(KEY_BACKUP_BACKOFF);\n break;\n case KeyDownloadErrorCode.STOPPED:\n // If the downloader was stopped, we don't want to retry.\n this.downloadLoopRunning = false;\n return;\n }\n } else if (err instanceof KeyDownloadRateLimitError) {\n // we want to retry after the backoff time\n await sleep(err.retryMillis);\n }\n }\n }\n } finally {\n // all pending request have been processed, we can stop the loop.\n this.downloadLoopRunning = false;\n }\n }\n\n /**\n * Query the backup for a key.\n *\n * @param targetRoomId - ID of the room that the session is used in.\n * @param targetSessionId - ID of the session for which to check backup.\n * @param configuration - The backup configuration to use.\n */\n private async queryKeyBackup(\n targetRoomId: string,\n targetSessionId: string,\n configuration: Configuration,\n ): Promise<KeyBackupSession> {\n this.logger.debug(`Checking key backup for session ${targetSessionId}`);\n if (this.stopped) throw new KeyDownloadError(KeyDownloadErrorCode.STOPPED);\n try {\n const res = await this.requestRoomKeyFromBackup(configuration.backupVersion, targetRoomId, targetSessionId);\n this.logger.debug(`Got key from backup for sessionId:${targetSessionId}`);\n return res;\n } catch (e) {\n if (this.stopped) throw new KeyDownloadError(KeyDownloadErrorCode.STOPPED);\n\n this.logger.info(`No luck requesting key backup for session ${targetSessionId}: ${e}`);\n if (e instanceof MatrixError) {\n const errCode = e.data.errcode;\n if (errCode == \"M_NOT_FOUND\") {\n // Unfortunately the spec doesn't give us a way to differentiate between a missing key and a wrong version.\n // Synapse will return:\n // - \"error\": \"Unknown backup version\" if the version is wrong.\n // - \"error\": \"No room_keys found\" if the key is missing.\n // It's useful to know if the key is missing or if the version is wrong.\n // As it's not spec'ed, we fall back on considering the key is not in backup.\n // Notice that this request will be lost if instead the backup got out of sync (updated from other session).\n throw new KeyDownloadError(KeyDownloadErrorCode.MISSING_DECRYPTION_KEY);\n }\n if (e.isRateLimitError()) {\n let waitTime: number | undefined;\n try {\n waitTime = e.getRetryAfterMs() ?? undefined;\n } catch (error) {\n this.logger.warn(\"Error while retrieving a rate-limit retry delay\", error);\n }\n if (waitTime && waitTime > 0) {\n this.logger.info(`Rate limited by server, waiting ${waitTime}ms`);\n }\n throw new KeyDownloadRateLimitError(waitTime ?? KEY_BACKUP_BACKOFF);\n }\n }\n throw new KeyDownloadError(KeyDownloadErrorCode.NETWORK_ERROR);\n }\n }\n\n private async decryptAndImport(\n sessionInfo: SessionInfo,\n data: KeyBackupSession,\n configuration: Configuration,\n ): Promise<void> {\n const sessionsToImport: Record<string, KeyBackupSession> = { [sessionInfo.megolmSessionId]: data };\n\n const keys = await configuration!.decryptor.decryptSessions(sessionsToImport);\n for (const k of keys) {\n k.room_id = sessionInfo.roomId;\n }\n await this.backupManager.importBackedUpRoomKeys(keys, configuration.backupVersion);\n }\n\n /**\n * Gets the current backup configuration or create one if it doesn't exist.\n *\n * When a valid configuration is found it is cached and returned for subsequent calls.\n * Otherwise, if a check is forced or a check has not yet been done, a new check is done.\n *\n * @returns The backup configuration to use or null if there is a configuration problem.\n */\n private async getOrCreateBackupConfiguration(): Promise<Configuration | null> {\n if (this.configuration) {\n return this.configuration;\n }\n\n // We already tried to check the configuration and it failed.\n // We don't want to try again immediately, we will retry if a configuration change is detected.\n if (this.hasConfigurationProblem) {\n return null;\n }\n\n // This method can be called rapidly by several emitted CryptoEvent, so we need to make sure that we don't\n // query the server several times.\n if (this.currentBackupVersionCheck != null) {\n this.logger.debug(`Already checking server version, use current promise`);\n return await this.currentBackupVersionCheck;\n }\n\n this.currentBackupVersionCheck = this.internalCheckFromServer();\n try {\n return await this.currentBackupVersionCheck;\n } finally {\n this.currentBackupVersionCheck = null;\n }\n }\n\n private async internalCheckFromServer(): Promise<Configuration | null> {\n let currentServerVersion = null;\n try {\n currentServerVersion = await this.backupManager.getServerBackupInfo();\n } catch (e) {\n this.logger.debug(`Backup: error while checking server version: ${e}`);\n this.hasConfigurationProblem = true;\n return null;\n }\n this.logger.debug(`Got current backup version from server: ${currentServerVersion?.version}`);\n\n if (currentServerVersion?.algorithm != \"m.megolm_backup.v1.curve25519-aes-sha2\") {\n this.logger.info(`Unsupported algorithm ${currentServerVersion?.algorithm}`);\n this.hasConfigurationProblem = true;\n return null;\n }\n\n if (!currentServerVersion?.version) {\n this.logger.info(`No current key backup`);\n this.hasConfigurationProblem = true;\n return null;\n }\n\n const activeVersion = await this.backupManager.getActiveBackupVersion();\n if (activeVersion == null || currentServerVersion.version != activeVersion) {\n // Either the current backup version on server side is not trusted, or it is out of sync with the active version on the client side.\n this.logger.info(\n `The current backup version on the server (${currentServerVersion.version}) is not trusted. Version we are currently backing up to: ${activeVersion}`,\n );\n this.hasConfigurationProblem = true;\n return null;\n }\n\n const backupKeys = await this.getBackupDecryptionKey();\n if (!backupKeys?.decryptionKey) {\n this.logger.debug(`Not checking key backup for session (no decryption key)`);\n this.hasConfigurationProblem = true;\n return null;\n }\n\n if (activeVersion != backupKeys.backupVersion) {\n this.logger.debug(\n `Version for which we have a decryption key (${backupKeys.backupVersion}) doesn't match the version we are backing up to (${activeVersion})`,\n );\n this.hasConfigurationProblem = true;\n return null;\n }\n\n const authData = currentServerVersion.auth_data as Curve25519AuthData;\n if (authData.public_key != backupKeys.decryptionKey.megolmV1PublicKey.publicKeyBase64) {\n this.logger.debug(`Key backup on server does not match our decryption key`);\n this.hasConfigurationProblem = true;\n return null;\n }\n\n const backupDecryptor = this.backupManager.createBackupDecryptor(backupKeys.decryptionKey);\n this.hasConfigurationProblem = false;\n this.configuration = {\n decryptor: backupDecryptor,\n backupVersion: activeVersion,\n };\n return this.configuration;\n }\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,SAASA,WAAW,QAAQ,wBAAwB;AAEpD,SAASC,YAAY,EAAaC,WAAW,EAAiBC,MAAM,QAAQ,sBAAsB;AAElG,SAASC,SAAS,EAAEC,KAAK,QAAQ,aAAa;AAG9C;AACA,IAAMC,k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AO,IAAI;MACf;MAEA,IAAI2G,aAAa,IAAIE,UAAU,CAAC/B,aAAa,EAAE;QAC3CsB,MAAI,CAAC1G,MAAM,CAACkF,KAAK,gDAAAvF,MAAA,CACkCwH,UAAU,CAAC/B,aAAa,wDAAAzF,MAAA,CAAqDsH,aAAa,MAC7I,CAAC;QACDP,MAAI,CAACpG,uBAAuB,GAAG,IAAI;QACnC,OAAO,IAAI;MACf;MAEA,IAAM+G,QAAQ,GAAGP,oBAAoB,CAACQ,SAA+B;MACrE,IAAID,QAAQ,CAACE,UAAU,IAAIJ,UAAU,CAACC,aAAa,CAACI,iBAAiB,CAACC,eAAe,EAAE;QACnFf,MAAI,CAAC1G,MAAM,CAACkF,KAAK,yDAAyD,CAAC;QAC3EwB,MAAI,CAACpG,uBAAuB,GAAG,IAAI;QACnC,OAAO,IAAI;MACf;MAEA,IAAMoH,eAAe,GAAGhB,MAAI,CAACvG,aAAa,CAACwH,qBAAqB,CAACR,UAAU,CAACC,aAAa,CAAC;MAC1FV,MAAI,CAACpG,uBAAuB,GAAG,KAAK;MACpCoG,MAAI,CAACnG,aAAa,GAAG;QACjB2F,SAAS,EAAEwB,eAAe;QAC1BtC,aAAa,EAAE6B;MACnB,CAAC;MACD,OAAOP,MAAI,CAACnG,aAAa;IAAC;EAC9B;AACJ","ignoreList":[]}
|
@@ -1,98 +0,0 @@
|
|
1
|
-
import { HistoryVisibility as RustHistoryVisibility, OlmMachine } from "@matrix-org/matrix-sdk-crypto-wasm";
|
2
|
-
import { IContent, MatrixEvent } from "../models/event.ts";
|
3
|
-
import { Room } from "../models/room.ts";
|
4
|
-
import { KeyClaimManager } from "./KeyClaimManager.ts";
|
5
|
-
import { RoomMember } from "../models/room-member.ts";
|
6
|
-
import { HistoryVisibility } from "../@types/partials.ts";
|
7
|
-
import { OutgoingRequestsManager } from "./OutgoingRequestsManager.ts";
|
8
|
-
import { DeviceIsolationMode } from "../crypto-api/index.ts";
|
9
|
-
/**
|
10
|
-
* RoomEncryptor: responsible for encrypting messages to a given room
|
11
|
-
*
|
12
|
-
* @internal
|
13
|
-
*/
|
14
|
-
export declare class RoomEncryptor {
|
15
|
-
private readonly olmMachine;
|
16
|
-
private readonly keyClaimManager;
|
17
|
-
private readonly outgoingRequestManager;
|
18
|
-
private readonly room;
|
19
|
-
private encryptionSettings;
|
20
|
-
private readonly prefixedLogger;
|
21
|
-
/** whether the room members have been loaded and tracked for the first time */
|
22
|
-
private lazyLoadedMembersResolved;
|
23
|
-
/**
|
24
|
-
* Ensures that there is only one encryption operation at a time for that room.
|
25
|
-
*
|
26
|
-
* An encryption operation is either a {@link prepareForEncryption} or an {@link encryptEvent} call.
|
27
|
-
*/
|
28
|
-
private currentEncryptionPromise;
|
29
|
-
/**
|
30
|
-
* @param olmMachine - The rust-sdk's OlmMachine
|
31
|
-
* @param keyClaimManager - Our KeyClaimManager, which manages the queue of one-time-key claim requests
|
32
|
-
* @param outgoingRequestManager - The OutgoingRequestManager, which manages the queue of outgoing requests.
|
33
|
-
* @param room - The room we want to encrypt for
|
34
|
-
* @param encryptionSettings - body of the m.room.encryption event currently in force in this room
|
35
|
-
*/
|
36
|
-
constructor(olmMachine: OlmMachine, keyClaimManager: KeyClaimManager, outgoingRequestManager: OutgoingRequestsManager, room: Room, encryptionSettings: IContent);
|
37
|
-
/**
|
38
|
-
* Handle a new `m.room.encryption` event in this room
|
39
|
-
*
|
40
|
-
* @param config - The content of the encryption event
|
41
|
-
*/
|
42
|
-
onCryptoEvent(config: IContent): void;
|
43
|
-
/**
|
44
|
-
* Handle a new `m.room.member` event in this room
|
45
|
-
*
|
46
|
-
* @param member - new membership state
|
47
|
-
*/
|
48
|
-
onRoomMembership(member: RoomMember): void;
|
49
|
-
/**
|
50
|
-
* Prepare to encrypt events in this room.
|
51
|
-
*
|
52
|
-
* This ensures that we have a megolm session ready to use and that we have shared its key with all the devices
|
53
|
-
* in the room.
|
54
|
-
* @param globalBlacklistUnverifiedDevices - When `true`, and `deviceIsolationMode` is `AllDevicesIsolationMode`,
|
55
|
-
* will not send encrypted messages to unverified devices.
|
56
|
-
* Ignored when `deviceIsolationMode` is `OnlySignedDevicesIsolationMode`.
|
57
|
-
* @param deviceIsolationMode - The device isolation mode. See {@link DeviceIsolationMode}.
|
58
|
-
*/
|
59
|
-
prepareForEncryption(globalBlacklistUnverifiedDevices: boolean, deviceIsolationMode: DeviceIsolationMode): Promise<void>;
|
60
|
-
/**
|
61
|
-
* Encrypt an event for this room, or prepare for encryption.
|
62
|
-
*
|
63
|
-
* This will ensure that we have a megolm session for this room, share it with the devices in the room, and
|
64
|
-
* then, if an event is provided, encrypt it using the session.
|
65
|
-
*
|
66
|
-
* @param event - Event to be encrypted, or null if only preparing for encryption (in which case we will pre-share the room key).
|
67
|
-
* @param globalBlacklistUnverifiedDevices - When `true`, and `deviceIsolationMode` is `AllDevicesIsolationMode`,
|
68
|
-
* will not send encrypted messages to unverified devices.
|
69
|
-
* Ignored when `deviceIsolationMode` is `OnlySignedDevicesIsolationMode`.
|
70
|
-
* @param deviceIsolationMode - The device isolation mode. See {@link DeviceIsolationMode}.
|
71
|
-
*/
|
72
|
-
encryptEvent(event: MatrixEvent | null, globalBlacklistUnverifiedDevices: boolean, deviceIsolationMode: DeviceIsolationMode): Promise<void>;
|
73
|
-
/**
|
74
|
-
* Prepare to encrypt events in this room.
|
75
|
-
*
|
76
|
-
* This ensures that we have a megolm session ready to use and that we have shared its key with all the devices
|
77
|
-
* in the room.
|
78
|
-
*
|
79
|
-
* @param logger - a place to write diagnostics to
|
80
|
-
* @param globalBlacklistUnverifiedDevices - When `true`, and `deviceIsolationMode` is `AllDevicesIsolationMode`,
|
81
|
-
* will not send encrypted messages to unverified devices.
|
82
|
-
* Ignored when `deviceIsolationMode` is `OnlySignedDevicesIsolationMode`.
|
83
|
-
* @param deviceIsolationMode - The device isolation mode. See {@link DeviceIsolationMode}.
|
84
|
-
*/
|
85
|
-
private ensureEncryptionSession;
|
86
|
-
/**
|
87
|
-
* Discard any existing group session for this room
|
88
|
-
*/
|
89
|
-
forceDiscardSession(): Promise<void>;
|
90
|
-
private encryptEventInner;
|
91
|
-
}
|
92
|
-
/**
|
93
|
-
* Convert a HistoryVisibility to a RustHistoryVisibility
|
94
|
-
* @param visibility - HistoryVisibility enum
|
95
|
-
* @returns a RustHistoryVisibility enum
|
96
|
-
*/
|
97
|
-
export declare function toRustHistoryVisibility(visibility: HistoryVisibility): RustHistoryVisibility;
|
98
|
-
//# sourceMappingURL=RoomEncryptor.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"RoomEncryptor.d.ts","sourceRoot":"","sources":["../../src/rust-crypto/RoomEncryptor.ts"],"names":[],"mappings":"AAiBA,OAAO,EAIH,iBAAiB,IAAI,qBAAqB,EAC1C,UAAU,EAIb,MAAM,oCAAoC,CAAC;AAG5C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAGvE,OAAO,EAAE,mBAAmB,EAA2B,MAAM,wBAAwB,CAAC;AAEtF;;;;GAIG;AACH,qBAAa,aAAa;IAqBlB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IACvC,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,kBAAkB;IAxB9B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IAExC,+EAA+E;IAC/E,OAAO,CAAC,yBAAyB,CAAS;IAE1C;;;;OAIG;IACH,OA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