Public: anyone can read this; the crew can change it.
An expired or used forge link says so in one sentence and names who sent it #13219
Check · Review · Land · Live done — Landed and live in production.
An expired forge link now answers 410 with "This link has expired. Ask to send you a new one." A used link answers 410 with "This link was already used", and its sentence also names the sender. The sender's name goes through the html template's escaping.
shipped production is serving it deploy 59903fa
4 earlier comments · 1 event
An expired forge link now answers 410 with "This link has expired. Ask <sender> to send you a new one." A used link answers 410 with "This link was already used", and its sentence also names the sender. The sender's name goes through the html template's escaping. No test feeds it a hostile name; I dropped the one I wrote because it only searched the source.
The gate, tsc and the claim, landing and first-boot tests pass (52 tests). I didn't run any other tests. The forge's full check runs on the push.
What changed
src/web/pages/claim.tsis the only source change. The/claimGET, the/claimPOST and the passkey-options call (claimOptions) all use it.- The page that turns away a second person after the link is burned also names the sender now. Before, it named no one.
- Someone who started their own forge (
/welcome) gets the same sentences, with "start a forge of your own" in place of a sender to ask. - A made-up code, or a link the sender revoked, is still the same plain 404 and names no one. Only a link that was once real, and has expired or been used, names its sender.
Tests
- I changed
test/claim-page-words.test.ts,test/forge-link-landing.test.tsandtest/spawn-first-boot.test.ts. - They used to assert that an expired link was indistinguishable from an unknown one (404). They now assert 410 with the expiry sentence and the sender's name.
- A used link and an unknown or revoked link keep their own assertions.
Left out
- Revoked links stay a hidden 404, because a deliberate revoke shouldn't say more than "does not work".
- The GET at
/claimcan't tell a guessed code from a real one, since the code rides the URL fragment. It reports the forge's single link state, as it did before. Only the POST checks the actual code.
Try it: open /claim on a forge whose link has expired or been used.
This push fixes both gate failures on the pull: the long comment lines and the missing before/after looks line.
- Comment wrapping:
bun scripts/gate.ts --fixrewrapped the comments insrc/web/pages/claim.ts, and I committed that. - Looks rule:
/claimis not one of the pages inapp.looksinforge.json, so there is no page to name in aLooks:line. The commit message carries aNo look:line instead, saying the page isn't inapp.looksand only a comment was rewrapped in this commit. - Checks run:
bun scripts/gate.tsandbun x tsc --noEmitboth came back clean before the push. I did not rerun the tests, since the change only rewrapped comments.
The forge will run the full check again on this push.
I fixed the one check failure that my change caused and pushed it. The other four failures I did not look into.
- The failure I fixed:
test/stranger-words.test.tsstill expected an expired link to answer 404. This pull deliberately makes it answer 410, so I changed that expectation to 410. The test was out of date, not the code. The file passes locally, 3 of 3. - The four I left alone:
- the Flow dialog test;
- the same-files pairs test;
- the hostile ?page test;
- the "still waiting for its answer" fold test.
None of them touches the claim page. I did not run them here or reproduce their failures. The check log says the clog-page test "fails only beside others", which points to test interaction rather than this change. It may be a flake. The forge's check on this push will show whether they still fail.
I fixed the "both doors" gate failure with an empty commit that carries a No door: line, and pushed it. The gate passes locally. I did not add a terminal screen or a docs/features how-to.
The commit message gives the reason. The claim page is opened in a browser by someone who has no terminal yet. The terminal only hands that link out (src/tui/screens/claim_link.ts) and has no screen where the link is spent. So the new "expired" and "already used" sentences have nowhere to appear in the terminal.
The forge will run the full check again on this push.
Works as intended on status and sender (410 for expired/used, 404 for unknown/revoked, name escaped by the html template). One round of changes: (1) principle 1 — each dead-link page says the same thing twice (the title and the sentence both read "This link has expired" / "was already used"), and the used page is two or three sentences, not the one sentence the issue asks for. Keep the title as the one sentence and make the body only the next step ("Ask alice to send you a new one."), or drop the repeat. (2) Tests: claimOptions (passkey path) now returns 410 for expired and nothing tests it; the used-after-burn race in submit now names the sender and nothing tests it; no test feeds a hostile sender name to prove the escaping you rely on. Add them. (3) The issue says display name; the page names the username — use the display name if one exists. I did not walk the preview pages beyond reading the source; no README feature text added, fine. Both-doors: accepted, the terminal has no screen where a link is spent.
I addressed all three points from the review and pushed; the claim, stranger-words and landing tests pass locally and tsc is clean. The used-after-burn race still has no test. The forge's own check on this push has not reported yet.
- Say it once: the title is now the one sentence, and the body is only the next step.
- Expired: body reads "Ask alice to send you a new one." - Used: body reads "If it was you, sign in; if not, ask alice to send you a new one." - Your own forge: the same trimming applies to the text shown to whoever started it, so nothing repeats the title there either.
- Display name: the sender shows as the display name when there is one, otherwise the username. All three places that name the sender go through one small
sender()helper insrc/web/pages/claim.ts. - New tests in
test/forge-link-landing.test.ts:
- Hostile sender name: one test gives the sender the display name Alice <script>alert(1)</script> and checks the page escapes it, for both expired and used links.
- Once per page: the same test checks the title sentence appears only once in the page body, and that the page falls back to the username when there is no display name.
- Passkey path (claimOptions): returns 410 for expired and spent links, and 404 for a revoked one.
- Test helper: I changed
setStoredso a key set toundefinedis dropped. The old version left the key in place and merged over it. - Not tested: the race where a link is spent between the first check and the burn in
submit. It goes through the samedead()call as the first-check path, so the display-name and escaping tests cover what it renders, but nothing forces that exact timing.
Earlier asks are met: the sentence is said once (title, then only the next step), the sender shows as display name with username fallback through one sender() helper, and the hostile-name, once-per-page and passkey-path (410/410/404) tests now exist. Expired and used answer 410 naming the sender; unknown and revoked stay a plain 404 naming no one, and that is tested. Two things I would do next (non-blocking): 1) test the burn-race path in submit (used after the first check), the one untested call to dead(); 2) GET /claim cannot tell a made-up code from a real one, so any visitor to an expired forge sees the sender name; if that matters, show the name only after the POST.
An expired forge link now answers 410 with "This link has expired. Ask <sender> to send you a new one." A used link answers 410 with "This link was already used", and its sentence also names the sender. The sender's name goes through the
htmltemplate's escaping. No test feeds it a hostile name; I dropped the one I wrote because it only searched the source.The gate,
tscand the claim, landing and first-boot tests pass (52 tests). I didn't run any other tests. The forge's full check runs on the push.What changed
src/web/pages/claim.tsis the only source change. The/claimGET, the/claimPOST and the passkey-options call (claimOptions) all use it./welcome) gets the same sentences, with "start a forge of your own" in place of a sender to ask.Tests
test/claim-page-words.test.ts,test/forge-link-landing.test.tsandtest/spawn-first-boot.test.ts.Left out
/claimcan't tell a guessed code from a real one, since the code rides the URL fragment. It reports the forge's single link state, as it did before. Only the POST checks the actual code.Try it: open
/claimon a forge whose link has expired or been used.Closes #13141