Merge branch 'develop' of github.com:thecodingmachine/workadventure
This commit is contained in:
@@ -1 +1,2 @@
|
||||
src/Messages/generated
|
||||
src/Messages/JsonMessages
|
||||
|
||||
@@ -11,6 +11,8 @@ COPY pusher/yarn.lock pusher/package.json ./
|
||||
RUN yarn install
|
||||
COPY pusher .
|
||||
COPY --from=messages /usr/src/generated src/Messages/generated
|
||||
COPY --from=messages /usr/src/JsonMessages src/Messages/JsonMessages
|
||||
|
||||
ENV NODE_ENV=production
|
||||
RUN yarn run tsc
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import { AuthTokenData, jwtTokenManager } from "../Services/JWTTokenManager";
|
||||
import { parse } from "query-string";
|
||||
import { openIDClient } from "../Services/OpenIDClient";
|
||||
import { DISABLE_ANONYMOUS, FRONT_URL } from "../Enum/EnvironmentVariable";
|
||||
import { RegisterData } from "../Messages/JsonMessages/RegisterData";
|
||||
|
||||
export interface TokenInterface {
|
||||
userUuid: string;
|
||||
@@ -83,7 +84,7 @@ export class AuthenticateController extends BaseController {
|
||||
console.error("Token cannot to be check on OpenId provider");
|
||||
res.writeStatus("500");
|
||||
res.writeHeader("Access-Control-Allow-Origin", FRONT_URL);
|
||||
res.end("User cannot to be connected on openid provier");
|
||||
res.end("User cannot to be connected on openid provider");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -105,7 +106,7 @@ export class AuthenticateController extends BaseController {
|
||||
console.error("User cannot to be connected on OpenId provider => ", err);
|
||||
res.writeStatus("500");
|
||||
res.writeHeader("Access-Control-Allow-Origin", FRONT_URL);
|
||||
res.end("User cannot to be connected on openid provier");
|
||||
res.end("User cannot to be connected on openid provider");
|
||||
return;
|
||||
}
|
||||
const sub = userInfo.sub;
|
||||
@@ -191,7 +192,7 @@ export class AuthenticateController extends BaseController {
|
||||
mapUrlStart,
|
||||
organizationMemberToken,
|
||||
textures,
|
||||
})
|
||||
} as RegisterData)
|
||||
);
|
||||
} catch (e) {
|
||||
console.error("register => ERROR", e);
|
||||
|
||||
@@ -29,7 +29,7 @@ import { emitInBatch } from "../Services/IoSocketHelpers";
|
||||
import { ADMIN_API_URL, DISABLE_ANONYMOUS, SOCKET_IDLE_TIMER } from "../Enum/EnvironmentVariable";
|
||||
import { Zone } from "_Model/Zone";
|
||||
import { ExAdminSocketInterface } from "_Model/Websocket/ExAdminSocketInterface";
|
||||
import { CharacterTexture } from "../Services/AdminApi/CharacterTexture";
|
||||
import { CharacterTexture } from "../Messages/JsonMessages/CharacterTexture";
|
||||
import { isAdminMessageInterface } from "../Model/Websocket/Admin/AdminMessages";
|
||||
import Axios from "axios";
|
||||
import { InvalidTokenError } from "../Controller/InvalidTokenError";
|
||||
|
||||
@@ -4,7 +4,7 @@ import { parse } from "query-string";
|
||||
import { adminApi } from "../Services/AdminApi";
|
||||
import { ADMIN_API_URL, DISABLE_ANONYMOUS, FRONT_URL } from "../Enum/EnvironmentVariable";
|
||||
import { GameRoomPolicyTypes } from "../Model/PusherRoom";
|
||||
import { isMapDetailsData, MapDetailsData } from "../Services/AdminApi/MapDetailsData";
|
||||
import { isMapDetailsData, MapDetailsData } from "../Messages/JsonMessages/MapDetailsData";
|
||||
import { socketManager } from "../Services/SocketManager";
|
||||
import { AuthTokenData, jwtTokenManager } from "../Services/JWTTokenManager";
|
||||
import { v4 } from "uuid";
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
import { WebSocket } from "uWebSockets.js";
|
||||
import { ClientDuplexStream } from "grpc";
|
||||
import { Zone } from "_Model/Zone";
|
||||
import { CharacterTexture } from "../../Services/AdminApi/CharacterTexture";
|
||||
import { CharacterTexture } from "../../Messages/JsonMessages/CharacterTexture";
|
||||
|
||||
export type BackConnection = ClientDuplexStream<PusherToBackMessage, ServerToClientMessage>;
|
||||
|
||||
|
||||
@@ -1,20 +1,10 @@
|
||||
import { ADMIN_API_TOKEN, ADMIN_API_URL, ADMIN_URL, OPID_PROFILE_SCREEN_PROVIDER } from "../Enum/EnvironmentVariable";
|
||||
import Axios from "axios";
|
||||
import { GameRoomPolicyTypes } from "_Model/PusherRoom";
|
||||
import { CharacterTexture } from "./AdminApi/CharacterTexture";
|
||||
import { MapDetailsData } from "./AdminApi/MapDetailsData";
|
||||
import { RoomRedirect } from "./AdminApi/RoomRedirect";
|
||||
|
||||
export interface AdminApiData {
|
||||
roomUrl: string;
|
||||
email: string | null;
|
||||
mapUrlStart: string;
|
||||
tags: string[];
|
||||
policy_type: number;
|
||||
userUuid: string;
|
||||
messages?: unknown[];
|
||||
textures: CharacterTexture[];
|
||||
}
|
||||
import { CharacterTexture } from "../Messages/JsonMessages/CharacterTexture";
|
||||
import { MapDetailsData } from "../Messages/JsonMessages/MapDetailsData";
|
||||
import { RoomRedirect } from "../Messages/JsonMessages/RoomRedirect";
|
||||
import { AdminApiData, isAdminApiData } from "../Messages/JsonMessages/AdminApiData";
|
||||
|
||||
export interface AdminBannedData {
|
||||
is_banned: boolean;
|
||||
@@ -78,6 +68,10 @@ class AdminApi {
|
||||
const res = await Axios.get(ADMIN_API_URL + "/api/login-url/" + organizationMemberToken, {
|
||||
headers: { Authorization: `${ADMIN_API_TOKEN}` },
|
||||
});
|
||||
if (!isAdminApiData(res.data)) {
|
||||
console.error("Message received from /api/login-url is not in the expected format. Message: ", res.data);
|
||||
throw new Error("Message received from /api/login-url is not in the expected format.");
|
||||
}
|
||||
return res.data;
|
||||
}
|
||||
|
||||
@@ -89,6 +83,10 @@ class AdminApi {
|
||||
const res = await Axios.get(ADMIN_API_URL + "/api/check-user/" + organizationMemberToken, {
|
||||
headers: { Authorization: `${ADMIN_API_TOKEN}` },
|
||||
});
|
||||
if (!isAdminApiData(res.data)) {
|
||||
console.error("Message received from /api/check-user is not in the expected format. Message: ", res.data);
|
||||
throw new Error("Message received from /api/check-user is not in the expected format.");
|
||||
}
|
||||
return res.data;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import * as tg from "generic-type-guard";
|
||||
|
||||
export const isCharacterTexture = new tg.IsInterface()
|
||||
.withProperties({
|
||||
id: tg.isNumber,
|
||||
level: tg.isNumber,
|
||||
url: tg.isString,
|
||||
rights: tg.isString,
|
||||
})
|
||||
.get();
|
||||
export type CharacterTexture = tg.GuardedType<typeof isCharacterTexture>;
|
||||
@@ -1,23 +0,0 @@
|
||||
import * as tg from "generic-type-guard";
|
||||
import { GameRoomPolicyTypes } from "_Model/PusherRoom";
|
||||
import { isCharacterTexture } from "./CharacterTexture";
|
||||
import { isAny, isNumber } from "generic-type-guard";
|
||||
|
||||
/*const isNumericEnum =
|
||||
<T extends { [n: number]: string }>(vs: T) =>
|
||||
(v: any): v is T =>
|
||||
typeof v === "number" && v in vs;*/
|
||||
|
||||
export const isMapDetailsData = new tg.IsInterface()
|
||||
.withProperties({
|
||||
roomSlug: tg.isOptional(tg.isString), // deprecated
|
||||
mapUrl: tg.isString,
|
||||
policy_type: isNumber, //isNumericEnum(GameRoomPolicyTypes),
|
||||
tags: tg.isArray(tg.isString),
|
||||
textures: tg.isArray(isCharacterTexture),
|
||||
contactPage: tg.isUnion(tg.isString, tg.isUndefined),
|
||||
authenticationMandatory: tg.isUnion(tg.isBoolean, tg.isUndefined),
|
||||
})
|
||||
.get();
|
||||
|
||||
export type MapDetailsData = tg.GuardedType<typeof isMapDetailsData>;
|
||||
@@ -1,8 +0,0 @@
|
||||
import * as tg from "generic-type-guard";
|
||||
|
||||
export const isRoomRedirect = new tg.IsInterface()
|
||||
.withProperties({
|
||||
redirectUrl: tg.isString,
|
||||
})
|
||||
.get();
|
||||
export type RoomRedirect = tg.GuardedType<typeof isRoomRedirect>;
|
||||
@@ -48,8 +48,8 @@ import { GroupDescriptor, UserDescriptor, ZoneEventListener } from "_Model/Zone"
|
||||
import Debug from "debug";
|
||||
import { ExAdminSocketInterface } from "_Model/Websocket/ExAdminSocketInterface";
|
||||
import { WebSocket } from "uWebSockets.js";
|
||||
import { isRoomRedirect } from "./AdminApi/RoomRedirect";
|
||||
import { CharacterTexture } from "./AdminApi/CharacterTexture";
|
||||
import { isRoomRedirect } from "../Messages/JsonMessages/RoomRedirect";
|
||||
import { CharacterTexture } from "../Messages/JsonMessages/CharacterTexture";
|
||||
|
||||
const debug = Debug("socket");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user