{"draft":null,"from":175,"to":318,"files":[{"path":"client/test/box.test.ts","added":133,"removed":0,"diff":"--- a/client/test/box.test.ts\n+++ b/client/test/box.test.ts\n@@ -9,6 +9,7 @@\n import { test } from \"node:test\";\n import { parseArgs } from \"../src/args.ts\";\n import {\n+\tboxCreateProject,\n \tboxPublic,\n \tboxText,\n \tforgetBox,\n@@ -419,3 +420,135 @@\n \t\t\"snow is this box's already: never minted again, which would replace its key\",\n \t);\n });\n+\n+test(\"abso init from a box (abso 663): one key for every try, waiting out a pending create; abso box says all projects\", async () => {\n+\tconst record = { server: SERVER, id: \"b_1\", credential: CREDENTIAL, grant, expiresAt: Date.now() + 86_400_000 };\n+\tconst seen: { path: string; key: string | null; auth: string | null; body: string }[] = [];\n+\tlet calls = 0;\n+\tconst fetcher = (async (url: string | URL | Request, init?: RequestInit) => {\n+\t\tconst headers = new Headers(init?.headers);\n+\t\tseen.push({\n+\t\t\tpath: new URL(String(url)).pathname,\n+\t\t\tkey: headers.get(\"idempotency-key\"),\n+\t\t\tauth: headers.get(\"authorization\"),\n+\t\t\tbody: String(init?.body),\n+\t\t});\n+\t\tcalls++;\n+\t\tconst body =\n+\t\t\tcalls < 3\n+\t\t\t\t? { operation: { id: \"op\", state: \"pending\" } }\n+\t\t\t\t: { project: \"made\", id: \"proj_1\", visibility: \"private\" };\n+\t\treturn new Response(JSON.stringify(body), { status: calls < 3 ? 202 : 200 });\n+\t}) as typeof fetch;\n+\tconst made = await boxCreateProject(\n+\t\trecord,\n+\t\t{ name: \"made\", files: [{ path: \"a.txt\", text: \"hi\\n\" }] },\n+\t\t\"33333333-3333-4333-8333-333333333333\",\n+\t\tfetcher,\n+\t\tasync () => {},\n+\t);\n+\tassert.equal(made.id, \"proj_1\");\n+\tassert.equal(seen.length, 3);\n+\tassert.ok(seen.every((s) => s.path === \"/box/projects\" && s.key === \"33333333-3333-4333-8333-333333333333\"));\n+\tassert.ok(seen.every((s) => s.auth === `Box ${CREDENTIAL}`));\n+\tassert.deepEqual(JSON.parse(seen[0]!.body), { name: \"made\", files: [{ path: \"a.txt\", text: \"hi\\n\" }] });\n+\tconst all = { ...record, grant: { projects: [], scopes: [{ kind: \"member-all\", role: \"writer\" }] } };\n+\tassert.match(\n+\t\tboxText(all, SERVER),\n+\t\t/Projects: all of yours, now and later \\(writer at most\\)\\. abso init makes a new one/,\n+\t);\n+});\n+\n+// abso 684: in an agent's folder, login asks a person in the project instead of relaying the code.\n+function askedOf(withdrawn: number[]): NonNullable<Parameters<typeof login>[1][\"ask\"]> {\n+\treturn async ({ device, user }) => {\n+\t\tassert.equal(device, started.device_code, \"the ask is made with this client's own device code\");\n+\t\tassert.equal(user, started.user_code);\n+\t\treturn {\n+\t\t\tproject: \"abso\",\n+\t\t\twho: \"the person who approved this agent's box\",\n+\t\t\tasks: [41],\n+\t\t\texpiresAt: Date.parse(\"2026-10-15T19:30:00Z\"),\n+\t\t\trole: \"writer\",\n+\t\t\twithdraw: async () => void withdrawn.push(41),\n+\t\t};\n+\t};\n+}\n+\n+test(\"an asked login says who was asked and until when, and doesn't lead with the code (abso 684)\", async () => {\n+\tconst said: string[] = [];\n+\tconst c = clock();\n+\tawait login(\n+\t\tSERVER,\n+\t\t{\n+\t\t\task: askedOf([]),\n+\t\t\tfetch: server(\n+\t\t\t\t[\n+\t\t\t\t\t[200, started],\n+\t\t\t\t\t[200, { box_id: \"b_test\", box_token: CREDENTIAL, expires_at: EXPIRES, grant: { projects: [] } }],\n+\t\t\t\t],\n+\t\t\t\t[],\n+\t\t\t),\n+\t\t\tsleep: c.sleep,\n+\t\t\tnow: c.now,\n+\t\t\tsay: (line) => said.push(line),\n+\t\t},\n+\t\thome(),\n+\t);\n+\tassert.match(\n+\t\tsaid[0]!,\n+\t\t/^Asked the person who approved this agent's box \\(ask 41 in abso\\) to sign this box in, as at most writer\\.$/,\n+\t);\n+\tassert.match(said[1]!, /^Waiting for their answer, until .* CT\\. To approve it yourself instead: /);\n+\tassert.doesNotMatch(said.join(\"\\n\"), /approve the code/);\n+});\n+\n+test(\"an asked login that's turned down says who turned it down (abso 684)\", async () => {\n+\tconst c = clock();\n+\tawait assert.rejects(\n+\t\tlogin(\n+\t\t\tSERVER,\n+\t\t\t{\n+\t\t\t\task: askedOf([]),\n+\t\t\t\tfetch: server(\n+\t\t\t\t\t[\n+\t\t\t\t\t\t[200, started],\n+\t\t\t\t\t\t[400, { error: \"access_denied\" }],\n+\t\t\t\t\t],\n+\t\t\t\t\t[],\n+\t\t\t\t),\n+\t\t\t\tsleep: c.sleep,\n+\t\t\t\tnow: c.now,\n+\t\t\t\tsay: () => {},\n+\t\t\t},\n+\t\t\thome(),\n+\t\t),\n+\t\t/the person who approved this agent's box turned this sign-in down/,\n+\t);\n+});\n+\n+test(\"an asked login that nobody answers withdraws its ask and grants nothing (abso 684)\", async () => {\n+\tconst withdrawn: number[] = [];\n+\tconst c = clock();\n+\tawait assert.rejects(\n+\t\tlogin(\n+\t\t\tSERVER,\n+\t\t\t{\n+\t\t\t\task: askedOf(withdrawn),\n+\t\t\t\tfetch: server(\n+\t\t\t\t\t[\n+\t\t\t\t\t\t[200, started],\n+\t\t\t\t\t\t[400, { error: \"expired_token\" }],\n+\t\t\t\t\t],\n+\t\t\t\t\t[],\n+\t\t\t\t),\n+\t\t\t\tsleep: c.sleep,\n+\t\t\t\tnow: c.now,\n+\t\t\t\tsay: () => {},\n+\t\t\t},\n+\t\t\thome(),\n+\t\t),\n+\t\t/nobody answered in time, so nothing was granted/,\n+\t);\n+\tassert.deepEqual(withdrawn, [41]);\n+});"}],"unmatched":[]}