@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 +0,0 @@
|
|
1
|
-
{"version":3,"file":"rust-crypto.js","names":["anotherjson","RustSdkCryptoJs","KnownMembership","MatrixEventEvent","DecryptionError","logger","LogSpan","Method","RoomEncryptor","OutgoingRequestProcessor","KeyClaimManager","logDuration","MapWithDefault","CrossSigningKey","DecryptionFailureCode","DeviceVerificationStatus","EventShieldColour","EventShieldReason","UserVerificationStatus","encodeRecoveryKey","deriveRecoveryKeyFromPassphrase","AllDevicesIsolationMode","DeviceIsolationModeKind","CryptoEvent","deviceKeysToDeviceMap","rustDeviceToJsDevice","SECRET_STORAGE_ALGORITHM_V1_AES","CrossSigningIdentity","secretStorageCanAccessSecrets","secretStorageContainsCrossSigningKeys","isVerificationEvent","RustVerificationRequest","verificationMethodIdentifierToMethod","EventType","MsgType","TypedEventEmitter","decryptionKeyMatchesKeyBackupInfo","RustBackupManager","TypedReEmitter","randomString","ClientStoppedError","decodeBase64","encodeBase64","OutgoingRequestsManager","PerSessionKeyBackupDownloader","DehydratedDeviceManager","VerificationMethod","keyFromAuthData","ALL_VERIFICATION_METHODS","Sas","ScanQrCode","ShowQrCode","Reciprocate","RustCrypto","constructor","olmMachine","http","userId","_deviceId","secretStorage","cryptoCallbacks","_defineProperty","outgoingRequestProcessor","outgoingRequestsManager","keyClaimManager","backupManager","perSessionBackupDownloader","dehydratedDeviceManager","eventDecryptor","EventDecryptor","reemitter","reEmit","KeyBackupStatus","KeyBackupSessionsRemaining","KeyBackupFailed","KeyBackupDecryptionKeyCached","crossSigningIdentity","checkKeyBackupAndEnable","getOlmMachineOrThrow","stopped","globalErrorOnUnknownDevices","_v","stop","close","encryptEvent","event","_room","_this","_asyncToGenerator","roomId","getRoomId","encryptor","roomEncryptors","Error","concat","globalBlacklistUnverifiedDevices","deviceIsolationMode","decryptEvent","_this2","attemptEventDecryption","getEventEncryptionInfo","_event$getSenderKey","ret","senderKey","getSenderKey","undefined","algorithm","getWireContent","encrypted","authenticated","mismatchedSender","checkUserTrust","getStoredCrossSigningForUser","checkOwnCrossSigningTrust","getBackupDecryptor","backupInfo","privKey","_this3","Uint8Array","backupDecryptionKey","BackupDecryptionKey","fromBase64","createBackupDecryptor","importBackedUpRoomKeys","keys","backupVersion","opts","_this4","getVersion","versions","getVersions","matrix_sdk_crypto","git_sha","vodozemac","setDeviceIsolationMode","isolationMode","isEncryptionEnabledInRoom","_this5","roomSettings","getRoomSettings","RoomId","Boolean","getOwnDeviceKeys","_this6","identityKeys","ed25519","toBase64","curve25519","prepareToEncrypt","room","prepareForEncryption","forceDiscardSession","_this$roomEncryptors$","exportRoomKeys","_this7","raw","JSON","parse","exportRoomKeysAsJson","_this8","importRoomKeys","_this9","importRoomKeysAsJson","_this10","userHasCrossSigningKeys","_arguments","arguments","_this11","length","downloadUncached","rustTrackedUsers","trackedUsers","rustTrackedUser","u","toString","request","queryKeysForUsers","clone","makeOutgoingRequest","userIdentity","getIdentity","free","_keyResult$master_key","keyResult","downloadDeviceList","Set","master_keys","Object","values","getUserDeviceInfo","userIds","_arguments2","_this12","deviceMapByUserId","Map","forEach","rustUserId","add","untrackedUsers","has","set","getUserDevices","size","queryResult","entries","device_keys","_ref","deviceKeys","_this13","UserId","userDevices","deviceArray","devices","map","device","deviceId","d","_this14","queryBody","user","authedRequest","Post","prefix","getTrustCrossSignedDevices","_trustCrossSignedDevices","setTrustCrossSignedDevices","val","setDeviceVerified","_arguments3","_this15","verified","getDevice","DeviceId","setLocalTrust","LocalTrust","Verified","Unset","crossSignDevice","_this16","outgoingRequest","verify","getDeviceVerificationStatus","_this17","signedByOwner","isCrossSignedByOwner","crossSigningVerified","isCrossSigningTrusted","localVerified","isLocallyTrusted","trustCrossSignedDevices","getUserVerificationStatus","_this18","isVerified","wasVerified","wasPreviouslyVerified","needsUserApproval","UserIdentity","identityNeedsUserApproval","pinCurrentUserIdentity","_this19","OwnUserIdentity","pinCurrentMasterKey","isCrossSigningReady","_this20","privateKeysInSecretStorage","privateKeysCachedLocally","getCrossSigningStatus","hasKeysInCache","masterKey","selfSigningKey","userSigningKey","identity","getOwnIdentity","getCrossSigningKeyId","_arguments4","_this21","type","Master","crossSigningStatus","privateKeysOnDevice","hasMaster","hasUserSigning","hasSelfSigning","key","SelfSigning","UserSigning","parsedKey","bootstrapCrossSigning","_this22","isSecretStorageReady","_this23","secretsToCheck","keyBackupEnabled","getActiveBackupVersion","push","bootstrapSecretStorage","_arguments5","_this24","createSecretStorageKey","setupNewSecretStorage","setupNewKeyBackup","isNewSecretStorageKeyNeeded","secretStorageHasAESKey","info","recoveryKey","addSecretStorageKeyToSecretStorage","hasPrivateKeys","crossSigningPrivateKeys","exportCrossSigningKeys","self_signing_key","store","resetKeyBackup","secretStorageKey","_this25","_secretStorageKey$key","_secretStorageKey$key2","_this25$cryptoCallbac","_this25$cryptoCallbac2","secretStorageKeyObject","addKey","passphrase","keyInfo","name","privateKey","setDefaultKeyId","keyId","cacheSecretStorageKey","call","_this26","secretStorageKeyTuple","getKey","_this27","publicKeysOnDevice","createRecoveryKeyFromPassphrase","password","_this28","salt","RECOVERY_KEY_DERIVATION_ITERATIONS","iterations","encodedPrivateKey","globalThis","crypto","getRandomValues","getEncryptionInfoForEvent","_this29","getVerificationRequestsToDeviceInProgress","requests","getVerificationRequests","filter","_supportedVerificationMethods","findVerificationRequestDMInProgress","find","_request$roomId","requestVerificationDM","_this30","methods","method","verificationEventContent","verificationRequestContent","eventId","sendVerificationRequestContent","requestVerification","EventId","_this31","txId","event_id","Put","encodeURIComponent","setSupportedVerificationMethods","requestOwnUserVerification","_this32","requestDeviceVerification","_this33","getSessionBackupPrivateKey","_this34","backupKeys","getBackupKeys","decryptionKey","Buffer","from","storeSessionBackupPrivateKey","version","_this35","base64Key","saveBackupDecryptionKey","loadSessionBackupPrivateKeyFromSecretStorage","_this36","backupKey","get","keyBackupInfo","getServerBackupInfo","getActiveSessionBackupVersion","_this37","getKeyBackupInfo","_this38","isKeyBackupTrusted","_this39","_this40","deleteKeyBackupVersion","_this41","_this42","setupKeyBackup","o","signObject","obj","_this43","sigs","signatures","unsigned","userSignatures","canonalizedJson","stringify","sign","asJSON","_objectSpread","fromEntries","restoreKeyBackupWithPassphrase","_this44","auth_data","restoreKeyBackup","_this45","decodedDecryptionKey","requestKeyBackupVersion","backupDecryptor","_opts$progressCallbac","progressCallback","stage","isDehydrationSupported","_this46","isSupported","startDehydration","createNewKey","_this47","start","importSecretsBundle","secrets","_this48","secretsBundle","SecretsBundle","from_json","exportSecretsBundle","_this49","to_json","encryptToDeviceMessages","eventType","payload","_this50","uniqueUsers","_ref2","ensureSessionsForUsers","Array","batch","RoomMessageEncrypted","Promise","all","_ref4","_ref3","encryptedPayload","encryptToDeviceEvent","warn","_x","apply","receiveSyncChanges","_ref5","_this51","events","oneTimeKeysCounts","unusedFallbackKeys","DeviceLists","result","preprocessToDeviceMessages","_this52","processed","message","KeyVerificationRequest","sender","transactionId","content","transaction_id","onIncomingKeyVerificationRequest","processKeyCounts","_this53","mapOneTimeKeysCount","setUnusedFallbackKeys","processDeviceLists","deviceLists","_this54","_deviceLists$changed","_deviceLists$left","changed","left","onCryptoEvent","_this55","config","getContent","settings","RoomSettings","EncryptionAlgorithm","MegolmV1AesSha2","sessionRotationPeriodMs","rotation_period_ms","sessionRotationPeriodMessages","rotation_period_msgs","setRoomSettings","e","existingEncryptor","onSyncCompleted","syncState","doProcessOutgoingRequests","catch","getVerificationRequest","emit","VerificationRequestReceived","onRoomMembership","member","oldMembership","enc","onRoomKeysUpdated","_this56","onRoomKeyUpdated","maybeUploadKey","_this57","debug","sessionId","pendingList","getEventsPendingRoomKey","getId","_loop","ev","attemptDecryption","isRetry","_e","onRoomKeysWithheld","withheld","_this58","session","onUserIdentityUpdated","_this59","newVerification","UserTrustStatusChanged","KeysChanged","onDevicesUpdated","_this60","WillUpdateDevices","DevicesUpdated","handleSecretReceived","value","_this61","handleBackupSecretReceived","checkSecrets","_this62","pendingValues","getSecretsFromInbox","deleteSecretsFromInbox","onLiveEventFromSync","_this63","isState","getUnsigned","processEvent","_ref7","evt","onKeyVerificationEvent","_x2","isDecryptionFailure","isEncrypted","TIMEOUT_DELAY","timeoutId","setTimeout","off","Decrypted","onDecrypted","decryptedEvent","error","clearTimeout","on","_this64","getType","getSender","receiveVerificationEvent","state_key","getStateKey","origin_server_ts","getTs","RoomMessage","msgtype","_this65","_this66","addEventToPendingList","trustRequirement","kind","TrustRequirement","Untrusted","OnlySignedDevicesIsolationMode","CrossSignedOrLegacy","res","decryptRoomEvent","stringifyEvent","DecryptionSettings","removeEventFromPendingList","clearEvent","claimedEd25519Key","senderClaimedEd25519Key","senderCurve25519Key","forwardingCurve25519KeyChain","err","MegolmDecryptionError","onMegolmDecryptionError","UNKNOWN_ERROR","serverBackupInfo","errorDetails","sender_key","session_id","code","DecryptionErrorCode","MissingRoomKey","UnknownMessageIndex","onDecryptionKeyMissingError","membership","getMembershipAtEvent","Join","Invite","HISTORICAL_MESSAGE_USER_NOT_JOINED","deviceCreationTimeMs","HISTORICAL_MESSAGE_NO_KEY_BACKUP","isKeyBackupDownloadConfigured","HISTORICAL_MESSAGE_BACKUP_UNCONFIGURED","HISTORICAL_MESSAGE_WORKING_BACKUP","maybe_withheld","failureCode","MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE","MEGOLM_KEY_WITHHELD","MEGOLM_UNKNOWN_INBOUND_SESSION_ID","OLM_UNKNOWN_MESSAGE_INDEX","SenderIdentityPreviouslyVerified","SENDER_IDENTITY_PREVIOUSLY_VERIFIED","UnknownSenderDevice","UNKNOWN_SENDER_DEVICE","UnsignedSenderDevice","UNSIGNED_SENDER_DEVICE","description","_this67","getClearContent","status","shieldColour","NONE","shieldReason","encryptionInfo","getRoomEventEncryptionInfo","rustEncryptionInfoToJsEncryptionInfo","roomPendingEvents","eventsPendingKey","sessionPendingEvents","getOrCreate","delete","getWireType","shieldState","color","ShieldColor","Grey","GREY","None","RED","UNVERIFIED_IDENTITY","UNSIGNED_DEVICE","AUTHENTICITY_NOT_GUARANTEED","UNKNOWN_DEVICE","UNKNOWN"],"sources":["../../src/rust-crypto/rust-crypto.ts"],"sourcesContent":["/*\nCopyright 2022-2023 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 anotherjson from \"another-json\";\nimport * as RustSdkCryptoJs from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport type { IEventDecryptionResult, IMegolmSessionData } from \"../@types/crypto.ts\";\nimport { KnownMembership } from \"../@types/membership.ts\";\nimport type { IDeviceLists, IToDeviceEvent } from \"../sync-accumulator.ts\";\nimport type { IEncryptedEventInfo } from \"../crypto/api.ts\";\nimport type { ToDevicePayload, ToDeviceBatch } from \"../models/ToDeviceMessage.ts\";\nimport { MatrixEvent, MatrixEventEvent } from \"../models/event.ts\";\nimport { Room } from \"../models/room.ts\";\nimport { RoomMember } from \"../models/room-member.ts\";\nimport {\n BackupDecryptor,\n CryptoBackend,\n DecryptionError,\n OnSyncCompletedData,\n} from \"../common-crypto/CryptoBackend.ts\";\nimport { logger, Logger, LogSpan } from \"../logger.ts\";\nimport { IHttpOpts, MatrixHttpApi, Method } from \"../http-api/index.ts\";\nimport { RoomEncryptor } from \"./RoomEncryptor.ts\";\nimport { OutgoingRequestProcessor } from \"./OutgoingRequestProcessor.ts\";\nimport { KeyClaimManager } from \"./KeyClaimManager.ts\";\nimport { logDuration, MapWithDefault } from \"../utils.ts\";\nimport {\n BackupTrustInfo,\n BootstrapCrossSigningOpts,\n CreateSecretStorageOpts,\n CrossSigningKey,\n CrossSigningKeyInfo,\n CrossSigningStatus,\n CryptoApi,\n CryptoCallbacks,\n DecryptionFailureCode,\n DeviceVerificationStatus,\n EventEncryptionInfo,\n EventShieldColour,\n EventShieldReason,\n GeneratedSecretStorageKey,\n ImportRoomKeysOpts,\n KeyBackupCheck,\n KeyBackupInfo,\n OwnDeviceKeys,\n UserVerificationStatus,\n VerificationRequest,\n encodeRecoveryKey,\n deriveRecoveryKeyFromPassphrase,\n DeviceIsolationMode,\n AllDevicesIsolationMode,\n DeviceIsolationModeKind,\n CryptoEvent,\n CryptoEventHandlerMap,\n KeyBackupRestoreOpts,\n KeyBackupRestoreResult,\n} from \"../crypto-api/index.ts\";\nimport { deviceKeysToDeviceMap, rustDeviceToJsDevice } from \"./device-converter.ts\";\nimport { IDownloadKeyResult, IQueryKeysRequest } from \"../client.ts\";\nimport { Device, DeviceMap } from \"../models/device.ts\";\nimport { SECRET_STORAGE_ALGORITHM_V1_AES, ServerSideSecretStorage } from \"../secret-storage.ts\";\nimport { CrossSigningIdentity } from \"./CrossSigningIdentity.ts\";\nimport { secretStorageCanAccessSecrets, secretStorageContainsCrossSigningKeys } from \"./secret-storage.ts\";\nimport { isVerificationEvent, RustVerificationRequest, verificationMethodIdentifierToMethod } from \"./verification.ts\";\nimport { EventType, MsgType } from \"../@types/event.ts\";\nimport { TypedEventEmitter } from \"../models/typed-event-emitter.ts\";\nimport { decryptionKeyMatchesKeyBackupInfo, RustBackupManager } from \"./backup.ts\";\nimport { TypedReEmitter } from \"../ReEmitter.ts\";\nimport { randomString } from \"../randomstring.ts\";\nimport { ClientStoppedError } from \"../errors.ts\";\nimport { ISignatures } from \"../@types/signed.ts\";\nimport { decodeBase64, encodeBase64 } from \"../base64.ts\";\nimport { OutgoingRequestsManager } from \"./OutgoingRequestsManager.ts\";\nimport { PerSessionKeyBackupDownloader } from \"./PerSessionKeyBackupDownloader.ts\";\nimport { DehydratedDeviceManager } from \"./DehydratedDeviceManager.ts\";\nimport { VerificationMethod } from \"../types.ts\";\nimport { keyFromAuthData } from \"../common-crypto/key-passphrase.ts\";\n\nconst ALL_VERIFICATION_METHODS = [\n VerificationMethod.Sas,\n VerificationMethod.ScanQrCode,\n VerificationMethod.ShowQrCode,\n VerificationMethod.Reciprocate,\n];\n\ninterface ISignableObject {\n signatures?: ISignatures;\n unsigned?: object;\n}\n\n/**\n * An implementation of {@link CryptoBackend} using the Rust matrix-sdk-crypto.\n *\n * @internal\n */\nexport class RustCrypto extends TypedEventEmitter<RustCryptoEvents, CryptoEventHandlerMap> implements CryptoBackend {\n /**\n * The number of iterations to use when deriving a recovery key from a passphrase.\n */\n private readonly RECOVERY_KEY_DERIVATION_ITERATIONS = 500000;\n\n private _trustCrossSignedDevices = true;\n private deviceIsolationMode: DeviceIsolationMode = new AllDevicesIsolationMode(false);\n\n /** whether {@link stop} has been called */\n private stopped = false;\n\n /** mapping of roomId → encryptor class */\n private roomEncryptors: Record<string, RoomEncryptor> = {};\n\n private eventDecryptor: EventDecryptor;\n private keyClaimManager: KeyClaimManager;\n private outgoingRequestProcessor: OutgoingRequestProcessor;\n private crossSigningIdentity: CrossSigningIdentity;\n private readonly backupManager: RustBackupManager;\n private outgoingRequestsManager: OutgoingRequestsManager;\n private readonly perSessionBackupDownloader: PerSessionKeyBackupDownloader;\n private readonly dehydratedDeviceManager: DehydratedDeviceManager;\n private readonly reemitter = new TypedReEmitter<RustCryptoEvents, CryptoEventHandlerMap>(this);\n\n public constructor(\n private readonly logger: Logger,\n\n /** The `OlmMachine` from the underlying rust crypto sdk. */\n private readonly olmMachine: RustSdkCryptoJs.OlmMachine,\n\n /**\n * Low-level HTTP interface: used to make outgoing requests required by the rust SDK.\n *\n * We expect it to set the access token, etc.\n */\n private readonly http: MatrixHttpApi<IHttpOpts & { onlyData: true }>,\n\n /** The local user's User ID. */\n private readonly userId: string,\n\n /** The local user's Device ID. */\n _deviceId: string,\n\n /** Interface to server-side secret storage */\n private readonly secretStorage: ServerSideSecretStorage,\n\n /** Crypto callbacks provided by the application */\n private readonly cryptoCallbacks: CryptoCallbacks,\n ) {\n super();\n this.outgoingRequestProcessor = new OutgoingRequestProcessor(olmMachine, http);\n this.outgoingRequestsManager = new OutgoingRequestsManager(\n this.logger,\n olmMachine,\n this.outgoingRequestProcessor,\n );\n\n this.keyClaimManager = new KeyClaimManager(olmMachine, this.outgoingRequestProcessor);\n\n this.backupManager = new RustBackupManager(olmMachine, http, this.outgoingRequestProcessor);\n this.perSessionBackupDownloader = new PerSessionKeyBackupDownloader(\n this.logger,\n this.olmMachine,\n this.http,\n this.backupManager,\n );\n this.dehydratedDeviceManager = new DehydratedDeviceManager(\n this.logger,\n olmMachine,\n http,\n this.outgoingRequestProcessor,\n secretStorage,\n );\n this.eventDecryptor = new EventDecryptor(this.logger, olmMachine, this.perSessionBackupDownloader);\n\n this.reemitter.reEmit(this.backupManager, [\n CryptoEvent.KeyBackupStatus,\n CryptoEvent.KeyBackupSessionsRemaining,\n CryptoEvent.KeyBackupFailed,\n CryptoEvent.KeyBackupDecryptionKeyCached,\n ]);\n\n this.crossSigningIdentity = new CrossSigningIdentity(olmMachine, this.outgoingRequestProcessor, secretStorage);\n\n // Check and start in background the key backup connection\n this.checkKeyBackupAndEnable();\n }\n\n /**\n * Return the OlmMachine only if {@link RustCrypto#stop} has not been called.\n *\n * This allows us to better handle race conditions where the client is stopped before or during a crypto API call.\n *\n * @throws ClientStoppedError if {@link RustCrypto#stop} has been called.\n */\n private getOlmMachineOrThrow(): RustSdkCryptoJs.OlmMachine {\n if (this.stopped) {\n throw new ClientStoppedError();\n }\n return this.olmMachine;\n }\n\n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n //\n // CryptoBackend implementation\n //\n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n\n public set globalErrorOnUnknownDevices(_v: boolean) {\n // Not implemented for rust crypto.\n }\n\n public get globalErrorOnUnknownDevices(): boolean {\n // Not implemented for rust crypto.\n return false;\n }\n\n public stop(): void {\n // stop() may be called multiple times, but attempting to close() the OlmMachine twice\n // will cause an error.\n if (this.stopped) {\n return;\n }\n this.stopped = true;\n\n this.keyClaimManager.stop();\n this.backupManager.stop();\n this.outgoingRequestsManager.stop();\n this.perSessionBackupDownloader.stop();\n this.dehydratedDeviceManager.stop();\n\n // make sure we close() the OlmMachine; doing so means that all the Rust objects will be\n // cleaned up; in particular, the indexeddb connections will be closed, which means they\n // can then be deleted.\n this.olmMachine.close();\n }\n\n public async encryptEvent(event: MatrixEvent, _room: Room): Promise<void> {\n const roomId = event.getRoomId()!;\n const encryptor = this.roomEncryptors[roomId];\n\n if (!encryptor) {\n throw new Error(`Cannot encrypt event in unconfigured room ${roomId}`);\n }\n\n await encryptor.encryptEvent(event, this.globalBlacklistUnverifiedDevices, this.deviceIsolationMode);\n }\n\n public async decryptEvent(event: MatrixEvent): Promise<IEventDecryptionResult> {\n const roomId = event.getRoomId();\n if (!roomId) {\n // presumably, a to-device message. These are normally decrypted in preprocessToDeviceMessages\n // so the fact it has come back here suggests that decryption failed.\n //\n // once we drop support for the libolm crypto implementation, we can stop passing to-device messages\n // through decryptEvent and hence get rid of this case.\n throw new Error(\"to-device event was not decrypted in preprocessToDeviceMessages\");\n }\n return await this.eventDecryptor.attemptEventDecryption(event, this.deviceIsolationMode);\n }\n\n /**\n * Implementation of (deprecated) {@link MatrixClient#getEventEncryptionInfo}.\n *\n * @param event - event to inspect\n */\n public getEventEncryptionInfo(event: MatrixEvent): IEncryptedEventInfo {\n const ret: Partial<IEncryptedEventInfo> = {};\n\n ret.senderKey = event.getSenderKey() ?? undefined;\n ret.algorithm = event.getWireContent().algorithm;\n\n if (!ret.senderKey || !ret.algorithm) {\n ret.encrypted = false;\n return ret as IEncryptedEventInfo;\n }\n ret.encrypted = true;\n ret.authenticated = true;\n ret.mismatchedSender = true;\n return ret as IEncryptedEventInfo;\n }\n\n /**\n * Implementation of {@link CryptoBackend#checkUserTrust}.\n *\n * Stub for backwards compatibility.\n *\n */\n public checkUserTrust(userId: string): UserVerificationStatus {\n return new UserVerificationStatus(false, false, false);\n }\n\n /**\n * Get the cross signing information for a given user.\n *\n * The cross-signing API is currently UNSTABLE and may change without notice.\n *\n * @param userId - the user ID to get the cross-signing info for.\n *\n * @returns the cross signing information for the user.\n */\n public getStoredCrossSigningForUser(userId: string): null {\n // TODO\n return null;\n }\n\n /**\n * This function is unneeded for the rust-crypto.\n * The cross signing key import and the device verification are done in {@link CryptoApi#bootstrapCrossSigning}\n *\n * The function is stub to keep the compatibility with the old crypto.\n * More information: https://github.com/vector-im/element-web/issues/25648\n *\n * Implementation of {@link CryptoBackend#checkOwnCrossSigningTrust}\n */\n public async checkOwnCrossSigningTrust(): Promise<void> {\n return;\n }\n\n /**\n * Implementation of {@link CryptoBackend#getBackupDecryptor}.\n */\n public async getBackupDecryptor(backupInfo: KeyBackupInfo, privKey: ArrayLike<number>): Promise<BackupDecryptor> {\n if (!(privKey instanceof Uint8Array)) {\n throw new Error(`getBackupDecryptor: expects Uint8Array`);\n }\n\n if (backupInfo.algorithm != \"m.megolm_backup.v1.curve25519-aes-sha2\") {\n throw new Error(`getBackupDecryptor: Unsupported algorithm ${backupInfo.algorithm}`);\n }\n\n const backupDecryptionKey = RustSdkCryptoJs.BackupDecryptionKey.fromBase64(encodeBase64(privKey));\n if (!decryptionKeyMatchesKeyBackupInfo(backupDecryptionKey, backupInfo)) {\n throw new Error(`getBackupDecryptor: key backup on server does not match the decryption key`);\n }\n\n return this.backupManager.createBackupDecryptor(backupDecryptionKey);\n }\n\n /**\n * Implementation of {@link CryptoBackend#importBackedUpRoomKeys}.\n */\n public async importBackedUpRoomKeys(\n keys: IMegolmSessionData[],\n backupVersion: string,\n opts?: ImportRoomKeysOpts,\n ): Promise<void> {\n return await this.backupManager.importBackedUpRoomKeys(keys, backupVersion, opts);\n }\n\n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n //\n // CryptoApi implementation\n //\n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n\n public globalBlacklistUnverifiedDevices = false;\n\n /**\n * Implementation of {@link CryptoApi#getVersion}.\n */\n public getVersion(): string {\n const versions = RustSdkCryptoJs.getVersions();\n return `Rust SDK ${versions.matrix_sdk_crypto} (${versions.git_sha}), Vodozemac ${versions.vodozemac}`;\n }\n\n /**\n * Implementation of {@link CryptoApi#setDeviceIsolationMode}.\n */\n public setDeviceIsolationMode(isolationMode: DeviceIsolationMode): void {\n this.deviceIsolationMode = isolationMode;\n }\n\n /**\n * Implementation of {@link CryptoApi#isEncryptionEnabledInRoom}.\n */\n public async isEncryptionEnabledInRoom(roomId: string): Promise<boolean> {\n const roomSettings: RustSdkCryptoJs.RoomSettings | undefined = await this.olmMachine.getRoomSettings(\n new RustSdkCryptoJs.RoomId(roomId),\n );\n return Boolean(roomSettings?.algorithm);\n }\n\n /**\n * Implementation of {@link CryptoApi#getOwnDeviceKeys}.\n */\n public async getOwnDeviceKeys(): Promise<OwnDeviceKeys> {\n const keys = this.olmMachine.identityKeys;\n return { ed25519: keys.ed25519.toBase64(), curve25519: keys.curve25519.toBase64() };\n }\n\n public prepareToEncrypt(room: Room): void {\n const encryptor = this.roomEncryptors[room.roomId];\n\n if (encryptor) {\n encryptor.prepareForEncryption(this.globalBlacklistUnverifiedDevices, this.deviceIsolationMode);\n }\n }\n\n public forceDiscardSession(roomId: string): Promise<void> {\n return this.roomEncryptors[roomId]?.forceDiscardSession();\n }\n\n public async exportRoomKeys(): Promise<IMegolmSessionData[]> {\n const raw = await this.olmMachine.exportRoomKeys(() => true);\n return JSON.parse(raw);\n }\n\n public async exportRoomKeysAsJson(): Promise<string> {\n return await this.olmMachine.exportRoomKeys(() => true);\n }\n\n public async importRoomKeys(keys: IMegolmSessionData[], opts?: ImportRoomKeysOpts): Promise<void> {\n return await this.backupManager.importRoomKeys(keys, opts);\n }\n\n public async importRoomKeysAsJson(keys: string, opts?: ImportRoomKeysOpts): Promise<void> {\n return await this.backupManager.importRoomKeysAsJson(keys, opts);\n }\n\n /**\n * Implementation of {@link CryptoApi.userHasCrossSigningKeys}.\n */\n public async userHasCrossSigningKeys(userId = this.userId, downloadUncached = false): Promise<boolean> {\n // TODO: could probably do with a more efficient way of doing this than returning the whole set and searching\n const rustTrackedUsers: Set<RustSdkCryptoJs.UserId> = await this.olmMachine.trackedUsers();\n let rustTrackedUser: RustSdkCryptoJs.UserId | undefined;\n for (const u of rustTrackedUsers) {\n if (userId === u.toString()) {\n rustTrackedUser = u;\n break;\n }\n }\n\n if (rustTrackedUser !== undefined) {\n if (userId === this.userId) {\n /* make sure we have an *up-to-date* idea of the user's cross-signing keys. This is important, because if we\n * return \"false\" here, we will end up generating new cross-signing keys and replacing the existing ones.\n */\n const request = this.olmMachine.queryKeysForUsers(\n // clone as rust layer will take ownership and it's reused later\n [rustTrackedUser.clone()],\n );\n await this.outgoingRequestProcessor.makeOutgoingRequest(request);\n }\n const userIdentity = await this.olmMachine.getIdentity(rustTrackedUser);\n userIdentity?.free();\n return userIdentity !== undefined;\n } else if (downloadUncached) {\n // Download the cross signing keys and check if the master key is available\n const keyResult = await this.downloadDeviceList(new Set([userId]));\n const keys = keyResult.master_keys?.[userId];\n\n // No master key\n if (!keys) return false;\n\n // `keys` is an object with { [`ed25519:${pubKey}`]: pubKey }\n // We assume only a single key, and we want the bare form without type\n // prefix, so we select the values.\n return Boolean(Object.values(keys.keys)[0]);\n } else {\n return false;\n }\n }\n\n /**\n * Get the device information for the given list of users.\n *\n * @param userIds - The users to fetch.\n * @param downloadUncached - If true, download the device list for users whose device list we are not\n * currently tracking. Defaults to false, in which case such users will not appear at all in the result map.\n *\n * @returns A map `{@link DeviceMap}`.\n */\n public async getUserDeviceInfo(userIds: string[], downloadUncached = false): Promise<DeviceMap> {\n const deviceMapByUserId = new Map<string, Map<string, Device>>();\n const rustTrackedUsers: Set<RustSdkCryptoJs.UserId> = await this.getOlmMachineOrThrow().trackedUsers();\n\n // Convert RustSdkCryptoJs.UserId to a `Set<string>`\n const trackedUsers = new Set<string>();\n rustTrackedUsers.forEach((rustUserId) => trackedUsers.add(rustUserId.toString()));\n\n // Keep untracked user to download their keys after\n const untrackedUsers: Set<string> = new Set();\n\n for (const userId of userIds) {\n // if this is a tracked user, we can just fetch the device list from the rust-sdk\n // (NB: this is probably ok even if we race with a leave event such that we stop tracking the user's\n // devices: the rust-sdk will return the last-known device list, which will be good enough.)\n if (trackedUsers.has(userId)) {\n deviceMapByUserId.set(userId, await this.getUserDevices(userId));\n } else {\n untrackedUsers.add(userId);\n }\n }\n\n // for any users whose device lists we are not tracking, fall back to downloading the device list\n // over HTTP.\n if (downloadUncached && untrackedUsers.size >= 1) {\n const queryResult = await this.downloadDeviceList(untrackedUsers);\n Object.entries(queryResult.device_keys).forEach(([userId, deviceKeys]) =>\n deviceMapByUserId.set(userId, deviceKeysToDeviceMap(deviceKeys)),\n );\n }\n\n return deviceMapByUserId;\n }\n\n /**\n * Get the device list for the given user from the olm machine\n * @param userId - Rust SDK UserId\n */\n private async getUserDevices(userId: string): Promise<Map<string, Device>> {\n const rustUserId = new RustSdkCryptoJs.UserId(userId);\n\n // For reasons I don't really understand, the Javascript FinalizationRegistry doesn't seem to run the\n // registered callbacks when `userDevices` goes out of scope, nor when the individual devices in the array\n // returned by `userDevices.devices` do so.\n //\n // This is particularly problematic, because each of those structures holds a reference to the\n // VerificationMachine, which in turn holds a reference to the IndexeddbCryptoStore. Hence, we end up leaking\n // open connections to the crypto store, which means the store can't be deleted on logout.\n //\n // To fix this, we explicitly call `.free` on each of the objects, which tells the rust code to drop the\n // allocated memory and decrement the refcounts for the crypto store.\n\n // Wait for up to a second for any in-flight device list requests to complete.\n // The reason for this isn't so much to avoid races (some level of raciness is\n // inevitable for this method) but to make testing easier.\n const userDevices: RustSdkCryptoJs.UserDevices = await this.olmMachine.getUserDevices(rustUserId, 1);\n try {\n const deviceArray: RustSdkCryptoJs.Device[] = userDevices.devices();\n try {\n return new Map(\n deviceArray.map((device) => [device.deviceId.toString(), rustDeviceToJsDevice(device, rustUserId)]),\n );\n } finally {\n deviceArray.forEach((d) => d.free());\n }\n } finally {\n userDevices.free();\n }\n }\n\n /**\n * Download the given user keys by calling `/keys/query` request\n * @param untrackedUsers - download keys of these users\n */\n private async downloadDeviceList(untrackedUsers: Set<string>): Promise<IDownloadKeyResult> {\n const queryBody: IQueryKeysRequest = { device_keys: {} };\n untrackedUsers.forEach((user) => (queryBody.device_keys[user] = []));\n\n return await this.http.authedRequest(Method.Post, \"/_matrix/client/v3/keys/query\", undefined, queryBody, {\n prefix: \"\",\n });\n }\n\n /**\n * Implementation of {@link CryptoApi#getTrustCrossSignedDevices}.\n */\n public getTrustCrossSignedDevices(): boolean {\n return this._trustCrossSignedDevices;\n }\n\n /**\n * Implementation of {@link CryptoApi#setTrustCrossSignedDevices}.\n */\n public setTrustCrossSignedDevices(val: boolean): void {\n this._trustCrossSignedDevices = val;\n // TODO: legacy crypto goes through the list of known devices and emits DeviceVerificationChanged\n // events. Maybe we need to do the same?\n }\n\n /**\n * Mark the given device as locally verified.\n *\n * Implementation of {@link CryptoApi#setDeviceVerified}.\n */\n public async setDeviceVerified(userId: string, deviceId: string, verified = true): Promise<void> {\n const device: RustSdkCryptoJs.Device | undefined = await this.olmMachine.getDevice(\n new RustSdkCryptoJs.UserId(userId),\n new RustSdkCryptoJs.DeviceId(deviceId),\n );\n\n if (!device) {\n throw new Error(`Unknown device ${userId}|${deviceId}`);\n }\n try {\n await device.setLocalTrust(\n verified ? RustSdkCryptoJs.LocalTrust.Verified : RustSdkCryptoJs.LocalTrust.Unset,\n );\n } finally {\n device.free();\n }\n }\n\n /**\n * Blindly cross-sign one of our other devices.\n *\n * Implementation of {@link CryptoApi#crossSignDevice}.\n */\n public async crossSignDevice(deviceId: string): Promise<void> {\n const device: RustSdkCryptoJs.Device | undefined = await this.olmMachine.getDevice(\n new RustSdkCryptoJs.UserId(this.userId),\n new RustSdkCryptoJs.DeviceId(deviceId),\n );\n if (!device) {\n throw new Error(`Unknown device ${deviceId}`);\n }\n try {\n const outgoingRequest: RustSdkCryptoJs.SignatureUploadRequest = await device.verify();\n await this.outgoingRequestProcessor.makeOutgoingRequest(outgoingRequest);\n } finally {\n device.free();\n }\n }\n\n /**\n * Implementation of {@link CryptoApi#getDeviceVerificationStatus}.\n */\n public async getDeviceVerificationStatus(\n userId: string,\n deviceId: string,\n ): Promise<DeviceVerificationStatus | null> {\n const device: RustSdkCryptoJs.Device | undefined = await this.olmMachine.getDevice(\n new RustSdkCryptoJs.UserId(userId),\n new RustSdkCryptoJs.DeviceId(deviceId),\n );\n\n if (!device) return null;\n try {\n return new DeviceVerificationStatus({\n signedByOwner: device.isCrossSignedByOwner(),\n crossSigningVerified: device.isCrossSigningTrusted(),\n localVerified: device.isLocallyTrusted(),\n trustCrossSignedDevices: this._trustCrossSignedDevices,\n });\n } finally {\n device.free();\n }\n }\n\n /**\n * Implementation of {@link CryptoApi#getUserVerificationStatus}.\n */\n public async getUserVerificationStatus(userId: string): Promise<UserVerificationStatus> {\n const userIdentity: RustSdkCryptoJs.UserIdentity | RustSdkCryptoJs.OwnUserIdentity | undefined =\n await this.getOlmMachineOrThrow().getIdentity(new RustSdkCryptoJs.UserId(userId));\n if (userIdentity === undefined) {\n return new UserVerificationStatus(false, false, false);\n }\n\n const verified = userIdentity.isVerified();\n const wasVerified = userIdentity.wasPreviouslyVerified();\n const needsUserApproval =\n userIdentity instanceof RustSdkCryptoJs.UserIdentity ? userIdentity.identityNeedsUserApproval() : false;\n userIdentity.free();\n return new UserVerificationStatus(verified, wasVerified, false, needsUserApproval);\n }\n\n /**\n * Implementation of {@link CryptoApi#pinCurrentUserIdentity}.\n */\n public async pinCurrentUserIdentity(userId: string): Promise<void> {\n const userIdentity: RustSdkCryptoJs.UserIdentity | RustSdkCryptoJs.OwnUserIdentity | undefined =\n await this.getOlmMachineOrThrow().getIdentity(new RustSdkCryptoJs.UserId(userId));\n\n if (userIdentity === undefined) {\n throw new Error(\"Cannot pin identity of unknown user\");\n }\n\n if (userIdentity instanceof RustSdkCryptoJs.OwnUserIdentity) {\n throw new Error(\"Cannot pin identity of own user\");\n }\n\n await userIdentity.pinCurrentMasterKey();\n }\n\n /**\n * Implementation of {@link CryptoApi#isCrossSigningReady}\n */\n public async isCrossSigningReady(): Promise<boolean> {\n const { privateKeysInSecretStorage, privateKeysCachedLocally } = await this.getCrossSigningStatus();\n const hasKeysInCache =\n Boolean(privateKeysCachedLocally.masterKey) &&\n Boolean(privateKeysCachedLocally.selfSigningKey) &&\n Boolean(privateKeysCachedLocally.userSigningKey);\n\n const identity = await this.getOwnIdentity();\n\n // Cross-signing is ready if the public identity is trusted, and the private keys\n // are either cached, or accessible via secret-storage.\n return !!identity?.isVerified() && (hasKeysInCache || privateKeysInSecretStorage);\n }\n\n /**\n * Implementation of {@link CryptoApi#getCrossSigningKeyId}\n */\n public async getCrossSigningKeyId(type: CrossSigningKey = CrossSigningKey.Master): Promise<string | null> {\n const userIdentity: RustSdkCryptoJs.OwnUserIdentity | undefined = await this.olmMachine.getIdentity(\n new RustSdkCryptoJs.UserId(this.userId),\n );\n if (!userIdentity) {\n // The public keys are not available on this device\n return null;\n }\n\n try {\n const crossSigningStatus: RustSdkCryptoJs.CrossSigningStatus = await this.olmMachine.crossSigningStatus();\n\n const privateKeysOnDevice =\n crossSigningStatus.hasMaster && crossSigningStatus.hasUserSigning && crossSigningStatus.hasSelfSigning;\n\n if (!privateKeysOnDevice) {\n // The private keys are not available on this device\n return null;\n }\n\n if (!userIdentity.isVerified()) {\n // We have both public and private keys, but they don't match!\n return null;\n }\n\n let key: string;\n switch (type) {\n case CrossSigningKey.Master:\n key = userIdentity.masterKey;\n break;\n case CrossSigningKey.SelfSigning:\n key = userIdentity.selfSigningKey;\n break;\n case CrossSigningKey.UserSigning:\n key = userIdentity.userSigningKey;\n break;\n default:\n // Unknown type\n return null;\n }\n\n const parsedKey: CrossSigningKeyInfo = JSON.parse(key);\n // `keys` is an object with { [`ed25519:${pubKey}`]: pubKey }\n // We assume only a single key, and we want the bare form without type\n // prefix, so we select the values.\n return Object.values(parsedKey.keys)[0];\n } finally {\n userIdentity.free();\n }\n }\n\n /**\n * Implementation of {@link CryptoApi#bootstrapCrossSigning}\n */\n public async bootstrapCrossSigning(opts: BootstrapCrossSigningOpts): Promise<void> {\n await this.crossSigningIdentity.bootstrapCrossSigning(opts);\n }\n\n /**\n * Implementation of {@link CryptoApi#isSecretStorageReady}\n */\n public async isSecretStorageReady(): Promise<boolean> {\n // make sure that the cross-signing keys are stored\n const secretsToCheck = [\n \"m.cross_signing.master\",\n \"m.cross_signing.user_signing\",\n \"m.cross_signing.self_signing\",\n ];\n\n // if key backup is active, we also need to check that the backup decryption key is stored\n const keyBackupEnabled = (await this.backupManager.getActiveBackupVersion()) != null;\n if (keyBackupEnabled) {\n secretsToCheck.push(\"m.megolm_backup.v1\");\n }\n\n return secretStorageCanAccessSecrets(this.secretStorage, secretsToCheck);\n }\n\n /**\n * Implementation of {@link CryptoApi#bootstrapSecretStorage}\n */\n public async bootstrapSecretStorage({\n createSecretStorageKey,\n setupNewSecretStorage,\n setupNewKeyBackup,\n }: CreateSecretStorageOpts = {}): Promise<void> {\n // If an AES Key is already stored in the secret storage and setupNewSecretStorage is not set\n // we don't want to create a new key\n const isNewSecretStorageKeyNeeded = setupNewSecretStorage || !(await this.secretStorageHasAESKey());\n\n if (isNewSecretStorageKeyNeeded) {\n if (!createSecretStorageKey) {\n throw new Error(\"unable to create a new secret storage key, createSecretStorageKey is not set\");\n }\n\n // Create a new storage key and add it to secret storage\n this.logger.info(\"bootstrapSecretStorage: creating new secret storage key\");\n const recoveryKey = await createSecretStorageKey();\n if (!recoveryKey) {\n throw new Error(\"createSecretStorageKey() callback did not return a secret storage key\");\n }\n await this.addSecretStorageKeyToSecretStorage(recoveryKey);\n }\n\n const crossSigningStatus: RustSdkCryptoJs.CrossSigningStatus = await this.olmMachine.crossSigningStatus();\n const hasPrivateKeys =\n crossSigningStatus.hasMaster && crossSigningStatus.hasSelfSigning && crossSigningStatus.hasUserSigning;\n\n // If we have cross-signing private keys cached, store them in secret\n // storage if they are not there already.\n if (\n hasPrivateKeys &&\n (isNewSecretStorageKeyNeeded || !(await secretStorageContainsCrossSigningKeys(this.secretStorage)))\n ) {\n this.logger.info(\"bootstrapSecretStorage: cross-signing keys not yet exported; doing so now.\");\n\n const crossSigningPrivateKeys: RustSdkCryptoJs.CrossSigningKeyExport =\n await this.olmMachine.exportCrossSigningKeys();\n\n if (!crossSigningPrivateKeys.masterKey) {\n throw new Error(\"missing master key in cross signing private keys\");\n }\n\n if (!crossSigningPrivateKeys.userSigningKey) {\n throw new Error(\"missing user signing key in cross signing private keys\");\n }\n\n if (!crossSigningPrivateKeys.self_signing_key) {\n throw new Error(\"missing self signing key in cross signing private keys\");\n }\n\n await this.secretStorage.store(\"m.cross_signing.master\", crossSigningPrivateKeys.masterKey);\n await this.secretStorage.store(\"m.cross_signing.user_signing\", crossSigningPrivateKeys.userSigningKey);\n await this.secretStorage.store(\"m.cross_signing.self_signing\", crossSigningPrivateKeys.self_signing_key);\n }\n\n if (setupNewKeyBackup) {\n await this.resetKeyBackup();\n }\n }\n\n /**\n * Add the secretStorage key to the secret storage\n * - The secret storage key must have the `keyInfo` field filled\n * - The secret storage key is set as the default key of the secret storage\n * - Call `cryptoCallbacks.cacheSecretStorageKey` when done\n *\n * @param secretStorageKey - The secret storage key to add in the secret storage.\n */\n private async addSecretStorageKeyToSecretStorage(secretStorageKey: GeneratedSecretStorageKey): Promise<void> {\n const secretStorageKeyObject = await this.secretStorage.addKey(SECRET_STORAGE_ALGORITHM_V1_AES, {\n passphrase: secretStorageKey.keyInfo?.passphrase,\n name: secretStorageKey.keyInfo?.name,\n key: secretStorageKey.privateKey,\n });\n\n await this.secretStorage.setDefaultKeyId(secretStorageKeyObject.keyId);\n\n this.cryptoCallbacks.cacheSecretStorageKey?.(\n secretStorageKeyObject.keyId,\n secretStorageKeyObject.keyInfo,\n secretStorageKey.privateKey,\n );\n }\n\n /**\n * Check if a secret storage AES Key is already added in secret storage\n *\n * @returns True if an AES key is in the secret storage\n */\n private async secretStorageHasAESKey(): Promise<boolean> {\n // See if we already have an AES secret-storage key.\n const secretStorageKeyTuple = await this.secretStorage.getKey();\n\n if (!secretStorageKeyTuple) return false;\n\n const [, keyInfo] = secretStorageKeyTuple;\n\n // Check if the key is an AES key\n return keyInfo.algorithm === SECRET_STORAGE_ALGORITHM_V1_AES;\n }\n\n /**\n * Implementation of {@link CryptoApi#getCrossSigningStatus}\n */\n public async getCrossSigningStatus(): Promise<CrossSigningStatus> {\n const userIdentity: RustSdkCryptoJs.OwnUserIdentity | null = await this.getOlmMachineOrThrow().getIdentity(\n new RustSdkCryptoJs.UserId(this.userId),\n );\n\n const publicKeysOnDevice =\n Boolean(userIdentity?.masterKey) &&\n Boolean(userIdentity?.selfSigningKey) &&\n Boolean(userIdentity?.userSigningKey);\n userIdentity?.free();\n\n const privateKeysInSecretStorage = await secretStorageContainsCrossSigningKeys(this.secretStorage);\n const crossSigningStatus: RustSdkCryptoJs.CrossSigningStatus | null =\n await this.getOlmMachineOrThrow().crossSigningStatus();\n\n return {\n publicKeysOnDevice,\n privateKeysInSecretStorage,\n privateKeysCachedLocally: {\n masterKey: Boolean(crossSigningStatus?.hasMaster),\n userSigningKey: Boolean(crossSigningStatus?.hasUserSigning),\n selfSigningKey: Boolean(crossSigningStatus?.hasSelfSigning),\n },\n };\n }\n\n /**\n * Implementation of {@link CryptoApi#createRecoveryKeyFromPassphrase}\n */\n public async createRecoveryKeyFromPassphrase(password?: string): Promise<GeneratedSecretStorageKey> {\n if (password) {\n // Generate the key from the passphrase\n // first we generate a random salt\n const salt = randomString(32);\n // then we derive the key from the passphrase\n const recoveryKey = await deriveRecoveryKeyFromPassphrase(\n password,\n salt,\n this.RECOVERY_KEY_DERIVATION_ITERATIONS,\n );\n return {\n keyInfo: {\n passphrase: {\n algorithm: \"m.pbkdf2\",\n iterations: this.RECOVERY_KEY_DERIVATION_ITERATIONS,\n salt,\n },\n },\n privateKey: recoveryKey,\n encodedPrivateKey: encodeRecoveryKey(recoveryKey),\n };\n } else {\n // Using the navigator crypto API to generate the private key\n const key = new Uint8Array(32);\n globalThis.crypto.getRandomValues(key);\n return {\n privateKey: key,\n encodedPrivateKey: encodeRecoveryKey(key),\n };\n }\n }\n\n /**\n * Implementation of {@link CryptoApi#getEncryptionInfoForEvent}.\n */\n public async getEncryptionInfoForEvent(event: MatrixEvent): Promise<EventEncryptionInfo | null> {\n return this.eventDecryptor.getEncryptionInfoForEvent(event);\n }\n\n /**\n * Returns to-device verification requests that are already in progress for the given user id.\n *\n * Implementation of {@link CryptoApi#getVerificationRequestsToDeviceInProgress}\n *\n * @param userId - the ID of the user to query\n *\n * @returns the VerificationRequests that are in progress\n */\n public getVerificationRequestsToDeviceInProgress(userId: string): VerificationRequest[] {\n const requests: RustSdkCryptoJs.VerificationRequest[] = this.olmMachine.getVerificationRequests(\n new RustSdkCryptoJs.UserId(userId),\n );\n return requests\n .filter((request) => request.roomId === undefined)\n .map(\n (request) =>\n new RustVerificationRequest(\n this.olmMachine,\n request,\n this.outgoingRequestProcessor,\n this._supportedVerificationMethods,\n ),\n );\n }\n\n /**\n * Finds a DM verification request that is already in progress for the given room id\n *\n * Implementation of {@link CryptoApi#findVerificationRequestDMInProgress}\n *\n * @param roomId - the room to use for verification\n * @param userId - search the verification request for the given user\n *\n * @returns the VerificationRequest that is in progress, if any\n *\n */\n public findVerificationRequestDMInProgress(roomId: string, userId?: string): VerificationRequest | undefined {\n if (!userId) throw new Error(\"missing userId\");\n\n const requests: RustSdkCryptoJs.VerificationRequest[] = this.olmMachine.getVerificationRequests(\n new RustSdkCryptoJs.UserId(userId),\n );\n\n // Search for the verification request for the given room id\n const request = requests.find((request) => request.roomId?.toString() === roomId);\n\n if (request) {\n return new RustVerificationRequest(\n this.olmMachine,\n request,\n this.outgoingRequestProcessor,\n this._supportedVerificationMethods,\n );\n }\n }\n\n /**\n * Implementation of {@link CryptoApi#requestVerificationDM}\n */\n public async requestVerificationDM(userId: string, roomId: string): Promise<VerificationRequest> {\n const userIdentity: RustSdkCryptoJs.UserIdentity | undefined = await this.olmMachine.getIdentity(\n new RustSdkCryptoJs.UserId(userId),\n );\n\n if (!userIdentity) throw new Error(`unknown userId ${userId}`);\n\n try {\n // Transform the verification methods into rust objects\n const methods = this._supportedVerificationMethods.map((method) =>\n verificationMethodIdentifierToMethod(method),\n );\n // Get the request content to send to the DM room\n const verificationEventContent: string = await userIdentity.verificationRequestContent(methods);\n\n // Send the request content to send to the DM room\n const eventId = await this.sendVerificationRequestContent(roomId, verificationEventContent);\n\n // Get a verification request\n const request: RustSdkCryptoJs.VerificationRequest = await userIdentity.requestVerification(\n new RustSdkCryptoJs.RoomId(roomId),\n new RustSdkCryptoJs.EventId(eventId),\n methods,\n );\n return new RustVerificationRequest(\n this.olmMachine,\n request,\n this.outgoingRequestProcessor,\n this._supportedVerificationMethods,\n );\n } finally {\n userIdentity.free();\n }\n }\n\n /**\n * Send the verification content to a room\n * See https://spec.matrix.org/v1.7/client-server-api/#put_matrixclientv3roomsroomidsendeventtypetxnid\n *\n * Prefer to use {@link OutgoingRequestProcessor.makeOutgoingRequest} when dealing with {@link RustSdkCryptoJs.RoomMessageRequest}\n *\n * @param roomId - the targeted room\n * @param verificationEventContent - the request body.\n *\n * @returns the event id\n */\n private async sendVerificationRequestContent(roomId: string, verificationEventContent: string): Promise<string> {\n const txId = randomString(32);\n // Send the verification request content to the DM room\n const { event_id: eventId } = await this.http.authedRequest<{ event_id: string }>(\n Method.Put,\n `/_matrix/client/v3/rooms/${encodeURIComponent(roomId)}/send/m.room.message/${encodeURIComponent(txId)}`,\n undefined,\n verificationEventContent,\n {\n prefix: \"\",\n },\n );\n\n return eventId;\n }\n\n /**\n * The verification methods we offer to the other side during an interactive verification.\n */\n private _supportedVerificationMethods: string[] = ALL_VERIFICATION_METHODS;\n\n /**\n * Set the verification methods we offer to the other side during an interactive verification.\n *\n * If `undefined`, we will offer all the methods supported by the Rust SDK.\n */\n public setSupportedVerificationMethods(methods: string[] | undefined): void {\n // by default, the Rust SDK does not offer `m.qr_code.scan.v1`, but we do want to offer that.\n this._supportedVerificationMethods = methods ?? ALL_VERIFICATION_METHODS;\n }\n\n /**\n * Send a verification request to our other devices.\n *\n * If a verification is already in flight, returns it. Otherwise, initiates a new one.\n *\n * Implementation of {@link CryptoApi#requestOwnUserVerification}.\n *\n * @returns a VerificationRequest when the request has been sent to the other party.\n */\n public async requestOwnUserVerification(): Promise<VerificationRequest> {\n const userIdentity: RustSdkCryptoJs.OwnUserIdentity | undefined = await this.olmMachine.getIdentity(\n new RustSdkCryptoJs.UserId(this.userId),\n );\n if (userIdentity === undefined) {\n throw new Error(\"cannot request verification for this device when there is no existing cross-signing key\");\n }\n\n try {\n const [request, outgoingRequest]: [RustSdkCryptoJs.VerificationRequest, RustSdkCryptoJs.ToDeviceRequest] =\n await userIdentity.requestVerification(\n this._supportedVerificationMethods.map(verificationMethodIdentifierToMethod),\n );\n await this.outgoingRequestProcessor.makeOutgoingRequest(outgoingRequest);\n return new RustVerificationRequest(\n this.olmMachine,\n request,\n this.outgoingRequestProcessor,\n this._supportedVerificationMethods,\n );\n } finally {\n userIdentity.free();\n }\n }\n\n /**\n * Request an interactive verification with the given device.\n *\n * If a verification is already in flight, returns it. Otherwise, initiates a new one.\n *\n * Implementation of {@link CryptoApi#requestDeviceVerification}.\n *\n * @param userId - ID of the owner of the device to verify\n * @param deviceId - ID of the device to verify\n *\n * @returns a VerificationRequest when the request has been sent to the other party.\n */\n public async requestDeviceVerification(userId: string, deviceId: string): Promise<VerificationRequest> {\n const device: RustSdkCryptoJs.Device | undefined = await this.olmMachine.getDevice(\n new RustSdkCryptoJs.UserId(userId),\n new RustSdkCryptoJs.DeviceId(deviceId),\n );\n\n if (!device) {\n throw new Error(\"Not a known device\");\n }\n\n try {\n const [request, outgoingRequest] = device.requestVerification(\n this._supportedVerificationMethods.map(verificationMethodIdentifierToMethod),\n );\n await this.outgoingRequestProcessor.makeOutgoingRequest(outgoingRequest);\n return new RustVerificationRequest(\n this.olmMachine,\n request,\n this.outgoingRequestProcessor,\n this._supportedVerificationMethods,\n );\n } finally {\n device.free();\n }\n }\n\n /**\n * Fetch the backup decryption key we have saved in our store.\n *\n * Implementation of {@link CryptoApi#getSessionBackupPrivateKey}.\n *\n * @returns the key, if any, or null\n */\n public async getSessionBackupPrivateKey(): Promise<Uint8Array | null> {\n const backupKeys: RustSdkCryptoJs.BackupKeys = await this.olmMachine.getBackupKeys();\n if (!backupKeys.decryptionKey) return null;\n return Buffer.from(backupKeys.decryptionKey.toBase64(), \"base64\");\n }\n\n /**\n * Store the backup decryption key.\n *\n * Implementation of {@link CryptoApi#storeSessionBackupPrivateKey}.\n *\n * @param key - the backup decryption key\n * @param version - the backup version for this key.\n */\n public async storeSessionBackupPrivateKey(key: Uint8Array, version?: string): Promise<void> {\n const base64Key = encodeBase64(key);\n\n if (!version) {\n throw new Error(\"storeSessionBackupPrivateKey: version is required\");\n }\n\n await this.backupManager.saveBackupDecryptionKey(\n RustSdkCryptoJs.BackupDecryptionKey.fromBase64(base64Key),\n version,\n );\n }\n\n /**\n * Implementation of {@link CryptoApi#loadSessionBackupPrivateKeyFromSecretStorage}.\n */\n public async loadSessionBackupPrivateKeyFromSecretStorage(): Promise<void> {\n const backupKey = await this.secretStorage.get(\"m.megolm_backup.v1\");\n if (!backupKey) {\n throw new Error(\"loadSessionBackupPrivateKeyFromSecretStorage: missing decryption key in secret storage\");\n }\n\n const keyBackupInfo = await this.backupManager.getServerBackupInfo();\n if (!keyBackupInfo || !keyBackupInfo.version) {\n throw new Error(\"loadSessionBackupPrivateKeyFromSecretStorage: unable to get backup version\");\n }\n\n const backupDecryptionKey = RustSdkCryptoJs.BackupDecryptionKey.fromBase64(backupKey);\n if (!decryptionKeyMatchesKeyBackupInfo(backupDecryptionKey, keyBackupInfo)) {\n throw new Error(\"loadSessionBackupPrivateKeyFromSecretStorage: decryption key does not match backup info\");\n }\n\n await this.backupManager.saveBackupDecryptionKey(backupDecryptionKey, keyBackupInfo.version);\n }\n\n /**\n * Get the current status of key backup.\n *\n * Implementation of {@link CryptoApi#getActiveSessionBackupVersion}.\n */\n public async getActiveSessionBackupVersion(): Promise<string | null> {\n return await this.backupManager.getActiveBackupVersion();\n }\n\n /**\n * Implementation of {@link CryptoApi#getKeyBackupInfo}.\n */\n public async getKeyBackupInfo(): Promise<KeyBackupInfo | null> {\n return (await this.backupManager.getServerBackupInfo()) || null;\n }\n\n /**\n * Determine if a key backup can be trusted.\n *\n * Implementation of {@link CryptoApi#isKeyBackupTrusted}.\n */\n public async isKeyBackupTrusted(info: KeyBackupInfo): Promise<BackupTrustInfo> {\n return await this.backupManager.isKeyBackupTrusted(info);\n }\n\n /**\n * Force a re-check of the key backup and enable/disable it as appropriate.\n *\n * Implementation of {@link CryptoApi#checkKeyBackupAndEnable}.\n */\n public async checkKeyBackupAndEnable(): Promise<KeyBackupCheck | null> {\n return await this.backupManager.checkKeyBackupAndEnable(true);\n }\n\n /**\n * Implementation of {@link CryptoApi#deleteKeyBackupVersion}.\n */\n public async deleteKeyBackupVersion(version: string): Promise<void> {\n await this.backupManager.deleteKeyBackupVersion(version);\n }\n\n /**\n * Implementation of {@link CryptoApi#resetKeyBackup}.\n */\n public async resetKeyBackup(): Promise<void> {\n const backupInfo = await this.backupManager.setupKeyBackup((o) => this.signObject(o));\n\n // we want to store the private key in 4S\n // need to check if 4S is set up?\n if (await this.secretStorageHasAESKey()) {\n await this.secretStorage.store(\"m.megolm_backup.v1\", backupInfo.decryptionKey.toBase64());\n }\n\n // we can check and start async\n this.checkKeyBackupAndEnable();\n }\n\n /**\n * Signs the given object with the current device and current identity (if available).\n * As defined in {@link https://spec.matrix.org/v1.8/appendices/#signing-json | Signing JSON}.\n *\n * Helper for {@link RustCrypto#resetKeyBackup}.\n *\n * @param obj - The object to sign\n */\n private async signObject<T extends ISignableObject & object>(obj: T): Promise<void> {\n const sigs = new Map(Object.entries(obj.signatures || {}));\n const unsigned = obj.unsigned;\n\n delete obj.signatures;\n delete obj.unsigned;\n\n const userSignatures = sigs.get(this.userId) || {};\n\n const canonalizedJson = anotherjson.stringify(obj);\n const signatures: RustSdkCryptoJs.Signatures = await this.olmMachine.sign(canonalizedJson);\n\n const map = JSON.parse(signatures.asJSON());\n\n sigs.set(this.userId, { ...userSignatures, ...map[this.userId] });\n\n if (unsigned !== undefined) obj.unsigned = unsigned;\n obj.signatures = Object.fromEntries(sigs.entries());\n }\n\n /**\n * Implementation of {@link CryptoApi#restoreKeyBackupWithPassphrase}.\n */\n public async restoreKeyBackupWithPassphrase(\n passphrase: string,\n opts?: KeyBackupRestoreOpts,\n ): Promise<KeyBackupRestoreResult> {\n const backupInfo = await this.backupManager.getServerBackupInfo();\n if (!backupInfo?.version) {\n throw new Error(\"No backup info available\");\n }\n\n const privateKey = await keyFromAuthData(backupInfo.auth_data, passphrase);\n\n // Cache the key\n await this.storeSessionBackupPrivateKey(privateKey, backupInfo.version);\n return this.restoreKeyBackup(opts);\n }\n\n /**\n * Implementation of {@link CryptoApi#restoreKeyBackup}.\n */\n public async restoreKeyBackup(opts?: KeyBackupRestoreOpts): Promise<KeyBackupRestoreResult> {\n // Get the decryption key from the crypto store\n const backupKeys: RustSdkCryptoJs.BackupKeys = await this.olmMachine.getBackupKeys();\n const { decryptionKey, backupVersion } = backupKeys;\n if (!decryptionKey || !backupVersion) throw new Error(\"No decryption key found in crypto store\");\n\n const decodedDecryptionKey = decodeBase64(decryptionKey.toBase64());\n\n const backupInfo = await this.backupManager.requestKeyBackupVersion(backupVersion);\n if (!backupInfo) throw new Error(`Backup version to restore ${backupVersion} not found on server`);\n\n const backupDecryptor = await this.getBackupDecryptor(backupInfo, decodedDecryptionKey);\n\n try {\n opts?.progressCallback?.({\n stage: \"fetch\",\n });\n\n return await this.backupManager.restoreKeyBackup(backupVersion, backupDecryptor, opts);\n } finally {\n // Free to avoid to keep in memory the decryption key stored in it. To avoid to exposing it to an attacker.\n backupDecryptor.free();\n }\n }\n\n /**\n * Implementation of {@link CryptoApi#isDehydrationSupported}.\n */\n public async isDehydrationSupported(): Promise<boolean> {\n return await this.dehydratedDeviceManager.isSupported();\n }\n\n /**\n * Implementation of {@link CryptoApi#startDehydration}.\n */\n public async startDehydration(createNewKey?: boolean): Promise<void> {\n if (!(await this.isCrossSigningReady()) || !(await this.isSecretStorageReady())) {\n throw new Error(\"Device dehydration requires cross-signing and secret storage to be set up\");\n }\n return await this.dehydratedDeviceManager.start(createNewKey);\n }\n\n /**\n * Implementation of {@link CryptoApi#importSecretsBundle}.\n */\n public async importSecretsBundle(\n secrets: Parameters<NonNullable<CryptoApi[\"importSecretsBundle\"]>>[0],\n ): Promise<void> {\n const secretsBundle = RustSdkCryptoJs.SecretsBundle.from_json(secrets);\n await this.getOlmMachineOrThrow().importSecretsBundle(secretsBundle); // this method frees the SecretsBundle\n }\n\n /**\n * Implementation of {@link CryptoApi#exportSecretsBundle}.\n */\n public async exportSecretsBundle(): ReturnType<NonNullable<CryptoApi[\"exportSecretsBundle\"]>> {\n const secretsBundle = await this.getOlmMachineOrThrow().exportSecretsBundle();\n const secrets = secretsBundle.to_json();\n secretsBundle.free();\n return secrets;\n }\n\n /**\n * Implementation of {@link CryptoApi#encryptToDeviceMessages}.\n */\n public async encryptToDeviceMessages(\n eventType: string,\n devices: { userId: string; deviceId: string }[],\n payload: ToDevicePayload,\n ): Promise<ToDeviceBatch> {\n const logger = new LogSpan(this.logger, \"encryptToDeviceMessages\");\n const uniqueUsers = new Set(devices.map(({ userId }) => userId));\n\n // This will ensure we have Olm sessions for all of the users' devices.\n // However, we only care about some of the devices.\n // So, perhaps we can optimise this later on.\n await this.keyClaimManager.ensureSessionsForUsers(\n logger,\n Array.from(uniqueUsers).map((userId) => new RustSdkCryptoJs.UserId(userId)),\n );\n const batch: ToDeviceBatch = {\n batch: [],\n eventType: EventType.RoomMessageEncrypted,\n };\n\n await Promise.all(\n devices.map(async ({ userId, deviceId }) => {\n const device: RustSdkCryptoJs.Device | undefined = await this.olmMachine.getDevice(\n new RustSdkCryptoJs.UserId(userId),\n new RustSdkCryptoJs.DeviceId(deviceId),\n );\n\n if (device) {\n const encryptedPayload = JSON.parse(await device.encryptToDeviceEvent(eventType, payload));\n batch.batch.push({\n deviceId,\n userId,\n payload: encryptedPayload,\n });\n } else {\n this.logger.warn(`encryptToDeviceMessages: unknown device ${userId}:${deviceId}`);\n }\n }),\n );\n\n return batch;\n }\n\n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n //\n // SyncCryptoCallbacks implementation\n //\n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n\n /**\n * Apply sync changes to the olm machine\n * @param events - the received to-device messages\n * @param oneTimeKeysCounts - the received one time key counts\n * @param unusedFallbackKeys - the received unused fallback keys\n * @param devices - the received device list updates\n * @returns A list of preprocessed to-device messages.\n */\n private async receiveSyncChanges({\n events,\n oneTimeKeysCounts = new Map<string, number>(),\n unusedFallbackKeys,\n devices = new RustSdkCryptoJs.DeviceLists(),\n }: {\n events?: IToDeviceEvent[];\n oneTimeKeysCounts?: Map<string, number>;\n unusedFallbackKeys?: Set<string>;\n devices?: RustSdkCryptoJs.DeviceLists;\n }): Promise<IToDeviceEvent[]> {\n const result = await logDuration(logger, \"receiveSyncChanges\", async () => {\n return await this.olmMachine.receiveSyncChanges(\n events ? JSON.stringify(events) : \"[]\",\n devices,\n oneTimeKeysCounts,\n unusedFallbackKeys,\n );\n });\n\n // receiveSyncChanges returns a JSON-encoded list of decrypted to-device messages.\n return JSON.parse(result);\n }\n\n /** called by the sync loop to preprocess incoming to-device messages\n *\n * @param events - the received to-device messages\n * @returns A list of preprocessed to-device messages.\n */\n public async preprocessToDeviceMessages(events: IToDeviceEvent[]): Promise<IToDeviceEvent[]> {\n // send the received to-device messages into receiveSyncChanges. We have no info on device-list changes,\n // one-time-keys, or fallback keys, so just pass empty data.\n const processed = await this.receiveSyncChanges({ events });\n\n // look for interesting to-device messages\n for (const message of processed) {\n if (message.type === EventType.KeyVerificationRequest) {\n const sender = message.sender;\n const transactionId = message.content.transaction_id;\n if (transactionId && sender) {\n this.onIncomingKeyVerificationRequest(sender, transactionId);\n }\n }\n }\n return processed;\n }\n\n /** called by the sync loop to process one time key counts and unused fallback keys\n *\n * @param oneTimeKeysCounts - the received one time key counts\n * @param unusedFallbackKeys - the received unused fallback keys\n */\n public async processKeyCounts(\n oneTimeKeysCounts?: Record<string, number>,\n unusedFallbackKeys?: string[],\n ): Promise<void> {\n const mapOneTimeKeysCount = oneTimeKeysCounts && new Map<string, number>(Object.entries(oneTimeKeysCounts));\n const setUnusedFallbackKeys = unusedFallbackKeys && new Set<string>(unusedFallbackKeys);\n\n if (mapOneTimeKeysCount !== undefined || setUnusedFallbackKeys !== undefined) {\n await this.receiveSyncChanges({\n oneTimeKeysCounts: mapOneTimeKeysCount,\n unusedFallbackKeys: setUnusedFallbackKeys,\n });\n }\n }\n\n /** called by the sync loop to process the notification that device lists have\n * been changed.\n *\n * @param deviceLists - device_lists field from /sync\n */\n public async processDeviceLists(deviceLists: IDeviceLists): Promise<void> {\n const devices = new RustSdkCryptoJs.DeviceLists(\n deviceLists.changed?.map((userId) => new RustSdkCryptoJs.UserId(userId)),\n deviceLists.left?.map((userId) => new RustSdkCryptoJs.UserId(userId)),\n );\n await this.receiveSyncChanges({ devices });\n }\n\n /** called by the sync loop on m.room.encrypted events\n *\n * @param room - in which the event was received\n * @param event - encryption event to be processed\n */\n public async onCryptoEvent(room: Room, event: MatrixEvent): Promise<void> {\n const config = event.getContent();\n const settings = new RustSdkCryptoJs.RoomSettings();\n\n if (config.algorithm === \"m.megolm.v1.aes-sha2\") {\n settings.algorithm = RustSdkCryptoJs.EncryptionAlgorithm.MegolmV1AesSha2;\n } else {\n // Among other situations, this happens if the crypto state event is redacted.\n this.logger.warn(`Room ${room.roomId}: ignoring crypto event with invalid algorithm ${config.algorithm}`);\n return;\n }\n\n try {\n settings.sessionRotationPeriodMs = config.rotation_period_ms;\n settings.sessionRotationPeriodMessages = config.rotation_period_msgs;\n await this.olmMachine.setRoomSettings(new RustSdkCryptoJs.RoomId(room.roomId), settings);\n } catch (e) {\n this.logger.warn(`Room ${room.roomId}: ignoring crypto event which caused error: ${e}`);\n return;\n }\n\n // If we got this far, the SDK found the event acceptable.\n // We need to either create or update the active RoomEncryptor.\n const existingEncryptor = this.roomEncryptors[room.roomId];\n if (existingEncryptor) {\n existingEncryptor.onCryptoEvent(config);\n } else {\n this.roomEncryptors[room.roomId] = new RoomEncryptor(\n this.olmMachine,\n this.keyClaimManager,\n this.outgoingRequestsManager,\n room,\n config,\n );\n }\n }\n\n /** called by the sync loop after processing each sync.\n *\n * TODO: figure out something equivalent for sliding sync.\n *\n * @param syncState - information on the completed sync.\n */\n public onSyncCompleted(syncState: OnSyncCompletedData): void {\n // Processing the /sync may have produced new outgoing requests which need sending, so kick off the outgoing\n // request loop, if it's not already running.\n this.outgoingRequestsManager.doProcessOutgoingRequests().catch((e) => {\n this.logger.warn(\"onSyncCompleted: Error processing outgoing requests\", e);\n });\n }\n\n /**\n * Handle an incoming m.key.verification.request event, received either in-room or in a to-device message.\n *\n * @param sender - the sender of the event\n * @param transactionId - the transaction ID for the verification. For to-device messages, this comes from the\n * content of the message; for in-room messages it is the event ID.\n */\n private onIncomingKeyVerificationRequest(sender: string, transactionId: string): void {\n const request: RustSdkCryptoJs.VerificationRequest | undefined = this.olmMachine.getVerificationRequest(\n new RustSdkCryptoJs.UserId(sender),\n transactionId,\n );\n\n if (request) {\n this.emit(\n CryptoEvent.VerificationRequestReceived,\n new RustVerificationRequest(\n this.olmMachine,\n request,\n this.outgoingRequestProcessor,\n this._supportedVerificationMethods,\n ),\n );\n } else {\n // There are multiple reasons this can happen; probably the most likely is that the event is an\n // in-room event which is too old.\n this.logger.info(\n `Ignoring just-received verification request ${transactionId} which did not start a rust-side verification`,\n );\n }\n }\n\n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n //\n // Other public functions\n //\n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n\n /** called by the MatrixClient on a room membership event\n *\n * @param event - The matrix event which caused this event to fire.\n * @param member - The member whose RoomMember.membership changed.\n * @param oldMembership - The previous membership state. Null if it's a new member.\n */\n public onRoomMembership(event: MatrixEvent, member: RoomMember, oldMembership?: string): void {\n const enc = this.roomEncryptors[event.getRoomId()!];\n if (!enc) {\n // not encrypting in this room\n return;\n }\n enc.onRoomMembership(member);\n }\n\n /** Callback for OlmMachine.registerRoomKeyUpdatedCallback\n *\n * Called by the rust-sdk whenever there is an update to (megolm) room keys. We\n * check if we have any events waiting for the given keys, and schedule them for\n * a decryption retry if so.\n *\n * @param keys - details of the updated keys\n */\n public async onRoomKeysUpdated(keys: RustSdkCryptoJs.RoomKeyInfo[]): Promise<void> {\n for (const key of keys) {\n this.onRoomKeyUpdated(key);\n }\n this.backupManager.maybeUploadKey();\n }\n\n private onRoomKeyUpdated(key: RustSdkCryptoJs.RoomKeyInfo): void {\n if (this.stopped) return;\n this.logger.debug(\n `Got update for session ${key.sessionId} from sender ${key.senderKey.toBase64()} in ${key.roomId.toString()}`,\n );\n const pendingList = this.eventDecryptor.getEventsPendingRoomKey(key.roomId.toString(), key.sessionId);\n if (pendingList.length === 0) return;\n\n this.logger.debug(\n \"Retrying decryption on events:\",\n pendingList.map((e) => `${e.getId()}`),\n );\n\n // Have another go at decrypting events with this key.\n //\n // We don't want to end up blocking the callback from Rust, which could otherwise end up dropping updates,\n // so we don't wait for the decryption to complete. In any case, there is no need to wait:\n // MatrixEvent.attemptDecryption ensures that there is only one decryption attempt happening at once,\n // and deduplicates repeated attempts for the same event.\n for (const ev of pendingList) {\n ev.attemptDecryption(this, { isRetry: true }).catch((_e) => {\n this.logger.info(`Still unable to decrypt event ${ev.getId()} after receiving key`);\n });\n }\n }\n\n /**\n * Callback for `OlmMachine.registerRoomKeyWithheldCallback`.\n *\n * Called by the rust sdk whenever we are told that a key has been withheld. We see if we had any events that\n * failed to decrypt for the given session, and update their status if so.\n *\n * @param withheld - Details of the withheld sessions.\n */\n public async onRoomKeysWithheld(withheld: RustSdkCryptoJs.RoomKeyWithheldInfo[]): Promise<void> {\n for (const session of withheld) {\n this.logger.debug(`Got withheld message for session ${session.sessionId} in ${session.roomId.toString()}`);\n const pendingList = this.eventDecryptor.getEventsPendingRoomKey(\n session.roomId.toString(),\n session.sessionId,\n );\n if (pendingList.length === 0) return;\n\n // The easiest way to update the status of the event is to have another go at decrypting it.\n this.logger.debug(\n \"Retrying decryption on events:\",\n pendingList.map((e) => `${e.getId()}`),\n );\n\n for (const ev of pendingList) {\n ev.attemptDecryption(this, { isRetry: true }).catch((_e) => {\n // It's somewhat expected that we still can't decrypt here.\n });\n }\n }\n }\n\n /**\n * Callback for `OlmMachine.registerUserIdentityUpdatedCallback`\n *\n * Called by the rust-sdk whenever there is an update to any user's cross-signing status. We re-check their trust\n * status and emit a `UserTrustStatusChanged` event, as well as a `KeysChanged` if it is our own identity that changed.\n *\n * @param userId - the user with the updated identity\n */\n public async onUserIdentityUpdated(userId: RustSdkCryptoJs.UserId): Promise<void> {\n const newVerification = await this.getUserVerificationStatus(userId.toString());\n this.emit(CryptoEvent.UserTrustStatusChanged, userId.toString(), newVerification);\n\n // If our own user identity has changed, we may now trust the key backup where we did not before.\n // So, re-check the key backup status and enable it if available.\n if (userId.toString() === this.userId) {\n this.emit(CryptoEvent.KeysChanged, {});\n await this.checkKeyBackupAndEnable();\n }\n }\n\n /**\n * Callback for `OlmMachine.registerDevicesUpdatedCallback`\n *\n * Called when users' devices have updated. Emits `WillUpdateDevices` and `DevicesUpdated`. In the JavaScript\n * crypto backend, these events are called at separate times, with `WillUpdateDevices` being emitted just before\n * the devices are saved, and `DevicesUpdated` being emitted just after. But the OlmMachine only gives us\n * one event, so we emit both events here.\n *\n * @param userIds - an array of user IDs of users whose devices have updated.\n */\n public async onDevicesUpdated(userIds: string[]): Promise<void> {\n this.emit(CryptoEvent.WillUpdateDevices, userIds, false);\n this.emit(CryptoEvent.DevicesUpdated, userIds, false);\n }\n\n /**\n * Handles secret received from the rust secret inbox.\n *\n * The gossipped secrets are received using the `m.secret.send` event type\n * and are guaranteed to have been received over a 1-to-1 Olm\n * Session from a verified device.\n *\n * The only secret currently handled in this way is `m.megolm_backup.v1`.\n *\n * @param name - the secret name\n * @param value - the secret value\n */\n private async handleSecretReceived(name: string, value: string): Promise<boolean> {\n this.logger.debug(`onReceiveSecret: Received secret ${name}`);\n if (name === \"m.megolm_backup.v1\") {\n return await this.backupManager.handleBackupSecretReceived(value);\n // XXX at this point we should probably try to download the backup and import the keys,\n // or at least retry for the current decryption failures?\n // Maybe add some signaling when a new secret is received, and let clients handle it?\n // as it's where the restore from backup APIs are exposed.\n }\n return false;\n }\n\n /**\n * Called when a new secret is received in the rust secret inbox.\n *\n * Will poll the secret inbox and handle the secrets received.\n *\n * @param name - The name of the secret received.\n */\n public async checkSecrets(name: string): Promise<void> {\n const pendingValues: string[] = await this.olmMachine.getSecretsFromInbox(name);\n for (const value of pendingValues) {\n if (await this.handleSecretReceived(name, value)) {\n // If we have a valid secret for that name there is no point of processing the other secrets values.\n // It's probably the same secret shared by another device.\n break;\n }\n }\n\n // Important to call this after handling the secrets as good hygiene.\n await this.olmMachine.deleteSecretsFromInbox(name);\n }\n\n /**\n * Handle a live event received via /sync.\n * See {@link ClientEventHandlerMap#event}\n *\n * @param event - live event\n */\n public async onLiveEventFromSync(event: MatrixEvent): Promise<void> {\n // Ignore state event or remote echo\n // transaction_id is provided in case of remote echo {@link https://spec.matrix.org/v1.7/client-server-api/#local-echo}\n if (event.isState() || !!event.getUnsigned().transaction_id) return;\n\n const processEvent = async (evt: MatrixEvent): Promise<void> => {\n // Process only verification event\n if (isVerificationEvent(event)) {\n await this.onKeyVerificationEvent(evt);\n }\n };\n\n // If the event is encrypted of in failure, we wait for decryption\n if (event.isDecryptionFailure() || event.isEncrypted()) {\n // 5 mins\n const TIMEOUT_DELAY = 5 * 60 * 1000;\n\n // After 5mins, we are not expecting the event to be decrypted\n const timeoutId = setTimeout(() => event.off(MatrixEventEvent.Decrypted, onDecrypted), TIMEOUT_DELAY);\n\n const onDecrypted = (decryptedEvent: MatrixEvent, error?: Error): void => {\n if (error) return;\n\n clearTimeout(timeoutId);\n event.off(MatrixEventEvent.Decrypted, onDecrypted);\n processEvent(decryptedEvent);\n };\n\n event.on(MatrixEventEvent.Decrypted, onDecrypted);\n } else {\n await processEvent(event);\n }\n }\n\n /**\n * Handle an in-room key verification event.\n *\n * @param event - a key validation request event.\n */\n private async onKeyVerificationEvent(event: MatrixEvent): Promise<void> {\n const roomId = event.getRoomId();\n\n if (!roomId) {\n throw new Error(\"missing roomId in the event\");\n }\n\n this.logger.debug(\n `Incoming verification event ${event.getId()} type ${event.getType()} from ${event.getSender()}`,\n );\n\n await this.olmMachine.receiveVerificationEvent(\n JSON.stringify({\n event_id: event.getId(),\n type: event.getType(),\n sender: event.getSender(),\n state_key: event.getStateKey(),\n content: event.getContent(),\n origin_server_ts: event.getTs(),\n }),\n new RustSdkCryptoJs.RoomId(roomId),\n );\n\n if (\n event.getType() === EventType.RoomMessage &&\n event.getContent().msgtype === MsgType.KeyVerificationRequest\n ) {\n this.onIncomingKeyVerificationRequest(event.getSender()!, event.getId()!);\n }\n\n // that may have caused us to queue up outgoing requests, so make sure we send them.\n this.outgoingRequestsManager.doProcessOutgoingRequests().catch((e) => {\n this.logger.warn(\"onKeyVerificationRequest: Error processing outgoing requests\", e);\n });\n }\n\n /**\n * Returns the cross-signing user identity of the current user.\n *\n * Not part of the public crypto-api interface.\n * Used during migration from legacy js-crypto to update local trust if needed.\n */\n public async getOwnIdentity(): Promise<RustSdkCryptoJs.OwnUserIdentity | undefined> {\n return await this.olmMachine.getIdentity(new RustSdkCryptoJs.UserId(this.userId));\n }\n}\n\nclass EventDecryptor {\n /**\n * Events which we couldn't decrypt due to unknown sessions / indexes.\n *\n * Map from roomId to sessionId to Set of MatrixEvents\n */\n private eventsPendingKey = new MapWithDefault<string, MapWithDefault<string, Set<MatrixEvent>>>(\n () => new MapWithDefault<string, Set<MatrixEvent>>(() => new Set()),\n );\n\n public constructor(\n private readonly logger: Logger,\n private readonly olmMachine: RustSdkCryptoJs.OlmMachine,\n private readonly perSessionBackupDownloader: PerSessionKeyBackupDownloader,\n ) {}\n\n public async attemptEventDecryption(\n event: MatrixEvent,\n isolationMode: DeviceIsolationMode,\n ): Promise<IEventDecryptionResult> {\n // add the event to the pending list *before* attempting to decrypt.\n // then, if the key turns up while decryption is in progress (and\n // decryption fails), we will schedule a retry.\n // (fixes https://github.com/vector-im/element-web/issues/5001)\n this.addEventToPendingList(event);\n\n let trustRequirement;\n\n switch (isolationMode.kind) {\n case DeviceIsolationModeKind.AllDevicesIsolationMode:\n trustRequirement = RustSdkCryptoJs.TrustRequirement.Untrusted;\n break;\n case DeviceIsolationModeKind.OnlySignedDevicesIsolationMode:\n trustRequirement = RustSdkCryptoJs.TrustRequirement.CrossSignedOrLegacy;\n break;\n }\n\n try {\n const res = (await this.olmMachine.decryptRoomEvent(\n stringifyEvent(event),\n new RustSdkCryptoJs.RoomId(event.getRoomId()!),\n new RustSdkCryptoJs.DecryptionSettings(trustRequirement),\n )) as RustSdkCryptoJs.DecryptedRoomEvent;\n\n // Success. We can remove the event from the pending list, if\n // that hasn't already happened.\n this.removeEventFromPendingList(event);\n\n return {\n clearEvent: JSON.parse(res.event),\n claimedEd25519Key: res.senderClaimedEd25519Key,\n senderCurve25519Key: res.senderCurve25519Key,\n forwardingCurve25519KeyChain: res.forwardingCurve25519KeyChain,\n };\n } catch (err) {\n if (err instanceof RustSdkCryptoJs.MegolmDecryptionError) {\n this.onMegolmDecryptionError(event, err, await this.perSessionBackupDownloader.getServerBackupInfo());\n } else {\n throw new DecryptionError(DecryptionFailureCode.UNKNOWN_ERROR, \"Unknown error\");\n }\n }\n }\n\n /**\n * Handle a `MegolmDecryptionError` returned by the rust SDK.\n *\n * Fires off a request to the `perSessionBackupDownloader`, if appropriate, and then throws a `DecryptionError`.\n *\n * @param event - The event which could not be decrypted.\n * @param err - The error from the Rust SDK.\n * @param serverBackupInfo - Details about the current backup from the server. `null` if there is no backup.\n * `undefined` if our attempt to check failed.\n */\n private onMegolmDecryptionError(\n event: MatrixEvent,\n err: RustSdkCryptoJs.MegolmDecryptionError,\n serverBackupInfo: KeyBackupInfo | null | undefined,\n ): never {\n const content = event.getWireContent();\n const errorDetails = { sender_key: content.sender_key, session_id: content.session_id };\n\n // If the error looks like it might be recoverable from backup, queue up a request to try that.\n if (\n err.code === RustSdkCryptoJs.DecryptionErrorCode.MissingRoomKey ||\n err.code === RustSdkCryptoJs.DecryptionErrorCode.UnknownMessageIndex\n ) {\n this.perSessionBackupDownloader.onDecryptionKeyMissingError(event.getRoomId()!, content.session_id!);\n\n // If the server is telling us our membership at the time the event\n // was sent, and it isn't \"join\", we use a different error code.\n const membership = event.getMembershipAtEvent();\n if (membership && membership !== KnownMembership.Join && membership !== KnownMembership.Invite) {\n throw new DecryptionError(\n DecryptionFailureCode.HISTORICAL_MESSAGE_USER_NOT_JOINED,\n \"This message was sent when we were not a member of the room.\",\n errorDetails,\n );\n }\n\n // If the event was sent before this device was created, we use some different error codes.\n if (event.getTs() <= this.olmMachine.deviceCreationTimeMs) {\n if (serverBackupInfo === null) {\n throw new DecryptionError(\n DecryptionFailureCode.HISTORICAL_MESSAGE_NO_KEY_BACKUP,\n \"This message was sent before this device logged in, and there is no key backup on the server.\",\n errorDetails,\n );\n } else if (!this.perSessionBackupDownloader.isKeyBackupDownloadConfigured()) {\n throw new DecryptionError(\n DecryptionFailureCode.HISTORICAL_MESSAGE_BACKUP_UNCONFIGURED,\n \"This message was sent before this device logged in, and key backup is not working.\",\n errorDetails,\n );\n } else {\n throw new DecryptionError(\n DecryptionFailureCode.HISTORICAL_MESSAGE_WORKING_BACKUP,\n \"This message was sent before this device logged in. Key backup is working, but we still do not (yet) have the key.\",\n errorDetails,\n );\n }\n }\n }\n\n // If we got a withheld code, expose that.\n if (err.maybe_withheld) {\n // Unfortunately the Rust SDK API doesn't let us distinguish between different withheld cases, other than\n // by string-matching.\n const failureCode =\n err.maybe_withheld === \"The sender has disabled encrypting to unverified devices.\"\n ? DecryptionFailureCode.MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE\n : DecryptionFailureCode.MEGOLM_KEY_WITHHELD;\n throw new DecryptionError(failureCode, err.maybe_withheld, errorDetails);\n }\n\n switch (err.code) {\n case RustSdkCryptoJs.DecryptionErrorCode.MissingRoomKey:\n throw new DecryptionError(\n DecryptionFailureCode.MEGOLM_UNKNOWN_INBOUND_SESSION_ID,\n \"The sender's device has not sent us the keys for this message.\",\n errorDetails,\n );\n\n case RustSdkCryptoJs.DecryptionErrorCode.UnknownMessageIndex:\n throw new DecryptionError(\n DecryptionFailureCode.OLM_UNKNOWN_MESSAGE_INDEX,\n \"The sender's device has not sent us the keys for this message at this index.\",\n errorDetails,\n );\n\n case RustSdkCryptoJs.DecryptionErrorCode.SenderIdentityPreviouslyVerified:\n // We're refusing to decrypt due to not trusting the sender,\n // rather than failing to decrypt due to lack of keys, so we\n // don't need to keep it on the pending list.\n this.removeEventFromPendingList(event);\n throw new DecryptionError(\n DecryptionFailureCode.SENDER_IDENTITY_PREVIOUSLY_VERIFIED,\n \"The sender identity is unverified, but was previously verified.\",\n );\n\n case RustSdkCryptoJs.DecryptionErrorCode.UnknownSenderDevice:\n // We're refusing to decrypt due to not trusting the sender,\n // rather than failing to decrypt due to lack of keys, so we\n // don't need to keep it on the pending list.\n this.removeEventFromPendingList(event);\n throw new DecryptionError(\n DecryptionFailureCode.UNKNOWN_SENDER_DEVICE,\n \"The sender device is not known.\",\n );\n\n case RustSdkCryptoJs.DecryptionErrorCode.UnsignedSenderDevice:\n // We're refusing to decrypt due to not trusting the sender,\n // rather than failing to decrypt due to lack of keys, so we\n // don't need to keep it on the pending list.\n this.removeEventFromPendingList(event);\n throw new DecryptionError(\n DecryptionFailureCode.UNSIGNED_SENDER_DEVICE,\n \"The sender identity is not cross-signed.\",\n );\n\n // We don't map MismatchedIdentityKeys for now, as there is no equivalent in legacy.\n // Just put it on the `UNKNOWN_ERROR` bucket.\n default:\n throw new DecryptionError(DecryptionFailureCode.UNKNOWN_ERROR, err.description, errorDetails);\n }\n }\n\n public async getEncryptionInfoForEvent(event: MatrixEvent): Promise<EventEncryptionInfo | null> {\n if (!event.getClearContent() || event.isDecryptionFailure()) {\n // not successfully decrypted\n return null;\n }\n\n // special-case outgoing events, which the rust crypto-sdk will barf on\n if (event.status !== null) {\n return { shieldColour: EventShieldColour.NONE, shieldReason: null };\n }\n\n const encryptionInfo = await this.olmMachine.getRoomEventEncryptionInfo(\n stringifyEvent(event),\n new RustSdkCryptoJs.RoomId(event.getRoomId()!),\n );\n\n return rustEncryptionInfoToJsEncryptionInfo(this.logger, encryptionInfo);\n }\n\n /**\n * Look for events which are waiting for a given megolm session\n *\n * Returns a list of events which were encrypted by `session` and could not be decrypted\n */\n public getEventsPendingRoomKey(roomId: string, sessionId: string): MatrixEvent[] {\n const roomPendingEvents = this.eventsPendingKey.get(roomId);\n if (!roomPendingEvents) return [];\n\n const sessionPendingEvents = roomPendingEvents.get(sessionId);\n if (!sessionPendingEvents) return [];\n\n return [...sessionPendingEvents];\n }\n\n /**\n * Add an event to the list of those awaiting their session keys.\n */\n private addEventToPendingList(event: MatrixEvent): void {\n const roomId = event.getRoomId();\n // We shouldn't have events without a room id here.\n if (!roomId) return;\n\n const roomPendingEvents = this.eventsPendingKey.getOrCreate(roomId);\n const sessionPendingEvents = roomPendingEvents.getOrCreate(event.getWireContent().session_id);\n sessionPendingEvents.add(event);\n }\n\n /**\n * Remove an event from the list of those awaiting their session keys.\n */\n private removeEventFromPendingList(event: MatrixEvent): void {\n const roomId = event.getRoomId();\n if (!roomId) return;\n\n const roomPendingEvents = this.eventsPendingKey.getOrCreate(roomId);\n if (!roomPendingEvents) return;\n\n const sessionPendingEvents = roomPendingEvents.get(event.getWireContent().session_id);\n if (!sessionPendingEvents) return;\n\n sessionPendingEvents.delete(event);\n\n // also clean up the higher-level maps if they are now empty\n if (sessionPendingEvents.size === 0) {\n roomPendingEvents.delete(event.getWireContent().session_id);\n if (roomPendingEvents.size === 0) {\n this.eventsPendingKey.delete(roomId);\n }\n }\n }\n}\n\nfunction stringifyEvent(event: MatrixEvent): string {\n return JSON.stringify({\n event_id: event.getId(),\n type: event.getWireType(),\n sender: event.getSender(),\n state_key: event.getStateKey(),\n content: event.getWireContent(),\n origin_server_ts: event.getTs(),\n });\n}\n\nfunction rustEncryptionInfoToJsEncryptionInfo(\n logger: Logger,\n encryptionInfo: RustSdkCryptoJs.EncryptionInfo | undefined,\n): EventEncryptionInfo | null {\n if (encryptionInfo === undefined) {\n // not decrypted here\n return null;\n }\n\n // TODO: use strict shield semantics.\n const shieldState = encryptionInfo.shieldState(false);\n\n let shieldColour: EventShieldColour;\n switch (shieldState.color) {\n case RustSdkCryptoJs.ShieldColor.Grey:\n shieldColour = EventShieldColour.GREY;\n break;\n case RustSdkCryptoJs.ShieldColor.None:\n shieldColour = EventShieldColour.NONE;\n break;\n default:\n shieldColour = EventShieldColour.RED;\n }\n\n let shieldReason: EventShieldReason | null;\n if (shieldState.message === undefined) {\n shieldReason = null;\n } else if (shieldState.message === \"Encrypted by an unverified user.\") {\n // this case isn't actually used with lax shield semantics.\n shieldReason = EventShieldReason.UNVERIFIED_IDENTITY;\n } else if (shieldState.message === \"Encrypted by a device not verified by its owner.\") {\n shieldReason = EventShieldReason.UNSIGNED_DEVICE;\n } else if (\n shieldState.message === \"The authenticity of this encrypted message can't be guaranteed on this device.\"\n ) {\n shieldReason = EventShieldReason.AUTHENTICITY_NOT_GUARANTEED;\n } else if (shieldState.message === \"Encrypted by an unknown or deleted device.\") {\n shieldReason = EventShieldReason.UNKNOWN_DEVICE;\n } else {\n logger.warn(`Unknown shield state message '${shieldState.message}'`);\n shieldReason = EventShieldReason.UNKNOWN;\n }\n\n return { shieldColour, shieldReason };\n}\n\ntype CryptoEvents = (typeof CryptoEvent)[keyof typeof CryptoEvent];\ntype RustCryptoEvents = Exclude<CryptoEvents, CryptoEvent.LegacyCryptoStoreMigrationProgress>;\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,WAAW,MAAM,cAAc;AACtC,OAAO,KAAKC,eAAe,MAAM,oCAAoC;AAGrE,SAASC,eAAe,QAAQ,yBAAyB;AAIzD,SAAsBC,gBAAgB,QAAQ,oBAAoB;AAGlE,SAGIC,eAAe,QAEZ,mCAAmC;AAC1C,SAASC,MAAM,EAAUC,OAAO,QAAQ,cAAc;AACtD,SAAmCC,MAAM,QAAQ,sBAAsB;AACvE,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,wBAAwB,QAAQ,+BAA+B;AACxE,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,WAAW,EAAEC,cAAc,QAAQ,aAAa;AACzD,SAIIC,eAAe,EAKfC,qBAAqB,EACrBC,wBAAwB,EAExBC,iBAAiB,EACjBC,iBAAiB,EAMjBC,sBAAsB,EAEtBC,iBAAiB,EACjBC,+BAA+B,EAE/BC,uBAAuB,EACvBC,uBAAuB,EACvBC,WAAW,QAIR,wBAAwB;AAC/B,SAASC,qBAAqB,EAAEC,oBAAoB,QAAQ,uBAAuB;AAGnF,SAASC,+BAA+B,QAAiC,sBAAsB;AAC/F,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,6BAA6B,EAAEC,qCAAqC,QAAQ,qBAAqB;AAC1G,SAASC,mBAAmB,EAAEC,uBAAuB,EAAEC,oCAAoC,QAAQ,mBAAmB;AACtH,SAASC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ACzC","ignoreList":[]}
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import { ServerSideSecretStorage } from "../secret-storage.ts";
|
2
|
-
/**
|
3
|
-
* Check that the private cross signing keys (master, self signing, user signing) are stored in the secret storage and encrypted with the default secret storage key.
|
4
|
-
*
|
5
|
-
* @param secretStorage - The secret store using account data
|
6
|
-
* @returns True if the cross-signing keys are all stored and encrypted with the same secret storage key.
|
7
|
-
*
|
8
|
-
* @internal
|
9
|
-
*/
|
10
|
-
export declare function secretStorageContainsCrossSigningKeys(secretStorage: ServerSideSecretStorage): Promise<boolean>;
|
11
|
-
/**
|
12
|
-
*
|
13
|
-
* Check that the secret storage can access the given secrets using the default key.
|
14
|
-
*
|
15
|
-
* @param secretStorage - The secret store using account data
|
16
|
-
* @param secretNames - The secret names to check
|
17
|
-
* @returns True if all the given secrets are accessible and encrypted with the given key.
|
18
|
-
*
|
19
|
-
* @internal
|
20
|
-
*/
|
21
|
-
export declare function secretStorageCanAccessSecrets(secretStorage: ServerSideSecretStorage, secretNames: string[]): Promise<boolean>;
|
22
|
-
//# sourceMappingURL=secret-storage.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"secret-storage.d.ts","sourceRoot":"","sources":["../../src/rust-crypto/secret-storage.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAE/D;;;;;;;GAOG;AACH,wBAAsB,qCAAqC,CAAC,aAAa,EAAE,uBAAuB,GAAG,OAAO,CAAC,OAAO,CAAC,CAMpH;AAED;;;;;;;;;GASG;AACH,wBAAsB,6BAA6B,CAC/C,aAAa,EAAE,uBAAuB,EACtC,WAAW,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,OAAO,CAAC,CAYlB"}
|
@@ -1,63 +0,0 @@
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
2
|
-
/*
|
3
|
-
Copyright 2023 The Matrix.org Foundation C.I.C.
|
4
|
-
|
5
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
you may not use this file except in compliance with the License.
|
7
|
-
You may obtain a copy of the License at
|
8
|
-
|
9
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
|
11
|
-
Unless required by applicable law or agreed to in writing, software
|
12
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
See the License for the specific language governing permissions and
|
15
|
-
limitations under the License.
|
16
|
-
*/
|
17
|
-
|
18
|
-
/**
|
19
|
-
* Check that the private cross signing keys (master, self signing, user signing) are stored in the secret storage and encrypted with the default secret storage key.
|
20
|
-
*
|
21
|
-
* @param secretStorage - The secret store using account data
|
22
|
-
* @returns True if the cross-signing keys are all stored and encrypted with the same secret storage key.
|
23
|
-
*
|
24
|
-
* @internal
|
25
|
-
*/
|
26
|
-
export function secretStorageContainsCrossSigningKeys(_x) {
|
27
|
-
return _secretStorageContainsCrossSigningKeys.apply(this, arguments);
|
28
|
-
}
|
29
|
-
|
30
|
-
/**
|
31
|
-
*
|
32
|
-
* Check that the secret storage can access the given secrets using the default key.
|
33
|
-
*
|
34
|
-
* @param secretStorage - The secret store using account data
|
35
|
-
* @param secretNames - The secret names to check
|
36
|
-
* @returns True if all the given secrets are accessible and encrypted with the given key.
|
37
|
-
*
|
38
|
-
* @internal
|
39
|
-
*/
|
40
|
-
function _secretStorageContainsCrossSigningKeys() {
|
41
|
-
_secretStorageContainsCrossSigningKeys = _asyncToGenerator(function* (secretStorage) {
|
42
|
-
return secretStorageCanAccessSecrets(secretStorage, ["m.cross_signing.master", "m.cross_signing.user_signing", "m.cross_signing.self_signing"]);
|
43
|
-
});
|
44
|
-
return _secretStorageContainsCrossSigningKeys.apply(this, arguments);
|
45
|
-
}
|
46
|
-
export function secretStorageCanAccessSecrets(_x2, _x3) {
|
47
|
-
return _secretStorageCanAccessSecrets.apply(this, arguments);
|
48
|
-
}
|
49
|
-
function _secretStorageCanAccessSecrets() {
|
50
|
-
_secretStorageCanAccessSecrets = _asyncToGenerator(function* (secretStorage, secretNames) {
|
51
|
-
var defaultKeyId = yield secretStorage.getDefaultKeyId();
|
52
|
-
if (!defaultKeyId) return false;
|
53
|
-
for (var secretName of secretNames) {
|
54
|
-
// check which keys this particular secret is encrypted with
|
55
|
-
var record = (yield secretStorage.isStored(secretName)) || {};
|
56
|
-
// if it's not encrypted with the right key, there is no point continuing
|
57
|
-
if (!(defaultKeyId in record)) return false;
|
58
|
-
}
|
59
|
-
return true;
|
60
|
-
});
|
61
|
-
return _secretStorageCanAccessSecrets.apply(this, arguments);
|
62
|
-
}
|
63
|
-
//# sourceMappingURL=secret-storage.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"secret-storage.js","names":["secretStorageContainsCrossSigningKeys","_x","_secretStorageContainsCrossSigningKeys","apply","arguments","_asyncToGenerator","secretStorage","secretStorageCanAccessSecrets","_x2","_x3","_secretStorageCanAccessSecrets","secretNames","defaultKeyId","getDefaultKeyId","secretName","record","isStored"],"sources":["../../src/rust-crypto/secret-storage.ts"],"sourcesContent":["/*\nCopyright 2023 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 { ServerSideSecretStorage } from \"../secret-storage.ts\";\n\n/**\n * Check that the private cross signing keys (master, self signing, user signing) are stored in the secret storage and encrypted with the default secret storage key.\n *\n * @param secretStorage - The secret store using account data\n * @returns True if the cross-signing keys are all stored and encrypted with the same secret storage key.\n *\n * @internal\n */\nexport async function secretStorageContainsCrossSigningKeys(secretStorage: ServerSideSecretStorage): Promise<boolean> {\n return secretStorageCanAccessSecrets(secretStorage, [\n \"m.cross_signing.master\",\n \"m.cross_signing.user_signing\",\n \"m.cross_signing.self_signing\",\n ]);\n}\n\n/**\n *\n * Check that the secret storage can access the given secrets using the default key.\n *\n * @param secretStorage - The secret store using account data\n * @param secretNames - The secret names to check\n * @returns True if all the given secrets are accessible and encrypted with the given key.\n *\n * @internal\n */\nexport async function secretStorageCanAccessSecrets(\n secretStorage: ServerSideSecretStorage,\n secretNames: string[],\n): Promise<boolean> {\n const defaultKeyId = await secretStorage.getDefaultKeyId();\n if (!defaultKeyId) return false;\n\n for (const secretName of secretNames) {\n // check which keys this particular secret is encrypted with\n const record = (await secretStorage.isStored(secretName)) || {};\n // if it's not encrypted with the right key, there is no point continuing\n if (!(defaultKeyId in record)) return false;\n }\n\n return true;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAsBA,qCAAqCA,CAAAC,EAAA;EAAA,OAAAC,sCAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA;;AAQ3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AATA,SAAAF,uCAAA;EAAAA,sCAAA,GAAAG,iBAAA,CARO,WAAqDC,aAAsC,EAAoB;IAClH,OAAOC,6BAA6B,CAACD,aAAa,EAAE,CAChD,wBAAwB,EACxB,8BAA8B,EAC9B,8BAA8B,CACjC,CAAC;EACN,CAAC;EAAA,OAAAJ,sCAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA;AAYD,gBAAsBG,6BAA6BA,CAAAC,GAAA,EAAAC,GAAA;EAAA,OAAAC,8BAAA,CAAAP,KAAA,OAAAC,SAAA;AAAA;AAelD,SAAAM,+BAAA;EAAAA,8BAAA,GAAAL,iBAAA,CAfM,WACHC,aAAsC,EACtCK,WAAqB,EACL;IAChB,IAAMC,YAAY,SAASN,aAAa,CAACO,eAAe,CAAC,CAAC;IAC1D,IAAI,CAACD,YAAY,EAAE,OAAO,KAAK;IAE/B,KAAK,IAAME,UAAU,IAAIH,WAAW,EAAE;MAClC;MACA,IAAMI,MAAM,GAAG,OAAOT,aAAa,CAACU,QAAQ,CAACF,UAAU,CAAC,KAAK,CAAC,CAAC;MAC/D;MACA,IAAI,EAAEF,YAAY,IAAIG,MAAM,CAAC,EAAE,OAAO,KAAK;IAC/C;IAEA,OAAO,IAAI;EACf,CAAC;EAAA,OAAAL,8BAAA,CAAAP,KAAA,OAAAC,SAAA;AAAA","ignoreList":[]}
|