Merge pull request #437 from isymchych/lib-jitsi-meet
Add methods related to external authentication
This commit is contained in:
commit
9960ce703f
|
@ -1,4 +1,4 @@
|
|||
/* global Strophe, $ */
|
||||
/* global Strophe, $, Promise */
|
||||
/* jshint -W101 */
|
||||
var logger = require("jitsi-meet-logger").getLogger(__filename);
|
||||
var RTC = require("./modules/RTC/RTC");
|
||||
|
@ -52,6 +52,13 @@ JitsiConference.prototype.join = function (password) {
|
|||
this.room.join(password, this.connection.tokenPassword);
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if joined to the conference.
|
||||
*/
|
||||
JitsiConference.prototype.isJoined = function () {
|
||||
return this.room && this.room.joined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Leaves the conference.
|
||||
*/
|
||||
|
@ -61,6 +68,40 @@ JitsiConference.prototype.leave = function () {
|
|||
this.room = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns name of this conference.
|
||||
*/
|
||||
JitsiConference.prototype.getName = function () {
|
||||
return this.options.name;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if external authentication is enabled for this conference.
|
||||
*/
|
||||
JitsiConference.prototype.isExternalAuthEnabled = function () {
|
||||
return this.room && this.room.moderator.isExternalAuthEnabled();
|
||||
};
|
||||
|
||||
/**
|
||||
* Get url for external authentication.
|
||||
* @param {boolean} [urlForPopup] if true then return url for login popup,
|
||||
* else url of login page.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
JitsiConference.prototype.getExternalAuthUrl = function (urlForPopup) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (!this.isExternalAuthEnabled()) {
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
if (urlForPopup) {
|
||||
this.room.moderator.getPopupLoginUrl(resolve, reject);
|
||||
} else {
|
||||
this.room.moderator.getLoginUrl(resolve, reject);
|
||||
}
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the local tracks.
|
||||
*/
|
||||
|
@ -267,7 +308,7 @@ JitsiConference.prototype.lock = function (password) {
|
|||
}, function (err) {
|
||||
reject(err);
|
||||
}, function () {
|
||||
reject(JitsiConferenceErrors.PASSWORD_REQUIRED);
|
||||
reject(JitsiConferenceErrors.PASSWORD_NOT_SUPPORTED);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@ -478,6 +519,18 @@ function setupListeners(conference) {
|
|||
conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
|
||||
conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_JOINED);
|
||||
});
|
||||
conference.room.addListener(XMPPEvents.ROOM_JOIN_ERROR, function (pres) {
|
||||
conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.CONNECTION_ERROR, pres);
|
||||
});
|
||||
conference.room.addListener(XMPPEvents.ROOM_CONNECT_ERROR, function (pres) {
|
||||
conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.CONNECTION_ERROR, pres);
|
||||
});
|
||||
conference.room.addListener(XMPPEvents.PASSWORD_REQUIRED, function (pres) {
|
||||
conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.PASSWORD_REQUIRED, pres);
|
||||
});
|
||||
conference.room.addListener(XMPPEvents.AUTHENTICATION_REQUIRED, function () {
|
||||
conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.AUTHENTICATION_REQUIRED);
|
||||
});
|
||||
// FIXME
|
||||
// conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
|
||||
// conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_LEFT);
|
||||
|
@ -501,7 +554,7 @@ function setupListeners(conference) {
|
|||
conference.eventEmitter.emit(JitsiConferenceEvents.CONNECTION_RESTORED);
|
||||
});
|
||||
conference.room.addListener(XMPPEvents.CONFERENCE_SETUP_FAILED, function () {
|
||||
conference.eventEmitter.emit(JitsiConferenceEvents.SETUP_FAILED);
|
||||
conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.SETUP_FAILED);
|
||||
});
|
||||
|
||||
conference.room.addListener(XMPPEvents.MESSAGE_RECEIVED, function (jid, displayName, txt, myJid, ts) {
|
||||
|
|
|
@ -7,6 +7,10 @@ var JitsiConferenceErrors = {
|
|||
* Indicates that a password is required in order to join the conference.
|
||||
*/
|
||||
PASSWORD_REQUIRED: "conference.passwordRequired",
|
||||
/**
|
||||
* Indicates that client must be authenticated to create the conference.
|
||||
*/
|
||||
AUTHENTICATION_REQUIRED: "conference.authenticationRequired",
|
||||
/**
|
||||
* Indicates that password cannot be set for this conference.
|
||||
*/
|
||||
|
@ -16,6 +20,10 @@ var JitsiConferenceErrors = {
|
|||
* conference.
|
||||
*/
|
||||
CONNECTION_ERROR: "conference.connectionError",
|
||||
/**
|
||||
* Indicates that the conference setup failed.
|
||||
*/
|
||||
SETUP_FAILED: "conference.setup_failed",
|
||||
/**
|
||||
* Indicates that there is no available videobridge.
|
||||
*/
|
||||
|
|
|
@ -69,9 +69,9 @@ var JitsiConferenceEvents = {
|
|||
*/
|
||||
CONNECTION_RESTORED: "conference.connectionRestored",
|
||||
/**
|
||||
* Indicates that the conference setup failed.
|
||||
* Indicates that conference failed.
|
||||
*/
|
||||
SETUP_FAILED: "conference.setup_failed",
|
||||
CONFERENCE_FAILED: "conference.failed",
|
||||
/**
|
||||
* Indicates that conference has been joined.
|
||||
*/
|
||||
|
|
|
@ -79,6 +79,7 @@ JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR);
|
|||
- CONFERENCE_LEFT - notifies the local user that he left the conference successfully. (no parameters)
|
||||
- DTMF_SUPPORT_CHANGED - notifies if at least one user supports DTMF. (parameters - supports(boolean))
|
||||
- USER_ROLE_CHANGED - notifies that role of some user changed. (parameters - id(string), role(string))
|
||||
- CONFERENCE_FAILED - notifies that user failed to join the conference. (parameters - errorCode(JitsiMeetJS.errors.conference))
|
||||
|
||||
2. connection
|
||||
- CONNECTION_FAILED - indicates that the server connection failed.
|
||||
|
@ -92,8 +93,10 @@ JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR);
|
|||
We support the following events:
|
||||
1. conference
|
||||
- CONNECTION_ERROR - the connection with the conference is lost.
|
||||
- SETUP_FAILED - conference setup failed
|
||||
- AUTHENTICATION_REQUIRED - user must be authenticated to create this conference
|
||||
- PASSWORD_REQUIRED - that error can be passed when the connection to the conference failed. You should try to join the conference with password.
|
||||
- PASSWORD_NOT_SUPPORTED - indicates that password cannot be set for this conference
|
||||
- PASSWORD_NOT_SUPPORTED - indicates that conference cannot be locked
|
||||
- VIDEOBRIDGE_NOT_AVAILABLE - video bridge issues.
|
||||
2. connection
|
||||
- PASSWORD_REQUIRED - passed when the connection to the server failed. You should try to authenticate with password.
|
||||
|
|
1401
lib-jitsi-meet.js
1401
lib-jitsi-meet.js
File diff suppressed because it is too large
Load Diff
|
@ -354,7 +354,7 @@ Moderator.prototype.allocateConferenceFocus = function (callback) {
|
|||
);
|
||||
};
|
||||
|
||||
Moderator.prototype.getLoginUrl = function (urlCallback) {
|
||||
Moderator.prototype.getLoginUrl = function (urlCallback, failureCallback) {
|
||||
var iq = $iq({to: this.getFocusComponent(), type: 'get'});
|
||||
iq.c('login-url', {
|
||||
xmlns: 'http://jitsi.org/protocol/focus',
|
||||
|
@ -372,14 +372,17 @@ Moderator.prototype.getLoginUrl = function (urlCallback) {
|
|||
} else {
|
||||
logger.error(
|
||||
"Failed to get auth url from the focus", result);
|
||||
failureCallback(result);
|
||||
}
|
||||
},
|
||||
function (error) {
|
||||
logger.error("Get auth url error", error);
|
||||
failureCallback(error);
|
||||
}
|
||||
);
|
||||
};
|
||||
Moderator.prototype.getPopupLoginUrl = function (urlCallback) {
|
||||
|
||||
Moderator.prototype.getPopupLoginUrl = function (urlCallback, failureCallback) {
|
||||
var iq = $iq({to: this.getFocusComponent(), type: 'get'});
|
||||
iq.c('login-url', {
|
||||
xmlns: 'http://jitsi.org/protocol/focus',
|
||||
|
@ -398,10 +401,12 @@ Moderator.prototype.getPopupLoginUrl = function (urlCallback) {
|
|||
} else {
|
||||
logger.error(
|
||||
"Failed to get POPUP auth url from the focus", result);
|
||||
failureCallback(result);
|
||||
}
|
||||
},
|
||||
function (error) {
|
||||
logger.error('Get POPUP auth url error', error);
|
||||
failureCallback(error);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
@ -435,6 +440,3 @@ Moderator.prototype.logout = function (callback) {
|
|||
};
|
||||
|
||||
module.exports = Moderator;
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue