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(iframe-api): replace ice servers
Hristo Terezova2624952a0d3
diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.jsindex eb1c0b2403..283dc6508e 100644--- a/modules/API/external/external_api.js+++ b/modules/API/external/external_api.js@@ -305,6 +305,9 @@ export default class JitsiMeetExternalAPI extends EventEmitter {* configuration options defined in config.js to be overridden.* @param {Object} [options.interfaceConfigOverwrite] - Object containing* configuration options defined in interface_config.js to be overridden.+ * @param {IIceServers} [options.iceServers] - Object with rules that will be used to modify/remove the existing+ * ice server configuration.+ * NOTE: This property is currently experimental and may be removed in the future!* @param {string} [options.jwt] - The JWT token if needed by jitsi-meet for* authentication.* @param {string} [options.lang] - The meeting's default language.@@ -334,6 +337,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter {lang = undefined,onload = undefined,invitees,+ iceServers,devices,userInfo,e2eeKey,@@ -345,6 +349,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter {this._parentNode = parentNode;this._url = generateURL(domain, {configOverwrite,+ iceServers,interfaceConfigOverwrite,jwt,lang,diff --git a/react/features/base/connection/actions.any.ts b/react/features/base/connection/actions.any.tsindex 49e4fcc13d..49bbc9c9c8 100644--- a/react/features/base/connection/actions.any.ts+++ b/react/features/base/connection/actions.any.ts@@ -3,7 +3,9 @@ import _ from 'lodash';import { IReduxState, IStore } from '../../app/types';import { conferenceLeft, conferenceWillLeave, redirect } from '../conference/actions';import { getCurrentConference } from '../conference/functions';+import { IConfigState } from '../config/reducer';import JitsiMeetJS, { JitsiConnectionEvents } from '../lib-jitsi-meet';+import { parseURLParams } from '../util/parseURLParams';import {appendURLParam,getBackendSafeRoomName@@ -18,53 +20,14 @@ import {} from './actionTypes';import { JITSI_CONNECTION_URL_KEY } from './constants';import logger from './logger';+import { ConnectionFailedError, IIceServers } from './types';/**- * The error structure passed to the {@link connectionFailed} action.- *- * Note there was an intention to make the error resemble an Error instance (to- * the extent that jitsi-meet needs it).+ * The options that will be passed to the JitsiConnection instance.*/-export type ConnectionFailedError = {-- /**- * The invalid credentials that were used to authenticate and the- * authentication failed.- */- credentials?: {-- /**- * The XMPP user's ID.- */- jid: string;-- /**- * The XMPP user's password.- */- password: string;- };-- /**- * The details about the connection failed event.- */- details?: Object;-- /**- * Error message.- */- message?: string;-- /**- * One of {@link JitsiConnectionError} constants (defined in- * lib-jitsi-meet).- */- name: string;-- /**- * Indicates whether this event is recoverable or not.- */- recoverable?: boolean;-};+interface IOptions extends IConfigState {+ iceServersOverride?: IIceServers;+}/*** Create an action for when the signaling connection has been lost.@@ -147,7 +110,15 @@ export function connectionFailed(export function constructOptions(state: IReduxState) {// Deep clone the options to make sure we don't modify the object in the// redux store.- const options = _.cloneDeep(state['features/base/config']);+ const options: IOptions = _.cloneDeep(state['features/base/config']);++ const { locationURL } = state['features/base/connection'];+ const params = parseURLParams(locationURL || '');+ const iceServersOverride = params['iceServers.replace'];++ if (iceServersOverride) {+ options.iceServersOverride = iceServersOverride;+ }const { bosh } = options;let { websocket } = options;diff --git a/react/features/base/connection/reducer.ts b/react/features/base/connection/reducer.tsindex cf5e5443f5..8801f20a17 100644--- a/react/features/base/connection/reducer.ts+++ b/react/features/base/connection/reducer.ts@@ -11,7 +11,7 @@ import {SET_LOCATION_URL,SHOW_CONNECTION_INFO} from './actionTypes';-import { ConnectionFailedError } from './actions.any';+import { ConnectionFailedError } from './types';export interface IConnectionState {connecting?: any;diff --git a/react/features/base/connection/types.ts b/react/features/base/connection/types.tsnew file mode 100644index 0000000000..cebc2516ac--- /dev/null+++ b/react/features/base/connection/types.ts@@ -0,0 +1,113 @@+/**+ * The error structure passed to the {@link connectionFailed} action.+ *+ * Note there was an intention to make the error resemble an Error instance (to+ * the extent that jitsi-meet needs it).+ */+export type ConnectionFailedError = {++ /**+ * The invalid credentials that were used to authenticate and the+ * authentication failed.+ */+ credentials?: {++ /**+ * The XMPP user's ID.+ */+ jid: string;++ /**+ * The XMPP user's password.+ */+ password: string;+ };++ /**+ * The details about the connection failed event.+ */+ details?: Object;++ /**+ * Error message.+ */+ message?: string;++ /**+ * One of {@link JitsiConnectionError} constants (defined in+ * lib-jitsi-meet).+ */+ name: string;++ /**+ * Indicates whether this event is recoverable or not.+ */+ recoverable?: boolean;+};++/**+ * The value for the username or credential property.+ */+type ReplaceIceServersField = string | null;++/**+ * The value for the urls property.+ */+type IceServerUrls = null | string | Array<string>;++/**+ * The types of ice servers.+ */+enum IceServerType {+ STUN = 'stun',+ TURN = 'turn',+ TURNS = 'turns'+}++/**+ * Represents a single override rule.+ */+interface IReplaceIceServer {++ /**+ * The value the credential prop will be replaced with.+ *+ * NOTE: If the value is null we will remove the credential property in entry that matches the target type. If the+ * value is undefined or missing we won't change the credential property in the entry that matches the target type.+ */+ credential?: ReplaceIceServersField;++ /**+ * Target type that will be used to match the already received ice server and modify/remove it based on the values+ * of credential, urls and username.+ */+ targetType: IceServerType;++ /**+ * The value the urls prop will be replaced with.+ *+ * NOTE: If the value is null we will remove the whole entry that matches the target type. If the value is undefined+ * or missing we won't change the urls property in the entry that matches the target type.+ */+ urls?: IceServerUrls;++ /**+ * The value the username prop will be replaced with.+ *+ * NOTE: If the value is null we will remove the username property in entry that matches the target type. If the+ * value is undefined or missing we won't change the username property in the entry that matches the target type.+ */+ username?: ReplaceIceServersField;+}++/**+ * An object with rules for changing the existing ice server configuration.+ */+export interface IIceServers {++ /**+ * An array of rules for replacing parts from the existing ice server configuration.+ */+ replace: Array<IReplaceIceServer>;+}+diff --git a/react/features/base/lib-jitsi-meet/functions.any.ts b/react/features/base/lib-jitsi-meet/functions.any.tsindex 8ffe1c5267..a0a2feccb5 100644--- a/react/features/base/lib-jitsi-meet/functions.any.ts+++ b/react/features/base/lib-jitsi-meet/functions.any.ts@@ -1,5 +1,5 @@import { IStateful } from '../app/types';-import { ConnectionFailedError } from '../connection/actions.any';+import { ConnectionFailedError } from '../connection/types';import { toState } from '../redux/functions';import JitsiMeetJS from './_';diff --git a/react/features/base/util/uri.ts b/react/features/base/util/uri.tsindex 29ddf3a90e..b0bcc01072 100644--- a/react/features/base/util/uri.ts+++ b/react/features/base/util/uri.ts@@ -559,7 +559,7 @@ export function urlObjectToString(o: { [key: string]: any; }): string | undefinelet { hash } = url;- for (const urlPrefix of [ 'config', 'interfaceConfig', 'devices', 'userInfo', 'appData' ]) {+ for (const urlPrefix of [ 'config', 'iceServers', 'interfaceConfig', 'devices', 'userInfo', 'appData' ]) {const urlParamsArray= _objectToURLParamsArray(o[`${urlPrefix}Overwrite`]