[mirotalk] - update dep

This commit is contained in:
Miroslav Pejic
2025-05-02 08:06:30 +02:00
parent ed2645852c
commit 43442f8813
6 changed files with 48 additions and 50 deletions
+2 -3
View File
@@ -94,7 +94,7 @@ class MattermostController {
const tokenService = new TokenService(
config.token || 'fallback-secret-at-least-32-chars',
config.roomTokenExpire || '15m',
config.encryptionKey || 'fallback-encryption-key-32chars'
config.encryptionKey || 'fallback-encryption-key-32chars',
);
this.authService = new MattermostAuthService({
@@ -107,7 +107,7 @@ class MattermostController {
tokenService,
config.server_url,
config.api_disabled,
config.security
config.security,
);
this.token = config.token;
@@ -117,7 +117,6 @@ class MattermostController {
this.authService.login();
this.setupRoutes();
} catch (error) {
log.error('MattermostController disabled due to config error:', error.message);
}
+2 -2
View File
@@ -45,7 +45,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.5.05
* @version 1.5.06
*
*/
@@ -347,7 +347,7 @@ const mattermostCfg = {
token: process.env.MATTERMOST_TOKEN,
roomTokenExpire: process.env.MATTERMOST_ROOM_TOKEN_EXPIRE,
encryptionKey: process.env.JWT_KEY,
security: (hostCfg.protected || OIDC.enabled),
security: hostCfg.protected || OIDC.enabled,
api_disabled: api_disabled,
};
+35 -36
View File
@@ -19,7 +19,7 @@ class JWTService {
/**
* Signs a payload into a JWT token.
* @param {Object} payload
* @param {Object} payload
* @param {string|number} expiresIn - Expiration time (e.g., '1h', 3600).
* @returns {string}
*/
@@ -32,8 +32,8 @@ class JWTService {
/**
* Verifies a JWT token.
* @param {string} token
* @param {boolean} [ignoreExpiration=false]
* @param {string} token
* @param {boolean} [ignoreExpiration=false]
* @returns {Object}
*/
verify(token, ignoreExpiration = false) {
@@ -46,7 +46,7 @@ class JWTService {
/**
* Decodes a JWT token without verification.
* @param {string} token
* @param {string} token
* @returns {Object|null}
*/
decode(token) {
@@ -67,8 +67,8 @@ class EncryptionService {
/**
* Encrypts a payload using AES.
* @param {any} payload
* @param {string} [type=typeof payload]
* @param {any} payload
* @param {string} [type=typeof payload]
* @returns {{ encrypted: string, type: string }}
*/
encrypt(payload, type = typeof payload) {
@@ -81,7 +81,7 @@ class EncryptionService {
/**
* Decrypts AES-encrypted data.
* @param {{ encrypted: string, type: string }} encryptedPayload
* @param {{ encrypted: string, type: string }} encryptedPayload
* @returns {any}
*/
decrypt(encryptedPayload) {
@@ -92,9 +92,12 @@ class EncryptionService {
if (!decrypted) throw new Error('Decryption failed');
switch (type) {
case 'object': return JSON.parse(decrypted);
case 'number': return Number(decrypted);
default: return decrypted;
case 'object':
return JSON.parse(decrypted);
case 'number':
return Number(decrypted);
default:
return decrypted;
}
}
}
@@ -105,15 +108,13 @@ class EncryptionService {
class PayloadComparator {
/**
* Checks if actual matches expected payload.
* @param {Object} expected
* @param {Object} actual
* @param {Object} expected
* @param {Object} actual
* @returns {boolean}
*/
static match(expected, actual) {
if (typeof expected === 'object') {
return Object.keys(expected).every(key =>
JSON.stringify(expected[key]) === JSON.stringify(actual[key])
);
return Object.keys(expected).every((key) => JSON.stringify(expected[key]) === JSON.stringify(actual[key]));
}
const value = actual?.value ?? actual;
@@ -122,13 +123,13 @@ class PayloadComparator {
/**
* Returns the difference between expected and actual payloads.
* @param {Object} expected
* @param {Object} actual
* @param {Object} expected
* @param {Object} actual
* @returns {Object}
*/
static diff(expected, actual) {
const diff = {};
Object.keys(expected).forEach(key => {
Object.keys(expected).forEach((key) => {
if (JSON.stringify(expected[key]) !== JSON.stringify(actual[key])) {
diff[key] = { expected: expected[key], actual: actual[key] };
}
@@ -141,9 +142,9 @@ class PayloadComparator {
* TokenManager class that handles logs
*/
class TokenLogger {
constructor(LoggerClass) {
return new LoggerClass('TokenManager');
}
constructor(LoggerClass) {
return new LoggerClass('TokenManager');
}
}
/**
@@ -164,9 +165,9 @@ class TokenManager {
/**
* Creates a JWT token, optionally encrypting the payload.
* @param {any} payload
* @param {any} payload
* @param {boolean} [encode=false] - Whether to encrypt the payload.
* @param {string|number} [expiresIn=defaultExpiry]
* @param {string|number} [expiresIn=defaultExpiry]
* @returns {string}
*/
create(payload, encode = false, expiresIn = this.defaultExpiry) {
@@ -176,7 +177,9 @@ class TokenManager {
const expiry = this._normalizeExpiry(expiresIn);
const data = encode
? this.encryptionService.encrypt(payload)
: typeof payload === 'object' ? payload : { value: payload };
: typeof payload === 'object'
? payload
: { value: payload };
return this.jwtService.sign(data, expiry);
} catch (error) {
@@ -187,19 +190,17 @@ class TokenManager {
/**
* Validates a token and checks if payload matches.
* @param {any} expectedPayload
* @param {string} token
* @param {any} expectedPayload
* @param {string} token
* @param {boolean} [decode=false] - Whether to decrypt the token.
* @param {boolean} [ignoreExpiry=false]
* @param {boolean} [ignoreExpiry=false]
* @returns {boolean}
*/
validate(expectedPayload, token, decode = false, ignoreExpiry = false) {
try {
const decoded = this.jwtService.verify(token, ignoreExpiry);
const payload = decode
? this.encryptionService.decrypt(decoded)
: decoded;
const payload = decode ? this.encryptionService.decrypt(decoded) : decoded;
const isMatch = PayloadComparator.match(expectedPayload, payload);
@@ -220,15 +221,13 @@ class TokenManager {
/**
* Decodes and decrypts token payload if necessary.
* @param {string} token
* @param {string} token
* @returns {any|null}
*/
decodePayload(token) {
try {
const decoded = this.jwtService.verify(token);
return decoded?.encrypted
? this.encryptionService.decrypt(decoded)
: decoded;
return decoded?.encrypted ? this.encryptionService.decrypt(decoded) : decoded;
} catch (error) {
this.logger.error('Decode failed', { error: error.message });
return null;
@@ -237,7 +236,7 @@ class TokenManager {
/**
* Extracts raw payload from a token without verification.
* @param {string} token
* @param {string} token
* @returns {any|null}
*/
extractPayload(token) {
@@ -255,7 +254,7 @@ class TokenManager {
/**
* Normalizes expiration format.
* @private
* @param {string|number} exp
* @param {string|number} exp
* @returns {string|number}
*/
_normalizeExpiry(exp) {
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "mirotalk",
"version": "1.5.05",
"version": "1.5.06",
"description": "A free WebRTC browser-based video call",
"main": "server.js",
"scripts": {
@@ -43,8 +43,8 @@
"dependencies": {
"@mattermost/client": "10.6.0",
"@ngrok/ngrok": "1.5.0",
"@sentry/node": "^9.13.0",
"axios": "^1.8.4",
"@sentry/node": "^9.15.0",
"axios": "^1.9.0",
"chokidar": "^4.0.3",
"colors": "^1.4.0",
"compression": "^1.8.0",
@@ -61,16 +61,16 @@
"jsonwebtoken": "^9.0.2",
"js-yaml": "^4.1.0",
"nodemailer": "^6.10.1",
"openai": "^4.95.1",
"openai": "^4.96.2",
"qs": "^6.14.0",
"socket.io": "^4.8.1",
"swagger-ui-express": "^5.0.1",
"uuid": "11.1.0"
},
"devDependencies": {
"mocha": "^11.1.0",
"mocha": "^11.2.2",
"node-fetch": "^3.3.2",
"nodemon": "^3.1.9",
"nodemon": "^3.1.10",
"prettier": "3.5.3",
"proxyquire": "^2.1.3",
"should": "^13.2.3",
+1 -1
View File
@@ -73,7 +73,7 @@ let brand = {
},
about: {
imageUrl: '../images/mirotalk-logo.gif',
title: 'WebRTC P2P v1.5.05',
title: 'WebRTC P2P v1.5.06',
html: `
<button
id="support-button"
+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.5.05
* @version 1.5.06
*
*/
@@ -11158,7 +11158,7 @@ function showAbout() {
Swal.fire({
background: swBg,
position: 'center',
title: brand.about?.title && brand.about.title.trim() !== '' ? brand.about.title : 'WebRTC P2P v1.5.05',
title: brand.about?.title && brand.about.title.trim() !== '' ? brand.about.title : 'WebRTC P2P v1.5.06',
imageUrl: brand.about?.imageUrl && brand.about.imageUrl.trim() !== '' ? brand.about.imageUrl : images.about,
customClass: { image: 'img-about' },
html: `