@unwanted/matrix-sdk-mini 34.12.0-2 → 34.12.0-4
Sign up to get free protection for your applications and to get access to all the features.
- package/git-revision.txt +1 -1
- package/lib/@types/global.d.js +0 -2
- package/lib/@types/global.d.js.map +1 -1
- package/lib/browser-index.d.ts.map +1 -1
- package/lib/browser-index.js +0 -11
- package/lib/browser-index.js.map +1 -1
- package/lib/client.d.ts +2 -1221
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +331 -2821
- package/lib/client.js.map +1 -1
- package/lib/embedded.d.ts +0 -22
- package/lib/embedded.d.ts.map +1 -1
- package/lib/embedded.js +24 -166
- package/lib/embedded.js.map +1 -1
- package/lib/event-mapper.d.ts.map +1 -1
- package/lib/event-mapper.js +0 -4
- package/lib/event-mapper.js.map +1 -1
- package/lib/matrix.d.ts +0 -19
- package/lib/matrix.d.ts.map +1 -1
- package/lib/matrix.js +1 -26
- package/lib/matrix.js.map +1 -1
- package/lib/models/MSC3089Branch.d.ts.map +1 -1
- package/lib/models/MSC3089Branch.js +0 -3
- package/lib/models/MSC3089Branch.js.map +1 -1
- package/lib/models/event.d.ts +0 -94
- package/lib/models/event.d.ts.map +1 -1
- package/lib/models/event.js +0 -274
- package/lib/models/event.js.map +1 -1
- package/lib/models/poll.d.ts.map +1 -1
- package/lib/models/poll.js +1 -5
- package/lib/models/poll.js.map +1 -1
- package/lib/models/relations-container.d.ts.map +1 -1
- package/lib/models/relations-container.js +1 -7
- package/lib/models/relations-container.js.map +1 -1
- package/lib/models/relations.d.ts +0 -1
- package/lib/models/relations.d.ts.map +1 -1
- package/lib/models/relations.js +0 -8
- package/lib/models/relations.js.map +1 -1
- package/lib/models/room-state.d.ts.map +1 -1
- package/lib/models/room-state.js +10 -26
- package/lib/models/room-state.js.map +1 -1
- package/lib/models/room.d.ts +0 -18
- package/lib/models/room.d.ts.map +1 -1
- package/lib/models/room.js +94 -148
- package/lib/models/room.js.map +1 -1
- package/lib/models/thread.d.ts.map +1 -1
- package/lib/models/thread.js +0 -1
- package/lib/models/thread.js.map +1 -1
- package/lib/sliding-sync-sdk.d.ts +2 -3
- package/lib/sliding-sync-sdk.d.ts.map +1 -1
- package/lib/sliding-sync-sdk.js +41 -90
- package/lib/sliding-sync-sdk.js.map +1 -1
- package/lib/sync.d.ts +0 -12
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +1 -73
- package/lib/sync.js.map +1 -1
- package/lib/testing.d.ts +0 -48
- package/lib/testing.d.ts.map +1 -1
- package/lib/testing.js +0 -105
- package/lib/testing.js.map +1 -1
- package/lib/types.d.ts +0 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +1 -3
- package/src/@types/global.d.ts +0 -3
- package/src/browser-index.ts +0 -11
- package/src/client.ts +60 -2882
- package/src/embedded.ts +3 -130
- package/src/event-mapper.ts +0 -4
- package/src/matrix.ts +0 -28
- package/src/models/MSC3089Branch.ts +0 -3
- package/src/models/event.ts +0 -289
- package/src/models/poll.ts +0 -6
- package/src/models/relations-container.ts +1 -8
- package/src/models/relations.ts +0 -8
- package/src/models/room-state.ts +2 -8
- package/src/models/room.ts +0 -62
- package/src/models/thread.ts +0 -1
- package/src/sliding-sync-sdk.ts +2 -72
- package/src/sync.ts +1 -98
- package/src/testing.ts +0 -108
- package/src/types.ts +0 -1
- package/CHANGELOG.md +0 -5910
- package/lib/@types/AESEncryptedSecretStoragePayload.d.ts +0 -14
- package/lib/@types/AESEncryptedSecretStoragePayload.d.ts.map +0 -1
- package/lib/@types/AESEncryptedSecretStoragePayload.js +0 -1
- package/lib/@types/AESEncryptedSecretStoragePayload.js.map +0 -1
- package/lib/@types/crypto.d.ts +0 -47
- package/lib/@types/crypto.d.ts.map +0 -1
- package/lib/@types/crypto.js +0 -1
- package/lib/@types/crypto.js.map +0 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js +0 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js.map +0 -1
- package/lib/common-crypto/CryptoBackend.d.ts +0 -240
- package/lib/common-crypto/CryptoBackend.d.ts.map +0 -1
- package/lib/common-crypto/CryptoBackend.js +0 -73
- package/lib/common-crypto/CryptoBackend.js.map +0 -1
- package/lib/common-crypto/key-passphrase.d.ts +0 -14
- package/lib/common-crypto/key-passphrase.d.ts.map +0 -1
- package/lib/common-crypto/key-passphrase.js +0 -33
- package/lib/common-crypto/key-passphrase.js.map +0 -1
- package/lib/crypto/CrossSigning.d.ts +0 -184
- package/lib/crypto/CrossSigning.d.ts.map +0 -1
- package/lib/crypto/CrossSigning.js +0 -718
- package/lib/crypto/CrossSigning.js.map +0 -1
- package/lib/crypto/DeviceList.d.ts +0 -216
- package/lib/crypto/DeviceList.d.ts.map +0 -1
- package/lib/crypto/DeviceList.js +0 -892
- package/lib/crypto/DeviceList.js.map +0 -1
- package/lib/crypto/EncryptionSetup.d.ts +0 -152
- package/lib/crypto/EncryptionSetup.d.ts.map +0 -1
- package/lib/crypto/EncryptionSetup.js +0 -356
- package/lib/crypto/EncryptionSetup.js.map +0 -1
- package/lib/crypto/OlmDevice.d.ts +0 -457
- package/lib/crypto/OlmDevice.d.ts.map +0 -1
- package/lib/crypto/OlmDevice.js +0 -1241
- package/lib/crypto/OlmDevice.js.map +0 -1
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts +0 -109
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts.map +0 -1
- package/lib/crypto/OutgoingRoomKeyRequestManager.js +0 -415
- package/lib/crypto/OutgoingRoomKeyRequestManager.js.map +0 -1
- package/lib/crypto/RoomList.d.ts +0 -26
- package/lib/crypto/RoomList.d.ts.map +0 -1
- package/lib/crypto/RoomList.js +0 -71
- package/lib/crypto/RoomList.js.map +0 -1
- package/lib/crypto/SecretSharing.d.ts +0 -24
- package/lib/crypto/SecretSharing.d.ts.map +0 -1
- package/lib/crypto/SecretSharing.js +0 -194
- package/lib/crypto/SecretSharing.js.map +0 -1
- package/lib/crypto/SecretStorage.d.ts +0 -55
- package/lib/crypto/SecretStorage.d.ts.map +0 -1
- package/lib/crypto/SecretStorage.js +0 -118
- package/lib/crypto/SecretStorage.js.map +0 -1
- package/lib/crypto/aes.d.ts +0 -6
- package/lib/crypto/aes.d.ts.map +0 -1
- package/lib/crypto/aes.js +0 -24
- package/lib/crypto/aes.js.map +0 -1
- package/lib/crypto/algorithms/base.d.ts +0 -156
- package/lib/crypto/algorithms/base.d.ts.map +0 -1
- package/lib/crypto/algorithms/base.js +0 -187
- package/lib/crypto/algorithms/base.js.map +0 -1
- package/lib/crypto/algorithms/index.d.ts +0 -4
- package/lib/crypto/algorithms/index.d.ts.map +0 -1
- package/lib/crypto/algorithms/index.js +0 -20
- package/lib/crypto/algorithms/index.js.map +0 -1
- package/lib/crypto/algorithms/megolm.d.ts +0 -385
- package/lib/crypto/algorithms/megolm.d.ts.map +0 -1
- package/lib/crypto/algorithms/megolm.js +0 -1822
- package/lib/crypto/algorithms/megolm.js.map +0 -1
- package/lib/crypto/algorithms/olm.d.ts +0 -5
- package/lib/crypto/algorithms/olm.d.ts.map +0 -1
- package/lib/crypto/algorithms/olm.js +0 -299
- package/lib/crypto/algorithms/olm.js.map +0 -1
- package/lib/crypto/api.d.ts +0 -32
- package/lib/crypto/api.d.ts.map +0 -1
- package/lib/crypto/api.js +0 -22
- package/lib/crypto/api.js.map +0 -1
- package/lib/crypto/backup.d.ts +0 -227
- package/lib/crypto/backup.d.ts.map +0 -1
- package/lib/crypto/backup.js +0 -824
- package/lib/crypto/backup.js.map +0 -1
- package/lib/crypto/crypto.d.ts +0 -3
- package/lib/crypto/crypto.d.ts.map +0 -1
- package/lib/crypto/crypto.js +0 -19
- package/lib/crypto/crypto.js.map +0 -1
- package/lib/crypto/dehydration.d.ts +0 -34
- package/lib/crypto/dehydration.d.ts.map +0 -1
- package/lib/crypto/dehydration.js +0 -252
- package/lib/crypto/dehydration.js.map +0 -1
- package/lib/crypto/device-converter.d.ts +0 -9
- package/lib/crypto/device-converter.d.ts.map +0 -1
- package/lib/crypto/device-converter.js +0 -42
- package/lib/crypto/device-converter.js.map +0 -1
- package/lib/crypto/deviceinfo.d.ts +0 -99
- package/lib/crypto/deviceinfo.d.ts.map +0 -1
- package/lib/crypto/deviceinfo.js +0 -148
- package/lib/crypto/deviceinfo.js.map +0 -1
- package/lib/crypto/index.d.ts +0 -1209
- package/lib/crypto/index.d.ts.map +0 -1
- package/lib/crypto/index.js +0 -4097
- package/lib/crypto/index.js.map +0 -1
- package/lib/crypto/key_passphrase.d.ts +0 -14
- package/lib/crypto/key_passphrase.d.ts.map +0 -1
- package/lib/crypto/key_passphrase.js +0 -44
- package/lib/crypto/key_passphrase.js.map +0 -1
- package/lib/crypto/keybackup.d.ts +0 -18
- package/lib/crypto/keybackup.d.ts.map +0 -1
- package/lib/crypto/keybackup.js +0 -1
- package/lib/crypto/keybackup.js.map +0 -1
- package/lib/crypto/olmlib.d.ts +0 -129
- package/lib/crypto/olmlib.d.ts.map +0 -1
- package/lib/crypto/olmlib.js +0 -492
- package/lib/crypto/olmlib.js.map +0 -1
- package/lib/crypto/recoverykey.d.ts +0 -2
- package/lib/crypto/recoverykey.d.ts.map +0 -1
- package/lib/crypto/recoverykey.js +0 -19
- package/lib/crypto/recoverykey.js.map +0 -1
- package/lib/crypto/store/base.d.ts +0 -252
- package/lib/crypto/store/base.d.ts.map +0 -1
- package/lib/crypto/store/base.js +0 -64
- package/lib/crypto/store/base.js.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts +0 -187
- package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.js +0 -1145
- package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store.d.ts +0 -432
- package/lib/crypto/store/indexeddb-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store.js +0 -728
- package/lib/crypto/store/indexeddb-crypto-store.js.map +0 -1
- package/lib/crypto/store/localStorage-crypto-store.d.ts +0 -119
- package/lib/crypto/store/localStorage-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/localStorage-crypto-store.js +0 -531
- package/lib/crypto/store/localStorage-crypto-store.js.map +0 -1
- package/lib/crypto/store/memory-crypto-store.d.ts +0 -215
- package/lib/crypto/store/memory-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/memory-crypto-store.js +0 -622
- package/lib/crypto/store/memory-crypto-store.js.map +0 -1
- package/lib/crypto/verification/Base.d.ts +0 -105
- package/lib/crypto/verification/Base.d.ts.map +0 -1
- package/lib/crypto/verification/Base.js +0 -372
- package/lib/crypto/verification/Base.js.map +0 -1
- package/lib/crypto/verification/Error.d.ts +0 -35
- package/lib/crypto/verification/Error.d.ts.map +0 -1
- package/lib/crypto/verification/Error.js +0 -86
- package/lib/crypto/verification/Error.js.map +0 -1
- package/lib/crypto/verification/IllegalMethod.d.ts +0 -15
- package/lib/crypto/verification/IllegalMethod.d.ts.map +0 -1
- package/lib/crypto/verification/IllegalMethod.js +0 -43
- package/lib/crypto/verification/IllegalMethod.js.map +0 -1
- package/lib/crypto/verification/QRCode.d.ts +0 -51
- package/lib/crypto/verification/QRCode.d.ts.map +0 -1
- package/lib/crypto/verification/QRCode.js +0 -277
- package/lib/crypto/verification/QRCode.js.map +0 -1
- package/lib/crypto/verification/SAS.d.ts +0 -27
- package/lib/crypto/verification/SAS.d.ts.map +0 -1
- package/lib/crypto/verification/SAS.js +0 -485
- package/lib/crypto/verification/SAS.js.map +0 -1
- package/lib/crypto/verification/SASDecimal.d.ts +0 -8
- package/lib/crypto/verification/SASDecimal.d.ts.map +0 -1
- package/lib/crypto/verification/SASDecimal.js +0 -34
- package/lib/crypto/verification/SASDecimal.js.map +0 -1
- package/lib/crypto/verification/request/Channel.d.ts +0 -18
- package/lib/crypto/verification/request/Channel.d.ts.map +0 -1
- package/lib/crypto/verification/request/Channel.js +0 -1
- package/lib/crypto/verification/request/Channel.js.map +0 -1
- package/lib/crypto/verification/request/InRoomChannel.d.ts +0 -113
- package/lib/crypto/verification/request/InRoomChannel.d.ts.map +0 -1
- package/lib/crypto/verification/request/InRoomChannel.js +0 -351
- package/lib/crypto/verification/request/InRoomChannel.js.map +0 -1
- package/lib/crypto/verification/request/ToDeviceChannel.d.ts +0 -105
- package/lib/crypto/verification/request/ToDeviceChannel.d.ts.map +0 -1
- package/lib/crypto/verification/request/ToDeviceChannel.js +0 -328
- package/lib/crypto/verification/request/ToDeviceChannel.js.map +0 -1
- package/lib/crypto/verification/request/VerificationRequest.d.ts +0 -227
- package/lib/crypto/verification/request/VerificationRequest.d.ts.map +0 -1
- package/lib/crypto/verification/request/VerificationRequest.js +0 -937
- package/lib/crypto/verification/request/VerificationRequest.js.map +0 -1
- package/lib/crypto-api/CryptoEvent.d.ts +0 -69
- package/lib/crypto-api/CryptoEvent.d.ts.map +0 -1
- package/lib/crypto-api/CryptoEvent.js +0 -33
- package/lib/crypto-api/CryptoEvent.js.map +0 -1
- package/lib/crypto-api/CryptoEventHandlerMap.d.ts +0 -16
- package/lib/crypto-api/CryptoEventHandlerMap.d.ts.map +0 -1
- package/lib/crypto-api/CryptoEventHandlerMap.js +0 -22
- package/lib/crypto-api/CryptoEventHandlerMap.js.map +0 -1
- package/lib/crypto-api/index.d.ts +0 -978
- package/lib/crypto-api/index.d.ts.map +0 -1
- package/lib/crypto-api/index.js +0 -304
- package/lib/crypto-api/index.js.map +0 -1
- package/lib/crypto-api/key-passphrase.d.ts +0 -11
- package/lib/crypto-api/key-passphrase.d.ts.map +0 -1
- package/lib/crypto-api/key-passphrase.js +0 -51
- package/lib/crypto-api/key-passphrase.js.map +0 -1
- package/lib/crypto-api/keybackup.d.ts +0 -88
- package/lib/crypto-api/keybackup.d.ts.map +0 -1
- package/lib/crypto-api/keybackup.js +0 -1
- package/lib/crypto-api/keybackup.js.map +0 -1
- package/lib/crypto-api/recovery-key.d.ts +0 -11
- package/lib/crypto-api/recovery-key.d.ts.map +0 -1
- package/lib/crypto-api/recovery-key.js +0 -65
- package/lib/crypto-api/recovery-key.js.map +0 -1
- package/lib/crypto-api/verification.d.ts +0 -344
- package/lib/crypto-api/verification.d.ts.map +0 -1
- package/lib/crypto-api/verification.js +0 -91
- package/lib/crypto-api/verification.js.map +0 -1
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts +0 -112
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts.map +0 -1
- package/lib/rendezvous/MSC4108SignInWithQR.js +0 -392
- package/lib/rendezvous/MSC4108SignInWithQR.js.map +0 -1
- package/lib/rendezvous/RendezvousChannel.d.ts +0 -27
- package/lib/rendezvous/RendezvousChannel.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousChannel.js +0 -1
- package/lib/rendezvous/RendezvousChannel.js.map +0 -1
- package/lib/rendezvous/RendezvousCode.d.ts +0 -9
- package/lib/rendezvous/RendezvousCode.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousCode.js +0 -1
- package/lib/rendezvous/RendezvousCode.js.map +0 -1
- package/lib/rendezvous/RendezvousError.d.ts +0 -6
- package/lib/rendezvous/RendezvousError.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousError.js +0 -23
- package/lib/rendezvous/RendezvousError.js.map +0 -1
- package/lib/rendezvous/RendezvousFailureReason.d.ts +0 -31
- package/lib/rendezvous/RendezvousFailureReason.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousFailureReason.js +0 -38
- package/lib/rendezvous/RendezvousFailureReason.js.map +0 -1
- package/lib/rendezvous/RendezvousIntent.d.ts +0 -5
- package/lib/rendezvous/RendezvousIntent.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousIntent.js +0 -22
- package/lib/rendezvous/RendezvousIntent.js.map +0 -1
- package/lib/rendezvous/RendezvousTransport.d.ts +0 -36
- package/lib/rendezvous/RendezvousTransport.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousTransport.js +0 -1
- package/lib/rendezvous/RendezvousTransport.js.map +0 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts +0 -58
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts.map +0 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.js +0 -246
- package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +0 -1
- package/lib/rendezvous/channels/index.d.ts +0 -2
- package/lib/rendezvous/channels/index.d.ts.map +0 -1
- package/lib/rendezvous/channels/index.js +0 -18
- package/lib/rendezvous/channels/index.js.map +0 -1
- package/lib/rendezvous/index.d.ts +0 -10
- package/lib/rendezvous/index.d.ts.map +0 -1
- package/lib/rendezvous/index.js +0 -23
- package/lib/rendezvous/index.js.map +0 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +0 -61
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts.map +0 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js +0 -253
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +0 -1
- package/lib/rendezvous/transports/index.d.ts +0 -2
- package/lib/rendezvous/transports/index.d.ts.map +0 -1
- package/lib/rendezvous/transports/index.js +0 -18
- package/lib/rendezvous/transports/index.js.map +0 -1
- package/lib/rust-crypto/CrossSigningIdentity.d.ts +0 -33
- package/lib/rust-crypto/CrossSigningIdentity.d.ts.map +0 -1
- package/lib/rust-crypto/CrossSigningIdentity.js +0 -157
- package/lib/rust-crypto/CrossSigningIdentity.js.map +0 -1
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts +0 -98
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts.map +0 -1
- package/lib/rust-crypto/DehydratedDeviceManager.js +0 -285
- package/lib/rust-crypto/DehydratedDeviceManager.js.map +0 -1
- package/lib/rust-crypto/KeyClaimManager.d.ts +0 -33
- package/lib/rust-crypto/KeyClaimManager.d.ts.map +0 -1
- package/lib/rust-crypto/KeyClaimManager.js +0 -82
- package/lib/rust-crypto/KeyClaimManager.js.map +0 -1
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts +0 -43
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts.map +0 -1
- package/lib/rust-crypto/OutgoingRequestProcessor.js +0 -195
- package/lib/rust-crypto/OutgoingRequestProcessor.js.map +0 -1
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts +0 -47
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts.map +0 -1
- package/lib/rust-crypto/OutgoingRequestsManager.js +0 -148
- package/lib/rust-crypto/OutgoingRequestsManager.js.map +0 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +0 -120
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts.map +0 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +0 -467
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +0 -1
- package/lib/rust-crypto/RoomEncryptor.d.ts +0 -98
- package/lib/rust-crypto/RoomEncryptor.d.ts.map +0 -1
- package/lib/rust-crypto/RoomEncryptor.js +0 -299
- package/lib/rust-crypto/RoomEncryptor.js.map +0 -1
- package/lib/rust-crypto/backup.d.ts +0 -254
- package/lib/rust-crypto/backup.d.ts.map +0 -1
- package/lib/rust-crypto/backup.js +0 -837
- package/lib/rust-crypto/backup.js.map +0 -1
- package/lib/rust-crypto/constants.d.ts +0 -3
- package/lib/rust-crypto/constants.d.ts.map +0 -1
- package/lib/rust-crypto/constants.js +0 -19
- package/lib/rust-crypto/constants.js.map +0 -1
- package/lib/rust-crypto/device-converter.d.ts +0 -28
- package/lib/rust-crypto/device-converter.d.ts.map +0 -1
- package/lib/rust-crypto/device-converter.js +0 -123
- package/lib/rust-crypto/device-converter.js.map +0 -1
- package/lib/rust-crypto/index.d.ts +0 -61
- package/lib/rust-crypto/index.d.ts.map +0 -1
- package/lib/rust-crypto/index.js +0 -152
- package/lib/rust-crypto/index.js.map +0 -1
- package/lib/rust-crypto/libolm_migration.d.ts +0 -81
- package/lib/rust-crypto/libolm_migration.d.ts.map +0 -1
- package/lib/rust-crypto/libolm_migration.js +0 -459
- package/lib/rust-crypto/libolm_migration.js.map +0 -1
- package/lib/rust-crypto/rust-crypto.d.ts +0 -556
- package/lib/rust-crypto/rust-crypto.d.ts.map +0 -1
- package/lib/rust-crypto/rust-crypto.js +0 -2016
- package/lib/rust-crypto/rust-crypto.js.map +0 -1
- package/lib/rust-crypto/secret-storage.d.ts +0 -22
- package/lib/rust-crypto/secret-storage.d.ts.map +0 -1
- package/lib/rust-crypto/secret-storage.js +0 -63
- package/lib/rust-crypto/secret-storage.js.map +0 -1
- package/lib/rust-crypto/verification.d.ts +0 -319
- package/lib/rust-crypto/verification.d.ts.map +0 -1
- package/lib/rust-crypto/verification.js +0 -816
- package/lib/rust-crypto/verification.js.map +0 -1
- package/lib/secret-storage.d.ts +0 -370
- package/lib/secret-storage.d.ts.map +0 -1
- package/lib/secret-storage.js +0 -466
- package/lib/secret-storage.js.map +0 -1
- package/lib/utils/decryptAESSecretStorageItem.d.ts +0 -12
- package/lib/utils/decryptAESSecretStorageItem.d.ts.map +0 -1
- package/lib/utils/decryptAESSecretStorageItem.js +0 -50
- package/lib/utils/decryptAESSecretStorageItem.js.map +0 -1
- package/lib/utils/encryptAESSecretStorageItem.d.ts +0 -16
- package/lib/utils/encryptAESSecretStorageItem.d.ts.map +0 -1
- package/lib/utils/encryptAESSecretStorageItem.js +0 -68
- package/lib/utils/encryptAESSecretStorageItem.js.map +0 -1
- package/lib/utils/internal/deriveKeys.d.ts +0 -10
- package/lib/utils/internal/deriveKeys.d.ts.map +0 -1
- package/lib/utils/internal/deriveKeys.js +0 -60
- package/lib/utils/internal/deriveKeys.js.map +0 -1
- package/src/@types/AESEncryptedSecretStoragePayload.ts +0 -29
- package/src/@types/crypto.ts +0 -73
- package/src/@types/matrix-sdk-crypto-wasm.d.ts +0 -44
- package/src/common-crypto/CryptoBackend.ts +0 -302
- package/src/common-crypto/README.md +0 -4
- package/src/common-crypto/key-passphrase.ts +0 -43
- package/src/crypto/CrossSigning.ts +0 -773
- package/src/crypto/DeviceList.ts +0 -989
- package/src/crypto/EncryptionSetup.ts +0 -351
- package/src/crypto/OlmDevice.ts +0 -1500
- package/src/crypto/OutgoingRoomKeyRequestManager.ts +0 -485
- package/src/crypto/RoomList.ts +0 -70
- package/src/crypto/SecretSharing.ts +0 -240
- package/src/crypto/SecretStorage.ts +0 -136
- package/src/crypto/aes.ts +0 -23
- package/src/crypto/algorithms/base.ts +0 -236
- package/src/crypto/algorithms/index.ts +0 -20
- package/src/crypto/algorithms/megolm.ts +0 -2216
- package/src/crypto/algorithms/olm.ts +0 -381
- package/src/crypto/api.ts +0 -70
- package/src/crypto/backup.ts +0 -922
- package/src/crypto/crypto.ts +0 -18
- package/src/crypto/dehydration.ts +0 -272
- package/src/crypto/device-converter.ts +0 -45
- package/src/crypto/deviceinfo.ts +0 -158
- package/src/crypto/index.ts +0 -4414
- package/src/crypto/key_passphrase.ts +0 -42
- package/src/crypto/keybackup.ts +0 -47
- package/src/crypto/olmlib.ts +0 -539
- package/src/crypto/recoverykey.ts +0 -18
- package/src/crypto/store/base.ts +0 -348
- package/src/crypto/store/indexeddb-crypto-store-backend.ts +0 -1250
- package/src/crypto/store/indexeddb-crypto-store.ts +0 -845
- package/src/crypto/store/localStorage-crypto-store.ts +0 -579
- package/src/crypto/store/memory-crypto-store.ts +0 -680
- package/src/crypto/verification/Base.ts +0 -409
- package/src/crypto/verification/Error.ts +0 -76
- package/src/crypto/verification/IllegalMethod.ts +0 -50
- package/src/crypto/verification/QRCode.ts +0 -310
- package/src/crypto/verification/SAS.ts +0 -494
- package/src/crypto/verification/SASDecimal.ts +0 -37
- package/src/crypto/verification/request/Channel.ts +0 -34
- package/src/crypto/verification/request/InRoomChannel.ts +0 -371
- package/src/crypto/verification/request/ToDeviceChannel.ts +0 -354
- package/src/crypto/verification/request/VerificationRequest.ts +0 -976
- package/src/crypto-api/CryptoEvent.ts +0 -93
- package/src/crypto-api/CryptoEventHandlerMap.ts +0 -32
- package/src/crypto-api/index.ts +0 -1175
- package/src/crypto-api/key-passphrase.ts +0 -58
- package/src/crypto-api/keybackup.ts +0 -115
- package/src/crypto-api/recovery-key.ts +0 -69
- package/src/crypto-api/verification.ts +0 -408
- package/src/rendezvous/MSC4108SignInWithQR.ts +0 -444
- package/src/rendezvous/RendezvousChannel.ts +0 -48
- package/src/rendezvous/RendezvousCode.ts +0 -25
- package/src/rendezvous/RendezvousError.ts +0 -26
- package/src/rendezvous/RendezvousFailureReason.ts +0 -49
- package/src/rendezvous/RendezvousIntent.ts +0 -20
- package/src/rendezvous/RendezvousTransport.ts +0 -58
- package/src/rendezvous/channels/MSC4108SecureChannel.ts +0 -270
- package/src/rendezvous/channels/index.ts +0 -17
- package/src/rendezvous/index.ts +0 -25
- package/src/rendezvous/transports/MSC4108RendezvousSession.ts +0 -270
- package/src/rendezvous/transports/index.ts +0 -17
- package/src/rust-crypto/CrossSigningIdentity.ts +0 -183
- package/src/rust-crypto/DehydratedDeviceManager.ts +0 -306
- package/src/rust-crypto/KeyClaimManager.ts +0 -86
- package/src/rust-crypto/OutgoingRequestProcessor.ts +0 -236
- package/src/rust-crypto/OutgoingRequestsManager.ts +0 -143
- package/src/rust-crypto/PerSessionKeyBackupDownloader.ts +0 -501
- package/src/rust-crypto/RoomEncryptor.ts +0 -352
- package/src/rust-crypto/backup.ts +0 -881
- package/src/rust-crypto/constants.ts +0 -18
- package/src/rust-crypto/device-converter.ts +0 -128
- package/src/rust-crypto/index.ts +0 -237
- package/src/rust-crypto/libolm_migration.ts +0 -530
- package/src/rust-crypto/rust-crypto.ts +0 -2205
- package/src/rust-crypto/secret-storage.ts +0 -60
- package/src/rust-crypto/verification.ts +0 -830
- package/src/secret-storage.ts +0 -693
- package/src/utils/decryptAESSecretStorageItem.ts +0 -54
- package/src/utils/encryptAESSecretStorageItem.ts +0 -73
- package/src/utils/internal/deriveKeys.ts +0 -63
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"megolm.js","names":["v4","uuidv4","logger","olmlib","DecryptionAlgorithm","EncryptionAlgorithm","registerAlgorithm","UnknownDeviceError","WITHHELD_MESSAGES","EventType","MsgType","ToDeviceMessageId","RoomKeyRequestState","immediate","MapWithDefault","KnownMembership","DecryptionFailureCode","DecryptionError","isRoomSharedHistory","room","_room$currentState","_visibilityEvent$getC","visibilityEvent","currentState","getStateEvents","visibility","getContent","history_visibility","includes","hasCiphertext","content","ciphertext","length","Object","keys","OutboundSessionInfo","constructor","sessionId","sharedHistory","arguments","undefined","_defineProperty","Map","creationTime","Date","getTime","needsRotation","rotationPeriodMsgs","rotationPeriodMs","sessionLifetime","useCount","log","markSharedWithDevice","userId","deviceId","deviceKey","chainIndex","sharedWithDevices","getOrCreate","set","messageIndex","markNotifiedBlockedDevice","blockedDevicesNotified","sharedWithTooManyDevices","devicesInRoom","devices","has","_devicesInRoom$get","get","MegolmEncryption","params","_params$config$rotati","_params$config","_params$config$rotati2","_params$config2","Promise","resolve","roomId","prefixedLogger","getChild","concat","sessionRotationPeriodMsgs","config","rotation_period_msgs","sessionRotationPeriodMs","rotation_period_ms","ensureOutboundSession","blocked","_arguments","_this","_asyncToGenerator","singleOlmCreationPhase","setup","_ref","oldSession","session","prepareSession","shareSession","_x","apply","fallible","setupPromise","then","catch","e","error","_this2","_session","_session2","debug","prepareNewSession","outboundSessions","_this3","shareMap","userDevices","deviceInfo","_session$sharedWithDe","key","getIdentityKey","olmDevice","deviceCurve25519Key","push","getOutboundGroupSessionKey","payload","type","MEGOLM_ALGORITHM","chain_index","devicesWithoutSession","olmSessions","getExistingOlmSessions","baseApis","all","olmSessionList","Array","from","entries","map","_ref3","sessionsByUser","_ref4","flat","shareKeyWithOlmSessions","deviceList","_ref6","devicesByUser","device","errorDevices","start","now","failedServers","shareKeyWithDevices","retryDevices","failedServerMap","Set","server","add","failedDevices","userHS","slice","indexOf","retryDeviceList","_ref8","notifyFailedOlmDevices","size","_ref10","blockedByUser","_ref11","_deviceInfo","blockedMap","blockedCount","userBlockedDevices","_session$blockedDevic","_ref12","_ref13","notifyBlockedDevices","_this4","createOutboundGroupSession","addInboundGroupSession","ed25519","deviceEd25519Key","crypto","backupManager","backupGroupSession","getDevicesWithoutSessions","deviceMap","noOlmDevices","devicesToShareWith","sessionResults","sessionResult","delete","splitDevices","maxDevicesPerRequest","currentSlice","mapSlices","values","pop","encryptAndSendKeysToDevices","encryptAndSendToDevices","sendBlockedNotificationsToDevices","userDeviceMap","_this5","contentMap","val","blockedInfo","message","_objectSpread","code","reason","room_id","session_id","sendToDevice","reshareKeyWithDevice","senderKey","_this6","_obSessionInfo$shared","obSessionInfo","sessionSharedData","warn","getInboundGroupSessionKey","ensureOlmSessionsForDevices","sender_claimed_ed25519_key","forwarding_curve25519_key_chain","shared_history","encryptedContent","algorithm","OLM_ALGORITHM","sender_key","encryptMessageForDevice","otkTimeout","_this7","devicemap","_this8","userDeviceMaps","i","taskDetail","d","_this9","unnotifiedFailedDevices","filterOutNotifiedErrorDevices","_this10","prepareToEncrypt","_this11","Error","encryptionPreparation","elapsedTime","startTime","cancel","cancelled","isCancelled","promise","getDevicesResult","getDevicesInRoom","globalErrorOnUnknownDevices","removeUnknownDevices","encryptMessage","eventType","_this12","_unused","forceDistributeToUnverified","isVerificationEvent","checkForUnknownDevices","payloadJson","encryptGroupMessage","JSON","stringify","device_id","KeyVerificationCancel","KeyVerificationDone","KeyVerificationMac","KeyVerificationStart","KeyVerificationKey","KeyVerificationReady","KeyVerificationAccept","RoomMessage","KeyVerificationRequest","forceDiscardSession","unknownDevices","isUnverified","isKnown","_arguments2","_this13","members","getEncryptionTargetMembers","shouldEncryptForInvitedMembers","u","membership","roomMembers","isBlacklisting","globalBlacklistUnverifiedDevices","isRoomBlacklisting","getBlacklistUnverifiedDevices","downloadKeys","userDevice","deviceTrust","checkDeviceTrust","isBlocked","isVerified","blockedDevices","MegolmDecryption","decryptEvent","event","_this14","getWireContent","MEGOLM_MISSING_FIELDS","addEventToPendingList","res","decryptGroupMessage","getRoomId","getId","getTs","name","errorCode","OLM_DECRYPT_GROUP_MESSAGE_ERROR","requestKeysForEvent","OLM_UNKNOWN_MESSAGE_INDEX","queryKeyBackupRateLimited","problem","sessionMayHaveProblems","info","getSender","problemDescription","PROBLEM_DESCRIPTIONS","unknown","fixed","MEGOLM_UNKNOWN_INBOUND_SESSION_ID","untrusted","removeEventFromPendingList","parse","result","MEGOLM_BAD_ROOM","clearEvent","senderCurve25519Key","claimedEd25519Key","keysClaimed","forwardingCurve25519KeyChain","wireContent","recipients","getKeyRequestRecipients","requestRoomKey","_senderPendingEvents$","pendingEvents","senderPendingEvents","roomKeyFromEvent","getSenderKey","extraSessionData","session_key","isOlmEncrypted","roomKey","sessionKey","exportFormat","forwardingKeyChain","getKeysClaimed","forwardedRoomKeyFromEvent","senderKeyUser","getUserByIdentityKey","claimedCurve25519Key","isArray","shouldAcceptForwardedKey","_this15","_this15$crypto$device","sendingDevice","getDeviceByIdentityKey","checkDeviceInfoTrust","fromUs","getUserId","keyFromOurVerifiedDevice","weRequested","wasRoomKeyRequested","fromInviter","wasRoomKeyForwardedByInviter","sharedAsHistory","wasRoomKeyForwardedAsHistory","_this16","outgoingRequests","cryptoStore","getOutgoingRoomKeyRequestsByTarget","Sent","some","req","requestBody","_room$getMember","_memberEvent$getUnsig","_memberEvent$getPrevC","getRoom","memberEvent","getMember","events","member","getUnsigned","prev_sender","getPrevContent","Invite","shouldParkForwardedKey","parkForwardedKey","_this17","parkedData","senderId","doTxn","txn","addParkedSharedHistory","addRoomKey","_this18","retryDecryption","cancelRoomKeyRequest","onForwardedRoomKey","_this19","onRoomKeyEvent","_this20","getType","onRoomKeyWithheldEvent","_this21","onNoOlmWithheldEvent","addInboundGroupSessionWithheld","retryDecryptionFromSender","_this22","sender","getSessionIdForDevice","recordSessionProblem","hasKeysForKeyRequest","keyRequest","body","hasInboundSessionKeys","shareKeysWithDevice","getStoredDevice","_devicemap$get","olmSessionResult","buildKeyForwardingMessage","_this23","importRoomKey","source","sender_claimed_keys","forceRedecryptIfUntrusted","_this24","_this24$pendingEvents","pending","pendingList","_ref15","ev","attemptDecryption","isRetry","_unused2","_x2","_this25","_ref17","_ref16","_sessionId","_ref18","_unused3","_x4","_x3","sendSharedHistoryInboundSessions","_this26","sharedHistorySessions","getSharedHistoryInboundGroupSessions","_ref19","promises","deviceMessages","no_olm"],"sources":["../../../src/crypto/algorithms/megolm.ts"],"sourcesContent":["/*\nCopyright 2015 - 2021, 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\n/**\n * Defines m.olm encryption/decryption\n */\n\nimport { v4 as uuidv4 } from \"uuid\";\n\nimport type { IEventDecryptionResult, IMegolmSessionData } from \"../../@types/crypto.ts\";\nimport { logger, Logger } from \"../../logger.ts\";\nimport * as olmlib from \"../olmlib.ts\";\nimport {\n DecryptionAlgorithm,\n DecryptionClassParams,\n EncryptionAlgorithm,\n IParams,\n registerAlgorithm,\n UnknownDeviceError,\n} from \"./base.ts\";\nimport { IDecryptedGroupMessage, WITHHELD_MESSAGES } from \"../OlmDevice.ts\";\nimport { Room } from \"../../models/room.ts\";\nimport { DeviceInfo } from \"../deviceinfo.ts\";\nimport { IOlmSessionResult } from \"../olmlib.ts\";\nimport { DeviceInfoMap } from \"../DeviceList.ts\";\nimport { IContent, MatrixEvent } from \"../../models/event.ts\";\nimport { EventType, MsgType, ToDeviceMessageId } from \"../../@types/event.ts\";\nimport { IMegolmEncryptedContent, IncomingRoomKeyRequest, IEncryptedContent } from \"../index.ts\";\nimport { RoomKeyRequestState } from \"../OutgoingRoomKeyRequestManager.ts\";\nimport { OlmGroupSessionExtraData } from \"../../@types/crypto.ts\";\nimport { MatrixError } from \"../../http-api/index.ts\";\nimport { immediate, MapWithDefault } from \"../../utils.ts\";\nimport { KnownMembership } from \"../../@types/membership.ts\";\nimport { DecryptionFailureCode } from \"../../crypto-api/index.ts\";\nimport { DecryptionError } from \"../../common-crypto/CryptoBackend.ts\";\n\n// determine whether the key can be shared with invitees\nexport function isRoomSharedHistory(room: Room): boolean {\n const visibilityEvent = room?.currentState?.getStateEvents(\"m.room.history_visibility\", \"\");\n // NOTE: if the room visibility is unset, it would normally default to\n // \"world_readable\".\n // (https://spec.matrix.org/unstable/client-server-api/#server-behaviour-5)\n // But we will be paranoid here, and treat it as a situation where the room\n // is not shared-history\n const visibility = visibilityEvent?.getContent()?.history_visibility;\n return [\"world_readable\", \"shared\"].includes(visibility);\n}\n\ninterface IBlockedDevice {\n code: string;\n reason: string;\n deviceInfo: DeviceInfo;\n}\n\n// map user Id → device Id → IBlockedDevice\ntype BlockedMap = Map<string, Map<string, IBlockedDevice>>;\n\nexport interface IOlmDevice<T = DeviceInfo> {\n userId: string;\n deviceInfo: T;\n}\n\n/**\n * Tests whether an encrypted content has a ciphertext.\n * Ciphertext can be a string or object depending on the content type {@link IEncryptedContent}.\n *\n * @param content - Encrypted content\n * @returns true: has ciphertext, else false\n */\nconst hasCiphertext = (content: IEncryptedContent): boolean => {\n return typeof content.ciphertext === \"string\"\n ? !!content.ciphertext.length\n : !!Object.keys(content.ciphertext).length;\n};\n\n/** The result of parsing the an `m.room_key` or `m.forwarded_room_key` to-device event */\ninterface RoomKey {\n /**\n * The Curve25519 key of the megolm session creator.\n *\n * For `m.room_key`, this is also the sender of the `m.room_key` to-device event.\n * For `m.forwarded_room_key`, the two are different (and the key of the sender of the\n * `m.forwarded_room_key` event is included in `forwardingKeyChain`)\n */\n senderKey: string;\n sessionId: string;\n sessionKey: string;\n exportFormat: boolean;\n roomId: string;\n algorithm: string;\n /**\n * A list of the curve25519 keys of the users involved in forwarding this key, most recent last.\n * For `m.room_key` events, this is empty.\n */\n forwardingKeyChain: string[];\n keysClaimed: Partial<Record<\"ed25519\", string>>;\n extraSessionData: OlmGroupSessionExtraData;\n}\n\nexport interface IOutboundGroupSessionKey {\n chain_index: number;\n key: string;\n}\n\ninterface IMessage {\n type: string;\n content: {\n \"algorithm\": string;\n \"room_id\": string;\n \"sender_key\"?: string;\n \"sender_claimed_ed25519_key\"?: string;\n \"session_id\": string;\n \"session_key\": string;\n \"chain_index\": number;\n \"forwarding_curve25519_key_chain\"?: string[];\n \"org.matrix.msc3061.shared_history\": boolean;\n };\n}\n\ninterface IKeyForwardingMessage extends IMessage {\n type: \"m.forwarded_room_key\";\n}\n\ninterface IPayload extends Partial<IMessage> {\n code?: string;\n reason?: string;\n room_id?: string;\n session_id?: string;\n algorithm?: string;\n sender_key?: string;\n}\n\ninterface SharedWithData {\n // The identity key of the device we shared with\n deviceKey: string;\n // The message index of the ratchet we shared with that device\n messageIndex: number;\n}\n\n/**\n * @internal\n */\nclass OutboundSessionInfo {\n /** number of times this session has been used */\n public useCount = 0;\n /** when the session was created (ms since the epoch) */\n public creationTime: number;\n /** devices with which we have shared the session key `userId -> {deviceId -> SharedWithData}` */\n public sharedWithDevices: MapWithDefault<string, Map<string, SharedWithData>> = new MapWithDefault(() => new Map());\n public blockedDevicesNotified: MapWithDefault<string, Map<string, boolean>> = new MapWithDefault(() => new Map());\n\n /**\n * @param sharedHistory - whether the session can be freely shared with\n * other group members, according to the room history visibility settings\n */\n public constructor(\n public readonly sessionId: string,\n public readonly sharedHistory = false,\n ) {\n this.creationTime = new Date().getTime();\n }\n\n /**\n * Check if it's time to rotate the session\n */\n public needsRotation(rotationPeriodMsgs: number, rotationPeriodMs: number): boolean {\n const sessionLifetime = new Date().getTime() - this.creationTime;\n\n if (this.useCount >= rotationPeriodMsgs || sessionLifetime >= rotationPeriodMs) {\n logger.log(\"Rotating megolm session after \" + this.useCount + \" messages, \" + sessionLifetime + \"ms\");\n return true;\n }\n\n return false;\n }\n\n public markSharedWithDevice(userId: string, deviceId: string, deviceKey: string, chainIndex: number): void {\n this.sharedWithDevices.getOrCreate(userId).set(deviceId, { deviceKey, messageIndex: chainIndex });\n }\n\n public markNotifiedBlockedDevice(userId: string, deviceId: string): void {\n this.blockedDevicesNotified.getOrCreate(userId).set(deviceId, true);\n }\n\n /**\n * Determine if this session has been shared with devices which it shouldn't\n * have been.\n *\n * @param devicesInRoom - `userId -> {deviceId -> object}`\n * devices we should shared the session with.\n *\n * @returns true if we have shared the session with devices which aren't\n * in devicesInRoom.\n */\n public sharedWithTooManyDevices(devicesInRoom: DeviceInfoMap): boolean {\n for (const [userId, devices] of this.sharedWithDevices) {\n if (!devicesInRoom.has(userId)) {\n logger.log(\"Starting new megolm session because we shared with \" + userId);\n return true;\n }\n\n for (const [deviceId] of devices) {\n if (!devicesInRoom.get(userId)?.get(deviceId)) {\n logger.log(\"Starting new megolm session because we shared with \" + userId + \":\" + deviceId);\n return true;\n }\n }\n }\n\n return false;\n }\n}\n\n/**\n * Megolm encryption implementation\n *\n * @param params - parameters, as per {@link EncryptionAlgorithm}\n */\nexport class MegolmEncryption extends EncryptionAlgorithm {\n // the most recent attempt to set up a session. This is used to serialise\n // the session setups, so that we have a race-free view of which session we\n // are using, and which devices we have shared the keys with. It resolves\n // with an OutboundSessionInfo (or undefined, for the first message in the\n // room).\n private setupPromise = Promise.resolve<OutboundSessionInfo | null>(null);\n\n // Map of outbound sessions by sessions ID. Used if we need a particular\n // session (the session we're currently using to send is always obtained\n // using setupPromise).\n private outboundSessions: Record<string, OutboundSessionInfo> = {};\n\n private readonly sessionRotationPeriodMsgs: number;\n private readonly sessionRotationPeriodMs: number;\n private encryptionPreparation?: {\n promise: Promise<void>;\n startTime: number;\n cancel: () => void;\n };\n\n protected readonly roomId: string;\n private readonly prefixedLogger: Logger;\n\n public constructor(params: IParams & Required<Pick<IParams, \"roomId\">>) {\n super(params);\n this.roomId = params.roomId;\n this.prefixedLogger = logger.getChild(`[${this.roomId} encryption]`);\n\n this.sessionRotationPeriodMsgs = params.config?.rotation_period_msgs ?? 100;\n this.sessionRotationPeriodMs = params.config?.rotation_period_ms ?? 7 * 24 * 3600 * 1000;\n }\n\n /**\n * @internal\n *\n * @param devicesInRoom - The devices in this room, indexed by user ID\n * @param blocked - The devices that are blocked, indexed by user ID\n * @param singleOlmCreationPhase - Only perform one round of olm\n * session creation\n *\n * This method updates the setupPromise field of the class by chaining a new\n * call on top of the existing promise, and then catching and discarding any\n * errors that might happen while setting up the outbound group session. This\n * is done to ensure that `setupPromise` always resolves to `null` or the\n * `OutboundSessionInfo`.\n *\n * Using `>>=` to represent the promise chaining operation, it does the\n * following:\n *\n * ```\n * setupPromise = previousSetupPromise >>= setup >>= discardErrors\n * ```\n *\n * The initial value for the `setupPromise` is a promise that resolves to\n * `null`. The forceDiscardSession() resets setupPromise to this initial\n * promise.\n *\n * @returns Promise which resolves to the\n * OutboundSessionInfo when setup is complete.\n */\n private async ensureOutboundSession(\n room: Room,\n devicesInRoom: DeviceInfoMap,\n blocked: BlockedMap,\n singleOlmCreationPhase = false,\n ): Promise<OutboundSessionInfo> {\n // takes the previous OutboundSessionInfo, and considers whether to create\n // a new one. Also shares the key with any (new) devices in the room.\n //\n // returns a promise which resolves once the keyshare is successful.\n const setup = async (oldSession: OutboundSessionInfo | null): Promise<OutboundSessionInfo> => {\n const sharedHistory = isRoomSharedHistory(room);\n const session = await this.prepareSession(devicesInRoom, sharedHistory, oldSession);\n\n await this.shareSession(devicesInRoom, sharedHistory, singleOlmCreationPhase, blocked, session);\n\n return session;\n };\n\n // first wait for the previous share to complete\n const fallible = this.setupPromise.then(setup);\n\n // Ensure any failures are logged for debugging and make sure that the\n // promise chain remains unbroken\n //\n // setupPromise resolves to `null` or the `OutboundSessionInfo` whether\n // or not the share succeeds\n this.setupPromise = fallible.catch((e) => {\n this.prefixedLogger.error(`Failed to setup outbound session`, e);\n return null;\n });\n\n // but we return a promise which only resolves if the share was successful.\n return fallible;\n }\n\n private async prepareSession(\n devicesInRoom: DeviceInfoMap,\n sharedHistory: boolean,\n session: OutboundSessionInfo | null,\n ): Promise<OutboundSessionInfo> {\n // history visibility changed\n if (session && sharedHistory !== session.sharedHistory) {\n session = null;\n }\n\n // need to make a brand new session?\n if (session?.needsRotation(this.sessionRotationPeriodMsgs, this.sessionRotationPeriodMs)) {\n this.prefixedLogger.debug(\"Starting new megolm session because we need to rotate.\");\n session = null;\n }\n\n // determine if we have shared with anyone we shouldn't have\n if (session?.sharedWithTooManyDevices(devicesInRoom)) {\n session = null;\n }\n\n if (!session) {\n this.prefixedLogger.debug(\"Starting new megolm session\");\n session = await this.prepareNewSession(sharedHistory);\n this.prefixedLogger.debug(`Started new megolm session ${session.sessionId}`);\n this.outboundSessions[session.sessionId] = session;\n }\n\n return session;\n }\n\n private async shareSession(\n devicesInRoom: DeviceInfoMap,\n sharedHistory: boolean,\n singleOlmCreationPhase: boolean,\n blocked: BlockedMap,\n session: OutboundSessionInfo,\n ): Promise<void> {\n // now check if we need to share with any devices\n const shareMap: Record<string, DeviceInfo[]> = {};\n\n for (const [userId, userDevices] of devicesInRoom) {\n for (const [deviceId, deviceInfo] of userDevices) {\n const key = deviceInfo.getIdentityKey();\n if (key == this.olmDevice.deviceCurve25519Key) {\n // don't bother sending to ourself\n continue;\n }\n\n if (!session.sharedWithDevices.get(userId)?.get(deviceId)) {\n shareMap[userId] = shareMap[userId] || [];\n shareMap[userId].push(deviceInfo);\n }\n }\n }\n\n const key = this.olmDevice.getOutboundGroupSessionKey(session.sessionId);\n const payload: IPayload = {\n type: \"m.room_key\",\n content: {\n \"algorithm\": olmlib.MEGOLM_ALGORITHM,\n \"room_id\": this.roomId,\n \"session_id\": session.sessionId,\n \"session_key\": key.key,\n \"chain_index\": key.chain_index,\n \"org.matrix.msc3061.shared_history\": sharedHistory,\n },\n };\n const [devicesWithoutSession, olmSessions] = await olmlib.getExistingOlmSessions(\n this.olmDevice,\n this.baseApis,\n shareMap,\n );\n\n await Promise.all([\n (async (): Promise<void> => {\n // share keys with devices that we already have a session for\n const olmSessionList = Array.from(olmSessions.entries())\n .map(([userId, sessionsByUser]) =>\n Array.from(sessionsByUser.entries()).map(\n ([deviceId, session]) => `${userId}/${deviceId}: ${session.sessionId}`,\n ),\n )\n .flat(1);\n this.prefixedLogger.debug(\"Sharing keys with devices with existing Olm sessions:\", olmSessionList);\n await this.shareKeyWithOlmSessions(session, key, payload, olmSessions);\n this.prefixedLogger.debug(\"Shared keys with existing Olm sessions\");\n })(),\n (async (): Promise<void> => {\n const deviceList = Array.from(devicesWithoutSession.entries())\n .map(([userId, devicesByUser]) => devicesByUser.map((device) => `${userId}/${device.deviceId}`))\n .flat(1);\n this.prefixedLogger.debug(\n \"Sharing keys (start phase 1) with devices without existing Olm sessions:\",\n deviceList,\n );\n const errorDevices: IOlmDevice[] = [];\n\n // meanwhile, establish olm sessions for devices that we don't\n // already have a session for, and share keys with them. If\n // we're doing two phases of olm session creation, use a\n // shorter timeout when fetching one-time keys for the first\n // phase.\n const start = Date.now();\n const failedServers: string[] = [];\n await this.shareKeyWithDevices(\n session,\n key,\n payload,\n devicesWithoutSession,\n errorDevices,\n singleOlmCreationPhase ? 10000 : 2000,\n failedServers,\n );\n this.prefixedLogger.debug(\"Shared keys (end phase 1) with devices without existing Olm sessions\");\n\n if (!singleOlmCreationPhase && Date.now() - start < 10000) {\n // perform the second phase of olm session creation if requested,\n // and if the first phase didn't take too long\n (async (): Promise<void> => {\n // Retry sending keys to devices that we were unable to establish\n // an olm session for. This time, we use a longer timeout, but we\n // do this in the background and don't block anything else while we\n // do this. We only need to retry users from servers that didn't\n // respond the first time.\n const retryDevices: MapWithDefault<string, DeviceInfo[]> = new MapWithDefault(() => []);\n const failedServerMap = new Set();\n for (const server of failedServers) {\n failedServerMap.add(server);\n }\n const failedDevices: IOlmDevice[] = [];\n for (const { userId, deviceInfo } of errorDevices) {\n const userHS = userId.slice(userId.indexOf(\":\") + 1);\n if (failedServerMap.has(userHS)) {\n retryDevices.getOrCreate(userId).push(deviceInfo);\n } else {\n // if we aren't going to retry, then handle it\n // as a failed device\n failedDevices.push({ userId, deviceInfo });\n }\n }\n\n const retryDeviceList = Array.from(retryDevices.entries())\n .map(([userId, devicesByUser]) =>\n devicesByUser.map((device) => `${userId}/${device.deviceId}`),\n )\n .flat(1);\n\n if (retryDeviceList.length > 0) {\n this.prefixedLogger.debug(\n \"Sharing keys (start phase 2) with devices without existing Olm sessions:\",\n retryDeviceList,\n );\n await this.shareKeyWithDevices(session, key, payload, retryDevices, failedDevices, 30000);\n this.prefixedLogger.debug(\n \"Shared keys (end phase 2) with devices without existing Olm sessions\",\n );\n }\n\n await this.notifyFailedOlmDevices(session, key, failedDevices);\n })();\n } else {\n await this.notifyFailedOlmDevices(session, key, errorDevices);\n }\n })(),\n (async (): Promise<void> => {\n this.prefixedLogger.debug(\n `There are ${blocked.size} blocked devices:`,\n Array.from(blocked.entries())\n .map(([userId, blockedByUser]) =>\n Array.from(blockedByUser.entries()).map(\n ([deviceId, _deviceInfo]) => `${userId}/${deviceId}`,\n ),\n )\n .flat(1),\n );\n\n // also, notify newly blocked devices that they're blocked\n const blockedMap: MapWithDefault<string, Map<string, { device: IBlockedDevice }>> = new MapWithDefault(\n () => new Map(),\n );\n let blockedCount = 0;\n for (const [userId, userBlockedDevices] of blocked) {\n for (const [deviceId, device] of userBlockedDevices) {\n if (session.blockedDevicesNotified.get(userId)?.get(deviceId) === undefined) {\n blockedMap.getOrCreate(userId).set(deviceId, { device });\n blockedCount++;\n }\n }\n }\n\n if (blockedCount) {\n this.prefixedLogger.debug(\n `Notifying ${blockedCount} newly blocked devices:`,\n Array.from(blockedMap.entries())\n .map(([userId, blockedByUser]) =>\n Object.entries(blockedByUser).map(([deviceId, _deviceInfo]) => `${userId}/${deviceId}`),\n )\n .flat(1),\n );\n await this.notifyBlockedDevices(session, blockedMap);\n this.prefixedLogger.debug(`Notified ${blockedCount} newly blocked devices`);\n }\n })(),\n ]);\n }\n\n /**\n * @internal\n *\n *\n * @returns session\n */\n private async prepareNewSession(sharedHistory: boolean): Promise<OutboundSessionInfo> {\n const sessionId = this.olmDevice.createOutboundGroupSession();\n const key = this.olmDevice.getOutboundGroupSessionKey(sessionId);\n\n await this.olmDevice.addInboundGroupSession(\n this.roomId,\n this.olmDevice.deviceCurve25519Key!,\n [],\n sessionId,\n key.key,\n { ed25519: this.olmDevice.deviceEd25519Key! },\n false,\n { sharedHistory },\n );\n\n // don't wait for it to complete\n this.crypto.backupManager.backupGroupSession(this.olmDevice.deviceCurve25519Key!, sessionId);\n\n return new OutboundSessionInfo(sessionId, sharedHistory);\n }\n\n /**\n * Determines what devices in devicesByUser don't have an olm session as given\n * in devicemap.\n *\n * @internal\n *\n * @param deviceMap - the devices that have olm sessions, as returned by\n * olmlib.ensureOlmSessionsForDevices.\n * @param devicesByUser - a map of user IDs to array of deviceInfo\n * @param noOlmDevices - an array to fill with devices that don't have\n * olm sessions\n *\n * @returns an array of devices that don't have olm sessions. If\n * noOlmDevices is specified, then noOlmDevices will be returned.\n */\n private getDevicesWithoutSessions(\n deviceMap: Map<string, Map<string, IOlmSessionResult>>,\n devicesByUser: Map<string, DeviceInfo[]>,\n noOlmDevices: IOlmDevice[] = [],\n ): IOlmDevice[] {\n for (const [userId, devicesToShareWith] of devicesByUser) {\n const sessionResults = deviceMap.get(userId);\n\n for (const deviceInfo of devicesToShareWith) {\n const deviceId = deviceInfo.deviceId;\n\n const sessionResult = sessionResults?.get(deviceId);\n if (!sessionResult?.sessionId) {\n // no session with this device, probably because there\n // were no one-time keys.\n\n noOlmDevices.push({ userId, deviceInfo });\n sessionResults?.delete(deviceId);\n\n // ensureOlmSessionsForUsers has already done the logging,\n // so just skip it.\n continue;\n }\n }\n }\n\n return noOlmDevices;\n }\n\n /**\n * Splits the user device map into multiple chunks to reduce the number of\n * devices we encrypt to per API call.\n *\n * @internal\n *\n * @param devicesByUser - map from userid to list of devices\n *\n * @returns the blocked devices, split into chunks\n */\n private splitDevices<T extends DeviceInfo | IBlockedDevice>(\n devicesByUser: Map<string, Map<string, { device: T }>>,\n ): IOlmDevice<T>[][] {\n const maxDevicesPerRequest = 20;\n\n // use an array where the slices of a content map gets stored\n let currentSlice: IOlmDevice<T>[] = [];\n const mapSlices = [currentSlice];\n\n for (const [userId, userDevices] of devicesByUser) {\n for (const deviceInfo of userDevices.values()) {\n currentSlice.push({\n userId: userId,\n deviceInfo: deviceInfo.device,\n });\n }\n\n // We do this in the per-user loop as we prefer that all messages to the\n // same user end up in the same API call to make it easier for the\n // server (e.g. only have to send one EDU if a remote user, etc). This\n // does mean that if a user has many devices we may go over the desired\n // limit, but its not a hard limit so that is fine.\n if (currentSlice.length > maxDevicesPerRequest) {\n // the current slice is filled up. Start inserting into the next slice\n currentSlice = [];\n mapSlices.push(currentSlice);\n }\n }\n if (currentSlice.length === 0) {\n mapSlices.pop();\n }\n return mapSlices;\n }\n\n /**\n * @internal\n *\n *\n * @param chainIndex - current chain index\n *\n * @param userDeviceMap - mapping from userId to deviceInfo\n *\n * @param payload - fields to include in the encrypted payload\n *\n * @returns Promise which resolves once the key sharing\n * for the given userDeviceMap is generated and has been sent.\n */\n private encryptAndSendKeysToDevices(\n session: OutboundSessionInfo,\n chainIndex: number,\n devices: IOlmDevice[],\n payload: IPayload,\n ): Promise<void> {\n return this.crypto\n .encryptAndSendToDevices(devices, payload)\n .then(() => {\n // store that we successfully uploaded the keys of the current slice\n for (const device of devices) {\n session.markSharedWithDevice(\n device.userId,\n device.deviceInfo.deviceId,\n device.deviceInfo.getIdentityKey(),\n chainIndex,\n );\n }\n })\n .catch((error) => {\n this.prefixedLogger.error(\"failed to encryptAndSendToDevices\", error);\n throw error;\n });\n }\n\n /**\n * @internal\n *\n *\n * @param userDeviceMap - list of blocked devices to notify\n *\n * @param payload - fields to include in the notification payload\n *\n * @returns Promise which resolves once the notifications\n * for the given userDeviceMap is generated and has been sent.\n */\n private async sendBlockedNotificationsToDevices(\n session: OutboundSessionInfo,\n userDeviceMap: IOlmDevice<IBlockedDevice>[],\n payload: IPayload,\n ): Promise<void> {\n const contentMap: MapWithDefault<string, Map<string, IPayload>> = new MapWithDefault(() => new Map());\n\n for (const val of userDeviceMap) {\n const userId = val.userId;\n const blockedInfo = val.deviceInfo;\n const deviceInfo = blockedInfo.deviceInfo;\n const deviceId = deviceInfo.deviceId;\n\n const message = {\n ...payload,\n code: blockedInfo.code,\n reason: blockedInfo.reason,\n [ToDeviceMessageId]: uuidv4(),\n };\n\n if (message.code === \"m.no_olm\") {\n delete message.room_id;\n delete message.session_id;\n }\n\n contentMap.getOrCreate(userId).set(deviceId, message);\n }\n\n await this.baseApis.sendToDevice(\"m.room_key.withheld\", contentMap);\n\n // record the fact that we notified these blocked devices\n for (const [userId, userDeviceMap] of contentMap) {\n for (const deviceId of userDeviceMap.keys()) {\n session.markNotifiedBlockedDevice(userId, deviceId);\n }\n }\n }\n\n /**\n * Re-shares a megolm session key with devices if the key has already been\n * sent to them.\n *\n * @param senderKey - The key of the originating device for the session\n * @param sessionId - ID of the outbound session to share\n * @param userId - ID of the user who owns the target device\n * @param device - The target device\n */\n public async reshareKeyWithDevice(\n senderKey: string,\n sessionId: string,\n userId: string,\n device: DeviceInfo,\n ): Promise<void> {\n const obSessionInfo = this.outboundSessions[sessionId];\n if (!obSessionInfo) {\n this.prefixedLogger.debug(`megolm session ${senderKey}|${sessionId} not found: not re-sharing keys`);\n return;\n }\n\n // The chain index of the key we previously sent this device\n if (!obSessionInfo.sharedWithDevices.has(userId)) {\n this.prefixedLogger.debug(`megolm session ${senderKey}|${sessionId} never shared with user ${userId}`);\n return;\n }\n const sessionSharedData = obSessionInfo.sharedWithDevices.get(userId)?.get(device.deviceId);\n if (sessionSharedData === undefined) {\n this.prefixedLogger.debug(\n `megolm session ${senderKey}|${sessionId} never shared with device ${userId}:${device.deviceId}`,\n );\n return;\n }\n\n if (sessionSharedData.deviceKey !== device.getIdentityKey()) {\n this.prefixedLogger.warn(\n `Megolm session ${senderKey}|${sessionId} has been shared with device ${device.deviceId} but ` +\n `with identity key ${sessionSharedData.deviceKey}. Key is now ${device.getIdentityKey()}!`,\n );\n return;\n }\n\n // get the key from the inbound session: the outbound one will already\n // have been ratcheted to the next chain index.\n const key = await this.olmDevice.getInboundGroupSessionKey(\n this.roomId,\n senderKey,\n sessionId,\n sessionSharedData.messageIndex,\n );\n\n if (!key) {\n this.prefixedLogger.warn(\n `No inbound session key found for megolm session ${senderKey}|${sessionId}: not re-sharing keys`,\n );\n return;\n }\n\n await olmlib.ensureOlmSessionsForDevices(this.olmDevice, this.baseApis, new Map([[userId, [device]]]));\n\n const payload = {\n type: \"m.forwarded_room_key\",\n content: {\n \"algorithm\": olmlib.MEGOLM_ALGORITHM,\n \"room_id\": this.roomId,\n \"session_id\": sessionId,\n \"session_key\": key.key,\n \"chain_index\": key.chain_index,\n \"sender_key\": senderKey,\n \"sender_claimed_ed25519_key\": key.sender_claimed_ed25519_key,\n \"forwarding_curve25519_key_chain\": key.forwarding_curve25519_key_chain,\n \"org.matrix.msc3061.shared_history\": key.shared_history || false,\n },\n };\n\n const encryptedContent: IEncryptedContent = {\n algorithm: olmlib.OLM_ALGORITHM,\n sender_key: this.olmDevice.deviceCurve25519Key!,\n ciphertext: {},\n [ToDeviceMessageId]: uuidv4(),\n };\n await olmlib.encryptMessageForDevice(\n encryptedContent.ciphertext,\n this.userId,\n this.deviceId,\n this.olmDevice,\n userId,\n device,\n payload,\n );\n\n await this.baseApis.sendToDevice(\n \"m.room.encrypted\",\n new Map([[userId, new Map([[device.deviceId, encryptedContent]])]]),\n );\n this.prefixedLogger.debug(\n `Re-shared key for megolm session ${senderKey}|${sessionId} with ${userId}:${device.deviceId}`,\n );\n }\n\n /**\n * @internal\n *\n *\n * @param key - the session key as returned by\n * OlmDevice.getOutboundGroupSessionKey\n *\n * @param payload - the base to-device message payload for sharing keys\n *\n * @param devicesByUser - map from userid to list of devices\n *\n * @param errorDevices - array that will be populated with the devices that we can't get an\n * olm session for\n *\n * @param otkTimeout - The timeout in milliseconds when requesting\n * one-time keys for establishing new olm sessions.\n *\n * @param failedServers - An array to fill with remote servers that\n * failed to respond to one-time-key requests.\n */\n private async shareKeyWithDevices(\n session: OutboundSessionInfo,\n key: IOutboundGroupSessionKey,\n payload: IPayload,\n devicesByUser: Map<string, DeviceInfo[]>,\n errorDevices: IOlmDevice[],\n otkTimeout: number,\n failedServers?: string[],\n ): Promise<void> {\n const devicemap = await olmlib.ensureOlmSessionsForDevices(\n this.olmDevice,\n this.baseApis,\n devicesByUser,\n false,\n otkTimeout,\n failedServers,\n this.prefixedLogger,\n );\n this.getDevicesWithoutSessions(devicemap, devicesByUser, errorDevices);\n await this.shareKeyWithOlmSessions(session, key, payload, devicemap);\n }\n\n private async shareKeyWithOlmSessions(\n session: OutboundSessionInfo,\n key: IOutboundGroupSessionKey,\n payload: IPayload,\n deviceMap: Map<string, Map<string, IOlmSessionResult>>,\n ): Promise<void> {\n const userDeviceMaps = this.splitDevices(deviceMap);\n\n for (let i = 0; i < userDeviceMaps.length; i++) {\n const taskDetail = `megolm keys for ${session.sessionId} (slice ${i + 1}/${userDeviceMaps.length})`;\n try {\n this.prefixedLogger.debug(\n `Sharing ${taskDetail}`,\n userDeviceMaps[i].map((d) => `${d.userId}/${d.deviceInfo.deviceId}`),\n );\n await this.encryptAndSendKeysToDevices(session, key.chain_index, userDeviceMaps[i], payload);\n this.prefixedLogger.debug(`Shared ${taskDetail}`);\n } catch (e) {\n this.prefixedLogger.error(`Failed to share ${taskDetail}`);\n throw e;\n }\n }\n }\n\n /**\n * Notify devices that we weren't able to create olm sessions.\n *\n *\n *\n * @param failedDevices - the devices that we were unable to\n * create olm sessions for, as returned by shareKeyWithDevices\n */\n private async notifyFailedOlmDevices(\n session: OutboundSessionInfo,\n key: IOutboundGroupSessionKey,\n failedDevices: IOlmDevice[],\n ): Promise<void> {\n this.prefixedLogger.debug(`Notifying ${failedDevices.length} devices we failed to create Olm sessions`);\n\n // mark the devices that failed as \"handled\" because we don't want to try\n // to claim a one-time-key for dead devices on every message.\n for (const { userId, deviceInfo } of failedDevices) {\n const deviceId = deviceInfo.deviceId;\n\n session.markSharedWithDevice(userId, deviceId, deviceInfo.getIdentityKey(), key.chain_index);\n }\n\n const unnotifiedFailedDevices = await this.olmDevice.filterOutNotifiedErrorDevices(failedDevices);\n this.prefixedLogger.debug(\n `Need to notify ${unnotifiedFailedDevices.length} failed devices which haven't been notified before`,\n );\n const blockedMap: MapWithDefault<string, Map<string, { device: IBlockedDevice }>> = new MapWithDefault(\n () => new Map(),\n );\n for (const { userId, deviceInfo } of unnotifiedFailedDevices) {\n // we use a similar format to what\n // olmlib.ensureOlmSessionsForDevices returns, so that\n // we can use the same function to split\n blockedMap.getOrCreate(userId).set(deviceInfo.deviceId, {\n device: {\n code: \"m.no_olm\",\n reason: WITHHELD_MESSAGES[\"m.no_olm\"],\n deviceInfo,\n },\n });\n }\n\n // send the notifications\n await this.notifyBlockedDevices(session, blockedMap);\n this.prefixedLogger.debug(\n `Notified ${unnotifiedFailedDevices.length} devices we failed to create Olm sessions`,\n );\n }\n\n /**\n * Notify blocked devices that they have been blocked.\n *\n *\n * @param devicesByUser - map from userid to device ID to blocked data\n */\n private async notifyBlockedDevices(\n session: OutboundSessionInfo,\n devicesByUser: Map<string, Map<string, { device: IBlockedDevice }>>,\n ): Promise<void> {\n const payload: IPayload = {\n room_id: this.roomId,\n session_id: session.sessionId,\n algorithm: olmlib.MEGOLM_ALGORITHM,\n sender_key: this.olmDevice.deviceCurve25519Key!,\n };\n\n const userDeviceMaps = this.splitDevices(devicesByUser);\n\n for (let i = 0; i < userDeviceMaps.length; i++) {\n try {\n await this.sendBlockedNotificationsToDevices(session, userDeviceMaps[i], payload);\n this.prefixedLogger.debug(\n `Completed blacklist notification for ${session.sessionId} ` +\n `(slice ${i + 1}/${userDeviceMaps.length})`,\n );\n } catch (e) {\n this.prefixedLogger.debug(\n `blacklist notification for ${session.sessionId} ` +\n `(slice ${i + 1}/${userDeviceMaps.length}) failed`,\n );\n\n throw e;\n }\n }\n }\n\n /**\n * Perform any background tasks that can be done before a message is ready to\n * send, in order to speed up sending of the message.\n *\n * @param room - the room the event is in\n * @returns A function that, when called, will stop the preparation\n */\n public prepareToEncrypt(room: Room): () => void {\n if (room.roomId !== this.roomId) {\n throw new Error(\"MegolmEncryption.prepareToEncrypt called on unexpected room\");\n }\n\n if (this.encryptionPreparation != null) {\n // We're already preparing something, so don't do anything else.\n const elapsedTime = Date.now() - this.encryptionPreparation.startTime;\n this.prefixedLogger.debug(\n `Already started preparing to encrypt for this room ${elapsedTime}ms ago, skipping`,\n );\n return this.encryptionPreparation.cancel;\n }\n\n this.prefixedLogger.debug(\"Preparing to encrypt events\");\n\n let cancelled = false;\n const isCancelled = (): boolean => cancelled;\n\n this.encryptionPreparation = {\n startTime: Date.now(),\n promise: (async (): Promise<void> => {\n try {\n // Attempt to enumerate the devices in room, and gracefully\n // handle cancellation if it occurs.\n const getDevicesResult = await this.getDevicesInRoom(room, false, isCancelled);\n if (getDevicesResult === null) return;\n const [devicesInRoom, blocked] = getDevicesResult;\n\n if (this.crypto.globalErrorOnUnknownDevices) {\n // Drop unknown devices for now. When the message gets sent, we'll\n // throw an error, but we'll still be prepared to send to the known\n // devices.\n this.removeUnknownDevices(devicesInRoom);\n }\n\n this.prefixedLogger.debug(\"Ensuring outbound megolm session\");\n await this.ensureOutboundSession(room, devicesInRoom, blocked, true);\n\n this.prefixedLogger.debug(\"Ready to encrypt events\");\n } catch (e) {\n this.prefixedLogger.error(\"Failed to prepare to encrypt events\", e);\n } finally {\n delete this.encryptionPreparation;\n }\n })(),\n\n cancel: (): void => {\n // The caller has indicated that the process should be cancelled,\n // so tell the promise that we'd like to halt, and reset the preparation state.\n cancelled = true;\n delete this.encryptionPreparation;\n },\n };\n\n return this.encryptionPreparation.cancel;\n }\n\n /**\n * @param content - plaintext event content\n *\n * @returns Promise which resolves to the new event body\n */\n public async encryptMessage(room: Room, eventType: string, content: IContent): Promise<IMegolmEncryptedContent> {\n this.prefixedLogger.debug(\"Starting to encrypt event\");\n\n if (this.encryptionPreparation != null) {\n // If we started sending keys, wait for it to be done.\n // FIXME: check if we need to cancel\n // (https://github.com/matrix-org/matrix-js-sdk/issues/1255)\n try {\n await this.encryptionPreparation.promise;\n } catch {\n // ignore any errors -- if the preparation failed, we'll just\n // restart everything here\n }\n }\n\n /**\n * When using in-room messages and the room has encryption enabled,\n * clients should ensure that encryption does not hinder the verification.\n */\n const forceDistributeToUnverified = this.isVerificationEvent(eventType, content);\n const [devicesInRoom, blocked] = await this.getDevicesInRoom(room, forceDistributeToUnverified);\n\n // check if any of these devices are not yet known to the user.\n // if so, warn the user so they can verify or ignore.\n if (this.crypto.globalErrorOnUnknownDevices) {\n this.checkForUnknownDevices(devicesInRoom);\n }\n\n const session = await this.ensureOutboundSession(room, devicesInRoom, blocked);\n const payloadJson = {\n room_id: this.roomId,\n type: eventType,\n content: content,\n };\n\n const ciphertext = this.olmDevice.encryptGroupMessage(session.sessionId, JSON.stringify(payloadJson));\n const encryptedContent: IEncryptedContent = {\n algorithm: olmlib.MEGOLM_ALGORITHM,\n sender_key: this.olmDevice.deviceCurve25519Key!,\n ciphertext: ciphertext,\n session_id: session.sessionId,\n // Include our device ID so that recipients can send us a\n // m.new_device message if they don't have our session key.\n // XXX: Do we still need this now that m.new_device messages\n // no longer exist since #483?\n device_id: this.deviceId,\n };\n\n session.useCount++;\n return encryptedContent;\n }\n\n private isVerificationEvent(eventType: string, content: IContent): boolean {\n switch (eventType) {\n case EventType.KeyVerificationCancel:\n case EventType.KeyVerificationDone:\n case EventType.KeyVerificationMac:\n case EventType.KeyVerificationStart:\n case EventType.KeyVerificationKey:\n case EventType.KeyVerificationReady:\n case EventType.KeyVerificationAccept: {\n return true;\n }\n case EventType.RoomMessage: {\n return content[\"msgtype\"] === MsgType.KeyVerificationRequest;\n }\n default: {\n return false;\n }\n }\n }\n\n /**\n * Forces the current outbound group session to be discarded such\n * that another one will be created next time an event is sent.\n *\n * This should not normally be necessary.\n */\n public forceDiscardSession(): void {\n this.setupPromise = this.setupPromise.then(() => null);\n }\n\n /**\n * Checks the devices we're about to send to and see if any are entirely\n * unknown to the user. If so, warn the user, and mark them as known to\n * give the user a chance to go verify them before re-sending this message.\n *\n * @param devicesInRoom - `userId -> {deviceId -> object}`\n * devices we should shared the session with.\n */\n private checkForUnknownDevices(devicesInRoom: DeviceInfoMap): void {\n const unknownDevices: MapWithDefault<string, Map<string, DeviceInfo>> = new MapWithDefault(() => new Map());\n\n for (const [userId, userDevices] of devicesInRoom) {\n for (const [deviceId, device] of userDevices) {\n if (device.isUnverified() && !device.isKnown()) {\n unknownDevices.getOrCreate(userId).set(deviceId, device);\n }\n }\n }\n\n if (unknownDevices.size) {\n // it'd be kind to pass unknownDevices up to the user in this error\n throw new UnknownDeviceError(\n \"This room contains unknown devices which have not been verified. \" +\n \"We strongly recommend you verify them before continuing.\",\n unknownDevices,\n );\n }\n }\n\n /**\n * Remove unknown devices from a set of devices. The devicesInRoom parameter\n * will be modified.\n *\n * @param devicesInRoom - `userId -> {deviceId -> object}`\n * devices we should shared the session with.\n */\n private removeUnknownDevices(devicesInRoom: DeviceInfoMap): void {\n for (const [userId, userDevices] of devicesInRoom) {\n for (const [deviceId, device] of userDevices) {\n if (device.isUnverified() && !device.isKnown()) {\n userDevices.delete(deviceId);\n }\n }\n\n if (userDevices.size === 0) {\n devicesInRoom.delete(userId);\n }\n }\n }\n\n /**\n * Get the list of unblocked devices for all users in the room\n *\n * @param forceDistributeToUnverified - if set to true will include the unverified devices\n * even if setting is set to block them (useful for verification)\n * @param isCancelled - will cause the procedure to abort early if and when it starts\n * returning `true`. If omitted, cancellation won't happen.\n *\n * @returns Promise which resolves to `null`, or an array whose\n * first element is a {@link DeviceInfoMap} indicating\n * the devices that messages should be encrypted to, and whose second\n * element is a map from userId to deviceId to data indicating the devices\n * that are in the room but that have been blocked.\n * If `isCancelled` is provided and returns `true` while processing, `null`\n * will be returned.\n * If `isCancelled` is not provided, the Promise will never resolve to `null`.\n */\n private async getDevicesInRoom(\n room: Room,\n forceDistributeToUnverified?: boolean,\n ): Promise<[DeviceInfoMap, BlockedMap]>;\n private async getDevicesInRoom(\n room: Room,\n forceDistributeToUnverified?: boolean,\n isCancelled?: () => boolean,\n ): Promise<null | [DeviceInfoMap, BlockedMap]>;\n private async getDevicesInRoom(\n room: Room,\n forceDistributeToUnverified = false,\n isCancelled?: () => boolean,\n ): Promise<null | [DeviceInfoMap, BlockedMap]> {\n const members = await room.getEncryptionTargetMembers();\n this.prefixedLogger.debug(\n `Encrypting for users (shouldEncryptForInvitedMembers: ${room.shouldEncryptForInvitedMembers()}):`,\n members.map((u) => `${u.userId} (${u.membership})`),\n );\n\n const roomMembers = members.map(function (u) {\n return u.userId;\n });\n\n // The global value is treated as a default for when rooms don't specify a value.\n let isBlacklisting = this.crypto.globalBlacklistUnverifiedDevices;\n const isRoomBlacklisting = room.getBlacklistUnverifiedDevices();\n if (typeof isRoomBlacklisting === \"boolean\") {\n isBlacklisting = isRoomBlacklisting;\n }\n\n // We are happy to use a cached version here: we assume that if we already\n // have a list of the user's devices, then we already share an e2e room\n // with them, which means that they will have announced any new devices via\n // device_lists in their /sync response. This cache should then be maintained\n // using all the device_lists changes and left fields.\n // See https://github.com/vector-im/element-web/issues/2305 for details.\n const devices = await this.crypto.downloadKeys(roomMembers, false);\n\n if (isCancelled?.() === true) {\n return null;\n }\n\n const blocked = new MapWithDefault<string, Map<string, IBlockedDevice>>(() => new Map());\n // remove any blocked devices\n for (const [userId, userDevices] of devices) {\n for (const [deviceId, userDevice] of userDevices) {\n // Yield prior to checking each device so that we don't block\n // updating/rendering for too long.\n // See https://github.com/vector-im/element-web/issues/21612\n if (isCancelled !== undefined) await immediate();\n if (isCancelled?.() === true) return null;\n const deviceTrust = this.crypto.checkDeviceTrust(userId, deviceId);\n\n if (\n userDevice.isBlocked() ||\n (!deviceTrust.isVerified() && isBlacklisting && !forceDistributeToUnverified)\n ) {\n const blockedDevices = blocked.getOrCreate(userId);\n const isBlocked = userDevice.isBlocked();\n blockedDevices.set(deviceId, {\n code: isBlocked ? \"m.blacklisted\" : \"m.unverified\",\n reason: WITHHELD_MESSAGES[isBlocked ? \"m.blacklisted\" : \"m.unverified\"],\n deviceInfo: userDevice,\n });\n userDevices.delete(deviceId);\n }\n }\n }\n\n return [devices, blocked];\n }\n}\n\n/**\n * Megolm decryption implementation\n *\n * @param params - parameters, as per {@link DecryptionAlgorithm}\n */\nexport class MegolmDecryption extends DecryptionAlgorithm {\n // events which we couldn't decrypt due to unknown sessions /\n // indexes, or which we could only decrypt with untrusted keys:\n // map from senderKey|sessionId to Set of MatrixEvents\n private pendingEvents = new Map<string, Map<string, Set<MatrixEvent>>>();\n\n // this gets stubbed out by the unit tests.\n private olmlib = olmlib;\n\n protected readonly roomId: string;\n private readonly prefixedLogger: Logger;\n\n public constructor(params: DecryptionClassParams<IParams & Required<Pick<IParams, \"roomId\">>>) {\n super(params);\n this.roomId = params.roomId;\n this.prefixedLogger = logger.getChild(`[${this.roomId} decryption]`);\n }\n\n /**\n * returns a promise which resolves to a\n * {@link EventDecryptionResult} once we have finished\n * decrypting, or rejects with an `algorithms.DecryptionError` if there is a\n * problem decrypting the event.\n */\n public async decryptEvent(event: MatrixEvent): Promise<IEventDecryptionResult> {\n const content = event.getWireContent();\n\n if (!content.sender_key || !content.session_id || !content.ciphertext) {\n throw new DecryptionError(DecryptionFailureCode.MEGOLM_MISSING_FIELDS, \"Missing fields in input\");\n }\n\n // we add the event to the pending list *before* we start decryption.\n //\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 res: IDecryptedGroupMessage | null;\n try {\n res = await this.olmDevice.decryptGroupMessage(\n event.getRoomId()!,\n content.sender_key,\n content.session_id,\n content.ciphertext,\n event.getId()!,\n event.getTs(),\n );\n } catch (e) {\n if ((<Error>e).name === \"DecryptionError\") {\n // re-throw decryption errors as-is\n throw e;\n }\n\n let errorCode = DecryptionFailureCode.OLM_DECRYPT_GROUP_MESSAGE_ERROR;\n\n if ((<MatrixError>e)?.message === \"OLM.UNKNOWN_MESSAGE_INDEX\") {\n this.requestKeysForEvent(event);\n\n errorCode = DecryptionFailureCode.OLM_UNKNOWN_MESSAGE_INDEX;\n }\n\n throw new DecryptionError(errorCode, e instanceof Error ? e.message : \"Unknown Error: Error is undefined\", {\n session: content.sender_key + \"|\" + content.session_id,\n });\n }\n\n if (res === null) {\n // We've got a message for a session we don't have.\n // try and get the missing key from the backup first\n this.crypto.backupManager.queryKeyBackupRateLimited(event.getRoomId(), content.session_id).catch(() => {});\n\n // (XXX: We might actually have received this key since we started\n // decrypting, in which case we'll have scheduled a retry, and this\n // request will be redundant. We could probably check to see if the\n // event is still in the pending list; if not, a retry will have been\n // scheduled, so we needn't send out the request here.)\n this.requestKeysForEvent(event);\n\n // See if there was a problem with the olm session at the time the\n // event was sent. Use a fuzz factor of 2 minutes.\n const problem = await this.olmDevice.sessionMayHaveProblems(content.sender_key, event.getTs() - 120000);\n if (problem) {\n this.prefixedLogger.info(\n `When handling UISI from ${event.getSender()} (sender key ${content.sender_key}): ` +\n `recent session problem with that sender:`,\n problem,\n );\n let problemDescription = PROBLEM_DESCRIPTIONS[problem.type as \"no_olm\"] || PROBLEM_DESCRIPTIONS.unknown;\n if (problem.fixed) {\n problemDescription += \" Trying to create a new secure channel and re-requesting the keys.\";\n }\n throw new DecryptionError(DecryptionFailureCode.MEGOLM_UNKNOWN_INBOUND_SESSION_ID, problemDescription, {\n session: content.sender_key + \"|\" + content.session_id,\n });\n }\n\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 {\n session: content.sender_key + \"|\" + content.session_id,\n },\n );\n }\n\n // Success. We can remove the event from the pending list, if\n // that hasn't already happened. However, if the event was\n // decrypted with an untrusted key, leave it on the pending\n // list so it will be retried if we find a trusted key later.\n if (!res.untrusted) {\n this.removeEventFromPendingList(event);\n }\n\n const payload = JSON.parse(res.result);\n\n // belt-and-braces check that the room id matches that indicated by the HS\n // (this is somewhat redundant, since the megolm session is scoped to the\n // room, so neither the sender nor a MITM can lie about the room_id).\n if (payload.room_id !== event.getRoomId()) {\n throw new DecryptionError(\n DecryptionFailureCode.MEGOLM_BAD_ROOM,\n \"Message intended for room \" + payload.room_id,\n );\n }\n\n return {\n clearEvent: payload,\n senderCurve25519Key: res.senderKey,\n claimedEd25519Key: res.keysClaimed.ed25519,\n forwardingCurve25519KeyChain: res.forwardingCurve25519KeyChain,\n untrusted: res.untrusted,\n };\n }\n\n private requestKeysForEvent(event: MatrixEvent): void {\n const wireContent = event.getWireContent();\n\n const recipients = event.getKeyRequestRecipients(this.userId);\n\n this.crypto.requestRoomKey(\n {\n room_id: event.getRoomId()!,\n algorithm: wireContent.algorithm,\n sender_key: wireContent.sender_key,\n session_id: wireContent.session_id,\n },\n recipients,\n );\n }\n\n /**\n * Add an event to the list of those awaiting their session keys.\n *\n * @internal\n *\n */\n private addEventToPendingList(event: MatrixEvent): void {\n const content = event.getWireContent();\n const senderKey = content.sender_key;\n const sessionId = content.session_id;\n if (!this.pendingEvents.has(senderKey)) {\n this.pendingEvents.set(senderKey, new Map<string, Set<MatrixEvent>>());\n }\n const senderPendingEvents = this.pendingEvents.get(senderKey)!;\n if (!senderPendingEvents.has(sessionId)) {\n senderPendingEvents.set(sessionId, new Set());\n }\n senderPendingEvents.get(sessionId)?.add(event);\n }\n\n /**\n * Remove an event from the list of those awaiting their session keys.\n *\n * @internal\n *\n */\n private removeEventFromPendingList(event: MatrixEvent): void {\n const content = event.getWireContent();\n const senderKey = content.sender_key;\n const sessionId = content.session_id;\n const senderPendingEvents = this.pendingEvents.get(senderKey);\n const pendingEvents = senderPendingEvents?.get(sessionId);\n if (!pendingEvents) {\n return;\n }\n\n pendingEvents.delete(event);\n if (pendingEvents.size === 0) {\n senderPendingEvents!.delete(sessionId);\n }\n if (senderPendingEvents!.size === 0) {\n this.pendingEvents.delete(senderKey);\n }\n }\n\n /**\n * Parse a RoomKey out of an `m.room_key` event.\n *\n * @param event - the event containing the room key.\n *\n * @returns The `RoomKey` if it could be successfully parsed out of the\n * event.\n *\n * @internal\n *\n */\n private roomKeyFromEvent(event: MatrixEvent): RoomKey | undefined {\n const senderKey = event.getSenderKey()!;\n const content = event.getContent<Partial<IMessage[\"content\"]>>();\n const extraSessionData: OlmGroupSessionExtraData = {};\n\n if (!content.room_id || !content.session_key || !content.session_id || !content.algorithm) {\n this.prefixedLogger.error(\"key event is missing fields\");\n return;\n }\n\n if (!olmlib.isOlmEncrypted(event)) {\n this.prefixedLogger.error(\"key event not properly encrypted\");\n return;\n }\n\n if (content[\"org.matrix.msc3061.shared_history\"]) {\n extraSessionData.sharedHistory = true;\n }\n\n const roomKey: RoomKey = {\n senderKey: senderKey,\n sessionId: content.session_id,\n sessionKey: content.session_key,\n extraSessionData,\n exportFormat: false,\n roomId: content.room_id,\n algorithm: content.algorithm,\n forwardingKeyChain: [],\n keysClaimed: event.getKeysClaimed(),\n };\n\n return roomKey;\n }\n\n /**\n * Parse a RoomKey out of an `m.forwarded_room_key` event.\n *\n * @param event - the event containing the forwarded room key.\n *\n * @returns The `RoomKey` if it could be successfully parsed out of the\n * event.\n *\n * @internal\n *\n */\n private forwardedRoomKeyFromEvent(event: MatrixEvent): RoomKey | undefined {\n // the properties in m.forwarded_room_key are a superset of those in m.room_key, so\n // start by parsing the m.room_key fields.\n const roomKey = this.roomKeyFromEvent(event);\n\n if (!roomKey) {\n return;\n }\n\n const senderKey = event.getSenderKey()!;\n const content = event.getContent<Partial<IMessage[\"content\"]>>();\n\n const senderKeyUser = this.baseApis.crypto!.deviceList.getUserByIdentityKey(olmlib.OLM_ALGORITHM, senderKey);\n\n // We received this to-device event from event.getSenderKey(), but the original\n // creator of the room key is claimed in the content.\n const claimedCurve25519Key = content.sender_key;\n const claimedEd25519Key = content.sender_claimed_ed25519_key;\n\n let forwardingKeyChain = Array.isArray(content.forwarding_curve25519_key_chain)\n ? content.forwarding_curve25519_key_chain\n : [];\n\n // copy content before we modify it\n forwardingKeyChain = forwardingKeyChain.slice();\n forwardingKeyChain.push(senderKey);\n\n // Check if we have all the fields we need.\n if (senderKeyUser !== event.getSender()) {\n this.prefixedLogger.error(\"sending device does not belong to the user it claims to be from\");\n return;\n }\n\n if (!claimedCurve25519Key) {\n this.prefixedLogger.error(\"forwarded_room_key event is missing sender_key field\");\n return;\n }\n\n if (!claimedEd25519Key) {\n this.prefixedLogger.error(`forwarded_room_key_event is missing sender_claimed_ed25519_key field`);\n return;\n }\n\n const keysClaimed = {\n ed25519: claimedEd25519Key,\n };\n\n // FIXME: We're reusing the same field to track both:\n //\n // 1. The Olm identity we've received this room key from.\n // 2. The Olm identity deduced (in the trusted case) or claiming (in the\n // untrusted case) to be the original creator of this room key.\n //\n // We now overwrite the value tracking usage 1 with the value tracking usage 2.\n roomKey.senderKey = claimedCurve25519Key;\n // Replace our keysClaimed as well.\n roomKey.keysClaimed = keysClaimed;\n roomKey.exportFormat = true;\n roomKey.forwardingKeyChain = forwardingKeyChain;\n // forwarded keys are always untrusted\n roomKey.extraSessionData.untrusted = true;\n\n return roomKey;\n }\n\n /**\n * Determine if we should accept the forwarded room key that was found in the given\n * event.\n *\n * @param event - An `m.forwarded_room_key` event.\n * @param roomKey - The room key that was found in the event.\n *\n * @returns promise that will resolve to a boolean telling us if it's ok to\n * accept the given forwarded room key.\n *\n * @internal\n *\n */\n private async shouldAcceptForwardedKey(event: MatrixEvent, roomKey: RoomKey): Promise<boolean> {\n const senderKey = event.getSenderKey()!;\n\n const sendingDevice =\n this.crypto.deviceList.getDeviceByIdentityKey(olmlib.OLM_ALGORITHM, senderKey) ?? undefined;\n const deviceTrust = this.crypto.checkDeviceInfoTrust(event.getSender()!, sendingDevice);\n\n // Using the plaintext sender here is fine since we checked that the\n // sender matches to the user id in the device keys when this event was\n // originally decrypted. This can obviously only happen if the device\n // keys have been downloaded, but if they haven't the\n // `deviceTrust.isVerified()` flag would be false as well.\n //\n // It would still be far nicer if the `sendingDevice` had a user ID\n // attached to it that went through signature checks.\n const fromUs = event.getSender() === this.baseApis.getUserId();\n const keyFromOurVerifiedDevice = deviceTrust.isVerified() && fromUs;\n const weRequested = await this.wasRoomKeyRequested(event, roomKey);\n const fromInviter = this.wasRoomKeyForwardedByInviter(event, roomKey);\n const sharedAsHistory = this.wasRoomKeyForwardedAsHistory(roomKey);\n\n return (weRequested && keyFromOurVerifiedDevice) || (fromInviter && sharedAsHistory);\n }\n\n /**\n * Did we ever request the given room key from the event sender and its\n * accompanying device.\n *\n * @param event - An `m.forwarded_room_key` event.\n * @param roomKey - The room key that was found in the event.\n *\n * @internal\n *\n */\n private async wasRoomKeyRequested(event: MatrixEvent, roomKey: RoomKey): Promise<boolean> {\n // We send the `m.room_key_request` out as a wildcard to-device request,\n // otherwise we would have to duplicate the same content for each\n // device. This is why we need to pass in \"*\" as the device id here.\n const outgoingRequests = await this.crypto.cryptoStore.getOutgoingRoomKeyRequestsByTarget(\n event.getSender()!,\n \"*\",\n [RoomKeyRequestState.Sent],\n );\n\n return outgoingRequests.some(\n (req) => req.requestBody.room_id === roomKey.roomId && req.requestBody.session_id === roomKey.sessionId,\n );\n }\n\n private wasRoomKeyForwardedByInviter(event: MatrixEvent, roomKey: RoomKey): boolean {\n // TODO: This is supposed to have a time limit. We should only accept\n // such keys if we happen to receive them for a recently joined room.\n const room = this.baseApis.getRoom(roomKey.roomId);\n const senderKey = event.getSenderKey();\n\n if (!senderKey) {\n return false;\n }\n\n const senderKeyUser = this.crypto.deviceList.getUserByIdentityKey(olmlib.OLM_ALGORITHM, senderKey);\n\n if (!senderKeyUser) {\n return false;\n }\n\n const memberEvent = room?.getMember(this.userId)?.events.member;\n const fromInviter =\n memberEvent?.getSender() === senderKeyUser ||\n (memberEvent?.getUnsigned()?.prev_sender === senderKeyUser &&\n memberEvent?.getPrevContent()?.membership === KnownMembership.Invite);\n\n if (room && fromInviter) {\n return true;\n } else {\n return false;\n }\n }\n\n private wasRoomKeyForwardedAsHistory(roomKey: RoomKey): boolean {\n const room = this.baseApis.getRoom(roomKey.roomId);\n\n // If the key is not for a known room, then something fishy is going on,\n // so we reject the key out of caution. In practice, this is a bit moot\n // because we'll only accept shared_history forwarded by the inviter, and\n // we won't know who was the inviter for an unknown room, so we'll reject\n // it anyway.\n if (room && roomKey.extraSessionData.sharedHistory) {\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Check if a forwarded room key should be parked.\n *\n * A forwarded room key should be parked if it's a key for a room we're not\n * in. We park the forwarded room key in case *this sender* invites us to\n * that room later.\n */\n private shouldParkForwardedKey(roomKey: RoomKey): boolean {\n const room = this.baseApis.getRoom(roomKey.roomId);\n\n if (!room && roomKey.extraSessionData.sharedHistory) {\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Park the given room key to our store.\n *\n * @param event - An `m.forwarded_room_key` event.\n * @param roomKey - The room key that was found in the event.\n *\n * @internal\n *\n */\n private async parkForwardedKey(event: MatrixEvent, roomKey: RoomKey): Promise<void> {\n const parkedData = {\n senderId: event.getSender()!,\n senderKey: roomKey.senderKey,\n sessionId: roomKey.sessionId,\n sessionKey: roomKey.sessionKey,\n keysClaimed: roomKey.keysClaimed,\n forwardingCurve25519KeyChain: roomKey.forwardingKeyChain,\n };\n await this.crypto.cryptoStore.doTxn(\n \"readwrite\",\n [\"parked_shared_history\"],\n (txn) => this.crypto.cryptoStore.addParkedSharedHistory(roomKey.roomId, parkedData, txn),\n logger.getChild(\"[addParkedSharedHistory]\"),\n );\n }\n\n /**\n * Add the given room key to our store.\n *\n * @param roomKey - The room key that should be added to the store.\n *\n * @internal\n *\n */\n private async addRoomKey(roomKey: RoomKey): Promise<void> {\n try {\n await this.olmDevice.addInboundGroupSession(\n roomKey.roomId,\n roomKey.senderKey,\n roomKey.forwardingKeyChain,\n roomKey.sessionId,\n roomKey.sessionKey,\n roomKey.keysClaimed,\n roomKey.exportFormat,\n roomKey.extraSessionData,\n );\n\n // have another go at decrypting events sent with this session.\n if (await this.retryDecryption(roomKey.senderKey, roomKey.sessionId, !roomKey.extraSessionData.untrusted)) {\n // cancel any outstanding room key requests for this session.\n // Only do this if we managed to decrypt every message in the\n // session, because if we didn't, we leave the other key\n // requests in the hopes that someone sends us a key that\n // includes an earlier index.\n this.crypto.cancelRoomKeyRequest({\n algorithm: roomKey.algorithm,\n room_id: roomKey.roomId,\n session_id: roomKey.sessionId,\n sender_key: roomKey.senderKey,\n });\n }\n\n // don't wait for the keys to be backed up for the server\n await this.crypto.backupManager.backupGroupSession(roomKey.senderKey, roomKey.sessionId);\n } catch (e) {\n this.prefixedLogger.error(`Error handling m.room_key_event: ${e}`);\n }\n }\n\n /**\n * Handle room keys that have been forwarded to us as an\n * `m.forwarded_room_key` event.\n *\n * Forwarded room keys need special handling since we have no way of knowing\n * who the original creator of the room key was. This naturally means that\n * forwarded room keys are always untrusted and should only be accepted in\n * some cases.\n *\n * @param event - An `m.forwarded_room_key` event.\n *\n * @internal\n *\n */\n private async onForwardedRoomKey(event: MatrixEvent): Promise<void> {\n const roomKey = this.forwardedRoomKeyFromEvent(event);\n\n if (!roomKey) {\n return;\n }\n\n if (await this.shouldAcceptForwardedKey(event, roomKey)) {\n await this.addRoomKey(roomKey);\n } else if (this.shouldParkForwardedKey(roomKey)) {\n await this.parkForwardedKey(event, roomKey);\n }\n }\n\n public async onRoomKeyEvent(event: MatrixEvent): Promise<void> {\n if (event.getType() == \"m.forwarded_room_key\") {\n await this.onForwardedRoomKey(event);\n } else {\n const roomKey = this.roomKeyFromEvent(event);\n\n if (!roomKey) {\n return;\n }\n\n await this.addRoomKey(roomKey);\n }\n }\n\n /**\n * @param event - key event\n */\n public async onRoomKeyWithheldEvent(event: MatrixEvent): Promise<void> {\n const content = event.getContent();\n const senderKey = content.sender_key;\n\n if (content.code === \"m.no_olm\") {\n await this.onNoOlmWithheldEvent(event);\n } else if (content.code === \"m.unavailable\") {\n // this simply means that the other device didn't have the key, which isn't very useful information. Don't\n // record it in the storage\n } else {\n await this.olmDevice.addInboundGroupSessionWithheld(\n content.room_id,\n senderKey,\n content.session_id,\n content.code,\n content.reason,\n );\n }\n\n // Having recorded the problem, retry decryption on any affected messages.\n // It's unlikely we'll be able to decrypt sucessfully now, but this will\n // update the error message.\n //\n if (content.session_id) {\n await this.retryDecryption(senderKey, content.session_id);\n } else {\n // no_olm messages aren't specific to a given megolm session, so\n // we trigger retrying decryption for all the messages from the sender's\n // key, so that we can update the error message to indicate the olm\n // session problem.\n await this.retryDecryptionFromSender(senderKey);\n }\n }\n\n private async onNoOlmWithheldEvent(event: MatrixEvent): Promise<void> {\n const content = event.getContent();\n const senderKey = content.sender_key;\n const sender = event.getSender()!;\n this.prefixedLogger.warn(`${sender}:${senderKey} was unable to establish an olm session with us`);\n // if the sender says that they haven't been able to establish an olm\n // session, let's proactively establish one\n\n if (await this.olmDevice.getSessionIdForDevice(senderKey)) {\n // a session has already been established, so we don't need to\n // create a new one.\n this.prefixedLogger.debug(\"New session already created. Not creating a new one.\");\n await this.olmDevice.recordSessionProblem(senderKey, \"no_olm\", true);\n return;\n }\n let device = this.crypto.deviceList.getDeviceByIdentityKey(content.algorithm, senderKey);\n if (!device) {\n // if we don't know about the device, fetch the user's devices again\n // and retry before giving up\n await this.crypto.downloadKeys([sender], false);\n device = this.crypto.deviceList.getDeviceByIdentityKey(content.algorithm, senderKey);\n if (!device) {\n this.prefixedLogger.info(\n \"Couldn't find device for identity key \" + senderKey + \": not establishing session\",\n );\n await this.olmDevice.recordSessionProblem(senderKey, \"no_olm\", false);\n return;\n }\n }\n\n // XXX: switch this to use encryptAndSendToDevices() rather than duplicating it?\n\n await olmlib.ensureOlmSessionsForDevices(this.olmDevice, this.baseApis, new Map([[sender, [device]]]), false);\n const encryptedContent: IEncryptedContent = {\n algorithm: olmlib.OLM_ALGORITHM,\n sender_key: this.olmDevice.deviceCurve25519Key!,\n ciphertext: {},\n [ToDeviceMessageId]: uuidv4(),\n };\n await olmlib.encryptMessageForDevice(\n encryptedContent.ciphertext,\n this.userId,\n undefined,\n this.olmDevice,\n sender,\n device,\n { type: \"m.dummy\" },\n );\n\n await this.olmDevice.recordSessionProblem(senderKey, \"no_olm\", true);\n\n await this.baseApis.sendToDevice(\n \"m.room.encrypted\",\n new Map([[sender, new Map([[device.deviceId, encryptedContent]])]]),\n );\n }\n\n public hasKeysForKeyRequest(keyRequest: IncomingRoomKeyRequest): Promise<boolean> {\n const body = keyRequest.requestBody;\n\n return this.olmDevice.hasInboundSessionKeys(\n body.room_id,\n body.sender_key,\n body.session_id,\n // TODO: ratchet index\n );\n }\n\n public shareKeysWithDevice(keyRequest: IncomingRoomKeyRequest): void {\n const userId = keyRequest.userId;\n const deviceId = keyRequest.deviceId;\n const deviceInfo = this.crypto.getStoredDevice(userId, deviceId)!;\n const body = keyRequest.requestBody;\n\n // XXX: switch this to use encryptAndSendToDevices()?\n\n this.olmlib\n .ensureOlmSessionsForDevices(this.olmDevice, this.baseApis, new Map([[userId, [deviceInfo]]]))\n .then((devicemap) => {\n const olmSessionResult = devicemap.get(userId)?.get(deviceId);\n if (!olmSessionResult?.sessionId) {\n // no session with this device, probably because there\n // were no one-time keys.\n //\n // ensureOlmSessionsForUsers has already done the logging,\n // so just skip it.\n return null;\n }\n\n this.prefixedLogger.debug(\n \"sharing keys for session \" +\n body.sender_key +\n \"|\" +\n body.session_id +\n \" with device \" +\n userId +\n \":\" +\n deviceId,\n );\n\n return this.buildKeyForwardingMessage(body.room_id, body.sender_key, body.session_id);\n })\n .then((payload) => {\n const encryptedContent: IEncryptedContent = {\n algorithm: olmlib.OLM_ALGORITHM,\n sender_key: this.olmDevice.deviceCurve25519Key!,\n ciphertext: {},\n [ToDeviceMessageId]: uuidv4(),\n };\n\n return this.olmlib\n .encryptMessageForDevice(\n encryptedContent.ciphertext,\n this.userId,\n undefined,\n this.olmDevice,\n userId,\n deviceInfo,\n payload!,\n )\n .then(() => {\n // TODO: retries\n return this.baseApis.sendToDevice(\n \"m.room.encrypted\",\n new Map([[userId, new Map([[deviceId, encryptedContent]])]]),\n );\n });\n });\n }\n\n private async buildKeyForwardingMessage(\n roomId: string,\n senderKey: string,\n sessionId: string,\n ): Promise<IKeyForwardingMessage> {\n const key = await this.olmDevice.getInboundGroupSessionKey(roomId, senderKey, sessionId);\n\n return {\n type: \"m.forwarded_room_key\",\n content: {\n \"algorithm\": olmlib.MEGOLM_ALGORITHM,\n \"room_id\": roomId,\n \"sender_key\": senderKey,\n \"sender_claimed_ed25519_key\": key!.sender_claimed_ed25519_key!,\n \"session_id\": sessionId,\n \"session_key\": key!.key,\n \"chain_index\": key!.chain_index,\n \"forwarding_curve25519_key_chain\": key!.forwarding_curve25519_key_chain,\n \"org.matrix.msc3061.shared_history\": key!.shared_history || false,\n },\n };\n }\n\n /**\n * @param untrusted - whether the key should be considered as untrusted\n * @param source - where the key came from\n */\n public importRoomKey(\n session: IMegolmSessionData,\n { untrusted, source }: { untrusted?: boolean; source?: string } = {},\n ): Promise<void> {\n const extraSessionData: OlmGroupSessionExtraData = {};\n if (untrusted || session.untrusted) {\n extraSessionData.untrusted = true;\n }\n if (session[\"org.matrix.msc3061.shared_history\"]) {\n extraSessionData.sharedHistory = true;\n }\n return this.olmDevice\n .addInboundGroupSession(\n session.room_id,\n session.sender_key,\n session.forwarding_curve25519_key_chain,\n session.session_id,\n session.session_key,\n session.sender_claimed_keys,\n true,\n extraSessionData,\n )\n .then(() => {\n if (source !== \"backup\") {\n // don't wait for it to complete\n this.crypto.backupManager.backupGroupSession(session.sender_key, session.session_id).catch((e) => {\n // This throws if the upload failed, but this is fine\n // since it will have written it to the db and will retry.\n this.prefixedLogger.debug(\"Failed to back up megolm session\", e);\n });\n }\n // have another go at decrypting events sent with this session.\n this.retryDecryption(session.sender_key, session.session_id, !extraSessionData.untrusted);\n });\n }\n\n /**\n * Have another go at decrypting events after we receive a key. Resolves once\n * decryption has been re-attempted on all events.\n *\n * @internal\n * @param forceRedecryptIfUntrusted - whether messages that were already\n * successfully decrypted using untrusted keys should be re-decrypted\n *\n * @returns whether all messages were successfully\n * decrypted with trusted keys\n */\n private async retryDecryption(\n senderKey: string,\n sessionId: string,\n forceRedecryptIfUntrusted?: boolean,\n ): Promise<boolean> {\n const senderPendingEvents = this.pendingEvents.get(senderKey);\n if (!senderPendingEvents) {\n return true;\n }\n\n const pending = senderPendingEvents.get(sessionId);\n if (!pending) {\n return true;\n }\n\n const pendingList = [...pending];\n this.prefixedLogger.debug(\n \"Retrying decryption on events:\",\n pendingList.map((e) => `${e.getId()}`),\n );\n\n await Promise.all(\n pendingList.map(async (ev) => {\n try {\n await ev.attemptDecryption(this.crypto, { isRetry: true, forceRedecryptIfUntrusted });\n } catch {\n // don't die if something goes wrong\n }\n }),\n );\n\n // If decrypted successfully with trusted keys, they'll have\n // been removed from pendingEvents\n return !this.pendingEvents.get(senderKey)?.has(sessionId);\n }\n\n public async retryDecryptionFromSender(senderKey: string): Promise<boolean> {\n const senderPendingEvents = this.pendingEvents.get(senderKey);\n if (!senderPendingEvents) {\n return true;\n }\n\n this.pendingEvents.delete(senderKey);\n\n await Promise.all(\n [...senderPendingEvents].map(async ([_sessionId, pending]) => {\n await Promise.all(\n [...pending].map(async (ev) => {\n try {\n await ev.attemptDecryption(this.crypto);\n } catch {\n // don't die if something goes wrong\n }\n }),\n );\n }),\n );\n\n return !this.pendingEvents.has(senderKey);\n }\n\n public async sendSharedHistoryInboundSessions(devicesByUser: Map<string, DeviceInfo[]>): Promise<void> {\n await olmlib.ensureOlmSessionsForDevices(this.olmDevice, this.baseApis, devicesByUser);\n\n const sharedHistorySessions = await this.olmDevice.getSharedHistoryInboundGroupSessions(this.roomId);\n this.prefixedLogger.debug(\n `Sharing history in with users ${Array.from(devicesByUser.keys())}`,\n sharedHistorySessions.map(([senderKey, sessionId]) => `${senderKey}|${sessionId}`),\n );\n for (const [senderKey, sessionId] of sharedHistorySessions) {\n const payload = await this.buildKeyForwardingMessage(this.roomId, senderKey, sessionId);\n\n // FIXME: use encryptAndSendToDevices() rather than duplicating it here.\n const promises: Promise<unknown>[] = [];\n const contentMap: Map<string, Map<string, IEncryptedContent>> = new Map();\n for (const [userId, devices] of devicesByUser) {\n const deviceMessages = new Map();\n contentMap.set(userId, deviceMessages);\n for (const deviceInfo of devices) {\n const encryptedContent: IEncryptedContent = {\n algorithm: olmlib.OLM_ALGORITHM,\n sender_key: this.olmDevice.deviceCurve25519Key!,\n ciphertext: {},\n [ToDeviceMessageId]: uuidv4(),\n };\n deviceMessages.set(deviceInfo.deviceId, encryptedContent);\n promises.push(\n olmlib.encryptMessageForDevice(\n encryptedContent.ciphertext,\n this.userId,\n undefined,\n this.olmDevice,\n userId,\n deviceInfo,\n payload,\n ),\n );\n }\n }\n await Promise.all(promises);\n\n // prune out any devices that encryptMessageForDevice could not encrypt for,\n // in which case it will have just not added anything to the ciphertext object.\n // There's no point sending messages to devices if we couldn't encrypt to them,\n // since that's effectively a blank message.\n for (const [userId, deviceMessages] of contentMap) {\n for (const [deviceId, content] of deviceMessages) {\n if (!hasCiphertext(content)) {\n this.prefixedLogger.debug(\"No ciphertext for device \" + userId + \":\" + deviceId + \": pruning\");\n deviceMessages.delete(deviceId);\n }\n }\n // No devices left for that user? Strip that too.\n if (deviceMessages.size === 0) {\n this.prefixedLogger.debug(\"Pruned all devices for user \" + userId);\n contentMap.delete(userId);\n }\n }\n\n // Is there anything left?\n if (contentMap.size === 0) {\n this.prefixedLogger.debug(\"No users left to send to: aborting\");\n return;\n }\n\n await this.baseApis.sendToDevice(\"m.room.encrypted\", contentMap);\n }\n }\n}\n\nconst PROBLEM_DESCRIPTIONS = {\n no_olm: \"The sender was unable to establish a secure channel.\",\n unknown: \"The secure channel with the sender was corrupted.\",\n};\n\nregisterAlgorithm(olmlib.MEGOLM_ALGORITHM, MegolmEncryption, MegolmDecryption);\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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