@unwanted/matrix-sdk-mini 34.12.0-1 → 34.12.0-3
Sign up to get free protection for your applications and to get access to all the features.
- package/git-revision.txt +1 -1
- package/lib/@types/event.d.ts +0 -19
- package/lib/@types/event.d.ts.map +1 -1
- package/lib/@types/event.js.map +1 -1
- package/lib/@types/global.d.js +0 -2
- package/lib/@types/global.d.js.map +1 -1
- package/lib/browser-index.d.ts.map +1 -1
- package/lib/browser-index.js +0 -11
- package/lib/browser-index.js.map +1 -1
- package/lib/client.d.ts +2 -1224
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +345 -2826
- package/lib/client.js.map +1 -1
- package/lib/embedded.d.ts +0 -22
- package/lib/embedded.d.ts.map +1 -1
- package/lib/embedded.js +24 -167
- package/lib/embedded.js.map +1 -1
- package/lib/event-mapper.d.ts.map +1 -1
- package/lib/event-mapper.js +0 -4
- package/lib/event-mapper.js.map +1 -1
- package/lib/matrix.d.ts +0 -25
- package/lib/matrix.d.ts.map +1 -1
- package/lib/matrix.js +1 -30
- package/lib/matrix.js.map +1 -1
- package/lib/models/MSC3089Branch.d.ts.map +1 -1
- package/lib/models/MSC3089Branch.js +0 -3
- package/lib/models/MSC3089Branch.js.map +1 -1
- package/lib/models/event.d.ts +0 -94
- package/lib/models/event.d.ts.map +1 -1
- package/lib/models/event.js +0 -274
- package/lib/models/event.js.map +1 -1
- package/lib/models/poll.d.ts.map +1 -1
- package/lib/models/poll.js +1 -5
- package/lib/models/poll.js.map +1 -1
- package/lib/models/relations-container.d.ts.map +1 -1
- package/lib/models/relations-container.js +1 -7
- package/lib/models/relations-container.js.map +1 -1
- package/lib/models/relations.d.ts +0 -1
- package/lib/models/relations.d.ts.map +1 -1
- package/lib/models/relations.js +0 -8
- package/lib/models/relations.js.map +1 -1
- package/lib/models/room-state.d.ts.map +1 -1
- package/lib/models/room-state.js +10 -26
- package/lib/models/room-state.js.map +1 -1
- package/lib/models/room.d.ts +0 -18
- package/lib/models/room.d.ts.map +1 -1
- package/lib/models/room.js +94 -148
- package/lib/models/room.js.map +1 -1
- package/lib/models/thread.d.ts.map +1 -1
- package/lib/models/thread.js +0 -1
- package/lib/models/thread.js.map +1 -1
- package/lib/sliding-sync-sdk.d.ts +2 -3
- package/lib/sliding-sync-sdk.d.ts.map +1 -1
- package/lib/sliding-sync-sdk.js +41 -90
- package/lib/sliding-sync-sdk.js.map +1 -1
- package/lib/sync.d.ts +0 -12
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +1 -73
- package/lib/sync.js.map +1 -1
- package/lib/testing.d.ts +0 -48
- package/lib/testing.d.ts.map +1 -1
- package/lib/testing.js +0 -105
- package/lib/testing.js.map +1 -1
- package/package.json +1 -3
- package/src/@types/event.ts +2 -36
- package/src/@types/global.d.ts +0 -3
- package/src/browser-index.ts +0 -11
- package/src/client.ts +52 -2876
- package/src/embedded.ts +3 -132
- package/src/event-mapper.ts +0 -4
- package/src/matrix.ts +0 -41
- package/src/models/MSC3089Branch.ts +0 -3
- package/src/models/event.ts +0 -289
- package/src/models/poll.ts +0 -6
- package/src/models/relations-container.ts +1 -8
- package/src/models/relations.ts +0 -8
- package/src/models/room-state.ts +2 -8
- package/src/models/room.ts +0 -62
- package/src/models/thread.ts +0 -1
- package/src/sliding-sync-sdk.ts +2 -72
- package/src/sync.ts +1 -98
- package/src/testing.ts +0 -108
- package/lib/@types/crypto.d.ts +0 -47
- package/lib/@types/crypto.d.ts.map +0 -1
- package/lib/@types/crypto.js +0 -1
- package/lib/@types/crypto.js.map +0 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js +0 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js.map +0 -1
- package/lib/common-crypto/CryptoBackend.d.ts +0 -240
- package/lib/common-crypto/CryptoBackend.d.ts.map +0 -1
- package/lib/common-crypto/CryptoBackend.js +0 -73
- package/lib/common-crypto/CryptoBackend.js.map +0 -1
- package/lib/common-crypto/key-passphrase.d.ts +0 -14
- package/lib/common-crypto/key-passphrase.d.ts.map +0 -1
- package/lib/common-crypto/key-passphrase.js +0 -33
- package/lib/common-crypto/key-passphrase.js.map +0 -1
- package/lib/crypto/CrossSigning.d.ts +0 -184
- package/lib/crypto/CrossSigning.d.ts.map +0 -1
- package/lib/crypto/CrossSigning.js +0 -718
- package/lib/crypto/CrossSigning.js.map +0 -1
- package/lib/crypto/DeviceList.d.ts +0 -216
- package/lib/crypto/DeviceList.d.ts.map +0 -1
- package/lib/crypto/DeviceList.js +0 -892
- package/lib/crypto/DeviceList.js.map +0 -1
- package/lib/crypto/EncryptionSetup.d.ts +0 -152
- package/lib/crypto/EncryptionSetup.d.ts.map +0 -1
- package/lib/crypto/EncryptionSetup.js +0 -356
- package/lib/crypto/EncryptionSetup.js.map +0 -1
- package/lib/crypto/OlmDevice.d.ts +0 -457
- package/lib/crypto/OlmDevice.d.ts.map +0 -1
- package/lib/crypto/OlmDevice.js +0 -1241
- package/lib/crypto/OlmDevice.js.map +0 -1
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts +0 -109
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts.map +0 -1
- package/lib/crypto/OutgoingRoomKeyRequestManager.js +0 -415
- package/lib/crypto/OutgoingRoomKeyRequestManager.js.map +0 -1
- package/lib/crypto/RoomList.d.ts +0 -26
- package/lib/crypto/RoomList.d.ts.map +0 -1
- package/lib/crypto/RoomList.js +0 -71
- package/lib/crypto/RoomList.js.map +0 -1
- package/lib/crypto/SecretSharing.d.ts +0 -24
- package/lib/crypto/SecretSharing.d.ts.map +0 -1
- package/lib/crypto/SecretSharing.js +0 -194
- package/lib/crypto/SecretSharing.js.map +0 -1
- package/lib/crypto/SecretStorage.d.ts +0 -55
- package/lib/crypto/SecretStorage.d.ts.map +0 -1
- package/lib/crypto/SecretStorage.js +0 -118
- package/lib/crypto/SecretStorage.js.map +0 -1
- package/lib/crypto/aes.d.ts +0 -6
- package/lib/crypto/aes.d.ts.map +0 -1
- package/lib/crypto/aes.js +0 -24
- package/lib/crypto/aes.js.map +0 -1
- package/lib/crypto/algorithms/base.d.ts +0 -156
- package/lib/crypto/algorithms/base.d.ts.map +0 -1
- package/lib/crypto/algorithms/base.js +0 -187
- package/lib/crypto/algorithms/base.js.map +0 -1
- package/lib/crypto/algorithms/index.d.ts +0 -4
- package/lib/crypto/algorithms/index.d.ts.map +0 -1
- package/lib/crypto/algorithms/index.js +0 -20
- package/lib/crypto/algorithms/index.js.map +0 -1
- package/lib/crypto/algorithms/megolm.d.ts +0 -385
- package/lib/crypto/algorithms/megolm.d.ts.map +0 -1
- package/lib/crypto/algorithms/megolm.js +0 -1822
- package/lib/crypto/algorithms/megolm.js.map +0 -1
- package/lib/crypto/algorithms/olm.d.ts +0 -5
- package/lib/crypto/algorithms/olm.d.ts.map +0 -1
- package/lib/crypto/algorithms/olm.js +0 -299
- package/lib/crypto/algorithms/olm.js.map +0 -1
- package/lib/crypto/api.d.ts +0 -32
- package/lib/crypto/api.d.ts.map +0 -1
- package/lib/crypto/api.js +0 -22
- package/lib/crypto/api.js.map +0 -1
- package/lib/crypto/backup.d.ts +0 -227
- package/lib/crypto/backup.d.ts.map +0 -1
- package/lib/crypto/backup.js +0 -824
- package/lib/crypto/backup.js.map +0 -1
- package/lib/crypto/crypto.d.ts +0 -3
- package/lib/crypto/crypto.d.ts.map +0 -1
- package/lib/crypto/crypto.js +0 -19
- package/lib/crypto/crypto.js.map +0 -1
- package/lib/crypto/dehydration.d.ts +0 -34
- package/lib/crypto/dehydration.d.ts.map +0 -1
- package/lib/crypto/dehydration.js +0 -252
- package/lib/crypto/dehydration.js.map +0 -1
- package/lib/crypto/device-converter.d.ts +0 -9
- package/lib/crypto/device-converter.d.ts.map +0 -1
- package/lib/crypto/device-converter.js +0 -42
- package/lib/crypto/device-converter.js.map +0 -1
- package/lib/crypto/deviceinfo.d.ts +0 -99
- package/lib/crypto/deviceinfo.d.ts.map +0 -1
- package/lib/crypto/deviceinfo.js +0 -148
- package/lib/crypto/deviceinfo.js.map +0 -1
- package/lib/crypto/index.d.ts +0 -1209
- package/lib/crypto/index.d.ts.map +0 -1
- package/lib/crypto/index.js +0 -4097
- package/lib/crypto/index.js.map +0 -1
- package/lib/crypto/key_passphrase.d.ts +0 -14
- package/lib/crypto/key_passphrase.d.ts.map +0 -1
- package/lib/crypto/key_passphrase.js +0 -44
- package/lib/crypto/key_passphrase.js.map +0 -1
- package/lib/crypto/keybackup.d.ts +0 -18
- package/lib/crypto/keybackup.d.ts.map +0 -1
- package/lib/crypto/keybackup.js +0 -1
- package/lib/crypto/keybackup.js.map +0 -1
- package/lib/crypto/olmlib.d.ts +0 -129
- package/lib/crypto/olmlib.d.ts.map +0 -1
- package/lib/crypto/olmlib.js +0 -492
- package/lib/crypto/olmlib.js.map +0 -1
- package/lib/crypto/recoverykey.d.ts +0 -2
- package/lib/crypto/recoverykey.d.ts.map +0 -1
- package/lib/crypto/recoverykey.js +0 -19
- package/lib/crypto/recoverykey.js.map +0 -1
- package/lib/crypto/store/base.d.ts +0 -252
- package/lib/crypto/store/base.d.ts.map +0 -1
- package/lib/crypto/store/base.js +0 -64
- package/lib/crypto/store/base.js.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts +0 -187
- package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.js +0 -1145
- package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store.d.ts +0 -432
- package/lib/crypto/store/indexeddb-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store.js +0 -728
- package/lib/crypto/store/indexeddb-crypto-store.js.map +0 -1
- package/lib/crypto/store/localStorage-crypto-store.d.ts +0 -119
- package/lib/crypto/store/localStorage-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/localStorage-crypto-store.js +0 -531
- package/lib/crypto/store/localStorage-crypto-store.js.map +0 -1
- package/lib/crypto/store/memory-crypto-store.d.ts +0 -215
- package/lib/crypto/store/memory-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/memory-crypto-store.js +0 -622
- package/lib/crypto/store/memory-crypto-store.js.map +0 -1
- package/lib/crypto/verification/Base.d.ts +0 -105
- package/lib/crypto/verification/Base.d.ts.map +0 -1
- package/lib/crypto/verification/Base.js +0 -372
- package/lib/crypto/verification/Base.js.map +0 -1
- package/lib/crypto/verification/Error.d.ts +0 -35
- package/lib/crypto/verification/Error.d.ts.map +0 -1
- package/lib/crypto/verification/Error.js +0 -86
- package/lib/crypto/verification/Error.js.map +0 -1
- package/lib/crypto/verification/IllegalMethod.d.ts +0 -15
- package/lib/crypto/verification/IllegalMethod.d.ts.map +0 -1
- package/lib/crypto/verification/IllegalMethod.js +0 -43
- package/lib/crypto/verification/IllegalMethod.js.map +0 -1
- package/lib/crypto/verification/QRCode.d.ts +0 -51
- package/lib/crypto/verification/QRCode.d.ts.map +0 -1
- package/lib/crypto/verification/QRCode.js +0 -277
- package/lib/crypto/verification/QRCode.js.map +0 -1
- package/lib/crypto/verification/SAS.d.ts +0 -27
- package/lib/crypto/verification/SAS.d.ts.map +0 -1
- package/lib/crypto/verification/SAS.js +0 -485
- package/lib/crypto/verification/SAS.js.map +0 -1
- package/lib/crypto/verification/SASDecimal.d.ts +0 -8
- package/lib/crypto/verification/SASDecimal.d.ts.map +0 -1
- package/lib/crypto/verification/SASDecimal.js +0 -34
- package/lib/crypto/verification/SASDecimal.js.map +0 -1
- package/lib/crypto/verification/request/Channel.d.ts +0 -18
- package/lib/crypto/verification/request/Channel.d.ts.map +0 -1
- package/lib/crypto/verification/request/Channel.js +0 -1
- package/lib/crypto/verification/request/Channel.js.map +0 -1
- package/lib/crypto/verification/request/InRoomChannel.d.ts +0 -113
- package/lib/crypto/verification/request/InRoomChannel.d.ts.map +0 -1
- package/lib/crypto/verification/request/InRoomChannel.js +0 -351
- package/lib/crypto/verification/request/InRoomChannel.js.map +0 -1
- package/lib/crypto/verification/request/ToDeviceChannel.d.ts +0 -105
- package/lib/crypto/verification/request/ToDeviceChannel.d.ts.map +0 -1
- package/lib/crypto/verification/request/ToDeviceChannel.js +0 -328
- package/lib/crypto/verification/request/ToDeviceChannel.js.map +0 -1
- package/lib/crypto/verification/request/VerificationRequest.d.ts +0 -227
- package/lib/crypto/verification/request/VerificationRequest.d.ts.map +0 -1
- package/lib/crypto/verification/request/VerificationRequest.js +0 -937
- package/lib/crypto/verification/request/VerificationRequest.js.map +0 -1
- package/lib/crypto-api/CryptoEvent.d.ts +0 -69
- package/lib/crypto-api/CryptoEvent.d.ts.map +0 -1
- package/lib/crypto-api/CryptoEvent.js +0 -33
- package/lib/crypto-api/CryptoEvent.js.map +0 -1
- package/lib/crypto-api/CryptoEventHandlerMap.d.ts +0 -16
- package/lib/crypto-api/CryptoEventHandlerMap.d.ts.map +0 -1
- package/lib/crypto-api/CryptoEventHandlerMap.js +0 -22
- package/lib/crypto-api/CryptoEventHandlerMap.js.map +0 -1
- package/lib/crypto-api/index.d.ts +0 -978
- package/lib/crypto-api/index.d.ts.map +0 -1
- package/lib/crypto-api/index.js +0 -304
- package/lib/crypto-api/index.js.map +0 -1
- package/lib/crypto-api/key-passphrase.d.ts +0 -11
- package/lib/crypto-api/key-passphrase.d.ts.map +0 -1
- package/lib/crypto-api/key-passphrase.js +0 -51
- package/lib/crypto-api/key-passphrase.js.map +0 -1
- package/lib/crypto-api/keybackup.d.ts +0 -88
- package/lib/crypto-api/keybackup.d.ts.map +0 -1
- package/lib/crypto-api/keybackup.js +0 -1
- package/lib/crypto-api/keybackup.js.map +0 -1
- package/lib/crypto-api/recovery-key.d.ts +0 -11
- package/lib/crypto-api/recovery-key.d.ts.map +0 -1
- package/lib/crypto-api/recovery-key.js +0 -65
- package/lib/crypto-api/recovery-key.js.map +0 -1
- package/lib/crypto-api/verification.d.ts +0 -344
- package/lib/crypto-api/verification.d.ts.map +0 -1
- package/lib/crypto-api/verification.js +0 -91
- package/lib/crypto-api/verification.js.map +0 -1
- package/lib/matrixrtc/CallMembership.d.ts +0 -66
- package/lib/matrixrtc/CallMembership.d.ts.map +0 -1
- package/lib/matrixrtc/CallMembership.js +0 -197
- package/lib/matrixrtc/CallMembership.js.map +0 -1
- package/lib/matrixrtc/LivekitFocus.d.ts +0 -16
- package/lib/matrixrtc/LivekitFocus.d.ts.map +0 -1
- package/lib/matrixrtc/LivekitFocus.js +0 -20
- package/lib/matrixrtc/LivekitFocus.js.map +0 -1
- package/lib/matrixrtc/MatrixRTCSession.d.ts +0 -295
- package/lib/matrixrtc/MatrixRTCSession.d.ts.map +0 -1
- package/lib/matrixrtc/MatrixRTCSession.js +0 -1043
- package/lib/matrixrtc/MatrixRTCSession.js.map +0 -1
- package/lib/matrixrtc/MatrixRTCSessionManager.d.ts +0 -40
- package/lib/matrixrtc/MatrixRTCSessionManager.d.ts.map +0 -1
- package/lib/matrixrtc/MatrixRTCSessionManager.js +0 -146
- package/lib/matrixrtc/MatrixRTCSessionManager.js.map +0 -1
- package/lib/matrixrtc/focus.d.ts +0 -10
- package/lib/matrixrtc/focus.d.ts.map +0 -1
- package/lib/matrixrtc/focus.js +0 -1
- package/lib/matrixrtc/focus.js.map +0 -1
- package/lib/matrixrtc/index.d.ts +0 -7
- package/lib/matrixrtc/index.d.ts.map +0 -1
- package/lib/matrixrtc/index.js +0 -21
- package/lib/matrixrtc/index.js.map +0 -1
- package/lib/matrixrtc/types.d.ts +0 -19
- package/lib/matrixrtc/types.d.ts.map +0 -1
- package/lib/matrixrtc/types.js +0 -1
- package/lib/matrixrtc/types.js.map +0 -1
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts +0 -112
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts.map +0 -1
- package/lib/rendezvous/MSC4108SignInWithQR.js +0 -392
- package/lib/rendezvous/MSC4108SignInWithQR.js.map +0 -1
- package/lib/rendezvous/RendezvousChannel.d.ts +0 -27
- package/lib/rendezvous/RendezvousChannel.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousChannel.js +0 -1
- package/lib/rendezvous/RendezvousChannel.js.map +0 -1
- package/lib/rendezvous/RendezvousCode.d.ts +0 -9
- package/lib/rendezvous/RendezvousCode.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousCode.js +0 -1
- package/lib/rendezvous/RendezvousCode.js.map +0 -1
- package/lib/rendezvous/RendezvousError.d.ts +0 -6
- package/lib/rendezvous/RendezvousError.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousError.js +0 -23
- package/lib/rendezvous/RendezvousError.js.map +0 -1
- package/lib/rendezvous/RendezvousFailureReason.d.ts +0 -31
- package/lib/rendezvous/RendezvousFailureReason.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousFailureReason.js +0 -38
- package/lib/rendezvous/RendezvousFailureReason.js.map +0 -1
- package/lib/rendezvous/RendezvousIntent.d.ts +0 -5
- package/lib/rendezvous/RendezvousIntent.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousIntent.js +0 -22
- package/lib/rendezvous/RendezvousIntent.js.map +0 -1
- package/lib/rendezvous/RendezvousTransport.d.ts +0 -36
- package/lib/rendezvous/RendezvousTransport.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousTransport.js +0 -1
- package/lib/rendezvous/RendezvousTransport.js.map +0 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts +0 -58
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts.map +0 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.js +0 -246
- package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +0 -1
- package/lib/rendezvous/channels/index.d.ts +0 -2
- package/lib/rendezvous/channels/index.d.ts.map +0 -1
- package/lib/rendezvous/channels/index.js +0 -18
- package/lib/rendezvous/channels/index.js.map +0 -1
- package/lib/rendezvous/index.d.ts +0 -10
- package/lib/rendezvous/index.d.ts.map +0 -1
- package/lib/rendezvous/index.js +0 -23
- package/lib/rendezvous/index.js.map +0 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +0 -61
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts.map +0 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js +0 -253
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +0 -1
- package/lib/rendezvous/transports/index.d.ts +0 -2
- package/lib/rendezvous/transports/index.d.ts.map +0 -1
- package/lib/rendezvous/transports/index.js +0 -18
- package/lib/rendezvous/transports/index.js.map +0 -1
- package/lib/rust-crypto/CrossSigningIdentity.d.ts +0 -33
- package/lib/rust-crypto/CrossSigningIdentity.d.ts.map +0 -1
- package/lib/rust-crypto/CrossSigningIdentity.js +0 -157
- package/lib/rust-crypto/CrossSigningIdentity.js.map +0 -1
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts +0 -98
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts.map +0 -1
- package/lib/rust-crypto/DehydratedDeviceManager.js +0 -285
- package/lib/rust-crypto/DehydratedDeviceManager.js.map +0 -1
- package/lib/rust-crypto/KeyClaimManager.d.ts +0 -33
- package/lib/rust-crypto/KeyClaimManager.d.ts.map +0 -1
- package/lib/rust-crypto/KeyClaimManager.js +0 -82
- package/lib/rust-crypto/KeyClaimManager.js.map +0 -1
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts +0 -43
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts.map +0 -1
- package/lib/rust-crypto/OutgoingRequestProcessor.js +0 -195
- package/lib/rust-crypto/OutgoingRequestProcessor.js.map +0 -1
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts +0 -47
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts.map +0 -1
- package/lib/rust-crypto/OutgoingRequestsManager.js +0 -148
- package/lib/rust-crypto/OutgoingRequestsManager.js.map +0 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +0 -120
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts.map +0 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +0 -467
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +0 -1
- package/lib/rust-crypto/RoomEncryptor.d.ts +0 -98
- package/lib/rust-crypto/RoomEncryptor.d.ts.map +0 -1
- package/lib/rust-crypto/RoomEncryptor.js +0 -299
- package/lib/rust-crypto/RoomEncryptor.js.map +0 -1
- package/lib/rust-crypto/backup.d.ts +0 -254
- package/lib/rust-crypto/backup.d.ts.map +0 -1
- package/lib/rust-crypto/backup.js +0 -837
- package/lib/rust-crypto/backup.js.map +0 -1
- package/lib/rust-crypto/constants.d.ts +0 -3
- package/lib/rust-crypto/constants.d.ts.map +0 -1
- package/lib/rust-crypto/constants.js +0 -19
- package/lib/rust-crypto/constants.js.map +0 -1
- package/lib/rust-crypto/device-converter.d.ts +0 -28
- package/lib/rust-crypto/device-converter.d.ts.map +0 -1
- package/lib/rust-crypto/device-converter.js +0 -123
- package/lib/rust-crypto/device-converter.js.map +0 -1
- package/lib/rust-crypto/index.d.ts +0 -61
- package/lib/rust-crypto/index.d.ts.map +0 -1
- package/lib/rust-crypto/index.js +0 -152
- package/lib/rust-crypto/index.js.map +0 -1
- package/lib/rust-crypto/libolm_migration.d.ts +0 -81
- package/lib/rust-crypto/libolm_migration.d.ts.map +0 -1
- package/lib/rust-crypto/libolm_migration.js +0 -459
- package/lib/rust-crypto/libolm_migration.js.map +0 -1
- package/lib/rust-crypto/rust-crypto.d.ts +0 -556
- package/lib/rust-crypto/rust-crypto.d.ts.map +0 -1
- package/lib/rust-crypto/rust-crypto.js +0 -2016
- package/lib/rust-crypto/rust-crypto.js.map +0 -1
- package/lib/rust-crypto/secret-storage.d.ts +0 -22
- package/lib/rust-crypto/secret-storage.d.ts.map +0 -1
- package/lib/rust-crypto/secret-storage.js +0 -63
- package/lib/rust-crypto/secret-storage.js.map +0 -1
- package/lib/rust-crypto/verification.d.ts +0 -319
- package/lib/rust-crypto/verification.d.ts.map +0 -1
- package/lib/rust-crypto/verification.js +0 -816
- package/lib/rust-crypto/verification.js.map +0 -1
- package/lib/secret-storage.d.ts +0 -370
- package/lib/secret-storage.d.ts.map +0 -1
- package/lib/secret-storage.js +0 -466
- package/lib/secret-storage.js.map +0 -1
- package/lib/webrtc/audioContext.d.ts +0 -15
- package/lib/webrtc/audioContext.d.ts.map +0 -1
- package/lib/webrtc/audioContext.js +0 -46
- package/lib/webrtc/audioContext.js.map +0 -1
- package/lib/webrtc/call.d.ts +0 -560
- package/lib/webrtc/call.d.ts.map +0 -1
- package/lib/webrtc/call.js +0 -2541
- package/lib/webrtc/call.js.map +0 -1
- package/lib/webrtc/callEventHandler.d.ts +0 -37
- package/lib/webrtc/callEventHandler.d.ts.map +0 -1
- package/lib/webrtc/callEventHandler.js +0 -344
- package/lib/webrtc/callEventHandler.js.map +0 -1
- package/lib/webrtc/callEventTypes.d.ts +0 -73
- package/lib/webrtc/callEventTypes.d.ts.map +0 -1
- package/lib/webrtc/callEventTypes.js +0 -13
- package/lib/webrtc/callEventTypes.js.map +0 -1
- package/lib/webrtc/callFeed.d.ts +0 -128
- package/lib/webrtc/callFeed.d.ts.map +0 -1
- package/lib/webrtc/callFeed.js +0 -289
- package/lib/webrtc/callFeed.js.map +0 -1
- package/lib/webrtc/groupCall.d.ts +0 -323
- package/lib/webrtc/groupCall.d.ts.map +0 -1
- package/lib/webrtc/groupCall.js +0 -1337
- package/lib/webrtc/groupCall.js.map +0 -1
- package/lib/webrtc/groupCallEventHandler.d.ts +0 -31
- package/lib/webrtc/groupCallEventHandler.d.ts.map +0 -1
- package/lib/webrtc/groupCallEventHandler.js +0 -178
- package/lib/webrtc/groupCallEventHandler.js.map +0 -1
- package/lib/webrtc/mediaHandler.d.ts +0 -89
- package/lib/webrtc/mediaHandler.d.ts.map +0 -1
- package/lib/webrtc/mediaHandler.js +0 -437
- package/lib/webrtc/mediaHandler.js.map +0 -1
- package/lib/webrtc/stats/callFeedStatsReporter.d.ts +0 -8
- package/lib/webrtc/stats/callFeedStatsReporter.d.ts.map +0 -1
- package/lib/webrtc/stats/callFeedStatsReporter.js +0 -82
- package/lib/webrtc/stats/callFeedStatsReporter.js.map +0 -1
- package/lib/webrtc/stats/callStatsReportGatherer.d.ts +0 -25
- package/lib/webrtc/stats/callStatsReportGatherer.d.ts.map +0 -1
- package/lib/webrtc/stats/callStatsReportGatherer.js +0 -199
- package/lib/webrtc/stats/callStatsReportGatherer.js.map +0 -1
- package/lib/webrtc/stats/callStatsReportSummary.d.ts +0 -17
- package/lib/webrtc/stats/callStatsReportSummary.d.ts.map +0 -1
- package/lib/webrtc/stats/callStatsReportSummary.js +0 -1
- package/lib/webrtc/stats/callStatsReportSummary.js.map +0 -1
- package/lib/webrtc/stats/connectionStats.d.ts +0 -28
- package/lib/webrtc/stats/connectionStats.d.ts.map +0 -1
- package/lib/webrtc/stats/connectionStats.js +0 -26
- package/lib/webrtc/stats/connectionStats.js.map +0 -1
- package/lib/webrtc/stats/connectionStatsBuilder.d.ts +0 -5
- package/lib/webrtc/stats/connectionStatsBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/connectionStatsBuilder.js +0 -27
- package/lib/webrtc/stats/connectionStatsBuilder.js.map +0 -1
- package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts +0 -7
- package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/connectionStatsReportBuilder.js +0 -121
- package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +0 -1
- package/lib/webrtc/stats/groupCallStats.d.ts +0 -22
- package/lib/webrtc/stats/groupCallStats.d.ts.map +0 -1
- package/lib/webrtc/stats/groupCallStats.js +0 -78
- package/lib/webrtc/stats/groupCallStats.js.map +0 -1
- package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts +0 -10
- package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaSsrcHandler.js +0 -57
- package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackHandler.d.ts +0 -12
- package/lib/webrtc/stats/media/mediaTrackHandler.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackHandler.js +0 -62
- package/lib/webrtc/stats/media/mediaTrackHandler.js.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStats.d.ts +0 -86
- package/lib/webrtc/stats/media/mediaTrackStats.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStats.js +0 -142
- package/lib/webrtc/stats/media/mediaTrackStats.js.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts +0 -22
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +0 -76
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +0 -1
- package/lib/webrtc/stats/statsReport.d.ts +0 -99
- package/lib/webrtc/stats/statsReport.d.ts.map +0 -1
- package/lib/webrtc/stats/statsReport.js +0 -32
- package/lib/webrtc/stats/statsReport.js.map +0 -1
- package/lib/webrtc/stats/statsReportEmitter.d.ts +0 -15
- package/lib/webrtc/stats/statsReportEmitter.d.ts.map +0 -1
- package/lib/webrtc/stats/statsReportEmitter.js +0 -33
- package/lib/webrtc/stats/statsReportEmitter.js.map +0 -1
- package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts +0 -16
- package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts.map +0 -1
- package/lib/webrtc/stats/summaryStatsReportGatherer.js +0 -116
- package/lib/webrtc/stats/summaryStatsReportGatherer.js.map +0 -1
- package/lib/webrtc/stats/trackStatsBuilder.d.ts +0 -19
- package/lib/webrtc/stats/trackStatsBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/trackStatsBuilder.js +0 -168
- package/lib/webrtc/stats/trackStatsBuilder.js.map +0 -1
- package/lib/webrtc/stats/transportStats.d.ts +0 -11
- package/lib/webrtc/stats/transportStats.d.ts.map +0 -1
- package/lib/webrtc/stats/transportStats.js +0 -1
- package/lib/webrtc/stats/transportStats.js.map +0 -1
- package/lib/webrtc/stats/transportStatsBuilder.d.ts +0 -5
- package/lib/webrtc/stats/transportStatsBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/transportStatsBuilder.js +0 -34
- package/lib/webrtc/stats/transportStatsBuilder.js.map +0 -1
- package/lib/webrtc/stats/valueFormatter.d.ts +0 -4
- package/lib/webrtc/stats/valueFormatter.d.ts.map +0 -1
- package/lib/webrtc/stats/valueFormatter.js +0 -25
- package/lib/webrtc/stats/valueFormatter.js.map +0 -1
- package/src/@types/crypto.ts +0 -73
- package/src/@types/matrix-sdk-crypto-wasm.d.ts +0 -44
- package/src/common-crypto/CryptoBackend.ts +0 -302
- package/src/common-crypto/README.md +0 -4
- package/src/common-crypto/key-passphrase.ts +0 -43
- package/src/crypto/CrossSigning.ts +0 -773
- package/src/crypto/DeviceList.ts +0 -989
- package/src/crypto/EncryptionSetup.ts +0 -351
- package/src/crypto/OlmDevice.ts +0 -1500
- package/src/crypto/OutgoingRoomKeyRequestManager.ts +0 -485
- package/src/crypto/RoomList.ts +0 -70
- package/src/crypto/SecretSharing.ts +0 -240
- package/src/crypto/SecretStorage.ts +0 -136
- package/src/crypto/aes.ts +0 -23
- package/src/crypto/algorithms/base.ts +0 -236
- package/src/crypto/algorithms/index.ts +0 -20
- package/src/crypto/algorithms/megolm.ts +0 -2216
- package/src/crypto/algorithms/olm.ts +0 -381
- package/src/crypto/api.ts +0 -70
- package/src/crypto/backup.ts +0 -922
- package/src/crypto/crypto.ts +0 -18
- package/src/crypto/dehydration.ts +0 -272
- package/src/crypto/device-converter.ts +0 -45
- package/src/crypto/deviceinfo.ts +0 -158
- package/src/crypto/index.ts +0 -4414
- package/src/crypto/key_passphrase.ts +0 -42
- package/src/crypto/keybackup.ts +0 -47
- package/src/crypto/olmlib.ts +0 -539
- package/src/crypto/recoverykey.ts +0 -18
- package/src/crypto/store/base.ts +0 -348
- package/src/crypto/store/indexeddb-crypto-store-backend.ts +0 -1250
- package/src/crypto/store/indexeddb-crypto-store.ts +0 -845
- package/src/crypto/store/localStorage-crypto-store.ts +0 -579
- package/src/crypto/store/memory-crypto-store.ts +0 -680
- package/src/crypto/verification/Base.ts +0 -409
- package/src/crypto/verification/Error.ts +0 -76
- package/src/crypto/verification/IllegalMethod.ts +0 -50
- package/src/crypto/verification/QRCode.ts +0 -310
- package/src/crypto/verification/SAS.ts +0 -494
- package/src/crypto/verification/SASDecimal.ts +0 -37
- package/src/crypto/verification/request/Channel.ts +0 -34
- package/src/crypto/verification/request/InRoomChannel.ts +0 -371
- package/src/crypto/verification/request/ToDeviceChannel.ts +0 -354
- package/src/crypto/verification/request/VerificationRequest.ts +0 -976
- package/src/crypto-api/CryptoEvent.ts +0 -93
- package/src/crypto-api/CryptoEventHandlerMap.ts +0 -32
- package/src/crypto-api/index.ts +0 -1175
- package/src/crypto-api/key-passphrase.ts +0 -58
- package/src/crypto-api/keybackup.ts +0 -115
- package/src/crypto-api/recovery-key.ts +0 -69
- package/src/crypto-api/verification.ts +0 -408
- package/src/matrixrtc/CallMembership.ts +0 -247
- package/src/matrixrtc/LivekitFocus.ts +0 -39
- package/src/matrixrtc/MatrixRTCSession.ts +0 -1319
- package/src/matrixrtc/MatrixRTCSessionManager.ts +0 -166
- package/src/matrixrtc/focus.ts +0 -25
- package/src/matrixrtc/index.ts +0 -22
- package/src/matrixrtc/types.ts +0 -36
- package/src/rendezvous/MSC4108SignInWithQR.ts +0 -444
- package/src/rendezvous/RendezvousChannel.ts +0 -48
- package/src/rendezvous/RendezvousCode.ts +0 -25
- package/src/rendezvous/RendezvousError.ts +0 -26
- package/src/rendezvous/RendezvousFailureReason.ts +0 -49
- package/src/rendezvous/RendezvousIntent.ts +0 -20
- package/src/rendezvous/RendezvousTransport.ts +0 -58
- package/src/rendezvous/channels/MSC4108SecureChannel.ts +0 -270
- package/src/rendezvous/channels/index.ts +0 -17
- package/src/rendezvous/index.ts +0 -25
- package/src/rendezvous/transports/MSC4108RendezvousSession.ts +0 -270
- package/src/rendezvous/transports/index.ts +0 -17
- package/src/rust-crypto/CrossSigningIdentity.ts +0 -183
- package/src/rust-crypto/DehydratedDeviceManager.ts +0 -306
- package/src/rust-crypto/KeyClaimManager.ts +0 -86
- package/src/rust-crypto/OutgoingRequestProcessor.ts +0 -236
- package/src/rust-crypto/OutgoingRequestsManager.ts +0 -143
- package/src/rust-crypto/PerSessionKeyBackupDownloader.ts +0 -501
- package/src/rust-crypto/RoomEncryptor.ts +0 -352
- package/src/rust-crypto/backup.ts +0 -881
- package/src/rust-crypto/constants.ts +0 -18
- package/src/rust-crypto/device-converter.ts +0 -128
- package/src/rust-crypto/index.ts +0 -237
- package/src/rust-crypto/libolm_migration.ts +0 -530
- package/src/rust-crypto/rust-crypto.ts +0 -2205
- package/src/rust-crypto/secret-storage.ts +0 -60
- package/src/rust-crypto/verification.ts +0 -830
- package/src/secret-storage.ts +0 -693
- package/src/webrtc/audioContext.ts +0 -44
- package/src/webrtc/call.ts +0 -3074
- package/src/webrtc/callEventHandler.ts +0 -425
- package/src/webrtc/callEventTypes.ts +0 -93
- package/src/webrtc/callFeed.ts +0 -364
- package/src/webrtc/groupCall.ts +0 -1735
- package/src/webrtc/groupCallEventHandler.ts +0 -234
- package/src/webrtc/mediaHandler.ts +0 -484
- package/src/webrtc/stats/callFeedStatsReporter.ts +0 -94
- package/src/webrtc/stats/callStatsReportGatherer.ts +0 -219
- package/src/webrtc/stats/callStatsReportSummary.ts +0 -30
- package/src/webrtc/stats/connectionStats.ts +0 -47
- package/src/webrtc/stats/connectionStatsBuilder.ts +0 -28
- package/src/webrtc/stats/connectionStatsReportBuilder.ts +0 -140
- package/src/webrtc/stats/groupCallStats.ts +0 -93
- package/src/webrtc/stats/media/mediaSsrcHandler.ts +0 -57
- package/src/webrtc/stats/media/mediaTrackHandler.ts +0 -76
- package/src/webrtc/stats/media/mediaTrackStats.ts +0 -176
- package/src/webrtc/stats/media/mediaTrackStatsHandler.ts +0 -90
- package/src/webrtc/stats/statsReport.ts +0 -133
- package/src/webrtc/stats/statsReportEmitter.ts +0 -49
- package/src/webrtc/stats/summaryStatsReportGatherer.ts +0 -148
- package/src/webrtc/stats/trackStatsBuilder.ts +0 -207
- package/src/webrtc/stats/transportStats.ts +0 -26
- package/src/webrtc/stats/transportStatsBuilder.ts +0 -48
- package/src/webrtc/stats/valueFormatter.ts +0 -27
@@ -1,299 +0,0 @@
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
-
/*
|
4
|
-
Copyright 2023 The Matrix.org Foundation C.I.C.
|
5
|
-
|
6
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
you may not use this file except in compliance with the License.
|
8
|
-
You may obtain a copy of the License at
|
9
|
-
|
10
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
|
12
|
-
Unless required by applicable law or agreed to in writing, software
|
13
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
See the License for the specific language governing permissions and
|
16
|
-
limitations under the License.
|
17
|
-
*/
|
18
|
-
|
19
|
-
import * as RustSdkCryptoJs from "@matrix-org/matrix-sdk-crypto-wasm";
|
20
|
-
import { CollectStrategy, EncryptionAlgorithm, EncryptionSettings, HistoryVisibility as RustHistoryVisibility, RoomId, UserId } from "@matrix-org/matrix-sdk-crypto-wasm";
|
21
|
-
import { EventType } from "../@types/event.js";
|
22
|
-
import { logger, LogSpan } from "../logger.js";
|
23
|
-
import { HistoryVisibility } from "../@types/partials.js";
|
24
|
-
import { logDuration } from "../utils.js";
|
25
|
-
import { KnownMembership } from "../@types/membership.js";
|
26
|
-
import { DeviceIsolationModeKind } from "../crypto-api/index.js";
|
27
|
-
|
28
|
-
/**
|
29
|
-
* RoomEncryptor: responsible for encrypting messages to a given room
|
30
|
-
*
|
31
|
-
* @internal
|
32
|
-
*/
|
33
|
-
export class RoomEncryptor {
|
34
|
-
/**
|
35
|
-
* @param olmMachine - The rust-sdk's OlmMachine
|
36
|
-
* @param keyClaimManager - Our KeyClaimManager, which manages the queue of one-time-key claim requests
|
37
|
-
* @param outgoingRequestManager - The OutgoingRequestManager, which manages the queue of outgoing requests.
|
38
|
-
* @param room - The room we want to encrypt for
|
39
|
-
* @param encryptionSettings - body of the m.room.encryption event currently in force in this room
|
40
|
-
*/
|
41
|
-
constructor(olmMachine, keyClaimManager, outgoingRequestManager, room, encryptionSettings) {
|
42
|
-
this.olmMachine = olmMachine;
|
43
|
-
this.keyClaimManager = keyClaimManager;
|
44
|
-
this.outgoingRequestManager = outgoingRequestManager;
|
45
|
-
this.room = room;
|
46
|
-
this.encryptionSettings = encryptionSettings;
|
47
|
-
_defineProperty(this, "prefixedLogger", void 0);
|
48
|
-
/** whether the room members have been loaded and tracked for the first time */
|
49
|
-
_defineProperty(this, "lazyLoadedMembersResolved", false);
|
50
|
-
/**
|
51
|
-
* Ensures that there is only one encryption operation at a time for that room.
|
52
|
-
*
|
53
|
-
* An encryption operation is either a {@link prepareForEncryption} or an {@link encryptEvent} call.
|
54
|
-
*/
|
55
|
-
_defineProperty(this, "currentEncryptionPromise", Promise.resolve());
|
56
|
-
this.prefixedLogger = logger.getChild("[".concat(room.roomId, " encryption]"));
|
57
|
-
|
58
|
-
// start tracking devices for any users already known to be in this room.
|
59
|
-
// Do not load members here, would defeat lazy loading.
|
60
|
-
var members = room.getJoinedMembers();
|
61
|
-
|
62
|
-
// At this point just mark the known members as tracked, it might not be the full list of members
|
63
|
-
// because of lazy loading. This is fine, because we will get a member list update when sending a message for
|
64
|
-
// the first time, see `RoomEncryptor#ensureEncryptionSession`
|
65
|
-
this.olmMachine.updateTrackedUsers(members.map(u => new RustSdkCryptoJs.UserId(u.userId))).catch(e => this.prefixedLogger.error("Error initializing tracked users", e));
|
66
|
-
}
|
67
|
-
|
68
|
-
/**
|
69
|
-
* Handle a new `m.room.encryption` event in this room
|
70
|
-
*
|
71
|
-
* @param config - The content of the encryption event
|
72
|
-
*/
|
73
|
-
onCryptoEvent(config) {
|
74
|
-
if (JSON.stringify(this.encryptionSettings) != JSON.stringify(config)) {
|
75
|
-
// This should currently be unreachable, since the Rust SDK will reject any attempts to change config.
|
76
|
-
throw new Error("Cannot reconfigure an active RoomEncryptor");
|
77
|
-
}
|
78
|
-
}
|
79
|
-
|
80
|
-
/**
|
81
|
-
* Handle a new `m.room.member` event in this room
|
82
|
-
*
|
83
|
-
* @param member - new membership state
|
84
|
-
*/
|
85
|
-
onRoomMembership(member) {
|
86
|
-
if (member.membership == KnownMembership.Join || member.membership == KnownMembership.Invite && this.room.shouldEncryptForInvitedMembers()) {
|
87
|
-
// make sure we are tracking the deviceList for this user
|
88
|
-
this.olmMachine.updateTrackedUsers([new UserId(member.userId)]).catch(e => {
|
89
|
-
this.prefixedLogger.error("Unable to update tracked users", e);
|
90
|
-
});
|
91
|
-
}
|
92
|
-
|
93
|
-
// TODO: handle leaves (including our own)
|
94
|
-
}
|
95
|
-
|
96
|
-
/**
|
97
|
-
* Prepare to encrypt events in this room.
|
98
|
-
*
|
99
|
-
* This ensures that we have a megolm session ready to use and that we have shared its key with all the devices
|
100
|
-
* in the room.
|
101
|
-
* @param globalBlacklistUnverifiedDevices - When `true`, and `deviceIsolationMode` is `AllDevicesIsolationMode`,
|
102
|
-
* will not send encrypted messages to unverified devices.
|
103
|
-
* Ignored when `deviceIsolationMode` is `OnlySignedDevicesIsolationMode`.
|
104
|
-
* @param deviceIsolationMode - The device isolation mode. See {@link DeviceIsolationMode}.
|
105
|
-
*/
|
106
|
-
prepareForEncryption(globalBlacklistUnverifiedDevices, deviceIsolationMode) {
|
107
|
-
var _this = this;
|
108
|
-
return _asyncToGenerator(function* () {
|
109
|
-
// We consider a prepareForEncryption as an encryption promise as it will potentially share keys
|
110
|
-
// even if it doesn't send an event.
|
111
|
-
// Usually this is called when the user starts typing, so we want to make sure we have keys ready when the
|
112
|
-
// message is finally sent.
|
113
|
-
// If `encryptEvent` is invoked before `prepareForEncryption` has completed, the `encryptEvent` call will wait for
|
114
|
-
// `prepareForEncryption` to complete before executing.
|
115
|
-
// The part where `encryptEvent` shares the room key will then usually be a no-op as it was already performed by `prepareForEncryption`.
|
116
|
-
yield _this.encryptEvent(null, globalBlacklistUnverifiedDevices, deviceIsolationMode);
|
117
|
-
})();
|
118
|
-
}
|
119
|
-
|
120
|
-
/**
|
121
|
-
* Encrypt an event for this room, or prepare for encryption.
|
122
|
-
*
|
123
|
-
* This will ensure that we have a megolm session for this room, share it with the devices in the room, and
|
124
|
-
* then, if an event is provided, encrypt it using the session.
|
125
|
-
*
|
126
|
-
* @param event - Event to be encrypted, or null if only preparing for encryption (in which case we will pre-share the room key).
|
127
|
-
* @param globalBlacklistUnverifiedDevices - When `true`, and `deviceIsolationMode` is `AllDevicesIsolationMode`,
|
128
|
-
* will not send encrypted messages to unverified devices.
|
129
|
-
* Ignored when `deviceIsolationMode` is `OnlySignedDevicesIsolationMode`.
|
130
|
-
* @param deviceIsolationMode - The device isolation mode. See {@link DeviceIsolationMode}.
|
131
|
-
*/
|
132
|
-
encryptEvent(event, globalBlacklistUnverifiedDevices, deviceIsolationMode) {
|
133
|
-
var _event$getTxnId,
|
134
|
-
_this2 = this;
|
135
|
-
var logger = new LogSpan(this.prefixedLogger, event ? (_event$getTxnId = event.getTxnId()) !== null && _event$getTxnId !== void 0 ? _event$getTxnId : "" : "prepareForEncryption");
|
136
|
-
// Ensure order of encryption to avoid message ordering issues, as the scheduler only ensures
|
137
|
-
// events order after they have been encrypted.
|
138
|
-
var prom = this.currentEncryptionPromise.catch(() => {
|
139
|
-
// Any errors in the previous call will have been reported already, so there is nothing to do here.
|
140
|
-
// we just throw away the error and start anew.
|
141
|
-
}).then(/*#__PURE__*/_asyncToGenerator(function* () {
|
142
|
-
yield logDuration(logger, "ensureEncryptionSession", /*#__PURE__*/_asyncToGenerator(function* () {
|
143
|
-
yield _this2.ensureEncryptionSession(logger, globalBlacklistUnverifiedDevices, deviceIsolationMode);
|
144
|
-
}));
|
145
|
-
if (event) {
|
146
|
-
yield logDuration(logger, "encryptEventInner", /*#__PURE__*/_asyncToGenerator(function* () {
|
147
|
-
yield _this2.encryptEventInner(logger, event);
|
148
|
-
}));
|
149
|
-
}
|
150
|
-
}));
|
151
|
-
this.currentEncryptionPromise = prom;
|
152
|
-
return prom;
|
153
|
-
}
|
154
|
-
|
155
|
-
/**
|
156
|
-
* Prepare to encrypt events in this room.
|
157
|
-
*
|
158
|
-
* This ensures that we have a megolm session ready to use and that we have shared its key with all the devices
|
159
|
-
* in the room.
|
160
|
-
*
|
161
|
-
* @param logger - a place to write diagnostics to
|
162
|
-
* @param globalBlacklistUnverifiedDevices - When `true`, and `deviceIsolationMode` is `AllDevicesIsolationMode`,
|
163
|
-
* will not send encrypted messages to unverified devices.
|
164
|
-
* Ignored when `deviceIsolationMode` is `OnlySignedDevicesIsolationMode`.
|
165
|
-
* @param deviceIsolationMode - The device isolation mode. See {@link DeviceIsolationMode}.
|
166
|
-
*/
|
167
|
-
ensureEncryptionSession(logger, globalBlacklistUnverifiedDevices, deviceIsolationMode) {
|
168
|
-
var _this3 = this;
|
169
|
-
return _asyncToGenerator(function* () {
|
170
|
-
if (_this3.encryptionSettings.algorithm !== "m.megolm.v1.aes-sha2") {
|
171
|
-
throw new Error("Cannot encrypt in ".concat(_this3.room.roomId, " for unsupported algorithm '").concat(_this3.encryptionSettings.algorithm, "'"));
|
172
|
-
}
|
173
|
-
logger.debug("Starting encryption");
|
174
|
-
var members = yield _this3.room.getEncryptionTargetMembers();
|
175
|
-
|
176
|
-
// If this is the first time we are sending a message to the room, we may not yet have seen all the members
|
177
|
-
// (so the Crypto SDK might not have a device list for them). So, if this is the first time we are encrypting
|
178
|
-
// for this room, give the SDK the full list of members, to be on the safe side.
|
179
|
-
//
|
180
|
-
// This could end up being racy (if two calls to ensureEncryptionSession happen at the same time), but that's
|
181
|
-
// not a particular problem, since `OlmMachine.updateTrackedUsers` just adds any users that weren't already tracked.
|
182
|
-
if (!_this3.lazyLoadedMembersResolved) {
|
183
|
-
yield logDuration(_this3.prefixedLogger, "loadMembersIfNeeded: updateTrackedUsers", /*#__PURE__*/_asyncToGenerator(function* () {
|
184
|
-
yield _this3.olmMachine.updateTrackedUsers(members.map(u => new RustSdkCryptoJs.UserId(u.userId)));
|
185
|
-
}));
|
186
|
-
logger.debug("Updated tracked users");
|
187
|
-
_this3.lazyLoadedMembersResolved = true;
|
188
|
-
|
189
|
-
// Query keys in case we don't have them for newly tracked members.
|
190
|
-
// It's important after loading members for the first time, as likely most of them won't be
|
191
|
-
// known yet and will be unable to decrypt messages despite being in the room for long.
|
192
|
-
// This must be done before ensuring sessions. If not the devices of these users are not
|
193
|
-
// known yet and will not get the room key.
|
194
|
-
// We don't have API to only get the keys queries related to this member list, so we just
|
195
|
-
// process the pending requests from the olmMachine. (usually these are processed
|
196
|
-
// at the end of the sync, but we can't wait for that).
|
197
|
-
// XXX future improvement process only KeysQueryRequests for the users that have never been queried.
|
198
|
-
logger.debug("Processing outgoing requests");
|
199
|
-
yield logDuration(_this3.prefixedLogger, "doProcessOutgoingRequests", /*#__PURE__*/_asyncToGenerator(function* () {
|
200
|
-
yield _this3.outgoingRequestManager.doProcessOutgoingRequests();
|
201
|
-
}));
|
202
|
-
} else {
|
203
|
-
// If members are already loaded it's less critical to await on key queries.
|
204
|
-
// We might still want to trigger a processOutgoingRequests here.
|
205
|
-
// The call to `ensureSessionsForUsers` below will wait a bit on in-flight key queries we are
|
206
|
-
// interested in. If a sync handling happens in the meantime, and some new members are added to the room
|
207
|
-
// or have new devices it would give us a chance to query them before sending.
|
208
|
-
// It's less critical due to the racy nature of this process.
|
209
|
-
logger.debug("Processing outgoing requests in background");
|
210
|
-
_this3.outgoingRequestManager.doProcessOutgoingRequests();
|
211
|
-
}
|
212
|
-
logger.debug("Encrypting for users (shouldEncryptForInvitedMembers: ".concat(_this3.room.shouldEncryptForInvitedMembers(), "):"), members.map(u => "".concat(u.userId, " (").concat(u.membership, ")")));
|
213
|
-
var userList = members.map(u => new UserId(u.userId));
|
214
|
-
yield logDuration(_this3.prefixedLogger, "ensureSessionsForUsers", /*#__PURE__*/_asyncToGenerator(function* () {
|
215
|
-
yield _this3.keyClaimManager.ensureSessionsForUsers(logger, userList);
|
216
|
-
}));
|
217
|
-
var rustEncryptionSettings = new EncryptionSettings();
|
218
|
-
rustEncryptionSettings.historyVisibility = toRustHistoryVisibility(_this3.room.getHistoryVisibility());
|
219
|
-
|
220
|
-
// We only support megolm
|
221
|
-
rustEncryptionSettings.algorithm = EncryptionAlgorithm.MegolmV1AesSha2;
|
222
|
-
|
223
|
-
// We need to convert the rotation period from milliseconds to microseconds
|
224
|
-
// See https://spec.matrix.org/v1.8/client-server-api/#mroomencryption and
|
225
|
-
// https://matrix-org.github.io/matrix-rust-sdk-crypto-wasm/classes/EncryptionSettings.html#rotationPeriod
|
226
|
-
if (typeof _this3.encryptionSettings.rotation_period_ms === "number") {
|
227
|
-
rustEncryptionSettings.rotationPeriod = BigInt(_this3.encryptionSettings.rotation_period_ms * 1000);
|
228
|
-
}
|
229
|
-
if (typeof _this3.encryptionSettings.rotation_period_msgs === "number") {
|
230
|
-
rustEncryptionSettings.rotationPeriodMessages = BigInt(_this3.encryptionSettings.rotation_period_msgs);
|
231
|
-
}
|
232
|
-
switch (deviceIsolationMode.kind) {
|
233
|
-
case DeviceIsolationModeKind.AllDevicesIsolationMode:
|
234
|
-
{
|
235
|
-
var _this3$room$getBlackl;
|
236
|
-
// When this.room.getBlacklistUnverifiedDevices() === null, the global settings should be used
|
237
|
-
// See Room#getBlacklistUnverifiedDevices
|
238
|
-
var onlyAllowTrustedDevices = (_this3$room$getBlackl = _this3.room.getBlacklistUnverifiedDevices()) !== null && _this3$room$getBlackl !== void 0 ? _this3$room$getBlackl : globalBlacklistUnverifiedDevices;
|
239
|
-
rustEncryptionSettings.sharingStrategy = CollectStrategy.deviceBasedStrategy(onlyAllowTrustedDevices, deviceIsolationMode.errorOnVerifiedUserProblems);
|
240
|
-
}
|
241
|
-
break;
|
242
|
-
case DeviceIsolationModeKind.OnlySignedDevicesIsolationMode:
|
243
|
-
rustEncryptionSettings.sharingStrategy = CollectStrategy.identityBasedStrategy();
|
244
|
-
break;
|
245
|
-
}
|
246
|
-
yield logDuration(_this3.prefixedLogger, "shareRoomKey", /*#__PURE__*/_asyncToGenerator(function* () {
|
247
|
-
var shareMessages = yield _this3.olmMachine.shareRoomKey(new RoomId(_this3.room.roomId),
|
248
|
-
// safe to pass without cloning, as it's not reused here (before or after)
|
249
|
-
userList, rustEncryptionSettings);
|
250
|
-
if (shareMessages) {
|
251
|
-
for (var m of shareMessages) {
|
252
|
-
yield _this3.outgoingRequestManager.outgoingRequestProcessor.makeOutgoingRequest(m);
|
253
|
-
}
|
254
|
-
}
|
255
|
-
}));
|
256
|
-
})();
|
257
|
-
}
|
258
|
-
|
259
|
-
/**
|
260
|
-
* Discard any existing group session for this room
|
261
|
-
*/
|
262
|
-
forceDiscardSession() {
|
263
|
-
var _this4 = this;
|
264
|
-
return _asyncToGenerator(function* () {
|
265
|
-
var r = yield _this4.olmMachine.invalidateGroupSession(new RoomId(_this4.room.roomId));
|
266
|
-
if (r) {
|
267
|
-
_this4.prefixedLogger.info("Discarded existing group session");
|
268
|
-
}
|
269
|
-
})();
|
270
|
-
}
|
271
|
-
encryptEventInner(logger, event) {
|
272
|
-
var _this5 = this;
|
273
|
-
return _asyncToGenerator(function* () {
|
274
|
-
logger.debug("Encrypting actual message content");
|
275
|
-
var encryptedContent = yield _this5.olmMachine.encryptRoomEvent(new RoomId(_this5.room.roomId), event.getType(), JSON.stringify(event.getContent()));
|
276
|
-
event.makeEncrypted(EventType.RoomMessageEncrypted, JSON.parse(encryptedContent), _this5.olmMachine.identityKeys.curve25519.toBase64(), _this5.olmMachine.identityKeys.ed25519.toBase64());
|
277
|
-
logger.debug("Encrypted event successfully");
|
278
|
-
})();
|
279
|
-
}
|
280
|
-
}
|
281
|
-
|
282
|
-
/**
|
283
|
-
* Convert a HistoryVisibility to a RustHistoryVisibility
|
284
|
-
* @param visibility - HistoryVisibility enum
|
285
|
-
* @returns a RustHistoryVisibility enum
|
286
|
-
*/
|
287
|
-
export function toRustHistoryVisibility(visibility) {
|
288
|
-
switch (visibility) {
|
289
|
-
case HistoryVisibility.Invited:
|
290
|
-
return RustHistoryVisibility.Invited;
|
291
|
-
case HistoryVisibility.Joined:
|
292
|
-
return RustHistoryVisibility.Joined;
|
293
|
-
case HistoryVisibility.Shared:
|
294
|
-
return RustHistoryVisibility.Shared;
|
295
|
-
case HistoryVisibility.WorldReadable:
|
296
|
-
return RustHistoryVisibility.WorldReadable;
|
297
|
-
}
|
298
|
-
}
|
299
|
-
//# sourceMappingURL=RoomEncryptor.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"RoomEncryptor.js","names":["RustSdkCryptoJs","CollectStrategy","EncryptionAlgorithm","EncryptionSettings","HistoryVisibility","RustHistoryVisibility","RoomId","UserId","EventType","logger","LogSpan","logDuration","KnownMembership","DeviceIsolationModeKind","RoomEncryptor","constructor","olmMachine","keyClaimManager","outgoingRequestManager","room","encryptionSettings","_defineProperty","Promise","resolve","prefixedLogger","getChild","concat","roomId","members","getJoinedMembers","updateTrackedUsers","map","u","userId","catch","e","error","onCryptoEvent","config","JSON","stringify","Error","onRoomMembership","member","membership","Join","Invite","shouldEncryptForInvitedMembers","prepareForEncryption","globalBlacklistUnverifiedDevices","deviceIsolationMode","_this","_asyncToGenerator","encryptEvent","event","_event$getTxnId","_this2","getTxnId","prom","currentEncryptionPromise","then","ensureEncryptionSession","encryptEventInner","_this3","algorithm","debug","getEncryptionTargetMembers","lazyLoadedMembersResolved","doProcessOutgoingRequests","userList","ensureSessionsForUsers","rustEncryptionSettings","historyVisibility","toRustHistoryVisibility","getHistoryVisibility","MegolmV1AesSha2","rotation_period_ms","rotationPeriod","BigInt","rotation_period_msgs","rotationPeriodMessages","kind","AllDevicesIsolationMode","_this3$room$getBlackl","onlyAllowTrustedDevices","getBlacklistUnverifiedDevices","sharingStrategy","deviceBasedStrategy","errorOnVerifiedUserProblems","OnlySignedDevicesIsolationMode","identityBasedStrategy","shareMessages","shareRoomKey","m","outgoingRequestProcessor","makeOutgoingRequest","forceDiscardSession","_this4","r","invalidateGroupSession","info","_this5","encryptedContent","encryptRoomEvent","getType","getContent","makeEncrypted","RoomMessageEncrypted","parse","identityKeys","curve25519","toBase64","ed25519","visibility","Invited","Joined","Shared","WorldReadable"],"sources":["../../src/rust-crypto/RoomEncryptor.ts"],"sourcesContent":["/*\nCopyright 2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport * as RustSdkCryptoJs from \"@matrix-org/matrix-sdk-crypto-wasm\";\nimport {\n CollectStrategy,\n EncryptionAlgorithm,\n EncryptionSettings,\n HistoryVisibility as RustHistoryVisibility,\n OlmMachine,\n RoomId,\n ToDeviceRequest,\n UserId,\n} from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport { EventType } from \"../@types/event.ts\";\nimport { IContent, MatrixEvent } from \"../models/event.ts\";\nimport { Room } from \"../models/room.ts\";\nimport { Logger, logger, LogSpan } from \"../logger.ts\";\nimport { KeyClaimManager } from \"./KeyClaimManager.ts\";\nimport { RoomMember } from \"../models/room-member.ts\";\nimport { HistoryVisibility } from \"../@types/partials.ts\";\nimport { OutgoingRequestsManager } from \"./OutgoingRequestsManager.ts\";\nimport { logDuration } from \"../utils.ts\";\nimport { KnownMembership } from \"../@types/membership.ts\";\nimport { DeviceIsolationMode, DeviceIsolationModeKind } from \"../crypto-api/index.ts\";\n\n/**\n * RoomEncryptor: responsible for encrypting messages to a given room\n *\n * @internal\n */\nexport class RoomEncryptor {\n private readonly prefixedLogger: Logger;\n\n /** whether the room members have been loaded and tracked for the first time */\n private lazyLoadedMembersResolved = false;\n\n /**\n * Ensures that there is only one encryption operation at a time for that room.\n *\n * An encryption operation is either a {@link prepareForEncryption} or an {@link encryptEvent} call.\n */\n private currentEncryptionPromise: Promise<void> = Promise.resolve();\n\n /**\n * @param olmMachine - The rust-sdk's OlmMachine\n * @param keyClaimManager - Our KeyClaimManager, which manages the queue of one-time-key claim requests\n * @param outgoingRequestManager - The OutgoingRequestManager, which manages the queue of outgoing requests.\n * @param room - The room we want to encrypt for\n * @param encryptionSettings - body of the m.room.encryption event currently in force in this room\n */\n public constructor(\n private readonly olmMachine: OlmMachine,\n private readonly keyClaimManager: KeyClaimManager,\n private readonly outgoingRequestManager: OutgoingRequestsManager,\n private readonly room: Room,\n private encryptionSettings: IContent,\n ) {\n this.prefixedLogger = logger.getChild(`[${room.roomId} encryption]`);\n\n // start tracking devices for any users already known to be in this room.\n // Do not load members here, would defeat lazy loading.\n const members = room.getJoinedMembers();\n\n // At this point just mark the known members as tracked, it might not be the full list of members\n // because of lazy loading. This is fine, because we will get a member list update when sending a message for\n // the first time, see `RoomEncryptor#ensureEncryptionSession`\n this.olmMachine\n .updateTrackedUsers(members.map((u) => new RustSdkCryptoJs.UserId(u.userId)))\n .catch((e) => this.prefixedLogger.error(\"Error initializing tracked users\", e));\n }\n\n /**\n * Handle a new `m.room.encryption` event in this room\n *\n * @param config - The content of the encryption event\n */\n public onCryptoEvent(config: IContent): void {\n if (JSON.stringify(this.encryptionSettings) != JSON.stringify(config)) {\n // This should currently be unreachable, since the Rust SDK will reject any attempts to change config.\n throw new Error(\"Cannot reconfigure an active RoomEncryptor\");\n }\n }\n\n /**\n * Handle a new `m.room.member` event in this room\n *\n * @param member - new membership state\n */\n public onRoomMembership(member: RoomMember): void {\n if (\n member.membership == KnownMembership.Join ||\n (member.membership == KnownMembership.Invite && this.room.shouldEncryptForInvitedMembers())\n ) {\n // make sure we are tracking the deviceList for this user\n this.olmMachine.updateTrackedUsers([new UserId(member.userId)]).catch((e) => {\n this.prefixedLogger.error(\"Unable to update tracked users\", e);\n });\n }\n\n // TODO: handle leaves (including our own)\n }\n\n /**\n * Prepare to encrypt events in this room.\n *\n * This ensures that we have a megolm session ready to use and that we have shared its key with all the devices\n * in the room.\n * @param globalBlacklistUnverifiedDevices - When `true`, and `deviceIsolationMode` is `AllDevicesIsolationMode`,\n * will not send encrypted messages to unverified devices.\n * Ignored when `deviceIsolationMode` is `OnlySignedDevicesIsolationMode`.\n * @param deviceIsolationMode - The device isolation mode. See {@link DeviceIsolationMode}.\n */\n public async prepareForEncryption(\n globalBlacklistUnverifiedDevices: boolean,\n deviceIsolationMode: DeviceIsolationMode,\n ): Promise<void> {\n // We consider a prepareForEncryption as an encryption promise as it will potentially share keys\n // even if it doesn't send an event.\n // Usually this is called when the user starts typing, so we want to make sure we have keys ready when the\n // message is finally sent.\n // If `encryptEvent` is invoked before `prepareForEncryption` has completed, the `encryptEvent` call will wait for\n // `prepareForEncryption` to complete before executing.\n // The part where `encryptEvent` shares the room key will then usually be a no-op as it was already performed by `prepareForEncryption`.\n await this.encryptEvent(null, globalBlacklistUnverifiedDevices, deviceIsolationMode);\n }\n\n /**\n * Encrypt an event for this room, or prepare for encryption.\n *\n * This will ensure that we have a megolm session for this room, share it with the devices in the room, and\n * then, if an event is provided, encrypt it using the session.\n *\n * @param event - Event to be encrypted, or null if only preparing for encryption (in which case we will pre-share the room key).\n * @param globalBlacklistUnverifiedDevices - When `true`, and `deviceIsolationMode` is `AllDevicesIsolationMode`,\n * will not send encrypted messages to unverified devices.\n * Ignored when `deviceIsolationMode` is `OnlySignedDevicesIsolationMode`.\n * @param deviceIsolationMode - The device isolation mode. See {@link DeviceIsolationMode}.\n */\n public encryptEvent(\n event: MatrixEvent | null,\n globalBlacklistUnverifiedDevices: boolean,\n deviceIsolationMode: DeviceIsolationMode,\n ): Promise<void> {\n const logger = new LogSpan(this.prefixedLogger, event ? (event.getTxnId() ?? \"\") : \"prepareForEncryption\");\n // Ensure order of encryption to avoid message ordering issues, as the scheduler only ensures\n // events order after they have been encrypted.\n const prom = this.currentEncryptionPromise\n .catch(() => {\n // Any errors in the previous call will have been reported already, so there is nothing to do here.\n // we just throw away the error and start anew.\n })\n .then(async () => {\n await logDuration(logger, \"ensureEncryptionSession\", async () => {\n await this.ensureEncryptionSession(logger, globalBlacklistUnverifiedDevices, deviceIsolationMode);\n });\n if (event) {\n await logDuration(logger, \"encryptEventInner\", async () => {\n await this.encryptEventInner(logger, event);\n });\n }\n });\n\n this.currentEncryptionPromise = prom;\n return prom;\n }\n\n /**\n * Prepare to encrypt events in this room.\n *\n * This ensures that we have a megolm session ready to use and that we have shared its key with all the devices\n * in the room.\n *\n * @param logger - a place to write diagnostics to\n * @param globalBlacklistUnverifiedDevices - When `true`, and `deviceIsolationMode` is `AllDevicesIsolationMode`,\n * will not send encrypted messages to unverified devices.\n * Ignored when `deviceIsolationMode` is `OnlySignedDevicesIsolationMode`.\n * @param deviceIsolationMode - The device isolation mode. See {@link DeviceIsolationMode}.\n */\n private async ensureEncryptionSession(\n logger: LogSpan,\n globalBlacklistUnverifiedDevices: boolean,\n deviceIsolationMode: DeviceIsolationMode,\n ): Promise<void> {\n if (this.encryptionSettings.algorithm !== \"m.megolm.v1.aes-sha2\") {\n throw new Error(\n `Cannot encrypt in ${this.room.roomId} for unsupported algorithm '${this.encryptionSettings.algorithm}'`,\n );\n }\n logger.debug(\"Starting encryption\");\n\n const members = await this.room.getEncryptionTargetMembers();\n\n // If this is the first time we are sending a message to the room, we may not yet have seen all the members\n // (so the Crypto SDK might not have a device list for them). So, if this is the first time we are encrypting\n // for this room, give the SDK the full list of members, to be on the safe side.\n //\n // This could end up being racy (if two calls to ensureEncryptionSession happen at the same time), but that's\n // not a particular problem, since `OlmMachine.updateTrackedUsers` just adds any users that weren't already tracked.\n if (!this.lazyLoadedMembersResolved) {\n await logDuration(this.prefixedLogger, \"loadMembersIfNeeded: updateTrackedUsers\", async () => {\n await this.olmMachine.updateTrackedUsers(members.map((u) => new RustSdkCryptoJs.UserId(u.userId)));\n });\n logger.debug(`Updated tracked users`);\n this.lazyLoadedMembersResolved = true;\n\n // Query keys in case we don't have them for newly tracked members.\n // It's important after loading members for the first time, as likely most of them won't be\n // known yet and will be unable to decrypt messages despite being in the room for long.\n // This must be done before ensuring sessions. If not the devices of these users are not\n // known yet and will not get the room key.\n // We don't have API to only get the keys queries related to this member list, so we just\n // process the pending requests from the olmMachine. (usually these are processed\n // at the end of the sync, but we can't wait for that).\n // XXX future improvement process only KeysQueryRequests for the users that have never been queried.\n logger.debug(`Processing outgoing requests`);\n\n await logDuration(this.prefixedLogger, \"doProcessOutgoingRequests\", async () => {\n await this.outgoingRequestManager.doProcessOutgoingRequests();\n });\n } else {\n // If members are already loaded it's less critical to await on key queries.\n // We might still want to trigger a processOutgoingRequests here.\n // The call to `ensureSessionsForUsers` below will wait a bit on in-flight key queries we are\n // interested in. If a sync handling happens in the meantime, and some new members are added to the room\n // or have new devices it would give us a chance to query them before sending.\n // It's less critical due to the racy nature of this process.\n logger.debug(`Processing outgoing requests in background`);\n this.outgoingRequestManager.doProcessOutgoingRequests();\n }\n\n logger.debug(\n `Encrypting for users (shouldEncryptForInvitedMembers: ${this.room.shouldEncryptForInvitedMembers()}):`,\n members.map((u) => `${u.userId} (${u.membership})`),\n );\n\n const userList = members.map((u) => new UserId(u.userId));\n\n await logDuration(this.prefixedLogger, \"ensureSessionsForUsers\", async () => {\n await this.keyClaimManager.ensureSessionsForUsers(logger, userList);\n });\n\n const rustEncryptionSettings = new EncryptionSettings();\n rustEncryptionSettings.historyVisibility = toRustHistoryVisibility(this.room.getHistoryVisibility());\n\n // We only support megolm\n rustEncryptionSettings.algorithm = EncryptionAlgorithm.MegolmV1AesSha2;\n\n // We need to convert the rotation period from milliseconds to microseconds\n // See https://spec.matrix.org/v1.8/client-server-api/#mroomencryption and\n // https://matrix-org.github.io/matrix-rust-sdk-crypto-wasm/classes/EncryptionSettings.html#rotationPeriod\n if (typeof this.encryptionSettings.rotation_period_ms === \"number\") {\n rustEncryptionSettings.rotationPeriod = BigInt(this.encryptionSettings.rotation_period_ms * 1000);\n }\n\n if (typeof this.encryptionSettings.rotation_period_msgs === \"number\") {\n rustEncryptionSettings.rotationPeriodMessages = BigInt(this.encryptionSettings.rotation_period_msgs);\n }\n\n switch (deviceIsolationMode.kind) {\n case DeviceIsolationModeKind.AllDevicesIsolationMode:\n {\n // When this.room.getBlacklistUnverifiedDevices() === null, the global settings should be used\n // See Room#getBlacklistUnverifiedDevices\n const onlyAllowTrustedDevices =\n this.room.getBlacklistUnverifiedDevices() ?? globalBlacklistUnverifiedDevices;\n rustEncryptionSettings.sharingStrategy = CollectStrategy.deviceBasedStrategy(\n onlyAllowTrustedDevices,\n deviceIsolationMode.errorOnVerifiedUserProblems,\n );\n }\n break;\n case DeviceIsolationModeKind.OnlySignedDevicesIsolationMode:\n rustEncryptionSettings.sharingStrategy = CollectStrategy.identityBasedStrategy();\n break;\n }\n\n await logDuration(this.prefixedLogger, \"shareRoomKey\", async () => {\n const shareMessages: ToDeviceRequest[] = await this.olmMachine.shareRoomKey(\n new RoomId(this.room.roomId),\n // safe to pass without cloning, as it's not reused here (before or after)\n userList,\n rustEncryptionSettings,\n );\n if (shareMessages) {\n for (const m of shareMessages) {\n await this.outgoingRequestManager.outgoingRequestProcessor.makeOutgoingRequest(m);\n }\n }\n });\n }\n\n /**\n * Discard any existing group session for this room\n */\n public async forceDiscardSession(): Promise<void> {\n const r = await this.olmMachine.invalidateGroupSession(new RoomId(this.room.roomId));\n if (r) {\n this.prefixedLogger.info(\"Discarded existing group session\");\n }\n }\n\n private async encryptEventInner(logger: LogSpan, event: MatrixEvent): Promise<void> {\n logger.debug(\"Encrypting actual message content\");\n const encryptedContent = await this.olmMachine.encryptRoomEvent(\n new RoomId(this.room.roomId),\n event.getType(),\n JSON.stringify(event.getContent()),\n );\n\n event.makeEncrypted(\n EventType.RoomMessageEncrypted,\n JSON.parse(encryptedContent),\n this.olmMachine.identityKeys.curve25519.toBase64(),\n this.olmMachine.identityKeys.ed25519.toBase64(),\n );\n\n logger.debug(\"Encrypted event successfully\");\n }\n}\n\n/**\n * Convert a HistoryVisibility to a RustHistoryVisibility\n * @param visibility - HistoryVisibility enum\n * @returns a RustHistoryVisibility enum\n */\nexport function toRustHistoryVisibility(visibility: HistoryVisibility): RustHistoryVisibility {\n switch (visibility) {\n case HistoryVisibility.Invited:\n return RustHistoryVisibility.Invited;\n case HistoryVisibility.Joined:\n return RustHistoryVisibility.Joined;\n case HistoryVisibility.Shared:\n return RustHistoryVisibility.Shared;\n case HistoryVisibility.WorldReadable:\n return RustHistoryVisibility.WorldReadable;\n }\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,eAAe,MAAM,oCAAoC;AACrE,SACIC,eAAe,EACfC,mBAAmB,EACnBC,kBAAkB,EAClBC,iBAAiB,IAAIC,qBAAqB,EAE1CC,MAAM,EAENC,MAAM,QACH,oCAAoC;AAE3C,SAASC,SAAS,QAAQ,oBAAoB;AAG9C,SAAiBC,MAAM,EAAEC,OAAO,QAAQ,cAAc;AAGtD,SAASN,iBAAiB,QAAQ,uBAAuB;AAEzD,SAASO,WAAW,QAAQ,aAAa;AACzC,SAASC,eAAe,QAAQ,yBAAyB;AACzD,SAA8BC,uBAAuB,QAAQ,wBAAwB;;AAErF;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,aAAa,CAAC;EAavB;AACJ;AACA;AACA;AACA;AACA;AACA;EACWC,WAAWA,CACGC,UAAsB,EACtBC,eAAgC,EAChCC,sBAA+C,EAC/CC,IAAU,EACnBC,kBAA4B,EACtC;IAAA,KALmBJ,UAA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IACxC,KAAK9G,iBAAiB,CAAC+G,MAAM;MACzB,OAAO9G,qBAAqB,CAAC8G,MAAM;IACvC,KAAK/G,iBAAiB,CAACgH,MAAM;MACzB,OAAO/G,qBAAqB,CAAC+G,MAAM;IACvC,KAAKhH,iBAAiB,CAACiH,aAAa;MAChC,OAAOhH,qBAAqB,CAACgH,aAAa;EAClD;AACJ","ignoreList":[]}
|
@@ -1,254 +0,0 @@
|
|
1
|
-
import { OlmMachine } from "@matrix-org/matrix-sdk-crypto-wasm";
|
2
|
-
import * as RustSdkCryptoJs from "@matrix-org/matrix-sdk-crypto-wasm";
|
3
|
-
import { BackupTrustInfo, KeyBackupCheck, KeyBackupInfo, KeyBackupSession, Curve25519SessionData, KeyBackupRestoreOpts, KeyBackupRestoreResult, KeyBackupRoomSessions } from "../crypto-api/keybackup.ts";
|
4
|
-
import { IHttpOpts, MatrixHttpApi } from "../http-api/index.ts";
|
5
|
-
import { IMegolmSessionData } from "../crypto/index.ts";
|
6
|
-
import { TypedEventEmitter } from "../models/typed-event-emitter.ts";
|
7
|
-
import { OutgoingRequestProcessor } from "./OutgoingRequestProcessor.ts";
|
8
|
-
import { BackupDecryptor } from "../common-crypto/CryptoBackend.ts";
|
9
|
-
import { ImportRoomKeysOpts, CryptoEvent } from "../crypto-api/index.ts";
|
10
|
-
import { AESEncryptedSecretStoragePayload } from "../@types/AESEncryptedSecretStoragePayload.ts";
|
11
|
-
/** Authentification of the backup info, depends on algorithm */
|
12
|
-
type AuthData = KeyBackupInfo["auth_data"];
|
13
|
-
/**
|
14
|
-
* Holds information of a created keybackup.
|
15
|
-
* Useful to get the generated private key material and save it securely somewhere.
|
16
|
-
*/
|
17
|
-
interface KeyBackupCreationInfo {
|
18
|
-
version: string;
|
19
|
-
algorithm: string;
|
20
|
-
authData: AuthData;
|
21
|
-
decryptionKey: RustSdkCryptoJs.BackupDecryptionKey;
|
22
|
-
}
|
23
|
-
/**
|
24
|
-
* @internal
|
25
|
-
*/
|
26
|
-
export declare class RustBackupManager extends TypedEventEmitter<RustBackupCryptoEvents, RustBackupCryptoEventMap> {
|
27
|
-
private readonly olmMachine;
|
28
|
-
private readonly http;
|
29
|
-
private readonly outgoingRequestProcessor;
|
30
|
-
/** Have we checked if there is a backup on the server which we can use */
|
31
|
-
private checkedForBackup;
|
32
|
-
/**
|
33
|
-
* The latest backup version on the server, when we last checked.
|
34
|
-
*
|
35
|
-
* If there was no backup on the server, `null`. If our attempt to check resulted in an error, `undefined`.
|
36
|
-
*
|
37
|
-
* Note that the backup was not necessarily verified.
|
38
|
-
*/
|
39
|
-
private serverBackupInfo;
|
40
|
-
private activeBackupVersion;
|
41
|
-
private stopped;
|
42
|
-
/** whether {@link backupKeysLoop} is currently running */
|
43
|
-
private backupKeysLoopRunning;
|
44
|
-
constructor(olmMachine: OlmMachine, http: MatrixHttpApi<IHttpOpts & {
|
45
|
-
onlyData: true;
|
46
|
-
}>, outgoingRequestProcessor: OutgoingRequestProcessor);
|
47
|
-
/**
|
48
|
-
* Tells the RustBackupManager to stop.
|
49
|
-
* The RustBackupManager is scheduling background uploads of keys to the backup, this
|
50
|
-
* call allows to cancel the process when the client is stoppped.
|
51
|
-
*/
|
52
|
-
stop(): void;
|
53
|
-
/**
|
54
|
-
* Get the backup version we are currently backing up to, if any
|
55
|
-
*/
|
56
|
-
getActiveBackupVersion(): Promise<string | null>;
|
57
|
-
/**
|
58
|
-
* Return the details of the latest backup on the server, when we last checked.
|
59
|
-
*
|
60
|
-
* This normally returns a cached value, but if we haven't yet made a request to the server, it will fire one off.
|
61
|
-
* It will always return the details of the active backup if key backup is enabled.
|
62
|
-
*
|
63
|
-
* If there was no backup on the server, `null`. If our attempt to check resulted in an error, `undefined`.
|
64
|
-
*/
|
65
|
-
getServerBackupInfo(): Promise<KeyBackupInfo | null | undefined>;
|
66
|
-
/**
|
67
|
-
* Determine if a key backup can be trusted.
|
68
|
-
*
|
69
|
-
* @param info - key backup info dict from {@link MatrixClient#getKeyBackupVersion}.
|
70
|
-
*/
|
71
|
-
isKeyBackupTrusted(info: KeyBackupInfo): Promise<BackupTrustInfo>;
|
72
|
-
/**
|
73
|
-
* Re-check the key backup and enable/disable it as appropriate.
|
74
|
-
*
|
75
|
-
* @param force - whether we should force a re-check even if one has already happened.
|
76
|
-
*/
|
77
|
-
checkKeyBackupAndEnable(force: boolean): Promise<KeyBackupCheck | null>;
|
78
|
-
/**
|
79
|
-
* Handles a backup secret received event and store it if it matches the current backup version.
|
80
|
-
*
|
81
|
-
* @param secret - The secret as received from a `m.secret.send` event for secret `m.megolm_backup.v1`.
|
82
|
-
* @returns true if the secret is valid and has been stored, false otherwise.
|
83
|
-
*/
|
84
|
-
handleBackupSecretReceived(secret: string): Promise<boolean>;
|
85
|
-
saveBackupDecryptionKey(backupDecryptionKey: RustSdkCryptoJs.BackupDecryptionKey, version: string): Promise<void>;
|
86
|
-
/**
|
87
|
-
* Import a list of room keys previously exported by exportRoomKeys
|
88
|
-
*
|
89
|
-
* @param keys - a list of session export objects
|
90
|
-
* @param opts - options object
|
91
|
-
* @returns a promise which resolves once the keys have been imported
|
92
|
-
*/
|
93
|
-
importRoomKeys(keys: IMegolmSessionData[], opts?: ImportRoomKeysOpts): Promise<void>;
|
94
|
-
/**
|
95
|
-
* Import a list of room keys previously exported by exportRoomKeysAsJson
|
96
|
-
*
|
97
|
-
* @param jsonKeys - a JSON string encoding a list of session export objects,
|
98
|
-
* each of which is an IMegolmSessionData
|
99
|
-
* @param opts - options object
|
100
|
-
* @returns a promise which resolves once the keys have been imported
|
101
|
-
*/
|
102
|
-
importRoomKeysAsJson(jsonKeys: string, opts?: ImportRoomKeysOpts): Promise<void>;
|
103
|
-
/**
|
104
|
-
* Implementation of {@link CryptoBackend#importBackedUpRoomKeys}.
|
105
|
-
*/
|
106
|
-
importBackedUpRoomKeys(keys: IMegolmSessionData[], backupVersion: string, opts?: ImportRoomKeysOpts): Promise<void>;
|
107
|
-
private keyBackupCheckInProgress;
|
108
|
-
/** Helper for `checkKeyBackup` */
|
109
|
-
private doCheckKeyBackup;
|
110
|
-
private enableKeyBackup;
|
111
|
-
/**
|
112
|
-
* Restart the backup key loop if there is an active trusted backup.
|
113
|
-
* Doesn't try to check the backup server side. To be called when a new
|
114
|
-
* megolm key is known locally.
|
115
|
-
*/
|
116
|
-
maybeUploadKey(): Promise<void>;
|
117
|
-
private disableKeyBackup;
|
118
|
-
private backupKeysLoop;
|
119
|
-
/**
|
120
|
-
* Utility method to count the number of keys in a backup request, in order to update the remaining keys count.
|
121
|
-
* This should be the chunk size of the backup request for all requests but the last, but we don't have access to it
|
122
|
-
* (it's static in the Rust SDK).
|
123
|
-
* @param batch - The backup request to count the keys from.
|
124
|
-
*
|
125
|
-
* @returns The number of keys in the backup request.
|
126
|
-
*/
|
127
|
-
private keysCountInBatch;
|
128
|
-
/**
|
129
|
-
* Get information about a key backup from the server
|
130
|
-
* - If version is provided, get information about that backup version.
|
131
|
-
* - If no version is provided, get information about the latest backup.
|
132
|
-
*
|
133
|
-
* @param version - The version of the backup to get information about.
|
134
|
-
* @returns Information object from API or null if there is no active backup.
|
135
|
-
*/
|
136
|
-
requestKeyBackupVersion(version?: string): Promise<KeyBackupInfo | null>;
|
137
|
-
/**
|
138
|
-
* Creates a new key backup by generating a new random private key.
|
139
|
-
*
|
140
|
-
* If there is an existing backup server side it will be deleted and replaced
|
141
|
-
* by the new one.
|
142
|
-
*
|
143
|
-
* @param signObject - Method that should sign the backup with existing device and
|
144
|
-
* existing identity.
|
145
|
-
* @returns a KeyBackupCreationInfo - All information related to the backup.
|
146
|
-
*/
|
147
|
-
setupKeyBackup(signObject: (authData: AuthData) => Promise<void>): Promise<KeyBackupCreationInfo>;
|
148
|
-
/**
|
149
|
-
* Deletes all key backups.
|
150
|
-
*
|
151
|
-
* Will call the API to delete active backup until there is no more present.
|
152
|
-
*/
|
153
|
-
deleteAllKeyBackupVersions(): Promise<void>;
|
154
|
-
/**
|
155
|
-
* Deletes the given key backup.
|
156
|
-
*
|
157
|
-
* @param version - The backup version to delete.
|
158
|
-
*/
|
159
|
-
deleteKeyBackupVersion(version: string): Promise<void>;
|
160
|
-
/**
|
161
|
-
* Creates a new backup decryptor for the given private key.
|
162
|
-
* @param decryptionKey - The private key to use for decryption.
|
163
|
-
*/
|
164
|
-
createBackupDecryptor(decryptionKey: RustSdkCryptoJs.BackupDecryptionKey): BackupDecryptor;
|
165
|
-
/**
|
166
|
-
* Restore a key backup.
|
167
|
-
*
|
168
|
-
* @param backupVersion - The version of the backup to restore.
|
169
|
-
* @param backupDecryptor - The backup decryptor to use to decrypt the keys.
|
170
|
-
* @param opts - Options for the restore.
|
171
|
-
* @returns The total number of keys and the total imported.
|
172
|
-
*/
|
173
|
-
restoreKeyBackup(backupVersion: string, backupDecryptor: BackupDecryptor, opts?: KeyBackupRestoreOpts): Promise<KeyBackupRestoreResult>;
|
174
|
-
/**
|
175
|
-
* Call `/room_keys/keys` to download the key backup (room keys) for the given backup version.
|
176
|
-
* https://spec.matrix.org/v1.12/client-server-api/#get_matrixclientv3room_keyskeys
|
177
|
-
*
|
178
|
-
* @param backupVersion
|
179
|
-
* @returns The key backup response.
|
180
|
-
*/
|
181
|
-
private downloadKeyBackup;
|
182
|
-
/**
|
183
|
-
* Import the room keys from a `/room_keys/keys` call.
|
184
|
-
* Calls `opts.progressCallback` with the progress of the import.
|
185
|
-
*
|
186
|
-
* @param keyBackup - The response from the server containing the keys to import.
|
187
|
-
* @param backupVersion - The version of the backup info.
|
188
|
-
* @param backupDecryptor - The backup decryptor to use to decrypt the keys.
|
189
|
-
* @param opts - Options for the import.
|
190
|
-
*
|
191
|
-
* @returns The total number of keys and the total imported.
|
192
|
-
*
|
193
|
-
* @private
|
194
|
-
*/
|
195
|
-
private importKeyBackup;
|
196
|
-
}
|
197
|
-
/**
|
198
|
-
* Implementation of {@link BackupDecryptor} for the rust crypto backend.
|
199
|
-
*/
|
200
|
-
export declare class RustBackupDecryptor implements BackupDecryptor {
|
201
|
-
private decryptionKey;
|
202
|
-
sourceTrusted: boolean;
|
203
|
-
constructor(decryptionKey: RustSdkCryptoJs.BackupDecryptionKey);
|
204
|
-
/**
|
205
|
-
* Implements {@link BackupDecryptor#decryptSessions}
|
206
|
-
*/
|
207
|
-
decryptSessions(ciphertexts: Record<string, KeyBackupSession<Curve25519SessionData | AESEncryptedSecretStoragePayload>>): Promise<IMegolmSessionData[]>;
|
208
|
-
/**
|
209
|
-
* Implements {@link BackupDecryptor#free}
|
210
|
-
*/
|
211
|
-
free(): void;
|
212
|
-
}
|
213
|
-
/**
|
214
|
-
* Fetch a key backup info from the server.
|
215
|
-
*
|
216
|
-
* If `version` is provided, calls `GET /room_keys/version/$version` and gets the backup info for that version.
|
217
|
-
* See https://spec.matrix.org/v1.12/client-server-api/#get_matrixclientv3room_keysversionversion.
|
218
|
-
*
|
219
|
-
* If not, calls `GET /room_keys/version` and gets the latest backup info.
|
220
|
-
* See https://spec.matrix.org/v1.12/client-server-api/#get_matrixclientv3room_keysversion
|
221
|
-
*
|
222
|
-
* @param http
|
223
|
-
* @param version - the specific version of the backup info to fetch
|
224
|
-
* @returns The key backup info or null if there is no backup.
|
225
|
-
*/
|
226
|
-
export declare function requestKeyBackupVersion(http: MatrixHttpApi<IHttpOpts & {
|
227
|
-
onlyData: true;
|
228
|
-
}>, version?: string): Promise<KeyBackupInfo | null>;
|
229
|
-
/**
|
230
|
-
* Checks if the provided decryption key matches the public key of the key backup info.
|
231
|
-
*
|
232
|
-
* @param decryptionKey - The decryption key to check.
|
233
|
-
* @param keyBackupInfo - The key backup info to check against.
|
234
|
-
* @returns `true` if the decryption key matches the key backup info, `false` otherwise.
|
235
|
-
*/
|
236
|
-
export declare function decryptionKeyMatchesKeyBackupInfo(decryptionKey: RustSdkCryptoJs.BackupDecryptionKey, keyBackupInfo: KeyBackupInfo): boolean;
|
237
|
-
export type RustBackupCryptoEvents = CryptoEvent.KeyBackupStatus | CryptoEvent.KeyBackupSessionsRemaining | CryptoEvent.KeyBackupFailed | CryptoEvent.KeyBackupDecryptionKeyCached;
|
238
|
-
export type RustBackupCryptoEventMap = {
|
239
|
-
[CryptoEvent.KeyBackupStatus]: (enabled: boolean) => void;
|
240
|
-
[CryptoEvent.KeyBackupSessionsRemaining]: (remaining: number) => void;
|
241
|
-
[CryptoEvent.KeyBackupFailed]: (errCode: string) => void;
|
242
|
-
[CryptoEvent.KeyBackupDecryptionKeyCached]: (version: string) => void;
|
243
|
-
};
|
244
|
-
/**
|
245
|
-
* Response from GET `/room_keys/keys` endpoint.
|
246
|
-
* See https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3room_keyskeys
|
247
|
-
*/
|
248
|
-
export interface KeyBackup {
|
249
|
-
rooms: Record<string, {
|
250
|
-
sessions: KeyBackupRoomSessions;
|
251
|
-
}>;
|
252
|
-
}
|
253
|
-
export {};
|
254
|
-
//# sourceMappingURL=backup.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"backup.d.ts","sourceRoot":"","sources":["../../src/rust-crypto/backup.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,UAAU,EAAyB,MAAM,oCAAoC,CAAC;AACvF,OAAO,KAAK,eAAe,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EACH,eAAe,EAEf,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACxB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAgB,SAAS,EAAe,aAAa,EAAU,MAAM,sBAAsB,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAA6B,kBAAkB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;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