{"file":"client/test/box.test.ts","version":318,"total":554,"from":1,"to":554,"lines":[{"n":1,"text":"// Signing in once per box (abso issue 108): login waits for approval and keeps","atom":"a0","author":"init","version":0},{"n":2,"text":"// the credential outside every project folder; it never shows up in output and","atom":"a0","author":"init","version":0},{"n":3,"text":"// only goes to the server that issued it.","atom":"a0","author":"init","version":0},{"n":4,"text":"","atom":"a0","author":"init","version":0},{"n":5,"text":"import assert from \"node:assert/strict\";","atom":"a0","author":"init","version":0},{"n":6,"text":"import { mkdtempSync, readdirSync, readFileSync } from \"node:fs\";","atom":"a0","author":"init","version":0},{"n":7,"text":"import { tmpdir } from \"node:os\";","atom":"a0","author":"init","version":0},{"n":8,"text":"import { join } from \"node:path\";","atom":"a0","author":"init","version":0},{"n":9,"text":"import { test } from \"node:test\";","atom":"a0","author":"init","version":0},{"n":10,"text":"import { parseArgs } from \"../src/args.ts\";","atom":"a922","author":"codex-mac-1","version":102},{"n":11,"text":"import {","atom":"a616","author":"trials","version":61},{"n":12,"text":"\tboxCreateProject,","atom":"a2075","author":"box-grants","version":185},{"n":13,"text":"\tboxPublic,","atom":"a616","author":"trials","version":61},{"n":14,"text":"\tboxText,","atom":"a616","author":"trials","version":61},{"n":15,"text":"\tforgetBox,","atom":"a616","author":"trials","version":61},{"n":16,"text":"\tlogin,","atom":"a616","author":"trials","version":61},{"n":17,"text":"\tloginRequest,","atom":"a922","author":"codex-mac-1","version":102},{"n":18,"text":"\tlogout,","atom":"a616","author":"trials","version":61},{"n":19,"text":"\tmintFreeName,","atom":"a623","author":"trials","version":63},{"n":20,"text":"\tmintKey,","atom":"a616","author":"trials","version":61},{"n":21,"text":"\treadBox,","atom":"a616","author":"trials","version":61},{"n":22,"text":"\tsignedInServers,","atom":"a616","author":"trials","version":61},{"n":23,"text":"\twriteBox,","atom":"a616","author":"trials","version":61},{"n":24,"text":"} from \"../src/box.ts\";","atom":"a616","author":"trials","version":61},{"n":25,"text":"import { serverFrom } from \"../src/join-commands.ts\";","atom":"a616","author":"trials","version":61},{"n":26,"text":"import { main } from \"../src/main.ts\";","atom":"a922","author":"codex-mac-1","version":102},{"n":27,"text":"","atom":"a0","author":"init","version":0},{"n":28,"text":"const SERVER = \"https://staging.abso.example\";","atom":"a0","author":"init","version":0},{"n":29,"text":"const CREDENTIAL = \"abso_bx_the-secret-credential\";","atom":"a0","author":"init","version":0},{"n":30,"text":"const grant = {","atom":"a0","author":"init","version":0},{"n":31,"text":"\tprojects: [","atom":"a0","author":"init","version":0},{"n":32,"text":"\t\t{ project: \"abso\", role: \"writer\" },","atom":"a0","author":"init","version":0},{"n":33,"text":"\t\t{ project: \"game\", role: \"reader\" },","atom":"a0","author":"init","version":0},{"n":34,"text":"\t],","atom":"a0","author":"init","version":0},{"n":35,"text":"};","atom":"a0","author":"init","version":0},{"n":36,"text":"const EXPIRES = \"2026-10-15T00:00:00.000Z\";","atom":"a0","author":"init","version":0},{"n":37,"text":"const record = { server: SERVER, id: \"b_0123abcd\", credential: CREDENTIAL, grant, expiresAt: Date.parse(EXPIRES) };","atom":"a0","author":"init","version":0},{"n":38,"text":"","atom":"a0","author":"init","version":0},{"n":39,"text":"const home = () => mkdtempSync(join(tmpdir(), \"abso-box-\"));","atom":"a0","author":"init","version":0},{"n":40,"text":"","atom":"a0","author":"init","version":0},{"n":41,"text":"type Seen = { url: string; auth: string | null; body: unknown }[];","atom":"a0","author":"init","version":0},{"n":42,"text":"function server(answers: [number, unknown][], seen: Seen): typeof fetch {","atom":"a0","author":"init","version":0},{"n":43,"text":"\treturn (async (url, init) => {","atom":"a0","author":"init","version":0},{"n":44,"text":"\t\tseen.push({","atom":"a0","author":"init","version":0},{"n":45,"text":"\t\t\turl: String(url),","atom":"a0","author":"init","version":0},{"n":46,"text":"\t\t\tauth: new Headers(init?.headers).get(\"authorization\"),","atom":"a0","author":"init","version":0},{"n":47,"text":"\t\t\tbody: JSON.parse(String(init?.body ?? \"null\")),","atom":"a0","author":"init","version":0},{"n":48,"text":"\t\t});","atom":"a0","author":"init","version":0},{"n":49,"text":"\t\tconst [status, body] = answers.shift() ?? [500, { error: \"no more answers\" }];","atom":"a0","author":"init","version":0},{"n":50,"text":"\t\treturn new Response(JSON.stringify(body), { status });","atom":"a0","author":"init","version":0},{"n":51,"text":"\t}) as typeof fetch;","atom":"a0","author":"init","version":0},{"n":52,"text":"}","atom":"a0","author":"init","version":0},{"n":53,"text":"","atom":"a0","author":"init","version":0},{"n":54,"text":"const started = {","atom":"a0","author":"init","version":0},{"n":55,"text":"\tdevice_code: \"device-code-long-enough\",","atom":"a0","author":"init","version":0},{"n":56,"text":"\tuser_code: \"WXYZ-BCDF\",","atom":"a0","author":"init","version":0},{"n":57,"text":"\tverification_uri_complete: \"https://abso.dev/login/box?code=WXYZ-BCDF\",","atom":"a0","author":"init","version":0},{"n":58,"text":"\texpires_in: 60,","atom":"a0","author":"init","version":0},{"n":59,"text":"\tinterval: 2,","atom":"a0","author":"init","version":0},{"n":60,"text":"};","atom":"a0","author":"init","version":0},{"n":61,"text":"","atom":"a0","author":"init","version":0},{"n":62,"text":"function clock() {","atom":"a0","author":"init","version":0},{"n":63,"text":"\tlet t = 0;","atom":"a0","author":"init","version":0},{"n":64,"text":"\treturn {","atom":"a0","author":"init","version":0},{"n":65,"text":"\t\tsleep: async (ms: number) => {","atom":"a0","author":"init","version":0},{"n":66,"text":"\t\t\tt += ms;","atom":"a0","author":"init","version":0},{"n":67,"text":"\t\t},","atom":"a0","author":"init","version":0},{"n":68,"text":"\t\tnow: () => t,","atom":"a0","author":"init","version":0},{"n":69,"text":"\t\tslept: () => t,","atom":"a0","author":"init","version":0},{"n":70,"text":"\t};","atom":"a0","author":"init","version":0},{"n":71,"text":"}","atom":"a0","author":"init","version":0},{"n":72,"text":"","atom":"a922","author":"codex-mac-1","version":102},{"n":73,"text":"test(\"login grant options validate project lists, roles and duration\", () => {","atom":"a1850","author":"open","version":171},{"n":74,"text":"\tconst request = (...words: string[]) =>","atom":"a922","author":"codex-mac-1","version":102},{"n":75,"text":"\t\tloginRequest(","atom":"a922","author":"codex-mac-1","version":102},{"n":76,"text":"\t\t\tparseArgs(\"login\", words, {","atom":"a922","author":"codex-mac-1","version":102},{"n":77,"text":"\t\t\t\tprojects: \"string\",","atom":"a922","author":"codex-mac-1","version":102},{"n":78,"text":"\t\t\t\trole: \"string\",","atom":"a922","author":"codex-mac-1","version":102},{"n":79,"text":"\t\t\t\tdays: \"string\",","atom":"a922","author":"codex-mac-1","version":102},{"n":80,"text":"\t\t\t}),","atom":"a922","author":"codex-mac-1","version":102},{"n":81,"text":"\t\t);","atom":"a922","author":"codex-mac-1","version":102},{"n":82,"text":"\tassert.equal(request(), undefined);","atom":"a922","author":"codex-mac-1","version":102},{"n":83,"text":"\tassert.deepEqual(request(\"--projects\", \"alpha, beta,alpha\", \"--days\", \"30\"), {","atom":"a1850","author":"open","version":171},{"n":84,"text":"\t\tprojects: [","atom":"a922","author":"codex-mac-1","version":102},{"n":85,"text":"\t\t\t{ project: \"alpha\", role: \"writer\" },","atom":"a922","author":"codex-mac-1","version":102},{"n":86,"text":"\t\t\t{ project: \"beta\", role: \"writer\" },","atom":"a922","author":"codex-mac-1","version":102},{"n":87,"text":"\t\t],","atom":"a922","author":"codex-mac-1","version":102},{"n":88,"text":"\t\tdays: 30,","atom":"a922","author":"codex-mac-1","version":102},{"n":89,"text":"\t});","atom":"a922","author":"codex-mac-1","version":102},{"n":90,"text":"\tassert.deepEqual(request(\"--projects\", \"alpha\", \"--role\", \"reader\"), {","atom":"a922","author":"codex-mac-1","version":102},{"n":91,"text":"\t\tprojects: [{ project: \"alpha\", role: \"reader\" }],","atom":"a922","author":"codex-mac-1","version":102},{"n":92,"text":"\t});","atom":"a922","author":"codex-mac-1","version":102},{"n":93,"text":"\tassert.deepEqual(request(\"--projects\", \"alpha\", \"--role\", \"owner\"), {","atom":"a922","author":"codex-mac-1","version":102},{"n":94,"text":"\t\tprojects: [{ project: \"alpha\", role: \"owner\" }],","atom":"a922","author":"codex-mac-1","version":102},{"n":95,"text":"\t});","atom":"a922","author":"codex-mac-1","version":102},{"n":96,"text":"\tassert.deepEqual(request(\"--days\", \"90\"), { days: 90 });","atom":"a1850","author":"open","version":171},{"n":97,"text":"\tfor (const words of [","atom":"a922","author":"codex-mac-1","version":102},{"n":98,"text":"\t\t[\"--role\", \"writer\"],","atom":"a922","author":"codex-mac-1","version":102},{"n":99,"text":"\t\t[\"--projects\", \"\"],","atom":"a922","author":"codex-mac-1","version":102},{"n":100,"text":"\t\t[\"--projects\", \"alpha,\"],","atom":"a922","author":"codex-mac-1","version":102},{"n":101,"text":"\t\t[\"--projects\", \"../alpha\"],","atom":"a922","author":"codex-mac-1","version":102},{"n":102,"text":"\t\t[\"--projects\", \"alpha\", \"--role\", \"admin\"],","atom":"a922","author":"codex-mac-1","version":102},{"n":103,"text":"\t\t[\"--projects\", Array.from({ length: 101 }, (_, i) => `p${i}`).join(\",\")],","atom":"a922","author":"codex-mac-1","version":102},{"n":104,"text":"\t])","atom":"a922","author":"codex-mac-1","version":102},{"n":105,"text":"\t\tassert.throws(() => request(...words));","atom":"a922","author":"codex-mac-1","version":102},{"n":106,"text":"\tfor (const value of [\"0\", \"-1\", \"1.5\", \"1e1\", \"Infinity\", \"100\", \"abc\", \"\"])","atom":"a1850","author":"open","version":171},{"n":107,"text":"\t\tassert.throws(() => request(\"--days\", value));","atom":"a1850","author":"open","version":171},{"n":108,"text":"});","atom":"a922","author":"codex-mac-1","version":102},{"n":109,"text":"","atom":"a922","author":"codex-mac-1","version":102},{"n":110,"text":"test(\"login sends requested grants only at device start and retains the user's actual approval\", async () => {","atom":"a922","author":"codex-mac-1","version":102},{"n":111,"text":"\tconst h = home();","atom":"a922","author":"codex-mac-1","version":102},{"n":112,"text":"\tconst seen: Seen = [];","atom":"a922","author":"codex-mac-1","version":102},{"n":113,"text":"\tconst c = clock();","atom":"a922","author":"codex-mac-1","version":102},{"n":114,"text":"\tconst requested = { projects: [{ project: \"abso\", role: \"owner\" as const }], days: 90 };","atom":"a1850","author":"open","version":171},{"n":115,"text":"\tconst approved = { projects: [{ project: \"abso\", role: \"reader\" }] };","atom":"a1850","author":"open","version":171},{"n":116,"text":"\tconst got = await login(","atom":"a922","author":"codex-mac-1","version":102},{"n":117,"text":"\t\tSERVER,","atom":"a922","author":"codex-mac-1","version":102},{"n":118,"text":"\t\t{","atom":"a922","author":"codex-mac-1","version":102},{"n":119,"text":"\t\t\trequest: requested,","atom":"a922","author":"codex-mac-1","version":102},{"n":120,"text":"\t\t\tfetch: server(","atom":"a922","author":"codex-mac-1","version":102},{"n":121,"text":"\t\t\t\t[","atom":"a922","author":"codex-mac-1","version":102},{"n":122,"text":"\t\t\t\t\t[200, started],","atom":"a922","author":"codex-mac-1","version":102},{"n":123,"text":"\t\t\t\t\t[400, { error: \"authorization_pending\" }],","atom":"a922","author":"codex-mac-1","version":102},{"n":124,"text":"\t\t\t\t\t[200, { box_id: \"b_test\", box_token: CREDENTIAL, expires_at: EXPIRES, grant: approved }],","atom":"a922","author":"codex-mac-1","version":102},{"n":125,"text":"\t\t\t\t],","atom":"a922","author":"codex-mac-1","version":102},{"n":126,"text":"\t\t\t\tseen,","atom":"a922","author":"codex-mac-1","version":102},{"n":127,"text":"\t\t\t),","atom":"a922","author":"codex-mac-1","version":102},{"n":128,"text":"\t\t\tsleep: c.sleep,","atom":"a922","author":"codex-mac-1","version":102},{"n":129,"text":"\t\t\tnow: c.now,","atom":"a922","author":"codex-mac-1","version":102},{"n":130,"text":"\t\t\tsay: () => {},","atom":"a922","author":"codex-mac-1","version":102},{"n":131,"text":"\t\t},","atom":"a922","author":"codex-mac-1","version":102},{"n":132,"text":"\t\th,","atom":"a922","author":"codex-mac-1","version":102},{"n":133,"text":"\t);","atom":"a922","author":"codex-mac-1","version":102},{"n":134,"text":"\tassert.ok(seen[0]);","atom":"a922","author":"codex-mac-1","version":102},{"n":135,"text":"\tassert.deepEqual((seen[0].body as Record<string, unknown>).requested_grant, requested);","atom":"a922","author":"codex-mac-1","version":102},{"n":136,"text":"\tassert.deepEqual(","atom":"a922","author":"codex-mac-1","version":102},{"n":137,"text":"\t\tseen.slice(1).map((call) => call.body),","atom":"a922","author":"codex-mac-1","version":102},{"n":138,"text":"\t\t[{ device_code: started.device_code }, { device_code: started.device_code }],","atom":"a922","author":"codex-mac-1","version":102},{"n":139,"text":"\t);","atom":"a922","author":"codex-mac-1","version":102},{"n":140,"text":"\tassert.deepEqual(got.grant, approved);","atom":"a922","author":"codex-mac-1","version":102},{"n":141,"text":"\tassert.deepEqual(readBox(SERVER, h)?.grant, approved);","atom":"a922","author":"codex-mac-1","version":102},{"n":142,"text":"});","atom":"a922","author":"codex-mac-1","version":102},{"n":143,"text":"","atom":"a922","author":"codex-mac-1","version":102},{"n":144,"text":"test(\"invalid login grant flags fail before a network request through the CLI\", async () => {","atom":"a922","author":"codex-mac-1","version":102},{"n":145,"text":"\tconst original = globalThis.fetch;","atom":"a922","author":"codex-mac-1","version":102},{"n":146,"text":"\tlet calls = 0;","atom":"a922","author":"codex-mac-1","version":102},{"n":147,"text":"\tglobalThis.fetch = (async () => {","atom":"a922","author":"codex-mac-1","version":102},{"n":148,"text":"\t\tcalls++;","atom":"a922","author":"codex-mac-1","version":102},{"n":149,"text":"\t\tthrow new Error(\"unexpected request\");","atom":"a922","author":"codex-mac-1","version":102},{"n":150,"text":"\t}) as typeof fetch;","atom":"a922","author":"codex-mac-1","version":102},{"n":151,"text":"\ttry {","atom":"a922","author":"codex-mac-1","version":102},{"n":152,"text":"\t\tconst result = await main([\"login\", \"--projects\", \"alpha\", \"--days\", \"0\", \"--no-browser\"], {","atom":"a922","author":"codex-mac-1","version":102},{"n":153,"text":"\t\t\tcwd: home(),","atom":"a922","author":"codex-mac-1","version":102},{"n":154,"text":"\t\t\tenv: {},","atom":"a922","author":"codex-mac-1","version":102},{"n":155,"text":"\t\t\twrite: () => {},","atom":"a922","author":"codex-mac-1","version":102},{"n":156,"text":"\t\t});","atom":"a922","author":"codex-mac-1","version":102},{"n":157,"text":"\t\tassert.equal(result.exit, 1);","atom":"a922","author":"codex-mac-1","version":102},{"n":158,"text":"\t\tassert.match(result.stderr, /--days is from 1 to 90/);","atom":"a922","author":"codex-mac-1","version":102},{"n":159,"text":"\t\tassert.equal(calls, 0);","atom":"a922","author":"codex-mac-1","version":102},{"n":160,"text":"\t} finally {","atom":"a922","author":"codex-mac-1","version":102},{"n":161,"text":"\t\tglobalThis.fetch = original;","atom":"a922","author":"codex-mac-1","version":102},{"n":162,"text":"\t}","atom":"a922","author":"codex-mac-1","version":102},{"n":163,"text":"});","atom":"a922","author":"codex-mac-1","version":102},{"n":164,"text":"","atom":"a0","author":"init","version":0},{"n":165,"text":"test(\"login shows the code, waits while it's pending, and keeps the credential in the user folder\", async () => {","atom":"a0","author":"init","version":0},{"n":166,"text":"\tconst h = home();","atom":"a0","author":"init","version":0},{"n":167,"text":"\tconst seen: Seen = [];","atom":"a0","author":"init","version":0},{"n":168,"text":"\tconst said: string[] = [];","atom":"a0","author":"init","version":0},{"n":169,"text":"\tconst c = clock();","atom":"a0","author":"init","version":0},{"n":170,"text":"\tconst got = await login(","atom":"a0","author":"init","version":0},{"n":171,"text":"\t\t`${SERVER}/some/path`,","atom":"a0","author":"init","version":0},{"n":172,"text":"\t\t{","atom":"a0","author":"init","version":0},{"n":173,"text":"\t\t\tfetch: server(","atom":"a0","author":"init","version":0},{"n":174,"text":"\t\t\t\t[","atom":"a0","author":"init","version":0},{"n":175,"text":"\t\t\t\t\t[200, started],","atom":"a0","author":"init","version":0},{"n":176,"text":"\t\t\t\t\t[400, { error: \"authorization_pending\" }],","atom":"a0","author":"init","version":0},{"n":177,"text":"\t\t\t\t\t[400, { error: \"slow_down\" }],","atom":"a0","author":"init","version":0},{"n":178,"text":"\t\t\t\t\t[200, { box_id: \"b_0123abcd\", box_token: CREDENTIAL, expires_at: EXPIRES, grant }],","atom":"a0","author":"init","version":0},{"n":179,"text":"\t\t\t\t],","atom":"a0","author":"init","version":0},{"n":180,"text":"\t\t\t\tseen,","atom":"a0","author":"init","version":0},{"n":181,"text":"\t\t\t),","atom":"a0","author":"init","version":0},{"n":182,"text":"\t\t\tsleep: c.sleep,","atom":"a0","author":"init","version":0},{"n":183,"text":"\t\t\tnow: c.now,","atom":"a0","author":"init","version":0},{"n":184,"text":"\t\t\tsay: (line) => said.push(line),","atom":"a0","author":"init","version":0},{"n":185,"text":"\t\t},","atom":"a0","author":"init","version":0},{"n":186,"text":"\t\th,","atom":"a0","author":"init","version":0},{"n":187,"text":"\t);","atom":"a0","author":"init","version":0},{"n":188,"text":"\tassert.equal(got.server, SERVER);","atom":"a0","author":"init","version":0},{"n":189,"text":"\tassert.deepEqual(","atom":"a0","author":"init","version":0},{"n":190,"text":"\t\tseen.map((s) => s.url),","atom":"a0","author":"init","version":0},{"n":191,"text":"\t\t[`${SERVER}/login/device`, `${SERVER}/login/token`, `${SERVER}/login/token`, `${SERVER}/login/token`],","atom":"a0","author":"init","version":0},{"n":192,"text":"\t);","atom":"a0","author":"init","version":0},{"n":193,"text":"\tassert.deepEqual(seen[1]?.body, { device_code: \"device-code-long-enough\" });","atom":"a0","author":"init","version":0},{"n":194,"text":"\tassert.equal(c.slept(), 2000 + 2000 + 7000, \"slow_down adds 5 s to the wait\");","atom":"a0","author":"init","version":0},{"n":195,"text":"\tassert.ok(","atom":"a0","author":"init","version":0},{"n":196,"text":"\t\tseen.every((s) => s.auth === null),","atom":"a0","author":"init","version":0},{"n":197,"text":"\t\t\"nothing is sent with login's calls\",","atom":"a0","author":"init","version":0},{"n":198,"text":"\t);","atom":"a0","author":"init","version":0},{"n":199,"text":"\tassert.deepEqual(said, [","atom":"a0","author":"init","version":0},{"n":200,"text":"\t\t\"To sign this box in, open https://abso.dev/login/box?code=WXYZ-BCDF and approve the code WXYZ-BCDF.\",","atom":"a0","author":"init","version":0},{"n":201,"text":"\t\t\"Waiting for approval. Ctrl-C stops waiting, and abso stops by itself when the code runs out.\",","atom":"a586","author":"pinch","version":58},{"n":202,"text":"\t]);","atom":"a0","author":"init","version":0},{"n":203,"text":"\tassert.equal(readBox(SERVER, h)?.credential, CREDENTIAL);","atom":"a0","author":"init","version":0},{"n":204,"text":"\tconst files = readdirSync(join(h, \".abso\", \"boxes\"));","atom":"a116","author":"review","version":17},{"n":205,"text":"\tassert.equal(files.length, 1);","atom":"a0","author":"init","version":0},{"n":206,"text":"\tassert.ok(readFileSync(join(h, \".abso\", \"boxes\", files[0]!), \"utf8\").includes(CREDENTIAL));","atom":"a116","author":"review","version":17},{"n":207,"text":"\tassert.equal(boxText(got, SERVER, 0).includes(CREDENTIAL), false);","atom":"a0","author":"init","version":0},{"n":208,"text":"\tassert.match(boxText(got, SERVER, 0), /abso \\(writer\\), game \\(reader\\)\\.\\n/);","atom":"a1850","author":"open","version":171},{"n":209,"text":"\tassert.doesNotMatch(boxText(got, SERVER, 0), /agents/);","atom":"a1850","author":"open","version":171},{"n":210,"text":"\tassert.equal(JSON.stringify(boxPublic(got)).includes(CREDENTIAL), false);","atom":"a0","author":"init","version":0},{"n":211,"text":"});","atom":"a0","author":"init","version":0},{"n":212,"text":"","atom":"a0","author":"init","version":0},{"n":213,"text":"test(\"login opens the approve page with the code in it, and prints the link and code all the same\", async () => {","atom":"a609","author":"speed","version":60},{"n":214,"text":"\tconst said: string[] = [];","atom":"a609","author":"speed","version":60},{"n":215,"text":"\tconst opened: string[] = [];","atom":"a609","author":"speed","version":60},{"n":216,"text":"\tconst c = clock();","atom":"a609","author":"speed","version":60},{"n":217,"text":"\tawait login(","atom":"a609","author":"speed","version":60},{"n":218,"text":"\t\tSERVER,","atom":"a609","author":"speed","version":60},{"n":219,"text":"\t\t{","atom":"a609","author":"speed","version":60},{"n":220,"text":"\t\t\tfetch: server(","atom":"a609","author":"speed","version":60},{"n":221,"text":"\t\t\t\t[","atom":"a609","author":"speed","version":60},{"n":222,"text":"\t\t\t\t\t[200, started],","atom":"a609","author":"speed","version":60},{"n":223,"text":"\t\t\t\t\t[200, { box_id: \"b_0123abcd\", box_token: CREDENTIAL, expires_at: EXPIRES, grant }],","atom":"a609","author":"speed","version":60},{"n":224,"text":"\t\t\t\t],","atom":"a609","author":"speed","version":60},{"n":225,"text":"\t\t\t\t[],","atom":"a609","author":"speed","version":60},{"n":226,"text":"\t\t\t),","atom":"a609","author":"speed","version":60},{"n":227,"text":"\t\t\tsleep: c.sleep,","atom":"a609","author":"speed","version":60},{"n":228,"text":"\t\t\tnow: c.now,","atom":"a609","author":"speed","version":60},{"n":229,"text":"\t\t\tsay: (line) => said.push(line),","atom":"a609","author":"speed","version":60},{"n":230,"text":"\t\t\topen: (url) => (opened.push(url), true),","atom":"a609","author":"speed","version":60},{"n":231,"text":"\t\t},","atom":"a609","author":"speed","version":60},{"n":232,"text":"\t\thome(),","atom":"a609","author":"speed","version":60},{"n":233,"text":"\t);","atom":"a609","author":"speed","version":60},{"n":234,"text":"\tassert.deepEqual(opened, [\"https://abso.dev/login/box?code=WXYZ-BCDF\"]);","atom":"a609","author":"speed","version":60},{"n":235,"text":"\tassert.deepEqual(said.slice(0, 2), [","atom":"a609","author":"speed","version":60},{"n":236,"text":"\t\t\"Opening the approve page in your browser.\",","atom":"a609","author":"speed","version":60},{"n":237,"text":"\t\t\"To sign this box in, open https://abso.dev/login/box?code=WXYZ-BCDF and approve the code WXYZ-BCDF.\",","atom":"a609","author":"speed","version":60},{"n":238,"text":"\t]);","atom":"a609","author":"speed","version":60},{"n":239,"text":"});","atom":"a609","author":"speed","version":60},{"n":240,"text":"","atom":"a609","author":"speed","version":60},{"n":241,"text":"test(\"an open that doesn't start says nothing about a browser, and the printed link stands\", async () => {","atom":"a609","author":"speed","version":60},{"n":242,"text":"\tconst said: string[] = [];","atom":"a609","author":"speed","version":60},{"n":243,"text":"\tconst c = clock();","atom":"a609","author":"speed","version":60},{"n":244,"text":"\tawait login(","atom":"a609","author":"speed","version":60},{"n":245,"text":"\t\tSERVER,","atom":"a609","author":"speed","version":60},{"n":246,"text":"\t\t{","atom":"a609","author":"speed","version":60},{"n":247,"text":"\t\t\tfetch: server(","atom":"a609","author":"speed","version":60},{"n":248,"text":"\t\t\t\t[","atom":"a609","author":"speed","version":60},{"n":249,"text":"\t\t\t\t\t[200, started],","atom":"a609","author":"speed","version":60},{"n":250,"text":"\t\t\t\t\t[200, { box_id: \"b_0123abcd\", box_token: CREDENTIAL, expires_at: EXPIRES, grant }],","atom":"a609","author":"speed","version":60},{"n":251,"text":"\t\t\t\t],","atom":"a609","author":"speed","version":60},{"n":252,"text":"\t\t\t\t[],","atom":"a609","author":"speed","version":60},{"n":253,"text":"\t\t\t),","atom":"a609","author":"speed","version":60},{"n":254,"text":"\t\t\tsleep: c.sleep,","atom":"a609","author":"speed","version":60},{"n":255,"text":"\t\t\tnow: c.now,","atom":"a609","author":"speed","version":60},{"n":256,"text":"\t\t\tsay: (line) => said.push(line),","atom":"a609","author":"speed","version":60},{"n":257,"text":"\t\t\topen: () => false,","atom":"a609","author":"speed","version":60},{"n":258,"text":"\t\t},","atom":"a609","author":"speed","version":60},{"n":259,"text":"\t\thome(),","atom":"a609","author":"speed","version":60},{"n":260,"text":"\t);","atom":"a609","author":"speed","version":60},{"n":261,"text":"\tassert.equal(","atom":"a609","author":"speed","version":60},{"n":262,"text":"\t\tsaid[0],","atom":"a609","author":"speed","version":60},{"n":263,"text":"\t\t\"To sign this box in, open https://abso.dev/login/box?code=WXYZ-BCDF and approve the code WXYZ-BCDF.\",","atom":"a609","author":"speed","version":60},{"n":264,"text":"\t);","atom":"a609","author":"speed","version":60},{"n":265,"text":"\tassert.equal(","atom":"a609","author":"speed","version":60},{"n":266,"text":"\t\tsaid.some((l) => l.includes(\"browser\")),","atom":"a609","author":"speed","version":60},{"n":267,"text":"\t\tfalse,","atom":"a609","author":"speed","version":60},{"n":268,"text":"\t);","atom":"a609","author":"speed","version":60},{"n":269,"text":"});","atom":"a609","author":"speed","version":60},{"n":270,"text":"","atom":"a609","author":"speed","version":60},{"n":271,"text":"test(\"a code that's turned down or runs out says so and keeps nothing\", async () => {","atom":"a0","author":"init","version":0},{"n":272,"text":"\tconst h = home();","atom":"a0","author":"init","version":0},{"n":273,"text":"\tconst c = clock();","atom":"a0","author":"init","version":0},{"n":274,"text":"\tconst io = { sleep: c.sleep, now: c.now, say: () => {} };","atom":"a0","author":"init","version":0},{"n":275,"text":"\tawait assert.rejects(","atom":"a0","author":"init","version":0},{"n":276,"text":"\t\tlogin(","atom":"a0","author":"init","version":0},{"n":277,"text":"\t\t\tSERVER,","atom":"a0","author":"init","version":0},{"n":278,"text":"\t\t\t{","atom":"a0","author":"init","version":0},{"n":279,"text":"\t\t\t\t...io,","atom":"a0","author":"init","version":0},{"n":280,"text":"\t\t\t\tfetch: server(","atom":"a0","author":"init","version":0},{"n":281,"text":"\t\t\t\t\t[","atom":"a0","author":"init","version":0},{"n":282,"text":"\t\t\t\t\t\t[200, started],","atom":"a0","author":"init","version":0},{"n":283,"text":"\t\t\t\t\t\t[400, { error: \"access_denied\" }],","atom":"a0","author":"init","version":0},{"n":284,"text":"\t\t\t\t\t],","atom":"a0","author":"init","version":0},{"n":285,"text":"\t\t\t\t\t[],","atom":"a0","author":"init","version":0},{"n":286,"text":"\t\t\t\t),","atom":"a0","author":"init","version":0},{"n":287,"text":"\t\t\t},","atom":"a0","author":"init","version":0},{"n":288,"text":"\t\t\th,","atom":"a0","author":"init","version":0},{"n":289,"text":"\t\t),","atom":"a0","author":"init","version":0},{"n":290,"text":"\t\t/was turned down/,","atom":"a0","author":"init","version":0},{"n":291,"text":"\t);","atom":"a0","author":"init","version":0},{"n":292,"text":"\tawait assert.rejects(","atom":"a0","author":"init","version":0},{"n":293,"text":"\t\tlogin(","atom":"a0","author":"init","version":0},{"n":294,"text":"\t\t\tSERVER,","atom":"a0","author":"init","version":0},{"n":295,"text":"\t\t\t{","atom":"a0","author":"init","version":0},{"n":296,"text":"\t\t\t\t...io,","atom":"a0","author":"init","version":0},{"n":297,"text":"\t\t\t\tfetch: server(","atom":"a0","author":"init","version":0},{"n":298,"text":"\t\t\t\t\t[","atom":"a0","author":"init","version":0},{"n":299,"text":"\t\t\t\t\t\t[200, started],","atom":"a0","author":"init","version":0},{"n":300,"text":"\t\t\t\t\t\t[400, { error: \"expired_token\" }],","atom":"a0","author":"init","version":0},{"n":301,"text":"\t\t\t\t\t],","atom":"a0","author":"init","version":0},{"n":302,"text":"\t\t\t\t\t[],","atom":"a0","author":"init","version":0},{"n":303,"text":"\t\t\t\t),","atom":"a0","author":"init","version":0},{"n":304,"text":"\t\t\t},","atom":"a0","author":"init","version":0},{"n":305,"text":"\t\t\th,","atom":"a0","author":"init","version":0},{"n":306,"text":"\t\t),","atom":"a0","author":"init","version":0},{"n":307,"text":"\t\t/ran out\\. Run abso login again/,","atom":"a0","author":"init","version":0},{"n":308,"text":"\t);","atom":"a0","author":"init","version":0},{"n":309,"text":"\tawait assert.rejects(","atom":"a0","author":"init","version":0},{"n":310,"text":"\t\tlogin(","atom":"a0","author":"init","version":0},{"n":311,"text":"\t\t\tSERVER,","atom":"a0","author":"init","version":0},{"n":312,"text":"\t\t\t{","atom":"a0","author":"init","version":0},{"n":313,"text":"\t\t\t\t...io,","atom":"a0","author":"init","version":0},{"n":314,"text":"\t\t\t\tfetch: server(","atom":"a0","author":"init","version":0},{"n":315,"text":"\t\t\t\t\t[","atom":"a0","author":"init","version":0},{"n":316,"text":"\t\t\t\t\t\t[200, { ...started, expires_in: 3 }],","atom":"a0","author":"init","version":0},{"n":317,"text":"\t\t\t\t\t\t[400, { error: \"authorization_pending\" }],","atom":"a0","author":"init","version":0},{"n":318,"text":"\t\t\t\t\t\t[400, { error: \"authorization_pending\" }],","atom":"a0","author":"init","version":0},{"n":319,"text":"\t\t\t\t\t],","atom":"a0","author":"init","version":0},{"n":320,"text":"\t\t\t\t\t[],","atom":"a0","author":"init","version":0},{"n":321,"text":"\t\t\t\t),","atom":"a0","author":"init","version":0},{"n":322,"text":"\t\t\t},","atom":"a0","author":"init","version":0},{"n":323,"text":"\t\t\th,","atom":"a0","author":"init","version":0},{"n":324,"text":"\t\t),","atom":"a0","author":"init","version":0},{"n":325,"text":"\t\t/in time\\. Run abso login again/,","atom":"a0","author":"init","version":0},{"n":326,"text":"\t);","atom":"a0","author":"init","version":0},{"n":327,"text":"\tassert.equal(readBox(SERVER, h), undefined);","atom":"a0","author":"init","version":0},{"n":328,"text":"});","atom":"a586","author":"pinch","version":58},{"n":329,"text":"","atom":"a586","author":"pinch","version":58},{"n":330,"text":"test(\"login says it's still waiting about once a minute, and stops in the end whatever the server says\", async () => {","atom":"a586","author":"pinch","version":58},{"n":331,"text":"\tconst c = clock();","atom":"a586","author":"pinch","version":58},{"n":332,"text":"\tconst said: string[] = [];","atom":"a586","author":"pinch","version":58},{"n":333,"text":"\tconst pending = Array.from({ length: 2000 }, (): [number, unknown] => [400, { error: \"authorization_pending\" }]);","atom":"a586","author":"pinch","version":58},{"n":334,"text":"\tawait assert.rejects(","atom":"a586","author":"pinch","version":58},{"n":335,"text":"\t\tlogin(","atom":"a586","author":"pinch","version":58},{"n":336,"text":"\t\t\tSERVER,","atom":"a586","author":"pinch","version":58},{"n":337,"text":"\t\t\t{","atom":"a586","author":"pinch","version":58},{"n":338,"text":"\t\t\t\tfetch: server([[200, { ...started, expires_in: 10 ** 9, interval: 5 }], ...pending], []),","atom":"a586","author":"pinch","version":58},{"n":339,"text":"\t\t\t\tsleep: c.sleep,","atom":"a586","author":"pinch","version":58},{"n":340,"text":"\t\t\t\tnow: c.now,","atom":"a586","author":"pinch","version":58},{"n":341,"text":"\t\t\t\tsay: (line) => said.push(line),","atom":"a586","author":"pinch","version":58},{"n":342,"text":"\t\t\t},","atom":"a586","author":"pinch","version":58},{"n":343,"text":"\t\t\thome(),","atom":"a586","author":"pinch","version":58},{"n":344,"text":"\t\t),","atom":"a586","author":"pinch","version":58},{"n":345,"text":"\t\t/nobody approved the code WXYZ-BCDF in time\\. Run abso login again\\./,","atom":"a586","author":"pinch","version":58},{"n":346,"text":"\t);","atom":"a586","author":"pinch","version":58},{"n":347,"text":"\tassert.equal(c.slept(), 30 * 60 * 1000, \"a server that says never still gets an end\");","atom":"a586","author":"pinch","version":58},{"n":348,"text":"\tconst still = said.filter((line) => line === \"Still waiting for the code WXYZ-BCDF to be approved.\");","atom":"a586","author":"pinch","version":58},{"n":349,"text":"\tassert.equal(still.length, 30);","atom":"a586","author":"pinch","version":58},{"n":350,"text":"\tassert.equal(said.length, 2 + 30);","atom":"a586","author":"pinch","version":58},{"n":351,"text":"});","atom":"a0","author":"init","version":0},{"n":352,"text":"","atom":"a0","author":"init","version":0},{"n":353,"text":"test(\"a key is minted with the box credential, sent only to the box's own server\", async () => {","atom":"a0","author":"init","version":0},{"n":354,"text":"\tconst seen: Seen = [];","atom":"a0","author":"init","version":0},{"n":355,"text":"\tconst minted = await mintKey(","atom":"a0","author":"init","version":0},{"n":356,"text":"\t\trecord,","atom":"a0","author":"init","version":0},{"n":357,"text":"\t\t\"abso\",","atom":"a0","author":"init","version":0},{"n":358,"text":"\t\t\"tester-1\",","atom":"a0","author":"init","version":0},{"n":359,"text":"\t\tserver([[200, { key: \"abso_sk_x\", id: \"k_0123abcd\" }]], seen),","atom":"a0","author":"init","version":0},{"n":360,"text":"\t);","atom":"a0","author":"init","version":0},{"n":361,"text":"\tassert.deepEqual(minted, { key: \"abso_sk_x\", id: \"k_0123abcd\" });","atom":"a0","author":"init","version":0},{"n":362,"text":"\tassert.equal(seen[0]?.url.startsWith(`${SERVER}/`), true);","atom":"a0","author":"init","version":0},{"n":363,"text":"\tassert.equal(seen[0]?.auth, `Box ${CREDENTIAL}`);","atom":"a0","author":"init","version":0},{"n":364,"text":"\tawait assert.rejects(","atom":"a0","author":"init","version":0},{"n":365,"text":"\t\tmintKey(record, \"secret-project\", \"a\", server([[403, { error: `outside the grant ${CREDENTIAL}` }]], [])),","atom":"a0","author":"init","version":0},{"n":366,"text":"\t\t(e: Error) => /refused \\(403\\)/.test(e.message) && !e.message.includes(CREDENTIAL),","atom":"a0","author":"init","version":0},{"n":367,"text":"\t);","atom":"a0","author":"init","version":0},{"n":368,"text":"});","atom":"a0","author":"init","version":0},{"n":369,"text":"","atom":"a0","author":"init","version":0},{"n":370,"text":"test(\"a box's sign-in is kept per server, and logout forgets it even when the server is down\", async () => {","atom":"a0","author":"init","version":0},{"n":371,"text":"\tconst h = home();","atom":"a0","author":"init","version":0},{"n":372,"text":"\twriteBox(record, h);","atom":"a0","author":"init","version":0},{"n":373,"text":"\tassert.equal(readBox(\"https://abso.example\", h), undefined, \"another server's box isn't this one\");","atom":"a0","author":"init","version":0},{"n":374,"text":"\tassert.match(boxText(undefined, SERVER), /isn't signed in/);","atom":"a0","author":"init","version":0},{"n":375,"text":"\tconst down = (async () => {","atom":"a0","author":"init","version":0},{"n":376,"text":"\t\tthrow new Error(\"offline\");","atom":"a0","author":"init","version":0},{"n":377,"text":"\t}) as typeof fetch;","atom":"a0","author":"init","version":0},{"n":378,"text":"\tassert.equal(await logout(readBox(SERVER, h)!, down, h), false);","atom":"a0","author":"init","version":0},{"n":379,"text":"\tassert.equal(readBox(SERVER, h), undefined);","atom":"a0","author":"init","version":0},{"n":380,"text":"\tassert.equal(forgetBox(SERVER, h), false);","atom":"a0","author":"init","version":0},{"n":381,"text":"});","atom":"a616","author":"trials","version":61},{"n":382,"text":"","atom":"a616","author":"trials","version":61},{"n":383,"text":"test(\"join and init pick the server in the one order: --server, the folder's, ABSO_SERVER, then prod\", () => {","atom":"a1569","author":"speed","version":156},{"n":384,"text":"\tconst h = home();","atom":"a616","author":"trials","version":61},{"n":385,"text":"\tconst outside = home();","atom":"a1569","author":"speed","version":156},{"n":386,"text":"\tconst args = (server?: string) => ({ positionals: [], flags: new Map(server ? [[\"server\", server]] : []) });","atom":"a616","author":"trials","version":61},{"n":387,"text":"\tconst none = { env: {}, cwd: outside };","atom":"a1569","author":"speed","version":156},{"n":388,"text":"\tassert.equal(serverFrom(args(), none), \"https://api.abso.dev\", \"nothing named: prod\");","atom":"a1569","author":"speed","version":156},{"n":389,"text":"\twriteBox({ ...record, expiresAt: Date.now() + 1e6 }, h);","atom":"a616","author":"trials","version":61},{"n":390,"text":"\tassert.deepEqual(signedInServers(h), [SERVER]);","atom":"a616","author":"trials","version":61},{"n":391,"text":"\tassert.equal(serverFrom(args(), none), \"https://api.abso.dev\", \"a sign-in elsewhere doesn't pick the server\");","atom":"a1569","author":"speed","version":156},{"n":392,"text":"\tassert.deepEqual(signedInServers(h, Date.now() + 2e6), [], \"an expired sign-in doesn't count\");","atom":"a616","author":"trials","version":61},{"n":393,"text":"\tassert.equal(serverFrom(args(), { ...none, env: { ABSO_SERVER: \"https://env.example\" } }), \"https://env.example\");","atom":"a1569","author":"speed","version":156},{"n":394,"text":"\tassert.equal(","atom":"a616","author":"trials","version":61},{"n":395,"text":"\t\tserverFrom(args(\"https://flag.example\"), { ...none, env: { ABSO_SERVER: \"https://env.example\" } }),","atom":"a1569","author":"speed","version":156},{"n":396,"text":"\t\t\"https://flag.example\",","atom":"a616","author":"trials","version":61},{"n":397,"text":"\t);","atom":"a616","author":"trials","version":61},{"n":398,"text":"\tassert.equal(serverFrom(args(SERVER), none), SERVER, \"--server is used as given\");","atom":"a1569","author":"speed","version":156},{"n":399,"text":"});","atom":"a623","author":"trials","version":63},{"n":400,"text":"","atom":"a623","author":"trials","version":63},{"n":401,"text":"test(\"join with no --agent takes the box's name, skips names this box holds, and moves past a taken one\", async () => {","atom":"a628","author":"trials","version":64},{"n":402,"text":"\tconst seen: Seen = [];","atom":"a623","author":"trials","version":63},{"n":403,"text":"\tconst fetcher = server(","atom":"a623","author":"trials","version":63},{"n":404,"text":"\t\t[","atom":"a623","author":"trials","version":63},{"n":405,"text":"\t\t\t[200, { box_id: record.id, agents: [{ project: \"abso\", agent: \"snow\", key_id: \"k_0\" }] }],","atom":"a623","author":"trials","version":63},{"n":406,"text":"\t\t\t[409, { error: \"that agent name is already in use in this project; pick a new one\" }],","atom":"a623","author":"trials","version":63},{"n":407,"text":"\t\t\t[200, { key: \"abso_sk_new\", id: \"k_3\" }],","atom":"a623","author":"trials","version":63},{"n":408,"text":"\t\t],","atom":"a623","author":"trials","version":63},{"n":409,"text":"\t\tseen,","atom":"a623","author":"trials","version":63},{"n":410,"text":"\t);","atom":"a623","author":"trials","version":63},{"n":411,"text":"\tconst got = await mintFreeName(record, \"abso\", \"snow\", fetcher);","atom":"a623","author":"trials","version":63},{"n":412,"text":"\tassert.deepEqual(got, { key: \"abso_sk_new\", id: \"k_3\", agent: \"snow-3\" });","atom":"a623","author":"trials","version":63},{"n":413,"text":"\tassert.deepEqual(","atom":"a623","author":"trials","version":63},{"n":414,"text":"\t\tseen.map((s) => [new URL(s.url).pathname, (s.body as { agent?: string } | null)?.agent ?? null]),","atom":"a623","author":"trials","version":63},{"n":415,"text":"\t\t[","atom":"a623","author":"trials","version":63},{"n":416,"text":"\t\t\t[\"/box\", null],","atom":"a623","author":"trials","version":63},{"n":417,"text":"\t\t\t[\"/box/agent-key\", \"snow-2\"],","atom":"a623","author":"trials","version":63},{"n":418,"text":"\t\t\t[\"/box/agent-key\", \"snow-3\"],","atom":"a623","author":"trials","version":63},{"n":419,"text":"\t\t],","atom":"a623","author":"trials","version":63},{"n":420,"text":"\t\t\"snow is this box's already: never minted again, which would replace its key\",","atom":"a623","author":"trials","version":63},{"n":421,"text":"\t);","atom":"a2075","author":"box-grants","version":185},{"n":422,"text":"});","atom":"a2075","author":"box-grants","version":185},{"n":423,"text":"","atom":"a2075","author":"box-grants","version":185},{"n":424,"text":"test(\"abso init from a box (abso 663): one key for every try, waiting out a pending create; abso box says all projects\", async () => {","atom":"a2075","author":"box-grants","version":185},{"n":425,"text":"\tconst record = { server: SERVER, id: \"b_1\", credential: CREDENTIAL, grant, expiresAt: Date.now() + 86_400_000 };","atom":"a2075","author":"box-grants","version":185},{"n":426,"text":"\tconst seen: { path: string; key: string | null; auth: string | null; body: string }[] = [];","atom":"a2075","author":"box-grants","version":185},{"n":427,"text":"\tlet calls = 0;","atom":"a2075","author":"box-grants","version":185},{"n":428,"text":"\tconst fetcher = (async (url: string | URL | Request, init?: RequestInit) => {","atom":"a2075","author":"box-grants","version":185},{"n":429,"text":"\t\tconst headers = new Headers(init?.headers);","atom":"a2075","author":"box-grants","version":185},{"n":430,"text":"\t\tseen.push({","atom":"a2075","author":"box-grants","version":185},{"n":431,"text":"\t\t\tpath: new URL(String(url)).pathname,","atom":"a2075","author":"box-grants","version":185},{"n":432,"text":"\t\t\tkey: headers.get(\"idempotency-key\"),","atom":"a2075","author":"box-grants","version":185},{"n":433,"text":"\t\t\tauth: headers.get(\"authorization\"),","atom":"a2075","author":"box-grants","version":185},{"n":434,"text":"\t\t\tbody: String(init?.body),","atom":"a2075","author":"box-grants","version":185},{"n":435,"text":"\t\t});","atom":"a2075","author":"box-grants","version":185},{"n":436,"text":"\t\tcalls++;","atom":"a2075","author":"box-grants","version":185},{"n":437,"text":"\t\tconst body =","atom":"a2075","author":"box-grants","version":185},{"n":438,"text":"\t\t\tcalls < 3","atom":"a2075","author":"box-grants","version":185},{"n":439,"text":"\t\t\t\t? { operation: { id: \"op\", state: \"pending\" } }","atom":"a2075","author":"box-grants","version":185},{"n":440,"text":"\t\t\t\t: { project: \"made\", id: \"proj_1\", visibility: \"private\" };","atom":"a2075","author":"box-grants","version":185},{"n":441,"text":"\t\treturn new Response(JSON.stringify(body), { status: calls < 3 ? 202 : 200 });","atom":"a2075","author":"box-grants","version":185},{"n":442,"text":"\t}) as typeof fetch;","atom":"a2075","author":"box-grants","version":185},{"n":443,"text":"\tconst made = await boxCreateProject(","atom":"a2075","author":"box-grants","version":185},{"n":444,"text":"\t\trecord,","atom":"a2075","author":"box-grants","version":185},{"n":445,"text":"\t\t{ name: \"made\", files: [{ path: \"a.txt\", text: \"hi\\n\" }] },","atom":"a2075","author":"box-grants","version":185},{"n":446,"text":"\t\t\"33333333-3333-4333-8333-333333333333\",","atom":"a2075","author":"box-grants","version":185},{"n":447,"text":"\t\tfetcher,","atom":"a2075","author":"box-grants","version":185},{"n":448,"text":"\t\tasync () => {},","atom":"a2075","author":"box-grants","version":185},{"n":449,"text":"\t);","atom":"a2075","author":"box-grants","version":185},{"n":450,"text":"\tassert.equal(made.id, \"proj_1\");","atom":"a2075","author":"box-grants","version":185},{"n":451,"text":"\tassert.equal(seen.length, 3);","atom":"a2075","author":"box-grants","version":185},{"n":452,"text":"\tassert.ok(seen.every((s) => s.path === \"/box/projects\" && s.key === \"33333333-3333-4333-8333-333333333333\"));","atom":"a2075","author":"box-grants","version":185},{"n":453,"text":"\tassert.ok(seen.every((s) => s.auth === `Box ${CREDENTIAL}`));","atom":"a2075","author":"box-grants","version":185},{"n":454,"text":"\tassert.deepEqual(JSON.parse(seen[0]!.body), { name: \"made\", files: [{ path: \"a.txt\", text: \"hi\\n\" }] });","atom":"a2075","author":"box-grants","version":185},{"n":455,"text":"\tconst all = { ...record, grant: { projects: [], scopes: [{ kind: \"member-all\", role: \"writer\" }] } };","atom":"a2075","author":"box-grants","version":185},{"n":456,"text":"\tassert.match(","atom":"a2075","author":"box-grants","version":185},{"n":457,"text":"\t\tboxText(all, SERVER),","atom":"a2075","author":"box-grants","version":185},{"n":458,"text":"\t\t/Projects: all of yours, now and later \\(writer at most\\)\\. abso init makes a new one/,","atom":"a2075","author":"box-grants","version":185},{"n":459,"text":"\t);","atom":"a623","author":"trials","version":63},{"n":460,"text":"});","atom":"a0","author":"init","version":0},{"n":461,"text":"","atom":"a2639","author":"approvals-page","version":259},{"n":462,"text":"// abso 684: in an agent's folder, login asks a person in the project instead of relaying the code.","atom":"a2639","author":"approvals-page","version":259},{"n":463,"text":"function askedOf(withdrawn: number[]): NonNullable<Parameters<typeof login>[1][\"ask\"]> {","atom":"a2639","author":"approvals-page","version":259},{"n":464,"text":"\treturn async ({ device, user }) => {","atom":"a2639","author":"approvals-page","version":259},{"n":465,"text":"\t\tassert.equal(device, started.device_code, \"the ask is made with this client's own device code\");","atom":"a2639","author":"approvals-page","version":259},{"n":466,"text":"\t\tassert.equal(user, started.user_code);","atom":"a2639","author":"approvals-page","version":259},{"n":467,"text":"\t\treturn {","atom":"a2639","author":"approvals-page","version":259},{"n":468,"text":"\t\t\tproject: \"abso\",","atom":"a2639","author":"approvals-page","version":259},{"n":469,"text":"\t\t\twho: \"the person who approved this agent's box\",","atom":"a2639","author":"approvals-page","version":259},{"n":470,"text":"\t\t\tasks: [41],","atom":"a2639","author":"approvals-page","version":259},{"n":471,"text":"\t\t\texpiresAt: Date.parse(\"2026-10-15T19:30:00Z\"),","atom":"a2639","author":"approvals-page","version":259},{"n":472,"text":"\t\t\trole: \"writer\",","atom":"a2639","author":"approvals-page","version":259},{"n":473,"text":"\t\t\twithdraw: async () => void withdrawn.push(41),","atom":"a2639","author":"approvals-page","version":259},{"n":474,"text":"\t\t};","atom":"a2639","author":"approvals-page","version":259},{"n":475,"text":"\t};","atom":"a2639","author":"approvals-page","version":259},{"n":476,"text":"}","atom":"a2639","author":"approvals-page","version":259},{"n":477,"text":"","atom":"a2639","author":"approvals-page","version":259},{"n":478,"text":"test(\"an asked login says who was asked and until when, and doesn't lead with the code (abso 684)\", async () => {","atom":"a2639","author":"approvals-page","version":259},{"n":479,"text":"\tconst said: string[] = [];","atom":"a2639","author":"approvals-page","version":259},{"n":480,"text":"\tconst c = clock();","atom":"a2639","author":"approvals-page","version":259},{"n":481,"text":"\tawait login(","atom":"a2639","author":"approvals-page","version":259},{"n":482,"text":"\t\tSERVER,","atom":"a2639","author":"approvals-page","version":259},{"n":483,"text":"\t\t{","atom":"a2639","author":"approvals-page","version":259},{"n":484,"text":"\t\t\task: askedOf([]),","atom":"a2639","author":"approvals-page","version":259},{"n":485,"text":"\t\t\tfetch: server(","atom":"a2639","author":"approvals-page","version":259},{"n":486,"text":"\t\t\t\t[","atom":"a2639","author":"approvals-page","version":259},{"n":487,"text":"\t\t\t\t\t[200, started],","atom":"a2639","author":"approvals-page","version":259},{"n":488,"text":"\t\t\t\t\t[200, { box_id: \"b_test\", box_token: CREDENTIAL, expires_at: EXPIRES, grant: { projects: [] } }],","atom":"a2639","author":"approvals-page","version":259},{"n":489,"text":"\t\t\t\t],","atom":"a2639","author":"approvals-page","version":259},{"n":490,"text":"\t\t\t\t[],","atom":"a2639","author":"approvals-page","version":259},{"n":491,"text":"\t\t\t),","atom":"a2639","author":"approvals-page","version":259},{"n":492,"text":"\t\t\tsleep: c.sleep,","atom":"a2639","author":"approvals-page","version":259},{"n":493,"text":"\t\t\tnow: c.now,","atom":"a2639","author":"approvals-page","version":259},{"n":494,"text":"\t\t\tsay: (line) => said.push(line),","atom":"a2639","author":"approvals-page","version":259},{"n":495,"text":"\t\t},","atom":"a2639","author":"approvals-page","version":259},{"n":496,"text":"\t\thome(),","atom":"a2639","author":"approvals-page","version":259},{"n":497,"text":"\t);","atom":"a2639","author":"approvals-page","version":259},{"n":498,"text":"\tassert.match(","atom":"a2639","author":"approvals-page","version":259},{"n":499,"text":"\t\tsaid[0]!,","atom":"a2639","author":"approvals-page","version":259},{"n":500,"text":"\t\t/^Asked the person who approved this agent's box \\(ask 41 in abso\\) to sign this box in, as at most writer\\.$/,","atom":"a2639","author":"approvals-page","version":259},{"n":501,"text":"\t);","atom":"a2639","author":"approvals-page","version":259},{"n":502,"text":"\tassert.match(said[1]!, /^Waiting for their answer, until .* CT\\. To approve it yourself instead: /);","atom":"a2639","author":"approvals-page","version":259},{"n":503,"text":"\tassert.doesNotMatch(said.join(\"\\n\"), /approve the code/);","atom":"a2639","author":"approvals-page","version":259},{"n":504,"text":"});","atom":"a2639","author":"approvals-page","version":259},{"n":505,"text":"","atom":"a2639","author":"approvals-page","version":259},{"n":506,"text":"test(\"an asked login that's turned down says who turned it down (abso 684)\", async () => {","atom":"a2639","author":"approvals-page","version":259},{"n":507,"text":"\tconst c = clock();","atom":"a2639","author":"approvals-page","version":259},{"n":508,"text":"\tawait assert.rejects(","atom":"a2639","author":"approvals-page","version":259},{"n":509,"text":"\t\tlogin(","atom":"a2639","author":"approvals-page","version":259},{"n":510,"text":"\t\t\tSERVER,","atom":"a2639","author":"approvals-page","version":259},{"n":511,"text":"\t\t\t{","atom":"a2639","author":"approvals-page","version":259},{"n":512,"text":"\t\t\t\task: askedOf([]),","atom":"a2639","author":"approvals-page","version":259},{"n":513,"text":"\t\t\t\tfetch: server(","atom":"a2639","author":"approvals-page","version":259},{"n":514,"text":"\t\t\t\t\t[","atom":"a2639","author":"approvals-page","version":259},{"n":515,"text":"\t\t\t\t\t\t[200, started],","atom":"a2639","author":"approvals-page","version":259},{"n":516,"text":"\t\t\t\t\t\t[400, { error: \"access_denied\" }],","atom":"a2639","author":"approvals-page","version":259},{"n":517,"text":"\t\t\t\t\t],","atom":"a2639","author":"approvals-page","version":259},{"n":518,"text":"\t\t\t\t\t[],","atom":"a2639","author":"approvals-page","version":259},{"n":519,"text":"\t\t\t\t),","atom":"a2639","author":"approvals-page","version":259},{"n":520,"text":"\t\t\t\tsleep: c.sleep,","atom":"a2639","author":"approvals-page","version":259},{"n":521,"text":"\t\t\t\tnow: c.now,","atom":"a2639","author":"approvals-page","version":259},{"n":522,"text":"\t\t\t\tsay: () => {},","atom":"a2639","author":"approvals-page","version":259},{"n":523,"text":"\t\t\t},","atom":"a2639","author":"approvals-page","version":259},{"n":524,"text":"\t\t\thome(),","atom":"a2639","author":"approvals-page","version":259},{"n":525,"text":"\t\t),","atom":"a2639","author":"approvals-page","version":259},{"n":526,"text":"\t\t/the person who approved this agent's box turned this sign-in down/,","atom":"a2639","author":"approvals-page","version":259},{"n":527,"text":"\t);","atom":"a2639","author":"approvals-page","version":259},{"n":528,"text":"});","atom":"a2639","author":"approvals-page","version":259},{"n":529,"text":"","atom":"a2639","author":"approvals-page","version":259},{"n":530,"text":"test(\"an asked login that nobody answers withdraws its ask and grants nothing (abso 684)\", async () => {","atom":"a2639","author":"approvals-page","version":259},{"n":531,"text":"\tconst withdrawn: number[] = [];","atom":"a2639","author":"approvals-page","version":259},{"n":532,"text":"\tconst c = clock();","atom":"a2639","author":"approvals-page","version":259},{"n":533,"text":"\tawait assert.rejects(","atom":"a2639","author":"approvals-page","version":259},{"n":534,"text":"\t\tlogin(","atom":"a2639","author":"approvals-page","version":259},{"n":535,"text":"\t\t\tSERVER,","atom":"a2639","author":"approvals-page","version":259},{"n":536,"text":"\t\t\t{","atom":"a2639","author":"approvals-page","version":259},{"n":537,"text":"\t\t\t\task: askedOf(withdrawn),","atom":"a2639","author":"approvals-page","version":259},{"n":538,"text":"\t\t\t\tfetch: server(","atom":"a2639","author":"approvals-page","version":259},{"n":539,"text":"\t\t\t\t\t[","atom":"a2639","author":"approvals-page","version":259},{"n":540,"text":"\t\t\t\t\t\t[200, started],","atom":"a2639","author":"approvals-page","version":259},{"n":541,"text":"\t\t\t\t\t\t[400, { error: \"expired_token\" }],","atom":"a2639","author":"approvals-page","version":259},{"n":542,"text":"\t\t\t\t\t],","atom":"a2639","author":"approvals-page","version":259},{"n":543,"text":"\t\t\t\t\t[],","atom":"a2639","author":"approvals-page","version":259},{"n":544,"text":"\t\t\t\t),","atom":"a2639","author":"approvals-page","version":259},{"n":545,"text":"\t\t\t\tsleep: c.sleep,","atom":"a2639","author":"approvals-page","version":259},{"n":546,"text":"\t\t\t\tnow: c.now,","atom":"a2639","author":"approvals-page","version":259},{"n":547,"text":"\t\t\t\tsay: () => {},","atom":"a2639","author":"approvals-page","version":259},{"n":548,"text":"\t\t\t},","atom":"a2639","author":"approvals-page","version":259},{"n":549,"text":"\t\t\thome(),","atom":"a2639","author":"approvals-page","version":259},{"n":550,"text":"\t\t),","atom":"a2639","author":"approvals-page","version":259},{"n":551,"text":"\t\t/nobody answered in time, so nothing was granted/,","atom":"a2639","author":"approvals-page","version":259},{"n":552,"text":"\t);","atom":"a2639","author":"approvals-page","version":259},{"n":553,"text":"\tassert.deepEqual(withdrawn, [41]);","atom":"a2639","author":"approvals-page","version":259},{"n":554,"text":"});","atom":"a2639","author":"approvals-page","version":259}],"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":"a116","author":"review","message":"","time":1791522261912,"timeIso":"2026-10-09T05:04:21.912Z","publish":{"draft":null,"version":17,"agent":"review","message":"New folders keep their state in .abso/, and the machine's sign-in, servers and admin token are read from ~/.abso/ first, then ~/.avcs/. A folder made before, with only .avcs/, is untouched: it keeps working, is never half-moved, and no older client or mod loses it. stateDir(root) and homeFile/homeWritePath are in the new client/src/state-dir.ts and replace the old AVCS_DIR constant everywhere. abso login writes only to ~/.abso/ and leaves ~/.avcs/ alone; logout removes both copies. The edit mod and the view mod read either folder. .abso is skipped like .avcs (including its odd spellings), the git exclude names whichever folder is in use, and the messages name .abso. Not changed: avcs.json (the server reads that name, so abso.json needs the server to learn it first), .avcsignore, env var names and wire headers. Tests: 709 run, 708 pass (one is skipped), including new ones for the folder choice, the home-file order and box sign-in; biome ci has no errors.","time":1791522270512,"timeIso":"2026-10-09T05:04:30.512Z"}},{"atom":"a586","author":"pinch","message":"","time":1791598040070,"timeIso":"2026-10-10T02:07:20.070Z","publish":{"draft":null,"version":58,"agent":"pinch","message":"abso login says it is waiting for approval, and that Ctrl-C stops it, then says it is still waiting about once a minute. It stops by itself when the code runs out, and never waits past 30 minutes whatever the server's expires_in says. A login that said nothing for 15 minutes looked like a hang.","time":1791598042242,"timeIso":"2026-10-10T02:07:22.242Z"}},{"atom":"a609","author":"speed","message":"","time":1791600855389,"timeIso":"2026-10-10T02:54:15.389Z","publish":{"draft":null,"version":60,"agent":"speed","message":"abso login opens the approve page in the browser\n\nLike gh auth login and wrangler login: abso login opens the approve page in the default browser with the code already in it, so nobody copies a link by hand. It still prints the link and the code, which stand when the open fails or is skipped.\n\n- Windows opens with rundll32 url.dll,FileProtocolHandler, macOS with open, Linux with xdg-open. There's no shell, so a link with & in it arrives whole (cmd's start would cut it).\n- No browser with --no-browser or ABSO_NO_BROWSER, over SSH (SSH_CONNECTION or SSH_TTY), under CI, or on Linux and other Unixes with neither DISPLAY nor WAYLAND_DISPLAY.\n- Only http and https links are opened, so a link from a server is never handed to the desktop as a file or a program.\n- The opener starts detached and isn't waited on; a failure is silent.\n\nTests: open-browser.test.ts (each skip, each platform's command, web links only, a failing opener is silent), and two login tests with an injected opener.","time":1791600855763,"timeIso":"2026-10-10T02:54:15.763Z"}},{"atom":"a616","author":"trials","message":"","time":1791600856656,"timeIso":"2026-10-10T02:54:16.656Z","publish":{"draft":null,"version":61,"agent":"trials","message":"abso join and abso init no longer need --server (abso issue 349): --server, then ABSO_SERVER, then the server this box signed in to with abso login, then https://api.abso.dev. A box signed in to more than one server is asked to say which. Usage, about text and the README's join line updated; box.test.ts covers the order.","time":1791600859268,"timeIso":"2026-10-10T02:54:19.268Z"}},{"atom":"a623","author":"trials","message":"","time":1791601554431,"timeIso":"2026-10-10T03:05:54.431Z","publish":{"draft":null,"version":63,"agent":"trials","message":"abso join <project> works with no --agent and no --dir (abso issue 351), so the project page can show npx abso-cli join <project>.\n\n- Agent: the box's name (the hostname abso login sends), lower-cased; if taken, <name>-2, -3, up to 20 tries. Names this box already holds in the project (GET /box) are skipped without minting, since minting one again replaces that agent's key and would cut off its folder. A 409 for a taken name moves on; the agent-limit 409 says the limit and where to revoke. No box sign-in: abso login first, or --agent.\n- Folder: --dir, else here when empty, else ./<project>, which must be new or empty; it prints cd <folder> when it isn't here.\n- --agent, --dir and --server still win. Project names are checked before use as a folder.\nTests: box.test.ts (mintFreeName: held name skipped, 409 moves on, agent limit), client.test.ts (empty folder, ./<project>, refusing a non-empty one); the git line-endings test now joins with --dir . since its folder has files.","time":1791601556423,"timeIso":"2026-10-10T03:05:56.423Z"}},{"atom":"a628","author":"trials","message":"","time":1791601972847,"timeIso":"2026-10-10T03:12:52.847Z","publish":{"draft":null,"version":64,"agent":"trials","message":"join: a folder prepared with abso key install --server is joined where it is again (Pinch's catch on 63).\n\n- --agent keeps 'here' as the default, as before 63, so scripts that join into a prepared folder still do. The ./<project> rule is only for a join with no --agent.\n- A folder holding only abso's own state folder (.abso, or the older .avcs) counts as empty.\n- New tests: joinFolder's rule (empty, only .abso, files here, --agent, --dir, a taken ./<project>), and a runJoin test that installs a key with --server and joins with --agent and no --dir: it joins here and sends that key (the shared token is wrong, so only the key gets through). The git line-endings test is back to joining without --dir.\n- Issue numbers taken out of the new code comments and test names.","time":1791601975047,"timeIso":"2026-10-10T03:12:55.047Z"}},{"atom":"a922","author":"codex-mac-1","message":"","time":1791680677633,"timeIso":"2026-10-11T01:04:37.633Z","publish":{"draft":null,"version":102,"agent":"codex-mac-1","message":"Let login request projects, roles, agent limits and duration","time":1791680699999,"timeIso":"2026-10-11T01:04:59.999Z"}},{"atom":"a1569","author":"speed","message":"","time":1791913878674,"timeIso":"2026-10-13T17:51:18.674Z","publish":{"draft":null,"version":156,"agent":"speed","message":"With nothing naming a server, the client now uses prod (https://api.abso.dev). Every command picks its server in one order: --server, else the joined folder's own server, else ABSO_SERVER, else prod. Which servers this box is signed in to no longer picks one, so a box signed in to staging and prod both, or to staging alone, goes to prod instead of refusing or quietly using staging; staging is a deliberate --server, a joined staging folder, or ABSO_SERVER. An explicit choice is used as given. A malformed ABSO_SERVER is refused like a malformed --server. When this box isn't signed in to the chosen server but is to others, whoami and join name them and how to pick one. Help states the order for every command that picks its server. For abso-core issue 9.","time":1791913882665,"timeIso":"2026-10-13T17:51:22.665Z"}},{"atom":"a1850","author":"open","message":"","time":1791965038684,"timeIso":"2026-10-14T08:03:58.684Z","publish":{"draft":null,"version":171,"agent":"open","message":"abso login drops --max-agents (abso ask 1947; Christopher, 2026-10-14: no arbitrary free limits). A box lets in any number of agents (the server stopped enforcing max_agents in abso 642): abso box no longer prints 'Up to N agents', the 'agent limit' 409 message is gone, and a stored grant without max_agents reads fine. Instant cutover, no alias. Bundle rebuilt.","time":1791965043647,"timeIso":"2026-10-14T08:04:03.647Z"}},{"atom":"a2075","author":"box-grants","message":"","time":1791994802453,"timeIso":"2026-10-14T16:20:02.453Z","publish":{"draft":null,"version":185,"agent":"box-grants","message":"abso init, init --org and org new from a signed-in box (abso 663). On a server this box is signed in to and with no token for it, abso init makes the project as the person who approved the box, through the server's POST /box/projects (the website's own create): its folder (up to 24 MB) is the first version, --public or --private picks visibility (private by default), --org makes it an organization's project, and one Idempotency-Key per folder (kept in .abso/init-key until it finishes) makes a retry the same project. The folder then joins at once with its own key from the box (--agent, else the box's name). abso org new <name> [--name] makes an organization through POST /box/orgs. abso box and login say 'all of yours, now and later' for a member-all grant. Without a box, init and init --org say to abso login. Tests: orgs, box, help; full suite passes.","time":1791994804231,"timeIso":"2026-10-14T16:20:04.231Z"}},{"atom":"a2639","author":"approvals-page","message":"","time":1792092902455,"timeIso":"2026-10-15T19:35:02.455Z","publish":{"draft":null,"version":259,"agent":"approvals-page","message":"Box sign-ins asked of a person (abso 684, client; Security's yes with changes on ask 2097). In an agent's folder on the same server, abso login also asks a person in that project to approve it, through POST /login/ask with the folder's agent key and this client's own device code, then an ordinary abso ask (to person:<id>) with the request link, linked with /login/ask/link. It says who it asked and until when, keeps the code link as a fallback, says who turned it down on a deny, and withdraws its ask when nobody answers in time. --no-ask shows the code only. Tests: client/test/box.test.ts, three new (abso 684).","time":1792093041064,"timeIso":"2026-10-15T19:37:21.064Z"}}]}