Просмотр исходного кода

feat(authentication): group config options inside an object param

factor2
Calin-Teodor 1 год назад
Родитель
Сommit
b09574f62f

+ 8
- 6
react/features/app/actions.any.ts Просмотреть файл

128
         const { tenant } = parseURIString(locationURL.href) || {};
128
         const { tenant } = parseURIString(locationURL.href) || {};
129
 
129
 
130
         getTokenAuthUrl(
130
         getTokenAuthUrl(
131
-            audioMuted,
132
-            audioOnlyEnabled || startAudioOnly,
133
             config,
131
             config,
134
-            room,
135
-            tenant,
136
-            true,
137
             locationURL,
132
             locationURL,
138
-            videoMuted
133
+            {
134
+                audioMuted,
135
+                audioOnlyEnabled: audioOnlyEnabled || startAudioOnly,
136
+                skipPrejoin: true,
137
+                videoMuted
138
+            },
139
+            room,
140
+            tenant
139
         )
141
         )
140
             .then((tokenAuthServiceUrl: string | undefined) => {
142
             .then((tokenAuthServiceUrl: string | undefined) => {
141
                 if (!tokenAuthServiceUrl) {
143
                 if (!tokenAuthServiceUrl) {

+ 12
- 1
react/features/app/getRouteToRender.web.ts Просмотреть файл

57
         const { tenant } = parseURIString(locationURL.href) || {};
57
         const { tenant } = parseURIString(locationURL.href) || {};
58
         const { startAudioOnly } = config;
58
         const { startAudioOnly } = config;
59
 
59
 
60
-        return getTokenAuthUrl(false, startAudioOnly, config, room, tenant, false, locationURL, false)
60
+        return getTokenAuthUrl(
61
+            config,
62
+            locationURL,
63
+            {
64
+                audioMuted: false,
65
+                audioOnlyEnabled: startAudioOnly,
66
+                skipPrejoin: false,
67
+                videoMuted: false
68
+            },
69
+            room,
70
+            tenant
71
+        )
61
             .then((url: string | undefined) => {
72
             .then((url: string | undefined) => {
62
                 route.href = url;
73
                 route.href = url;
63
 
74
 

+ 23
- 12
react/features/authentication/functions.any.ts Просмотреть файл

13
 /**
13
 /**
14
  * Returns the state that we can add as a parameter to the tokenAuthUrl.
14
  * Returns the state that we can add as a parameter to the tokenAuthUrl.
15
  *
15
  *
16
- * @param {boolean} audioMuted - Start conference with audio muted.
17
- * @param {boolean} audioOnlyEnabled - Join conference audio only.
16
+ * @param {URL} locationURL - The location URL.
17
+ * @param {Object} options: - Config options {
18
+ *     audioMuted: boolean | undefined
19
+ *     audioOnlyEnabled: boolean | undefined,
20
+ *     skipPrejoin: boolean | undefined,
21
+ *     videoMuted: boolean | undefined
22
+ * }.
18
  * @param {string?} roomName - The room name.
23
  * @param {string?} roomName - The room name.
19
  * @param {string?} tenant - The tenant name if any.
24
  * @param {string?} tenant - The tenant name if any.
20
- * @param {boolean} skipPrejoin - Whether to skip pre-join page.
21
- * @param {URL} locationURL - The location URL.
22
- * @param {boolean} videoMuted - Start conference with video muted.
25
+ *
23
  * @returns {Object} The state object.
26
  * @returns {Object} The state object.
24
  */
27
  */
25
 export const _getTokenAuthState = (
28
 export const _getTokenAuthState = (
26
-        audioMuted: boolean | undefined = false,
27
-        audioOnlyEnabled: boolean | undefined = false,
28
-        roomName: string | undefined,
29
-        tenant: string | undefined,
30
-        skipPrejoin: boolean | undefined = false,
31
         locationURL: URL,
29
         locationURL: URL,
32
-        // eslint-disable-next-line max-params
33
-        videoMuted: boolean | undefined = false): object => {
30
+        options: {
31
+            audioMuted: boolean | undefined;
32
+            audioOnlyEnabled: boolean | undefined;
33
+            skipPrejoin: boolean | undefined;
34
+            videoMuted: boolean | undefined;
35
+        },
36
+        roomName: string | undefined,
37
+        tenant: string | undefined): object => {
34
     const state = {
38
     const state = {
35
         room: roomName,
39
         room: roomName,
36
         roomSafe: getBackendSafeRoomName(roomName),
40
         roomSafe: getBackendSafeRoomName(roomName),
37
         tenant
41
         tenant
38
     };
42
     };
39
 
43
 
44
+    const {
45
+        audioMuted = false,
46
+        audioOnlyEnabled = false,
47
+        skipPrejoin = false,
48
+        videoMuted = false
49
+    } = options;
50
+
40
     if (audioMuted) {
51
     if (audioMuted) {
41
 
52
 
42
         // @ts-ignore
53
         // @ts-ignore

+ 31
- 18
react/features/authentication/functions.native.ts Просмотреть файл

13
  * '{room}' - name of the conference room passed as <tt>roomName</tt>
13
  * '{room}' - name of the conference room passed as <tt>roomName</tt>
14
  * argument to this method.
14
  * argument to this method.
15
  *
15
  *
16
- * @param {boolean} audioMuted - Start conference with audio muted.
17
- * @param {boolean} audioOnlyEnabled - Join conference audio only.
18
  * @param {Object} config - Configuration state object from store. A URL pattern pointing to the login service.
16
  * @param {Object} config - Configuration state object from store. A URL pattern pointing to the login service.
19
- * @param {string} roomName - The name of the conference room for which the user will be authenticated.
20
- * @param {string} tenant - The name of the conference tenant.
21
- * @param {boolean} skipPrejoin - Whether to skip pre-join page.
22
  * @param {URL} locationURL - The location URL.
17
  * @param {URL} locationURL - The location URL.
23
- * @param {boolean} videoMuted - Start conference with video muted.
18
+ * @param {Object} options:  - Config options {
19
+ *     audioMuted: boolean | undefined
20
+ *     audioOnlyEnabled: boolean | undefined,
21
+ *     skipPrejoin: boolean | undefined,
22
+ *     videoMuted: boolean | undefined
23
+ * }.
24
+ * @param {string?} roomName - The room name.
25
+ * @param {string?} tenant - The tenant name if any.
24
  *
26
  *
25
  * @returns {Promise<string|undefined>} - The URL pointing to JWT login service or
27
  * @returns {Promise<string|undefined>} - The URL pointing to JWT login service or
26
  * <tt>undefined</tt> if the pattern stored in config is not a string and the URL can not be
28
  * <tt>undefined</tt> if the pattern stored in config is not a string and the URL can not be
27
  * constructed.
29
  * constructed.
28
  */
30
  */
29
 export const getTokenAuthUrl = (
31
 export const getTokenAuthUrl = (
30
-        audioMuted: boolean | undefined = false,
31
-        audioOnlyEnabled: boolean | undefined = false,
32
         config: IConfig,
32
         config: IConfig,
33
-        roomName: string | undefined,
34
-        tenant: string | undefined,
35
-        skipPrejoin: boolean | undefined = false,
36
         locationURL: URL,
33
         locationURL: URL,
34
+        options: {
35
+            audioMuted: boolean | undefined;
36
+            audioOnlyEnabled: boolean | undefined;
37
+            skipPrejoin: boolean | undefined;
38
+            videoMuted: boolean | undefined;
39
+        },
40
+        roomName: string | undefined,
37
         // eslint-disable-next-line max-params
41
         // eslint-disable-next-line max-params
38
-        videoMuted: boolean | undefined = false): Promise<string | undefined> => {
42
+        tenant: string | undefined): Promise<string | undefined> => {
43
+
44
+    const {
45
+        audioMuted = false,
46
+        audioOnlyEnabled = false,
47
+        skipPrejoin = false,
48
+        videoMuted = false
49
+    } = options;
39
 
50
 
40
     let url = config.tokenAuthUrl;
51
     let url = config.tokenAuthUrl;
41
 
52
 
45
 
56
 
46
     if (url.indexOf('{state}')) {
57
     if (url.indexOf('{state}')) {
47
         const state = _getTokenAuthState(
58
         const state = _getTokenAuthState(
48
-            audioMuted,
49
-            audioOnlyEnabled,
50
-            roomName,
51
-            tenant,
52
-            skipPrejoin,
53
             locationURL,
59
             locationURL,
54
-            videoMuted
60
+            {
61
+                audioMuted,
62
+                audioOnlyEnabled,
63
+                skipPrejoin,
64
+                videoMuted
65
+            },
66
+            roomName,
67
+            tenant
55
         );
68
         );
56
 
69
 
57
         // Append ios=true or android=true to the token URL.
70
         // Append ios=true or android=true to the token URL.

+ 32
- 19
react/features/authentication/functions.web.ts Просмотреть файл

31
  * '{room}' - name of the conference room passed as <tt>roomName</tt>
31
  * '{room}' - name of the conference room passed as <tt>roomName</tt>
32
  * argument to this method.
32
  * argument to this method.
33
  *
33
  *
34
- * @param {boolean} audioMuted - Start conference with audio muted.
35
- * @param {boolean} audioOnlyEnabled - Join conference audio only.
36
  * @param {Object} config - Configuration state object from store. A URL pattern pointing to the login service.
34
  * @param {Object} config - Configuration state object from store. A URL pattern pointing to the login service.
37
- * @param {string} roomName - The name of the conference room for which the user will be authenticated.
38
- * @param {string} tenant - The name of the conference tenant.
39
- * @param {boolean} skipPrejoin - Whether to skip pre-join page.
40
- * @param {URL} locationURL - The current location URL.
41
- * @param {boolean} videoMuted - Start conference with video muted.
35
+ * @param {URL} locationURL - The location URL.
36
+ * @param {Object} options:  - Config options {
37
+ *     audioMuted: boolean | undefined
38
+ *     audioOnlyEnabled: boolean | undefined,
39
+ *     skipPrejoin: boolean | undefined,
40
+ *     videoMuted: boolean | undefined
41
+ * }.
42
+ * @param {string?} roomName - The room name.
43
+ * @param {string?} tenant - The tenant name if any.
42
  *
44
  *
43
  * @returns {Promise<string|undefined>} - The URL pointing to JWT login service or
45
  * @returns {Promise<string|undefined>} - The URL pointing to JWT login service or
44
  * <tt>undefined</tt> if the pattern stored in config is not a string and the URL can not be
46
  * <tt>undefined</tt> if the pattern stored in config is not a string and the URL can not be
45
  * constructed.
47
  * constructed.
46
  */
48
  */
47
 export const getTokenAuthUrl = (
49
 export const getTokenAuthUrl = (
48
-        audioMuted: boolean | undefined = false,
49
-        audioOnlyEnabled: boolean | undefined = false,
50
         config: IConfig,
50
         config: IConfig,
51
-        roomName: string | undefined,
52
-        tenant: string | undefined,
53
-        skipPrejoin: boolean | undefined = false,
54
         locationURL: URL,
51
         locationURL: URL,
52
+        options: {
53
+            audioMuted: boolean | undefined;
54
+            audioOnlyEnabled: boolean | undefined;
55
+            skipPrejoin: boolean | undefined;
56
+            videoMuted: boolean | undefined;
57
+        },
58
+        roomName: string | undefined,
55
         // eslint-disable-next-line max-params
59
         // eslint-disable-next-line max-params
56
-        videoMuted: boolean | undefined = false): Promise<string | undefined> => {
60
+        tenant: string | undefined): Promise<string | undefined> => {
61
+
62
+    const {
63
+        audioMuted = false,
64
+        audioOnlyEnabled = false,
65
+        skipPrejoin = false,
66
+        videoMuted = false
67
+    } = options;
57
 
68
 
58
     let url = config.tokenAuthUrl;
69
     let url = config.tokenAuthUrl;
59
 
70
 
63
 
74
 
64
     if (url.indexOf('{state}')) {
75
     if (url.indexOf('{state}')) {
65
         const state = _getTokenAuthState(
76
         const state = _getTokenAuthState(
66
-            audioMuted,
67
-            audioOnlyEnabled,
68
-            roomName,
69
-            tenant,
70
-            skipPrejoin,
71
             locationURL,
77
             locationURL,
72
-            videoMuted
78
+            {
79
+                audioMuted,
80
+                audioOnlyEnabled,
81
+                skipPrejoin,
82
+                videoMuted
83
+            },
84
+            roomName,
85
+            tenant
73
         );
86
         );
74
 
87
 
75
         if (browser.isElectron()) {
88
         if (browser.isElectron()) {

+ 12
- 1
react/features/authentication/middleware.ts Просмотреть файл

275
         return;
275
         return;
276
     }
276
     }
277
 
277
 
278
-    getTokenAuthUrl(audioMuted, audioOnlyEnabled, config, room, tenant, true, locationURL, videoMuted)
278
+    getTokenAuthUrl(
279
+        config,
280
+        locationURL,
281
+        {
282
+            audioMuted,
283
+            audioOnlyEnabled,
284
+            skipPrejoin: true,
285
+            videoMuted
286
+        },
287
+        room,
288
+        tenant
289
+    )
279
         .then((tokenAuthServiceUrl: string | undefined) => {
290
         .then((tokenAuthServiceUrl: string | undefined) => {
280
             if (!tokenAuthServiceUrl) {
291
             if (!tokenAuthServiceUrl) {
281
                 logger.warn('Cannot handle login, token service URL is not set');
292
                 logger.warn('Cannot handle login, token service URL is not set');

Загрузка…
Отмена
Сохранить