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

A forge link says when it expires on opening, and an expired link offers one way to ask for a fresh one #13564

Merged opened this

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

Merged

scout/forge:scout/13525-a-forge-link-says-when-it-expires-on-ope → main 5 commits fork 3 threads · 3 unresolved

  • Merged. scout/13525-a-forge-link-says-when-it-expires-on-ope was merged into main as 902f319.

Review

Sign in to review this change.
6 files changed +179 −1
docs/features/README.md +1
@@ -437,6 +437,7 @@ Read with the guide page [Every setting, by topic](../guide-settings.md).
437437 - [Rotating the secret key](rotate-secret-key.md)
438438 - [Sent to sign in by an app, and back again](signin-asking.md)
439439 - [Taking the forge's own name](claim-own-name.md)
440 - [Ask for a new forge link](claim-renew.md)
440441 - [Trusted sources](trusted-sources.md)
441442 - [Who can see it, in one line](visibility-line.md)
442443 - [Your dotfiles in every shell](dotfiles.md)
docs/features/claim-renew.md added +14
@@ -0,0 +1,14 @@
1 # Ask for a new forge link
2
3 When a forge link has expired, the claim page says so and offers one action: **Ask for a new link**. It records one
4 ask on this forge's own feed, once per link (a repeat answers the same and records nothing). It does not reach the
5 sender, who lives on the parent forge, so the page says the ask is recorded and tells the person to ask whoever sent
6 the link too.
7 Only an expired, unused, unrevoked link can ask; every other state answers the same plain 404 as a made-up link.
8
9 Try it: open `/claim` on a forge whose link has expired and press **Ask for a new link**.
10
11 The terminal (both doors): the claim link is a web-only handoff for a person with no account yet, so `src/tui` has no
12 claim screen to bring in line. The admins see the event on the same feed as other forge events.
13
14 Pinned by `test/forge-link-expiry.test.ts`.
src/core/event_audience.ts +1
@@ -130,6 +130,7 @@ const READER_KINDS: ReadonlySet<string> = new Set([
130130 "forge.claim_reissued",
131131 "forge.claim_revoked",
132132 "forge.claim_restored",
133 "forge.claim_renewal_asked",
133134 "agent.created",
134135 "agent.updated",
135136 "agent.deleted",
src/http/server.ts +2 −1
@@ -310,7 +310,7 @@ import {
310310 import { shareTellPage } from "../web/studio/share_tell.ts";
311311 import { forgeReady } from "../web/pages/forge-ready.ts";
312312 import { forgeName } from "../web/pages/forge-name.ts";
313 import { claimFragmentPage, claimOptions, claimSubmit, welcomePage, welcomeSubmit } from "../web/pages/claim.ts";
313 import { claimFragmentPage, claimOptions, claimRenew, claimSubmit, welcomePage, welcomeSubmit } from "../web/pages/claim.ts";
314314 import { firstAdminOptions, firstAdminPage, firstAdminSubmit } from "../web/pages/first-admin.ts";
315315 import { familyPage } from "../web/pages/family.ts";
316316 import { forgeLinkForm, forgeLinkRevoke, forgeLinkSubmit, forgeLinkUndo, forgeArchiveConfirm, forgeArchiveSubmit, forgeRestoreSubmit, forgeRemoveConfirm, forgeRemoveSubmit, forgeStopSubmit,
@@ -933,6 +933,7 @@ export function buildRouter(): Router<Handler> {
933933 router.add("GET", "/claim", claimFragmentPage);
934934 router.add("POST", "/claim", claimSubmit);
935935 router.add("POST", "/claim/options", claimOptions);
936 router.add("POST", "/claim/renew", claimRenew);
936937 router.add("GET", "/welcome", welcomePage);
937938 router.add("POST", "/welcome", welcomeSubmit);
938939 router.add("POST", "/welcome/options", claimOptions);
src/web/pages/claim.ts +31
@@ -155,6 +155,11 @@ function dead(
155155 ${pageHead(says.title)}
156156 <section class="settings-block">
157157 <p>${says.text}</p>
158 ${state === "expired" && !own
159 ? html`<form method="post" action="/claim/renew" class="form-actions">
160 ${btn("Ask for a new link", { type: "submit", variant: "primary" })}
161 </form>`
162 : null}
158163 ${state === "used" || state === "owned"
159164 ? html`<div class="form-actions">
160165 ${btn("Sign in", { href: "/signin", variant: "primary" })}
@@ -420,6 +425,32 @@ export async function claimOptions(ctx: Ctx): Promise<Response> {
420425 return json(makeOptions(ctx, "claim", username));
421426 }
422427
428 /**
429 * POST /claim/renew — "Ask for a new link" on an expired link. It records the ask on this forge's
430 * own feed, once per link: a repeat answers the same sentence and records nothing. It does not
431 * reach the sender: they live on the parent forge, and no path from here to them exists, so the
432 * page says "recorded", never "told". Only an expired, unused, unrevoked link of a spawned forge
433 * can ask; every other state answers the same plain 404 as a made-up link.
434 */
435 export async function claimRenew(ctx: Ctx): Promise<Response> {
436 const form = await readForm(ctx);
437 if (form instanceof Response) return form;
438 const spawned = await spawnedOrg(ctx.app);
439 const link = linkOf(ctx.app.db);
440 if (spawned === undefined || link === null || link.state !== "ended" || link.revokedAt !== null || link.usedAt !== null)
441 return dead(ctx, "unknown");
442 const open = ctx.app.db
outdated

MEDIUM: a hand-rolled 429 page with inline markup. Principle 1 and the named-components rule: reuse a shared helper. Add a test for this branch.

443 .query("SELECT 1 FROM event WHERE kind = 'forge.claim_renewal_asked' AND json_extract(payload, '$.link') = ?1 LIMIT 1")
outdated

HIGH: this event stays on the child forge. The sender is not told. Deliver it to the sender, or to the parent forge they read, and dedupe repeat presses per link.

444 .get(link.expiresAt ?? "");
445 if (open === null)
446 ctx.app.bus.append({ kind: "forge.claim_renewal_asked", payload: { org: spawned.org.username, link: link.expiresAt ?? "" } });
447 return page({
448 ctx,
outdated

HIGH: 'We have told' is untrue until a delivery happens. Principle 1: one honest sentence, and the title above should not repeat it.

449 title: "Ask recorded",
450 body: html`<div class="narrow">${pageHead("Ask recorded")}<section class="settings-block"><p id="claim-asked">Your ask is recorded on this forge's feed. It has not reached whoever sent the link, so ask them for a new one too.</p></section></div>`,
451 });
452 }
453
423454 // POST /claim — make the account, burn the link, sign the person in.
424455 export const claimSubmit = (ctx: Ctx): Promise<Response> => submit(ctx, false);
425456 /** POST /welcome — the same, for the person who started the forge. */

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs