better we.bslty & deveop integration
This commit is contained in:
@@ -5,6 +5,10 @@ import { adminApi } from "../Services/AdminApi";
|
||||
import { AuthTokenData, jwtTokenManager } from "../Services/JWTTokenManager";
|
||||
import { parse } from "query-string";
|
||||
import { openIDClient } from "../Services/OpenIDClient";
|
||||
import { FRONT_URL, DEBUG_IGNORE_SSL } from "../Enum/EnvironmentVariable"
|
||||
import Axios from "axios";
|
||||
import { AxiosRequestConfig } from "axios";
|
||||
import https from "https";
|
||||
|
||||
export interface TokenInterface {
|
||||
userUuid: string;
|
||||
@@ -165,12 +169,27 @@ export class AuthenticateController extends BaseController {
|
||||
res.end();
|
||||
});
|
||||
|
||||
this.App.post("/anonymLogin", (res: HttpResponse, req: HttpRequest) => {
|
||||
this.App.post("/anonymLogin", async (res: HttpResponse, req: HttpRequest) => {
|
||||
res.onAborted(() => {
|
||||
console.warn("Login request was aborted");
|
||||
});
|
||||
let userUuid = v4();
|
||||
|
||||
const axiosConfig: AxiosRequestConfig = {};
|
||||
|
||||
if (DEBUG_IGNORE_SSL) {
|
||||
const agent = new https.Agent({
|
||||
rejectUnauthorized: false,
|
||||
});
|
||||
axiosConfig.httpsAgent = agent;
|
||||
}
|
||||
|
||||
const response = await Axios.get(FRONT_URL, axiosConfig);
|
||||
|
||||
if (response.headers[ 'bstlyuserid' ]) {
|
||||
userUuid = response.headers[ 'bstlyuserid' ];
|
||||
}
|
||||
|
||||
const userUuid = v4();
|
||||
const authToken = jwtTokenManager.createAuthToken(userUuid);
|
||||
res.writeStatus("200 OK");
|
||||
this.addCorsHeaders(res);
|
||||
|
||||
@@ -245,7 +245,7 @@ export class IoSocketController {
|
||||
roomId
|
||||
);
|
||||
console.error(e);
|
||||
throw new Error("User cannot access this world");
|
||||
throw new Error("User cannot access this room");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ export const FRONT_URL = process.env.FRONT_URL || "http://localhost";
|
||||
export const OPID_CLIENT_ID = process.env.OPID_CLIENT_ID || "";
|
||||
export const OPID_CLIENT_SECRET = process.env.OPID_CLIENT_SECRET || "";
|
||||
export const OPID_CLIENT_ISSUER = process.env.OPID_CLIENT_ISSUER || "";
|
||||
export const DEBUG_IGNORE_SSL = process.env.DEBUG_IGNORE_SSL ? process.env.DEBUG_IGNORE_SSL == "true" : false;
|
||||
export const DEBUG_PUSHER_FORCE_ROOM_UPDATE = process.env.DEBUG_PUSHER_FORCE_ROOM_UPDATE ? process.env.DEBUG_PUSHER_FORCE_ROOM_UPDATE == "true" : false;
|
||||
|
||||
export {
|
||||
SECRET_KEY,
|
||||
|
||||
@@ -36,7 +36,7 @@ import {
|
||||
WorldFullMessage,
|
||||
} from "../Messages/generated/messages_pb";
|
||||
import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils";
|
||||
import { ADMIN_API_URL, JITSI_ISS, JITSI_URL, SECRET_JITSI_KEY } from "../Enum/EnvironmentVariable";
|
||||
import { ADMIN_API_URL, JITSI_ISS, JITSI_URL, SECRET_JITSI_KEY, DEBUG_PUSHER_FORCE_ROOM_UPDATE } from "../Enum/EnvironmentVariable";
|
||||
import { adminApi } from "./AdminApi";
|
||||
import { emitInBatch } from "./IoSocketHelpers";
|
||||
import Jwt from "jsonwebtoken";
|
||||
@@ -366,7 +366,7 @@ export class SocketManager implements ZoneEventListener {
|
||||
async getOrCreateRoom(roomUrl: string): Promise<PusherRoom> {
|
||||
//check and create new world for a room
|
||||
let room = this.rooms.get(roomUrl);
|
||||
if (room === undefined) {
|
||||
if (DEBUG_PUSHER_FORCE_ROOM_UPDATE || room === undefined) {
|
||||
room = new PusherRoom(roomUrl, this);
|
||||
if (ADMIN_API_URL) {
|
||||
await this.updateRoomWithAdminData(room);
|
||||
|
||||
Reference in New Issue
Block a user