Skip to content

Commit e6c127a

Browse files
committed
Merge tag 'v23.1.0' into sc
* Remove extensible events v1 field population on legacy events ([\matrix-org#3040](matrix-org#3040)). * Improve hasUserReadEvent and getUserReadUpTo realibility with threads ([\matrix-org#3031](matrix-org#3031)). Fixes element-hq/element-web#24164. * Remove video track when muting video ([\matrix-org#3028](matrix-org#3028)). Fixes element-hq/element-call#209. * Make poll start event type available (PSG-962) ([\matrix-org#3034](matrix-org#3034)). * Add alt event type matching in Relations model ([\matrix-org#3018](matrix-org#3018)). * Remove usage of v1 Identity Server API ([\matrix-org#3003](matrix-org#3003)). * Add `device_id` to `/account/whoami` types ([\matrix-org#3005](matrix-org#3005)). * Implement MSC3912: Relation-based redactions ([\matrix-org#2954](matrix-org#2954)). * Introduce a mechanism for using the rust-crypto-sdk ([\matrix-org#2969](matrix-org#2969)). * Support MSC3391: Account data deletion ([\matrix-org#2967](matrix-org#2967)). * Fix threaded cache receipt when event holds multiple receipts ([\matrix-org#3026](matrix-org#3026)). * Fix false key requests after verifying new device ([\matrix-org#3029](matrix-org#3029)). Fixes element-hq/element-web#24167 and element-hq/element-web#23333. * Avoid triggering decryption errors when decrypting redacted events ([\matrix-org#3004](matrix-org#3004)). Fixes element-hq/element-web#24084. * bugfix: upload OTKs in sliding sync mode ([\matrix-org#3008](matrix-org#3008)). * Apply edits discovered from sync after thread is initialised ([\matrix-org#3002](matrix-org#3002)). Fixes element-hq/element-web#23921. * Sliding sync: Fix issue where no unsubs are sent when switching rooms ([\matrix-org#2991](matrix-org#2991)). * Threads are missing from the timeline ([\matrix-org#2996](matrix-org#2996)). Fixes element-hq/element-web#24036. * Close all streams when a call ends ([\matrix-org#2992](matrix-org#2992)). Fixes element-hq/element-call#742. * Resume to-device message queue after resumed sync ([\matrix-org#2920](matrix-org#2920)). Fixes matrix-org/element-web-rageshakes#17170. * Fix browser entrypoint ([\matrix-org#3051](matrix-org#3051)). Fixes matrix-org#3013. * Fix failure to start in firefox private browser ([\matrix-org#3058](matrix-org#3058)). Fixes element-hq/element-web#24216. * Correctly handle limited sync responses by resetting the thread timeline ([\matrix-org#3056](matrix-org#3056)). Fixes element-hq/element-web#23952.
2 parents b9afe23 + b8711f1 commit e6c127a

Some content is hidden

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

63 files changed

+3738
-1001
lines changed

.git-blame-ignore-revs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ cee7f7a280a8c20bafc21c0a2911f60851f7a7ca
3838
7ed65407e6cdf292ce3cf659310c68d19dcd52b2
3939
# Switch to ESLint from JSHint (Google eslint rules as a base)
4040
e057956ede9ad1a931ff8050c411aca7907e0394
41-
41+
# prettier
42+
349c2c2587c2885bb69eda4aa078b5383724cf5e

CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
Changes in [23.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v23.1.0) (2023-01-18)
2+
==================================================================================================
3+
4+
## 🦖 Deprecations
5+
* Remove extensible events v1 field population on legacy events ([\#3040](https://github.com/matrix-org/matrix-js-sdk/pull/3040)).
6+
7+
## ✨ Features
8+
* Improve hasUserReadEvent and getUserReadUpTo realibility with threads ([\#3031](https://github.com/matrix-org/matrix-js-sdk/pull/3031)). Fixes vector-im/element-web#24164.
9+
* Remove video track when muting video ([\#3028](https://github.com/matrix-org/matrix-js-sdk/pull/3028)). Fixes vector-im/element-call#209.
10+
* Make poll start event type available (PSG-962) ([\#3034](https://github.com/matrix-org/matrix-js-sdk/pull/3034)).
11+
* Add alt event type matching in Relations model ([\#3018](https://github.com/matrix-org/matrix-js-sdk/pull/3018)).
12+
* Remove usage of v1 Identity Server API ([\#3003](https://github.com/matrix-org/matrix-js-sdk/pull/3003)).
13+
* Add `device_id` to `/account/whoami` types ([\#3005](https://github.com/matrix-org/matrix-js-sdk/pull/3005)).
14+
* Implement MSC3912: Relation-based redactions ([\#2954](https://github.com/matrix-org/matrix-js-sdk/pull/2954)).
15+
* Introduce a mechanism for using the rust-crypto-sdk ([\#2969](https://github.com/matrix-org/matrix-js-sdk/pull/2969)).
16+
* Support MSC3391: Account data deletion ([\#2967](https://github.com/matrix-org/matrix-js-sdk/pull/2967)).
17+
18+
## 🐛 Bug Fixes
19+
* Fix threaded cache receipt when event holds multiple receipts ([\#3026](https://github.com/matrix-org/matrix-js-sdk/pull/3026)).
20+
* Fix false key requests after verifying new device ([\#3029](https://github.com/matrix-org/matrix-js-sdk/pull/3029)). Fixes vector-im/element-web#24167 and vector-im/element-web#23333.
21+
* Avoid triggering decryption errors when decrypting redacted events ([\#3004](https://github.com/matrix-org/matrix-js-sdk/pull/3004)). Fixes vector-im/element-web#24084.
22+
* bugfix: upload OTKs in sliding sync mode ([\#3008](https://github.com/matrix-org/matrix-js-sdk/pull/3008)).
23+
* Apply edits discovered from sync after thread is initialised ([\#3002](https://github.com/matrix-org/matrix-js-sdk/pull/3002)). Fixes vector-im/element-web#23921.
24+
* Sliding sync: Fix issue where no unsubs are sent when switching rooms ([\#2991](https://github.com/matrix-org/matrix-js-sdk/pull/2991)).
25+
* Threads are missing from the timeline ([\#2996](https://github.com/matrix-org/matrix-js-sdk/pull/2996)). Fixes vector-im/element-web#24036.
26+
* Close all streams when a call ends ([\#2992](https://github.com/matrix-org/matrix-js-sdk/pull/2992)). Fixes vector-im/element-call#742.
27+
* Resume to-device message queue after resumed sync ([\#2920](https://github.com/matrix-org/matrix-js-sdk/pull/2920)). Fixes matrix-org/element-web-rageshakes#17170.
28+
* Fix browser entrypoint ([\#3051](https://github.com/matrix-org/matrix-js-sdk/pull/3051)). Fixes #3013.
29+
* Fix failure to start in firefox private browser ([\#3058](https://github.com/matrix-org/matrix-js-sdk/pull/3058)). Fixes vector-im/element-web#24216.
30+
* Correctly handle limited sync responses by resetting the thread timeline ([\#3056](https://github.com/matrix-org/matrix-js-sdk/pull/3056)). Fixes vector-im/element-web#23952.
31+
132
Changes in [23.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v23.0.0) (2022-12-21)
233
==================================================================================================
334

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ if you do not have it already.
4747

4848
```javascript
4949
import * as sdk from "matrix-js-sdk";
50-
const client = sdk.createClient("https://matrix.org");
50+
const client = sdk.createClient({ baseUrl: "https://matrix.org" });
5151
client.publicRooms(function (err, data) {
5252
console.log("Public Rooms: %s", JSON.stringify(data));
5353
});

examples/browser/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
To try it out, **you must build the SDK first** and then host this folder:
22

33
```
4+
$ yarn install
45
$ yarn build
56
$ cd examples/browser
67
$ python -m http.server 8003

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "matrix-js-sdk",
3-
"version": "23.0.0",
3+
"version": "23.1.0",
44
"description": "Matrix Client-Server SDK for Javascript",
55
"engines": {
66
"node": ">=16.0.0"
@@ -14,7 +14,7 @@
1414
"build:dev": "yarn clean && git rev-parse HEAD > git-revision.txt && yarn build:compile && yarn build:types",
1515
"build:types": "tsc -p tsconfig-build.json --emitDeclarationOnly",
1616
"build:compile": "babel -d lib --verbose --extensions \".ts,.js\" src",
17-
"build:compile-browser": "mkdirp dist && browserify -d src/browser-index.ts -p [ tsify -p ./tsconfig-build.json ] -t [ babelify --sourceMaps=inline --presets [ @babel/preset-env @babel/preset-typescript ] ] | exorcist dist/browser-matrix.js.map > dist/browser-matrix.js",
17+
"build:compile-browser": "mkdir dist && browserify -d src/browser-index.ts -p [ tsify -p ./tsconfig-build.json ] -t [ babelify --sourceMaps=inline --presets [ @babel/preset-env @babel/preset-typescript ] ] | exorcist dist/browser-matrix.js.map > dist/browser-matrix.js",
1818
"build:minify-browser": "terser dist/browser-matrix.js --compress --mangle --source-map --output dist/browser-matrix.min.js",
1919
"gendoc": "typedoc",
2020
"lint": "yarn lint:types && yarn lint:js",
@@ -33,10 +33,11 @@
3333
"matrix-org"
3434
],
3535
"main": "./lib/index.js",
36-
"browser": "./lib/browser-index.ts",
36+
"browser": "./lib/browser-index.js",
3737
"matrix_src_main": "./src/index.ts",
3838
"matrix_src_browser": "./src/browser-index.ts",
3939
"matrix_lib_main": "./lib/index.js",
40+
"matrix_lib_browser": "./lib/browser-index.js",
4041
"matrix_lib_typings": "./lib/index.d.ts",
4142
"author": "matrix.org",
4243
"license": "Apache-2.0",
@@ -54,17 +55,17 @@
5455
],
5556
"dependencies": {
5657
"@babel/runtime": "^7.12.5",
58+
"@matrix-org/matrix-sdk-crypto-js": "^0.1.0-alpha.2",
5759
"another-json": "^0.2.0",
5860
"bs58": "^5.0.0",
5961
"content-type": "^1.0.4",
6062
"loglevel": "^1.7.1",
6163
"matrix-events-sdk": "0.0.1",
6264
"matrix-widget-api": "^1.0.0",
6365
"p-retry": "4",
64-
"qs": "^6.9.6",
6566
"sdp-transform": "^2.14.1",
6667
"unhomoglyph": "^1.0.6",
67-
"uuid": "7"
68+
"uuid": "9"
6869
},
6970
"devDependencies": {
7071
"@babel/cli": "^7.12.10",
@@ -97,7 +98,7 @@
9798
"browserify": "^17.0.0",
9899
"docdash": "^2.0.0",
99100
"domexception": "^4.0.0",
100-
"eslint": "8.28.0",
101+
"eslint": "8.29.0",
101102
"eslint-config-google": "^0.14.0",
102103
"eslint-config-prettier": "^8.5.0",
103104
"eslint-import-resolver-typescript": "^3.5.1",
@@ -113,7 +114,7 @@
113114
"jest-localstorage-mock": "^2.4.6",
114115
"jest-mock": "^29.0.0",
115116
"matrix-mock-request": "^2.5.0",
116-
"prettier": "2.8.0",
117+
"prettier": "2.8.1",
117118
"rimraf": "^3.0.2",
118119
"terser": "^5.5.1",
119120
"tsify": "^5.0.2",

post-release.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ if [ "$(git branch -lr | grep origin/develop -c)" -ge 1 ]; then
2121
# to the TypeScript source.
2222
src_value=$(jq -r ".matrix_src_$i" package.json)
2323
if [ "$src_value" != "null" ]; then
24-
jq ".$i = .matrix_src_$i" package.json > package.json.new && mv package.json.new package.json
24+
jq ".$i = .matrix_src_$i" package.json > package.json.new && mv package.json.new package.json && yarn prettier --write package.json
2525
else
26-
jq "del(.$i)" package.json > package.json.new && mv package.json.new package.json
26+
jq "del(.$i)" package.json > package.json.new && mv package.json.new package.json && yarn prettier --write package.json
2727
fi
2828
fi
2929
done

spec/TestClient.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import MockHttpBackend from "matrix-mock-request";
2424
import { LocalStorageCryptoStore } from "../src/crypto/store/localStorage-crypto-store";
2525
import { logger } from "../src/logger";
2626
import { syncPromise } from "./test-utils/test-utils";
27-
import { createClient } from "../src/matrix";
27+
import { createClient, IStartClientOpts } from "../src/matrix";
2828
import { ICreateClientOpts, IDownloadKeyResult, MatrixClient, PendingEventOrdering } from "../src/client";
2929
import { MockStorageApi } from "./MockStorageApi";
3030
import { encodeUri } from "../src/utils";
@@ -79,9 +79,12 @@ export class TestClient {
7979
/**
8080
* start the client, and wait for it to initialise.
8181
*/
82-
public start(): Promise<void> {
82+
public start(opts: IStartClientOpts = {}): Promise<void> {
8383
logger.log(this + ": starting");
84-
this.httpBackend.when("GET", "/versions").respond(200, {});
84+
this.httpBackend.when("GET", "/versions").respond(200, {
85+
// we have tests that rely on support for lazy-loading members
86+
versions: ["r0.5.0"],
87+
});
8588
this.httpBackend.when("GET", "/pushrules").respond(200, {});
8689
this.httpBackend.when("POST", "/filter").respond(200, { filter_id: "fid" });
8790
this.expectDeviceKeyUpload();
@@ -93,6 +96,8 @@ export class TestClient {
9396
this.client.startClient({
9497
// set this so that we can get hold of failed events
9598
pendingEventOrdering: PendingEventOrdering.Detached,
99+
100+
...opts,
96101
});
97102

98103
return Promise.all([this.httpBackend.flushAllExpected(), syncPromise(this.client)]).then(() => {

spec/integ/matrix-client-event-timeline.spec.ts

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,97 @@ describe("MatrixClient event timelines", function () {
10731073
});
10741074
});
10751075

1076+
it("should ensure thread events are ordered correctly", async () => {
1077+
// Test data for a second reply to the first thread
1078+
const THREAD_REPLY2 = utils.mkEvent({
1079+
room: roomId,
1080+
user: userId,
1081+
type: "m.room.message",
1082+
content: {
1083+
"body": "thread reply 2",
1084+
"msgtype": "m.text",
1085+
"m.relates_to": {
1086+
// We can't use the const here because we change server support mode for test
1087+
rel_type: "io.element.thread",
1088+
event_id: THREAD_ROOT.event_id,
1089+
},
1090+
},
1091+
event: true,
1092+
});
1093+
THREAD_REPLY2.localTimestamp += 1000;
1094+
1095+
// Test data for a second reply to the first thread
1096+
const THREAD_REPLY3 = utils.mkEvent({
1097+
room: roomId,
1098+
user: userId,
1099+
type: "m.room.message",
1100+
content: {
1101+
"body": "thread reply 3",
1102+
"msgtype": "m.text",
1103+
"m.relates_to": {
1104+
// We can't use the const here because we change server support mode for test
1105+
rel_type: "io.element.thread",
1106+
event_id: THREAD_ROOT.event_id,
1107+
},
1108+
},
1109+
event: true,
1110+
});
1111+
THREAD_REPLY3.localTimestamp += 2000;
1112+
1113+
// Test data for the first thread, with the second reply
1114+
const THREAD_ROOT_UPDATED = {
1115+
...THREAD_ROOT,
1116+
unsigned: {
1117+
...THREAD_ROOT.unsigned,
1118+
"m.relations": {
1119+
...THREAD_ROOT.unsigned!["m.relations"],
1120+
"io.element.thread": {
1121+
...THREAD_ROOT.unsigned!["m.relations"]!["io.element.thread"],
1122+
count: 3,
1123+
latest_event: THREAD_REPLY3.event,
1124+
},
1125+
},
1126+
},
1127+
};
1128+
1129+
// @ts-ignore
1130+
client.clientOpts.experimentalThreadSupport = true;
1131+
Thread.setServerSideSupport(FeatureSupport.Stable);
1132+
Thread.setServerSideListSupport(FeatureSupport.Stable);
1133+
Thread.setServerSideFwdPaginationSupport(FeatureSupport.Stable);
1134+
1135+
client.fetchRoomEvent = () => Promise.resolve(THREAD_ROOT_UPDATED);
1136+
1137+
await client.stopClient(); // we don't need the client to be syncing at this time
1138+
const room = client.getRoom(roomId)!;
1139+
1140+
const prom = emitPromise(room, ThreadEvent.Update);
1141+
// Assume we're seeing the reply while loading backlog
1142+
room.addLiveEvents([THREAD_REPLY2]);
1143+
httpBackend
1144+
.when(
1145+
"GET",
1146+
"/_matrix/client/v1/rooms/!foo%3Abar/relations/" +
1147+
encodeURIComponent(THREAD_ROOT_UPDATED.event_id!) +
1148+
"/" +
1149+
encodeURIComponent(THREAD_RELATION_TYPE.name),
1150+
)
1151+
.respond(200, {
1152+
chunk: [THREAD_REPLY3.event, THREAD_REPLY2.event, THREAD_REPLY],
1153+
});
1154+
await flushHttp(prom);
1155+
// but while loading the metadata, a new reply has arrived
1156+
room.addLiveEvents([THREAD_REPLY3]);
1157+
const thread = room.getThread(THREAD_ROOT_UPDATED.event_id!)!;
1158+
// then the events should still be all in the right order
1159+
expect(thread.events.map((it) => it.getId())).toEqual([
1160+
THREAD_ROOT.event_id,
1161+
THREAD_REPLY.event_id,
1162+
THREAD_REPLY2.getId(),
1163+
THREAD_REPLY3.getId(),
1164+
]);
1165+
});
1166+
10761167
describe("paginateEventTimeline for thread list timeline", function () {
10771168
const RANDOM_TOKEN = "7280349c7bee430f91defe2a38a0a08c";
10781169

spec/integ/matrix-client-methods.spec.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ describe("MatrixClient", function () {
3535
let store: MemoryStore | undefined;
3636

3737
const defaultClientOpts: IStoredClientOpts = {
38-
canResetEntireTimeline: (roomId) => false,
3938
experimentalThreadSupport: false,
40-
crypto: {} as unknown as IStoredClientOpts["crypto"],
4139
};
4240
const setupTests = (): [MatrixClient, HttpBackend, MemoryStore] => {
4341
const store = new MemoryStore();
@@ -1179,11 +1177,10 @@ describe("MatrixClient", function () {
11791177
.when("PUT", "/send")
11801178
.check((req) => {
11811179
expect(req.data).toStrictEqual({
1182-
"msgtype": "m.emote",
1183-
"body": "Body",
1184-
"formatted_body": "<h1>Body</h1>",
1185-
"format": "org.matrix.custom.html",
1186-
"org.matrix.msc1767.message": expect.anything(),
1180+
msgtype: "m.emote",
1181+
body: "Body",
1182+
formatted_body: "<h1>Body</h1>",
1183+
format: "org.matrix.custom.html",
11871184
});
11881185
})
11891186
.respond(200, { event_id: "$foobar" });
@@ -1199,11 +1196,10 @@ describe("MatrixClient", function () {
11991196
.when("PUT", "/send")
12001197
.check((req) => {
12011198
expect(req.data).toStrictEqual({
1202-
"msgtype": "m.text",
1203-
"body": "Body",
1204-
"formatted_body": "<h1>Body</h1>",
1205-
"format": "org.matrix.custom.html",
1206-
"org.matrix.msc1767.message": expect.anything(),
1199+
msgtype: "m.text",
1200+
body: "Body",
1201+
formatted_body: "<h1>Body</h1>",
1202+
format: "org.matrix.custom.html",
12071203
});
12081204
})
12091205
.respond(200, { event_id: "$foobar" });

spec/integ/matrix-client-syncing.spec.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,52 @@ describe("MatrixClient syncing", () => {
15431543
});
15441544
});
15451545
});
1546+
1547+
it("only replays receipts relevant to the current context", async () => {
1548+
const THREAD_ID = "$unknownthread:localhost";
1549+
1550+
const receipt = {
1551+
type: "m.receipt",
1552+
room_id: "!foo:bar",
1553+
content: {
1554+
"$event1:localhost": {
1555+
[ReceiptType.Read]: {
1556+
"@alice:localhost": { ts: 666, thread_id: THREAD_ID },
1557+
},
1558+
},
1559+
"$otherevent:localhost": {
1560+
[ReceiptType.Read]: {
1561+
"@alice:localhost": { ts: 999, thread_id: "$otherthread:localhost" },
1562+
},
1563+
},
1564+
},
1565+
};
1566+
syncData.rooms.join[roomOne].ephemeral.events = [receipt];
1567+
1568+
httpBackend!.when("GET", "/sync").respond(200, syncData);
1569+
client!.startClient();
1570+
1571+
return Promise.all([httpBackend!.flushAllExpected(), awaitSyncEvent()]).then(() => {
1572+
const room = client?.getRoom(roomOne);
1573+
expect(room).toBeInstanceOf(Room);
1574+
1575+
expect(room?.cachedThreadReadReceipts.has(THREAD_ID)).toBe(true);
1576+
1577+
const thread = room!.createThread(THREAD_ID, undefined, [], true);
1578+
1579+
expect(room?.cachedThreadReadReceipts.has(THREAD_ID)).toBe(false);
1580+
1581+
const receipt = thread.getReadReceiptForUserId("@alice:localhost");
1582+
1583+
expect(receipt).toStrictEqual({
1584+
data: {
1585+
thread_id: "$unknownthread:localhost",
1586+
ts: 666,
1587+
},
1588+
eventId: "$event1:localhost",
1589+
});
1590+
});
1591+
});
15461592
});
15471593

15481594
describe("of a room", () => {

0 commit comments

Comments
 (0)