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

A forge link that was revoked says so in its own words, apart from an expired one #13625

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

mason/forge:mason/13584-a-forge-link-that-was-revoked-says-so-in → main 8 commits fork 3 threads · 3 unresolved

  • Merged. mason/13584-a-forge-link-that-was-revoked-says-so-in was merged into main as 9feb835.

Review

Sign in to review this change.
7 files changed +118 −28
docs/features/README.md +1
@@ -319,6 +319,7 @@ Read with the guide page [Hosting forges for others, and getting paid](../guide-
319319 - [Disks on the machines page](machines-disks.md)
320320 - [Does a forge I sent answer yet?](forge-ready.md)
321321 - [End a forge link, and undo it](forge-link-revoke.md)
322 - [What a forge link says when it no longer works](forge-link-dead.md)
322323 - [Fleet rows](fleet.md)
323324 - [Forge it](forge-it.md)
324325 - [/forges side by side](forges-side-by-side.md)
src/web/pages/claim.ts +16 −7
@@ -13,8 +13,8 @@
1313 * The GET only shows the form — a link unfurled in a chat app must not
1414 * spend itself — and the POST, same-origin, makes the account and burns the
1515 * link in one step. A link that is used or expired says which in one
16 * sentence and names who sent it (410); one that is revoked or made up is a plain 404; a forge that
17 * was not spawned has no claim page at all.
16 * sentence and names who sent it (410); one that is revoked says it was withdrawn (404); one made
17 * up is a plain 404; a forge that was not spawned has no claim page at all.
1818 *
1919 * Who keeps access is never silent. By default the spawner's account leaves
2020 * the organisation's Owners when the forge is claimed (the new owner can
@@ -113,8 +113,13 @@ function dead(
113113 own = false,
114114 ): Response {
115115 const ask = sender === undefined ? "whoever sent it" : sender;
116 // Only a link that once was real says so (used, expired) and names its
117 // sender; unknown and revoked stay one plain 404 naming no one.
116 // Only a link that once was real says so (used, expired, revoked) and names
117 // its sender; an unknown one stays a plain 404 naming no one. The POSTs
outdated

This comment claims revoked is told apart on POST only with its own token. GET /claim and /claim/options carry no token and still say withdrawn. Reword it to say what happens.

118 // (/claim, /welcome and their /options) judge the posted token, so a guess
119 // only ever meets "unknown". GET /claim and /welcome carry no token (it
120 // rides the fragment) and read the forge's one current link: anyone who
121 // opens the bare page learns whether that link was used, expired or
122 // withdrawn, never its secret, as used and expired already did.
118123 const gone = {
119124 status: 404,
120125 title: "This link does not work",
@@ -132,7 +137,11 @@ function dead(
132137 title: "This link has expired",
133138 text: `Ask ${ask} to send you a new one.`,
134139 },
135 revoked: gone,
140 revoked: {
141 status: 404,
142 title: "This link was withdrawn",
143 text: `The sender withdrew this link. Ask ${ask} to send you a new one.`,
144 },
136145 owned: {
137146 status: 410,
138147 title: "This forge already has an owner",
@@ -144,7 +153,7 @@ function dead(
144153 unknown: "This link does not work any more. Start the forge again from the home page.",
145154 used: "If it was you, sign in. Otherwise start a forge of your own from the home page.",
146155 expired: "Start the forge again from the home page.",
147 revoked: "This link does not work any more. Start the forge again from the home page.",
156 revoked: "You withdrew this link. Start the forge again from the home page.",
148157 };
149158 if (own) says.text = mine[state] ?? says.text;
150159 return page(
@@ -394,7 +403,7 @@ const LINK_REFUSED: Record<Exclude<ClaimState["state"], "ok">, string> = {
394403 unknown: "This link does not work any more.",
395404 used: "This link was already used.",
396405 expired: "This link has expired.",
397 revoked: "This link does not work any more.",
406 revoked: "The sender withdrew this link. Ask them to send you a new one.",
398407 owned: "This forge already has an owner.",
399408 };
400409
test/claim-revoke.test.ts +23 −1
@@ -112,7 +112,29 @@ describe("revoking a forge link", () => {
112112 });
113113 expect(post.status).toBe(404);
114114 expect(post.headers.get("set-cookie")).toBeNull();
115 expect(await post.text()).toContain("This link does not work");
115 expect(await post.text()).toContain("The sender withdrew this link");
116 });
117
118 test("the starter's own page says 'You withdrew this link'; the recipient's never does, nor the reverse", async () => {
119 // "one" is still revoked by the test above; the next test undoes it.
120 const url = kids["one"]!.servers.url;
121 const send = (path: string) =>
122 fetch(`${url}${path}`, {
123 method: "POST",
124 headers: { origin: url },
125 body: new URLSearchParams({ token: kids["one"]!.token, username: "x", email: "[email protected]" }),
126 redirect: "manual",
127 });
128 const own = await send("/welcome");
129 const ownText = await own.text();
130 expect(own.status).toBe(404);
131 expect(own.headers.get("set-cookie")).toBeNull();
132 expect(ownText).toContain("You withdrew this link");
133 expect(ownText).not.toContain("The sender withdrew this link");
134 const theirs = await send("/claim");
135 const theirText = await theirs.text();
136 expect(theirText).toContain("The sender withdrew this link");
137 expect(theirText).not.toContain("You withdrew this link");
116138 });
117139
118140 test("a revoke is receipted, and undone within the minute", async () => {

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs