Further the login process

* Matchmaking login locks (created and checked only in memory for now)
* Profile reputation temporary implementation
* Profiles now no longer initialize if a user with the same username is found
* vrMovementMode in presence is now required, falls back to 'Teleport'
* Progression implementation began
* API routes: Settings, player subscriptions, reputation, progression
* cropSquare in image query is not a boolean, rather a number representing a boolean
* Hile reporting uses forms, not json
* Presence heartbeat and logout
* Socket changes: Close event listener (destroy), send message function, targets further started
This commit is contained in:
2025-03-29 23:09:40 -04:00
parent 1af0206b6a
commit 026f9c8bd8
22 changed files with 294 additions and 56 deletions

View File

@@ -18,7 +18,7 @@ const HileMessageSchema = z.object({
route.router.post('/v1/hile',
APIUtils.Authentication,
express.json(),
express.urlencoded({ extended: true }),
APIUtils.validateRequestBody(HileMessageSchema),
(rq: express.Request<NoBody, NoBody, HileMessage>, rs) => {

View File

@@ -0,0 +1,24 @@
import { APIUtils } from "../../apiutils.ts";
import UnifiedProfile from "../../data/profiles.ts";
import { AuthType } from "../../data/users.ts";
import express from "express";
export const route = APIUtils.createRouter("/playerReputation");
route.router.get('/v1/:id',
APIUtils.Authentication,
APIUtils.AuthenticationType(AuthType.Game),
(rq: express.Request<{ id: string }>, rs) => {
const unparsedPlayerId = rq.params.id;
const parsedPlayerId = parseInt(unparsedPlayerId);
if (isNaN(parsedPlayerId)) {
rs.json(APIUtils.genericResponseFormat(true, 'The player ID was invalid.'));
return;
}
rs.json(UnifiedProfile.get(parsedPlayerId).Reputation.getReputation());
}
);

View File

@@ -1,4 +1,9 @@
import Logging from "@proxnet/undead-logging";
import { APIUtils } from "../../apiutils.ts";
import express from "express";
import UnifiedProfile from "../../data/profiles.ts";
const log = new Logging("ProgressionRoute");
export const route = APIUtils.createRouter("/players");
@@ -6,12 +11,22 @@ route.router.get('/v1/progression/:id',
APIUtils.Authentication,
async (_rq, rs) => {
rs.json({
PlayerId: rs.locals.profile.getId(),
Level: await rs.locals.profile.Progression.getLevel(), // await is temporary
Xp: await rs.locals.profile.Progression.getXp()
});
async (rq: express.Request<{ id: string }>, rs) => {
const unparsedPlayerId = rq.params.id;
const parsedPlayerId = parseInt(unparsedPlayerId);
if (isNaN(parsedPlayerId)) {
rs.json(APIUtils.genericResponseFormat(true, 'The player ID was invalid.'));
return;
}
const profile = UnifiedProfile.get(parsedPlayerId);
const res = {
PlayerId: profile.getId(),
Level: await profile.Progression.getLevel(),
XP: await profile.Progression.getXp()
};
log.d(`prog res: ${JSON.stringify(res)}`);
rs.json(res);
}
);

View File

@@ -0,0 +1,11 @@
import { APIUtils } from "../../apiutils.ts";
export const route = APIUtils.createRouter("/playersubscriptions");
route.router.get('/v1/my',
(_rq, rs) => {
rs.json([]); // temporary: todo
}
);

View File

@@ -0,0 +1,22 @@
import Logging from "@proxnet/undead-logging";
import { APIUtils } from "../../apiutils.ts";
import { AuthType } from "../../data/users.ts";
const log = new Logging("SettingsRoute");
export const route = APIUtils.createRouter("/settings");
route.router.get('/v2',
APIUtils.Authentication,
APIUtils.AuthenticationType(AuthType.Game),
async (_rq, rs) => {
const settings = await rs.locals.profile.Settings.getSettings();
log.d(`settings res: ${JSON.stringify(settings)}`);
rs.json(settings);
}
);