Lines 11–17 at 318 (were 11–16 at 269)
1111import { UsageError } from "./args.ts"; 1212import { type MachineServers, machineServers, TOKEN_SERVERS, tokenGoesTo, trustedList } from "./core.ts"; 1313import { fromEnv } from "./env-names.ts"; 14+import { isLocal, storeDir } from "./local-store.ts"; 1415import { homeFile, stateDir } from "./state-dir.ts"; 1617/** What .avcs/config.json holds. */ Lines 28–41 at 318 (were 27–36 at 269)
2728 * routes anyone can read and sends no credential. It has no agent; its config holds server, project and this. 2930 readonly visitor?: boolean; 31+ /** A local project's store (abso init --local --store), when it isn't the machine's own: ABSO_STORE or the OS data folder. */ 32+ readonly store?: string; 3235export interface Config extends Settings { 3336 readonly token?: string; 37+ /** For a local project (server "local"): the store folder its history is in, or undefined when there's none to use. */ 38+ readonly localStore?: string; 3641export function configPath(root: string): string { Lines 56–62 at 318 (were 51–57 at 269)
5156export function readConfig( 5358 env: Readonly<Record<string, string | undefined>> = process.env, 54− tokenFileOk = true,
5661 const raw = JSON.parse(readFileSync(configPath(root), "utf8")) as Partial<Settings>; 5762 if (raw.visitor === true) { Lines 69–83 at 318 (were 64–74 at 269)
6469 for (const key of ["server", "project", "agent"] as const) { 6570 if (typeof raw[key] !== "string" || raw[key] === "") throw new Error(`${configPath(root)} has no "${key}"`); 67− const token = tokenFor(raw.server!, env, root, tokenFileOk);
72+ // A local project's calls never leave this process, so no credential goes with them. 73+ const local = isLocal(raw.server); 74+ const token = local ? undefined : tokenFor(raw.server!, env, root, tokenFileOk); 6976 server: raw.server!, 7077 project: raw.project!, 79+ ...(typeof raw.store === "string" && raw.store !== "" ? { store: raw.store } : {}), 80+ ...(local ? { localStore: storeDir(env, raw.store, root) } : {}), 7281 ...(typeof raw.follow === "string" && raw.follow !== "" ? { follow: raw.follow } : {}), 7382 ...(raw.reader === true ? { reader: true } : {}), 7483 ...(token ? { token } : {}), Lines 111–117 at 318 (were 102–107 at 269)
104113 env: Readonly<Record<string, string | undefined>> = process.env, 114+ tokenFileOk = false, 105115): { kind: "agent key" | "shared token" | "pipeline run key" | "none"; id: string | null } { 106116 const key = readKeyFile(root); Lines 120–126 at 318 (were 110–116 at 269)
111121 if (fromEnv(env, "TOKEN")) return { kind: "shared token", id: null }; 112122 if (fromEnv(env, "KEY_FILE")) return { kind: "pipeline run key", id: null }; 113− return { kind: readToken(env) ? "shared token" : "none", id: null };
123+ return { kind: tokenFileOk && tokenFile() ? "shared token" : "none", id: null }; 116126interface StoredKey { Lines 192–206 at 318 (were 182–191 at 269)
183193 env: Readonly<Record<string, string | undefined>> = process.env, 185− tokenFileOk = true,
195+ tokenFileOk = false, 186196): string | undefined { 188198 const key = readKeyFile(root); 199+ // A folder with a key signs in with that key and nothing else, even when the server refuses it. 200+ if (!key && existsSync(keyPath(root))) 201+ throw new UsageError( 202+ `this folder's key file (${keyPath(root)}) can't be read, so abso sends nothing; abso key install puts a key back`, 190205 if (originOf(key.server) !== originOf(server)) 191206 throw new UsageError("this folder's key was issued for a different server, so abso will not send it"); Lines 266–272 at 318 (were 251–257 at 269)
254−/** This machine's token file (~/.abso/token, else ~/.avcs/token), or none. abso init and join read it only with --token-file. */
269+/** This machine's token file (~/.abso/token, else ~/.avcs/token), or none. Read only for a command given --token-file. */ 255270export function tokenFile(): string | undefined { 256271 return readToken({}); Lines 284–300 at 318 (were 269–278 at 269)
270285export function writeConfig(root: string, settings: Settings): void { 271286 mkdirSync(stateDir(root), { recursive: true }); 272− const { server, project, agent, follow, reader, visitor } = settings;
287+ const { server, project, agent, follow, reader, visitor, store } = settings; 273288 const written = visitor 274289 ? { server, project, visitor: true } 275− : { server, project, agent, ...(follow ? { follow } : {}), ...(reader ? { reader: true } : {}) };
294+ ...(follow ? { follow } : {}), 295+ ...(reader ? { reader: true } : {}), 296+ ...(store ? { store } : {}), 276298 writeFileSync(configPath(root), `${JSON.stringify(written, null, 2)}\n`); 277299 excludeFromGit(root);