uhh
All checks were successful
Galvanic Corrosion Cross-Compile / build (push) Successful in 57s

The Rewrite™️

- Discord bot removed, will return *eventually*
- Watchdog kills the server with a knife when it does not shut down in (default) 60 seconds
- New event system that works.. better.. and callbacks have types
- Removed a metric ton of circular dependencies that previously would not let the server start up
    * This included splitting up some classes
- Other. internal stuff. I forgot.
This commit is contained in:
2025-06-29 00:16:07 -04:00
parent 0ac46fcee2
commit 746c2203e5
90 changed files with 2408 additions and 1397 deletions

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
import { APIUtils } from "../../apiutils.ts";
import { AuthType } from "../../data/users.ts";
import { AuthType } from "../../data/UserTypes.ts";
export const route = APIUtils.createRouter("/account");

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
import { APIUtils } from "../../apiutils.ts";
import { AuthType } from "../../data/users.ts";
import { AuthType } from "../../data/UserTypes.ts";
export const route = APIUtils.createRouter("/cachedlogin");

View File

@@ -18,14 +18,16 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */
import { APIUtils, NoBody } from "../../apiutils.ts";
import express from "express";
import { decode } from "@gz/jwt";
import { Config } from "../../config.ts";
import { Config } from "../../config/config.ts";
import Logging from "@proxnet/undead-logging";
import { z } from "zod";
import { AuthType } from "../../data/users.ts";
import { AuthType } from "../../data/UserTypes.ts";
import { Redis } from "../../db.ts";
import { validVersions } from "../api/versioncheck.ts";
import { Steam } from "../../data/steam.ts";
import Server from "../../data/server.ts";
import Steam from "../../data/steam/steam.ts";
import Server from "../../data/server/server.ts";
import { DeviceClass } from "../../data/live/types.ts";
import { SteamAuthResult } from "../../data/steam/SteamAuthTypes.ts";
const config = Config.getConfig();
@@ -124,7 +126,7 @@ route.router.post("/token",
});
}
const conditionsMet = ![
const conditions = [
rq.body.client_id === "recroom",
rq.body.platform === "0",
validVersions.includes(rq.body.ver),
@@ -136,7 +138,8 @@ route.router.post("/token",
!(rq.body.time.length > 32),
!(rq.body.asid.length > 32),
SteamPlatformParamsSchema.safeParse(JSON.parse(rq.body.platform_auth)).success
].includes(false);
];
const conditionsMet = !conditions.includes(false);
if (!conditionsMet) {
requestFailed();
@@ -164,48 +167,56 @@ route.router.post("/token",
targetAccount = parseInt(decodedToken.sub ? decodedToken.sub : "NaN");
}
const platformAuth = (JSON.parse(rq.body.platform_auth)) as SteamPlatformParams;
let platformid: string | null;
if (config.auth.steamkey) {
const steamAuthed = await Steam.AuthenticateUserTicket(platformAuth.Ticket, rq.body.platform_id);
if (!steamAuthed) {
const steamAuth = await Steam.AuthenticateUserTicket(platformAuth.Ticket, rq.body.platform_id);
if (steamAuth.valid == SteamAuthResult.Failure) {
requestFailed();
return;
}
}
} else if (steamAuth.valid == SteamAuthResult.Success) platformid = steamAuth.res.steamid;
else platformid = null;
} else platformid = null;
if (isNaN(targetAccount)) {
requestFailed();
return;
}
const accounts = await rs.locals.user.getAssociatedProfiles();
if (!accounts.has(targetAccount)) {
requestFailed("access_denied");
return;
}
rs.locals.user.addAssociatedDeviceId(rq.body.device_id);
rs.locals.user.addAssociatedPlatformId(rq.body.platform_id);
Redis.Database.sadd(Redis.buildKey(Redis.KeyGroups.PlatformAssociations, rq.body.platform_id), targetAccount);
if (platformid) rs.locals.user.addAssociatedPlatformId(platformid);
if (platformid) Redis.Database.sadd(Redis.buildKey(Redis.KeyGroups.PlatformAssociations, platformid), targetAccount);
const profile = Server.UnifiedProfile.get(targetAccount);
if (!profile) {
requestFailed();
return;
}
const deviceClass = Number(rq.body.device_class);
if (typeof DeviceClass[deviceClass] == 'undefined') {
requestFailed();
return;
}
const details = await profile.export();
log.i(`Player ${details?.username} "${details?.displayName}" (${profile.getId()}) logged in`);
const token = await profile.getToken();
const token = await profile.Auth.getToken();
rs.json({
access_token: token,
refresh_token: token,
});
await profile.setKnownDeviceClass(Number(rq.body.device_class));
await profile.setKnownDeviceClass(deviceClass);
nxt();
},