Skip to content

Commit b775e30

Browse files
thorajms-dosx86richvdhMidhunSureshRRiotRobot
authored
Bringing develop to v 33.0.0 (#5)
* Preserve ESM for async imports to work correctly (matrix-org#4187) * fix: fix lazy rust crypto import * test: use "commonjs" for tests because of circular deps * chore: revert commonjs for "module" * refactor: remove unnecessary example * refactor: add comments Signed-off-by: Bayyr Oorjak <[email protected]> * refactor: improve comment Signed-off-by: Bayyr Oorjak <[email protected]> Co-authored-by: Richard van der Hoff <[email protected]> * Update babel.config.js --------- Signed-off-by: Bayyr Oorjak <[email protected]> Co-authored-by: Richard van der Hoff <[email protected]> * Update organization (matrix-org#4212) * v32.4.0 * Update dependency @matrix-org/matrix-sdk-crypto-wasm to v4.10.0 (matrix-org#4214) * Update dependency @matrix-org/matrix-sdk-crypto-wasm to v4.10.0 * Disable affected test Signed-off-by: Michael Telatynski <[email protected]> --------- Signed-off-by: Michael Telatynski <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Michael Telatynski <[email protected]> * `initRustCrypto`: allow app to pass in the store key directly (matrix-org#4210) * `initRustCrypto`: allow app to pass in the store key directly ... instead of using the pickleKey. This allows us to avoid a slow PBKDF operation. * Fix link in doc-comment * Bump matrix-sdk-crypto-wasm to 5.0.0 (matrix-org#4216) Slightly more involved than normal because it requires us to pass a backup version into OlmMachine.importBackedUpRoomKeys. On the other hand we can now re-enable the test that was disabled in matrix-org#4214 due to matrix-org/matrix-rust-sdk#3447 Fixes: element-hq/element-web#27165 * Remove more deprecated methods, fields, and exports (matrix-org#4217) * Don't run migration for Rust crypto if the legacy store is empty (matrix-org#4218) * Don't run migration for Rust crypto if the legacy store is empty Fixes element-hq/element-web#27447 * Add copyright for the TypeScript files in legacy DB dumps * Provide a type for the accountPickle we check for before migration * Remove redundant backup response This is unused * Simplify keys response * Downgrade log message. --------- Co-authored-by: Richard van der Hoff <[email protected]> * v33.0.0-rc.0 * v33.0.0 --------- Signed-off-by: Bayyr Oorjak <[email protected]> Signed-off-by: Michael Telatynski <[email protected]> Co-authored-by: Bayyr Oorjak <[email protected]> Co-authored-by: Richard van der Hoff <[email protected]> Co-authored-by: R Midhun Suresh <[email protected]> Co-authored-by: RiotRobot <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Michael Telatynski <[email protected]> Co-authored-by: Andy Balaam <[email protected]> Co-authored-by: Richard van der Hoff <[email protected]>
1 parent 93d9628 commit b775e30

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+421
-374
lines changed

.babelrc

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/notify-downstream.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
include:
15-
- repo: vector-im/element-web
15+
- repo: element-hq/element-web
1616
event: element-web-notify
1717
- repo: matrix-org/matrix-react-sdk
1818
event: upstream-sdk-notify

.github/workflows/triage-labelled.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ on:
66

77
jobs:
88
call-triage-labelled:
9-
uses: vector-im/element-web/.github/workflows/triage-labelled.yml@develop
9+
uses: element-hq/element-web/.github/workflows/triage-labelled.yml@develop
1010
secrets:
1111
ELEMENT_BOT_TOKEN: ${{ secrets.ELEMENT_BOT_TOKEN }}

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
Changes in [33.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v33.0.0) (2024-06-04)
2+
==================================================================================================
3+
## 🚨 BREAKING CHANGES
4+
5+
* Remove more deprecated methods, fields, and exports ([#4217](https://github.com/matrix-org/matrix-js-sdk/pull/4217)). Contributed by @t3chguy.
6+
* Remove deprecated methods and fields ([#4201](https://github.com/matrix-org/matrix-js-sdk/pull/4201)). Contributed by @t3chguy.
7+
8+
## 🦖 Deprecations
9+
10+
* Remove more deprecated methods, fields, and exports ([#4217](https://github.com/matrix-org/matrix-js-sdk/pull/4217)). Contributed by @t3chguy.
11+
* Remove deprecated methods and fields ([#4201](https://github.com/matrix-org/matrix-js-sdk/pull/4201)). Contributed by @t3chguy.
12+
13+
## ✨ Features
14+
15+
* `initRustCrypto`: allow app to pass in the store key directly ([#4210](https://github.com/matrix-org/matrix-js-sdk/pull/4210)). Contributed by @richvdh.
16+
* Preserve ESM for async imports to work correctly ([#4187](https://github.com/matrix-org/matrix-js-sdk/pull/4187)). Contributed by @ms-dosx86.
17+
18+
## 🐛 Bug Fixes
19+
20+
* Don't run migration for Rust crypto if the legacy store is empty ([#4218](https://github.com/matrix-org/matrix-js-sdk/pull/4218)). Contributed by @andybalaam.
21+
* Bump matrix-sdk-crypto-wasm to 5.0.0 ([#4216](https://github.com/matrix-org/matrix-js-sdk/pull/4216)). Contributed by @richvdh.
22+
* Wire up verification cancel \& mismatch for rust crypto ([#4202](https://github.com/matrix-org/matrix-js-sdk/pull/4202)). Contributed by @t3chguy.
23+
* Only pass id\_server if we had one to begin with ([#4200](https://github.com/matrix-org/matrix-js-sdk/pull/4200)). Contributed by @t3chguy.
24+
25+
26+
Changes in [32.4.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v32.4.0) (2024-05-22)
27+
==================================================================================================
28+
* No changes
29+
30+
131
Changes in [32.3.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v32.3.0) (2024-05-21)
232
==================================================================================================
333
## ✨ Features

babel.config.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
sourceMaps: true,
3+
presets: [
4+
[
5+
"@babel/preset-env",
6+
{
7+
targets: {
8+
esmodules: true,
9+
},
10+
// We want to output ES modules for the final build (mostly to ensure that
11+
// async imports work correctly). However, jest doesn't support ES modules very
12+
// well yet (see https://github.com/jestjs/jest/issues/9430), so we use commonjs
13+
// when testing.
14+
modules: process.env.NODE_ENV === "test" ? "commonjs" : false,
15+
},
16+
],
17+
"@babel/preset-typescript",
18+
],
19+
plugins: [
20+
"@babel/plugin-proposal-numeric-separator",
21+
"@babel/plugin-proposal-class-properties",
22+
"@babel/plugin-proposal-object-rest-spread",
23+
"@babel/plugin-syntax-dynamic-import",
24+
"@babel/plugin-transform-runtime",
25+
],
26+
};

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "matrix-js-sdk",
3-
"version": "32.3.0",
3+
"version": "33.0.0",
44
"description": "Matrix Client-Server SDK for Javascript",
55
"engines": {
66
"node": ">=18.0.0"
@@ -31,8 +31,8 @@
3131
"keywords": [
3232
"matrix-org"
3333
],
34-
"main": "./src/index.ts",
35-
"browser": "./src/browser-index.ts",
34+
"main": "./lib/index.js",
35+
"browser": "./lib/browser-index.js",
3636
"matrix_src_main": "./src/index.ts",
3737
"matrix_src_browser": "./src/browser-index.ts",
3838
"matrix_lib_main": "./lib/index.js",
@@ -53,7 +53,7 @@
5353
],
5454
"dependencies": {
5555
"@babel/runtime": "^7.12.5",
56-
"@matrix-org/matrix-sdk-crypto-wasm": "^4.9.0",
56+
"@matrix-org/matrix-sdk-crypto-wasm": "^5.0.0",
5757
"another-json": "^0.2.0",
5858
"bs58": "^5.0.0",
5959
"content-type": "^1.0.4",
@@ -132,5 +132,6 @@
132132
"outputDirectory": "coverage",
133133
"outputName": "jest-sonar-report.xml",
134134
"relativePaths": true
135-
}
135+
},
136+
"typings": "./lib/index.d.ts"
136137
}

spec/integ/crypto/megolm-backup.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { Mocked } from "jest-mock";
2121

2222
import {
2323
createClient,
24-
CryptoApi,
24+
Crypto,
2525
CryptoEvent,
2626
ICreateClientOpts,
2727
IEvent,
@@ -310,7 +310,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("megolm-keys backup (%s)", (backe
310310
});
311311

312312
describe("recover from backup", () => {
313-
let aliceCrypto: CryptoApi;
313+
let aliceCrypto: Crypto.CryptoApi;
314314

315315
beforeEach(async () => {
316316
fetchMock.get("path:/_matrix/client/v3/room_keys/version", testData.SIGNED_BACKUP_DATA);

spec/integ/crypto/rust-crypto.spec.ts

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { populateStore } from "../../test-utils/test_indexeddb_cryptostore_dump"
2323
import { MSK_NOT_CACHED_DATASET } from "../../test-utils/test_indexeddb_cryptostore_dump/no_cached_msk_dump";
2424
import { IDENTITY_NOT_TRUSTED_DATASET } from "../../test-utils/test_indexeddb_cryptostore_dump/unverified";
2525
import { FULL_ACCOUNT_DATASET } from "../../test-utils/test_indexeddb_cryptostore_dump/full_account";
26+
import { EMPTY_ACCOUNT_DATASET } from "../../test-utils/test_indexeddb_cryptostore_dump/empty_account";
2627

2728
jest.setTimeout(15000);
2829

@@ -85,6 +86,44 @@ describe("MatrixClient.initRustCrypto", () => {
8586
);
8687
});
8788

89+
it("should create the meta db if given a storageKey", async () => {
90+
const matrixClient = createClient({
91+
baseUrl: "http://test.server",
92+
userId: "@alice:localhost",
93+
deviceId: "aliceDevice",
94+
});
95+
96+
// No databases.
97+
expect(await indexedDB.databases()).toHaveLength(0);
98+
99+
await matrixClient.initRustCrypto({ storageKey: new Uint8Array(32) });
100+
101+
// should have two indexed dbs now
102+
const databaseNames = (await indexedDB.databases()).map((db) => db.name);
103+
expect(databaseNames).toEqual(
104+
expect.arrayContaining(["matrix-js-sdk::matrix-sdk-crypto", "matrix-js-sdk::matrix-sdk-crypto-meta"]),
105+
);
106+
});
107+
108+
it("should create the meta db if given a storagePassword", async () => {
109+
const matrixClient = createClient({
110+
baseUrl: "http://test.server",
111+
userId: "@alice:localhost",
112+
deviceId: "aliceDevice",
113+
});
114+
115+
// No databases.
116+
expect(await indexedDB.databases()).toHaveLength(0);
117+
118+
await matrixClient.initRustCrypto({ storagePassword: "the cow is on the moon" });
119+
120+
// should have two indexed dbs now
121+
const databaseNames = (await indexedDB.databases()).map((db) => db.name);
122+
expect(databaseNames).toEqual(
123+
expect.arrayContaining(["matrix-js-sdk::matrix-sdk-crypto", "matrix-js-sdk::matrix-sdk-crypto-meta"]),
124+
);
125+
});
126+
88127
it("should ignore a second call", async () => {
89128
const matrixClient = createClient({
90129
baseUrl: "http://test.server",
@@ -266,6 +305,38 @@ describe("MatrixClient.initRustCrypto", () => {
266305
});
267306
});
268307

308+
it("should not migrate if account data is missing", async () => {
309+
// See https://github.com/element-hq/element-web/issues/27447
310+
311+
// Given we have an almost-empty legacy account in the database
312+
fetchMock.get("path:/_matrix/client/v3/room_keys/version", {
313+
status: 404,
314+
body: { errcode: "M_NOT_FOUND", error: "No backup found" },
315+
});
316+
fetchMock.post("path:/_matrix/client/v3/keys/query", EMPTY_ACCOUNT_DATASET.keyQueryResponse);
317+
318+
const testStoreName = "test-store";
319+
await populateStore(testStoreName, EMPTY_ACCOUNT_DATASET.dumpPath);
320+
const cryptoStore = new IndexedDBCryptoStore(indexedDB, testStoreName);
321+
322+
const matrixClient = createClient({
323+
baseUrl: "http://test.server",
324+
userId: EMPTY_ACCOUNT_DATASET.userId,
325+
deviceId: EMPTY_ACCOUNT_DATASET.deviceId,
326+
cryptoStore,
327+
pickleKey: EMPTY_ACCOUNT_DATASET.pickleKey,
328+
});
329+
330+
// When we start Rust crypto, potentially triggering an upgrade
331+
const progressListener = jest.fn();
332+
matrixClient.addListener(CryptoEvent.LegacyCryptoStoreMigrationProgress, progressListener);
333+
334+
await matrixClient.initRustCrypto();
335+
336+
// Then no error occurs, and no upgrade happens
337+
expect(progressListener.mock.calls.length).toBe(0);
338+
}, 60000);
339+
269340
describe("Legacy trust migration", () => {
270341
async function populateAndStartLegacyCryptoStore(dumpPath: string): Promise<IndexedDBCryptoStore> {
271342
const testStoreName = "test-store";

0 commit comments

Comments
 (0)