Public: anyone can read this; the crew can change it.
Public /privacy and /support pages (needed for the App Store listing) #17948
Merged 18h 18m ago, live in production
scout/forge:scout/17947-public-privacy-and-support-pages-needed → main 0 commits fork 5 threads · 5 unresolved
24 files
changed +350
−93
- docs/design/audit.md
- docs/design/quiet-debt.json
- docs/features/privacy-support.md
- scripts/doorless-allow.json
- src/core/support_contact.ts
- src/generated/marks.ts
- src/http/lazy_lists.ts
- src/http/marks/support.json
- src/http/routes/docs.ts
- src/tui/forge_parts.ts
- src/tui/screens/support.ts
- src/tui/screens/terms.ts
- src/view/policy.ts
- src/web/layout.ts
- src/web/pages/privacy.ts
- src/web/pages/support.ts
- src/web/pages/terms.ts
- src/web/policy_rows.ts
- src/web/standards.ts
- src/web/studio/home.ts
- test/forge-looks.test.ts
- test/palette-roster.test.ts
- test/privacy-support.test.ts
- test/terms-page.test.ts
docs/design/audit.md +2 −1
| @@ -120,7 +120,8 @@ Machine routes are not pages and have no entry: `/audit.csv`, | ||
| 120 | 120 | - `/family` — `pages/family.ts` · parent, this forge and children as a tree · `/forges` (the same children) · colour 1. |
| 121 | 121 | - `/claim` — `pages/claim.ts` · claim a forge that was sent to me · none · colour 1. |
| 122 | 122 | - `/welcome` — `pages/claim.ts` (`welcomePage`) · the account screen of a forge you just started: make your account · none · none seen. |
| 123 | - `/privacy` — `pages/privacy.ts` · what the forge keeps about a visitor, three plain lines, open to anyone · none · none seen. | |
| 123 | - `/privacy` — `pages/privacy.ts` · what a forge stores, what the Apple app sends, and what it keeps about a visitor, open to anyone · none · none seen. | |
| 124 | - `/support` — `pages/support.ts` · how to get help: docs, status, Report in the Apple app and a contact, open to anyone · `/privacy` · none seen. | |
| 124 | 125 | - `/status` — `pages/status.ts` · is the forge working, one sentence and five rows, open to anyone · none · none seen. |
| 125 | 126 | - `/tab` — `pages/tab.ts` · start a forge in this browser tab: three plain facts and a button · none · none seen. |
| 126 | 127 | - `/first-admin` — `pages/first-admin.ts` · the first person becomes admin · none · none seen. |
docs/design/quiet-debt.json −4
| @@ -358,7 +358,6 @@ | ||
| 358 | 358 | "bare-list": 1 |
| 359 | 359 | }, |
| 360 | 360 | "src/web/pages/privacy.ts": { |
| 361 | "pagehead": 1, | |
| 362 | 361 | "bare-list": 1 |
| 363 | 362 | }, |
| 364 | 363 | "src/web/pages/prompts.ts": { |
| @@ -459,9 +458,6 @@ | ||
| 459 | 458 | "src/web/pages/templates.ts": { |
| 460 | 459 | "bare-list": 1 |
| 461 | 460 | }, |
| 462 | "src/web/pages/terms.ts": { | |
| 463 | "pagehead": 1 | |
| 464 | }, | |
| 465 | 461 | "src/web/pages/thread.ts": { |
| 466 | 462 | "bare-list": 1 |
| 467 | 463 | }, |
docs/features/privacy-support.md added +14
| @@ -0,0 +1,14 @@ | ||
| 1 | --- | |
| 2 | topic: What a forge is | |
| 3 | row: Privacy and support pages | |
| 4 | --- | |
| 5 | # Privacy and support pages | |
| 6 | ||
| 7 | `/privacy` and `/support` are public, signed-out pages (#17947) that the App Store listing and the Apple app's About screen point at. Both are linked from the footer of every page and listed in `/sitemap.xml`. | |
| 8 | ||
| 9 | - **/privacy** says what a forge stores (git plus one SQLite file), that the crew uses your own AI account, that the Apple app is a client of the forge you sign in to (what it sends is kept by that forge; not checked against the app, a person confirms before the App Store points here), that there is no tracking and no ads, and a contact. Below it, the short list of what the forge keeps about a site visitor. | |
| 10 | - **/support** says how to get help: the docs, the status page, a contact, and where to send a security problem. | |
| 11 | - **Contact:** set `FORGE_SUPPORT_CONTACT` to an email address or an https link. Without it the contact is the new-issue form of the forge's own public repository (`FORGE_REPO`), else the front page. No address is ever built in (`src/core/support_contact.ts`). | |
| 12 | - **Terminal:** palette → "Privacy" or "Support" (`src/tui/screens/support.ts`). Same rows; Esc goes back. | |
| 13 | - **Code:** the sentences are plain rows in `src/view/policy.ts`, read by `src/web/pages/privacy.ts`, `src/web/pages/support.ts` and the terminal screen, so they cannot drift. | |
| 14 | - **Test:** `bun test test/privacy-support.test.ts`. |
scripts/doorless-allow.json −1
src/core/support_contact.ts added +17
| @@ -0,0 +1,17 @@ | ||
| 1 | /** | |
| 2 | * Where a person asks for help or about their data (#17947). An address is | |
| 3 | * published only when the operator wrote one down in `FORGE_SUPPORT_CONTACT` | |
| 4 | * (an email address or an https link): a default must never put a person's | |
| 5 | * email on the open web. Without one, it is the new-issue form of the forge's | |
| 6 | * own public repository, else the forge's front page. | |
| 7 | */ | |
| 8 | ||
| 9 | import type { App } from "../app.ts"; | |
| 10 | import { publicForgeRepo } from "./forge_repo.ts"; | |
| 11 | ||
| 12 | export function supportContact(app: App, origin: string): string { | |
| 13 | const configured = process.env["FORGE_SUPPORT_CONTACT"]?.trim(); | |
| 14 | if (configured) return configured; | |
| 15 | const own = publicForgeRepo(app); | |
| 16 | return own === undefined ? `${origin}/` : `${origin}/${own.ownerName}/${own.name}/issues/new`; | |
| 17 | } |
src/generated/marks.ts +17 −15
| @@ -195,21 +195,22 @@ import k190 from "../http/marks/signin.json"; | ||
| 195 | 195 | import k191 from "../http/marks/signup.json"; |
| 196 | 196 | import k192 from "../http/marks/sitemap.xml.json"; |
| 197 | 197 | import k193 from "../http/marks/status.json"; |
| 198 | import k194 from "../http/marks/sw.js.json"; | |
| 199 | import k195 from "../http/marks/system.json"; | |
| 200 | import k196 from "../http/marks/tab.json"; | |
| 201 | import k197 from "../http/marks/tabforge.json"; | |
| 202 | import k198 from "../http/marks/talk.json"; | |
| 203 | import k199 from "../http/marks/tell.json"; | |
| 204 | import k200 from "../http/marks/templates.json"; | |
| 205 | import k201 from "../http/marks/templates.json.json"; | |
| 206 | import k202 from "../http/marks/terms.json"; | |
| 207 | import k203 from "../http/marks/theme.json"; | |
| 208 | import k204 from "../http/marks/toolbar-lab.js.json"; | |
| 209 | import k205 from "../http/marks/toolbar-lab.json"; | |
| 210 | import k206 from "../http/marks/verify.json"; | |
| 211 | import k207 from "../http/marks/welcome.json"; | |
| 212 | import k208 from "../http/marks/well-known.json"; | |
| 198 | import k194 from "../http/marks/support.json"; | |
| 199 | import k195 from "../http/marks/sw.js.json"; | |
| 200 | import k196 from "../http/marks/system.json"; | |
| 201 | import k197 from "../http/marks/tab.json"; | |
| 202 | import k198 from "../http/marks/tabforge.json"; | |
| 203 | import k199 from "../http/marks/talk.json"; | |
| 204 | import k200 from "../http/marks/tell.json"; | |
| 205 | import k201 from "../http/marks/templates.json"; | |
| 206 | import k202 from "../http/marks/templates.json.json"; | |
| 207 | import k203 from "../http/marks/terms.json"; | |
| 208 | import k204 from "../http/marks/theme.json"; | |
| 209 | import k205 from "../http/marks/toolbar-lab.js.json"; | |
| 210 | import k206 from "../http/marks/toolbar-lab.json"; | |
| 211 | import k207 from "../http/marks/verify.json"; | |
| 212 | import k208 from "../http/marks/welcome.json"; | |
| 213 | import k209 from "../http/marks/well-known.json"; | |
| 213 | 214 | |
| 214 | 215 | /** Each file of `http/marks/`, parsed, in name order. */ |
| 215 | 216 | export const MARK_FILES: readonly unknown[] = [ |
| @@ -422,4 +423,5 @@ export const MARK_FILES: readonly unknown[] = [ | ||
| 422 | 423 | k206, |
| 423 | 424 | k207, |
| 424 | 425 | k208, |
| 426 | k209, | |
| 425 | 427 | ]; |
src/http/lazy_lists.ts +1
src/http/routes/docs.ts +2
| @@ -9,6 +9,7 @@ import { docsFolder, docsFile, docsFeature } from "../../web/pages/docs_link.ts" | ||
| 9 | 9 | import { privacyPage } from "../../web/pages/privacy.ts"; |
| 10 | 10 | import { publicSecurityPage } from "../../web/pages/security_public.ts"; |
| 11 | 11 | import { statusPage } from "../../web/pages/status.ts"; |
| 12 | import { supportPage } from "../../web/pages/support.ts"; | |
| 12 | 13 | import { templatePage } from "../../web/pages/template.ts"; |
| 13 | 14 | import { termsPage } from "../../web/pages/terms.ts"; |
| 14 | 15 | import { outsiderStatusPage } from "../offer_routes.ts"; |
| @@ -19,6 +20,7 @@ export function docsRoutes(router: Router<Handler>): void { | ||
| 19 | 20 | router.add("GET", "/dataset", datasetPage); |
| 20 | 21 | // The forge's own documentation: a redirect built from configuration only. |
| 21 | 22 | router.add("GET", "/privacy", privacyPage); |
| 23 | router.add("GET", "/support", supportPage); | |
| 22 | 24 | router.add("GET", "/terms", termsPage); |
| 23 | 25 | router.add("GET", "/templates/:name", templatePage); |
| 24 | 26 | router.add("GET", "/templates/:owner/:name", templatePage); |
src/tui/forge_parts.ts +3
| @@ -37,6 +37,7 @@ import { interruptedOutCommand } from "./screens/interrupted_out.ts"; | ||
| 37 | 37 | import { getForgeCommand } from "./screens/getforge.ts"; |
| 38 | 38 | import { startForgeCommand } from "./screens/startforge.ts"; |
| 39 | 39 | import { pricingCommand } from "./screens/pricing.ts"; |
| 40 | import { privacyCommand, supportCommand } from "./screens/support.ts"; | |
| 40 | 41 | import { termsCommand } from "./screens/terms.ts"; |
| 41 | 42 | import { forgeNameCommand } from "./screens/forgename.ts"; |
| 42 | 43 | import { workCommand } from "./screens/work.ts"; |
| @@ -322,6 +323,8 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] { | ||
| 322 | 323 | ...startForgeCommand(session, ctx), |
| 323 | 324 | pricingCommand(session, ctx), |
| 324 | 325 | termsCommand(session, ctx), |
| 326 | privacyCommand(session, ctx), | |
| 327 | supportCommand(session, ctx), | |
| 325 | 328 | ...forgeNameCommand(session, ctx), |
| 326 | 329 | ...dataCommand(session, ctx), |
| 327 | 330 | fleetCommand(session, ctx), |
src/tui/screens/support.ts added +54
| @@ -0,0 +1,54 @@ | ||
| 1 | /** | |
| 2 | * `/privacy` and `/support` in the terminal (#17947): the web pages' rows, from | |
| 3 | * `view/policy.ts`, so the two doors cannot drift. Read-only; Esc goes back. | |
| 4 | * Offered to everyone, as both pages are public. | |
| 5 | */ | |
| 6 | ||
| 7 | import { supportContact } from "../../core/support_contact.ts"; | |
| 8 | import { PRIVACY_PURPOSE, SUPPORT_PURPOSE, privacyRows, supportRows, type PolicyRow } from "../../view/policy.ts"; | |
| 9 | import type { Ctx, Screen } from "../app/app.ts"; | |
| 10 | import { binding } from "../app/keys.ts"; | |
| 11 | import { style } from "../term/style.ts"; | |
| 12 | import { truncate, wrap } from "../term/width.ts"; | |
| 13 | import type { Session } from "../session.ts"; | |
| 14 | ||
| 15 | export function policyScreen(title: string, purpose: string, rows: readonly PolicyRow[], ctx: Ctx): Screen { | |
| 16 | return { | |
| 17 | title, | |
| 18 | keys: [binding(["esc"], "back")], | |
| 19 | render(area, s) { | |
| 20 | const c = ctx.theme.c; | |
| 21 | const w = Math.max(20, area.w); | |
| 22 | const out: [string, number][] = wrap(purpose, w).map((row) => [row, c.mutedFg]); | |
| 23 | for (const r of rows) { | |
| 24 | out.push(["", c.fg], [r.label, c.mutedFg]); | |
| 25 | for (const row of wrap(r.link === undefined ? r.words : `${r.words} ${r.link.text} (${r.link.href})`, w)) out.push([row, c.fg]); | |
| 26 | } | |
| 27 | out.slice(0, area.h).forEach(([text, color], i) => s.text(area.x, area.y + i, truncate(text, w), style(color, c.bg), area.x + area.w)); | |
| 28 | }, | |
| 29 | key(e) { | |
| 30 | if (e.key !== "esc") return false; | |
| 31 | ctx.pop(); | |
| 32 | return true; | |
| 33 | }, | |
| 34 | }; | |
| 35 | } | |
| 36 | ||
| 37 | const contactOf = (f: Session): string => supportContact(f.app, f.app.config.url ?? `http://localhost:${f.app.config.port ?? 3000}`); | |
| 38 | ||
| 39 | export const privacyScreen = (f: Session, ctx: Ctx): Screen => policyScreen("Privacy", PRIVACY_PURPOSE, privacyRows(contactOf(f)), ctx); | |
| 40 | export const supportScreen = (f: Session, ctx: Ctx): Screen => policyScreen("Support", SUPPORT_PURPOSE, supportRows(contactOf(f)), ctx); | |
| 41 | ||
| 42 | export const privacyCommand = (session: Session, ctx: Ctx) => ({ | |
| 43 | id: "privacy", | |
| 44 | title: "Privacy", | |
| 45 | hint: "what a forge stores and who sees it", | |
| 46 | run: () => ctx.push(privacyScreen(session, ctx)), | |
| 47 | }); | |
| 48 | ||
| 49 | export const supportCommand = (session: Session, ctx: Ctx) => ({ | |
| 50 | id: "support", | |
| 51 | title: "Support", | |
| 52 | hint: "how to get help", | |
| 53 | run: () => ctx.push(supportScreen(session, ctx)), | |
| 54 | }); |
src/tui/screens/terms.ts +2 −29
| @@ -6,37 +6,10 @@ | ||
| 6 | 6 | |
| 7 | 7 | import { termRows, TERMS_PURPOSE } from "../../billing/terms_words.ts"; |
| 8 | 8 | import type { Ctx, Screen } from "../app/app.ts"; |
| 9 | import { binding } from "../app/keys.ts"; | |
| 10 | import { style } from "../term/style.ts"; | |
| 11 | import { truncate, wrap } from "../term/width.ts"; | |
| 9 | import { policyScreen } from "./support.ts"; | |
| 12 | 10 | import type { Session } from "../session.ts"; |
| 13 | 11 | |
| 14 | export function termsScreen(f: Session, ctx: Ctx): Screen { | |
| 15 | return { | |
| 16 | title: "Terms of a paid forge", | |
| 17 | keys: [binding(["esc"], "back")], | |
| 18 | render(area, s) { | |
| 19 | const c = ctx.theme.c; | |
| 20 | const w = Math.max(20, area.w); | |
| 21 | let y = area.y; | |
| 22 | const line = (text: string, color = c.fg): void => { | |
| 23 | if (y < area.y + area.h) s.text(area.x, y, truncate(text, w), style(color, c.bg), area.x + area.w); | |
| 24 | y++; | |
| 25 | }; | |
| 26 | for (const row of wrap(TERMS_PURPOSE, w)) line(row, c.mutedFg); | |
| 27 | for (const r of termRows(f.app.db)) { | |
| 28 | y++; | |
| 29 | line(r.label, c.mutedFg); | |
| 30 | for (const row of wrap(r.link === undefined ? r.words : `${r.words} (${r.link.href})`, w)) line(row); | |
| 31 | } | |
| 32 | }, | |
| 33 | key(e) { | |
| 34 | if (e.key !== "esc") return false; | |
| 35 | ctx.pop(); | |
| 36 | return true; | |
| 37 | }, | |
| 38 | }; | |
| 39 | } | |
| 12 | export const termsScreen = (f: Session, ctx: Ctx): Screen => policyScreen("Terms of a paid forge", TERMS_PURPOSE, termRows(f.app.db), ctx); | |
| 40 | 13 | |
| 41 | 14 | /** Offered to everyone: the terms are public on the web. */ |
| 42 | 15 | export const termsCommand = (session: Session, ctx: Ctx) => ({ |
src/view/policy.ts added +63
| @@ -0,0 +1,63 @@ | ||
| 1 | /** | |
| 2 | * What /privacy and /support say (#17947), as plain rows the web pages and the | |
| 3 | * terminal screen both draw, so the two doors cannot drift. Only what is true | |
| 4 | * of today's code goes here. | |
| 5 | */ | |
| 6 | ||
| 7 | export interface PolicyRow { | |
| 8 | readonly label: string; | |
| 9 | readonly words: string; | |
| 10 | /** A stable name for tests and anchors, when a page wants one. */ | |
| 11 | readonly term?: string; | |
| 12 | readonly link?: { readonly href: string; readonly text: string }; | |
| 13 | } | |
| 14 | ||
| 15 | const EMAIL = /^[^\s@<>"']+@[^\s@<>"']+\.[^\s@<>"']+$/; | |
| 16 | ||
| 17 | /** A contact as a link when it is an email address or an https URL; anything else is plain text. */ | |
| 18 | export function contactLink(contact: string): { href: string; text: string } | undefined { | |
| 19 | if (EMAIL.test(contact)) return { href: `mailto:${contact}`, text: contact }; | |
| 20 | return /^https:\/\/[^\s<>"']+$/.test(contact) ? { href: contact, text: contact } : undefined; | |
| 21 | } | |
| 22 | ||
| 23 | function contactRow(contact: string, words: string): PolicyRow { | |
| 24 | const link = contactLink(contact); | |
| 25 | return link === undefined ? { label: "Contact", words: `${words} ${contact}` } : { label: "Contact", words, link }; | |
| 26 | } | |
| 27 | ||
| 28 | export const PRIVACY_PURPOSE = "What a forge keeps and who sees it."; | |
| 29 | ||
| 30 | export function privacyRows(contact: string): PolicyRow[] { | |
| 31 | return [ | |
| 32 | { | |
| 33 | label: "What a forge stores", | |
| 34 | words: | |
| 35 | "Your code is git. Everything else (accounts, issues, runs, settings) is one SQLite file. Both live in the forge's own data directory, on the machine that runs it. An app keeps its own data in a directory of its own.", | |
| 36 | }, | |
| 37 | { | |
| 38 | label: "Your AI account", | |
| 39 | words: | |
| 40 | "The crew works with the AI account you connect, or with credit the forge's host lends you, and the forge says which. Your prompts and code go to that provider under its terms. The forge sends them nowhere else.", | |
| 41 | }, | |
| 42 | { | |
| 43 | label: "The Apple app", | |
| 44 | words: "It is a client of the forge you sign in to. What it sends to that forge is kept by that forge, as described on this page.", | |
| 45 | }, | |
| 46 | { | |
| 47 | label: "Tracking and ads", | |
| 48 | words: "No ads. No tracking across sites. Nothing about you is sold or shared.", | |
| 49 | }, | |
| 50 | contactRow(contact, "Ask about your data, or ask for it to be deleted:"), | |
| 51 | ]; | |
| 52 | } | |
| 53 | ||
| 54 | export const SUPPORT_PURPOSE = "How to get help with a forge or the Apple app."; | |
| 55 | ||
| 56 | export function supportRows(contact: string): PolicyRow[] { | |
| 57 | return [ | |
| 58 | { label: "Learn it", words: "Start with the guide.", link: { href: "/docs", text: "Docs" } }, | |
| 59 | { label: "Is it up?", words: "The forge says what it is doing now.", link: { href: "/status", text: "Status" } }, | |
| 60 | contactRow(contact, "Ask a person:"), | |
| 61 | { label: "A security problem", words: "Tell the security contact, not the support one.", link: { href: "/security", text: "Security" } }, | |
| 62 | ]; | |
| 63 | } |
src/web/layout.ts +2 −7
| @@ -816,13 +816,8 @@ function footer(ctx: Ctx, own?: Html): Html { | ||
| 816 | 816 | >${reduced}</span |
| 817 | 817 | >`} |
| 818 | 818 | <span class="spacer"></span> |
| 819 | <a href="/docs">Docs</a> | |
| 820 | <a href="/pricing">Pricing</a> | |
| 821 | <a href="/security">Security</a> | |
| 822 | <a href="/changelog">Changelog</a> | |
| 823 | <a href="/status">Status</a> | |
| 824 | <a href="/privacy">Privacy</a> | |
| 825 | <a href="/api">API</a> | |
| 819 | <a href="/docs">Docs</a> <a href="/pricing">Pricing</a> <a href="/security">Security</a> <a href="/changelog">Changelog</a> | |
| 820 | <a href="/status">Status</a> <a href="/privacy">Privacy</a> <a href="/support">Support</a> <a href="/api">API</a> | |
| 826 | 821 | ${ctx.auth.user !== undefined && ctx.auth.user.kind !== "org" |
| 827 | 822 | ? html`<a class="btn" data-variant="link" data-size="sm" href="/tell" data-tell-door>Tell the crew</a>` |
| 828 | 823 | : ""} |
src/web/pages/privacy.ts +16 −15
| @@ -1,21 +1,24 @@ | ||
| 1 | 1 | /** |
| 2 | * GET /privacy: what the forge keeps about a visitor, in three plain lines | |
| 3 | * (#11265). Public, static, server-rendered. | |
| 2 | * GET /privacy: what a forge stores, what who sees it and what it keeps | |
| 3 | * about a visitor (#11265, #17947). Public, server-rendered; the first rows are | |
| 4 | * `view/policy.ts`, which the terminal screen reads too. | |
| 4 | 5 | */ |
| 5 | 6 | |
| 6 | import { notePhase, takeSessionTime, timePhase } from "../../core/route_timing.ts"; | |
| 7 | import { supportContact } from "../../core/support_contact.ts"; | |
| 7 | 8 | import type { Ctx } from "../../http/context.ts"; |
| 9 | import { PRIVACY_PURPOSE, privacyRows } from "../../view/policy.ts"; | |
| 8 | 10 | import { html } from "../html.ts"; |
| 9 | import { page } from "../layout.ts"; | |
| 11 | import { policyPage } from "../policy_rows.ts"; | |
| 10 | 12 | |
| 11 | export function privacyPage(ctx: Ctx): Response { | |
| 12 | notePhase(ctx.request, "session", takeSessionTime(ctx.request)); | |
| 13 | return timePhase(ctx.request, "render", () => | |
| 14 | page({ | |
| 15 | ctx, | |
| 16 | title: "Privacy", | |
| 17 | description: "What this forge keeps about visitors, for how long, and what it never keeps.", | |
| 18 | body: html`<div class="page-head"><h1>Privacy</h1></div> | |
| 13 | export const privacyPage = (ctx: Ctx): Response => | |
| 14 | policyPage(ctx, { | |
| 15 | id: "privacy", | |
| 16 | title: "Privacy", | |
| 17 | purpose: PRIVACY_PURPOSE, | |
| 18 | description: "What a forge stores and who sees it, and what this forge keeps about visitors.", | |
| 19 | rows: privacyRows(supportContact(ctx.app, ctx.url.origin)), | |
| 20 | after: html` | |
| 21 | <h2>Visitors to this site</h2> | |
| 19 | 22 | <ul class="list"> |
| 20 | 23 | <li> |
| 21 | 24 | Kept: a random visitor id in a first-party cookie (or, without it, a salted hash of your browser family, OS, |
| @@ -30,6 +33,4 @@ export function privacyPage(ctx: Ctx): Response { | ||
| 30 | 33 | gets no cookie and no visitor record, and the owner can turn this off. |
| 31 | 34 | </li> |
| 32 | 35 | </ul>`, |
| 33 | }), | |
| 34 | ); | |
| 35 | } | |
| 36 | }); |
src/web/pages/support.ts added +11
| @@ -0,0 +1,11 @@ | ||
| 1 | /** | |
| 2 | * GET /support: how to get help (#17947). Public, server-rendered; the rows are `view/policy.ts`. | |
| 3 | */ | |
| 4 | ||
| 5 | import { supportContact } from "../../core/support_contact.ts"; | |
| 6 | import type { Ctx } from "../../http/context.ts"; | |
| 7 | import { SUPPORT_PURPOSE, supportRows } from "../../view/policy.ts"; | |
| 8 | import { policyPage } from "../policy_rows.ts"; | |
| 9 | ||
| 10 | export const supportPage = (ctx: Ctx): Response => | |
| 11 | policyPage(ctx, { id: "support", title: "Support", purpose: SUPPORT_PURPOSE, rows: supportRows(supportContact(ctx.app, ctx.url.origin)) }); |
src/web/pages/terms.ts +3 −20
| @@ -5,27 +5,10 @@ | ||
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | import { termRows, TERMS_PURPOSE } from "../../billing/terms_words.ts"; |
| 8 | import { notePhase, takeSessionTime, timePhase } from "../../core/route_timing.ts"; | |
| 9 | 8 | import type { Ctx } from "../../http/context.ts"; |
| 10 | import { html } from "../html.ts"; | |
| 11 | import { page } from "../layout.ts"; | |
| 9 | import { policyPage } from "../policy_rows.ts"; | |
| 12 | 10 | |
| 13 | 11 | export { keepWords, TERMS_PURPOSE as TERMS_DESCRIPTION } from "../../billing/terms_words.ts"; |
| 14 | 12 | |
| 15 | export function termsPage(ctx: Ctx): Response { | |
| 16 | notePhase(ctx.request, "session", takeSessionTime(ctx.request)); | |
| 17 | return timePhase(ctx.request, "render", () => | |
| 18 | page({ | |
| 19 | ctx, | |
| 20 | title: "Terms", | |
| 21 | description: TERMS_PURPOSE, | |
| 22 | body: html`<div class="page-head"><h1>Terms of a paid forge</h1></div> | |
| 23 | <p class="muted">${TERMS_PURPOSE}</p> | |
| 24 | <dl class="status-rows" id="terms"> | |
| 25 | ${termRows(ctx.app.db).map( | |
| 26 | (r) => html`<div class="status-row" data-term="${r.term}"><dt>${r.label}</dt><dd>${r.words}${r.link === undefined ? "" : html` <a href="${r.link.href}">${r.link.text}</a>`}</dd></div>`, | |
| 27 | )} | |
| 28 | </dl>`, | |
| 29 | }), | |
| 30 | ); | |
| 31 | } | |
| 13 | export const termsPage = (ctx: Ctx): Response => | |
| 14 | policyPage(ctx, { id: "terms", title: "Terms", heading: "Terms of a paid forge", purpose: TERMS_PURPOSE, rows: termRows(ctx.app.db) }); |
src/web/policy_rows.ts added +36
| @@ -0,0 +1,36 @@ | ||
| 1 | /** | |
| 2 | * The one layout of /privacy, /support and /terms: a head, a labelled list, and what a page adds | |
| 3 | * after it (#17947). | |
| 4 | */ | |
| 5 | ||
| 6 | import { notePhase, takeSessionTime, timePhase } from "../core/route_timing.ts"; | |
| 7 | import type { Ctx } from "../http/context.ts"; | |
| 8 | import type { PolicyRow } from "../view/policy.ts"; | |
| 9 | import { pageHead } from "./chrome.ts"; | |
| 10 | import { html, type Html } from "./html.ts"; | |
| 11 | import { page } from "./layout.ts"; | |
| 12 | ||
| 13 | export function policyRows(id: string, rows: readonly PolicyRow[]): Html { | |
| 14 | return html`<dl class="status-rows" id="${id}"> | |
| 15 | ${rows.map( | |
| 16 | (r) => | |
| 17 | html`<div class="status-row"${r.term === undefined ? "" : html` data-term="${r.term}"`}><dt>${r.label}</dt><dd>${r.words}${r.link === undefined ? "" : html` <a href="${r.link.href}">${r.link.text}</a>`}</dd></div>`, | |
| 18 | )} | |
| 19 | </dl>`; | |
| 20 | } | |
| 21 | ||
| 22 | export function policyPage( | |
| 23 | ctx: Ctx, | |
| 24 | o: { id: string; title: string; heading?: string; purpose: string; description?: string; rows: readonly PolicyRow[]; after?: Html }, | |
| 25 | ): Response { | |
| 26 | notePhase(ctx.request, "session", takeSessionTime(ctx.request)); | |
| 27 | return timePhase(ctx.request, "render", () => | |
| 28 | page({ | |
| 29 | ctx, | |
| 30 | title: o.title, | |
| 31 | description: o.description ?? o.purpose, | |
| 32 | body: html`${pageHead(o.heading ?? o.title, { sub: o.purpose })} | |
| 33 | ${policyRows(o.id, o.rows)}${o.after ?? null}`, | |
| 34 | }), | |
| 35 | ); | |
| 36 | } |
src/web/standards.ts +1
| @@ -380,6 +380,7 @@ export async function sitemapXml(ctx: Ctx): Promise<Response> { | ||
| 380 | 380 | `<url><loc>${o}/agents</loc></url>`, |
| 381 | 381 | `<url><loc>${o}/pricing</loc></url>`, |
| 382 | 382 | `<url><loc>${o}/privacy</loc></url>`, |
| 383 | `<url><loc>${o}/support</loc></url>`, | |
| 383 | 384 | `<url><loc>${o}/terms</loc></url>`, |
| 384 | 385 | `<url><loc>${o}/docs</loc></url>`, |
| 385 | 386 | ...pages.map((p) => { |
src/web/studio/home.ts +2
| @@ -913,6 +913,8 @@ export function studioDoor(ctx: Ctx): Response { | ||
| 913 | 913 | <span>Open Platform. Open source under AGPL-3.0.</span> |
| 914 | 914 | <span class="spacer"></span> |
| 915 | 915 | <a href="${FORGE_REPO}">Code</a> |
| 916 | <a href="/privacy">Privacy</a> | |
| 917 | <a href="/support">Support</a> | |
| 916 | 918 | <a href="https://www.open-platform.sh">open-platform.sh</a> |
| 917 | 919 | <a href="https://www.espodev.com">EspoDev</a>`, |
| 918 | 920 | } |
test/forge-looks.test.ts +1
| @@ -104,6 +104,7 @@ const NOT_A_PAGE: Record<string, string> = { | ||
| 104 | 104 | "/search": "a search box; its slot went to the preview seed's /next as its owner (#8866)", |
| 105 | 105 | "/contribute": "a static page about how to help; its slot went to the preview seed's /bets as its owner (#8866)", |
| 106 | 106 | "/privacy": "three static lines on what the forge keeps about a visitor (#11265); covered by test/visitors.test.ts", |
| 107 | "/support": "a static page on how to get help; covered by test/privacy-support.test.ts", | |
| 107 | 108 | "/status": "one sentence and five rows on whether the forge works (#13211); covered by test/status-page.test.ts", |
| 108 | 109 | "/migrate": "an import form, nothing to picture until a job runs; its slot went to /repos, and that one to /maintenance (#12692)", |
| 109 | 110 | }; |
test/palette-roster.test.ts +8
| @@ -69,6 +69,8 @@ test("a site-admin person is offered the whole roster", () => { | ||
| 69 | 69 | ["get-a-forge", "Get your own forge", "the plans, where to get a hosted forge, how to run one yourself"], |
| 70 | 70 | ["pricing", "Get a forge (plans)", "pick a plan, name it, pay at the checkout address"], |
| 71 | 71 | ["terms", "Terms of a paid forge", "what you buy, what a lapse does, who owns the data"], |
| 72 | ["privacy", "Privacy", "what a forge stores and who sees it"], | |
| 73 | ["support", "Support", "how to get help"], | |
| 72 | 74 | ["data", "Data", "the SQLite files you may read as a tree; / filters, : asks in SQL, y yanks a row, e exports a table as CSV"], |
| 73 | 75 | ["fleet", "Fleet rows", "the rows a fleet query line selects"], |
| 74 | 76 | ["profile", "Open a profile", "username or org"], |
| @@ -290,6 +292,8 @@ test("a site-admin agent is offered the roster without the person-only entries", | ||
| 290 | 292 | ["get-a-forge", "Get your own forge", "the plans, where to get a hosted forge, how to run one yourself"], |
| 291 | 293 | ["pricing", "Get a forge (plans)", "pick a plan, name it, pay at the checkout address"], |
| 292 | 294 | ["terms", "Terms of a paid forge", "what you buy, what a lapse does, who owns the data"], |
| 295 | ["privacy", "Privacy", "what a forge stores and who sees it"], | |
| 296 | ["support", "Support", "how to get help"], | |
| 293 | 297 | ["data", "Data", "the SQLite files you may read as a tree; / filters, : asks in SQL, y yanks a row, e exports a table as CSV"], |
| 294 | 298 | ["fleet", "Fleet rows", "the rows a fleet query line selects"], |
| 295 | 299 | ["profile", "Open a profile", "username or org"], |
| @@ -413,6 +417,8 @@ test("a member person is offered the signed-in roster without the admin entries" | ||
| 413 | 417 | ["get-a-forge", "Get your own forge", "the plans, where to get a hosted forge, how to run one yourself"], |
| 414 | 418 | ["pricing", "Get a forge (plans)", "pick a plan, name it, pay at the checkout address"], |
| 415 | 419 | ["terms", "Terms of a paid forge", "what you buy, what a lapse does, who owns the data"], |
| 420 | ["privacy", "Privacy", "what a forge stores and who sees it"], | |
| 421 | ["support", "Support", "how to get help"], | |
| 416 | 422 | ["fleet", "Fleet rows", "the rows a fleet query line selects"], |
| 417 | 423 | ["profile", "Open a profile", "username or org"], |
| 418 | 424 | ["repos", "Repositories", "the repositories you may write"], |
| @@ -531,6 +537,8 @@ test("signed out, the palette offers sign-in and the public entries", () => { | ||
| 531 | 537 | ["start-forge", "Start my forge", "a free forge of your own; you pick a username and create your passkey next"], |
| 532 | 538 | ["pricing", "Get a forge (plans)", "pick a plan, name it, pay at the checkout address"], |
| 533 | 539 | ["terms", "Terms of a paid forge", "what you buy, what a lapse does, who owns the data"], |
| 540 | ["privacy", "Privacy", "what a forge stores and who sees it"], | |
| 541 | ["support", "Support", "how to get help"], | |
| 534 | 542 | ["forge-name", "Is a forge name free?", "ask whether Start my forge would take a name"], |
| 535 | 543 | ["fleet", "Fleet rows", "the rows a fleet query line selects"], |
| 536 | 544 | ["profile", "Open a profile", "username or org"], |
test/privacy-support.test.ts added +90
| @@ -0,0 +1,90 @@ | ||
| 1 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; | |
| 2 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 3 | import { tmpdir } from "node:os"; | |
| 4 | import { join } from "node:path"; | |
| 5 | import { createApp, type App } from "../src/app.ts"; | |
| 6 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 7 | import { createForgeApp, type TuiIdentity } from "../src/tui/forge.ts"; | |
| 8 | import { forgeCommands } from "../src/tui/forge_parts.ts"; | |
| 9 | import { privacyScreen, supportScreen } from "../src/tui/screens/support.ts"; | |
| 10 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; | |
| 11 | import { contactLink, privacyRows, supportRows } from "../src/view/policy.ts"; | |
| 12 | import { quietLogs } from "./helpers/globals.ts"; | |
| 13 | import { settleApp } from "./helpers/tui.ts"; | |
| 14 | ||
| 15 | quietLogs(); | |
| 16 | ||
| 17 | describe("/privacy and /support", () => { | |
| 18 | let dir = ""; | |
| 19 | let app: App; | |
| 20 | let servers: Servers; | |
| 21 | const get = async (p: string) => { | |
| 22 | const r = await fetch(`${servers.url}${p}`); | |
| 23 | return { status: r.status, text: await r.text() }; | |
| 24 | }; | |
| 25 | beforeAll(async () => { | |
| 26 | dir = await mkdtemp(join(tmpdir(), "privacy-support-")); | |
| 27 | process.env["FORGE_SUPPORT_CONTACT"] = "[email protected]"; | |
| 28 | app = createApp({ dataDir: dir, url: "https://forge.test", port: 0 }); | |
| 29 | servers = await serve(app); | |
| 30 | }); | |
| 31 | afterAll(async () => { | |
| 32 | delete process.env["FORGE_SUPPORT_CONTACT"]; | |
| 33 | servers.stop?.(); | |
| 34 | await rm(dir, { recursive: true, force: true }); | |
| 35 | }); | |
| 36 | ||
| 37 | test("/privacy answers signed out with every promise and the contact", async () => { | |
| 38 | const { status, text } = await get("/privacy"); | |
| 39 | expect(status).toBe(200); | |
| 40 | for (const r of privacyRows("[email protected]")) expect(text).toContain(r.label); | |
| 41 | expect(text).toContain("one SQLite file"); | |
| 42 | expect(text).not.toContain("Report"); | |
| 43 | expect(text).toContain('href="mailto:[email protected]"'); | |
| 44 | expect(text).toContain("Visitors to this site"); | |
| 45 | }); | |
| 46 | ||
| 47 | test("/support answers signed out with the docs and the contact", async () => { | |
| 48 | const { status, text } = await get("/support"); | |
| 49 | expect(status).toBe(200); | |
| 50 | expect(text).toContain("<title>Support"); | |
| 51 | expect(text).toContain('href="/docs"'); | |
| 52 | expect(text).toContain('href="mailto:[email protected]"'); | |
| 53 | expect(text.match(/<main[\s\S]*?<\/main>/)![0]).not.toContain("<script"); | |
| 54 | }); | |
| 55 | ||
| 56 | test("the footer links both, and the sitemap lists /support", async () => { | |
| 57 | const { text } = await get("/"); | |
| 58 | expect(text).toContain('href="/privacy"'); | |
| 59 | expect(text).toContain('href="/support"'); | |
| 60 | expect((await get("/sitemap.xml")).text).toContain("/support</loc>"); | |
| 61 | }); | |
| 62 | ||
| 63 | test("a contact that is not an address or an https link is text, never a link", () => { | |
| 64 | expect(contactLink("javascript:alert(1)")).toBeUndefined(); | |
| 65 | expect(contactLink('[email protected]"><x')).toBeUndefined(); | |
| 66 | expect(contactLink("https://forge.test/x")).toEqual({ href: "https://forge.test/x", text: "https://forge.test/x" }); | |
| 67 | expect(supportRows("call me").find((r) => r.label === "Contact")!.words).toContain("call me"); | |
| 68 | }); | |
| 69 | ||
| 70 | test("the terminal shows the same rows and the palette offers both", async () => { | |
| 71 | const identity: TuiIdentity = { sshUsername: "git", remoteAddress: "203.0.113.4", fingerprint: "SHA256:test", user: undefined }; | |
| 72 | const terminal = headlessTerminal(120, 60); | |
| 73 | const { app: tui, session } = createForgeApp(app, identity, { terminal, exitHooks: false }); | |
| 74 | tui.start(); | |
| 75 | const ids = forgeCommands(session)(tui.ctx).map((c) => c.id); | |
| 76 | expect(ids).toContain("privacy"); | |
| 77 | expect(ids).toContain("support"); | |
| 78 | for (const [screen, rows] of [ | |
| 79 | [privacyScreen, privacyRows("[email protected]")], | |
| 80 | [supportScreen, supportRows("[email protected]")], | |
| 81 | ] as const) { | |
| 82 | tui.ctx.push(screen(session, tui.ctx)); | |
| 83 | await settleApp(tui); | |
| 84 | const text = tui.screen.toText().replace(/\s+/g, " "); | |
| 85 | for (const r of rows) expect(text).toContain(r.label); | |
| 86 | expect(text).toContain("[email protected]"); | |
| 87 | tui.ctx.pop(); | |
| 88 | } | |
| 89 | }); | |
| 90 | }); |
test/terms-page.test.ts +1 −1
| @@ -37,7 +37,7 @@ describe("/terms", () => { | ||
| 37 | 37 | // under 10 KB with any body; the page's own part is held small, and the shell under 10.5 KB. |
| 38 | 38 | const main = text.match(/<main[\s\S]*?<\/main>/)![0]; |
| 39 | 39 | expect(main.length).toBeLessThan(2_000); |
| 40 | expect(text.length - main.length).toBeLessThan(11_000); // 10,866 B measured: the theme select and four themes' boot rules | |
| 40 | expect(text.length - main.length).toBeLessThan(11_000); // 10,866 B on main; the footer links stay under it | |
| 41 | 41 | expect(text).toContain("<title>Terms"); |
| 42 | 42 | expect(text).toContain("<h1>Terms of a paid forge</h1>"); |
| 43 | 43 | expect(text.match(/<dt>/g)!.length).toBe(6); |
new above
offline
This
linehelper is a copy of the one in the pricing screen (gate: one implementation?). Share it from the term helpers instead of a fourth copy.