Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed
MCP
show on this site's /mcp
CLI
abso show 58 --json
JSON
/christopher/abso-core/versions/58?format=json

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.

of shared·pinch··Not checked

Version 57 · Files at version 58

2 files, 38 lines added, 1 removed.

--- a/client/src/box.ts
+++ b/client/src/box.ts
@@ -174,6 +174,11 @@
174174 );
175175}
176176
177+/** The longest login waits for approval, whatever the server says. */
178+const MAX_LOGIN_WAIT_S = 30 * 60;
179+/** How often login says it's still waiting. */
180+const STILL_WAITING_MS = 60_000;
177182export interface LoginIo {
178183 readonly fetch?: typeof fetch;
179184 readonly sleep?: (ms: number) => Promise<void>;
@@ -193,13 +198,21 @@
193198 const start = await call(server, "/login/device", { name: boxName(), client: "abso" }, undefined, fetcher);
194199 const { device_code: device, user_code: code, verification_uri_complete: link } = start.body;
195200 let interval = Number(start.body.interval) || 5;
196− const expiresIn = Number(start.body.expires_in) || 900;
201+ // The server says when its code runs out; a server that says never still gets an end.
202+ const expiresIn = Math.min(Number(start.body.expires_in) || 900, MAX_LOGIN_WAIT_S);
197203 if (typeof code !== "string" || typeof link !== "string" || typeof device !== "string")
198204 throw new UsageError(`${originOf(server)} didn't give a code to approve`);
199205 io.say(`To sign this box in, open ${link} and approve the code ${code}.`);
206+ io.say("Waiting for approval. Ctrl-C stops waiting, and abso stops by itself when the code runs out.");
200207 const until = now() + expiresIn * 1000;
208+ let toldAt = now();
201209 while (now() < until) {
202210 await sleep(interval * 1000);
211+ // A wait with no word looks like a hang, so say it's still waiting now and then.
212+ if (now() - toldAt >= STILL_WAITING_MS) {
213+ io.say(`Still waiting for the code ${code} to be approved.`);
214+ toldAt = now();
215+ }
203216 const a = await call(server, "/login/token", { device_code: device }, undefined, fetcher);
204217 if (a.status === 400) {
205218 if (a.body.error === "authorization_pending") continue;
--- a/client/test/box.test.ts
+++ b/client/test/box.test.ts
@@ -91,6 +91,7 @@
9191 );
9292 assert.deepEqual(said, [
9393 "To sign this box in, open https://abso.dev/login/box?code=WXYZ-BCDF and approve the code WXYZ-BCDF.",
94+ "Waiting for approval. Ctrl-C stops waiting, and abso stops by itself when the code runs out.",
9495 ]);
9596 assert.equal(readBox(SERVER, h)?.credential, CREDENTIAL);
9697 const files = readdirSync(join(h, ".abso", "boxes"));
@@ -160,6 +161,29 @@
160161 assert.equal(readBox(SERVER, h), undefined);
161162});
162163
164+test("login says it's still waiting about once a minute, and stops in the end whatever the server says", async () => {
165+ const c = clock();
166+ const said: string[] = [];
167+ const pending = Array.from({ length: 2000 }, (): [number, unknown] => [400, { error: "authorization_pending" }]);
168+ await assert.rejects(
169+ login(
170+ SERVER,
171+ {
172+ fetch: server([[200, { ...started, expires_in: 10 ** 9, interval: 5 }], ...pending], []),
173+ sleep: c.sleep,
174+ now: c.now,
175+ say: (line) => said.push(line),
176+ },
177+ home(),
178+ ),
179+ /nobody approved the code WXYZ-BCDF in time\. Run abso login again\./,
180+ );
181+ assert.equal(c.slept(), 30 * 60 * 1000, "a server that says never still gets an end");
182+ const still = said.filter((line) => line === "Still waiting for the code WXYZ-BCDF to be approved.");
183+ assert.equal(still.length, 30);
184+ assert.equal(said.length, 2 + 30);
185+});
163187test("a key is minted with the box credential, sent only to the box's own server", async () => {
164188 const seen: Seen = [];
165189 const minted = await mintKey(