From 5350c5e551120a405e19149ae3ab70d4a9378720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Tue, 13 Oct 2020 16:36:38 +0200 Subject: [PATCH 01/11] electron-platform: Pass the user/devce id pair when initializing the event index. --- src/vector/platform/ElectronPlatform.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vector/platform/ElectronPlatform.tsx b/src/vector/platform/ElectronPlatform.tsx index 1ce7eefde3..ab3fc153c1 100644 --- a/src/vector/platform/ElectronPlatform.tsx +++ b/src/vector/platform/ElectronPlatform.tsx @@ -140,8 +140,8 @@ class SeshatIndexManager extends BaseEventIndexManager { return this._ipcCall('supportsEventIndexing'); } - async initEventIndex(): Promise { - return this._ipcCall('initEventIndex'); + async initEventIndex(user_id: string, device_id: string): Promise { + return this._ipcCall('initEventIndex', user_id, device_id); } async addEventToIndex(ev: MatrixEvent, profile: MatrixProfile): Promise { From 0507cd2d9003858612cc41f1fe2991fb2f1df29d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Tue, 13 Oct 2020 17:04:40 +0200 Subject: [PATCH 02/11] electron-platform: Use camel case for the user/device id. --- src/vector/platform/ElectronPlatform.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vector/platform/ElectronPlatform.tsx b/src/vector/platform/ElectronPlatform.tsx index ab3fc153c1..64835a00d4 100644 --- a/src/vector/platform/ElectronPlatform.tsx +++ b/src/vector/platform/ElectronPlatform.tsx @@ -140,8 +140,8 @@ class SeshatIndexManager extends BaseEventIndexManager { return this._ipcCall('supportsEventIndexing'); } - async initEventIndex(user_id: string, device_id: string): Promise { - return this._ipcCall('initEventIndex', user_id, device_id); + async initEventIndex(userId: string, deviceId: string): Promise { + return this._ipcCall('initEventIndex', userId, deviceId); } async addEventToIndex(ev: MatrixEvent, profile: MatrixProfile): Promise { From 917a85ead9d4c6af1d1ea724738e3472f4a040ee Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 14 Oct 2020 16:16:08 -0600 Subject: [PATCH 03/11] Don't fatally end the Jitsi widget when it's not being used as a widget --- src/vector/jitsi/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vector/jitsi/index.ts b/src/vector/jitsi/index.ts index e1b6a58bc9..e1521f4ee7 100644 --- a/src/vector/jitsi/index.ts +++ b/src/vector/jitsi/index.ts @@ -88,7 +88,7 @@ let meetApi: any; // JitsiMeetExternalAPI ]); widgetApi.start(); } else { - throw new Error("No parent URL or no widget ID"); + console.warn("No parent URL or no widget ID - assuming no widget API is available"); } // Populate the Jitsi params now From 7793f07c814a44151ca8e8d6701380dce22d903e Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Thu, 15 Oct 2020 18:01:38 +0100 Subject: [PATCH 04/11] Document customisation points https://github.com/matrix-org/matrix-react-sdk/pull/5327 adds a concept of "customisation points" to keep custom functionality contained. This adds some general guidance on how to use them. --- docs/customisations.md | 34 ++++++++++++++++++++++++++++++++++ src/customisations/README.md | 1 + 2 files changed, 35 insertions(+) create mode 100644 docs/customisations.md create mode 120000 src/customisations/README.md diff --git a/docs/customisations.md b/docs/customisations.md new file mode 100644 index 0000000000..cea95af478 --- /dev/null +++ b/docs/customisations.md @@ -0,0 +1,34 @@ +# Customisations + +Element Web and the React SDK support "customisation points" that can be used to +easily add custom logic specific to a particular deployment of Element Web. + +An example of this is the [security customisations +module](https://github.com/matrix-org/matrix-react-sdk/blob/develop/src/customisations/Security.ts). +This module in the React SDK only defines some empty functions and their types: +it does not do anything by default. + +To make use of these customisation points, you will first need to fork Element +Web so that you can add your own code. Even though the default module is part of +the React SDK, you can still override it from the Element Web layer: + +1. Copy the default customisation module to + `element-web/src/customisations/YourNameSecurity.js` +2. Edit customisations points and make sure export the ones you actually want to + activate +3. Tweak the Element build process to use the customised module instead of the + default by adding this to end of the `plugins` array in `webpack.config.js`: + +```js +new webpack.NormalModuleReplacementPlugin( + /src\/customisations\/Security.ts/, + path.resolve(__dirname, 'src/customisations/YourNameSecurity.ts'), +), +``` + +If we add more customisation modules in the future, we'll likely improve these +steps to remove the need for build changes like the above. + +By isolating customisations to their own module, this approach should remove the +chance of merge conflicts when updating your fork, and thus simplify ongoing +maintenance. diff --git a/src/customisations/README.md b/src/customisations/README.md new file mode 120000 index 0000000000..d2cbdd09d6 --- /dev/null +++ b/src/customisations/README.md @@ -0,0 +1 @@ +docs/customisations.md \ No newline at end of file From f37b63a6cb9bac0f2078ed265a739551633ee4e6 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Fri, 16 Oct 2020 11:22:28 +0100 Subject: [PATCH 05/11] Fix file extension Co-authored-by: Travis Ralston --- docs/customisations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/customisations.md b/docs/customisations.md index cea95af478..2c36b54f9b 100644 --- a/docs/customisations.md +++ b/docs/customisations.md @@ -13,7 +13,7 @@ Web so that you can add your own code. Even though the default module is part of the React SDK, you can still override it from the Element Web layer: 1. Copy the default customisation module to - `element-web/src/customisations/YourNameSecurity.js` + `element-web/src/customisations/YourNameSecurity.ts` 2. Edit customisations points and make sure export the ones you actually want to activate 3. Tweak the Element build process to use the customised module instead of the From 4053d598f81216596793d628c587ff77929e4ae6 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Fri, 16 Oct 2020 11:32:57 +0100 Subject: [PATCH 06/11] Update README.md link --- src/customisations/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/customisations/README.md b/src/customisations/README.md index d2cbdd09d6..cacf116604 120000 --- a/src/customisations/README.md +++ b/src/customisations/README.md @@ -1 +1 @@ -docs/customisations.md \ No newline at end of file +../../docs/customisations.md \ No newline at end of file From 7f4f9b2cf1f6c84d51decc464b53a3ae8085b7bb Mon Sep 17 00:00:00 2001 From: Sebastian Denz Date: Fri, 16 Oct 2020 14:48:28 +0200 Subject: [PATCH 07/11] Use HTTPS_PROXY environment variable for downloading external_api.min.js if set --- package.json | 1 + scripts/build-jitsi.js | 9 ++++++++- yarn.lock | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c030f45a53..10b146781c 100644 --- a/package.json +++ b/package.json @@ -139,6 +139,7 @@ "postcss-strip-inline-comments": "^0.1.5", "rimraf": "^2.4.3", "shell-escape": "^0.2.0", + "simple-proxy-agent": "^1.1.0", "stylelint": "^12.0.1", "terser-webpack-plugin": "^2.3.0", "typescript": "^3.7.3", diff --git a/scripts/build-jitsi.js b/scripts/build-jitsi.js index 464ec6ea69..fb3f0ddd2b 100644 --- a/scripts/build-jitsi.js +++ b/scripts/build-jitsi.js @@ -7,6 +7,7 @@ const fs = require("fs"); const path = require("path"); const mkdirp = require("mkdirp"); const fetch = require("node-fetch"); +const ProxyAgent = require("simple-proxy-agent"); console.log("Making webapp directory"); mkdirp.sync("webapp"); @@ -14,7 +15,13 @@ mkdirp.sync("webapp"); // curl -s https://jitsi.riot.im/libs/external_api.min.js > ./webapp/jitsi_external_api.min.js console.log("Downloading Jitsi script"); const fname = path.join("webapp", "jitsi_external_api.min.js"); -fetch("https://jitsi.riot.im/libs/external_api.min.js").then(res => { + +const options = {}; +if (process.env.HTTPS_PROXY) { + options.agent = new ProxyAgent(process.env.HTTPS_PROXY, { tunnel : true } ); +} + +fetch("https://jitsi.riot.im/libs/external_api.min.js", options).then(res => { const stream = fs.createWriteStream(fname); return new Promise((resolve, reject) => { res.body.pipe(stream); diff --git a/yarn.lock b/yarn.lock index d7beb0cc88..4aeeb3d694 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11286,6 +11286,13 @@ simple-get@^3.0.3: once "^1.3.1" simple-concat "^1.0.0" +simple-proxy-agent@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/simple-proxy-agent/-/simple-proxy-agent-1.1.0.tgz#974cd1130dd32554775e2d4caeb70d701f7ca8b3" + integrity sha512-amJaLagzNELaNNB2UXdXiORVbbU/RC4yRwtGvF4cttJheTm4JvL2fZ1SfuLU952XC7TLamYdgzzJtWUbGM6Jcw== + dependencies: + socks "^2.3.2" + simple-swizzle@^0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a" @@ -11386,6 +11393,14 @@ socks-proxy-agent@^4.0.0: agent-base "~4.2.1" socks "~2.3.2" +socks@^2.3.2: + version "2.4.4" + resolved "https://registry.yarnpkg.com/socks/-/socks-2.4.4.tgz#f1a3382e7814ae28c97bb82a38bc1ac24b21cca2" + integrity sha512-7LmHN4IHj1Vpd/k8D872VGCHJ6yIVyeFkfIBExRmGPYQ/kdUkpdg9eKh9oOzYYYKQhuxavayJHTnmBG+EzluUA== + dependencies: + ip "^1.1.5" + smart-buffer "^4.1.0" + socks@~2.3.2: version "2.3.3" resolved "https://registry.yarnpkg.com/socks/-/socks-2.3.3.tgz#01129f0a5d534d2b897712ed8aceab7ee65d78e3" From 44bf49d41459497808a7947a0352a5cc217e016d Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 16 Oct 2020 13:15:08 -0600 Subject: [PATCH 08/11] Update scripts/build-jitsi.js --- scripts/build-jitsi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-jitsi.js b/scripts/build-jitsi.js index fb3f0ddd2b..3f2ba29906 100644 --- a/scripts/build-jitsi.js +++ b/scripts/build-jitsi.js @@ -18,7 +18,7 @@ const fname = path.join("webapp", "jitsi_external_api.min.js"); const options = {}; if (process.env.HTTPS_PROXY) { - options.agent = new ProxyAgent(process.env.HTTPS_PROXY, { tunnel : true } ); + options.agent = new ProxyAgent(process.env.HTTPS_PROXY, {tunnel: true}); } fetch("https://jitsi.riot.im/libs/external_api.min.js", options).then(res => { From dfb1579625d31c2475daf839f6d0b72815aee0f2 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Mon, 19 Oct 2020 16:43:55 +0100 Subject: [PATCH 09/11] Adjust for new widget messaging APIs As part of changing to the `events` package, the API surface changed slightly. Related to https://github.com/vector-im/element-web/issues/15493 --- src/vector/jitsi/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vector/jitsi/index.ts b/src/vector/jitsi/index.ts index e1521f4ee7..aa8cb6585c 100644 --- a/src/vector/jitsi/index.ts +++ b/src/vector/jitsi/index.ts @@ -76,7 +76,7 @@ let meetApi: any; // JitsiMeetExternalAPI widgetApi.requestCapabilities(VideoConferenceCapabilities); readyPromise = Promise.all([ new Promise(resolve => { - widgetApi.once>(`action:${ElementWidgetActions.ClientReady}`, ev => { + widgetApi.once(`action:${ElementWidgetActions.ClientReady}`, ev => { ev.preventDefault(); widgetApi.transport.reply(ev.detail, {}); resolve(); @@ -113,7 +113,7 @@ let meetApi: any; // JitsiMeetExternalAPI // TODO: register widgetApi listeners for PTT controls (https://github.com/vector-im/riot-web/issues/12795) - widgetApi.addEventListener(`action:${ElementWidgetActions.HangupCall}`, + widgetApi.on(`action:${ElementWidgetActions.HangupCall}`, (ev: CustomEvent) => { if (meetApi) meetApi.executeCommand('hangup'); widgetApi.transport.reply(ev.detail, {}); // ack From 0f76c858acc3995a68990550e62b5849c49e8f98 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Mon, 19 Oct 2020 16:57:18 +0100 Subject: [PATCH 10/11] Upgrade widget API --- package.json | 2 +- yarn.lock | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 10b146781c..8a06b3c582 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "jsrsasign": "^9.1.5", "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#develop", "matrix-react-sdk": "github:matrix-org/matrix-react-sdk#develop", - "matrix-widget-api": "^0.1.0-beta.2", + "matrix-widget-api": "^0.1.0-beta.5", "olm": "https://packages.matrix.org/npm/olm/olm-3.2.1.tgz", "prop-types": "^15.7.2", "react": "^16.9.0", diff --git a/yarn.lock b/yarn.lock index 4aeeb3d694..dc898b10e2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4783,6 +4783,11 @@ events@^3.0.0: resolved "https://registry.yarnpkg.com/events/-/events-3.1.0.tgz#84279af1b34cb75aa88bf5ff291f6d0bd9b31a59" integrity sha512-Rv+u8MLHNOdMjTAFeT3nCjHn2aGlx435FP/sDHNaRhDEMwyI/aB22Kj2qIN8R0cw3z28psEQLYwxVKLsKrMgWg== +events@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/events/-/events-3.2.0.tgz#93b87c18f8efcd4202a461aec4dfc0556b639379" + integrity sha512-/46HWwbfCX2xTawVfkKLGxMifJYQBWMwY1mjywRtb4c9x8l5NP3KoJtnIOiL1hfdRkIuYhETxQlo62IF8tcnlg== + eventsource@^1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/eventsource/-/eventsource-1.0.7.tgz#8fbc72c93fcd34088090bc0a4e64f4b5cee6d8d0" @@ -7980,16 +7985,18 @@ matrix-react-test-utils@^0.2.2: resolved "https://registry.yarnpkg.com/matrix-react-test-utils/-/matrix-react-test-utils-0.2.2.tgz#c87144d3b910c7edc544a6699d13c7c2bf02f853" integrity sha512-49+7gfV6smvBIVbeloql+37IeWMTD+fiywalwCqk8Dnz53zAFjKSltB3rmWHso1uecLtQEcPtCijfhzcLXAxTQ== -matrix-widget-api@^0.1.0-beta.2: - version "0.1.0-beta.2" - resolved "https://registry.yarnpkg.com/matrix-widget-api/-/matrix-widget-api-0.1.0-beta.2.tgz#367da1ccd26b711f73fc5b6e02edf55ac2ea2692" - integrity sha512-q5g5RZN+RRjM4HmcJ+LYoQAYrB1wzyERmoQ+LvKbTV/+9Ov36Kp0QEP8CleSXEd5WLp6bkRlt60axDaY6pWGmg== - matrix-widget-api@^0.1.0-beta.3: version "0.1.0-beta.3" resolved "https://registry.yarnpkg.com/matrix-widget-api/-/matrix-widget-api-0.1.0-beta.3.tgz#356965ca357172ee056e3fd86fd96879b059a114" integrity sha512-j7nxdhLQfdU6snsdBA29KQR0DmT8/vl6otOvGqPCV0OCHpq1312cP79Eg4JzJKIFI3A76Qha3nYx6G9/aapwXg== +matrix-widget-api@^0.1.0-beta.5: + version "0.1.0-beta.5" + resolved "https://registry.yarnpkg.com/matrix-widget-api/-/matrix-widget-api-0.1.0-beta.5.tgz#dd7f24a177aa590d812bd4e92e2c3ac225c5557e" + integrity sha512-J3GBJtVMFuEM/EWFylc0IlkPjdgmWxrkGYPaZ0LSmxp+OlNJxYfnWPR6F6HveW+Z8C1i0vq+BTueofSqKv2zDg== + dependencies: + events "^3.2.0" + md5.js@^1.3.4: version "1.3.5" resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f" From 06aa5a9aa9128459c050b139dd74aecf634d0100 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Mon, 19 Oct 2020 17:08:07 +0100 Subject: [PATCH 11/11] Shake lock file --- yarn.lock | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/yarn.lock b/yarn.lock index dc898b10e2..71d4365993 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4778,12 +4778,7 @@ eventemitter3@^4.0.0: resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.4.tgz#b5463ace635a083d018bdc7c917b4c5f10a85384" integrity sha512-rlaVLnVxtxvoyLsQQFBx53YmXHDxRIzzTLbdfxqi4yocpSjAxXwkU0cScM5JgSKMqEhrZpnvQ2D9gjylR0AimQ== -events@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/events/-/events-3.1.0.tgz#84279af1b34cb75aa88bf5ff291f6d0bd9b31a59" - integrity sha512-Rv+u8MLHNOdMjTAFeT3nCjHn2aGlx435FP/sDHNaRhDEMwyI/aB22Kj2qIN8R0cw3z28psEQLYwxVKLsKrMgWg== - -events@^3.2.0: +events@^3.0.0, events@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/events/-/events-3.2.0.tgz#93b87c18f8efcd4202a461aec4dfc0556b639379" integrity sha512-/46HWwbfCX2xTawVfkKLGxMifJYQBWMwY1mjywRtb4c9x8l5NP3KoJtnIOiL1hfdRkIuYhETxQlo62IF8tcnlg== @@ -7985,12 +7980,7 @@ matrix-react-test-utils@^0.2.2: resolved "https://registry.yarnpkg.com/matrix-react-test-utils/-/matrix-react-test-utils-0.2.2.tgz#c87144d3b910c7edc544a6699d13c7c2bf02f853" integrity sha512-49+7gfV6smvBIVbeloql+37IeWMTD+fiywalwCqk8Dnz53zAFjKSltB3rmWHso1uecLtQEcPtCijfhzcLXAxTQ== -matrix-widget-api@^0.1.0-beta.3: - version "0.1.0-beta.3" - resolved "https://registry.yarnpkg.com/matrix-widget-api/-/matrix-widget-api-0.1.0-beta.3.tgz#356965ca357172ee056e3fd86fd96879b059a114" - integrity sha512-j7nxdhLQfdU6snsdBA29KQR0DmT8/vl6otOvGqPCV0OCHpq1312cP79Eg4JzJKIFI3A76Qha3nYx6G9/aapwXg== - -matrix-widget-api@^0.1.0-beta.5: +matrix-widget-api@^0.1.0-beta.3, matrix-widget-api@^0.1.0-beta.5: version "0.1.0-beta.5" resolved "https://registry.yarnpkg.com/matrix-widget-api/-/matrix-widget-api-0.1.0-beta.5.tgz#dd7f24a177aa590d812bd4e92e2c3ac225c5557e" integrity sha512-J3GBJtVMFuEM/EWFylc0IlkPjdgmWxrkGYPaZ0LSmxp+OlNJxYfnWPR6F6HveW+Z8C1i0vq+BTueofSqKv2zDg==