Skip to content

Commit 5c6b029

Browse files
committed
Merge tag 'v15.4.0' into sc
* Don't consider alt_aliases when calculating room name ([\matrix-org#2094](matrix-org#2094)). Fixes element-hq/element-web#13887. * Load room history if necessary when searching for MSC3089 getFileEvent() ([\matrix-org#2066](matrix-org#2066)). * Add support for MSC3030 `/timestamp_to_event` ([\matrix-org#2072](matrix-org#2072)). * Stop encrypting redactions as it isn't spec compliant ([\matrix-org#2098](matrix-org#2098)). Fixes element-hq/element-web#20460. * Fix more function typings relating to key backup ([\matrix-org#2086](matrix-org#2086)). * Fix timeline search in MSC3089 getFileEvent() ([\matrix-org#2085](matrix-org#2085)). * Set a `deviceId` for VoIP example and use `const`/`let` ([\matrix-org#2090](matrix-org#2090)). Fixes matrix-org#2083. Contributed by @SimonBrandner. * Fix incorrect TS return type for secret storage and key backup functions ([\matrix-org#2082](matrix-org#2082)).
2 parents a71dd32 + f0597e0 commit 5c6b029

Some content is hidden

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

57 files changed

+1556
-808
lines changed

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
Changes in [15.4.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v15.4.0) (2022-01-17)
2+
==================================================================================================
3+
4+
## ✨ Features
5+
* Don't consider alt_aliases when calculating room name ([\#2094](https://github.com/matrix-org/matrix-js-sdk/pull/2094)). Fixes vector-im/element-web#13887.
6+
* Load room history if necessary when searching for MSC3089 getFileEvent() ([\#2066](https://github.com/matrix-org/matrix-js-sdk/pull/2066)).
7+
* Add support for MSC3030 `/timestamp_to_event` ([\#2072](https://github.com/matrix-org/matrix-js-sdk/pull/2072)).
8+
9+
## 🐛 Bug Fixes
10+
* Stop encrypting redactions as it isn't spec compliant ([\#2098](https://github.com/matrix-org/matrix-js-sdk/pull/2098)). Fixes vector-im/element-web#20460.
11+
* Fix more function typings relating to key backup ([\#2086](https://github.com/matrix-org/matrix-js-sdk/pull/2086)).
12+
* Fix timeline search in MSC3089 getFileEvent() ([\#2085](https://github.com/matrix-org/matrix-js-sdk/pull/2085)).
13+
* Set a `deviceId` for VoIP example and use `const`/`let` ([\#2090](https://github.com/matrix-org/matrix-js-sdk/pull/2090)). Fixes #2083. Contributed by @SimonBrandner.
14+
* Fix incorrect TS return type for secret storage and key backup functions ([\#2082](https://github.com/matrix-org/matrix-js-sdk/pull/2082)).
15+
16+
Changes in [15.4.0-rc.1](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v15.4.0-rc.1) (2022-01-11)
17+
============================================================================================================
18+
19+
## ✨ Features
20+
* Don't consider alt_aliases when calculating room name ([\#2094](https://github.com/matrix-org/matrix-js-sdk/pull/2094)). Fixes vector-im/element-web#13887.
21+
* Load room history if necessary when searching for MSC3089 getFileEvent() ([\#2066](https://github.com/matrix-org/matrix-js-sdk/pull/2066)).
22+
* Add support for MSC3030 `/timestamp_to_event` ([\#2072](https://github.com/matrix-org/matrix-js-sdk/pull/2072)).
23+
24+
## 🐛 Bug Fixes
25+
* Stop encrypting redactions as it isn't spec compliant ([\#2098](https://github.com/matrix-org/matrix-js-sdk/pull/2098)). Fixes vector-im/element-web#20460.
26+
* Fix more function typings relating to key backup ([\#2086](https://github.com/matrix-org/matrix-js-sdk/pull/2086)).
27+
* Fix timeline search in MSC3089 getFileEvent() ([\#2085](https://github.com/matrix-org/matrix-js-sdk/pull/2085)).
28+
* Set a `deviceId` for VoIP example and use `const`/`let` ([\#2090](https://github.com/matrix-org/matrix-js-sdk/pull/2090)). Fixes #2083. Contributed by @SimonBrandner.
29+
* Fix incorrect TS return type for secret storage and key backup functions ([\#2082](https://github.com/matrix-org/matrix-js-sdk/pull/2082)).
30+
131
Changes in [15.3.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v15.3.0) (2021-12-20)
232
==================================================================================================
333

examples/voip/browserTest.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
console.log("Loading browser sdk");
2-
var BASE_URL = "https://matrix.org";
3-
var TOKEN = "accesstokengoeshere";
4-
var USER_ID = "@username:localhost";
5-
var ROOM_ID = "!room:id";
2+
const BASE_URL = "https://matrix.org";
3+
const TOKEN = "accesstokengoeshere";
4+
const USER_ID = "@username:localhost";
5+
const ROOM_ID = "!room:id";
6+
const DEVICE_ID = "some_device_id";
67

7-
8-
var client = matrixcs.createClient({
8+
const client = matrixcs.createClient({
99
baseUrl: BASE_URL,
1010
accessToken: TOKEN,
11-
userId: USER_ID
11+
userId: USER_ID,
12+
deviceId: DEVICE_ID
1213
});
13-
var call;
14+
let call;
1415

1516
function disableButtons(place, answer, hangup) {
1617
document.getElementById("hangup").disabled = hangup;
@@ -19,7 +20,7 @@ function disableButtons(place, answer, hangup) {
1920
}
2021

2122
function addListeners(call) {
22-
var lastError = "";
23+
let lastError = "";
2324
call.on("hangup", function() {
2425
disableButtons(false, true, true);
2526
document.getElementById("result").innerHTML = (

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "matrix-js-sdk",
3-
"version": "15.3.0",
3+
"version": "15.4.0",
44
"description": "Matrix Client-Server SDK for Javascript",
55
"scripts": {
66
"prepublishOnly": "yarn build",
@@ -15,7 +15,7 @@
1515
"build:minify-browser": "terser dist/browser-matrix.js --compress --mangle --source-map --output dist/browser-matrix.min.js",
1616
"gendoc": "jsdoc -c jsdoc.json -P package.json",
1717
"lint": "yarn lint:types && yarn lint:js",
18-
"lint:js": "eslint --max-warnings 4 src spec",
18+
"lint:js": "eslint --max-warnings 0 src spec",
1919
"lint:js-fix": "eslint --fix src spec",
2020
"lint:types": "tsc --noEmit",
2121
"test": "jest",
@@ -55,7 +55,6 @@
5555
"browser-request": "^0.3.3",
5656
"bs58": "^4.0.1",
5757
"content-type": "^1.0.4",
58-
"eslint-plugin-import": "^2.25.2",
5958
"loglevel": "^1.7.1",
6059
"p-retry": "^4.5.0",
6160
"qs": "^6.9.6",
@@ -77,6 +76,7 @@
7776
"@babel/register": "^7.12.10",
7877
"@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz",
7978
"@types/bs58": "^4.0.1",
79+
"@types/content-type": "^1.1.5",
8080
"@types/jest": "^26.0.20",
8181
"@types/node": "12",
8282
"@types/request": "^2.48.5",
@@ -90,7 +90,8 @@
9090
"docdash": "^1.2.0",
9191
"eslint": "7.18.0",
9292
"eslint-config-google": "^0.14.0",
93-
"eslint-plugin-matrix-org": "github:matrix-org/eslint-plugin-matrix-org#48ec1e6af2cfb8310b9a6e23edf2dc7a26ddd580",
93+
"eslint-plugin-import": "^2.25.4",
94+
"eslint-plugin-matrix-org": "^0.4.0",
9495
"exorcist": "^1.0.1",
9596
"fake-indexeddb": "^3.1.2",
9697
"jest": "^26.6.3",

release.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,12 @@ if [ -n "$signing_id" ]; then
255255
# the easiest way to check the validity of the tarball from git is to unzip
256256
# it and compare it with our own idea of what the tar should look like.
257257

258+
# This uses git archive which seems to be what github uses. Specifically,
259+
# the header fields are set in the same way: same file mode, uid & gid
260+
# both zero and mtime set to the timestamp of the commit that the tag
261+
# references. Also note that this puts the commit into the tar headers
262+
# and can be extracted with gunzip -c foo.tar.gz | git get-tar-commit-id
263+
258264
# the name of the sig file we want to create
259265
source_sigfile="${tag}-src.tar.gz.asc"
260266

spec/TestClient.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ TestClient.prototype.toString = function() {
8686
*/
8787
TestClient.prototype.start = function() {
8888
logger.log(this + ': starting');
89+
this.httpBackend.when("GET", "/capabilities").respond(200, { capabilities: {} });
8990
this.httpBackend.when("GET", "/pushrules").respond(200, {});
9091
this.httpBackend.when("POST", "/filter").respond(200, { filter_id: "fid" });
9192
this.expectDeviceKeyUpload();

spec/browserify/sync-browserify.spec.js

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,55 +17,34 @@ limitations under the License.
1717
// load XmlHttpRequest mock
1818
import "./setupTests";
1919
import "../../dist/browser-matrix"; // uses browser-matrix instead of the src
20-
import MockHttpBackend from "matrix-mock-request";
21-
22-
import { MockStorageApi } from "../MockStorageApi";
23-
import { WebStorageSessionStore } from "../../src/store/session/webstorage";
24-
import { LocalStorageCryptoStore } from "../../src/crypto/store/localStorage-crypto-store";
2520
import * as utils from "../test-utils";
21+
import { TestClient } from "../TestClient";
2622

2723
const USER_ID = "@user:test.server";
2824
const DEVICE_ID = "device_id";
2925
const ACCESS_TOKEN = "access_token";
3026
const ROOM_ID = "!room_id:server.test";
3127

32-
/* global matrixcs */
33-
3428
describe("Browserify Test", function() {
3529
let client;
3630
let httpBackend;
3731

38-
async function createTestClient() {
39-
const sessionStoreBackend = new MockStorageApi();
40-
const sessionStore = new WebStorageSessionStore(sessionStoreBackend);
41-
const httpBackend = new MockHttpBackend();
32+
beforeEach(() => {
33+
const testClient = new TestClient(USER_ID, DEVICE_ID, ACCESS_TOKEN);
4234

43-
const options = {
44-
baseUrl: "http://" + USER_ID + ".test.server",
45-
userId: USER_ID,
46-
accessToken: ACCESS_TOKEN,
47-
deviceId: DEVICE_ID,
48-
sessionStore: sessionStore,
49-
request: httpBackend.requestFn,
50-
cryptoStore: new LocalStorageCryptoStore(sessionStoreBackend),
51-
};
52-
53-
const client = matrixcs.createClient(options);
35+
client = testClient.client;
36+
httpBackend = testClient.httpBackend;
5437

38+
httpBackend.when("GET", "/capabilities").respond(200, { capabilities: {} });
5539
httpBackend.when("GET", "/pushrules").respond(200, {});
5640
httpBackend.when("POST", "/filter").respond(200, { filter_id: "fid" });
5741

58-
return { client, httpBackend };
59-
}
60-
61-
beforeEach(async () => {
62-
({ client, httpBackend } = await createTestClient());
63-
await client.startClient();
42+
client.startClient();
6443
});
6544

6645
afterEach(async () => {
6746
client.stopClient();
68-
await httpBackend.stop();
47+
httpBackend.stop();
6948
});
7049

7150
it("Sync", async function() {
@@ -92,10 +71,8 @@ describe("Browserify Test", function() {
9271
};
9372

9473
httpBackend.when("GET", "/sync").respond(200, syncData);
95-
await Promise.race([
96-
Promise.all([
97-
httpBackend.flushAllExpected(),
98-
]),
74+
return await Promise.race([
75+
httpBackend.flushAllExpected(),
9976
new Promise((_, reject) => {
10077
client.once("sync.unexpectedError", reject);
10178
}),

spec/integ/matrix-client-crypto.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,7 @@ describe("MatrixClient crypto", function() {
722722
return Promise.resolve()
723723
.then(() => {
724724
logger.log(aliTestClient + ': starting');
725+
httpBackend.when("GET", "/capabilities").respond(200, {});
725726
httpBackend.when("GET", "/pushrules").respond(200, {});
726727
httpBackend.when("POST", "/filter").respond(200, { filter_id: "fid" });
727728
aliTestClient.expectDeviceKeyUpload();

spec/integ/matrix-client-event-emitter.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ describe("MatrixClient events", function() {
1313
httpBackend = testClient.httpBackend;
1414
httpBackend.when("GET", "/pushrules").respond(200, {});
1515
httpBackend.when("POST", "/filter").respond(200, { filter_id: "a filter id" });
16+
httpBackend.when("GET", "/capabilities").respond(200, { capabilities: {} });
1617
});
1718

1819
afterEach(function() {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const EVENTS = [
7171

7272
// start the client, and wait for it to initialise
7373
function startClient(httpBackend, client) {
74+
httpBackend.when("GET", "/capabilities").respond(200, { capabilities: {} });
7475
httpBackend.when("GET", "/pushrules").respond(200, {});
7576
httpBackend.when("POST", "/filter").respond(200, { filter_id: "fid" });
7677
httpBackend.when("GET", "/sync").respond(200, INITIAL_SYNC_DATA);
@@ -502,7 +503,7 @@ describe("MatrixClient event timelines", function() {
502503
const params = req.queryParams;
503504
expect(params.dir).toEqual("b");
504505
expect(params.from).toEqual("start_token0");
505-
expect(params.limit).toEqual(30);
506+
expect(params.limit).toEqual("30");
506507
}).respond(200, function() {
507508
return {
508509
chunk: [EVENTS[1], EVENTS[2]],
@@ -553,7 +554,7 @@ describe("MatrixClient event timelines", function() {
553554
const params = req.queryParams;
554555
expect(params.dir).toEqual("f");
555556
expect(params.from).toEqual("end_token0");
556-
expect(params.limit).toEqual(20);
557+
expect(params.limit).toEqual("20");
557558
}).respond(200, function() {
558559
return {
559560
chunk: [EVENTS[1], EVENTS[2]],

spec/integ/matrix-client-opts.spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@ describe("MatrixClient opts", function() {
105105
expectedEventTypes.indexOf(event.getType()), 1,
106106
);
107107
});
108+
httpBackend.when("GET", "/capabilities").respond(200, { capabilities: {} });
108109
httpBackend.when("GET", "/pushrules").respond(200, {});
109110
httpBackend.when("POST", "/filter").respond(200, { filter_id: "foo" });
110111
httpBackend.when("GET", "/sync").respond(200, syncData);
111-
await client.startClient();
112+
client.startClient();
113+
await httpBackend.flush("/capabilities", 1);
112114
await httpBackend.flush("/pushrules", 1);
113115
await httpBackend.flush("/filter", 1);
114116
await Promise.all([

spec/integ/matrix-client-room-timeline.spec.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ describe("MatrixClient room timelines", function() {
9696
});
9797
}
9898

99-
beforeEach(function() {
99+
beforeEach(async function() {
100100
// these tests should work with or without timelineSupport
101101
const testClient = new TestClient(
102102
userId,
@@ -109,16 +109,18 @@ describe("MatrixClient room timelines", function() {
109109
client = testClient.client;
110110

111111
setNextSyncData();
112+
httpBackend.when("GET", "/capabilities").respond(200, { capabilities: {} });
112113
httpBackend.when("GET", "/pushrules").respond(200, {});
113114
httpBackend.when("POST", "/filter").respond(200, { filter_id: "fid" });
114115
httpBackend.when("GET", "/sync").respond(200, SYNC_DATA);
115116
httpBackend.when("GET", "/sync").respond(200, function() {
116117
return NEXT_SYNC_DATA;
117118
});
118119
client.startClient();
119-
return httpBackend.flush("/pushrules").then(function() {
120-
return httpBackend.flush("/filter");
121-
});
120+
121+
await httpBackend.flush("/capabilities");
122+
await httpBackend.flush("/pushrules");
123+
await httpBackend.flush("/filter");
122124
});
123125

124126
afterEach(function() {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ describe("MatrixClient syncing", function() {
1919
const testClient = new TestClient(selfUserId, "DEVICE", selfAccessToken);
2020
httpBackend = testClient.httpBackend;
2121
client = testClient.client;
22+
httpBackend.when("GET", "/capabilities").respond(200, { capabilities: {} });
2223
httpBackend.when("GET", "/pushrules").respond(200, {});
2324
httpBackend.when("POST", "/filter").respond(200, { filter_id: "a filter id" });
2425
});

spec/test-utils.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -341,28 +341,27 @@ HttpResponse.SYNC_RESPONSE = {
341341
data: HttpResponse.SYNC_DATA,
342342
};
343343

344+
HttpResponse.CAPABILITIES_RESPONSE = {
345+
method: "GET",
346+
path: "/capabilities",
347+
data: { capabilities: {} },
348+
};
349+
344350
HttpResponse.defaultResponses = function(userId) {
345351
return [
352+
HttpResponse.CAPABILITIES_RESPONSE,
346353
HttpResponse.PUSH_RULES_RESPONSE,
347354
HttpResponse.filterResponse(userId),
348355
HttpResponse.SYNC_RESPONSE,
349356
];
350357
};
351358

352359
export function setHttpResponses(
353-
client, responses, acceptKeepalives, ignoreUnhandledSyncs,
360+
httpBackend, responses,
354361
) {
355-
const httpResponseObj = new HttpResponse(
356-
responses, acceptKeepalives, ignoreUnhandledSyncs,
357-
);
358-
359-
const httpReq = httpResponseObj.request.bind(httpResponseObj);
360-
client.http = [
361-
"authedRequest", "authedRequestWithPrefix", "getContentUri",
362-
"request", "requestWithPrefix", "uploadContent",
363-
].reduce((r, k) => {r[k] = jest.fn(); return r;}, {});
364-
client.http.authedRequest.mockImplementation(httpReq);
365-
client.http.authedRequestWithPrefix.mockImplementation(httpReq);
366-
client.http.requestWithPrefix.mockImplementation(httpReq);
367-
client.http.request.mockImplementation(httpReq);
362+
responses.forEach(response => {
363+
httpBackend
364+
.when(response.method, response.path)
365+
.respond(200, response.data);
366+
});
368367
}

0 commit comments

Comments
 (0)