Merge auth/sign-in-redesign into main
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by oscabriel · committed by oscabriel · parents b9fc54b, 2d841e7 · Browse files · 12 files·+478 added−103 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
12 files+478 added−103 removed
- tests:+213 added−11 removed
- other:+265 added−92 removed
Provenance
- Commit
9142e90- Tree
347e3a1- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent 1
b9fc54b- Parent 2
2d841e7
12 files changed+478 added−103 removed
modified:apps/cli/src/local/login.ts+31 added-2 removed
285 unmodified lines286 Effect.flatMap((digest) => encodeBase64Url(new Uint8Array(digest))),287 Effect.orDie288 );289 290+// The browser's last stop, in the sign-in pages' look: their paper, ink and291+// muted values, light and dark, and nothing loaded. The text is fixed, so292+// nothing in it needs escaping.293+const callbackPage = (title: string, line: string) => `<!doctype html>294+<html lang="en">295+<head>296+<meta charset="utf-8">297+<meta name="viewport" content="width=device-width, initial-scale=1">298+<meta name="color-scheme" content="light dark">299+<title>${title} · ${Brand.name}</title>300+<style>301+:root{color-scheme:light dark;--paper:#f8f7f4;--ink:#1a1f2e;--muted:#5d6371}302+@media (prefers-color-scheme:dark){:root{--paper:#0a0a0a;--ink:#f5f5f5;--muted:#a0a0a0}}303+body{margin:0;background-color:var(--paper);color:var(--ink);font-family:"IBM Plex Sans",ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;font-size:16px;line-height:1.5}304+main{max-width:25rem;margin:0 auto;padding:20vh 16px 48px;text-align:center}305+.wordmark{margin:0 0 28px;font-size:1.1875rem;font-weight:600;letter-spacing:-.02em}306+h1{margin:0 0 8px;font-size:1.5rem;line-height:2rem;font-weight:600;letter-spacing:-.015em}307+p{margin:0;color:var(--muted)}308+p.wordmark{color:var(--ink)}309+</style>310+</head>311+<body><main><p class="wordmark">${Brand.name}</p><h1>${title}</h1><p>${line}</p></main></body>312+</html>313+`;314+315 const loopback = Effect.gen(function* () {316 const { listen } = yield* Loopback;317 const server = yield* listen({ hostname: LOOPBACK, port: 0 });318 const returned = yield* Deferred.make<URLSearchParams>();10 unmodified lines329 const first = yield* Deferred.succeed(returned, at.searchParams);330 331 return HttpServerResponse.text(332 first308- ? `${Brand.cli} login has the sign-in. You can close this tab; the terminal says how it ended.`309- : "This sign-in has already come back.",333+ ? callbackPage(334+ "Signed in",335+ "You can close this tab and go back to your terminal."336+ )337+ : callbackPage("Already signed in", "This sign-in already finished."),338 {339+ contentType: "text/html; charset=utf-8",340 // One request per connection, so closing the server waits on none.341 headers: { "cache-control": "no-store", connection: "close" },342 status: first ? 200 : 410,343 }342 unmodified linesmodified:apps/cli/test/local/login.test.ts+26 added-1 removed
247 unmodified lines248 249 return response.status;250 }).pipe(Effect.provide(FetchHttpClient.layer));251 252+/** What the browser is shown at the end: the callback's page. */253+const landing = (at: string) =>254+ Effect.gen(function* () {255+ const client = yield* HttpClient.HttpClient;256+ const response = yield* client.get(at);257+258+ return {259+ status: response.status,260+ text: yield* response.text,261+ type: response.headers["content-type"],262+ };263+ }).pipe(Effect.provide(FetchHttpClient.layer));264+265 const fieldsOf = (query: URLSearchParams | undefined) =>266 Object.fromEntries(query?.entries() ?? []);267 268 describe(`${Brand.cli} login --token-stdin`, () => {295 unmodified lines564 { env, seams: platform.layer }565 )566 );567 555- expect(yield* visit(yield* signInUrl(server.origin))).toBe(200);568+ const shown = yield* landing(yield* signInUrl(server.origin));569+570+ expect({571+ said: shown.text.includes(572+ "You can close this tab and go back to your terminal."573+ ),574+ status: shown.status,575+ type: shown.type,576+ }).toStrictEqual({577+ said: true,578+ status: 200,579+ type: "text/html; charset=utf-8",580+ });581 expect(Exit.isSuccess(yield* Fiber.join(fiber))).toBeTruthy();582 583 const [query] = yield* server.authorizations;584 const fields = fieldsOf(query);257 unmodified linesadded:apps/platform/src/auth/first-party.ts+31 added
12345678910111213141516171819202122232425262728293031import { Option } from "effect";
import { cliClientId } from "./cli-client.ts";
// Where the web serves its Client ID Metadata Document (apps/web's `/auth/client`).export const WEB_CLIENT_PATH = "/auth/client";
export type FirstParty = "cli" | "web";
const originOf = Option.liftThrowable((url: string) => new URL(url).origin);
/** * Our own clients, told apart by their id alone: a client names itself in its * metadata, so a name proves nothing, but only this platform and its web serve * a document at these addresses. */export const firstPartyOf = ( clientId: string, origin: string, webUrl: Option.Option<string>): FirstParty | undefined => { if (clientId === cliClientId(origin)) { return "cli"; }
const web = Option.flatMap(webUrl, originOf);
return Option.isSome(web) && clientId === `${web.value}${WEB_CLIENT_PATH}` ? "web" : undefined;};modified:apps/platform/src/auth/google.ts+2 added
43 unmodified lines44 HeldHandles,45 htmlPage,46 Says,47 SignInKeys,48+ SignInHome,49 SignInOffers,50 signInPageFor,51 } from "./sign-in.ts";52 import type { SignInServices } from "./sign-in.ts";781 unmodified lines834 Context.add(Identities, yield* Identities),835 Context.add(Mailer, yield* Mailer),836 Context.add(OAuthStore, yield* OAuthStore),837 Context.add(SignInAttempts, yield* SignInAttempts),838+ Context.add(SignInHome, yield* SignInHome),839 Context.add(SignInKeys, yield* SignInKeys),840 Context.add(SignInOffers, yield* SignInOffers)841 );842 20 unmodified linesmodified:apps/platform/src/auth/pages.ts+157 added-82 removed
1 // Loads nothing (no script, stylesheet, font or image), so the page's CSP can be `default-src 'none'`.2 import { Brand } from "@repo/brand";3 4+import type { FirstParty } from "./first-party.ts";5+6 export interface Asker {7 readonly clientDomain?: string | undefined;8 readonly clientName: string;9 readonly redirectHost: string;10 readonly redirectIsLoopback: boolean;11+ // Our own web or CLI, told by the client's id: neither is asked to consent.12+ readonly firstParty?: FirstParty | undefined;13+ // The web's home, which the wordmark links to; the platform's `/` when it is not known.14+ readonly home?: string | undefined;15 }16 17 export interface PendingForm {18 readonly csrf: string;28 unmodified lines47 .replaceAll(">", ">")48 .replaceAll('"', """)49 .replaceAll("'", "'");50 45-// The web's focus shell, drawn without its code: the sage garden palette's51+// The web's focus card, drawn without its code: the sage garden palette's52 // values copied from apps/web/src/styles.css as hex (the paper, ink, rule,53 // muted, input, primary and state roles, light and dark), and its faces named54 // first. No font may load here, so IBM Plex is used where the reader has it49-// installed and the system's faces stand in otherwise. The frame is the50-// web's: from 640 px a hairline down each edge of the card's container, the51-// page's full height, with the wordmark's bar a box between them under a52-// 16 px gap (DESIGN.md "Rails"); on a phone the bar's rule alone.55+// installed and the system's faces stand in otherwise. One centred column of56+// the card's width: the wordmark over the card, and what leads elsewhere57+// under it. From 640 px the card is a hairline-bordered surface on the paper;58+// on a phone it is the page itself, with no border to box it in.59 const STYLE = `60 :root{color-scheme:light dark;--paper:#f8f7f4;--ink:#1a1f2e;--card:#ffffff;--surface:#e8e6e1;--muted:#5d6371;--rule:#d6d4cf;--input:#79808f;--primary:#677a6d;--on-primary:#ffffff;--refused:#ae2325;--waiting:#516012;--selection:#0c628c38}61 @media (prefers-color-scheme:dark){:root{--paper:#0a0a0a;--ink:#f5f5f5;--card:#121212;--surface:#1a1a1a;--muted:#a0a0a0;--rule:#2a2a2a;--input:#696969;--primary:#7c9082;--on-primary:#000000;--refused:#ff5451;--waiting:#bad074;--selection:#68bbef38}}62 *{box-sizing:border-box}63 body{margin:0;background-color:var(--paper);color:var(--ink);caret-color:var(--ink);font-family:"IBM Plex Sans",ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;font-size:16px;line-height:1.5;-webkit-text-size-adjust:100%;text-size-adjust:100%}64 ::selection{background-color:var(--selection);color:var(--ink)}59-.frame{display:flex;flex-direction:column;min-height:100dvh;max-width:25rem;margin:0 auto}60-.top{display:flex;align-items:center;height:56px;padding:0 16px;border-bottom:1px solid var(--rule)}61-.wordmark{margin:0;font-size:1rem;line-height:1.5rem;font-weight:600;letter-spacing:-.015em}62-main{padding:32px 16px 64px}63-main.document{max-width:44rem;margin:0 auto;padding-top:48px}64-@media (min-width:40em){.frame{border-left:1px solid var(--rule);border-right:1px solid var(--rule)}.top{margin-top:16px;padding:0 32px;border-top:1px solid var(--rule)}main{padding:32px 32px 64px}}65-.card{background-color:var(--card);border:1px solid var(--rule);border-radius:2px;padding:28px 24px}65+.shell{max-width:28rem;margin:0 auto;padding:28px 16px 48px}66+.top{display:flex;justify-content:center;margin:0 0 28px}67+.wordmark{font-size:1.1875rem;line-height:1.6rem;font-weight:600;letter-spacing:-.02em;color:var(--ink);text-decoration:none}68+.card{background-color:var(--card);border:1px solid var(--rule);border-radius:2px;padding:32px}69 .card>:last-child{margin-bottom:0}70+@media (max-width:39.99em){.card{background-color:transparent;border-color:transparent;padding:0}}71+@media (min-width:40em){.shell{padding:12vh 24px 64px}}72+main.document{max-width:44rem;margin:0 auto;padding:48px 16px 64px}67-h1{font-size:1.5rem;line-height:2rem;font-weight:600;letter-spacing:-.015em;margin:0 0 20px;text-wrap:balance;overflow-wrap:anywhere}73+h1{font-size:1.5rem;line-height:2rem;font-weight:600;letter-spacing:-.015em;margin:0 0 24px;text-wrap:balance;overflow-wrap:anywhere}74 h2{font-size:1.1875rem;line-height:1.6rem;font-weight:600;letter-spacing:-.01em;margin:40px 0 12px}75 p{margin:0 0 16px}76 a{color:var(--ink);text-decoration-color:var(--input);text-decoration-thickness:1px;text-underline-offset:.2em}77 a:hover{text-decoration-color:currentColor}78 :focus-visible{outline:2px solid var(--primary);outline-offset:2px}79 strong{font-weight:600}74-.consent{border-top:1px solid var(--rule);border-bottom:1px solid var(--rule);padding:16px 0;margin:0 0 24px;overflow-wrap:anywhere}75-.consent p{margin:0}76-.consent p+p{margin-top:4px}80+.small{font-size:.875rem;line-height:1.3rem}81+.lead{margin:-16px 0 24px}82+.consent{margin:-8px 0 24px;font-size:.875rem;line-height:1.3rem;padding:0 0 20px;border-bottom:1px solid var(--rule);overflow-wrap:anywhere}83+.consent p{margin:0 0 4px}84 .consent .warning{margin-top:12px}78-.consent .may{margin:4px 0 12px}79-.consent .may li{margin:0 0 4px}85+details{margin-top:12px}86+summary{cursor:pointer;font-weight:500}87+details ul{margin:8px 0 0}88+details li{margin:0 0 4px}89 .warn{color:var(--waiting);font-weight:600;white-space:nowrap}90 .warn svg{width:16px;height:16px;vertical-align:-2px;margin-right:6px}82-.error{color:var(--refused);font-weight:600;overflow-wrap:anywhere}91+.error{color:var(--refused);font-weight:500;font-size:.875rem;line-height:1.3rem;overflow-wrap:anywhere}92 .muted{color:var(--muted)}84-form{margin:0 0 24px}93+form{margin:0}94 label{display:block;margin:0 0 16px;font-size:.875rem;line-height:1.3rem;font-weight:500}95+.field{margin:0 0 16px}96+.field-head{display:flex;align-items:baseline;justify-content:space-between;gap:12px}97+.field-head label{margin:0}98+.field-head a{font-size:.875rem;line-height:1.3rem;font-weight:400;color:var(--muted);text-decoration:none}99+.field-head a:hover{color:var(--ink);text-decoration:underline}100 input{display:block;width:100%;height:44px;margin-top:6px;padding:0 12px;font-family:inherit;font-size:16px;font-weight:400;color:var(--ink);background-color:var(--paper);border:1px solid;border-color:var(--input);border-radius:2px}87-button,.button{display:inline-flex;align-items:center;justify-content:center;min-height:44px;padding:0 16px;font-family:inherit;font-size:1rem;font-weight:500;text-decoration:none;border:1px solid;border-radius:2px;cursor:pointer}101+button,.button{display:flex;width:100%;align-items:center;justify-content:center;gap:10px;min-height:44px;padding:0 16px;font-family:inherit;font-size:1rem;font-weight:500;line-height:1.25rem;text-decoration:none;border:1px solid;border-radius:2px;cursor:pointer}102 button{color:var(--on-primary);background-color:var(--primary);border-color:var(--primary)}89-button.secondary,.button{color:var(--ink);background-color:var(--card);border-color:var(--input)}90-button:hover{opacity:.88}91-button.secondary:hover,.button:hover{background-color:var(--surface);opacity:1}92-.button{display:flex;width:100%}93-.actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:24px}103+.button{color:var(--ink);background-color:var(--card);border-color:var(--input)}104+button:hover{opacity:.9}105+.button:hover{background-color:var(--surface)}106+.button svg{flex:none;width:18px;height:18px}107+button.link{display:block;width:auto;min-height:0;margin:16px auto 0;padding:2px 4px;color:var(--muted);background-color:transparent;border:0;font-size:.875rem;line-height:1.3rem;font-weight:400;text-decoration:none;text-underline-offset:.2em}108+button.link:hover{color:var(--ink);opacity:1;text-decoration:underline}109+.submit{margin-top:24px}110+.or{display:flex;align-items:center;gap:12px;margin:20px 0}111+.or .line{flex:1;height:1px;background-color:var(--rule)}112+.aside{margin:24px 0 0;text-align:center}113 pre{margin:8px 0 12px;padding:8px 12px;overflow-x:auto;background-color:var(--surface);border:1px solid var(--rule)}114 code{font-family:"IBM Plex Mono",ui-monospace,"SF Mono",Menlo,Consolas,monospace;font-size:.8125rem;overflow-wrap:anywhere}115 ul{margin:0;padding-left:1.25rem}116 li{margin:0 0 8px}117 `;118 119 type Width = "form" | "document";120 102-// A form is the focus shell: the wordmark as text in a bar between the rails,103-// one card under it, and no navigation. A document (the platform's `/`)104-// reads as plain prose.105-const frame = (body: string, width: Width) =>121+interface Frame {122+ // The web's home, which the wordmark links to.123+ readonly home?: string | undefined;124+ // What leads elsewhere, under the card.125+ readonly after?: string;126+}127+128+// A form is the focus card: the wordmark over it, a line under it, and no129+// navigation. A document (the platform's `/`) reads as plain prose.130+const framed = (body: string, width: Width, frame: Frame) =>131 width === "document"132 ? `<main class="document">133 ${body}134 </main>`110- : `<div class="frame"><header class="top"><p class="wordmark">${escapeHtml(Brand.name)}</p></header>111-<main><div class="card">135+ : `<div class="shell"><header class="top"><a class="wordmark" href="${escapeHtml(frame.home ?? "/")}">${escapeHtml(Brand.name)}</a></header>136+<main class="card">137 ${body}113-</div></main></div>`;138+</main>${frame.after === undefined ? "" : `\n<p class="aside small muted">${frame.after}</p>`}</div>`;139 115-// `body` is HTML already escaped.116-export const page = (title: string, body: string, width: Width = "form") =>140+// `body` and `frame.after` are HTML already escaped.141+export const page = (142+ title: string,143+ body: string,144+ width: Width = "form",145+ frame: Frame = {}146+) =>147 `<!doctype html>148 <html lang="en">149 <head>150 <meta charset="utf-8">1 unmodified line152 <meta name="color-scheme" content="light dark">153 <title>${escapeHtml(title)} · ${escapeHtml(Brand.name)}</title>154 <style>${STYLE}</style>155 </head>126-<body>${frame(body, width)}</body>156+<body>${framed(body, width, frame)}</body>157 </html>158 `;159 160 const WARNING_MARK = `<svg viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path d="M8 1.75 14.75 14H1.25z" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/><path d="M8 6.25v3.5M8 11.75v.25" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>`;161 162+// Google's "G", in its own colours, as its sign-in buttons show it.163+const GOOGLE_MARK = `<svg viewBox="0 0 18 18" aria-hidden="true" focusable="false"><path fill="#4285F4" d="M17.64 9.2c0-.64-.06-1.25-.16-1.84H9v3.48h4.84a4.14 4.14 0 0 1-1.8 2.72v2.26h2.92c1.7-1.57 2.68-3.88 2.68-6.62z"/><path fill="#34A853" d="M9 18c2.43 0 4.47-.8 5.96-2.18l-2.92-2.26c-.8.54-1.84.86-3.04.86-2.34 0-4.32-1.58-5.03-3.7H.96v2.33A9 9 0 0 0 9 18z"/><path fill="#FBBC05" d="M3.97 10.72A5.41 5.41 0 0 1 3.68 9c0-.6.1-1.18.29-1.72V4.95H.96A9 9 0 0 0 0 9c0 1.45.35 2.83.96 4.05l3.01-2.33z"/><path fill="#EA4335" d="M9 3.58c1.32 0 2.5.45 3.44 1.35l2.58-2.58A8.65 8.65 0 0 0 9 0 9 9 0 0 0 .96 4.95l3.01 2.33C4.68 5.16 6.66 3.58 9 3.58z"/></svg>`;164+165 // What a grant lets a client do: it acts as the person, through the CLI's166 // contracts, MCP and the git gateway alike.134-const MAY = `<p>As you, it may:</p>167+const MAY = `<details>168+<summary>What it can do</summary>169 <ul class="may">170 <li>Read what you can read: projects, asks, code, verdicts, and any layer whose audience you are in</li>171 <li>Claim, release and answer asks, and push to your forks</li>172 <li>Make projects, and propose and flag asks</li>173 <li>Open asks, take decisions, finish answers, land changes, vouch for or denounce people, and set write-only values where you are a maintainer; nobody can read a value back</li>174 </ul>141-<p>It never sees your password.</p>`;175+<p>It never sees your password.</p>176+</details>`;177 178 type Says = "who" | "who and what";179 180+/**181+ * Who asks, said only of a client that is not ours: the web says nothing, and182+ * the CLI one line, since the person started it themselves a moment ago.183+ */184 const askerParagraphs = (asker: Asker, says: Says = "who") => {185+ if (asker.firstParty === "web") {186+ return "";187+ }188+189+ if (asker.firstParty === "cli") {190+ return `<p class="lead small muted">This finishes signing in the CLI on this computer. Continue only if you just ran <code>${escapeHtml(Brand.cli)} login</code>.</p>`;191+ }192+193 const name = `<strong>${escapeHtml(asker.clientName)}</strong>`;194 195 const domain =196 asker.clientDomain === undefined197 ? ""151- : ` (published by ${escapeHtml(asker.clientDomain)})`;198+ : ` (${escapeHtml(asker.clientDomain)})`;199 200 const loopback = asker.redirectIsLoopback201 ? `<p class="warning"><strong class="warn">${WARNING_MARK}Warning</strong> This sends access to an app on your computer. Continue only if you just started signing in from it.</p>`202 : "";203 204 const label = says === "who" ? "Who asks" : "Who asks and what it may do";205 206 return `<section class="consent" aria-label="${label}">160-<p>${name}${domain} asks to act as you.</p>207+<p>${name}${domain} wants to act as you.</p>208 <p>Access goes to <strong>${escapeHtml(asker.redirectHost)}</strong>.</p>209 ${loopback}210 ${says === "who and what" ? MAY : ""}211 </section>`;212 };213 214+const homeOf = (asker: Asker): Frame => ({ home: asker.home });215+216 const messageParagraph = (message?: string) =>217 message === undefined218 ? ""219 : `<p class="error" role="alert">${escapeHtml(message)}</p>`;1 unmodified line221 const hiddenFields = (form: PendingForm) =>222 `<input type="hidden" name="request" value="${escapeHtml(form.request)}">223 <input type="hidden" name="csrf" value="${escapeHtml(form.csrf)}">`;224 225+const OR = `<div class="or small muted"><span class="line" aria-hidden="true"></span>or<span class="line" aria-hidden="true"></span></div>`;226+227 // A link, so no form posts to Google.177-const googleChoices = (offers: Offers, form: PendingForm) =>228+const googleStart = (offers: Offers, form: PendingForm) =>229 offers.google179- ? {180- link: `<button type="submit" class="secondary" formaction="${GOOGLE_PATHS.link}">Sign in and link Google</button>`,181- start: `<p><a href="${GOOGLE_PATHS.start}?request=${encodeURIComponent(form.request)}" class="button">Continue with Google</a></p>182-<p class="muted">Or sign in with your email or handle and password.</p>`,183- }184- : { link: "", start: "" };230+ ? `<a href="${GOOGLE_PATHS.start}?request=${encodeURIComponent(form.request)}" class="button">${GOOGLE_MARK}Continue with Google</a>231+${OR}`232+ : "";233 234+const LINK_GOOGLE = "Sign in and link your Google account";235+236 const valueOf = (value?: string) =>237 value === undefined ? "" : ` value="${escapeHtml(value)}"`;238 239 const withRequest = (path: string, form: PendingForm) =>3 unmodified lines243 asker: Asker,244 form: PendingForm,245 offers: Offers,246 message?: string197-) => {198- const google = googleChoices(offers, form);199-200- return page(247+) =>248+ page(249 "Sign in",202- `<h1>Sign in</h1>250+ `<h1>Sign in to ${escapeHtml(Brand.name)}</h1>251 ${askerParagraphs(asker, "who and what")}204-${google.start}252+${googleStart(offers, form)}253 ${messageParagraph(message)}254 <form method="post" action="/authorize">255 ${hiddenFields(form)}256 <label>Email or handle <input name="login" autocomplete="username" autocapitalize="none" spellcheck="false" required></label>209-<label>Password <input type="password" name="password" autocomplete="current-password" required></label>210-<div class="actions">211-<button type="submit">Sign in</button>212-${google.link}257+<div class="field">258+<div class="field-head"><label for="password">Password</label><a href="${withRequest(ACCOUNT_PATHS.reset, form)}">Forgot password?</a></div>259+<input type="password" name="password" id="password" autocomplete="current-password" required>260 </div>214-</form>215-<p><a href="${withRequest(ACCOUNT_PATHS.reset, form)}">Forgot your password?</a></p>216-<p>New here? <a href="${withRequest("/signup", form)}">Sign up</a>.</p>`261+<div class="submit"><button type="submit">Sign in</button></div>262+${offers.google ? `<button type="submit" class="link" formaction="${GOOGLE_PATHS.link}">${LINK_GOOGLE}</button>` : ""}263+</form>`,264+ "form",265+ {266+ ...homeOf(asker),267+ after: `New here? <a href="${withRequest("/signup", form)}">Create an account</a>`,268+ }269 );218-};270 271 export interface ProfileValues {272 readonly displayName?: string;273 readonly handle?: string;15 unmodified lines289 page(290 "Set up your profile",291 `<h1>Set up your profile</h1>292 ${askerParagraphs(asker)}242-<p>Google confirmed who you are. This Google account has not signed in here before: choose the handle and name people will know you by.</p>293+<p>Google confirmed who you are. Choose the handle and name people will know you by.</p>294 ${messageParagraph(message)}295 <form method="post" action="${GOOGLE_PATHS.handle}">296 ${hiddenFields(form)}297 ${DISPLAY_NAME_FIELD(values.displayName)}298 ${HANDLE_FIELD(values.handle)}248-<div class="actions"><button type="submit">Sign up</button></div>249-</form>250-<p>Have an account with a password? <a href="${escapeHtml(signInHref)}">Sign in with it</a> and choose "Sign in and link Google".</p>`299+<div class="submit"><button type="submit">Create account</button></div>300+</form>`,301+ "form",302+ {303+ ...homeOf(asker),304+ after: `Have an account with a password? <a href="${escapeHtml(signInHref)}">Sign in with it</a>, then choose "${LINK_GOOGLE}".`,305+ }306 );307 308 export interface SignUpValues extends ProfileValues {309 readonly email?: string;1 unmodified line311 312 export const signUpPage = (313 asker: Asker,314 form: PendingForm,315+ offers: Offers,316 signInHref: string,317 values: SignUpValues,318 message?: string319 ) =>320 page(265- "Sign up",266- `<h1>Sign up</h1>321+ "Create your account",322+ `<h1>Create your account</h1>323 ${askerParagraphs(asker, "who and what")}324+${googleStart(offers, form)}325 ${messageParagraph(message)}326 <form method="post" action="/signup">327 ${hiddenFields(form)}328 <label>Email <input type="email" name="email" autocomplete="email" autocapitalize="none" spellcheck="false" maxlength="254" required${valueOf(values.email)}></label>329 ${DISPLAY_NAME_FIELD(values.displayName)}330 ${HANDLE_FIELD(values.handle)}331 <label>Password, 12 to 256 characters <input type="password" name="password" autocomplete="new-password" minlength="12" maxlength="256" required></label>275-<div class="actions"><button type="submit">Sign up</button></div>332+<div class="submit"><button type="submit">Create account</button></div>333 </form>277-<p>We mail a code to the address, to check it is yours.</p>278-<p>Have an account? <a href="${escapeHtml(signInHref)}">Sign in</a>.</p>`334+<p class="small muted aside">We mail a code to the address, to check it is yours.</p>`,335+ "form",336+ {337+ ...homeOf(asker),338+ after: `Have an account? <a href="${escapeHtml(signInHref)}">Sign in</a>`,339+ }340 );341 342 export interface CodeForm {343 readonly action: string;11 unmodified lines355 message?: string356 ) =>357 page(358 "Enter the code",298- `<h1>Enter the code we mailed you</h1>359+ `<h1>Check your email</h1>360 ${askerParagraphs(asker)}361 <p>${escapeHtml(code.intro)} It works for 10 minutes.</p>362 ${messageParagraph(message)}363 <form method="post" action="${code.action}">364 ${hiddenFields(form)}365 <label>Code <input name="code" inputmode="numeric" autocomplete="one-time-code" pattern="[0-9 -]*" maxlength="12" required></label>366 ${code.newPassword ? `<label>New password, 12 to 256 characters <input type="password" name="password" autocomplete="new-password" minlength="12" maxlength="256" required></label>` : ""}306-<div class="actions"><button type="submit">Continue</button></div>307-</form>308-<p>No mail? Check your spam folder, or <a href="${escapeHtml(code.startOverHref)}">start again</a>.</p>`367+<div class="submit"><button type="submit">Continue</button></div>368+</form>`,369+ "form",370+ {371+ ...homeOf(asker),372+ after: `No mail? Check your spam folder, or <a href="${escapeHtml(code.startOverHref)}">start again</a>.`,373+ }374 );375 376 export const addEmailPage = (377 asker: Asker,10 unmodified lines388 ${messageParagraph(message)}389 <form method="post" action="${ACCOUNT_PATHS.addEmail}">390 ${hiddenFields(form)}391 <label>Email <input type="email" name="email" autocomplete="email" autocapitalize="none" spellcheck="false" maxlength="254" required${valueOf(value)}></label>327-<div class="actions"><button type="submit">Send the code</button></div>328-</form>329-<p><a href="${escapeHtml(startOverHref)}">Sign in as someone else</a></p>`392+<div class="submit"><button type="submit">Send the code</button></div>393+</form>`,394+ "form",395+ {396+ ...homeOf(asker),397+ after: `<a href="${escapeHtml(startOverHref)}">Sign in as someone else</a>`,398+ }399 );400 401 export const resetPage = (402 asker: Asker,10 unmodified lines413 ${messageParagraph(message)}414 <form method="post" action="${ACCOUNT_PATHS.reset}">415 ${hiddenFields(form)}416 <label>Email <input type="email" name="email" autocomplete="email" autocapitalize="none" spellcheck="false" maxlength="254" required${valueOf(value)}></label>348-<div class="actions"><button type="submit">Send the code</button></div>349-</form>350-<p>Remembered it? <a href="${escapeHtml(signInHref)}">Sign in</a>.</p>`417+<div class="submit"><button type="submit">Send the code</button></div>418+</form>`,419+ "form",420+ {421+ ...homeOf(asker),422+ after: `Remembered it? <a href="${escapeHtml(signInHref)}">Sign in</a>`,423+ }424 );425 353-export const problemPage = (message: string) =>426+export const problemPage = (message: string, home = "/") =>427 page(428 "Sign-in problem",429 `<h1>Signing in did not work</h1>430 <p role="alert">${escapeHtml(message)}</p>358-<p><a href="/">What this host serves</a></p>`431+<p><a href="${escapeHtml(home)}">Back to ${escapeHtml(Brand.name)}</a></p>`,432+ "form",433+ { home }434 );modified:apps/platform/src/auth/provider.ts+5 added
18 unmodified lines19202122232425262794 unmodified lines12212312412512612712812913013113213330 unmodified lines18 unmodified lines Authorization, AUTHORIZATION_SERVER_PATHS, HeldHandles, SIGN_IN_PATHS, SignInHome, SignInKeys, SignInOffers, signInRoutes,} from "./sign-in.ts";94 unmodified lines google: Option.as(googleClientOf(config), GOOGLE_ACCOUNTS), }) ), Layer.succeed( SignInHome, SignInHome.of({ webUrl: Option.fromUndefinedOr(config.PUBLIC_WEB_URL) }) ), Layer.succeed( SignInKeys, SignInKeys.of({ cookieKey: config.COOKIE_KEY, pepper: config.PASSWORD_PEPPER,30 unmodified linesmodified:apps/platform/src/auth/sign-in.ts+38 added-7 removed
30 unmodified lines31 import { SignInAttempts } from "./attempts.ts";32 import { CLI_CLIENT_PATH, cliClientMetadata } from "./cli-client.ts";33 import { codeMatches, codeTag, deadTag, freshCode } from "./codes.ts";34 import type { CodePurpose } from "./codes.ts";35+import { firstPartyOf } from "./first-party.ts";36 import { Mailer } from "./mailer.ts";37 import { OAuthStore } from "./oauth-store.ts";38 import {39 ACCOUNT_PATHS,34 unmodified lines74 SignInOffers,75 { readonly google: Option.Option<string> }76 >()("platform/SignInOffers") {}77 78+// The web's address, when the platform knows it: the wordmark links there, and its client is told apart from any other.79+export class SignInHome extends Context.Service<80+ SignInHome,81+ { readonly webUrl: Option.Option<string> }82+>()("platform/SignInHome") {}83+84 // Nobody signs up as a handle a named session holds, or an account would call as that person.85 export class HeldHandles extends Context.Service<86 HeldHandles,87 { readonly handles: readonly Handle[] }198 unmodified lines286 287 export const askerOf = (request: AuthRequest) =>288 Effect.gen(function* () {289 const api = yield* oauthApi;290+ const { origin } = yield* Authorization;291+ const { webUrl } = yield* SignInHome;292 293 const consent = yield* provider(() =>294 api.describeConsent(forProvider(request))295 );296 297 const asker: Asker = {298 clientDomain: consent.clientDomain,299 clientName: consent.clientName,300+ firstParty: firstPartyOf(request.clientId, origin, webUrl),301+ home: Option.getOrElse(webUrl, () => "/"),302 redirectHost: consent.redirectHost,303 redirectIsLoopback: consent.redirectIsLoopback,304 };305 548 unmodified lines854 855 const pending = yield* openState(cookieKey, sealed);856 857 const asker = yield* askerOf(pending.request);858+ const { google } = yield* SignInOffers;859 860 return htmlPage(861 signUpPage(862 asker,863 { csrf: pending.csrf, request: sealed },864+ { google: Option.isSome(google) },865 authorizeHref(pending.request),866 {}867 ),868 200,76 unmodified lines945 values: SignUpValues,946 status: number,947 message: string948 ) =>936- Effect.map(askerOf(request), (asker) =>937- htmlPage(938- signUpPage(asker, form, authorizeHref(request), values, message),949+ Effect.gen(function* () {950+ const asker = yield* askerOf(request);951+ const { google } = yield* SignInOffers;952+953+ return htmlPage(954+ signUpPage(955+ asker,956+ form,957+ { google: Option.isSome(google) },958+ authorizeHref(request),959+ values,960+ message961+ ),962 status,963 request.redirectUri941- )942- );964+ );965+ });966 967 const signUpCode = (request: AuthRequest, email: Email): CodeForm => ({968 action: ACCOUNT_PATHS.signUpVerify,969 intro: codeSentTo(email),349 unmodified lines1319 return HttpServerResponse.fromWeb(response);1320 });1321 1322 export const failedPage = (failed: SignInFailed) =>1300- Effect.succeed(1323+ Effect.map(Effect.service(SignInHome), ({ webUrl }) =>1324 failed.redirectTo === undefined1302- ? htmlPage(problemPage(failed.reason), 400)1325+ ? htmlPage(1326+ problemPage(1327+ failed.reason,1328+ Option.getOrElse(webUrl, () => "/")1329+ ),1330+ 4001331+ )1332 : HttpServerResponse.redirect(failed.redirectTo, {1333 headers: { "cache-control": "no-store" },1334 status: 302,1335 })4 unmodified lines1340 | HeldHandles1341 | Mailer1342 | OAuthStore1343 | SignInAttempts1344+ | SignInHome1345 | SignInKeys1346 | SignInOffers;1347 1348 export const signInRoutes = HttpRouter.use((router) =>2 unmodified lines1351 Context.add(HeldHandles, yield* HeldHandles),1352 Context.add(Mailer, yield* Mailer),1353 Context.add(OAuthStore, yield* OAuthStore),1354 Context.add(SignInAttempts, yield* SignInAttempts),1355+ Context.add(SignInHome, yield* SignInHome),1356 Context.add(SignInKeys, yield* SignInKeys),1357 Context.add(SignInOffers, yield* SignInOffers)1358 );1359 31 unmodified linesadded:apps/platform/test/first-party.test.ts+40 added
12345678910111213141516171819202122232425262728293031323334353637383940import { describe, expect, it } from "@effect/vitest";import { Option } from "effect";
import { firstPartyOf } from "../src/auth/first-party.ts";
const origin = "https://platform.test";
const web = Option.some("https://web.test");
describe("the platform's own clients", () => { it("are the CLI's id on this platform and the web's id on its own address", () => { expect([ firstPartyOf(`${origin}/oauth/cli`, origin, web), firstPartyOf("https://web.test/auth/client", origin, web), firstPartyOf( "https://web.test/auth/client", origin, Option.some("https://web.test/") ), ]).toStrictEqual(["cli", "web", "web"]); });
it("are never told by a client's own name or path on another address", () => { expect([ firstPartyOf("https://other.test/oauth/cli", origin, web), firstPartyOf("https://other.test/auth/client", origin, web), firstPartyOf("https://web.test.other.test/auth/client", origin, web), firstPartyOf(`${origin}/auth/client`, origin, web), firstPartyOf("https://web.test/auth/client", origin, Option.none()), firstPartyOf("https://web.test/auth/client", origin, Option.some("::")), ]).toStrictEqual([ undefined, undefined, undefined, undefined, undefined, undefined, ]); });});modified:apps/platform/test/google.test.ts+1 added-1 removed
600 unmodified lines601 });602 603 describe("Google sign-in, with a Google OAuth client", () => {604 it.live(605- 'offers "Continue with Google" and "Sign in and link Google" on the sign-in page',605+ 'offers "Continue with Google" and "Sign in and link your Google account" on the sign-in page',606 () =>607 Effect.gen(function* () {608 const world = yield* googleWorld();609 713 unmodified linesmodified:apps/platform/test/oauth.test.ts+37 added-1 removed
529 unmodified lines530 "text/html; charset=utf-8",531 `${CSP} http://127.0.0.1:${port}`,532 "DENY",533 ]);534- expect(page.html).toContain(`${Brand.name} CLI`);534+ expect(page.html).toContain(535+ "This finishes signing in the CLI on this computer."536+ );537+ expect(page.html).not.toContain("What it can do");538 expect(page.html).not.toMatch(/<script|<link|<img|src=|url\(|@import/u);539 expect(Option.isSome(formOf(page.response, page.html))).toBeTruthy();540 })541 );542 543 it.live(544+ "asks a client from another address for consent, though it names itself as the platform's CLI",545+ () =>546+ Effect.gen(function* () {547+ const world = yield* signInWorld();548+ const url = authorizeUrl();549+550+ // The same metadata document, served at another origin: its name is ours, its id is not.551+ url.searchParams.set("client_id", "https://other.test/oauth/cli");552+553+ const page = yield* world554+ .fetch(new Request(url))555+ .pipe(Effect.flatMap(read));556+557+ expect({558+ asks: new RegExp(559+ `<strong>${Brand.name} CLI</strong>[^<]* wants to act as you\\.`,560+ "u"561+ ).test(page.html),562+ lists: page.html.includes("<summary>What it can do</summary>"),563+ ours: page.html.includes("This finishes signing in the CLI"),564+ status: page.response.status,565+ warns: page.html.includes("Warning</strong>"),566+ }).toStrictEqual({567+ asks: true,568+ lists: true,569+ ours: false,570+ status: 200,571+ warns: true,572+ });573+ })574+ );575+576+ it.live(577 "lets the code go back to an IPv6 loopback, which no CSP host can name",578 () =>579 Effect.gen(function* () {580 const world = yield* signInWorld();940 unmodified linesmodified:apps/platform/test/pages.test.ts+109 added-8 removed
31 unmodified lines32 redirectHost: "127.0.0.1:53682",33 redirectIsLoopback: true,34 };35 36+const ourWeb: Asker = {37+ clientName: `${Brand.name} web`,38+ firstParty: "web",39+ home: "https://web.example",40+ redirectHost: "web.example",41+ redirectIsLoopback: false,42+};43+44+const ourCli: Asker = {45+ clientName: `${Brand.name} CLI`,46+ firstParty: "cli",47+ redirectHost: "127.0.0.1:53682",48+ redirectIsLoopback: true,49+};50+51 const form: PendingForm = { csrf: "csrf-token", request: "sealed-request" };52 53 const home = Effect.gen(function* () {54 const response = yield* homeResponse(81 unmodified lines136 ),137 "sign-up": signUpPage(138 local,139 form,140+ { google: true },141 "/authorize?x=1",142 { displayName: "Alice", email: "alice@mail.example", handle: "alice" },143 "A password is 12 to 256 characters."144 ),290 unmodified lines435 436 const EDGES = /^(?:border-(?:top|right|bottom|left)|box-shadow|outline)/u;437 438 describe.each(SIGN_IN_PAGES)("$name, in the focus look", ({ html }) => {423- it("shows the wordmark as text, then one card, and no navigation", () => {424- const wordmark = html.indexOf(`<p class="wordmark">${Brand.name}</p>`);439+ it("shows the wordmark as a link home, then one card, and no navigation", () => {440+ const wordmark = html.indexOf(441+ `<a class="wordmark" href="/">${Brand.name}</a>`442+ );443+444 const card = html.indexOf('class="card"');445 446 expect(wordmark).toBeGreaterThan(html.indexOf("<body"));447 expect(card).toBeGreaterThan(wordmark);67 unmodified lines515 it("names the client and lists what it may do as you", () => {516 const consent = consentOf(PAGES["sign-in"]);517 518 expect(consent).toContain(500- "<strong>Claude</strong> (published by claude.ai)"519+ "<strong>Claude</strong> (claude.ai) wants to act as you."520 );521 expect(consent.match(/<li>/gu)).toHaveLength(4);522 expect(consent).toContain("<li>Claim, release and answer asks");523 expect(consent).toContain("It never sees your password.");1 unmodified line525 "finish answers, land changes, vouch for or denounce people"526 );527 });528 529+ it("keeps what the client may do behind a disclosure, the who and where in view", () => {530+ expect(consentOf(PAGES["sign-in"])).toMatch(531+ /wants to act as you\.<\/p>\s*<p>Access goes to <strong>claude\.ai<\/strong>\.<\/p>[\s\S]*<details>\s*<summary>What it can do<\/summary>\s*<ul class="may">/u532+ );533+ });534+535 it("lists the same on the sign-up page, where a newcomer allows it", () => {536 expect(mayListOf(PAGES["sign-up"])).toBeDefined();537 expect(mayListOf(PAGES["sign-up"])).toBe(mayListOf(PAGES["sign-in"]));538 });17 unmodified lines556 redirectIsLoopback: true,557 };558 559 const named = [535- signUpPage(hostile, form, "/authorize", {}),560+ signUpPage(hostile, form, { google: true }, "/authorize", {}),561 profilePage(hostile, form, "/authorize", {}),562 addEmailPage(hostile, form, "/authorize"),563 resetPage(hostile, form, "/authorize"),564 codePage(hostile, form, {13 unmodified lines578 });579 580 it("says who asks and where access goes before Google and the form", () => {581 const html = PAGES["sign-in"];557- const asks = html.indexOf("asks to act as you");582+ const asks = html.indexOf("wants to act as you");583 const goes = html.indexOf("Access goes to");584 const google = html.indexOf("Continue with Google");585 const formAt = html.indexOf("<form");586 41 unmodified lines628 expect(PAGES["sign-in"]).toMatch(629 /<p class="error" role="alert">The email, handle or password is wrong\.<\/p>/u630 );631 expect(PAGES["the problem page"]).not.toContain('class="error"');607- expect(PAGES["the problem page"]).toMatch(/<a href="\/">/u);632+ expect(PAGES["the problem page"]).toMatch(633+ new RegExp(`<a href="/">Back to ${Brand.name}</a>`, "u")634+ );635 });636 });637 638+describe("the sign-in page, for one of the platform's own clients", () => {639+ it("asks the web's reader nothing about consent", () => {640+ const html = signInPage(ourWeb, form, { google: true });641+642+ expect(consentOf(html)).toBe("");643+ expect(html).not.toContain("What it can do");644+ expect(html).not.toContain("act as you");645+ expect(html).toContain(`<h1>Sign in to ${Brand.name}</h1>`);646+ });647+648+ it("tells the CLI's reader in one line what finishing does, with no warning or list", () => {649+ const html = signInPage(ourCli, form, { google: true });650+651+ expect(consentOf(html)).toBe("");652+ expect(html).toContain(653+ `This finishes signing in the CLI on this computer. Continue only if you just ran <code>${Brand.cli} login</code>.`654+ );655+ expect(html).not.toContain("Warning");656+ expect(html).not.toContain("What it can do");657+ });658+659+ it("links the wordmark and the problem page to the web's home when it is known", () => {660+ expect(signInPage(ourWeb, form, { google: false })).toContain(661+ `<a class="wordmark" href="https://web.example">${Brand.name}</a>`662+ );663+ expect(problemPage("Expired.", "https://web.example")).toContain(664+ `<a href="https://web.example">Back to ${Brand.name}</a>`665+ );666+ });667+668+ it("treats every page's asker the same way", () => {669+ const pages = [670+ signUpPage(ourWeb, form, { google: false }, "/authorize", {}),671+ profilePage(ourWeb, form, "/authorize", {}),672+ addEmailPage(ourWeb, form, "/authorize"),673+ resetPage(ourWeb, form, "/authorize"),674+ ];675+676+ for (const html of pages) {677+ expect(consentOf(html)).toBe("");678+ expect(html).not.toContain("act as you");679+ }680+ });681+});682+683 describe("a sign-in form shown again", () => {684 it("escapes every value the person typed", () => {685 const typed = `"><script>alert(1)</script>`;686 687 const pages = [616- signUpPage(local, form, "/authorize", {688+ signUpPage(local, form, { google: false }, "/authorize", {689 displayName: typed,690 email: typed,691 handle: typed,692 }),14 unmodified lines707 });708 709 it("never fills in a password", () => {710 expect(639- signUpPage(local, form, "/authorize", { email: "alice@mail.example" })711+ signUpPage(local, form, { google: false }, "/authorize", {712+ email: "alice@mail.example",713+ })714 ).toMatch(/<input type="password" name="password" [^>]*required>/u);715 });716 });717 6 unmodified lines724 );725 expect(html).toContain('href="/signup?request=sealed-request"');726 expect(html).toContain("Email or handle");727 });728+729+ it("offers Google first, then the password, with linking Google as a quiet choice under Sign in", () => {730+ const html = signInPage(claude, form, { google: true });731+ const google = html.indexOf("Continue with Google");732+ const or = html.indexOf('class="or');733+ const formAt = html.indexOf("<form");734+ const signIn = html.indexOf('<button type="submit">Sign in</button>');735+736+ const link = html.indexOf(737+ '<button type="submit" class="link" formaction="/oauth/google/link">Sign in and link your Google account</button>'738+ );739+740+ expect(or).toBeGreaterThan(google);741+ expect(formAt).toBeGreaterThan(or);742+ expect(signIn).toBeGreaterThan(formAt);743+ expect(link).toBeGreaterThan(signIn);744+ expect(signInPage(claude, form, { google: false })).not.toMatch(745+ /Continue with Google|formaction=/u746+ );747+ });748+749+ it("offers Google on the sign-up page too, when the platform has it", () => {750+ expect(PAGES["sign-up"]).toContain("Continue with Google");751+ expect(752+ signUpPage(local, form, { google: false }, "/authorize", {})753+ ).not.toContain("Continue with Google");754+ });755 });modified:DESIGN.md+1 added-1 removed
402 unmodified lines403 | `focus` | sign-in, MCP consent, new project, new proposal | a centred, ruled card, `--container-focus` (400 px) | the wordmark only, in the framed bar | none |404 405 A shell sets its gutter once, on its frame, and every bar and page inside it reads it: 16 px on a phone, 20 px from `tablet`, and from `shell` (1120 px) `--gutter-site` in the site, the docs and a focused page, or `--gutter-project` in a project.406 407-**Rails.** The site, the docs and a focused page are ruled: from `tablet`, the container stands `--frame-inset` (24 px) in from the viewport and carries a hairline down each edge, the page's full height (`RAILS` in `app-shell.tsx`), and the top bar is a box between them, `--frame-gap` (16 px) under the viewport's top, with a hairline over and under it. Everything inside (the frame, a section's rule, the footer's rule) runs rail to rail, and the gutter sits inside the rails, so content stands 32 px in from them. Below `tablet` the rails and the gap go: the bar keeps its rule underneath, and the page takes the phone's 16 px gutter. The top bar's height stays `--top-bar`, borders included, so what sticks under it reads `--stick-bar` unchanged, and when the bar sticks it sits flush at the top. The platform's own pages draw the same frame at the card's width, in their inline style. A project has no rails.407+**Rails.** The site, the docs and a focused page are ruled: from `tablet`, the container stands `--frame-inset` (24 px) in from the viewport and carries a hairline down each edge, the page's full height (`RAILS` in `app-shell.tsx`), and the top bar is a box between them, `--frame-gap` (16 px) under the viewport's top, with a hairline over and under it. Everything inside (the frame, a section's rule, the footer's rule) runs rail to rail, and the gutter sits inside the rails, so content stands 32 px in from them. Below `tablet` the rails and the gap go: the bar keeps its rule underneath, and the page takes the phone's 16 px gutter. The top bar's height stays `--top-bar`, borders included, so what sticks under it reads `--stick-bar` unchanged, and when the bar sticks it sits flush at the top. The platform's sign-in pages are not ruled: at the card's width, rails and a boxed bar read as boxes in boxes, so they draw one centred column, the wordmark (linking the web's home) over the card and what leads elsewhere under it, the card a bordered surface from `tablet` and the page itself on a phone. The platform's own clients (the web and the CLI, told by their client ids) are asked no consent there; any other client's name, address and grant are said above the form, the grant behind a disclosure. A project has no rails.408 409 From `columns` (1100 px, `--breakpoint-columns`) a side column stands beside its main column; below it, every side column stacks under its main column. From `nav` (900 px, `--breakpoint-nav`) the top bar shows its links; below it they fold into a menu. Phone width (360 px) is a first-class layout: nothing scrolls sideways.410 411 **The four rules (ADR 0041):**229 unmodified lines