[mirotalk] - fix & update dep

This commit is contained in:
Miroslav Pejic
2024-10-09 14:24:24 +02:00
parent 32239c94fd
commit 792862ffc1
5 changed files with 41 additions and 68 deletions
-27
View File
@@ -3,7 +3,6 @@
module.exports = class Host {
constructor() {
this.authorizedIPs = new Map();
this.roomActive = false;
}
/**
@@ -30,7 +29,6 @@ module.exports = class Host {
*/
setAuthorizedIP(ip, authorized) {
this.authorizedIPs.set(ip, authorized);
this.setRoomActive();
}
/**
@@ -42,37 +40,12 @@ module.exports = class Host {
return this.authorizedIPs.has(ip);
}
/**
* Host room status
* @returns boolean
*/
isRoomActive() {
return this.roomActive;
}
/**
* Set host room activate
*/
setRoomActive() {
this.roomActive = true;
}
/**
* Set host room deactivate
*/
setRoomDeactivate() {
this.roomActive = false;
}
/**
* Delete ip from authorized IPs
* @param {string} ip
* @returns boolean
*/
deleteIP(ip) {
if (this.isAuthorizedIP(ip)) {
this.setRoomDeactivate();
}
return this.authorizedIPs.delete(ip);
}
};
+36 -36
View File
@@ -39,7 +39,7 @@ dependencies: {
* @license For commercial use or closed source, contact us at license.mirotalk@gmail.com or purchase directly from CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-p2p-webrtc-realtime-video-conferences/38376661
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.3.79
* @version 1.3.80
*
*/
@@ -319,7 +319,6 @@ function OIDCAuth(req, res, next) {
log.debug('[OIDC] ------> Host protected', {
authenticated: hostCfg.authenticated,
authorizedIPs: authHost.getAuthorizedIPs(),
activeRoom: authHost.isRoomActive(),
});
}
next();
@@ -457,7 +456,6 @@ app.get('/logout', (req, res) => {
log.debug('[OIDC] ------> Logout', {
authenticated: hostCfg.authenticated,
authorizedIPs: authHost.getAuthorizedIPs(),
activeRoom: authHost.isRoomActive(),
});
}
req.logout(); // Logout user
@@ -467,7 +465,7 @@ app.get('/logout', (req, res) => {
// main page
app.get(['/'], OIDCAuth, (req, res) => {
if ((!OIDC.enabled && hostCfg.protected) || authHost.isRoomActive()) {
if (!OIDC.enabled && hostCfg.protected) {
const ip = getIP(req);
if (allowedIP(ip)) {
res.sendFile(views.landing);
@@ -483,10 +481,10 @@ app.get(['/'], OIDCAuth, (req, res) => {
// set new room name and join
app.get(['/newcall'], OIDCAuth, (req, res) => {
if ((!OIDC.enabled && hostCfg.protected) || authHost.isRoomActive()) {
if (!OIDC.enabled && hostCfg.protected) {
const ip = getIP(req);
if (allowedIP(ip)) {
res.sendFile(views.newCall);
res.redirect('/');
hostCfg.authenticated = true;
} else {
hostCfg.authenticated = false;
@@ -532,7 +530,7 @@ app.get('/join/', async (req, res) => {
*/
const { room, name, audio, video, screen, notify, hide, token } = checkXSS(req.query);
const allowRoomAccess = isAllowedRoomAccess('/join/params', req, hostCfg, authHost, peers, room);
const allowRoomAccess = isAllowedRoomAccess('/join/params', req, hostCfg, peers, room);
if (!allowRoomAccess && !token) {
return res.status(401).json({ message: 'Direct Room Join Unauthorized' });
@@ -595,17 +593,19 @@ app.get('/join/', async (req, res) => {
// Join Room by id
app.get('/join/:roomId', function (req, res) {
//
const allowRoomAccess = isAllowedRoomAccess('/join/:roomId', req, hostCfg, authHost, peers, req.params.roomId);
const { roomId } = req.params;
if (!roomId) {
log.warn('/join/:roomId empty', roomId);
return res.redirect('/');
}
const allowRoomAccess = isAllowedRoomAccess('/join/:roomId', req, hostCfg, peers, roomId);
if (allowRoomAccess) {
if (hostCfg.protected) authHost.setRoomActive();
res.sendFile(views.client);
} else {
if (!OIDC.enabled && hostCfg.protected) {
return res.sendFile(views.login);
}
res.redirect('/');
!OIDC.enabled && hostCfg.protected ? res.redirect('/login') : res.redirect('/');
}
});
@@ -623,10 +623,10 @@ app.get(['/login'], (req, res) => {
app.get(['/logged'], (req, res) => {
const ip = getIP(req);
if (allowedIP(ip)) {
res.sendFile(views.landing);
res.redirect('/');
} else {
hostCfg.authenticated = false;
res.sendFile(views.login);
res.redirect('/login');
}
});
@@ -953,11 +953,11 @@ io.sockets.on('connect', async (socket) => {
});
/**
* On peer diconnected
* On peer disconnected
*/
socket.on('disconnect', async (reason) => {
removeIP(socket);
for (let channel in socket.channels) {
removeIP(socket);
await removePeerFrom(channel);
}
log.debug('[' + socket.id + '] disconnected', { reason: reason });
@@ -1875,37 +1875,37 @@ function getActiveRooms() {
* @param {string} logMessage
* @param {object} req
* @param {object} hostCfg
* @param {class} authHost
* @param {object} roomList
* @param {object} peers
* @param {string} roomId
* @returns boolean true/false
*/
function isAllowedRoomAccess(logMessage, req, hostCfg, authHost, peers, roomId) {
function isAllowedRoomAccess(logMessage, req, hostCfg, peers, roomId) {
const OIDCUserAuthenticated = OIDC.enabled && req.oidc.isAuthenticated();
const hostUserAuthenticated = hostCfg.protected && hostCfg.authenticated;
const roomActive = authHost.isRoomActive();
const roomExist = roomId in peers;
const roomCount = Object.keys(peers).length;
log.debug(logMessage, {
OIDCUserEnabled: OIDC.enabled,
OIDCUserAuthenticated: OIDCUserAuthenticated,
hostUserAuthenticated: hostUserAuthenticated,
hostProtected: hostCfg.protected,
hostAuthenticated: hostCfg.authenticated,
roomActive: roomActive,
roomExist: roomExist,
roomCount: roomCount,
roomId: roomId,
});
const allowRoomAccess =
(!hostCfg.protected && !OIDC.enabled) || // No host protection and OIDC mode enabled (default)
OIDCUserAuthenticated || // User authenticated via OIDC
hostUserAuthenticated || // User authenticated via Login
(OIDCUserAuthenticated && roomExist) || // User authenticated via OIDC and room Exist
(hostUserAuthenticated && roomExist) || // User authenticated via Login and room Exist
((OIDCUserAuthenticated || hostUserAuthenticated) && roomCount === 0) || // User authenticated joins the first room
roomExist; // User Or Guest join an existing Room
log.debug(logMessage, {
OIDCUserAuthenticated: OIDCUserAuthenticated,
hostUserAuthenticated: hostUserAuthenticated,
roomExist: roomExist,
roomCount: roomCount,
extraInfo: {
roomId: roomId,
OIDCUserEnabled: OIDC.enabled,
hostProtected: hostCfg.protected,
hostAuthenticated: hostCfg.authenticated,
},
allowRoomAccess: allowRoomAccess,
});
return allowRoomAccess;
}
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "mirotalk",
"version": "1.3.79",
"version": "1.3.80",
"description": "A free WebRTC browser-based video call",
"main": "server.js",
"scripts": {
@@ -55,7 +55,7 @@
"js-yaml": "^4.1.0",
"ngrok": "^5.0.0-beta.2",
"nodemailer": "^6.9.15",
"openai": "^4.67.1",
"openai": "^4.67.3",
"qs": "^6.13.0",
"socket.io": "^4.8.0",
"swagger-ui-express": "^5.0.1",
+2 -2
View File
@@ -15,7 +15,7 @@
* @license For commercial use or closed source, contact us at license.mirotalk@gmail.com or purchase directly from CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-p2p-webrtc-realtime-video-conferences/38376661
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.3.79
* @version 1.3.80
*
*/
@@ -10569,7 +10569,7 @@ function showAbout() {
Swal.fire({
background: swBg,
position: 'center',
title: '<strong>WebRTC P2P v1.3.79</strong>',
title: '<strong>WebRTC P2P v1.3.80</strong>',
imageAlt: 'mirotalk-about',
imageUrl: images.about,
customClass: { image: 'img-about' },
+1 -1
View File
@@ -53,7 +53,7 @@ function login() {
return (window.location.href = '/join/' + window.location.search);
// return (window.location.href = '/join/?room=' + room + '&token=' + token);
}
if (roomPath) {
if (roomPath && roomPath !== 'login') {
return (window.location.href = '/join/' + roomPath);
// return (window.location.href = '/join/?room=' + roomPath + '&token=' + token);
}