Release Healer Man 0.1.32

This commit is contained in:
phenom committed 2026-09-12 11:07:25 -04:00
1 parent d3d6aaebdb
commit 6dcb1034e5
102 files changed
+10772 -788

No files matched your search

+61 -1
View File
@@ -3,6 +3,7 @@ import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
import os from "node:os";
import path from "node:path";
import test from "node:test";
import { brotliCompressSync } from "node:zlib";
import { createGameServer } from "./server.mjs";
test("serves the game and authenticated cloud-save API", async () => {
@@ -11,18 +12,36 @@ test("serves the game and authenticated cloud-save API", async () => {
const dataDir = path.join(directory, "data");
const contentDir = path.join(directory, "content");
mkdirSync(staticDir, { recursive: true });
mkdirSync(path.join(staticDir, "assets"), { recursive: true });
mkdirSync(path.join(staticDir, "content", "bundled"), { recursive: true });
mkdirSync(path.join(contentDir, "objects"), { recursive: true });
writeFileSync(path.join(staticDir, "index.html"), "<!doctype html><title>Healer Man</title>");
const hashedScript = "console.log('compressed delivery');";
writeFileSync(path.join(staticDir, "assets", "app-12345678.js"), hashedScript);
writeFileSync(path.join(staticDir, "assets", "app-12345678.js.br"), brotliCompressSync(hashedScript));
writeFileSync(path.join(staticDir, "content", "bootstrap-manifest.json"), JSON.stringify({ schemaVersion: 1, files: {} }));
writeFileSync(path.join(staticDir, "content", "bundled", `${"a".repeat(64)}.json`), "{}");
writeFileSync(path.join(staticDir, "sample.glb"), Buffer.from("0123456789"));
writeFileSync(path.join(contentDir, "manifest.json"), JSON.stringify({ schemaVersion: 1 }));
writeFileSync(path.join(contentDir, "objects", "asset.glb"), Buffer.from("abcdefghij"));
const runtime = createGameServer({ staticDir, contentDir, dataDir, corsOrigins: "https://iwanttoheal.phenomrom.com" });
const runtime = createGameServer({
staticDir, contentDir, dataDir, corsOrigins: "https://iwanttoheal.phenomrom.com", enableShelvedModes: true,
});
await new Promise((resolve) => runtime.server.listen(0, "127.0.0.1", resolve));
const address = runtime.server.address();
const origin = `http://127.0.0.1:${address.port}`;
try {
assert.equal((await fetch(`${origin}/`)).status, 200);
const compressedScript = await fetch(`${origin}/assets/app-12345678.js`, {
headers: { "Accept-Encoding": "br" },
});
assert.equal(compressedScript.headers.get("content-encoding"), "br");
assert.equal(compressedScript.headers.get("cache-control"), "public, max-age=31536000, immutable");
assert.equal(await compressedScript.text(), hashedScript);
const bundledObject = await fetch(`${origin}/content/bundled/${"a".repeat(64)}.json`);
assert.equal(bundledObject.headers.get("cache-control"), "public, max-age=31536000, immutable");
assert.equal((await fetch(`${origin}/content/bootstrap-manifest.json`)).headers.get("cache-control"), "no-cache");
const range = await fetch(`${origin}/sample.glb`, { headers: { Range: "bytes=2-5" } });
assert.equal(range.status, 206);
assert.equal(await range.text(), "2345");
@@ -250,3 +269,44 @@ test("serves the game and authenticated cloud-save API", async () => {
rmSync(directory, { recursive: true, force: true });
}
});
test("disables shelved APIs and Manastorm group creation by default", async () => {
const directory = mkdtempSync(path.join(os.tmpdir(), "healer-man-shelved-server-test-"));
const staticDir = path.join(directory, "dist");
const dataDir = path.join(directory, "data");
const contentDir = path.join(directory, "content");
mkdirSync(staticDir, { recursive: true });
mkdirSync(contentDir, { recursive: true });
writeFileSync(path.join(staticDir, "index.html"), "<!doctype html><title>Healer Man</title>");
const runtime = createGameServer({ staticDir, contentDir, dataDir, enableShelvedModes: false });
await new Promise((resolve) => runtime.server.listen(0, "127.0.0.1", resolve));
const address = runtime.server.address();
const origin = `http://127.0.0.1:${address.port}`;
try {
assert.equal(runtime.enableShelvedModes, false);
for (const route of ["/api/manastorm-config", "/api/gm/manastorm-config", "/api/arena/state"]) {
const response = await fetch(`${origin}${route}`);
assert.equal(response.status, 503);
assert.equal((await response.json()).code, "feature_disabled");
}
const registration = await fetch(`${origin}/api/auth/register`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ username: "ShelvedHealer", password: "healing-pass" }),
});
const auth = await registration.json();
const activity = await fetch(`${origin}/api/online-group/activity`, {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: `Bearer ${auth.token}` },
body: JSON.stringify({ type: "manastorm", contentId: "deadmines", partySize: 1, fillWithAi: true }),
});
assert.equal(activity.status, 503);
assert.equal((await activity.json()).code, "feature_disabled");
assert.equal(runtime.arenaService.inspect().tickets.size, 0);
} finally {
await new Promise((resolve) => runtime.server.close(resolve));
rmSync(directory, { recursive: true, force: true });
}
});