[mirotalksfu] - add token endpoint
هذا الالتزام موجود في:
@@ -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 +
|
||||
'¬ify=' +
|
||||
notifyValue +
|
||||
jwtToken
|
||||
);
|
||||
'/join?' +
|
||||
`room=${roomValue}` +
|
||||
`&roomPassword=${roomPasswordValue}` +
|
||||
`&name=${encodeURIComponent(nameValue)}` +
|
||||
`&audio=${audioValue}` +
|
||||
`&video=${videoValue}` +
|
||||
`&screen=${screenValue}` +
|
||||
`¬ify=${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() {
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم