[mirotalksfu] - add token endpoint

هذا الالتزام موجود في:
Miroslav Pejic
2024-02-23 13:43:01 +01:00
الأصل 5bdf4ed4f5
التزام dea4577e53
11 ملفات معدلة مع 211 إضافات و41 حذوفات

عرض الملف

@@ -28,49 +28,46 @@ module.exports = class ServerApi {
const { room, roomPassword, name, audio, video, screen, notify, token } = data;
const roomValue = room || uuidV4();
const roomPasswordValue = roomPassword || false;
const nameValue = name || 'User-' + this.getRandomNumber();
const roomPasswordValue = roomPassword || false;
const audioValue = audio || false;
const videoValue = video || false;
const screenValue = screen || false;
const notifyValue = notify || false;
const jwtToken = token ? '&token=' + this.getToken(token) : '';
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: usernameValue, password: passwordValue, presenter: presenterValue }, JWT_KEY, {
expiresIn: expireValue,
});
}
return (
const joinURL =
'https://' +
this._host +
'/join?room=' +
roomValue +
'&roomPassword=' +
roomPasswordValue +
'&name=' +
nameValue +
'&audio=' +
audioValue +
'&video=' +
videoValue +
'&screen=' +
screenValue +
'&notify=' +
notifyValue +
jwtToken
);
'/join?' +
`room=${roomValue}` +
`&roomPassword=${roomPasswordValue}` +
`&name=${encodeURIComponent(nameValue)}` +
`&audio=${audioValue}` +
`&video=${videoValue}` +
`&screen=${screenValue}` +
`&notify=${notifyValue}` +
jwtToken;
return joinURL;
}
getToken(token) {
if (!token) return '';
const { username = 'username', password = 'password', presenter = false, expire } = token;
const expireValue = expire || JWT_EXP;
const payload = {
username: String(username),
password: String(password),
presenter: String(presenter),
};
const jwtToken = jwt.sign(payload, JWT_KEY, { expiresIn: expireValue });
return jwtToken;
}
getRandomNumber() {