{"draft":null,"from":33,"to":34,"files":[{"path":"client/src/box.ts","added":29,"removed":2,"diff":"--- a/client/src/box.ts\n+++ b/client/src/box.ts\n@@ -5,7 +5,8 @@\n //\n // The box credential lives in the user's config folder, one file per server,\n // never in a project folder. It is never printed, never an argument, and only\n-// ever sent to the server that issued it, on /box/ routes.\n+// ever sent to the server that issued it: on /box/ routes, and on the org reads,\n+// which answer as the person who approved the box.\n \n import { createHash } from \"node:crypto\";\n import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\n@@ -84,7 +85,7 @@\n \treturn out;\n }\n \n-interface Answer {\n+export interface Answer {\n \treadonly status: number;\n \treadonly body: Record<string, unknown>;\n }\n@@ -127,6 +128,32 @@\n \treturn { status: response.status, body: parsed };\n }\n \n+/**\n+ * A read that answers as the person who approved this box: the org reads (GET /orgs, /orgs/<name>). Answers the\n+ * status and body as they came, refusals included, so the caller can say what each means; never the credential.\n+ */\n+export async function boxGet(record: BoxRecord, path: string, fetcher: typeof fetch = fetch): Promise<Answer> {\n+\tconst secrets = [record.credential];\n+\tlet response: Response;\n+\ttry {\n+\t\tresponse = await fetcher(`${originOf(record.server)}${path}`, {\n+\t\t\theaders: { authorization: `Box ${record.credential}` },\n+\t\t\tsignal: AbortSignal.timeout(30_000),\n+\t\t});\n+\t} catch (err) {\n+\t\tthrow new UsageError(\n+\t\t\t`couldn't reach ${originOf(record.server)}: ${scrub(err instanceof Error ? err.message : String(err), secrets)}`,\n+\t\t);\n+\t}\n+\tconst text = await response.text();\n+\ttry {\n+\t\tconst body = JSON.parse(text) as unknown;\n+\t\tif (typeof body === \"object\" && body !== null && !Array.isArray(body))\n+\t\t\treturn { status: response.status, body: body as Record<string, unknown> };\n+\t} catch {}\n+\treturn { status: response.status, body: { error: scrub(text.slice(0, 300), secrets) } };\n+}\n+\n /** This machine's name, as the server takes a box's name: 1-64 letters, digits, '.', '_' or '-'. */\n function boxName(): string {\n \tconst name = hostname()"}],"unmatched":[]}