Fix prettier and change last use of adminAPI to Service way
This commit is contained in:
parent
3767555e38
commit
0ac6b50469
@ -1,6 +1,6 @@
|
|||||||
import { v4 } from "uuid";
|
import { v4 } from "uuid";
|
||||||
import { BaseHttpController } from "./BaseHttpController";
|
import { BaseHttpController } from "./BaseHttpController";
|
||||||
import { adminApi, FetchMemberDataByUuidResponse } from "../Services/AdminApi";
|
import { FetchMemberDataByUuidResponse } from "../Services/AdminApi";
|
||||||
import { AuthTokenData, jwtTokenManager } from "../Services/JWTTokenManager";
|
import { AuthTokenData, jwtTokenManager } from "../Services/JWTTokenManager";
|
||||||
import { parse } from "query-string";
|
import { parse } from "query-string";
|
||||||
import { openIDClient } from "../Services/OpenIDClient";
|
import { openIDClient } from "../Services/OpenIDClient";
|
||||||
@ -508,7 +508,7 @@ export class AuthenticateController extends BaseHttpController {
|
|||||||
userRoomToken: undefined,
|
userRoomToken: undefined,
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
data = await adminApi.fetchMemberDataByUuid(email, playUri, IPAddress, []);
|
data = await adminService.fetchMemberDataByUuid(email, playUri, IPAddress, []);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("openIDCallback => fetchMemberDataByUuid", err);
|
console.error("openIDCallback => fetchMemberDataByUuid", err);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ import { localWokaService } from "../Services/LocalWokaService";
|
|||||||
import { WebSocket } from "uWebSockets.js";
|
import { WebSocket } from "uWebSockets.js";
|
||||||
import { WokaDetail } from "../Messages/JsonMessages/PlayerTextures";
|
import { WokaDetail } from "../Messages/JsonMessages/PlayerTextures";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import {adminService} from "../Services/AdminService";
|
import { adminService } from "../Services/AdminService";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object passed between the "open" and the "upgrade" methods when opening a websocket
|
* The object passed between the "open" and the "upgrade" methods when opening a websocket
|
||||||
|
@ -2,7 +2,7 @@ import { DISABLE_ANONYMOUS } from "../Enum/EnvironmentVariable";
|
|||||||
import { isMapDetailsData } from "../Messages/JsonMessages/MapDetailsData";
|
import { isMapDetailsData } from "../Messages/JsonMessages/MapDetailsData";
|
||||||
import { parse } from "query-string";
|
import { parse } from "query-string";
|
||||||
import { BaseHttpController } from "./BaseHttpController";
|
import { BaseHttpController } from "./BaseHttpController";
|
||||||
import {adminService} from "../Services/AdminService";
|
import { adminService } from "../Services/AdminService";
|
||||||
|
|
||||||
export class MapController extends BaseHttpController {
|
export class MapController extends BaseHttpController {
|
||||||
// Returns a map mapping map name to file name of the map
|
// Returns a map mapping map name to file name of the map
|
||||||
|
@ -7,8 +7,8 @@ import { z } from "zod";
|
|||||||
import { isWokaDetail } from "../Messages/JsonMessages/PlayerTextures";
|
import { isWokaDetail } from "../Messages/JsonMessages/PlayerTextures";
|
||||||
import qs from "qs";
|
import qs from "qs";
|
||||||
import { AdminInterface } from "./AdminInterface";
|
import { AdminInterface } from "./AdminInterface";
|
||||||
import {AuthTokenData, jwtTokenManager} from "./JWTTokenManager";
|
import { AuthTokenData, jwtTokenManager } from "./JWTTokenManager";
|
||||||
import {InvalidTokenError} from "../Controller/InvalidTokenError";
|
import { InvalidTokenError } from "../Controller/InvalidTokenError";
|
||||||
|
|
||||||
export interface AdminBannedData {
|
export interface AdminBannedData {
|
||||||
is_banned: boolean;
|
is_banned: boolean;
|
||||||
@ -46,13 +46,13 @@ class AdminApi implements AdminInterface {
|
|||||||
console.info("JWT expire, but decoded", userId);
|
console.info("JWT expire, but decoded", userId);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof InvalidTokenError) {
|
if (e instanceof InvalidTokenError) {
|
||||||
throw new Error('Token decrypted error');
|
throw new Error("Token decrypted error");
|
||||||
// The token was not good, redirect user on login page
|
// The token was not good, redirect user on login page
|
||||||
//res.status(401);
|
//res.status(401);
|
||||||
//res.send("Token decrypted error");
|
//res.send("Token decrypted error");
|
||||||
//return;
|
//return;
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Error on decryption of token :' + e);
|
throw new Error("Error on decryption of token :" + e);
|
||||||
//this.castErrorToResponse(e, res);
|
//this.castErrorToResponse(e, res);
|
||||||
//return;
|
//return;
|
||||||
}
|
}
|
||||||
@ -190,7 +190,7 @@ class AdminApi implements AdminInterface {
|
|||||||
return `${OPID_PROFILE_SCREEN_PROVIDER}?accessToken=${accessToken}`;
|
return `${OPID_PROFILE_SCREEN_PROVIDER}?accessToken=${accessToken}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async logoutOauth(token: string): Promise<void>{
|
async logoutOauth(token: string): Promise<void> {
|
||||||
await Axios.get(ADMIN_API_URL + `/oauth/logout?token=${token}`);
|
await Axios.get(ADMIN_API_URL + `/oauth/logout?token=${token}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {AdminBannedData, FetchMemberDataByUuidResponse} from "./AdminApi";
|
import { AdminBannedData, FetchMemberDataByUuidResponse } from "./AdminApi";
|
||||||
import {MapDetailsData} from "../Messages/JsonMessages/MapDetailsData";
|
import { MapDetailsData } from "../Messages/JsonMessages/MapDetailsData";
|
||||||
import {RoomRedirect} from "../Messages/JsonMessages/RoomRedirect";
|
import { RoomRedirect } from "../Messages/JsonMessages/RoomRedirect";
|
||||||
import {AdminApiData} from "../Messages/JsonMessages/AdminApiData";
|
import { AdminApiData } from "../Messages/JsonMessages/AdminApiData";
|
||||||
|
|
||||||
export interface AdminInterface {
|
export interface AdminInterface {
|
||||||
locale: string;
|
locale: string;
|
||||||
@ -25,20 +25,14 @@ export interface AdminInterface {
|
|||||||
* @var userId: can to be undefined or email or uuid
|
* @var userId: can to be undefined or email or uuid
|
||||||
* @return MapDetailsData|RoomRedirect
|
* @return MapDetailsData|RoomRedirect
|
||||||
*/
|
*/
|
||||||
fetchMapDetails(
|
fetchMapDetails(playUri: string, authToken?: string): Promise<MapDetailsData | RoomRedirect>;
|
||||||
playUri: string,
|
|
||||||
authToken?: string
|
|
||||||
): Promise<MapDetailsData | RoomRedirect>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param organizationMemberToken
|
* @param organizationMemberToken
|
||||||
* @param playUri
|
* @param playUri
|
||||||
* @return AdminApiData
|
* @return AdminApiData
|
||||||
*/
|
*/
|
||||||
fetchMemberDataByToken(
|
fetchMemberDataByToken(organizationMemberToken: string, playUri: string | null): Promise<AdminApiData>;
|
||||||
organizationMemberToken: string,
|
|
||||||
playUri: string | null
|
|
||||||
): Promise<AdminApiData>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param reportedUserUuid
|
* @param reportedUserUuid
|
||||||
@ -59,32 +53,22 @@ export interface AdminInterface {
|
|||||||
* @param roomUrl
|
* @param roomUrl
|
||||||
* @return AdminBannedData
|
* @return AdminBannedData
|
||||||
*/
|
*/
|
||||||
verifyBanUser(
|
verifyBanUser(userUuid: string, ipAddress: string, roomUrl: string): Promise<AdminBannedData>;
|
||||||
userUuid: string,
|
|
||||||
ipAddress: string,
|
|
||||||
roomUrl: string
|
|
||||||
): Promise<AdminBannedData>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param roomUrl
|
* @param roomUrl
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
getUrlRoomsFromSameWorld(
|
getUrlRoomsFromSameWorld(roomUrl: string): Promise<string[]>;
|
||||||
roomUrl: string
|
|
||||||
): Promise<string[]>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param accessToken
|
* @param accessToken
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
getProfileUrl(
|
getProfileUrl(accessToken: string): string;
|
||||||
accessToken: string
|
|
||||||
): string;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param token
|
* @param token
|
||||||
*/
|
*/
|
||||||
logoutOauth(
|
logoutOauth(token: string): Promise<void>;
|
||||||
token: string
|
|
||||||
): Promise<void>;
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
import {AdminBannedData, FetchMemberDataByUuidResponse} from "./AdminApi";
|
import { AdminBannedData, FetchMemberDataByUuidResponse } from "./AdminApi";
|
||||||
import {AdminInterface} from "./AdminInterface";
|
import { AdminInterface } from "./AdminInterface";
|
||||||
import {MapDetailsData} from "../Messages/JsonMessages/MapDetailsData";
|
import { MapDetailsData } from "../Messages/JsonMessages/MapDetailsData";
|
||||||
import {RoomRedirect} from "../Messages/JsonMessages/RoomRedirect";
|
import { RoomRedirect } from "../Messages/JsonMessages/RoomRedirect";
|
||||||
import {GameRoomPolicyTypes} from "../Model/PusherRoom";
|
import { GameRoomPolicyTypes } from "../Model/PusherRoom";
|
||||||
import {ADMIN_API_URL, DISABLE_ANONYMOUS, OPID_PROFILE_SCREEN_PROVIDER} from "../Enum/EnvironmentVariable";
|
import { DISABLE_ANONYMOUS } from "../Enum/EnvironmentVariable";
|
||||||
import {AdminApiData} from "../Messages/JsonMessages/AdminApiData";
|
import { AdminApiData } from "../Messages/JsonMessages/AdminApiData";
|
||||||
import Axios from "axios";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A local class mocking a real admin if no admin is configured.
|
* A local class mocking a real admin if no admin is configured.
|
||||||
@ -38,7 +37,6 @@ class LocalAdmin implements AdminInterface {
|
|||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
authToken?: string
|
authToken?: string
|
||||||
): Promise<MapDetailsData | RoomRedirect> {
|
): Promise<MapDetailsData | RoomRedirect> {
|
||||||
|
|
||||||
const roomUrl = new URL(playUri);
|
const roomUrl = new URL(playUri);
|
||||||
|
|
||||||
const match = /\/_\/[^/]+\/(.+)/.exec(roomUrl.pathname);
|
const match = /\/_\/[^/]+\/(.+)/.exec(roomUrl.pathname);
|
||||||
@ -58,7 +56,7 @@ class LocalAdmin implements AdminInterface {
|
|||||||
group: null,
|
group: null,
|
||||||
iframeAuthentication: null,
|
iframeAuthentication: null,
|
||||||
loadingLogo: null,
|
loadingLogo: null,
|
||||||
loginSceneLogo: null
|
loginSceneLogo: null,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +111,7 @@ class LocalAdmin implements AdminInterface {
|
|||||||
async logoutOauth(
|
async logoutOauth(
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
token: string
|
token: string
|
||||||
): Promise<void>{
|
): Promise<void> {
|
||||||
return Promise.reject(new Error("No admin backoffice set!"));
|
return Promise.reject(new Error("No admin backoffice set!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ import Debug from "debug";
|
|||||||
import { ExAdminSocketInterface } from "../Model/Websocket/ExAdminSocketInterface";
|
import { ExAdminSocketInterface } from "../Model/Websocket/ExAdminSocketInterface";
|
||||||
import { compressors } from "hyper-express";
|
import { compressors } from "hyper-express";
|
||||||
import { isMapDetailsData } from "../Messages/JsonMessages/MapDetailsData";
|
import { isMapDetailsData } from "../Messages/JsonMessages/MapDetailsData";
|
||||||
import {adminService} from "./AdminService";
|
import { adminService } from "./AdminService";
|
||||||
|
|
||||||
const debug = Debug("socket");
|
const debug = Debug("socket");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user