Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(visitors): Adds an option to request to be visitor based on jwt. (#13977)
Дамян Минков07b903d8873e
diff --git a/package-lock.json b/package-lock.jsonindex ae0892fd02..308255efbf 100644--- a/package-lock.json+++ b/package-lock.json@@ -59,7 +59,7 @@"js-md5": "0.6.1","js-sha512": "0.8.0","jwt-decode": "2.2.0",- "lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1704.0.0+d3efd197/lib-jitsi-meet.tgz",+ "lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1711.0.0+8ec3b736/lib-jitsi-meet.tgz","lodash": "4.17.21","moment": "2.29.4","moment-duration-format": "2.2.2",@@ -12756,8 +12756,8 @@},"node_modules/lib-jitsi-meet": {"version": "0.0.0",- "resolved": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1704.0.0+d3efd197/lib-jitsi-meet.tgz",- "integrity": "sha512-wEXm6xGT59AcQgOvqJ5MIEZiy/tbQ0KGIp6dsmb7Gz3a0dVsVz95n3x0lx+6AlxT1OJj+hzXV7rrMDeDMrRrtQ==",+ "resolved": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1711.0.0+8ec3b736/lib-jitsi-meet.tgz",+ "integrity": "sha512-4/DjRs+z9Cch4QgRXmK3enI+6bzwPoJeDUFOBOSvwf1y55Ze7zvJOLxp0pWbdIzrGKgwSG9wAd8y63DVu1+Rgg==","hasInstallScript": true,"license": "Apache-2.0","dependencies": {@@ -29776,8 +29776,8 @@}},"lib-jitsi-meet": {- "version": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1704.0.0+d3efd197/lib-jitsi-meet.tgz",- "integrity": "sha512-wEXm6xGT59AcQgOvqJ5MIEZiy/tbQ0KGIp6dsmb7Gz3a0dVsVz95n3x0lx+6AlxT1OJj+hzXV7rrMDeDMrRrtQ==",+ "version": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1711.0.0+8ec3b736/lib-jitsi-meet.tgz",+ "integrity": "sha512-4/DjRs+z9Cch4QgRXmK3enI+6bzwPoJeDUFOBOSvwf1y55Ze7zvJOLxp0pWbdIzrGKgwSG9wAd8y63DVu1+Rgg==","requires": {"@jitsi/js-utils": "2.2.1","@jitsi/logger": "2.0.2",diff --git a/package.json b/package.jsonindex 8d76c96ddd..3d0f1b2348 100644--- a/package.json+++ b/package.json@@ -65,7 +65,7 @@"js-md5": "0.6.1","js-sha512": "0.8.0","jwt-decode": "2.2.0",- "lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1704.0.0+d3efd197/lib-jitsi-meet.tgz",+ "lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1711.0.0+8ec3b736/lib-jitsi-meet.tgz","lodash": "4.17.21","moment": "2.29.4","moment-duration-format": "2.2.2",diff --git a/react/features/base/connection/actions.any.ts b/react/features/base/connection/actions.any.tsindex 0e0fb41270..aa62450598 100644--- a/react/features/base/connection/actions.any.ts+++ b/react/features/base/connection/actions.any.ts@@ -27,6 +27,7 @@ import { ConnectionFailedError, IIceServers } from './types';*/interface IOptions extends IConfigState {iceServersOverride?: IIceServers;+ preferVisitor?: boolean;}/**@@ -112,7 +113,7 @@ export function constructOptions(state: IReduxState) {// redux store.const options: IOptions = _.cloneDeep(state['features/base/config']);- const { locationURL } = state['features/base/connection'];+ const { locationURL, preferVisitor } = state['features/base/connection'];const params = parseURLParams(locationURL || '');const iceServersOverride = params['iceServers.replace'];@@ -155,6 +156,10 @@ export function constructOptions(state: IReduxState) {}}+ if (preferVisitor) {+ options.preferVisitor = true;+ }+return options;}diff --git a/react/features/base/connection/reducer.ts b/react/features/base/connection/reducer.tsindex 8801f20a17..bb734f1d63 100644--- a/react/features/base/connection/reducer.ts+++ b/react/features/base/connection/reducer.ts@@ -1,4 +1,5 @@import { SET_ROOM } from '../conference/actionTypes';+import { SET_JWT } from '../jwt/actionTypes';import { JitsiConnectionErrors } from '../lib-jitsi-meet';import ReducerRegistry from '../redux/ReducerRegistry';import { assign, set } from '../redux/functions';@@ -26,6 +27,7 @@ export interface IConnectionState {error?: ConnectionFailedError;locationURL?: URL;passwordRequired?: Object;+ preferVisitor?: boolean;showConnectionInfo?: boolean;timeEstablished?: number;}@@ -49,6 +51,9 @@ ReducerRegistry.register<IConnectionState>(case CONNECTION_WILL_CONNECT:return _connectionWillConnect(state, action);+ case SET_JWT:+ return _setJWT(state, action);+case SET_LOCATION_URL:return _setLocationURL(state, action);@@ -84,6 +89,7 @@ function _connectionDisconnected(return assign(state, {connecting: undefined,connection: undefined,+ preferVisitor: undefined,timeEstablished: undefined});}@@ -141,7 +147,8 @@ function _connectionFailed(error,passwordRequired:error.name === JitsiConnectionErrors.PASSWORD_REQUIRED- ? connection : undefined+ ? connection : undefined,+ preferVisitor: undefined});}@@ -184,6 +191,22 @@ function _getCurrentConnection(baseConnectionState: IConnectionState): IConnectireturn baseConnectionState.connection || baseConnectionState.connecting;}+/**+ * Reduces a specific redux action {@link SET_JWT} of the feature+ * base/connection.+ *+ * @param {IConnectionState} state - The redux state of the feature base/connection.+ * @param {Action} action - The Redux action SET_JWT to reduce.+ * @private+ * @returns {Object} The new state of the feature base/connection after the+ * reduction of the specified action.+ */+function _setJWT(state: IConnectionState, { preferVisitor }: { preferVisitor: boolean; }) {+ return assign(state, {+ preferVisitor+ });+}+/*** Reduces a specific redux action {@link SET_LOCATION_URL} of the feature* base/connection.diff --git a/react/features/base/jwt/middleware.ts b/react/features/base/jwt/middleware.tsindex 80f0067349..4e52d8dd9d 100644--- a/react/features/base/jwt/middleware.ts+++ b/react/features/base/jwt/middleware.ts@@ -153,6 +153,11 @@ function _setJWT(store: IStore, next: Function, action: AnyAction) {_overwriteLocalParticipant(store, { ...newUser,features: context.features });++ // eslint-disable-next-line max-depth+ if (context.user && context.user.role === 'visitor') {+ action.preferVisitor = true;+ }} else if (jwtPayload.name || jwtPayload.picture || jwtPayload.email) {// there are some tokens (firebase) having picture and name on the main level._overwriteLocalParticipant(store, {