Browse Source

feat(old-electron-app-notification): Implement

Detects if Jitsi Meet is running in old jitsi-meet-electron app and
warns the user for scurity issues.
master
Hristo Terezov 5 years ago
parent
commit
6ce1eaba24

+ 5
- 1
lang/main.json View File

@@ -460,7 +460,11 @@
460 460
         "unmute": "Unmute",
461 461
         "newDeviceCameraTitle": "New camera detected",
462 462
         "newDeviceAudioTitle": "New audio device detected",
463
-        "newDeviceAction": "Use"
463
+        "newDeviceAction": "Use",
464
+        "OldElectronAPPTitle": "Security vulnerability!",
465
+        "oldElectronClientDescription1": "You appear to be using an old verion of the Jitsi Meet client which has known security vulnerabilities. Please make sure you update to our ",
466
+        "oldElectronClientDescription2": "latest build",
467
+        "oldElectronClientDescription3": " now!"
464 468
     },
465 469
     "passwordSetRemotely": "set by another participant",
466 470
     "passwordDigitsOnly": "Up to {{number}} digits",

+ 1
- 0
react/features/app/components/App.web.js View File

@@ -14,6 +14,7 @@ import '../../power-monitor';
14 14
 import '../../room-lock';
15 15
 import '../../talk-while-muted';
16 16
 import '../../video-layout';
17
+import '../../old-client-notification';
17 18
 
18 19
 import { AbstractApp } from './AbstractApp';
19 20
 

+ 47
- 0
react/features/old-client-notification/components/OldElectronAPPNotificationDescription.js View File

@@ -0,0 +1,47 @@
1
+// @flow
2
+
3
+import React, { Component } from 'react';
4
+import { translate } from '../../base/i18n';
5
+
6
+/**
7
+ * The type of the React {@code Component} props of {@link OldElectronAPPNotificationDescription}.
8
+ */
9
+type Props = {
10
+
11
+    /**
12
+     * Invoked to obtain translated strings.
13
+     */
14
+    t: Function
15
+};
16
+
17
+/**
18
+ * A component that renders the description of the notification for old Jitsi Meet Electron clients.
19
+ *
20
+ * @extends AbstractApp
21
+ */
22
+export class OldElectronAPPNotificationDescription extends Component<Props> {
23
+    /**
24
+     * Implements React's {@link Component#render()}.
25
+     *
26
+     * @inheritdoc
27
+     * @returns {ReactElement}
28
+     */
29
+    render() {
30
+        const { t } = this.props;
31
+
32
+        return (
33
+            <div>
34
+                { t('notify.oldElectronClientDescription1') }
35
+                <a
36
+                    href = 'https://github.com/jitsi/jitsi-meet-electron/releases/latest'
37
+                    rel = 'noopener noreferrer'
38
+                    target = '_blank'>
39
+                    { t('notify.oldElectronClientDescription2') }
40
+                </a>
41
+                { t('notify.oldElectronClientDescription3') }
42
+            </div>);
43
+    }
44
+
45
+}
46
+
47
+export default translate(OldElectronAPPNotificationDescription);

+ 3
- 0
react/features/old-client-notification/components/index.js View File

@@ -0,0 +1,3 @@
1
+// @flow
2
+
3
+export { default as OldElectronAPPNotificationDescription } from './OldElectronAPPNotificationDescription';

+ 28
- 0
react/features/old-client-notification/functions.js View File

@@ -0,0 +1,28 @@
1
+// @flow
2
+
3
+import { browser } from '../../../react/features/base/lib-jitsi-meet';
4
+
5
+/**
6
+ * Returns true if Jitsi Meet is running in too old jitsi-meet-electron app and false otherwise.
7
+ *
8
+ * @returns {boolean} - True if Jitsi Meet is running in too old jitsi-meet-electron app and false otherwise.
9
+ */
10
+export function isOldJitsiMeetElectronApp() {
11
+    if (!browser.isElectron()) {
12
+        return false;
13
+    }
14
+
15
+    const match = navigator.userAgent.match(/(JitsiMeet)\s*\/\s*((\d+)\.[^\s]*)/);
16
+
17
+    if (!Array.isArray(match) || match.length < 3) {
18
+        return false;
19
+    }
20
+
21
+    const majorVersion = Number(match[3]);
22
+
23
+    if (isNaN(majorVersion) || majorVersion >= 2) {
24
+        return false;
25
+    }
26
+
27
+    return true;
28
+}

+ 1
- 0
react/features/old-client-notification/index.js View File

@@ -0,0 +1 @@
1
+import './middleware';

+ 43
- 0
react/features/old-client-notification/middleware.js View File

@@ -0,0 +1,43 @@
1
+// @flow
2
+
3
+import React from 'react';
4
+
5
+import { APP_WILL_MOUNT } from '../base/app';
6
+import { MiddlewareRegistry } from '../base/redux';
7
+import { showErrorNotification } from '../notifications';
8
+
9
+import { isOldJitsiMeetElectronApp } from './functions';
10
+import { OldElectronAPPNotificationDescription } from './components';
11
+
12
+declare var interfaceConfig: Object;
13
+
14
+MiddlewareRegistry.register(store => next => action => {
15
+    switch (action.type) {
16
+    case APP_WILL_MOUNT:
17
+        return _appWillMount(store, next, action);
18
+    }
19
+
20
+    return next(action);
21
+});
22
+
23
+/**
24
+ * Notifies the feature that the action {@link APP_WILL_MOUNT} has being dispatched.
25
+ *
26
+ * @param {Store} store - The redux store in which the specified {@code action} is being dispatched.
27
+ * @param {Dispatch} next - The redux {@code dispatch} function to dispatch the specified {@code action}.
28
+ * @param {Action} action - The redux action {@code APP_WILL_MOUNT} which is being dispatched.
29
+ * @private
30
+ * @returns {Object} The new state that is the result of the reduction of the specified {@code action}.
31
+ */
32
+function _appWillMount(store, next, action) {
33
+    if (isOldJitsiMeetElectronApp()) {
34
+        const { dispatch } = store;
35
+
36
+        dispatch(showErrorNotification({
37
+            titleKey: 'notify.OldElectronAPPTitle',
38
+            description: <OldElectronAPPNotificationDescription />
39
+        }));
40
+    }
41
+
42
+    return next(action);
43
+}

Loading…
Cancel
Save