1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
const createElectronStorage = require('redux-persist-electron-storage');
const { ipcRenderer, shell } = require('electron');
const os = require('os');
const url = require('url');
const jitsiMeetElectronUtils = require('jitsi-meet-electron-utils');
const protocolRegex = /^https?:/i;
/**
* Opens the given link in an external browser.
*
* @param {string} link - The link (URL) that should be opened in the external browser.
* @returns {void}
*/
function openExternalLink(link) {
let u;
try {
u = url.parse(link);
} catch (e) {
return;
}
if (protocolRegex.test(u.protocol)) {
shell.openExternal(link);
}
}
const whitelistedIpcChannels = [ 'protocol-data-msg', 'renderer-ready' ];
window.jitsiNodeAPI = {
createElectronStorage,
osUserInfo: os.userInfo,
openExternalLink,
jitsiMeetElectronUtils,
shellOpenExternal: shell.openExternal,
ipc: {
on: (channel, listener) => {
if (!whitelistedIpcChannels.includes(channel)) {
return;
}
return ipcRenderer.on(channel, listener);
},
send: channel => {
if (!whitelistedIpcChannels.includes(channel)) {
return;
}
return ipcRenderer.send(channel);
},
removeListener: (channel, listener) => {
if (!whitelistedIpcChannels.includes(channel)) {
return;
}
return ipcRenderer.removeListener(channel, listener);
}
}
};
|