diff --git a/app/api/swagger.yaml b/app/api/swagger.yaml index 2b120446..e097af7c 100644 --- a/app/api/swagger.yaml +++ b/app/api/swagger.yaml @@ -43,14 +43,6 @@ paths: description: Custom Join URL. schema: type: object - required: - - room - - name - - audio - - video - - screen - - hide - - notify properties: room: type: string @@ -60,10 +52,10 @@ paths: default: 'mirotalk' audio: type: boolean - default: true + default: false video: type: boolean - default: true + default: false screen: type: boolean default: false @@ -72,7 +64,26 @@ paths: default: false notify: type: boolean - default: true + default: false + token: + type: object + description: | + Object containing authentication token details. + This token is required when HOST_PROTECTED or HOST_USER_AUTH is enabled in the .env file. + It includes properties such as username, password, presenter, and expire. + properties: + username: + type: string + default: 'username' + password: + type: string + default: 'password' + presenter: + type: boolean + default: true + expire: + type: string + default: '1h' consumes: - 'application/json' produces: diff --git a/app/src/api.js b/app/src/api.js index 97244376..f3c82165 100644 --- a/app/src/api.js +++ b/app/src/api.js @@ -5,7 +5,6 @@ const { v4: uuidV4 } = require('uuid'); const JWT_KEY = process.env.JWT_KEY || 'mirotalk_jwt_secret'; const JWT_EXP = process.env.JWT_EXP || '1h'; - module.exports = class ServerApi { constructor(host = null, authorization = null, api_key_secret = null) { this._host = host; @@ -26,33 +25,48 @@ module.exports = class ServerApi { // Get data... const { room, name, audio, video, screen, hide, notify, token } = data; + const roomValue = room || uuidV4(); + const nameValue = name || uuidV4(); + const audioValue = audio || false; + const videoValue = video || false; + const screenValue = screen || false; + const hideValue = hide || false; + const notifyValue = notify || false; + let jwtToken = ''; if (token) { + // JWT.io const { username, password, presenter, expire } = token; + + const usernameValue = username || 'username'; + const passwordValue = password || 'password'; + const presenterValue = String(presenter); + const expireValue = expire || JWT_EXP; + jwtToken = '&token=' + - jwt.sign({ username: username, password: password, presenter: presenter }, JWT_KEY, { - expiresIn: expire ? expire : JWT_EXP, + jwt.sign({ username: usernameValue, password: passwordValue, presenter: presenterValue }, JWT_KEY, { + expiresIn: expireValue, }); } return ( this.getProtocol() + this._host + '/join?room=' + - room + + roomValue + '&name=' + - name + + nameValue + '&audio=' + - audio + + audioValue + '&video=' + - video + + videoValue + '&screen=' + - screen + + screenValue + '&hide=' + - hide + + hideValue + '¬ify=' + - notify + + notifyValue + jwtToken ); } diff --git a/app/src/server.js b/app/src/server.js index d2f970f7..2c802a26 100755 --- a/app/src/server.js +++ b/app/src/server.js @@ -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.2.86 + * @version 1.2.87 * */ diff --git a/package.json b/package.json index a9cc2567..fe1fccc3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mirotalk", - "version": "1.2.86", + "version": "1.2.87", "description": "A free WebRTC browser-based video call", "main": "server.js", "scripts": { diff --git a/public/js/client.js b/public/js/client.js index 965495c3..230836d7 100644 --- a/public/js/client.js +++ b/public/js/client.js @@ -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.2.86 + * @version 1.2.87 * */