Public: anyone can read this; the crew can change it.

Access 5c: a linked game player mints the visitor principal #18209

opened this

Merged 3h 7m ago, live in production

A player with no account who links themselves from a game client link now becomes the visitor principal at that moment, and not before. I tested it in test/game-client-pack.test.ts (13 pass) and bun x tsc --noEmit is clean. The nine gate-related test files also pass, and I did not run the full suite.

Notes

opened this

A player with no account who links themselves from a game client link now becomes the visitor principal at that moment, and not before. I tested it in test/game-client-pack.test.ts (13 pass) and bun x tsc --noEmit is clean. The nine gate-related test files also pass, and I did not run the full suite. I did not try it on the preview.

What changed

  • A browser that opens /games/@pack/<token>/<service>.mrpack now sees a "Join <server>" page with "Link me and get the pack". A launcher, or a request with ?raw=1, still gets the file straight away.
  • A new POST to the same path is the linking action (gamePackLinked):
    • It asks admitVisitor first, which checks may for visitor.make and then VISITOR_CAPS. A refusal gives 403 and a cap gives 429, shown on the page with no cookie and nothing counted.
    • Once admitted it calls countMake, then answers 303 to ?raw=1 and sets forge_maker only at that point.
    • A dead or revoked link answers 404 and mints nothing.
    • A signed-in person gets the pack without minting.
  • The tests cover the four cases the issue lists:
    • A read mints and counts nothing.
    • Linking mints and counts once.
    • DNT links and counts without an id or cookie.
    • The client cap refuses the next link with 429.
  • docs/features/games.md and the header comment in src/core/visitors.ts are updated.

Left out

  • Linking records no row beyond the visitor count itself; the principal is the point of this issue.
  • The terminal door is a No door: line in the commit. A player with no account has no terminal, and the operator's l and x already make and end the link.
  • The operator's link stays the plain .mrpack address, so Prism and the Modrinth App import it as before.

How to try it: open a client pack link in a browser and press "Link me and get the pack". You should land on the download with a forge_maker cookie set. To see the 303 and cookie from the command line, curl -X POST the same path with the preview's Origin. An operator makes the link on /games/<box>/<service>.

Reused: admitVisitor, countMake, clientBucket, secureFor, loadKey and the existing linkOf.

Gate warnings: the duplicate-function check says my linkPage is 0.69 like usageShell, but they share nothing beyond the page-shell shape, so I left it. Two routes are still marked in the route lists (lazy_lists.ts, games_routes.ts).

Closes #18189

3 earlier comments
commented

A player with no account who links themselves from a game client link now becomes the visitor principal at that moment, and not before. I tested it in test/game-client-pack.test.ts (13 pass) and bun x tsc --noEmit is clean. The nine gate-related test files also pass, and I did not run the full suite. I did not try it on the preview.

What changed

  • A browser that opens /games/@pack/<token>/<service>.mrpack now sees a "Join <server>" page with "Link me and get the pack". A launcher, or a request with ?raw=1, still gets the file straight away.
  • A new POST to the same path is the linking action (gamePackLinked):
    • It asks admitVisitor first, which checks may for visitor.make and then VISITOR_CAPS. A refusal gives 403 and a cap gives 429, shown on the page with no cookie and nothing counted.
    • Once admitted it calls countMake, then answers 303 to ?raw=1 and sets forge_maker only at that point.
    • A dead or revoked link answers 404 and mints nothing.
    • A signed-in person gets the pack without minting.
  • The tests cover the four cases the issue lists:
    • A read mints and counts nothing.
    • Linking mints and counts once.
    • DNT links and counts without an id or cookie.
    • The client cap refuses the next link with 429.
  • docs/features/games.md and the header comment in src/core/visitors.ts are updated.

Left out

  • Linking records no row beyond the visitor count itself; the principal is the point of this issue.
  • The terminal door is a No door: line in the commit. A player with no account has no terminal, and the operator's l and x already make and end the link.
  • The operator's link stays the plain .mrpack address, so Prism and the Modrinth App import it as before.

How to try it: open a client pack link in a browser and press "Link me and get the pack". You should land on the download with a forge_maker cookie set. To see the 303 and cookie from the command line, curl -X POST the same path with the preview's Origin. An operator makes the link on /games/<box>/<service>.

Reused: admitVisitor, countMake, clientBucket, secureFor, loadKey and the existing linkOf.

Gate warnings: the duplicate-function check says my linkPage is 0.69 like usageShell, but they share nothing beyond the page-shell shape, so I left it. Two routes are still marked in the route lists (lazy_lists.ts, games_routes.ts).

commented

This push fixes the two failing cookie-floor tests. src/web/pages/games_client_pack.ts now sets the visitor cookie when a player links, and that site had not been counted in test/cookie-flags.test.ts.

I added src/web/pages/games_client_pack.ts with 1 site to the WALKED table in that file. I only edited the test's bookkeeping, not the cookie code. Its other writer check already knew admitted.setCookie, so nothing else needed naming.

bun test test/cookie-flags.test.ts passes (14 tests). I did not run bun x tsc --noEmit or any other test file. bun scripts/gate.ts --fix printed only notes and changed nothing. I pushed with a "No door" line, since this is test bookkeeping only.

The gate noted two things I left alone:

  • Long comments: src/http/games_routes.ts and test/game-client-pack.test.ts have comment lines over 100 columns; the nightly rewrap on main will wrap them.
  • Possible duplicate: linkPage in games_client_pack.ts scores 0.69 against usageShell in usage-tabs.ts, which the gate flags as possibly the same implementation. I did not look into it.
commented

The remaining failing test, "every cookie constructed under src/ reaches the helper", should now pass. src/web/pages/games_client_pack.ts appends the visitor cookie from admitted.setCookie, and test/cookie-floor.test.ts had no entry for it. I added one with the same reason as the existing src/apps/feedback.ts entry. The cookie is built by admitVisitor through setCookie in src/core/visitors.ts.

test/cookie-floor.test.ts and test/cookie-flags.test.ts pass locally (19 tests). I did not run bun x tsc --noEmit or any other test file. The change is test bookkeeping only, so I pushed it with a "No door" line.

commented

Both of sentinel's points are addressed and pushed. The type check is clean. test/game-client-pack.test.ts, test/visitors*.test.ts and test/cookie-f*.test.ts passed together (39 tests) before the last edit. After it, which only fixed a type annotation, I re-ran only test/game-client-pack.test.ts (14 pass). bun scripts/design-lint.ts prints "no colour, size or component added outside the system". The forge's check has not run on this push yet.

  • Link page: it now has one plain sentence on what linking does, with the plain download link inside it, and the Do Not Track / Global Privacy Control paragraph is gone. The refusal uses <p class="notice danger" role="alert">, the same class gifts.ts and games.ts use for refusals. No new class was needed, so I touched nothing in docs/design/areas/.
  • 403 path: this route could never answer 403, because admitVisitor always treated an unrecognised caller as not refused. I added an optional refused field to its request, and the route passes ctx.auth.refused. A request carrying a rejected credential now gets 403 with no cookie and nothing counted. This changes src/core/visitors.ts, and the feedback route doesn't pass the field yet, so it behaves as before.
  • Tests: a new case in test/game-client-pack.test.ts covers the 403 (a bad bearer token) and the forge cap. For the forge cap it fills visitor_made to the cap from other clients and checks that the next link gets 429 with no cookie and no new row. I did not add a per-visitor-cap case through this route.
  • No door: a player with no account has no terminal, and the operator's l and x already exist; the commit line says so.
  • Gate: the gate's possible-duplicate note on linkPage and usageShell is still there and I left it.
Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs