Skip to content

Commit 07016bb

Browse files
committed
Merge branch 'develop' into florianduros/rip-out-legacy-crypto/remove-legacy-crypto
# Conflicts: # src/crypto/index.ts
2 parents 6bd319b + 72519a0 commit 07016bb

20 files changed

+763
-66
lines changed

.github/workflows/sonarcloud.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
run: |
7171
coverage=$(find coverage -type f -name '*lcov.info' -printf '%h/%f,' | tr -d '\r\n' | sed 's/,$//g')
7272
echo "sonar.javascript.lcov.reportPaths=$coverage" >> sonar-project.properties
73-
reports=$(find coverage -type f -name 'jest-sonar-report*.xml' -printf '%h/%f,' | tr -d '\r\n' | sed 's/,$//g')
73+
reports=$(find coverage -type f -name '*sonar-report*.xml' -printf '%h/%f,' | tr -d '\r\n' | sed 's/,$//g')
7474
echo "sonar.testExecutionReportPaths=$reports" >> sonar-project.properties
7575
7676
- name: "🩻 SonarCloud Scan"

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
Changes in [36.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v36.1.0) (2025-01-28)
2+
==================================================================================================
3+
## ✨ Features
4+
5+
* Deprecate `MatrixClient.login` and replace with `loginRequest` ([#4632](https://github.com/matrix-org/matrix-js-sdk/pull/4632)). Contributed by @richvdh.
6+
* Use `SyncCryptoCallback` api instead of legacy crypto in sliding sync ([#4624](https://github.com/matrix-org/matrix-js-sdk/pull/4624)). Contributed by @florianduros.
7+
* Distinguish room state and timeline events in embedded clients ([#4574](https://github.com/matrix-org/matrix-js-sdk/pull/4574)). Contributed by @robintown.
8+
* Allow setting default secret storage key id to null ([#4615](https://github.com/matrix-org/matrix-js-sdk/pull/4615)). Contributed by @florianduros.
9+
* Add authenticated media to getAvatarUrl in room and room-member models ([#4616](https://github.com/matrix-org/matrix-js-sdk/pull/4616)). Contributed by @m004.
10+
* Send MSC3981 'recurse' param on `/relations` endpoint on Matrix 1.10 servers ([#4023](https://github.com/matrix-org/matrix-js-sdk/pull/4023)). Contributed by @dbkr.
11+
12+
## 🐛 Bug Fixes
13+
14+
* [Backport staging] Revert "Distinguish room state and timeline events in embedded clients (#4574)" ([#4657](https://github.com/matrix-org/matrix-js-sdk/pull/4657)). Contributed by @RiotRobot.
15+
* Change randomString et al to be secure ([#4621](https://github.com/matrix-org/matrix-js-sdk/pull/4621)). Contributed by @dbkr.
16+
* Fix issue with sentinels being incorrect on m.room.member events ([#4609](https://github.com/matrix-org/matrix-js-sdk/pull/4609)). Contributed by @t3chguy.
17+
18+
119
Changes in [36.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v36.0.0) (2025-01-14)
220
==================================================================================================
321
## 🚨 BREAKING CHANGES

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "matrix-js-sdk",
3-
"version": "36.0.0",
3+
"version": "36.1.0",
44
"description": "Matrix Client-Server SDK for Javascript",
55
"engines": {
66
"node": ">=20.0.0"
@@ -50,7 +50,7 @@
5050
],
5151
"dependencies": {
5252
"@babel/runtime": "^7.12.5",
53-
"@matrix-org/matrix-sdk-crypto-wasm": "^12.1.0",
53+
"@matrix-org/matrix-sdk-crypto-wasm": "^13.0.0",
5454
"@matrix-org/olm": "3.2.15",
5555
"another-json": "^0.2.0",
5656
"bs58": "^6.0.0",

spec/integ/crypto/device-dehydration.spec.ts

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ limitations under the License.
1717
import "fake-indexeddb/auto";
1818
import fetchMock from "fetch-mock-jest";
1919

20-
import { createClient, ClientEvent, MatrixClient, MatrixEvent } from "../../../src";
20+
import { ClientEvent, createClient, MatrixClient, MatrixEvent } from "../../../src";
21+
import { CryptoEvent } from "../../../src/crypto-api/index";
2122
import { RustCrypto } from "../../../src/rust-crypto/rust-crypto";
2223
import { AddSecretStorageKeyOpts } from "../../../src/secret-storage";
2324
import { E2EKeyReceiver } from "../../test-utils/E2EKeyReceiver";
2425
import { E2EKeyResponder } from "../../test-utils/E2EKeyResponder";
26+
import { emitPromise, EventCounter } from "../../test-utils/test-utils";
2527

2628
describe("Device dehydration", () => {
2729
it("should rehydrate and dehydrate a device", async () => {
@@ -40,6 +42,12 @@ describe("Device dehydration", () => {
4042

4143
await initializeSecretStorage(matrixClient, "@alice:localhost", "http://test.server");
4244

45+
const creationEventCounter = new EventCounter(matrixClient, CryptoEvent.DehydratedDeviceCreated);
46+
const dehydrationKeyCachedEventCounter = new EventCounter(matrixClient, CryptoEvent.DehydrationKeyCached);
47+
const rehydrationStartedCounter = new EventCounter(matrixClient, CryptoEvent.RehydrationStarted);
48+
const rehydrationCompletedCounter = new EventCounter(matrixClient, CryptoEvent.RehydrationCompleted);
49+
const rehydrationProgressCounter = new EventCounter(matrixClient, CryptoEvent.RehydrationProgress);
50+
4351
// count the number of times the dehydration key gets set
4452
let setDehydrationCount = 0;
4553
matrixClient.on(ClientEvent.AccountData, (event: MatrixEvent) => {
@@ -74,14 +82,19 @@ describe("Device dehydration", () => {
7482
await crypto.startDehydration();
7583

7684
expect(dehydrationCount).toEqual(1);
85+
expect(creationEventCounter.counter).toEqual(1);
86+
expect(dehydrationKeyCachedEventCounter.counter).toEqual(1);
7787

7888
// a week later, we should have created another dehydrated device
7989
const dehydrationPromise = new Promise<void>((resolve, reject) => {
8090
resolveDehydrationPromise = resolve;
8191
});
8292
jest.advanceTimersByTime(7 * 24 * 60 * 60 * 1000);
8393
await dehydrationPromise;
94+
95+
expect(dehydrationKeyCachedEventCounter.counter).toEqual(1);
8496
expect(dehydrationCount).toEqual(2);
97+
expect(creationEventCounter.counter).toEqual(2);
8598

8699
// restart dehydration -- rehydrate the device that we created above,
87100
// and create a new dehydrated device. We also set `createNewKey`, so
@@ -113,6 +126,39 @@ describe("Device dehydration", () => {
113126
expect(setDehydrationCount).toEqual(2);
114127
expect(eventsResponse.mock.calls).toHaveLength(2);
115128

129+
expect(rehydrationStartedCounter.counter).toEqual(1);
130+
expect(rehydrationCompletedCounter.counter).toEqual(1);
131+
expect(creationEventCounter.counter).toEqual(3);
132+
expect(rehydrationProgressCounter.counter).toEqual(1);
133+
expect(dehydrationKeyCachedEventCounter.counter).toEqual(2);
134+
135+
// test that if we get an error when we try to rotate, it emits an event
136+
fetchMock.put("path:/_matrix/client/unstable/org.matrix.msc3814.v1/dehydrated_device", {
137+
status: 500,
138+
body: {
139+
errcode: "M_UNKNOWN",
140+
error: "Unknown error",
141+
},
142+
});
143+
const rotationErrorEventPromise = emitPromise(matrixClient, CryptoEvent.DehydratedDeviceRotationError);
144+
jest.advanceTimersByTime(7 * 24 * 60 * 60 * 1000);
145+
await rotationErrorEventPromise;
146+
147+
// Restart dehydration, but return an error for GET /dehydrated_device so that rehydration fails.
148+
fetchMock.get("path:/_matrix/client/unstable/org.matrix.msc3814.v1/dehydrated_device", {
149+
status: 500,
150+
body: {
151+
errcode: "M_UNKNOWN",
152+
error: "Unknown error",
153+
},
154+
});
155+
fetchMock.put("path:/_matrix/client/unstable/org.matrix.msc3814.v1/dehydrated_device", (_, opts) => {
156+
return {};
157+
});
158+
const rehydrationErrorEventPromise = emitPromise(matrixClient, CryptoEvent.RehydrationError);
159+
await crypto.startDehydration(true);
160+
await rehydrationErrorEventPromise;
161+
116162
matrixClient.stopClient();
117163
});
118164
});

spec/test-utils/test-utils.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,19 @@ CRYPTO_BACKENDS["rust-sdk"] = (client: MatrixClient) => client.initRustCrypto();
563563

564564
export const emitPromise = (e: EventEmitter, k: string): Promise<any> => new Promise((r) => e.once(k, r));
565565

566+
/**
567+
* Counts the number of times that an event was emitted.
568+
*/
569+
export class EventCounter {
570+
public counter;
571+
constructor(emitter: EventEmitter, event: string) {
572+
this.counter = 0;
573+
emitter.on(event, () => {
574+
this.counter++;
575+
});
576+
}
577+
}
578+
566579
/**
567580
* Advance the fake timers in a loop until the given promise resolves or rejects.
568581
*

spec/unit/content-helpers.spec.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,17 @@ describe("Topic content helpers", () => {
207207
],
208208
});
209209
});
210+
211+
it("creates an empty event when the topic is falsey", () => {
212+
expect(makeTopicContent(undefined)).toEqual({
213+
topic: undefined,
214+
[M_TOPIC.name]: [],
215+
});
216+
expect(makeTopicContent(null)).toEqual({
217+
topic: null,
218+
[M_TOPIC.name]: [],
219+
});
220+
});
210221
});
211222

212223
describe("parseTopicContent()", () => {
@@ -257,5 +268,26 @@ describe("Topic content helpers", () => {
257268
html: "<b>pizza</b>",
258269
});
259270
});
271+
272+
it("parses legacy event content", () => {
273+
expect(
274+
parseTopicContent({
275+
topic: "pizza",
276+
}),
277+
).toEqual({
278+
text: "pizza",
279+
});
280+
});
281+
282+
it("uses legacy event content when new topic key is invalid", () => {
283+
expect(
284+
parseTopicContent({
285+
"topic": "pizza",
286+
"m.topic": {} as any,
287+
}),
288+
).toEqual({
289+
text: "pizza",
290+
});
291+
});
260292
});
261293
});

0 commit comments

Comments
 (0)