{"file":"client/test/key.test.ts","version":318,"total":60,"from":1,"to":60,"lines":[{"n":1,"text":"import assert from \"node:assert/strict\";","atom":"a0","author":"init","version":0},{"n":2,"text":"import { mkdtempSync, readFileSync, writeFileSync } from \"node:fs\";","atom":"a0","author":"init","version":0},{"n":3,"text":"import { tmpdir } from \"node:os\";","atom":"a0","author":"init","version":0},{"n":4,"text":"import { join } from \"node:path\";","atom":"a0","author":"init","version":0},{"n":5,"text":"import { test } from \"node:test\";","atom":"a0","author":"init","version":0},{"n":6,"text":"import { credentialLabel, installKey, tokenFor, writeConfig } from \"../src/config.ts\";","atom":"a0","author":"init","version":0},{"n":7,"text":"","atom":"a0","author":"init","version":0},{"n":8,"text":"function folder() {","atom":"a0","author":"init","version":0},{"n":9,"text":"\tconst root = mkdtempSync(join(tmpdir(), \"abso-key-\"));","atom":"a0","author":"init","version":0},{"n":10,"text":"\twriteConfig(root, { server: \"https://staging.abso.example\", project: \"p\", agent: \"a\" });","atom":"a0","author":"init","version":0},{"n":11,"text":"\treturn root;","atom":"a0","author":"init","version":0},{"n":12,"text":"}","atom":"a0","author":"init","version":0},{"n":13,"text":"","atom":"a0","author":"init","version":0},{"n":14,"text":"const KEY = \"abso_sk_abcdefghijklmnopqrstuvwxyz012345\";","atom":"a0","author":"init","version":0},{"n":15,"text":"const ID = \"k_ab12cd34\";","atom":"a0","author":"init","version":0},{"n":16,"text":"","atom":"a0","author":"init","version":0},{"n":17,"text":"test(\"a key in the folder is sent instead of AVCS_TOKEN, and only to its server\", () => {","atom":"a0","author":"init","version":0},{"n":18,"text":"\tconst root = folder();","atom":"a0","author":"init","version":0},{"n":19,"text":"\tinstallKey(root, JSON.stringify({ key: KEY, id: ID }));","atom":"a0","author":"init","version":0},{"n":20,"text":"\tconst env = { AVCS_TOKEN: \"shared-token-value\" };","atom":"a0","author":"init","version":0},{"n":21,"text":"\tassert.equal(tokenFor(\"https://staging.abso.example\", env, root), KEY);","atom":"a0","author":"init","version":0},{"n":22,"text":"\tassert.throws(() => tokenFor(\"https://abso.example\", env, root), /different server/);","atom":"a0","author":"init","version":0},{"n":23,"text":"\tconst label = credentialLabel(root, \"https://staging.abso.example\", env);","atom":"a0","author":"init","version":0},{"n":24,"text":"\tassert.deepEqual(label, { kind: \"agent key\", id: ID });","atom":"a0","author":"init","version":0},{"n":25,"text":"\tassert.equal(JSON.stringify(label).includes(KEY), false);","atom":"a0","author":"init","version":0},{"n":26,"text":"});","atom":"a0","author":"init","version":0},{"n":27,"text":"","atom":"a0","author":"init","version":0},{"n":28,"text":"test(\"with no key, the shared token is unchanged\", () => {","atom":"a0","author":"init","version":0},{"n":29,"text":"\tconst root = folder();","atom":"a0","author":"init","version":0},{"n":30,"text":"\tconst env = {","atom":"a0","author":"init","version":0},{"n":31,"text":"\t\tAVCS_TOKEN: \"shared-token-value\",","atom":"a0","author":"init","version":0},{"n":32,"text":"\t\tAVCS_TRUSTED_SERVERS: \"https://abso.example\",","atom":"a0","author":"init","version":0},{"n":33,"text":"\t\tAVCS_SERVERS_FILE: \"no-servers.json\",","atom":"a0","author":"init","version":0},{"n":34,"text":"\t};","atom":"a0","author":"init","version":0},{"n":35,"text":"\tassert.equal(tokenFor(\"https://abso.example\", env, root), \"shared-token-value\");","atom":"a0","author":"init","version":0},{"n":36,"text":"\tassert.deepEqual(credentialLabel(root, \"https://abso.example\", env), { kind: \"shared token\", id: null });","atom":"a0","author":"init","version":0},{"n":37,"text":"});","atom":"a0","author":"init","version":0},{"n":38,"text":"","atom":"a0","author":"init","version":0},{"n":39,"text":"test(\"install writes .avcs/key and does not leave the key in the returned value\", () => {","atom":"a131","author":"pinch","version":18},{"n":40,"text":"\tconst root = folder();","atom":"a0","author":"init","version":0},{"n":41,"text":"\tconst installed = installKey(root, JSON.stringify({ key: KEY, id: ID }));","atom":"a0","author":"init","version":0},{"n":42,"text":"\tassert.deepEqual(installed, { id: ID });","atom":"a0","author":"init","version":0},{"n":43,"text":"\tconst stored = readFileSync(join(root, \".avcs\", \"key\"), \"utf8\");","atom":"a131","author":"pinch","version":18},{"n":44,"text":"\tassert.equal(stored.includes(KEY), true);","atom":"a0","author":"init","version":0},{"n":45,"text":"\tassert.equal(JSON.stringify(installed).includes(KEY), false);","atom":"a0","author":"init","version":0},{"n":46,"text":"\twriteFileSync(join(root, \".avcs\", \"key\"), stored);","atom":"a131","author":"pinch","version":18},{"n":47,"text":"});","atom":"a0","author":"init","version":0},{"n":48,"text":"","atom":"a0","author":"init","version":0},{"n":49,"text":"test(\"a key installed with --server before join is the one join's folder sends\", () => {","atom":"a0","author":"init","version":0},{"n":50,"text":"\tconst root = mkdtempSync(join(tmpdir(), \"abso-key-\"));","atom":"a0","author":"init","version":0},{"n":51,"text":"\tconst staging = \"https://staging.abso.example\";","atom":"a0","author":"init","version":0},{"n":52,"text":"\tassert.throws(() => installKey(root, JSON.stringify({ key: KEY, id: ID })), /--server/);","atom":"a0","author":"init","version":0},{"n":53,"text":"\tinstallKey(root, JSON.stringify({ key: KEY, id: ID }), staging);","atom":"a0","author":"init","version":0},{"n":54,"text":"\twriteConfig(root, { server: staging, project: \"p\", agent: \"a\" });","atom":"a0","author":"init","version":0},{"n":55,"text":"\tassert.equal(tokenFor(staging, {}, root), KEY);","atom":"a0","author":"init","version":0},{"n":56,"text":"\tassert.throws(","atom":"a0","author":"init","version":0},{"n":57,"text":"\t\t() => installKey(root, JSON.stringify({ key: KEY, id: ID }), \"https://abso.example\"),","atom":"a0","author":"init","version":0},{"n":58,"text":"\t\t/not https:\\/\\/abso.example/,","atom":"a0","author":"init","version":0},{"n":59,"text":"\t);","atom":"a0","author":"init","version":0},{"n":60,"text":"});","atom":"a0","author":"init","version":0}],"atoms":[{"atom":"a0","author":"init","message":"Start the project","time":1791506895507,"timeIso":"2026-10-09T00:48:15.507Z","publish":{"draft":null,"version":0,"agent":"init","message":"Start the project","time":1791506895507,"timeIso":"2026-10-09T00:48:15.507Z"}},{"atom":"a131","author":"pinch","message":"","time":1791523142973,"timeIso":"2026-10-09T05:19:02.973Z","publish":{"draft":null,"version":18,"agent":"pinch","message":"New folders keep .avcs/ for now; the server keeps both state folders out of a project\n\nVersion 17 made new folders with .abso/. An edit mod or Cursor hook installed before the rename looks only for .avcs/config.json, so in a .abso/ folder it would stop recording edits, and nothing would say so. Until installs can say which mods know .abso/, a new folder is made with .avcs/ again (NEW_FOLDER_DIR in client/src/state-dir.ts). Reading is unchanged: a folder with .abso/ works exactly as one with .avcs/, and neither is ever half-moved. The user's files still go to ~/.abso/, since an older client that can't find them says so.\n\nThe server refused only paths under .avcs/, and the test server only .abso/. Both now refuse both, so a folder's state never becomes part of a project, whichever name it has.\n\nTests: new folders get .avcs/; a folder moved to .abso/ records and isn't moved back; the tests that assumed .abso/ for a new folder now use .avcs/.","time":1791523143960,"timeIso":"2026-10-09T05:19:03.960Z"}}]}