matrix-js-sdk 42.3.0 → 42.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/lib/@types/json.d.ts.map +1 -1
- package/lib/@types/json.js.map +1 -1
- package/lib/client.d.ts +74 -5
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +83 -7
- package/lib/client.js.map +1 -1
- package/lib/common-crypto/CryptoBackend.d.ts +42 -23
- package/lib/common-crypto/CryptoBackend.d.ts.map +1 -1
- package/lib/common-crypto/CryptoBackend.js +7 -0
- package/lib/common-crypto/CryptoBackend.js.map +1 -1
- package/lib/embedded.d.ts +35 -1
- package/lib/embedded.d.ts.map +1 -1
- package/lib/embedded.js +49 -1
- package/lib/embedded.js.map +1 -1
- package/lib/http-api/fetch.d.ts +0 -1
- package/lib/http-api/fetch.d.ts.map +1 -1
- package/lib/http-api/fetch.js +3 -22
- package/lib/http-api/fetch.js.map +1 -1
- package/lib/http-api/logging.d.ts +10 -0
- package/lib/http-api/logging.d.ts.map +1 -0
- package/lib/http-api/logging.js +46 -0
- package/lib/http-api/logging.js.map +1 -0
- package/lib/matrixrtc/EncryptionManager.d.ts +5 -0
- package/lib/matrixrtc/EncryptionManager.d.ts.map +1 -1
- package/lib/matrixrtc/EncryptionManager.js.map +1 -1
- package/lib/matrixrtc/LivekitTransport.d.ts +82 -0
- package/lib/matrixrtc/LivekitTransport.d.ts.map +1 -1
- package/lib/matrixrtc/LivekitTransport.js +25 -0
- package/lib/matrixrtc/LivekitTransport.js.map +1 -1
- package/lib/matrixrtc/MatrixRTCSession.d.ts +41 -2
- package/lib/matrixrtc/MatrixRTCSession.d.ts.map +1 -1
- package/lib/matrixrtc/MatrixRTCSession.js +59 -1
- package/lib/matrixrtc/MatrixRTCSession.js.map +1 -1
- package/lib/matrixrtc/MembershipManager.js +7 -4
- package/lib/matrixrtc/MembershipManager.js.map +1 -1
- package/lib/matrixrtc/RTCEncryptionManager.d.ts +17 -0
- package/lib/matrixrtc/RTCEncryptionManager.d.ts.map +1 -1
- package/lib/matrixrtc/RTCEncryptionManager.js +68 -29
- package/lib/matrixrtc/RTCEncryptionManager.js.map +1 -1
- package/lib/models/room-receipts.d.ts +9 -3
- package/lib/models/room-receipts.d.ts.map +1 -1
- package/lib/models/room-receipts.js +51 -11
- package/lib/models/room-receipts.js.map +1 -1
- package/lib/oauth/authorize.d.ts +7 -2
- package/lib/oauth/authorize.d.ts.map +1 -1
- package/lib/oauth/authorize.js +10 -4
- package/lib/oauth/authorize.js.map +1 -1
- package/lib/oauth/fetch.d.ts +17 -0
- package/lib/oauth/fetch.d.ts.map +1 -0
- package/lib/oauth/fetch.js +47 -0
- package/lib/oauth/fetch.js.map +1 -0
- package/lib/oauth/index.d.ts +15 -2
- package/lib/oauth/index.d.ts.map +1 -1
- package/lib/oauth/index.js +33 -12
- package/lib/oauth/index.js.map +1 -1
- package/lib/rust-crypto/index.d.ts +17 -0
- package/lib/rust-crypto/index.d.ts.map +1 -1
- package/lib/rust-crypto/index.js +4 -2
- package/lib/rust-crypto/index.js.map +1 -1
- package/lib/rust-crypto/rust-crypto.d.ts +6 -26
- package/lib/rust-crypto/rust-crypto.d.ts.map +1 -1
- package/lib/rust-crypto/rust-crypto.js +19 -54
- package/lib/rust-crypto/rust-crypto.js.map +1 -1
- package/lib/sliding-sync-sdk.d.ts.map +1 -1
- package/lib/sliding-sync-sdk.js +65 -27
- package/lib/sliding-sync-sdk.js.map +1 -1
- package/lib/sliding-sync.d.ts +17 -0
- package/lib/sliding-sync.d.ts.map +1 -1
- package/lib/sliding-sync.js +21 -9
- package/lib/sliding-sync.js.map +1 -1
- package/lib/sync.d.ts +9 -1
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +54 -29
- package/lib/sync.js.map +1 -1
- package/package.json +5 -5
- package/src/@types/json.ts +11 -2
- package/src/client.ts +126 -11
- package/src/common-crypto/CryptoBackend.ts +45 -23
- package/src/embedded.ts +67 -4
- package/src/http-api/fetch.ts +2 -23
- package/src/http-api/logging.ts +46 -0
- package/src/matrixrtc/EncryptionManager.ts +6 -0
- package/src/matrixrtc/LivekitTransport.ts +86 -0
- package/src/matrixrtc/MatrixRTCSession.ts +81 -1
- package/src/matrixrtc/MembershipManager.ts +7 -7
- package/src/matrixrtc/RTCEncryptionManager.ts +80 -31
- package/src/models/room-receipts.ts +54 -10
- package/src/oauth/authorize.ts +10 -2
- package/src/oauth/fetch.ts +54 -0
- package/src/oauth/index.ts +29 -10
- package/src/rust-crypto/index.ts +23 -0
- package/src/rust-crypto/rust-crypto.ts +25 -67
- package/src/sliding-sync-sdk.ts +73 -33
- package/src/sliding-sync.ts +31 -14
- package/src/sync.ts +58 -35
|
@@ -179,12 +179,12 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
179
179
|
async decryptEvent(event) {
|
|
180
180
|
const roomId = event.getRoomId();
|
|
181
181
|
if (!roomId) {
|
|
182
|
-
// presumably, a to-device message. These are normally decrypted in
|
|
182
|
+
// presumably, a to-device message. These are normally decrypted in processSyncChanges
|
|
183
183
|
// so the fact it has come back here suggests that decryption failed.
|
|
184
184
|
//
|
|
185
185
|
// once we drop support for the libolm crypto implementation, we can stop passing to-device messages
|
|
186
186
|
// through decryptEvent and hence get rid of this case.
|
|
187
|
-
throw new Error("to-device event was not decrypted in
|
|
187
|
+
throw new Error("to-device event was not decrypted in processSyncChanges");
|
|
188
188
|
}
|
|
189
189
|
return await this.eventDecryptor.attemptEventDecryption(event, this.deviceIsolationMode);
|
|
190
190
|
}
|
|
@@ -1353,33 +1353,26 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1353
1353
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
1354
1354
|
|
|
1355
1355
|
/**
|
|
1356
|
-
*
|
|
1357
|
-
*
|
|
1358
|
-
*
|
|
1359
|
-
*
|
|
1360
|
-
* @param devices - the received device list updates
|
|
1361
|
-
* @returns A list of processed to-device messages.
|
|
1356
|
+
* Implementation of {@link SyncCryptoCallbacks.processSyncChanges}.
|
|
1357
|
+
*
|
|
1358
|
+
* Passes all of the encryption-relevant data from a sync response to the OlmMachine in a single call, and
|
|
1359
|
+
* post-processes the resulting to-device messages.
|
|
1362
1360
|
*/
|
|
1363
|
-
async
|
|
1364
|
-
|
|
1365
|
-
|
|
1361
|
+
async processSyncChanges({
|
|
1362
|
+
toDeviceEvents,
|
|
1363
|
+
deviceLists,
|
|
1364
|
+
oneTimeKeysCounts,
|
|
1366
1365
|
unusedFallbackKeys,
|
|
1367
|
-
|
|
1366
|
+
useMsc4186 = false
|
|
1368
1367
|
}) {
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
async preprocessToDeviceMessages(events) {
|
|
1378
|
-
// send the received to-device messages into receiveSyncChanges. We have no info on device-list changes,
|
|
1379
|
-
// one-time-keys, or fallback keys, so just pass empty data.
|
|
1380
|
-
const processed = await this.receiveSyncChanges({
|
|
1381
|
-
events
|
|
1382
|
-
});
|
|
1368
|
+
const events = JSON.stringify(toDeviceEvents);
|
|
1369
|
+
const devices = new RustSdkCryptoJs.DeviceLists(deviceLists?.changed?.map(userId => new RustSdkCryptoJs.UserId(userId)), deviceLists?.left?.map(userId => new RustSdkCryptoJs.UserId(userId)));
|
|
1370
|
+
const counts = new Map(Object.entries(oneTimeKeysCounts ?? {}));
|
|
1371
|
+
const fallbackKeys = unusedFallbackKeys && new Set(unusedFallbackKeys);
|
|
1372
|
+
|
|
1373
|
+
// The two variants differ only in how they treat a missing one-time key count: zero keys on the server (sync
|
|
1374
|
+
// v2) versus unchanged (sliding sync).
|
|
1375
|
+
const processed = useMsc4186 ? await this.olmMachine.receiveSyncChangesMsc4186(events, devices, counts, fallbackKeys) : await this.olmMachine.receiveSyncChanges(events, devices, counts, fallbackKeys);
|
|
1383
1376
|
const received = [];
|
|
1384
1377
|
for (const message of processed) {
|
|
1385
1378
|
const parsedMessage = JSON.parse(message.rawEvent);
|
|
@@ -1450,34 +1443,6 @@ export class RustCrypto extends TypedEventEmitter {
|
|
|
1450
1443
|
return received;
|
|
1451
1444
|
}
|
|
1452
1445
|
|
|
1453
|
-
/** called by the sync loop to process one time key counts and unused fallback keys
|
|
1454
|
-
*
|
|
1455
|
-
* @param oneTimeKeysCounts - the received one time key counts
|
|
1456
|
-
* @param unusedFallbackKeys - the received unused fallback keys
|
|
1457
|
-
*/
|
|
1458
|
-
async processKeyCounts(oneTimeKeysCounts, unusedFallbackKeys) {
|
|
1459
|
-
const mapOneTimeKeysCount = oneTimeKeysCounts && new Map(Object.entries(oneTimeKeysCounts));
|
|
1460
|
-
const setUnusedFallbackKeys = unusedFallbackKeys && new Set(unusedFallbackKeys);
|
|
1461
|
-
if (mapOneTimeKeysCount !== undefined || setUnusedFallbackKeys !== undefined) {
|
|
1462
|
-
await this.receiveSyncChanges({
|
|
1463
|
-
oneTimeKeysCounts: mapOneTimeKeysCount,
|
|
1464
|
-
unusedFallbackKeys: setUnusedFallbackKeys
|
|
1465
|
-
});
|
|
1466
|
-
}
|
|
1467
|
-
}
|
|
1468
|
-
|
|
1469
|
-
/** called by the sync loop to process the notification that device lists have
|
|
1470
|
-
* been changed.
|
|
1471
|
-
*
|
|
1472
|
-
* @param deviceLists - device_lists field from /sync
|
|
1473
|
-
*/
|
|
1474
|
-
async processDeviceLists(deviceLists) {
|
|
1475
|
-
const devices = new RustSdkCryptoJs.DeviceLists(deviceLists.changed?.map(userId => new RustSdkCryptoJs.UserId(userId)), deviceLists.left?.map(userId => new RustSdkCryptoJs.UserId(userId)));
|
|
1476
|
-
await this.receiveSyncChanges({
|
|
1477
|
-
devices
|
|
1478
|
-
});
|
|
1479
|
-
}
|
|
1480
|
-
|
|
1481
1446
|
/** called by the sync loop on m.room.encryption events
|
|
1482
1447
|
*
|
|
1483
1448
|
* @param room - in which the event was received
|