|
|
@@ -1,7 +1,7 @@
|
|
1
|
1
|
/* eslint-disable newline-per-chained-call */
|
|
2
|
2
|
import { getLogger } from '@jitsi/logger';
|
|
3
|
3
|
import $ from 'jquery';
|
|
4
|
|
-import { $iq, Strophe } from 'strophe.js';
|
|
|
4
|
+import { $iq } from 'strophe.js';
|
|
5
|
5
|
|
|
6
|
6
|
import { CONNECTION_REDIRECTED } from '../../JitsiConnectionEvents';
|
|
7
|
7
|
import FeatureFlags from '../flags/FeatureFlags';
|
|
|
@@ -55,9 +55,6 @@ export default class Moderator extends Listenable {
|
|
55
|
55
|
this.getNextErrorTimeout = createExpBackoffTimer(1000);
|
|
56
|
56
|
this.options = xmpp.options;
|
|
57
|
57
|
|
|
58
|
|
- // External authentication stuff
|
|
59
|
|
- this.externalAuthEnabled = false;
|
|
60
|
|
-
|
|
61
|
58
|
// Whether SIP gateway (jigasi) support is enabled. TODO: use presence so it can be changed based on jigasi
|
|
62
|
59
|
// availability.
|
|
63
|
60
|
this.sipGatewayEnabled = false;
|
|
|
@@ -133,14 +130,6 @@ export default class Moderator extends Listenable {
|
|
133
|
130
|
return false;
|
|
134
|
131
|
}
|
|
135
|
132
|
|
|
136
|
|
- /**
|
|
137
|
|
- * Is external authentication enabled.
|
|
138
|
|
- * @returns {boolean}
|
|
139
|
|
- */
|
|
140
|
|
- isExternalAuthEnabled() {
|
|
141
|
|
- return this.externalAuthEnabled;
|
|
142
|
|
- }
|
|
143
|
|
-
|
|
144
|
133
|
/**
|
|
145
|
134
|
* Is sip gw enabled.
|
|
146
|
135
|
* @returns {boolean}
|
|
|
@@ -385,10 +374,7 @@ export default class Moderator extends Listenable {
|
|
385
|
374
|
|
|
386
|
375
|
logger.info(`Authentication enabled: ${authenticationEnabled}`);
|
|
387
|
376
|
|
|
388
|
|
- this.externalAuthEnabled = conferenceRequest.properties.externalAuth === 'true';
|
|
389
|
|
- logger.info(`External authentication enabled: ${this.externalAuthEnabled}`);
|
|
390
|
|
-
|
|
391
|
|
- if (!this.externalAuthEnabled && conferenceRequest.sessionId) {
|
|
|
377
|
+ if (conferenceRequest.sessionId) {
|
|
392
|
378
|
logger.info(`Received sessionId: ${conferenceRequest.sessionId}`);
|
|
393
|
379
|
Settings.sessionId = conferenceRequest.sessionId;
|
|
394
|
380
|
}
|
|
|
@@ -507,13 +493,6 @@ export default class Moderator extends Listenable {
|
|
507
|
493
|
// Not authorized to create new room
|
|
508
|
494
|
const notAuthorized = $(error).find('>error>not-authorized').length > 0;
|
|
509
|
495
|
|
|
510
|
|
- if (notAuthorized
|
|
511
|
|
- && Strophe.getDomainFromJid(error.getAttribute('to')) !== this.options.hosts.anonymousdomain) {
|
|
512
|
|
- // FIXME "is external" should come either from the focus or
|
|
513
|
|
- // config.js
|
|
514
|
|
- this.externalAuthEnabled = true;
|
|
515
|
|
- }
|
|
516
|
|
-
|
|
517
|
496
|
this._handleError(roomJid, invalidSession, notAuthorized, callback);
|
|
518
|
497
|
}
|
|
519
|
498
|
|
|
|
@@ -568,84 +547,6 @@ export default class Moderator extends Listenable {
|
|
568
|
547
|
});
|
|
569
|
548
|
}
|
|
570
|
549
|
|
|
571
|
|
- /**
|
|
572
|
|
- * Gets the login URL by requesting it to jicofo.
|
|
573
|
|
- * @param roomJid The room jid to use.
|
|
574
|
|
- * @param urlCallback The success callback.
|
|
575
|
|
- * @param failureCallback The error callback.
|
|
576
|
|
- */
|
|
577
|
|
- getLoginUrl(roomJid, urlCallback, failureCallback) {
|
|
578
|
|
- this._getLoginUrl(roomJid, /* popup */ false, urlCallback, failureCallback);
|
|
579
|
|
- }
|
|
580
|
|
-
|
|
581
|
|
- /**
|
|
582
|
|
- * Gets the login URL by requesting it to jicofo.
|
|
583
|
|
- * @param {boolean} popup false for {@link Moderator#getLoginUrl} or true for
|
|
584
|
|
- * {@link Moderator#getPopupLoginUrl}
|
|
585
|
|
- * @param roomJid - The room jid to use.
|
|
586
|
|
- * @param urlCb
|
|
587
|
|
- * @param failureCb
|
|
588
|
|
- */
|
|
589
|
|
- _getLoginUrl(roomJid, popup, urlCb, failureCb) {
|
|
590
|
|
- const iq = $iq({
|
|
591
|
|
- to: this.targetJid,
|
|
592
|
|
- type: 'get'
|
|
593
|
|
- });
|
|
594
|
|
- const attrs = {
|
|
595
|
|
- xmlns: 'http://jitsi.org/protocol/focus',
|
|
596
|
|
- room: roomJid,
|
|
597
|
|
- 'machine-uid': Settings.machineId
|
|
598
|
|
- };
|
|
599
|
|
- let str = 'auth url'; // for logger
|
|
600
|
|
-
|
|
601
|
|
- if (popup) {
|
|
602
|
|
- attrs.popup = true;
|
|
603
|
|
- str = `POPUP ${str}`;
|
|
604
|
|
- }
|
|
605
|
|
- iq.c('login-url', attrs);
|
|
606
|
|
-
|
|
607
|
|
- /**
|
|
608
|
|
- * Implements a failure callback which reports an error message and an error
|
|
609
|
|
- * through (1) GlobalOnErrorHandler, (2) logger, and (3) failureCb.
|
|
610
|
|
- *
|
|
611
|
|
- * @param {string} errmsg the error messsage to report
|
|
612
|
|
- * @param {*} error the error to report (in addition to errmsg)
|
|
613
|
|
- */
|
|
614
|
|
- function reportError(errmsg, err) {
|
|
615
|
|
- GlobalOnErrorHandler.callErrorHandler(new Error(errmsg));
|
|
616
|
|
- logger.error(errmsg, err);
|
|
617
|
|
- failureCb(err);
|
|
618
|
|
- }
|
|
619
|
|
-
|
|
620
|
|
- this.connection.sendIQ(
|
|
621
|
|
- iq,
|
|
622
|
|
- result => {
|
|
623
|
|
- let url = $(result)
|
|
624
|
|
- .find('login-url')
|
|
625
|
|
- .attr('url');
|
|
626
|
|
-
|
|
627
|
|
- url = decodeURIComponent(url);
|
|
628
|
|
- if (url) {
|
|
629
|
|
- logger.info(`Got ${str}: ${url}`);
|
|
630
|
|
- urlCb(url);
|
|
631
|
|
- } else {
|
|
632
|
|
- reportError(`Failed to get ${str} from the focus`, result);
|
|
633
|
|
- }
|
|
634
|
|
- },
|
|
635
|
|
- reportError.bind(undefined, `Get ${str} error`)
|
|
636
|
|
- );
|
|
637
|
|
- }
|
|
638
|
|
-
|
|
639
|
|
- /**
|
|
640
|
|
- * Gets the login URL by requesting it to jicofo.
|
|
641
|
|
- * @param roomJid The room jid to use.
|
|
642
|
|
- * @param urlCallback The success callback.
|
|
643
|
|
- * @param failureCallback The error callback.
|
|
644
|
|
- */
|
|
645
|
|
- getPopupLoginUrl(roomJid, urlCallback, failureCallback) {
|
|
646
|
|
- this._getLoginUrl(roomJid, /* popup */ true, urlCallback, failureCallback);
|
|
647
|
|
- }
|
|
648
|
|
-
|
|
649
|
550
|
/**
|
|
650
|
551
|
* Logout by sending conference IQ.
|
|
651
|
552
|
* @param callback
|
|
|
@@ -669,16 +570,9 @@ export default class Moderator extends Listenable {
|
|
669
|
570
|
this.connection.sendIQ(
|
|
670
|
571
|
iq,
|
|
671
|
572
|
result => {
|
|
672
|
|
- let logoutUrl = $(result)
|
|
673
|
|
- .find('logout')
|
|
674
|
|
- .attr('logout-url');
|
|
675
|
|
-
|
|
676
|
|
- if (logoutUrl) {
|
|
677
|
|
- logoutUrl = decodeURIComponent(logoutUrl);
|
|
678
|
|
- }
|
|
679
|
|
- logger.info(`Log out OK, url: ${logoutUrl}`, result);
|
|
|
573
|
+ logger.info('Log out OK', result);
|
|
680
|
574
|
Settings.sessionId = undefined;
|
|
681
|
|
- callback(logoutUrl);
|
|
|
575
|
+ callback();
|
|
682
|
576
|
},
|
|
683
|
577
|
error => {
|
|
684
|
578
|
const errmsg = 'Logout error';
|