aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaúl Ibarra Corretgé <s@saghul.net>2022-03-21 13:49:39 +0100
committerSaúl Ibarra Corretgé <s@saghul.net>2022-03-21 14:41:23 +0100
commit180540facbb601c9e7f59db1d4c86696ce4fd01e (patch)
treee7a19cdc9a97c6a4945362f7aa5fc24e909d35b7
parent7ec0304a53f1e97a4f376ab31e14bb2b7ee688e4 (diff)
feat(preload) limit the exposed SDK API surface
Expose a single function that sets up everything on the renderer.
-rw-r--r--app/features/conference/components/Conference.js34
-rw-r--r--app/preload/preload.js44
2 files changed, 45 insertions, 33 deletions
diff --git a/app/features/conference/components/Conference.js b/app/features/conference/components/Conference.js
index 0a9f058..8df1968 100644
--- a/app/features/conference/components/Conference.js
+++ b/app/features/conference/components/Conference.js
@@ -234,35 +234,11 @@ class Conference extends Component<Props, State> {
}
);
- const { RemoteControl,
- setupScreenSharingRender,
- setupAlwaysOnTopRender,
- initPopupsConfigurationRender,
- setupWiFiStats,
- setupPowerMonitorRender
- } = window.jitsiNodeAPI.jitsiMeetElectronUtils;
-
- initPopupsConfigurationRender(this._api);
-
- const iframe = this._api.getIFrame();
-
- setupScreenSharingRender(this._api);
-
- if (ENABLE_REMOTE_CONTROL) {
- new RemoteControl(iframe); // eslint-disable-line no-new
- }
-
- // Allow window to be on top if enabled in settings
- if (this.props._alwaysOnTopWindowEnabled) {
- setupAlwaysOnTopRender(this._api);
- }
-
- // Disable WiFiStats on mac due to jitsi-meet-electron#585
- if (window.jitsiNodeAPI.platform !== 'darwin') {
- setupWiFiStats(iframe);
- }
-
- setupPowerMonitorRender(this._api);
+ // Setup Jitsi Meet Electron SDK on this renderer.
+ window.jitsiNodeAPI.setupRenderer(this._api, {
+ enableRemoteControl: ENABLE_REMOTE_CONTROL,
+ enableAlwaysOnTopWindow: this.props._alwaysOnTopWindowEnabled
+ });
}
/**
diff --git a/app/preload/preload.js b/app/preload/preload.js
index c566835..fad8ea5 100644
--- a/app/preload/preload.js
+++ b/app/preload/preload.js
@@ -1,16 +1,52 @@
/* global process */
const { ipcRenderer } = require('electron');
-const jitsiMeetElectronUtils = require('@jitsi/electron-sdk');
+const { RemoteControl,
+ setupScreenSharingRender,
+ setupAlwaysOnTopRender,
+ initPopupsConfigurationRender,
+ setupWiFiStats,
+ setupPowerMonitorRender
+} = require('@jitsi/electron-sdk');
const { openExternalLink } = require('../features/utils/openExternalLink');
-
+const platform = process.platform;
const whitelistedIpcChannels = [ 'protocol-data-msg', 'renderer-ready' ];
+/**
+ * Setup the renderer process.
+ *
+ * @param {*} api - API object.
+ * @param {*} options - Options for what to enable.
+ * @returns {void}
+ */
+function setupRenderer(api, options = {}) {
+ initPopupsConfigurationRender(api);
+
+ const iframe = api.getIFrame();
+
+ setupScreenSharingRender(api);
+
+ if (options.enableRemoteControl) {
+ new RemoteControl(iframe); // eslint-disable-line no-new
+ }
+
+ // Allow window to be on top if enabled in settings
+ if (options.enableAlwaysOnTopWindow) {
+ setupAlwaysOnTopRender(api);
+ }
+
+ // Disable WiFiStats on mac due to jitsi-meet-electron#585
+ if (platform !== 'darwin') {
+ setupWiFiStats(iframe);
+ }
+
+ setupPowerMonitorRender(api);
+}
+
window.jitsiNodeAPI = {
openExternalLink,
- platform: process.platform,
- jitsiMeetElectronUtils,
+ setupRenderer,
ipc: {
on: (channel, listener) => {
if (!whitelistedIpcChannels.includes(channel)) {