{"draft":null,"from":302,"to":318,"files":[{"path":"client/test/local.test.ts","added":8,"removed":3,"diff":"--- a/client/test/local.test.ts\n+++ b/client/test/local.test.ts\n@@ -4,7 +4,7 @@\n \n import assert from \"node:assert/strict\";\n import { spawnSync } from \"node:child_process\";\n-import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\n+import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\n import { tmpdir } from \"node:os\";\n import { join } from \"node:path\";\n import { after, before, describe, it } from \"node:test\";\n@@ -145,9 +145,14 @@\n \tit(\"a project's name can't start with a dot, so its folder stays inside the store\", async () => {\n \t\tconst dir = temp(\"dots\");\n \t\twriteFileSync(join(dir, \"a.txt\"), \"x\\n\");\n-\t\tconst r = await run(dir, \"init\", \"--local\", \"--project\", \"..\", \"--agent\", \"a\");\n-\t\tassert.notEqual(r.exit, 0);\n+\t\tfor (const name of [\"..\", \".hidden\"]) {\n+\t\t\tconst r = await run(dir, \"init\", \"--local\", \"--project\", name, \"--agent\", \"a\");\n+\t\t\tassert.equal(r.exit, 1, r.out + r.err);\n+\t\t\t// The name rule says why, before any call is made (a \"..\" would collapse the call's path).\n+\t\t\tassert.match(r.err, /project names are letters, digits, dot, dash and underscore/);\n+\t\t}\n \t\tassert.ok(!existsSync(join(store, \"..\", \"project.sqlite\")));\n+\t\tassert.deepEqual(readdirSync(dir), [\"a.txt\"], \"init left nothing behind\");\n \t});\n });\n "},{"path":"client/test/web-session.test.ts","added":43,"removed":8,"diff":"--- a/client/test/web-session.test.ts\n+++ b/client/test/web-session.test.ts\n@@ -5,20 +5,53 @@\n import { tmpdir } from \"node:os\";\n import { join } from \"node:path\";\n import { test } from \"node:test\";\n-import { handoffText, patFromFile, siteFor, webHandoff } from \"../src/web-session.ts\";\n+import { handoffText, patFromFile, siteFor, webHandoff, webLogin } from \"../src/web-session.ts\";\n \n const SITE = \"https://abso-website-staging.chrisazy.workers.dev\";\n+const STAGING = \"https://abso-staging.chrisazy.workers.dev\";\n const BOX = `abso_bx_${\"C\".repeat(43)}`;\n+const PAT = `abso_pat_${\"A\".repeat(40)}`;\n const NOW = Date.UTC(2026, 9, 16, 9, 0, 0);\n \n-test(\"the website is the staging one beside the server, or --site; prod has none, since agents never sign in there\", () => {\n-\tassert.equal(siteFor(\"https://abso-staging.chrisazy.workers.dev\"), SITE);\n-\tassert.equal(siteFor(\"https://avcs-staging.chrisazy.workers.dev/\"), SITE);\n-\tassert.throws(() => siteFor(\"https://api.abso.dev\"), /for staging.*never sign in to the website on prod/);\n-\tassert.equal(siteFor(\"https://api.abso.dev\", \"http://localhost:8871/x\"), \"http://localhost:8871\");\n-\tassert.throws(() => siteFor(\"https://api.abso.dev\", \"http://elsewhere.example\"), /https/);\n+test(\"the credential goes only to the staging website beside the folder's staging server (Security condition 6)\", () => {\n+\tassert.equal(siteFor(STAGING, undefined, \"box\"), SITE);\n+\tassert.equal(siteFor(\"https://avcs-staging.chrisazy.workers.dev/\", undefined, \"pat\"), SITE);\n+\t// A server that isn't staging is refused, prod included, whatever is asked.\n+\tassert.throws(\n+\t\t() => siteFor(\"https://api.abso.dev\", undefined, \"box\"),\n+\t\t/for staging.*never sign in to the website on prod/,\n+\t);\n+\tassert.throws(() => siteFor(\"https://api.abso.dev\", \"http://localhost:8871\", \"pat\"), /for staging/);\n+\t// A box's sign-in takes no --site, not even the staging website's own address.\n+\tassert.throws(() => siteFor(STAGING, SITE, \"box\"), /isn't taken with a box's sign-in/);\n+\tassert.throws(() => siteFor(STAGING, \"http://localhost:8871\", \"box\"), /isn't taken with a box's sign-in/);\n+\t// A PAT may name this machine over http, and nothing else.\n+\tassert.equal(siteFor(STAGING, \"http://localhost:8871/x\", \"pat\"), \"http://localhost:8871\");\n+\tassert.equal(siteFor(STAGING, \"http://127.0.0.1:8871\", \"pat\"), \"http://127.0.0.1:8871\");\n+\tfor (const elsewhere of [\"https://anywhere.example\", SITE, \"https://localhost:8871\", \"not a url\"])\n+\t\tassert.throws(() => siteFor(STAGING, elsewhere, \"pat\"), /names this machine only/, elsewhere);\n });\n \n+test(\"a refused handoff reads no credential and sends no request\", async () => {\n+\tconst sent: string[] = [];\n+\tconst fetcher = (async (url: string) => (sent.push(url), Response.json({}))) as unknown as typeof fetch;\n+\tlet read = 0;\n+\tconst credential = () => (read++, BOX);\n+\tfor (const asked of [\n+\t\t{ server: \"https://api.abso.dev\", site: undefined, kind: \"box\" as const },\n+\t\t{ server: STAGING, site: \"https://anywhere.example\", kind: \"box\" as const },\n+\t\t{ server: STAGING, site: SITE, kind: \"box\" as const },\n+\t\t{ server: \"https://api.abso.dev\", site: \"http://localhost:8871\", kind: \"pat\" as const },\n+\t\t{ server: STAGING, site: \"https://anywhere.example\", kind: \"pat\" as const },\n+\t])\n+\t\tawait assert.rejects(webLogin({ ...asked, credential, fetcher }), /Nothing was sent/, JSON.stringify(asked));\n+\tassert.deepEqual(sent, []);\n+\tassert.equal(read, 0);\n+\t// Allowed, it goes to the staging website only.\n+\tawait webLogin({ server: STAGING, site: undefined, kind: \"pat\", credential: () => PAT, fetcher }).catch(() => {});\n+\tassert.deepEqual(sent, [`${SITE}/login/handoff`]);\n+});\n+\n test(\"the credential goes in Authorization only, and the answer is the one link and who it signs in as\", async () => {\n \tconst seen: { url: string; authorization: string | null; body: unknown }[] = [];\n \tconst fetcher = (async (url: string, init: RequestInit) => {\n@@ -33,9 +66,11 @@\n \t}) as typeof fetch;\n \tconst h = await webHandoff(SITE, BOX, fetcher);\n \tassert.deepEqual(seen, [{ url: `${SITE}/login/handoff`, authorization: `Bearer ${BOX}`, body: null }]);\n-\tconst text = handoffText(h, SITE, NOW);\n+\tconst text = handoffText(h, SITE, true, NOW);\n \tassert.match(text, /within 60 seconds/);\n \tassert.match(text, /as christopher, until 2026-10-16T21:00:00.000Z, and works once/);\n+\tassert.match(text, /only to the projects this box was granted, at most as a writer/);\n+\tassert.match(handoffText(h, SITE, false, NOW), /It reaches at most as a writer:/);\n \tassert.match(text, /\\/login\\/handoff#t{50}$/);\n \tassert.doesNotMatch(text + JSON.stringify(h), /abso_bx_/);\n });"}],"unmatched":[]}