Further login process

* APIUtils addition: query validation
* Coach and Server accounts are now properly created if they do not exist
* Profiles now cannot be IDs 1 or 2 (reservedIds)
* Fixed profile username exists bug
* Added relationship manager
* Started relationship management
* DeviceClass and VRMovementMode enum defaults for reserved profiles
* Presence update simplification
* Progression fixes
* Relationship query and object fixes
* Base configuration is now rate limited
* Progression route no longer requires authentication, instead is rate limited
* Base relationships with reserved profiles (Coach and Server)
* DeviceClass required for login
* Get presence route
* Socket route no longer logs
* Socket target base finished
This commit is contained in:
2025-03-30 19:29:57 -04:00
parent 026f9c8bd8
commit 639e809a20
19 changed files with 270 additions and 81 deletions

View File

@@ -2,9 +2,10 @@ import { z } from "zod";
import { APIUtils, NoBody } from "../../apiutils.ts";
import express from "express";
import Matchmaking from "../../data/live/base.ts";
import Presence from "../../data/live/presence.ts";
import Presence, { PresenceExport } from "../../data/live/presence.ts";
import { AuthType } from "../../data/users.ts";
import Logging from "@proxnet/undead-logging";
import UnifiedProfile from "../../data/profiles.ts";
const log = new Logging("MatchPlayerRoute");
@@ -18,6 +19,31 @@ const LoginSchema = z.object({
LoginLock: z.string().uuid("LoginLock must be a UUIDv4")
});
route.router.get('/',
APIUtils.Authentication,
APIUtils.AuthenticationType(AuthType.Game),
APIUtils.validateQuery(z.object({ id: z.union([z.string(), z.array(z.string())]) })),
async (rq: express.Request<NoBody, PresenceExport[], NoBody, { id: string[] | string }>, rs) => {
let ids: number[] = [];
if (typeof rq.query.id == 'object') ids = rq.query.id.map(val => parseInt(val));
else ids.push(parseInt(rq.query.id));
ids = ids.filter(val => !isNaN(val));
const presExport: PresenceExport[] = [];
for (const id of ids) {
const pres = await Presence.get(UnifiedProfile.get(id));
await pres.update();
presExport.push(await pres.export());
}
rs.json(presExport);
log.d(JSON.stringify(presExport));
}
)
route.router.post('/login',
APIUtils.Authentication,
@@ -40,8 +66,9 @@ route.router.post('/logout',
express.urlencoded({extended: true}),
APIUtils.validateRequestBody(LoginSchema),
(rq, rs) => {
(_rq, rs) => {
Matchmaking.deleteLoginLock(rs.locals.profile);
rs.sendStatus(200);
}
)
@@ -56,6 +83,7 @@ route.router.post('/heartbeat',
async (_rq, rs) => {
const pres = await Presence.get(rs.locals.profile);
await pres.update();
log.d(`pres heartbeat for ${rs.locals.profile.getId()}: ${JSON.stringify(await pres.export())}`);
rs.json(await pres.export());
}