@hadoku/game-server 0.1.230 → 0.1.231

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * Scoped to GET/HEAD: a POST to a path that does not exist is a bug in the
5
5
  * caller, and answering it with an HTML page hides that. Mounted LAST, below
6
- * every route that owns a path, or it answers for them.
6
+ * every route that owns a path, or it answers for them. A missing `/embed/*`
7
+ * file is a 404, never the page: a module `import()` handed HTML fails with a
8
+ * MIME error that names nothing.
7
9
  *
8
10
  * Per caller, a page load is a costly act: each one boots the whole app, about
9
11
  * eight requests, each a line in this server's log and a row in the edge's. A
package/dist/http/page.js CHANGED
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * Scoped to GET/HEAD: a POST to a path that does not exist is a bug in the
5
5
  * caller, and answering it with an HTML page hides that. Mounted LAST, below
6
- * every route that owns a path, or it answers for them.
6
+ * every route that owns a path, or it answers for them. A missing `/embed/*`
7
+ * file is a 404, never the page: a module `import()` handed HTML fails with a
8
+ * MIME error that names nothing.
7
9
  *
8
10
  * Per caller, a page load is a costly act: each one boots the whole app, about
9
11
  * eight requests, each a line in this server's log and a row in the edge's. A
@@ -23,6 +25,9 @@ export function attachPage(app, deps) {
23
25
  act: 'page-load',
24
26
  now: deps.now,
25
27
  });
28
+ app.use('/embed', (_req, res) => {
29
+ res.status(404).type('text').send('no such embed file');
30
+ });
26
31
  app.get(/.*/, (req, res, next) => {
27
32
  if (!deps.basePath.ok) {
28
33
  res.status(503).type('html').send(diagnosticPage(deps.basePath, deps.basePrefix, deps.name));
@@ -233,6 +233,8 @@ export interface RoomCoreDeps<V extends RoomViewCore, C, P extends object, G = n
233
233
  * Absent: only the leader.
234
234
  */
235
235
  operator?: (req: Request) => boolean;
236
+ /** An operator's seat op, done or refused, as `act` (the route, `-` for `/`) and the body with `ok` and `reason`. Never a leader's own: filling a pod with the AI makes a dozen. */
237
+ audit?: (req: Request, act: string, roomId: string, outcome: Record<string, unknown>) => void;
236
238
  lobby: LobbyCore<V, C>;
237
239
  wire: RoomCoreWire<C, P>;
238
240
  /** Structured log lines. Never carries a password, hash or salt. */
@@ -369,7 +369,7 @@ export function attachRoomCore(api, deps, opts = {}) {
369
369
  });
370
370
  /**
371
371
  * One seat route. `leader`: the leader's op, so an operator (`deps.operator`) may act in the
372
- * leader's place; a member's own sit and stand are not. `limited`: it spends `SEAT_OP_RATE_LIMIT`
372
+ * leader's place, reported to `deps.audit`; a member's own sit and stand are not. `limited`: it spends `SEAT_OP_RATE_LIMIT`
373
373
  * (an op on another person or on the room's size); one that touches only the caller's own seat or
374
374
  * an open one never does, as a leader filling a pod with the AI makes a dozen of them in a row.
375
375
  */
@@ -382,7 +382,11 @@ export function attachRoomCore(api, deps, opts = {}) {
382
382
  const caller = callerOf(req);
383
383
  if (how.limited && !seatOpLimit(caller.id, res))
384
384
  return;
385
- const result = run(String(req.params.id), caller.id, body.value, how.leader && deps.operator?.(req) === true);
385
+ const id = String(req.params.id);
386
+ const override = how.leader && deps.operator?.(req) === true;
387
+ const result = run(id, caller.id, body.value, override);
388
+ if (override)
389
+ deps.audit?.(req, path.replaceAll('/', '-'), id, { ...body.value, ok: result.ok, ...(result.ok ? {} : { reason: result.reason }) });
386
390
  if (!result.ok)
387
391
  return seatOpStatus(res, result.reason);
388
392
  res.json({ ...roomBody(result.room, caller.id), ...('evicted' in result ? { evicted: result.evicted } : {}) });
@@ -226,10 +226,6 @@ export async function startRelayGame(options) {
226
226
  res.status(503).type('text').send(s.missing);
227
227
  });
228
228
  }
229
- // The embed's own files are the static bundle's; anything else under it is no page.
230
- ctx.app.use('/embed', (_req, res) => {
231
- res.status(404).type('text').send('no such embed file');
232
- });
233
229
  attachPage(ctx.app, {
234
230
  indexHtml: join(config.webDir, 'index.html'),
235
231
  basePath: ctx.bundle,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/game-server",
3
- "version": "0.1.230",
4
- "gitHead": "eff3ab2cbc75ee1d70fa3a3c7ad603d9e5fcfe5d",
3
+ "version": "0.1.231",
4
+ "gitHead": "832e803f00a069b6a6ded4a922d7168d14006d7d",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "description": "The server parts any hosted game shares, above the kernel: the app config and edge auth, the room core (identity, seats, sessions, membership, the room list, the generic room routes), match hosting (the host contract, local and remote JVMs, placement, the start queue, recordings, the in-process and relay runtimes), streams, erase, telemetry and usage. Knows no game; Magic plugs in from apps/server. MIT; imports only node built-ins, express, socket.io, @wolffm/* and the platform packages.",
@@ -16,9 +16,9 @@
16
16
  "play/remote/"
17
17
  ],
18
18
  "dependencies": {
19
- "@wolffm/host-wire": "npm:@hadoku/host-wire@0.1.230",
20
- "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.230",
21
- "@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.263",
19
+ "@wolffm/host-wire": "npm:@hadoku/host-wire@0.1.231",
20
+ "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.231",
21
+ "@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.264",
22
22
  "@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.2.3",
23
23
  "@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.152",
24
24
  "@wolffm/rooms-server": "npm:@hadoku/rooms-server@^0.45.152",