Skip to content

Commit

Permalink
feat(jaas) add zero-config mode for JaaS customers
Browse files Browse the repository at this point in the history
  • Loading branch information
saghul committed Apr 12, 2024
1 parent 8e41688 commit 5a431b8
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions JitsiConnection.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import clonedeep from 'lodash.clonedeep';

import JitsiConference from './JitsiConference';
import * as JitsiConnectionEvents from './JitsiConnectionEvents';
import FeatureFlags from './modules/flags/FeatureFlags';
Expand All @@ -8,6 +10,11 @@ import {
createConnectionFailedEvent
} from './service/statistics/AnalyticsEvents';

/**
* Prefix used by JaaS apps.
*/
const JAAS_APPID_PREFIX = 'vpaas-magic-cookie';

/**
* Creates a new connection object for the Jitsi Meet server side video
* conferencing service. Provides access to the JitsiConference interface.
Expand All @@ -18,15 +25,36 @@ import {
* the server.
* @constructor
*/
export default function JitsiConnection(appID, token, options) {
this.appID = appID;
export default function JitsiConnection(appID, token, options = {}) {
this.appID = (appID || '').toLowerCase();
this.token = token;
this.options = options;

const _options = clonedeep(options);

// If a JaaS app ID was provided but no options, provide some ourselves.
if (this.appID.startsWith(JAAS_APPID_PREFIX)) {
if (!_options.hosts) {
_options.hosts = {
domain: '8x8.vc',
muc: `conference.${this.appID}.8x8.vc`
};
}

if (!_options.serviceUrl && !_options.bosh && !_options.websocket) {
_options.serviceUrl = `wss://8x8.vc/${this.appID}/xmpp-websocket`;
}

if (!_options.websocketKeepAliveUrl) {
_options.websocketKeepAliveUrl = `https://8x8.vc/${this.appID}/_unlock`;
}
}

this.options = _options;

// Initialize the feature flags so that they are advertised through the disco-info.
FeatureFlags.init(options.flags || {});
FeatureFlags.init(_options.flags || {});

this.xmpp = new XMPP(options, token);
this.xmpp = new XMPP(this.options, token);

/* eslint-disable max-params */
this.addEventListener(JitsiConnectionEvents.CONNECTION_FAILED,
Expand Down

0 comments on commit 5a431b8

Please sign in to comment.