From ad12d084af76e6f75b802c2a9bf32d8bf73c83ec Mon Sep 17 00:00:00 2001 From: TCHDORUK Date: Tue, 28 May 2024 10:09:10 +0300 Subject: [PATCH 1/3] feat: ldap authentication added --- JitsiConference.js | 5 +++-- modules/xmpp/ChatRoom.js | 41 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/JitsiConference.js b/JitsiConference.js index 631da239..d7bb93d0 100644 --- a/JitsiConference.js +++ b/JitsiConference.js @@ -569,9 +569,10 @@ JitsiConference.prototype._init = function(options = {}) { * @param replaceParticipant {boolean} whether the current join replaces * an existing participant with same jwt from the meeting. */ -JitsiConference.prototype.join = function(password, replaceParticipant = false, captchaId, captchaValue) { +JitsiConference.prototype.join = function(password, replaceParticipant = false, captchaId, captchaValue, email, ldapPassword) { if (this.room) { - this.room.join(password, replaceParticipant, captchaId, captchaValue).then(() => this._maybeSetSITimeout()); + this.room.join(password, replaceParticipant, captchaId, captchaValue, email, ldapPassword) + .then(() => this._maybeSetSITimeout()); } }; diff --git a/modules/xmpp/ChatRoom.js b/modules/xmpp/ChatRoom.js index bf2c242b..ed56c408 100644 --- a/modules/xmpp/ChatRoom.js +++ b/modules/xmpp/ChatRoom.js @@ -214,10 +214,12 @@ export default class ChatRoom extends Listenable { * @returns {Promise} - resolved when join completes. At the time of this * writing it's never rejected. */ - join(password, replaceParticipant, captchaId, captchaValue) { + join(password, replaceParticipant, captchaId, captchaValue, email, ldapPassword) { this.password = password; this.captchaId = captchaId; this.captchaValue = captchaValue; + this.email = email; + this.ldapPassword = ldapPassword; this.replaceParticipant = replaceParticipant; return new Promise(resolve => { @@ -273,6 +275,12 @@ export default class ChatRoom extends Listenable { pres.c('captchaId').t(this.captchaId).up(); pres.c('captchaValue').t(this.captchaValue).up(); } + if (this.email) { + pres.c('email').t(this.email).up(); + } + if (this.ldapPassword) { + pres.c('user_password').t(this.ldapPassword).up(); + } if (this.options.billingId) { pres.c('billingid').t(this.options.billingId).up(); } @@ -1350,6 +1358,37 @@ export default class ChatRoom extends Listenable { '>error[type="modify"]>displayname-required[xmlns="http://jitsi.org/jitmeet"]')).length) { logger.warn('display name required ', pres); this.eventEmitter.emit(XMPPEvents.DISPLAY_NAME_REQUIRED, errorDescriptionNode[0].attributes.lobby?.value); + } else if ($(pres) + .find('>error[type="modify"]' + + '>email-required[' + + 'xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]').length + || $(pres) + .find('>error[type="modify"]' + + '>ldap-auth-required[' + + 'xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]').length + || $(pres) + .find('>error[type="modify"]' + + '>ldap-auth-error[' + + 'xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]').length) { + + const isLdapForce = $(pres).find('>error[type="modify"]>ldap-auth-required'); + const isLdapError = $(pres).find('>error[type="modify"]>ldap-auth-error'); + + const msgNode = $(pres).find('>error[type="modify"]>text'); + let msg = ''; + + if (msgNode.length) { + msg = msgNode.text(); + } + + if (isLdapForce.length || isLdapError.length) { + this.eventEmitter.emit(XMPPEvents.AUTHENTICATION_REQUIRED, { + type: 'ldap-auth-required', + errmsg: msg + }); + } else { + this.eventEmitter.emit(XMPPEvents.AUTHENTICATION_REQUIRED, { type: 'email-required' }); + } } else { const msgNode = $(pres).find('>error[type="cancel"]>text'); let msg; From 200b9b13da63fb30e32f73ee3af4a01cec35aaf6 Mon Sep 17 00:00:00 2001 From: TCHDORUK Date: Mon, 3 Jun 2024 09:55:00 +0300 Subject: [PATCH 2/3] feat: added visitor chat visibility --- modules/xmpp/ChatRoom.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/xmpp/ChatRoom.js b/modules/xmpp/ChatRoom.js index ed56c408..93911085 100644 --- a/modules/xmpp/ChatRoom.js +++ b/modules/xmpp/ChatRoom.js @@ -384,10 +384,12 @@ export default class ChatRoom extends Listenable { const autoRecordingWithoutAction = $(result).find('>query>feature[var="auto_recording_without_action"]').length === 1; + const visitorChat = $(result).find('>query>feature[var="visitor_chat"]').length === 1; + this.eventEmitter.emit(XMPPEvents.MUC_ROOM_VISIBILITY_CHANGED, specialRoom, roomOwner, externalScheduled, coHost, autoRecording, disableMuteOthers, whiteListEnabled, disableParticipantChat, - liveStreamEnable, autoRecordingWithoutAction); + liveStreamEnable, autoRecordingWithoutAction, visitorChat); const everybodyHasMicAccess = $(result).find('>query>x[type="result"]>field[var="muc#roomconfig_bip_allow_microphone"]>value') From 915f38a786f3d49208f523b807e33b59daf21823 Mon Sep 17 00:00:00 2001 From: TCHDORUK Date: Fri, 7 Jun 2024 16:38:49 +0300 Subject: [PATCH 3/3] fix: added error event for webinr authenticaiton --- JitsiConferenceErrors.spec.ts | 3 +++ JitsiConferenceErrors.ts | 6 ++++++ JitsiConferenceEventManager.js | 4 ++++ JitsiConnectionErrors.ts | 9 ++++++++- modules/xmpp/ChatRoom.js | 4 ++-- service/xmpp/XMPPEvents.spec.ts | 1 + service/xmpp/XMPPEvents.ts | 1 + types/hand-crafted/JitsiConferenceErrors.d.ts | 1 + types/hand-crafted/service/xmpp/XMPPEvents.d.ts | 1 + 9 files changed, 27 insertions(+), 3 deletions(-) diff --git a/JitsiConferenceErrors.spec.ts b/JitsiConferenceErrors.spec.ts index be8565a3..bcbe51c4 100644 --- a/JitsiConferenceErrors.spec.ts +++ b/JitsiConferenceErrors.spec.ts @@ -4,6 +4,7 @@ import * as exported from "./JitsiConferenceErrors"; describe( "/JitsiConferenceErrors members", () => { const { + WEBINAR_AUTHENTICATION_REQUIRED, AUTHENTICATION_REQUIRED, CHAT_ERROR, SETTINGS_ERROR, @@ -31,6 +32,7 @@ describe( "/JitsiConferenceErrors members", () => { } = exported; it( "known members", () => { + expect( WEBINAR_AUTHENTICATION_REQUIRED ).toBe( 'conference.webinarAuthenticationRequired' ); expect( AUTHENTICATION_REQUIRED ).toBe( 'conference.authenticationRequired' ); expect( CHAT_ERROR ).toBe( 'conference.chatError' ); expect( SETTINGS_ERROR ).toBe( 'conference.settingsError' ); @@ -56,6 +58,7 @@ describe( "/JitsiConferenceErrors members", () => { expect( JitsiConferenceErrors ).toBeDefined(); + expect( JitsiConferenceErrors.WEBINAR_AUTHENTICATION_REQUIRED ).toBe( 'conference.webinarAuthenticationRequired' ); expect( JitsiConferenceErrors.AUTHENTICATION_REQUIRED ).toBe( 'conference.authenticationRequired' ); expect( JitsiConferenceErrors.CHAT_ERROR ).toBe( 'conference.chatError' ); expect( JitsiConferenceErrors.SETTINGS_ERROR ).toBe( 'conference.settingsError' ); diff --git a/JitsiConferenceErrors.ts b/JitsiConferenceErrors.ts index 46f9fa8f..059aac22 100644 --- a/JitsiConferenceErrors.ts +++ b/JitsiConferenceErrors.ts @@ -3,6 +3,11 @@ */ export enum JitsiConferenceErrors { + /** + * Indicates that client must be authenticated to create the conference. + */ + WEBINAR_AUTHENTICATION_REQUIRED = 'conference.webinarAuthenticationRequired', + /** * Indicates that client must be authenticated to create the conference. */ @@ -122,6 +127,7 @@ export enum JitsiConferenceErrors { }; // exported for backward compatibility +export const WEBINAR_AUTHENTICATION_REQUIRED = JitsiConferenceErrors.WEBINAR_AUTHENTICATION_REQUIRED; export const AUTHENTICATION_REQUIRED = JitsiConferenceErrors.AUTHENTICATION_REQUIRED; export const CHAT_ERROR = JitsiConferenceErrors.CHAT_ERROR; export const SETTINGS_ERROR = JitsiConferenceErrors.SETTINGS_ERROR; diff --git a/JitsiConferenceEventManager.js b/JitsiConferenceEventManager.js index 641049b9..5c7ed7a1 100644 --- a/JitsiConferenceEventManager.js +++ b/JitsiConferenceEventManager.js @@ -221,6 +221,10 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function() { JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.PASSWORD_REQUIRED); + this.chatRoomForwarder.forward(XMPPEvents.WEBINAR_AUTHENTICATION_REQUIRED, + JitsiConferenceEvents.CONFERENCE_FAILED, + JitsiConferenceErrors.WEBINAR_AUTHENTICATION_REQUIRED); + this.chatRoomForwarder.forward(XMPPEvents.AUTHENTICATION_REQUIRED, JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.AUTHENTICATION_REQUIRED); diff --git a/JitsiConnectionErrors.ts b/JitsiConnectionErrors.ts index 7ce17353..dab837ab 100644 --- a/JitsiConnectionErrors.ts +++ b/JitsiConnectionErrors.ts @@ -30,11 +30,18 @@ export enum JitsiConnectionErrors { * Indicates that the connection was dropped, because of too many 5xx HTTP * errors on BOSH requests. */ - SERVER_ERROR = 'connection.serverError' + SERVER_ERROR = 'connection.serverError', + + /** + * Indicates that the connection was dropped, because of too many 5xx HTTP + * errors on BOSH requests. + */ + WEBINAR_AUTHENTICATION_REQUIRED = 'connection.webinarAuthenticationRequired' }; // exported for backward compatibility export const CONNECTION_DROPPED_ERROR = JitsiConnectionErrors.CONNECTION_DROPPED_ERROR; export const OTHER_ERROR = JitsiConnectionErrors.OTHER_ERROR; export const PASSWORD_REQUIRED = JitsiConnectionErrors.PASSWORD_REQUIRED; +export const WEBINAR_AUTHENTICATION_REQUIRED = JitsiConnectionErrors.WEBINAR_AUTHENTICATION_REQUIRED; export const SERVER_ERROR = JitsiConnectionErrors.SERVER_ERROR; diff --git a/modules/xmpp/ChatRoom.js b/modules/xmpp/ChatRoom.js index 93911085..ee69538d 100644 --- a/modules/xmpp/ChatRoom.js +++ b/modules/xmpp/ChatRoom.js @@ -1384,12 +1384,12 @@ export default class ChatRoom extends Listenable { } if (isLdapForce.length || isLdapError.length) { - this.eventEmitter.emit(XMPPEvents.AUTHENTICATION_REQUIRED, { + this.eventEmitter.emit(XMPPEvents.WEBINAR_AUTHENTICATION_REQUIRED, { type: 'ldap-auth-required', errmsg: msg }); } else { - this.eventEmitter.emit(XMPPEvents.AUTHENTICATION_REQUIRED, { type: 'email-required' }); + this.eventEmitter.emit(XMPPEvents.WEBINAR_AUTHENTICATION_REQUIRED, { type: 'email-required' }); } } else { const msgNode = $(pres).find('>error[type="cancel"]>text'); diff --git a/service/xmpp/XMPPEvents.spec.ts b/service/xmpp/XMPPEvents.spec.ts index 462c7932..6d233666 100644 --- a/service/xmpp/XMPPEvents.spec.ts +++ b/service/xmpp/XMPPEvents.spec.ts @@ -14,6 +14,7 @@ describe( "/service/xmpp/XMPPEvents members", () => { expect( XMPPEvents.ADD_ICE_CANDIDATE_FAILED ).toBe( 'xmpp.add_ice_candidate_failed' ); expect( XMPPEvents.AUDIO_MUTED_BY_FOCUS ).toBe( 'xmpp.audio_muted_by_focus' ); expect( XMPPEvents.VIDEO_MUTED_BY_FOCUS ).toBe( 'xmpp.video_muted_by_focus' ); + expect( XMPPEvents.WEBINAR_AUTHENTICATION_REQUIRED ).toBe( 'xmpp.webinar_authentication_required' ); expect( XMPPEvents.AUTHENTICATION_REQUIRED ).toBe( 'xmpp.authentication_required' ); expect( XMPPEvents.BRIDGE_DOWN ).toBe( 'xmpp.bridge_down' ); expect( XMPPEvents.CALL_ACCEPTED ).toBe( 'xmpp.callaccepted.jingle' ); diff --git a/service/xmpp/XMPPEvents.ts b/service/xmpp/XMPPEvents.ts index 2cb7cab7..74541b57 100644 --- a/service/xmpp/XMPPEvents.ts +++ b/service/xmpp/XMPPEvents.ts @@ -12,6 +12,7 @@ export enum XMPPEvents { // camera. VIDEO_MUTED_BY_FOCUS = 'xmpp.video_muted_by_focus', AUTHENTICATION_REQUIRED = 'xmpp.authentication_required', + WEBINAR_AUTHENTICATION_REQUIRED = 'xmpp.webinar_authentication_required', BRIDGE_DOWN = 'xmpp.bridge_down', /** diff --git a/types/hand-crafted/JitsiConferenceErrors.d.ts b/types/hand-crafted/JitsiConferenceErrors.d.ts index 58a4296e..2858df38 100644 --- a/types/hand-crafted/JitsiConferenceErrors.d.ts +++ b/types/hand-crafted/JitsiConferenceErrors.d.ts @@ -1,4 +1,5 @@ export enum JitsiConferenceErrors { + WEBINAR_AUTHENTICATION_REQUIRED = 'conference.webinarAuthenticationRequired', AUTHENTICATION_REQUIRED = 'conference.authenticationRequired', CHAT_ERROR = 'conference.chatError', CONFERENCE_DESTROYED = 'conference.destroyed', diff --git a/types/hand-crafted/service/xmpp/XMPPEvents.d.ts b/types/hand-crafted/service/xmpp/XMPPEvents.d.ts index af705995..dcdb1ab0 100644 --- a/types/hand-crafted/service/xmpp/XMPPEvents.d.ts +++ b/types/hand-crafted/service/xmpp/XMPPEvents.d.ts @@ -2,6 +2,7 @@ ADD_ICE_CANDIDATE_FAILED = 'xmpp.add_ice_candidate_failed', AUDIO_MUTED_BY_FOCUS = 'xmpp.audio_muted_by_focus', VIDEO_MUTED_BY_FOCUS = 'xmpp.video_muted_by_focus', + WEBINAR_AUTHENTICATION_REQUIRED = 'xmpp.webinar_authentication_required', AUTHENTICATION_REQUIRED = 'xmpp.authentication_required', BRIDGE_DOWN = 'xmpp.bridge_down', CALL_ACCEPTED = 'xmpp.callaccepted.jingle',