[mirotalk] - improve/update REST API
This commit is contained in:
+22
-11
@@ -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:
|
||||
|
||||
+24
-10
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
+1
-1
@@ -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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
+1
-1
@@ -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": {
|
||||
|
||||
+1
-1
@@ -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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user