Lines 4–10 at 318 (were 4–10 at 304)
55import assert from "node:assert/strict"; 66import { spawnSync } from "node:child_process"; 7−import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
7+import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; 88import { tmpdir } from "node:os"; 99import { join } from "node:path"; 1010import { after, before, describe, it } from "node:test"; Lines 145–158 at 318 (were 145–153 at 304)
145145 it("a project's name can't start with a dot, so its folder stays inside the store", async () => { 146146 const dir = temp("dots"); 147147 writeFileSync(join(dir, "a.txt"), "x\n"); 148− const r = await run(dir, "init", "--local", "--project", "..", "--agent", "a");
149− assert.notEqual(r.exit, 0);
148+ for (const name of ["..", ".hidden"]) { 149+ const r = await run(dir, "init", "--local", "--project", name, "--agent", "a"); 150+ assert.equal(r.exit, 1, r.out + r.err); 151+ // The name rule says why, before any call is made (a ".." would collapse the call's path). 152+ assert.match(r.err, /project names are letters, digits, dot, dash and underscore/); 150154 assert.ok(!existsSync(join(store, "..", "project.sqlite"))); 155+ assert.deepEqual(readdirSync(dir), ["a.txt"], "init left nothing behind"); Lines 5–57 at 318 (were 5–24 at 304)
55import { tmpdir } from "node:os"; 66import { join } from "node:path"; 77import { test } from "node:test"; 8−import { handoffText, patFromFile, siteFor, webHandoff } from "../src/web-session.ts";
8+import { handoffText, patFromFile, siteFor, webHandoff, webLogin } from "../src/web-session.ts"; 1010const SITE = "https://abso-website-staging.chrisazy.workers.dev"; 11+const STAGING = "https://abso-staging.chrisazy.workers.dev"; 1112const BOX = `abso_bx_${"C".repeat(43)}`; 13+const PAT = `abso_pat_${"A".repeat(40)}`; 1214const NOW = Date.UTC(2026, 9, 16, 9, 0, 0); 14−test("the website is the staging one beside the server, or --site; prod has none, since agents never sign in there", () => {
15− assert.equal(siteFor("https://abso-staging.chrisazy.workers.dev"), SITE);
16− assert.equal(siteFor("https://avcs-staging.chrisazy.workers.dev/"), SITE);
17− assert.throws(() => siteFor("https://api.abso.dev"), /for staging.*never sign in to the website on prod/);
18− assert.equal(siteFor("https://api.abso.dev", "http://localhost:8871/x"), "http://localhost:8871");
19− assert.throws(() => siteFor("https://api.abso.dev", "http://elsewhere.example"), /https/);
16+test("the credential goes only to the staging website beside the folder's staging server (Security condition 6)", () => { 17+ assert.equal(siteFor(STAGING, undefined, "box"), SITE); 18+ assert.equal(siteFor("https://avcs-staging.chrisazy.workers.dev/", undefined, "pat"), SITE); 19+ // A server that isn't staging is refused, prod included, whatever is asked. 21+ () => siteFor("https://api.abso.dev", undefined, "box"), 22+ /for staging.*never sign in to the website on prod/, 24+ assert.throws(() => siteFor("https://api.abso.dev", "http://localhost:8871", "pat"), /for staging/); 25+ // A box's sign-in takes no --site, not even the staging website's own address. 26+ assert.throws(() => siteFor(STAGING, SITE, "box"), /isn't taken with a box's sign-in/); 27+ assert.throws(() => siteFor(STAGING, "http://localhost:8871", "box"), /isn't taken with a box's sign-in/); 28+ // A PAT may name this machine over http, and nothing else. 29+ assert.equal(siteFor(STAGING, "http://localhost:8871/x", "pat"), "http://localhost:8871"); 30+ assert.equal(siteFor(STAGING, "http://127.0.0.1:8871", "pat"), "http://127.0.0.1:8871"); 31+ for (const elsewhere of ["https://anywhere.example", SITE, "https://localhost:8871", "not a url"]) 32+ assert.throws(() => siteFor(STAGING, elsewhere, "pat"), /names this machine only/, elsewhere); 35+test("a refused handoff reads no credential and sends no request", async () => { 36+ const sent: string[] = []; 37+ const fetcher = (async (url: string) => (sent.push(url), Response.json({}))) as unknown as typeof fetch; 39+ const credential = () => (read++, BOX); 40+ for (const asked of [ 41+ { server: "https://api.abso.dev", site: undefined, kind: "box" as const }, 42+ { server: STAGING, site: "https://anywhere.example", kind: "box" as const }, 43+ { server: STAGING, site: SITE, kind: "box" as const }, 44+ { server: "https://api.abso.dev", site: "http://localhost:8871", kind: "pat" as const }, 45+ { server: STAGING, site: "https://anywhere.example", kind: "pat" as const }, 47+ await assert.rejects(webLogin({ ...asked, credential, fetcher }), /Nothing was sent/, JSON.stringify(asked)); 48+ assert.deepEqual(sent, []); 49+ assert.equal(read, 0); 50+ // Allowed, it goes to the staging website only. 51+ await webLogin({ server: STAGING, site: undefined, kind: "pat", credential: () => PAT, fetcher }).catch(() => {}); 52+ assert.deepEqual(sent, [`${SITE}/login/handoff`]); 2255test("the credential goes in Authorization only, and the answer is the one link and who it signs in as", async () => { 2356 const seen: { url: string; authorization: string | null; body: unknown }[] = []; 2457 const fetcher = (async (url: string, init: RequestInit) => {