From 876ddc87d22d9f716eefded374e872b8183f265c Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Mon, 7 Feb 2022 19:26:34 +0100 Subject: [PATCH 01/17] =?UTF-8?q?Change=20acc=C3=A8s=20token=20with=20quer?= =?UTF-8?q?y=20privateAccessToken=20in=20the=20url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gregoire Parant --- front/src/Connexion/ConnectionManager.ts | 40 ++++++++++++++++++++++-- front/src/Url/UrlManager.ts | 23 ++++++++++++-- 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 05d0255d..6f1984ae 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -2,7 +2,7 @@ import Axios from "axios"; import { PUSHER_URL } from "../Enum/EnvironmentVariable"; import { RoomConnection } from "./RoomConnection"; import type { OnConnectInterface, PositionInterface, ViewportInterface } from "./ConnexionModels"; -import { GameConnexionTypes, urlManager } from "../Url/UrlManager"; +import { GameConnexionTypes, queryPrivateAccessToken, urlManager } from "../Url/UrlManager"; import { localUserStore } from "./LocalUserStore"; import { CharacterTexture, LocalUser } from "./LocalUser"; import { Room } from "./Room"; @@ -124,8 +124,42 @@ class ConnectionManager { return Promise.reject(new Error("You will be redirect on login page")); } urlManager.pushRoomIdToUrl(this._currentRoom); - } else if (connexionType === GameConnexionTypes.register) { - //@deprecated + } else if (connexionType === GameConnexionTypes.privateAccessToken) { + const organizationMemberToken = urlManager.getPrivateAccessToken; + + //clear queryPrivateAccessToken query in window location + urlParams.delete(queryPrivateAccessToken); + + const data = await Axios.post(`${PUSHER_URL}/register`, { organizationMemberToken }).then( + (res) => res.data + ); + if (!isRegisterData(data)) { + console.error("Invalid data received from /register route. Data: ", data); + throw new Error("Invalid data received from /register route."); + } + this.localUser = new LocalUser(data.userUuid, data.textures, data.email); + this.authToken = data.authToken; + localUserStore.saveUser(this.localUser); + localUserStore.setAuthToken(this.authToken); + analyticsClient.loggedWithToken(); + + const roomUrl = data.roomUrl; + + const query = urlParams.toString(); + this._currentRoom = await Room.createRoom( + new URL( + window.location.protocol + + "//" + + window.location.host + + roomUrl + + (query ? "?" + query : "") + //use urlParams because the token param must be deleted + window.location.hash + ) + ); + urlManager.pushRoomIdToUrl(this._currentRoom); + } + //@deprecated + else if (connexionType === GameConnexionTypes.register) { const organizationMemberToken = urlManager.getOrganizationToken(); const data = await Axios.post(`${PUSHER_URL}/register`, { organizationMemberToken }).then( (res) => res.data diff --git a/front/src/Url/UrlManager.ts b/front/src/Url/UrlManager.ts index cb0e1ed0..b8a967c6 100644 --- a/front/src/Url/UrlManager.ts +++ b/front/src/Url/UrlManager.ts @@ -3,13 +3,16 @@ import { localUserStore } from "../Connexion/LocalUserStore"; export enum GameConnexionTypes { room = 1, - register, + register /*@deprecated*/, empty, unknown, jwt, login, + privateAccessToken, } +export const queryPrivateAccessToken = "privateAccessToken"; + //this class is responsible with analysing and editing the game's url class UrlManager { public getGameConnexionType(): GameConnexionTypes { @@ -19,8 +22,13 @@ class UrlManager { } else if (url === "/jwt") { return GameConnexionTypes.jwt; } else if (url.includes("_/") || url.includes("*/") || url.includes("@/")) { + if (window.location.search.includes(queryPrivateAccessToken)) { + return GameConnexionTypes.privateAccessToken; + } return GameConnexionTypes.room; - } else if (url.includes("register/")) { + } + //@deprecated register url will be replace by "?privateAccessToken=" + else if (url.includes("register/")) { return GameConnexionTypes.register; } else if (url === "/") { return GameConnexionTypes.empty; @@ -29,6 +37,17 @@ class UrlManager { } } + /** + * @return string + */ + get getPrivateAccessToken(): string | null { + const urlParams = new URLSearchParams(window.location.search.toString()); + return urlParams.get(queryPrivateAccessToken); + } + + /** + * @deprecated + */ public getOrganizationToken(): string | null { const match = /\/register\/(.+)/.exec(window.location.pathname.toString()); return match ? match[1] : null; From 64ba7575a09d874b6d53edc523b1a8c99c6c0c79 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Tue, 8 Feb 2022 18:47:11 +0100 Subject: [PATCH 02/17] Add play uri param Signed-off-by: Gregoire Parant --- front/src/Connexion/ConnectionManager.ts | 9 ++++++--- pusher/src/Controller/AuthenticateController.ts | 3 ++- pusher/src/Services/AdminApi.ts | 12 +++++++++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 6f1984ae..344f9152 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -130,9 +130,12 @@ class ConnectionManager { //clear queryPrivateAccessToken query in window location urlParams.delete(queryPrivateAccessToken); - const data = await Axios.post(`${PUSHER_URL}/register`, { organizationMemberToken }).then( - (res) => res.data - ); + //create play uri parameter + const playUri = window.location.protocol + "//" + window.location.host; + const data = await Axios.post(`${PUSHER_URL}/register`, { + organizationMemberToken, + playUri, + }).then((res) => res.data); if (!isRegisterData(data)) { console.error("Invalid data received from /register route. Data: ", data); throw new Error("Invalid data received from /register route."); diff --git a/pusher/src/Controller/AuthenticateController.ts b/pusher/src/Controller/AuthenticateController.ts index fe80eafa..046de8fe 100644 --- a/pusher/src/Controller/AuthenticateController.ts +++ b/pusher/src/Controller/AuthenticateController.ts @@ -170,10 +170,11 @@ export class AuthenticateController extends BaseController { //todo: what to do if the organizationMemberToken is already used? const organizationMemberToken: string | null = param.organizationMemberToken; + const playUri: string | null = param.playUri; try { if (typeof organizationMemberToken != "string") throw new Error("No organization token"); - const data = await adminApi.fetchMemberDataByToken(organizationMemberToken); + const data = await adminApi.fetchMemberDataByToken(organizationMemberToken, playUri); const userUuid = data.userUuid; const email = data.email; const roomUrl = data.roomUrl; diff --git a/pusher/src/Services/AdminApi.ts b/pusher/src/Services/AdminApi.ts index c72a6ba8..6fe1d258 100644 --- a/pusher/src/Services/AdminApi.ts +++ b/pusher/src/Services/AdminApi.ts @@ -47,25 +47,31 @@ class AdminApi { async fetchMemberDataByUuid( userIdentifier: string | null, - roomId: string, + playUri: string, ipAddress: string ): Promise { if (!ADMIN_API_URL) { return Promise.reject(new Error("No admin backoffice set!")); } const res = await Axios.get(ADMIN_API_URL + "/api/room/access", { - params: { userIdentifier, roomId, ipAddress }, + params: { + userIdentifier, + roomId: playUri /* @deprecated */, + playUri, + ipAddress, + }, headers: { Authorization: `${ADMIN_API_TOKEN}` }, }); return res.data; } - async fetchMemberDataByToken(organizationMemberToken: string): Promise { + async fetchMemberDataByToken(organizationMemberToken: string, playUri: string | null): Promise { if (!ADMIN_API_URL) { return Promise.reject(new Error("No admin backoffice set!")); } //todo: this call can fail if the corresponding world is not activated or if the token is invalid. Handle that case. const res = await Axios.get(ADMIN_API_URL + "/api/login-url/" + organizationMemberToken, { + params: { playUri }, headers: { Authorization: `${ADMIN_API_TOKEN}` }, }); if (!isAdminApiData(res.data)) { From cfbf9dca232fe91543a7f1bf307aad1667cfe668 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Tue, 8 Feb 2022 20:31:08 +0100 Subject: [PATCH 03/17] PlayUri parameter Signed-off-by: Gregoire Parant --- front/src/Connexion/ConnectionManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 344f9152..b5a25fbb 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -131,7 +131,7 @@ class ConnectionManager { urlParams.delete(queryPrivateAccessToken); //create play uri parameter - const playUri = window.location.protocol + "//" + window.location.host; + const playUri = window.location.protocol + "//" + window.location.host + window.location.pathname; const data = await Axios.post(`${PUSHER_URL}/register`, { organizationMemberToken, playUri, From 0e7a52aa58d009fd30d455fc0f4ee5e9e9c9269c Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Thu, 17 Mar 2022 10:38:52 +0100 Subject: [PATCH 04/17] update with dan suggest Signed-off-by: Gregoire Parant --- front/src/Connexion/ConnectionManager.ts | 2 +- front/src/Url/UrlManager.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 422f6546..c8c67b77 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -129,7 +129,7 @@ class ConnectionManager { } urlManager.pushRoomIdToUrl(this._currentRoom); } else if (connexionType === GameConnexionTypes.privateAccessToken) { - const organizationMemberToken = urlManager.getPrivateAccessToken; + const organizationMemberToken = urlManager.privateAccessToken; //clear queryPrivateAccessToken query in window location urlParams.delete(queryPrivateAccessToken); diff --git a/front/src/Url/UrlManager.ts b/front/src/Url/UrlManager.ts index f1283f70..5ab6ba21 100644 --- a/front/src/Url/UrlManager.ts +++ b/front/src/Url/UrlManager.ts @@ -40,7 +40,7 @@ class UrlManager { /** * @return string */ - get getPrivateAccessToken(): string | null { + get privateAccessToken(): string | null { const urlParams = new URLSearchParams(window.location.search.toString()); return urlParams.get(queryPrivateAccessToken); } From 56fb73c6822e5c9dd4150e23fd3641a2e39091b3 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Thu, 17 Mar 2022 10:53:56 +0100 Subject: [PATCH 05/17] Change roomId by playUri Signed-off-by: Gregoire Parant --- front/src/Connexion/ConnectionManager.ts | 2 +- pusher/src/Services/AdminApi.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index c8c67b77..d2b8275e 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -144,7 +144,7 @@ class ConnectionManager { console.error("Invalid data received from /register route. Data: ", data); throw new Error("Invalid data received from /register route."); } - this.localUser = new LocalUser(data.userUuid, data.textures, data.email); + this.localUser = new LocalUser(data.userUuid, data.email); this.authToken = data.authToken; localUserStore.saveUser(this.localUser); localUserStore.setAuthToken(this.authToken); diff --git a/pusher/src/Services/AdminApi.ts b/pusher/src/Services/AdminApi.ts index 62d582ff..33c8ad93 100644 --- a/pusher/src/Services/AdminApi.ts +++ b/pusher/src/Services/AdminApi.ts @@ -65,7 +65,7 @@ class AdminApi { const res = await Axios.get>(ADMIN_API_URL + "/api/room/access", { params: { userIdentifier, - roomId: playUri, + playUri, ipAddress, characterLayers, }, From 29a0b9c5ae7d8ca4085bbedcbf14d9ca7e634135 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Sat, 19 Mar 2022 07:11:15 +0100 Subject: [PATCH 06/17] Refactor access by token Signed-off-by: Gregoire Parant --- front/src/Connexion/ConnectionManager.ts | 38 +----------------------- front/src/Url/UrlManager.ts | 22 ++++---------- 2 files changed, 6 insertions(+), 54 deletions(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index d2b8275e..643ab57d 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -2,7 +2,7 @@ import Axios from "axios"; import { PUSHER_URL } from "../Enum/EnvironmentVariable"; import { RoomConnection } from "./RoomConnection"; import type { OnConnectInterface, PositionInterface, ViewportInterface } from "./ConnexionModels"; -import { GameConnexionTypes, queryPrivateAccessToken, urlManager } from "../Url/UrlManager"; +import { GameConnexionTypes, urlManager } from "../Url/UrlManager"; import { localUserStore } from "./LocalUserStore"; import { CharacterTexture, LocalUser } from "./LocalUser"; import { Room } from "./Room"; @@ -128,42 +128,6 @@ class ConnectionManager { return Promise.reject(new Error("You will be redirect on login page")); } urlManager.pushRoomIdToUrl(this._currentRoom); - } else if (connexionType === GameConnexionTypes.privateAccessToken) { - const organizationMemberToken = urlManager.privateAccessToken; - - //clear queryPrivateAccessToken query in window location - urlParams.delete(queryPrivateAccessToken); - - //create play uri parameter - const playUri = window.location.protocol + "//" + window.location.host + window.location.pathname; - const data = await Axios.post(`${PUSHER_URL}/register`, { - organizationMemberToken, - playUri, - }).then((res) => res.data); - if (!isRegisterData(data)) { - console.error("Invalid data received from /register route. Data: ", data); - throw new Error("Invalid data received from /register route."); - } - this.localUser = new LocalUser(data.userUuid, data.email); - this.authToken = data.authToken; - localUserStore.saveUser(this.localUser); - localUserStore.setAuthToken(this.authToken); - analyticsClient.loggedWithToken(); - - const roomUrl = data.roomUrl; - - const query = urlParams.toString(); - this._currentRoom = await Room.createRoom( - new URL( - window.location.protocol + - "//" + - window.location.host + - roomUrl + - (query ? "?" + query : "") + //use urlParams because the token param must be deleted - window.location.hash - ) - ); - urlManager.pushRoomIdToUrl(this._currentRoom); } //@deprecated else if (connexionType === GameConnexionTypes.register) { diff --git a/front/src/Url/UrlManager.ts b/front/src/Url/UrlManager.ts index 5ab6ba21..a7abbadd 100644 --- a/front/src/Url/UrlManager.ts +++ b/front/src/Url/UrlManager.ts @@ -6,28 +6,24 @@ export enum GameConnexionTypes { register /*@deprecated*/, empty, unknown, - jwt, + jwt /*@deprecated*/, login, - privateAccessToken, } -export const queryPrivateAccessToken = "privateAccessToken"; - //this class is responsible with analysing and editing the game's url class UrlManager { public getGameConnexionType(): GameConnexionTypes { const url = window.location.pathname.toString(); if (url === "/login") { return GameConnexionTypes.login; - } else if (url === "/jwt") { + } + //@deprecated jwt url will be replace by "?token=" + else if (url === "/jwt") { return GameConnexionTypes.jwt; } else if (url.includes("_/") || url.includes("*/") || url.includes("@/")) { - if (window.location.search.includes(queryPrivateAccessToken)) { - return GameConnexionTypes.privateAccessToken; - } return GameConnexionTypes.room; } - //@deprecated register url will be replace by "?privateAccessToken=" + //@deprecated register url will be replace by "?token=" else if (url.includes("register/")) { return GameConnexionTypes.register; } else if (url === "/") { @@ -37,14 +33,6 @@ class UrlManager { } } - /** - * @return string - */ - get privateAccessToken(): string | null { - const urlParams = new URLSearchParams(window.location.search.toString()); - return urlParams.get(queryPrivateAccessToken); - } - /** * @deprecated */ From e618dc6c3d99079fb205688f21a026da6a3b733b Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Sun, 20 Mar 2022 14:33:25 +0100 Subject: [PATCH 07/17] Refactor connexion manager Signed-off-by: Gregoire Parant --- front/src/Connexion/ConnectionManager.ts | 14 +++++++------- pusher/src/Controller/OpenIdProfileController.ts | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 643ab57d..38be8737 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -85,8 +85,7 @@ class ConnectionManager { * Tries to login to the node server and return the starting map url to be loaded */ public async initGameConnexion(): Promise { - const connexionType = urlManager.getGameConnexionType(); - this.connexionType = connexionType; + this.connexionType = urlManager.getGameConnexionType(); this._currentRoom = null; const urlParams = new URLSearchParams(window.location.search); @@ -99,13 +98,14 @@ class ConnectionManager { urlParams.delete("token"); } - if (connexionType === GameConnexionTypes.login) { + if (this.connexionType === GameConnexionTypes.login) { this._currentRoom = await Room.createRoom(new URL(localUserStore.getLastRoomUrl())); if (this.loadOpenIDScreen() !== null) { return Promise.reject(new Error("You will be redirect on login page")); } urlManager.pushRoomIdToUrl(this._currentRoom); - } else if (connexionType === GameConnexionTypes.jwt) { + } else if (this.connexionType === GameConnexionTypes.jwt) { + /** @deprecated */ if (!token) { const code = urlParams.get("code"); const state = urlParams.get("state"); @@ -130,7 +130,7 @@ class ConnectionManager { urlManager.pushRoomIdToUrl(this._currentRoom); } //@deprecated - else if (connexionType === GameConnexionTypes.register) { + else if (this.connexionType === GameConnexionTypes.register) { const organizationMemberToken = urlManager.getOrganizationToken(); const data = await Axios.post(`${PUSHER_URL}/register`, { organizationMemberToken }).then( (res) => res.data @@ -159,11 +159,11 @@ class ConnectionManager { ) ); urlManager.pushRoomIdToUrl(this._currentRoom); - } else if (connexionType === GameConnexionTypes.room || connexionType === GameConnexionTypes.empty) { + } else if (this.connexionType === GameConnexionTypes.room || this.connexionType === GameConnexionTypes.empty) { this.authToken = localUserStore.getAuthToken(); let roomPath: string; - if (connexionType === GameConnexionTypes.empty) { + if (this.connexionType === GameConnexionTypes.empty) { roomPath = localUserStore.getLastRoomUrl(); //get last room path from cache api try { diff --git a/pusher/src/Controller/OpenIdProfileController.ts b/pusher/src/Controller/OpenIdProfileController.ts index 3ff4c948..e0b77268 100644 --- a/pusher/src/Controller/OpenIdProfileController.ts +++ b/pusher/src/Controller/OpenIdProfileController.ts @@ -13,14 +13,14 @@ export class OpenIdProfileController extends BaseHttpController { } try { const resCheckTokenAuth = await openIDClient.checkTokenAuth(accessToken as string); - if (!resCheckTokenAuth.email) { + if (!resCheckTokenAuth.sub) { throw new Error("Email was not found"); } res.send( this.buildHtml( OPID_CLIENT_ISSUER, - resCheckTokenAuth.email as string, - resCheckTokenAuth.picture as string | undefined + resCheckTokenAuth.sub as string + /*resCheckTokenAuth.picture as string | undefined*/ ) ); return; From 82dffff5a750d676b9bfabb016f60b4f3f63ec40 Mon Sep 17 00:00:00 2001 From: Piotr 'pwh' Hanusiak Date: Mon, 28 Mar 2022 17:08:12 +0200 Subject: [PATCH 08/17] make use of proto well knows types --- front/src/Connexion/RoomConnection.ts | 2 +- front/src/Network/ProtobufClientUtils.ts | 2 +- messages/package.json | 2 +- messages/protos/messages.proto | 6 ++++-- pusher/src/Model/Zone.ts | 13 +++++++++---- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/front/src/Connexion/RoomConnection.ts b/front/src/Connexion/RoomConnection.ts index f1dbde13..5cfc85c1 100644 --- a/front/src/Connexion/RoomConnection.ts +++ b/front/src/Connexion/RoomConnection.ts @@ -41,7 +41,7 @@ import { SetPlayerDetailsMessage as SetPlayerDetailsMessageTsProto, PingMessage as PingMessageTsProto, CharacterLayerMessage, -} from "../Messages/ts-proto-generated/messages"; +} from "../Messages/ts-proto-generated/protos/messages"; import { Subject } from "rxjs"; import { selectCharacterSceneVisibleStore } from "../Stores/SelectCharacterStore"; import { gameManager } from "../Phaser/Game/GameManager"; diff --git a/front/src/Network/ProtobufClientUtils.ts b/front/src/Network/ProtobufClientUtils.ts index 3e172d0f..beec3d9f 100644 --- a/front/src/Network/ProtobufClientUtils.ts +++ b/front/src/Network/ProtobufClientUtils.ts @@ -1,4 +1,4 @@ -import { PositionMessage, PositionMessage_Direction } from "../Messages/ts-proto-generated/messages"; +import { PositionMessage, PositionMessage_Direction } from "../Messages/ts-proto-generated/protos/messages"; import type { PointInterface } from "../Connexion/ConnexionModels"; diff --git a/messages/package.json b/messages/package.json index 644065c9..4cef28dd 100644 --- a/messages/package.json +++ b/messages/package.json @@ -6,7 +6,7 @@ "proto": "grpc_tools_node_protoc --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts --grpc_out=generated --js_out=\"import_style=commonjs,binary:generated\" --ts_out=generated -I ./protos protos/*.proto", "ts-proto": "grpc_tools_node_protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=ts-proto-generated --ts_proto_opt=oneof=unions --ts_proto_opt=esModuleInterop=true protos/*.proto", "copy-to-back": "rm -rf ../back/src/Messages/generated && cp -rf generated/ ../back/src/Messages/generated", - "copy-to-front-ts-proto": "sed 's/import { Observable } from \"rxjs\";/import type { Observable } from \"rxjs\";/g' ts-proto-generated/protos/messages.ts > ../front/src/Messages/ts-proto-generated/messages.ts", + "copy-to-front-ts-proto": "cp -rf ts-proto-generated/* ../front/src/Messages/ts-proto-generated/ && sed -i 's/import { Observable } from \"rxjs\";/import type { Observable } from \"rxjs\";/g' ../front/src/Messages/ts-proto-generated/protos/messages.ts", "copy-to-pusher": "rm -rf ../pusher/src/Messages/generated && cp -rf generated/ ../pusher/src/Messages/generated", "json-copy-to-pusher": "rm -rf ../pusher/src/Messages/JsonMessages/* && cp -rf JsonMessages/* ../pusher/src/Messages/JsonMessages/", "json-copy-to-back": "rm -rf ../back/src/Messages/JsonMessages/* && cp -rf JsonMessages/* ../back/src/Messages/JsonMessages/", diff --git a/messages/protos/messages.proto b/messages/protos/messages.proto index 4ddb3941..35db5321 100644 --- a/messages/protos/messages.proto +++ b/messages/protos/messages.proto @@ -1,5 +1,7 @@ syntax = "proto3"; +import "google/protobuf/wrappers.proto"; + /*********** PARTIAL MESSAGES **************/ message PositionMessage { @@ -189,8 +191,8 @@ message BatchMessage { message GroupUpdateMessage { int32 groupId = 1; PointMessage position = 2; - int32 groupSize = 3; - bool locked = 4; + google.protobuf.UInt32Value groupSize = 3; + google.protobuf.BoolValue locked = 4; } message GroupDeleteMessage { diff --git a/pusher/src/Model/Zone.ts b/pusher/src/Model/Zone.ts index 02a01d8d..f3b15ed2 100644 --- a/pusher/src/Model/Zone.ts +++ b/pusher/src/Model/Zone.ts @@ -22,6 +22,7 @@ import { import { ClientReadableStream } from "grpc"; import { PositionDispatcher } from "_Model/PositionDispatcher"; import Debug from "debug"; +import { BoolValue, UInt32Value } from "google-protobuf/google/protobuf/wrappers_pb"; const debug = Debug("zone"); @@ -125,9 +126,9 @@ export class UserDescriptor { export class GroupDescriptor { private constructor( public readonly groupId: number, - private groupSize: number, + private groupSize: number | undefined, private position: PointMessage, - private locked: boolean + private locked: boolean | undefined ) {} public static createFromGroupUpdateZoneMessage(message: GroupUpdateZoneMessage): GroupDescriptor { @@ -150,9 +151,13 @@ export class GroupDescriptor { throw new Error("GroupDescriptor.groupId is not an integer: " + this.groupId); } groupUpdateMessage.setGroupid(this.groupId); - groupUpdateMessage.setGroupsize(this.groupSize); + if (this.groupSize !== undefined) { + groupUpdateMessage.setGroupsize(new UInt32Value().setValue(this.groupSize)); + } groupUpdateMessage.setPosition(this.position); - groupUpdateMessage.setLocked(this.locked); + if (this.locked !== undefined) { + groupUpdateMessage.setLocked(new BoolValue().setValue(this.locked)); + } return groupUpdateMessage; } } From 225f80b3ad3de6d2ed02428f135946698bdcc79e Mon Sep 17 00:00:00 2001 From: Piotr 'pwh' Hanusiak Date: Tue, 29 Mar 2022 10:00:26 +0200 Subject: [PATCH 09/17] fixed types for RoomConnection --- front/src/Connexion/AdminMessagesService.ts | 2 +- front/src/Connexion/ConnexionModels.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/front/src/Connexion/AdminMessagesService.ts b/front/src/Connexion/AdminMessagesService.ts index 4b7030ed..22bdd469 100644 --- a/front/src/Connexion/AdminMessagesService.ts +++ b/front/src/Connexion/AdminMessagesService.ts @@ -1,5 +1,5 @@ import { Subject } from "rxjs"; -import type { BanUserMessage, SendUserMessage } from "../Messages/ts-proto-generated/messages"; +import type { BanUserMessage, SendUserMessage } from "../Messages/ts-proto-generated/protos/messages"; export enum AdminMessageEventTypes { admin = "message", diff --git a/front/src/Connexion/ConnexionModels.ts b/front/src/Connexion/ConnexionModels.ts index d71d5c63..84ce60c1 100644 --- a/front/src/Connexion/ConnexionModels.ts +++ b/front/src/Connexion/ConnexionModels.ts @@ -43,8 +43,8 @@ export interface PositionInterface { export interface GroupCreatedUpdatedMessageInterface { position: PositionInterface; groupId: number; - groupSize: number; - locked: boolean; + groupSize?: number; + locked?: boolean; } export interface GroupUsersUpdateMessageInterface { From 0e3529ae4a3e430849ad65654872148f33a6def5 Mon Sep 17 00:00:00 2001 From: Piotr 'pwh' Hanusiak Date: Tue, 29 Mar 2022 11:04:29 +0200 Subject: [PATCH 10/17] fix locking bubble when returning from away mode --- front/src/Phaser/Game/GameScene.ts | 10 ++-------- front/src/Stores/CurrentPlayerGroupStore.ts | 1 - 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 1ef034dd..66a2d8eb 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -76,7 +76,7 @@ import { userIsAdminStore } from "../../Stores/GameStore"; import { contactPageStore } from "../../Stores/MenuStore"; import type { WasCameraUpdatedEvent } from "../../Api/Events/WasCameraUpdatedEvent"; import { audioManagerFileStore } from "../../Stores/AudioManagerStore"; -import { currentPlayerGroupIdStore, currentPlayerGroupLockStateStore } from "../../Stores/CurrentPlayerGroupStore"; +import { currentPlayerGroupLockStateStore } from "../../Stores/CurrentPlayerGroupStore"; import EVENT_TYPE = Phaser.Scenes.Events; import Texture = Phaser.Textures.Texture; @@ -711,10 +711,6 @@ export class GameScene extends DirtyScene { } }); - this.currentPlayerGroupIdStoreUnsubscribe = currentPlayerGroupIdStore.subscribe((groupId) => { - this.currentPlayerGroupId = groupId; - }); - Promise.all([ this.connectionAnswerPromiseDeferred.promise as Promise, ...scriptPromises, @@ -847,8 +843,7 @@ export class GameScene extends DirtyScene { }); this.connection.groupUsersUpdateMessageStream.subscribe((message) => { - // TODO: how else can we deduce our current group? - currentPlayerGroupIdStore.set(message.groupId); + this.currentPlayerGroupId = message.groupId; }); /** @@ -1870,7 +1865,6 @@ ${escapedMessage} break; case "DeleteGroupEvent": { this.doDeleteGroup(event.groupId); - currentPlayerGroupIdStore.set(undefined); currentPlayerGroupLockStateStore.set(undefined); break; } diff --git a/front/src/Stores/CurrentPlayerGroupStore.ts b/front/src/Stores/CurrentPlayerGroupStore.ts index cda46325..91d4b50e 100644 --- a/front/src/Stores/CurrentPlayerGroupStore.ts +++ b/front/src/Stores/CurrentPlayerGroupStore.ts @@ -1,4 +1,3 @@ import { writable } from "svelte/store"; -export const currentPlayerGroupIdStore = writable(undefined); export const currentPlayerGroupLockStateStore = writable(undefined); From c1222c1c571d3a10ac62c873002c825c9cf42517 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Tue, 29 Mar 2022 13:45:31 +0200 Subject: [PATCH 11/17] Fix run pretty Signed-off-by: Gregoire Parant --- front/src/Connexion/ConnectionManager.ts | 2 +- pusher/src/Controller/OpenIdProfileController.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index c36f6fa8..c0c9597c 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -109,7 +109,7 @@ class ConnectionManager { } urlManager.pushRoomIdToUrl(this._currentRoom); } else if (this.connexionType === GameConnexionTypes.jwt) { - /** @deprecated */ + /** @deprecated */ if (!token) { const code = urlParams.get("code"); const state = urlParams.get("state"); diff --git a/pusher/src/Controller/OpenIdProfileController.ts b/pusher/src/Controller/OpenIdProfileController.ts index e0b77268..589c9d54 100644 --- a/pusher/src/Controller/OpenIdProfileController.ts +++ b/pusher/src/Controller/OpenIdProfileController.ts @@ -19,7 +19,7 @@ export class OpenIdProfileController extends BaseHttpController { res.send( this.buildHtml( OPID_CLIENT_ISSUER, - resCheckTokenAuth.sub as string + resCheckTokenAuth.sub /*resCheckTokenAuth.picture as string | undefined*/ ) ); From ac9926b8d69e6ff0845aff1665d04a5c8776342f Mon Sep 17 00:00:00 2001 From: Piotr 'pwh' Hanusiak Date: Mon, 28 Mar 2022 15:27:29 +0200 Subject: [PATCH 12/17] prevent actions menu from appearing when inserting space key on chat --- front/src/Phaser/UserInput/UserInputManager.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/front/src/Phaser/UserInput/UserInputManager.ts b/front/src/Phaser/UserInput/UserInputManager.ts index e7f814b9..b454de56 100644 --- a/front/src/Phaser/UserInput/UserInputManager.ts +++ b/front/src/Phaser/UserInput/UserInputManager.ts @@ -280,6 +280,9 @@ export class UserInputManager { ); this.scene.input.keyboard.on("keyup-SPACE", (event: Event) => { + if (this.isInputDisabled) { + return; + } this.userInputHandler.handleSpaceKeyUpEvent(event); }); } From f04cfb3bb44428badfb2e2314ef10ad0aeade652 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Mar 2022 12:41:23 +0000 Subject: [PATCH 13/17] Bump ansi-regex from 4.1.0 to 4.1.1 in /maps Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 4.1.0 to 4.1.1. - [Release notes](https://github.com/chalk/ansi-regex/releases) - [Commits](https://github.com/chalk/ansi-regex/compare/v4.1.0...v4.1.1) --- updated-dependencies: - dependency-name: ansi-regex dependency-type: indirect ... Signed-off-by: dependabot[bot] --- maps/yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/maps/yarn.lock b/maps/yarn.lock index 38a0f92b..97e22592 100644 --- a/maps/yarn.lock +++ b/maps/yarn.lock @@ -124,9 +124,9 @@ ansi-escapes@^4.2.1: type-fest "^0.21.3" ansi-regex@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" - integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.1.tgz#164daac87ab2d6f6db3a29875e2d1766582dabed" + integrity sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g== ansi-regex@^5.0.0: version "5.0.1" From 80122a52940ed0f34fcce9b0b7dbddc38eaf6ea6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Mar 2022 12:41:25 +0000 Subject: [PATCH 14/17] Bump minimist from 1.2.5 to 1.2.6 in /desktop/local-app Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6. - [Release notes](https://github.com/substack/minimist/releases) - [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6) --- updated-dependencies: - dependency-name: minimist dependency-type: indirect ... Signed-off-by: dependabot[bot] --- desktop/local-app/yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/desktop/local-app/yarn.lock b/desktop/local-app/yarn.lock index 03b6bbab..52bbce0a 100644 --- a/desktop/local-app/yarn.lock +++ b/desktop/local-app/yarn.lock @@ -587,9 +587,9 @@ minimatch@^3.0.4: brace-expansion "^1.1.7" minimist@^1.2.0, minimist@^1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" - integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== + version "1.2.6" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" + integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== mkdirp@^0.5.1: version "0.5.5" From f436f5bcd4765505b7eccbeea9362af8625f46d7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Mar 2022 12:41:30 +0000 Subject: [PATCH 15/17] Bump ansi-regex from 4.1.0 to 4.1.1 in /desktop/electron Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 4.1.0 to 4.1.1. - [Release notes](https://github.com/chalk/ansi-regex/releases) - [Commits](https://github.com/chalk/ansi-regex/compare/v4.1.0...v4.1.1) --- updated-dependencies: - dependency-name: ansi-regex dependency-type: indirect ... Signed-off-by: dependabot[bot] --- desktop/electron/yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/desktop/electron/yarn.lock b/desktop/electron/yarn.lock index 82034d10..179d7ff3 100644 --- a/desktop/electron/yarn.lock +++ b/desktop/electron/yarn.lock @@ -295,9 +295,9 @@ ansi-escapes@^4.2.1: type-fest "^0.21.3" ansi-regex@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" - integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.1.tgz#164daac87ab2d6f6db3a29875e2d1766582dabed" + integrity sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g== ansi-regex@^5.0.1: version "5.0.1" From 8d690bcae1f0a1037111adfd8943dde81ecf210b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Mar 2022 12:41:34 +0000 Subject: [PATCH 16/17] Bump ansi-regex from 4.1.0 to 4.1.1 in /uploader Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 4.1.0 to 4.1.1. - [Release notes](https://github.com/chalk/ansi-regex/releases) - [Commits](https://github.com/chalk/ansi-regex/compare/v4.1.0...v4.1.1) --- updated-dependencies: - dependency-name: ansi-regex dependency-type: indirect ... Signed-off-by: dependabot[bot] --- uploader/yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/uploader/yarn.lock b/uploader/yarn.lock index feab6ff4..4c36556a 100644 --- a/uploader/yarn.lock +++ b/uploader/yarn.lock @@ -174,9 +174,9 @@ ansi-escapes@^4.2.1: type-fest "^0.11.0" ansi-regex@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" - integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.1.tgz#164daac87ab2d6f6db3a29875e2d1766582dabed" + integrity sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g== ansi-regex@^5.0.0: version "5.0.0" From ba68623e6f807b7046e79be51b7bb4384e4a7fd4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Mar 2022 12:41:59 +0000 Subject: [PATCH 17/17] Bump plist from 3.0.4 to 3.0.5 in /desktop/electron Bumps [plist](https://github.com/TooTallNate/node-plist) from 3.0.4 to 3.0.5. - [Release notes](https://github.com/TooTallNate/node-plist/releases) - [Changelog](https://github.com/TooTallNate/plist.js/blob/master/History.md) - [Commits](https://github.com/TooTallNate/node-plist/commits) --- updated-dependencies: - dependency-name: plist dependency-type: indirect ... Signed-off-by: dependabot[bot] --- desktop/electron/yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/desktop/electron/yarn.lock b/desktop/electron/yarn.lock index 179d7ff3..32dd7fe9 100644 --- a/desktop/electron/yarn.lock +++ b/desktop/electron/yarn.lock @@ -2409,9 +2409,9 @@ pirates@^4.0.1: integrity sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ== plist@^3.0.1, plist@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/plist/-/plist-3.0.4.tgz#a62df837e3aed2bb3b735899d510c4f186019cbe" - integrity sha512-ksrr8y9+nXOxQB2osVNqrgvX/XQPOXaU4BQMKjYq8PvaY1U18mo+fKgBSwzK+luSyinOuPae956lSVcBwxlAMg== + version "3.0.5" + resolved "https://registry.yarnpkg.com/plist/-/plist-3.0.5.tgz#2cbeb52d10e3cdccccf0c11a63a85d830970a987" + integrity sha512-83vX4eYdQp3vP9SxuYgEM/G/pJQqLUz/V/xzPrzruLs7fz7jxGQ1msZ/mg1nwZxUSuOp4sb+/bEIbRrbzZRxDA== dependencies: base64-js "^1.5.1" xmlbuilder "^9.0.7"