Skip to content

Commit 9b20f5c

Browse files
committed
Merge tag 'v21.0.0' into sc
* Changes the `uploadContent` API, kills off `request` and `browser-request` in favour of `fetch`, removed callback support on a lot of the methods, adds a lot of tests. ([\matrix-org#2719](matrix-org#2719)). Fixes matrix-org#2415 and matrix-org#801. * Remove deprecated `m.room.aliases` references ([\matrix-org#2759](matrix-org#2759)). Fixes element-hq/element-web#12680. * Remove node-specific crypto bits, use Node 16's WebCrypto ([\matrix-org#2762](matrix-org#2762)). Fixes matrix-org#2760. * Export types for MatrixEvent and Room emitted events, and make event handler map types stricter ([\matrix-org#2750](matrix-org#2750)). Contributed by @stas-demydiuk. * Use even more stable calls to `/room_keys` ([\matrix-org#2746](matrix-org#2746)). * Upgrade to Olm 3.2.13 which has been repackaged to support Node 18 ([\matrix-org#2744](matrix-org#2744)). * Fix `power_level_content_override` type ([\matrix-org#2741](matrix-org#2741)). * Add custom notification handling for MSC3401 call events ([\matrix-org#2720](matrix-org#2720)). * Add support for unread thread notifications ([\matrix-org#2726](matrix-org#2726)). * Load Thread List with server-side assistance (MSC3856) ([\matrix-org#2602](matrix-org#2602)). * Use stable calls to `/room_keys` ([\matrix-org#2729](matrix-org#2729)). Fixes element-hq/element-web#22839. * Fix POST data not being passed for registerWithIdentityServer ([\matrix-org#2769](matrix-org#2769)). Fixes matrix-org/element-web-rageshakes#16206. * Fix IdentityPrefix.V2 containing spurious `/api` ([\matrix-org#2761](matrix-org#2761)). Fixes element-hq/element-web#23505. * Always send back an httpStatus property if one is known ([\matrix-org#2753](matrix-org#2753)). * Check for AbortError, not any generic connection error, to avoid tightlooping ([\matrix-org#2752](matrix-org#2752)). * Correct the dir parameter of MSC3715 ([\matrix-org#2745](matrix-org#2745)). Contributed by @dhenneke. * Fix sync init when thread unread notif is not supported ([\matrix-org#2739](matrix-org#2739)). Fixes element-hq/element-web#23435. * Use the correct sender key when checking shared secret ([\matrix-org#2730](matrix-org#2730)). Fixes element-hq/element-web#23374.
2 parents c2f7795 + 1842004 commit 9b20f5c

File tree

130 files changed

+8653
-5583
lines changed

Some content is hidden

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

130 files changed

+8653
-5583
lines changed

.eslintrc.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
module.exports = {
22
plugins: [
33
"matrix-org",
4+
"import",
45
],
56
extends: [
67
"plugin:matrix-org/babel",
8+
"plugin:import/typescript",
79
],
810
env: {
911
browser: true,
1012
node: true,
1113
},
14+
settings: {
15+
"import/resolver": {
16+
typescript: true,
17+
node: true,
18+
},
19+
},
1220
// NOTE: These rules are frozen and new rules should not be added here.
1321
// New changes belong in https://github.com/matrix-org/eslint-plugin-matrix-org/
1422
rules: {
@@ -35,7 +43,19 @@ module.exports = {
3543
"no-console": "error",
3644

3745
// restrict EventEmitters to force callers to use TypedEventEmitter
38-
"no-restricted-imports": ["error", "events"],
46+
"no-restricted-imports": ["error", {
47+
name: "events",
48+
message: "Please use TypedEventEmitter instead"
49+
}],
50+
51+
"import/no-restricted-paths": ["error", {
52+
"zones": [{
53+
"target": "./src/",
54+
"from": "./src/index.ts",
55+
"message": "The package index is dynamic between src and lib depending on " +
56+
"whether release or development, target the specific module or matrix.ts instead",
57+
}],
58+
}],
3959
},
4060
overrides: [{
4161
files: [

.github/workflows/release-npm.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ jobs:
3636
package=$(cat package.json | jq -er .name)
3737
npm dist-tag add "$package@$release" latest
3838
env:
39-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
39+
# JS-DevTools/npm-publish overrides `NODE_AUTH_TOKEN` with `INPUT_TOKEN` in .npmrc
40+
INPUT_TOKEN: ${{ secrets.NPM_TOKEN }}
4041
release: ${{ steps.npm-publish.outputs.version }}

.github/workflows/static_analysis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ jobs:
2323
- name: Typecheck
2424
run: "yarn run lint:types"
2525

26+
- name: Switch js-sdk to release mode
27+
run: |
28+
scripts/switch_package_to_release.js
29+
yarn install
30+
yarn run build:compile
31+
yarn run build:types
32+
33+
- name: Typecheck (release mode)
34+
run: "yarn run lint:types"
35+
2636
js_lint:
2737
name: "ESLint"
2838
runs-on: ubuntu-latest

CHANGELOG.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,58 @@
1+
Changes in [21.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v21.0.0) (2022-10-25)
2+
==================================================================================================
3+
4+
## 🚨 BREAKING CHANGES
5+
* Changes the `uploadContent` API, kills off `request` and `browser-request` in favour of `fetch`, removed callback support on a lot of the methods, adds a lot of tests. ([\#2719](https://github.com/matrix-org/matrix-js-sdk/pull/2719)). Fixes #2415 and #801.
6+
* Remove deprecated `m.room.aliases` references ([\#2759](https://github.com/matrix-org/matrix-js-sdk/pull/2759)). Fixes vector-im/element-web#12680.
7+
8+
## ✨ Features
9+
* Remove node-specific crypto bits, use Node 16's WebCrypto ([\#2762](https://github.com/matrix-org/matrix-js-sdk/pull/2762)). Fixes #2760.
10+
* Export types for MatrixEvent and Room emitted events, and make event handler map types stricter ([\#2750](https://github.com/matrix-org/matrix-js-sdk/pull/2750)). Contributed by @stas-demydiuk.
11+
* Use even more stable calls to `/room_keys` ([\#2746](https://github.com/matrix-org/matrix-js-sdk/pull/2746)).
12+
* Upgrade to Olm 3.2.13 which has been repackaged to support Node 18 ([\#2744](https://github.com/matrix-org/matrix-js-sdk/pull/2744)).
13+
* Fix `power_level_content_override` type ([\#2741](https://github.com/matrix-org/matrix-js-sdk/pull/2741)).
14+
* Add custom notification handling for MSC3401 call events ([\#2720](https://github.com/matrix-org/matrix-js-sdk/pull/2720)).
15+
* Add support for unread thread notifications ([\#2726](https://github.com/matrix-org/matrix-js-sdk/pull/2726)).
16+
* Load Thread List with server-side assistance (MSC3856) ([\#2602](https://github.com/matrix-org/matrix-js-sdk/pull/2602)).
17+
* Use stable calls to `/room_keys` ([\#2729](https://github.com/matrix-org/matrix-js-sdk/pull/2729)). Fixes vector-im/element-web#22839.
18+
19+
## 🐛 Bug Fixes
20+
* Fix POST data not being passed for registerWithIdentityServer ([\#2769](https://github.com/matrix-org/matrix-js-sdk/pull/2769)). Fixes matrix-org/element-web-rageshakes#16206.
21+
* Fix IdentityPrefix.V2 containing spurious `/api` ([\#2761](https://github.com/matrix-org/matrix-js-sdk/pull/2761)). Fixes vector-im/element-web#23505.
22+
* Always send back an httpStatus property if one is known ([\#2753](https://github.com/matrix-org/matrix-js-sdk/pull/2753)).
23+
* Check for AbortError, not any generic connection error, to avoid tightlooping ([\#2752](https://github.com/matrix-org/matrix-js-sdk/pull/2752)).
24+
* Correct the dir parameter of MSC3715 ([\#2745](https://github.com/matrix-org/matrix-js-sdk/pull/2745)). Contributed by @dhenneke.
25+
* Fix sync init when thread unread notif is not supported ([\#2739](https://github.com/matrix-org/matrix-js-sdk/pull/2739)). Fixes vector-im/element-web#23435.
26+
* Use the correct sender key when checking shared secret ([\#2730](https://github.com/matrix-org/matrix-js-sdk/pull/2730)). Fixes vector-im/element-web#23374.
27+
28+
Changes in [20.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v20.1.0) (2022-10-11)
29+
============================================================================================================
30+
31+
## ✨ Features
32+
* Add local notification settings capability ([\#2700](https://github.com/matrix-org/matrix-js-sdk/pull/2700)).
33+
* Implementation of MSC3882 login token request ([\#2687](https://github.com/matrix-org/matrix-js-sdk/pull/2687)). Contributed by @hughns.
34+
* Typings for MSC2965 OIDC provider discovery ([\#2424](https://github.com/matrix-org/matrix-js-sdk/pull/2424)). Contributed by @hughns.
35+
* Support to remotely toggle push notifications ([\#2686](https://github.com/matrix-org/matrix-js-sdk/pull/2686)).
36+
* Read receipts for threads ([\#2635](https://github.com/matrix-org/matrix-js-sdk/pull/2635)).
37+
38+
## 🐛 Bug Fixes
39+
* Use the correct sender key when checking shared secret ([\#2730](https://github.com/matrix-org/matrix-js-sdk/pull/2730)). Fixes vector-im/element-web#23374.
40+
* Unexpected ignored self key request when it's not shared history ([\#2724](https://github.com/matrix-org/matrix-js-sdk/pull/2724)). Contributed by @mcalinghee.
41+
* Fix IDB initial migration handling causing spurious lazy loading upgrade loops ([\#2718](https://github.com/matrix-org/matrix-js-sdk/pull/2718)). Fixes vector-im/element-web#23377.
42+
* Fix backpagination at end logic being spec non-conforming ([\#2680](https://github.com/matrix-org/matrix-js-sdk/pull/2680)). Fixes vector-im/element-web#22784.
43+
44+
Changes in [20.0.2](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v20.0.2) (2022-09-30)
45+
==================================================================================================
46+
47+
## 🐛 Bug Fixes
48+
* Fix issue in sync when crypto is not supported by client ([\#2715](https://github.com/matrix-org/matrix-js-sdk/pull/2715)). Contributed by @stas-demydiuk.
49+
50+
Changes in [20.0.1](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v20.0.1) (2022-09-28)
51+
==================================================================================================
52+
53+
## 🐛 Bug Fixes
54+
* Fix missing return when receiving an invitation without shared history ([\#2710](https://github.com/matrix-org/matrix-js-sdk/pull/2710)).
55+
156
Changes in [20.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v20.0.0) (2022-09-28)
257
==================================================================================================
358

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ In Node.js
3434
----------
3535

3636
Ensure you have the latest LTS version of Node.js installed.
37-
38-
This SDK targets Node 12 for compatibility, which translates to ES6. If you're using
39-
a bundler like webpack you'll likely have to transpile dependencies, including this
40-
SDK, to match your target browsers.
37+
This library relies on `fetch` which is available in Node from v18.0.0 - it should work fine also with polyfills.
38+
If you wish to use a ponyfill or adapter of some sort then pass it as `fetchFn` to the MatrixClient constructor options.
4139

4240
Using `yarn` instead of `npm` is recommended. Please see the Yarn [install guide](https://classic.yarnpkg.com/en/docs/install)
4341
if you do not have it already.

package.json

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "matrix-js-sdk",
3-
"version": "20.0.0",
3+
"version": "21.0.0",
44
"description": "Matrix Client-Server SDK for Javascript",
55
"engines": {
6-
"node": ">=12.9.0"
6+
"node": ">=16.0.0"
77
},
88
"scripts": {
99
"prepublishOnly": "yarn build",
@@ -55,14 +55,12 @@
5555
"dependencies": {
5656
"@babel/runtime": "^7.12.5",
5757
"another-json": "^0.2.0",
58-
"browser-request": "^0.3.3",
5958
"bs58": "^5.0.0",
6059
"content-type": "^1.0.4",
6160
"loglevel": "^1.7.1",
6261
"matrix-events-sdk": "^0.0.1-beta.7",
6362
"p-retry": "4",
6463
"qs": "^6.9.6",
65-
"request": "^2.88.2",
6664
"unhomoglyph": "^1.0.6"
6765
},
6866
"devDependencies": {
@@ -78,12 +76,12 @@
7876
"@babel/preset-env": "^7.12.11",
7977
"@babel/preset-typescript": "^7.12.7",
8078
"@babel/register": "^7.12.10",
81-
"@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.12.tgz",
79+
"@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.13.tgz",
8280
"@types/bs58": "^4.0.1",
8381
"@types/content-type": "^1.1.5",
82+
"@types/domexception": "^4.0.0",
8483
"@types/jest": "^29.0.0",
8584
"@types/node": "16",
86-
"@types/request": "^2.48.5",
8785
"@typescript-eslint/eslint-plugin": "^5.6.0",
8886
"@typescript-eslint/parser": "^5.6.0",
8987
"allchange": "^1.0.6",
@@ -92,17 +90,20 @@
9290
"better-docs": "^2.4.0-beta.9",
9391
"browserify": "^17.0.0",
9492
"docdash": "^1.2.0",
95-
"eslint": "8.23.0",
93+
"domexception": "^4.0.0",
94+
"eslint": "8.24.0",
9695
"eslint-config-google": "^0.14.0",
97-
"eslint-plugin-import": "^2.25.4",
96+
"eslint-import-resolver-typescript": "^3.5.1",
97+
"eslint-plugin-import": "^2.26.0",
9898
"eslint-plugin-matrix-org": "^0.6.0",
9999
"exorcist": "^2.0.0",
100100
"fake-indexeddb": "^4.0.0",
101101
"jest": "^29.0.0",
102102
"jest-localstorage-mock": "^2.4.6",
103+
"jest-mock": "^27.5.1",
103104
"jest-sonar-reporter": "^2.0.0",
104105
"jsdoc": "^3.6.6",
105-
"matrix-mock-request": "^2.1.2",
106+
"matrix-mock-request": "^2.5.0",
106107
"rimraf": "^3.0.2",
107108
"terser": "^5.5.1",
108109
"tsify": "^5.0.2",
@@ -113,6 +114,9 @@
113114
"testMatch": [
114115
"<rootDir>/spec/**/*.spec.{js,ts}"
115116
],
117+
"setupFilesAfterEnv": [
118+
"<rootDir>/spec/setupTests.ts"
119+
],
116120
"collectCoverageFrom": [
117121
"<rootDir>/src/**/*.{js,ts}"
118122
],

release.sh

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ yarn install --ignore-scripts --pure-lockfile
135135
# ignore leading v on release
136136
release="${1#v}"
137137
tag="v${release}"
138-
rel_branch="release-$tag"
139138

140139
prerelease=0
141140
# We check if this build is a prerelease by looking to
@@ -150,18 +149,7 @@ else
150149
read -p "Making a FINAL RELEASE, press enter to continue " REPLY
151150
fi
152151

153-
# We might already be on the release branch, in which case, yay
154-
# If we're on any branch starting with 'release', or the staging branch
155-
# we don't create a separate release branch (this allows us to use the same
156-
# release branch for releases and release candidates).
157-
curbranch=$(git symbolic-ref --short HEAD)
158-
if [[ "$curbranch" != release* && "$curbranch" != "staging" ]]; then
159-
echo "Creating release branch"
160-
git checkout -b "$rel_branch"
161-
else
162-
echo "Using current branch ($curbranch) for release"
163-
rel_branch=$curbranch
164-
fi
152+
rel_branch=$(git symbolic-ref --short HEAD)
165153

166154
if [ -z "$skip_changelog" ]; then
167155
echo "Generating changelog"

scripts/switch_package_to_release.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env node
2+
3+
const fsProm = require('fs/promises');
4+
5+
const PKGJSON = 'package.json';
6+
7+
async function main() {
8+
const pkgJson = JSON.parse(await fsProm.readFile(PKGJSON, 'utf8'));
9+
for (const field of ['main', 'typings']) {
10+
if (pkgJson["matrix_lib_"+field] !== undefined) {
11+
pkgJson[field] = pkgJson["matrix_lib_"+field];
12+
}
13+
}
14+
await fsProm.writeFile(PKGJSON, JSON.stringify(pkgJson, null, 2));
15+
}
16+
17+
main();

spec/TestClient.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import { MockStorageApi } from "./MockStorageApi";
3030
import { encodeUri } from "../src/utils";
3131
import { IDeviceKeys, IOneTimeKey } from "../src/crypto/dehydration";
3232
import { IKeyBackupSession } from "../src/crypto/keybackup";
33-
import { IHttpOpts } from "../src/http-api";
3433
import { IKeysUploadResponse, IUploadKeysRequest } from '../src/client';
3534

3635
/**
@@ -56,11 +55,11 @@ export class TestClient {
5655
this.httpBackend = new MockHttpBackend();
5756

5857
const fullOptions: ICreateClientOpts = {
59-
baseUrl: "http://" + userId + ".test.server",
58+
baseUrl: "http://" + userId?.slice(1).replace(":", ".") + ".test.server",
6059
userId: userId,
6160
accessToken: accessToken,
6261
deviceId: deviceId,
63-
request: this.httpBackend.requestFn as IHttpOpts["request"],
62+
fetchFn: this.httpBackend.fetchFn as typeof global.fetch,
6463
...options,
6564
};
6665
if (!fullOptions.cryptoStore) {

spec/browserify/setupTests.js renamed to spec/browserify/setupTests.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ limitations under the License.
1515
*/
1616

1717
// stub for browser-matrix browserify tests
18+
// @ts-ignore
1819
global.XMLHttpRequest = jest.fn();
1920

2021
afterAll(() => {
2122
// clean up XMLHttpRequest mock
23+
// @ts-ignore
2224
global.XMLHttpRequest = undefined;
2325
});

0 commit comments

Comments
 (0)