{"draft":null,"from":16,"to":17,"files":[{"path":"client/src/box.ts","added":13,"removed":16,"diff":"--- a/client/src/box.ts\n+++ b/client/src/box.ts\n@@ -8,10 +8,11 @@\n // ever sent to the server that issued it, on /box/ routes.\n \n import { createHash } from \"node:crypto\";\n-import { chmodSync, mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\n+import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\n import { homedir, hostname } from \"node:os\";\n-import { join } from \"node:path\";\n+import { dirname, join } from \"node:path\";\n import { UsageError } from \"./args.ts\";\n+import { homeFile, homeWritePath, OLD_STATE_DIR } from \"./state-dir.ts\";\n \n /** What the person who approved the code allowed: each project with the highest role its agents get there, and how many agents. */\n export interface Grant {\n@@ -35,14 +36,13 @@\n \t}\n }\n \n-function boxPath(server: string, home: string): string {\n-\tconst name = createHash(\"sha256\").update(originOf(server)).digest(\"hex\").slice(0, 16);\n-\treturn join(home, \".avcs\", \"boxes\", `${name}.json`);\n+function boxFile(server: string): string {\n+\treturn `${createHash(\"sha256\").update(originOf(server)).digest(\"hex\").slice(0, 16)}.json`;\n }\n \n export function readBox(server: string, home = homedir()): BoxRecord | undefined {\n \ttry {\n-\t\tconst raw = JSON.parse(readFileSync(boxPath(server, home), \"utf8\")) as Partial<BoxRecord>;\n+\t\tconst raw = JSON.parse(readFileSync(homeFile(home, \"boxes\", boxFile(server)), \"utf8\")) as Partial<BoxRecord>;\n \t\tif (\n \t\t\ttypeof raw.server !== \"string\" ||\n \t\t\toriginOf(raw.server) !== originOf(server) ||\n@@ -59,8 +59,8 @@\n }\n \n export function writeBox(record: BoxRecord, home = homedir()): void {\n-\tconst path = boxPath(record.server, home);\n-\tmkdirSync(join(home, \".avcs\", \"boxes\"), { recursive: true });\n+\tconst path = homeWritePath(home, \"boxes\", boxFile(record.server));\n+\tmkdirSync(dirname(path), { recursive: true });\n \twriteFileSync(path, `${JSON.stringify(record)}\\n`, { mode: 0o600 });\n \ttry {\n \t\tchmodSync(path, 0o600);\n@@ -69,15 +69,12 @@\n \t}\n }\n \n+/** Logout ends the sign-in everywhere on this machine: the credential under ~/.abso and any older copy under ~/.avcs. */\n export function forgetBox(server: string, home = homedir()): boolean {\n-\tconst path = boxPath(server, home);\n-\ttry {\n-\t\treadFileSync(path);\n-\t} catch {\n-\t\treturn false;\n-\t}\n-\trmSync(path, { force: true });\n-\treturn true;\n+\tconst paths = [homeWritePath(home, \"boxes\", boxFile(server)), join(home, OLD_STATE_DIR, \"boxes\", boxFile(server))];\n+\tconst had = paths.filter((path) => existsSync(path));\n+\tfor (const path of had) rmSync(path, { force: true });\n+\treturn had.length > 0;\n }\n \n /** Error text with the credential (and anything shaped like a key) taken out. */"}],"unmatched":[]}