{"draft":null,"from":5,"to":318,"files":[{"path":"client/src/key-admin.ts","added":15,"removed":9,"diff":"--- a/client/src/key-admin.ts\n+++ b/client/src/key-admin.ts\n@@ -3,9 +3,10 @@\n \n import { readFileSync } from \"node:fs\";\n import { homedir } from \"node:os\";\n-import { join } from \"node:path\";\n import { UsageError } from \"./args.ts\";\n import type { Config } from \"./config.ts\";\n+import { fromEnv } from \"./env-names.ts\";\n+import { homeFile } from \"./state-dir.ts\";\n \n function originOf(server: string): string {\n \ttry {\n@@ -15,7 +16,7 @@\n \t}\n }\n \n-/** The admin token goes only to a server named in AVCS_ADMIN_SERVERS (comma-separated): none is built in. */\n+/** The admin token goes only to a server named in ABSO_ADMIN_SERVERS (comma-separated): none is built in. */\n export function adminGoesTo(server: string, extra = \"\"): boolean {\n \tconst allowed = [\n \t\t...extra\n@@ -28,15 +29,20 @@\n }\n \n export function adminToken(env: Readonly<Record<string, string | undefined>> = process.env): string {\n-\tconst fromEnv = env.AVCS_ADMIN_TOKEN?.trim();\n-\tif (fromEnv) return fromEnv;\n+\tconst fromVar = fromEnv(env, \"ADMIN_TOKEN\")?.trim();\n+\tif (fromVar) return fromVar;\n \ttry {\n-\t\tconst fromFile = readFileSync(join(homedir(), \".avcs\", \"admin-token\"), \"utf8\").trim();\n+\t\tconst fromFile = readFileSync(homeFile(homedir(), \"admin-token\"), \"utf8\").trim();\n \t\tif (fromFile) return fromFile;\n \t} catch {}\n-\tthrow new UsageError(\"abso key needs the admin token in AVCS_ADMIN_TOKEN or ~/.avcs/admin-token\");\n+\tthrow new UsageError(\"abso key needs the admin token in ABSO_ADMIN_TOKEN or ~/.abso/admin-token\");\n }\n \n+/** What an admin command says each time it uses the admin token, and where it came from. Never the token. */\n+export function adminTokenWords(env: Readonly<Record<string, string | undefined>> = process.env): string {\n+\treturn `Using the admin token, from ${fromEnv(env, \"ADMIN_TOKEN\")?.trim() ? \"ABSO_ADMIN_TOKEN\" : \"~/.abso/admin-token\"}.`;\n+}\n+\n function scrub(text: string, secrets: readonly string[]): string {\n \tlet out = text.replace(/abso_sk_[A-Za-z0-9_-]+/g, \"[redacted]\");\n \tfor (const secret of secrets) if (secret.length > 0) out = out.split(secret).join(\"[redacted]\");\n@@ -44,9 +50,9 @@\n }\n \n async function call(config: Config, admin: string, method: \"GET\" | \"POST\", path: string): Promise<unknown> {\n-\tif (!adminGoesTo(config.server, process.env.AVCS_ADMIN_SERVERS))\n+\tif (!adminGoesTo(config.server, fromEnv(process.env, \"ADMIN_SERVERS\")))\n \t\tthrow new UsageError(\n-\t\t\t`abso key will not send the admin token to ${config.server}; AVCS_ADMIN_SERVERS names the servers it may go to`,\n+\t\t\t`abso key will not send the admin token to ${config.server}; ABSO_ADMIN_SERVERS names the servers it may go to`,\n \t\t);\n \tconst secrets = [admin, config.token ?? \"\"].filter((s) => s.length > 0);\n \tlet response: Response;\n@@ -55,7 +61,7 @@\n \t\t\tmethod,\n \t\t\theaders: {\n \t\t\t\t...(config.token ? { authorization: `Bearer ${config.token}` } : {}),\n-\t\t\t\t\"x-avcs-admin\": admin,\n+\t\t\t\t\"x-abso-admin\": admin,\n \t\t\t},\n \t\t\tsignal: AbortSignal.timeout(30_000),\n \t\t});"}],"unmatched":[]}