Versions 302 to 318
Lines 154–164 at 318 (were 154–159 at 302)
157+ // Checked before any call: a name like ".." would otherwise go out as part of the request's path.
160+ `project names are letters, digits, dot, dash and underscore (got ${JSON.stringify(project)})`,
157162 if (bool(args, "public") && bool(args, "private")) throw new UsageError("--public or --private, not both");
159164 // A box signed in here, and no other credential asked for: the project is made as the person who approved the box,
Lines 79–85 at 318 (were 79–85 at 302)
82−import { handoffText, patFromFile, siteFor, webHandoff } from "./web-session.ts";
8383
Lines 218–243 at 318 (were 218–236 at 302)
221− "abso login [--no-browser] [--no-ask] [--projects <name,name>] [--role <reader|writer|owner>] [--days <1-90>] | abso login --web [--pat-file <file>] [--site <url>]",
221+ "abso login [--no-browser] [--no-ask] [--projects <name,name>] [--role <reader|writer|owner>] [--days <1-90>] | abso login --web [--pat-file <file> [--site http://localhost:<port>]]",
223− "Sign this box in once: it opens the approve page in your browser with the code filled in, prints the link and the code too, and waits while a person approves the code on the website, choosing the projects, the highest role and how long. Then abso join in any of those projects gives each agent its own key, with no approval. The box's sign-in is kept in your user folder, never in a project folder, and is never printed. No browser opens with --no-browser or ABSO_NO_BROWSER, over SSH, under CI, or on Linux without a display. In an agent's folder on the same server, it also asks a person in that project to approve it (the person who approved the agent's box, else the project's owners), as an abso ask, so nobody has to relay the code; the box can then be granted that project at no more than the agent's own role. --no-ask shows the code only. --web, on staging only, signs a browser in to the website instead: it prints a link that works once, within a minute, and signs whichever browser opens it in as the person who approved this box (or, with --pat-file, the test account whose PAT that file holds). The box's sign-in, the PAT and the session never appear; agents never sign in to the website on prod.",
223+ "Sign this box in once: it opens the approve page in your browser with the code filled in, prints the link and the code too, and waits while a person approves the code on the website, choosing the projects, the highest role and how long. Then abso join in any of those projects gives each agent its own key, with no approval. The box's sign-in is kept in your user folder, never in a project folder, and is never printed. No browser opens with --no-browser or ABSO_NO_BROWSER, over SSH, under CI, or on Linux without a display. In an agent's folder on the same server, it also asks a person in that project to approve it (the person who approved the agent's box, else the project's owners), as an abso ask, so nobody has to relay the code; the box can then be granted that project at no more than the agent's own role. --no-ask shows the code only. --web, on staging only, signs a browser in to the website instead: it prints a link that works once, within a minute, and signs whichever browser opens it in as the person who approved this box, but only to the projects the box was granted and at most as a writer, until the box is revoked or ends (or, with --pat-file, as the test account whose PAT that file holds, at most as a writer). It writes issues, replies, answers, groups and announcements, and changes no members, roles, visibility, keys, boxes or settings. The box's sign-in, the PAT and the session never appear. It goes only to the staging website beside this folder's staging server; any other server, prod included, is refused and nothing is sent. --site, with --pat-file only, points it at a website on this machine (http://localhost or 127.0.0.1).",
227− const site = siteFor(server, str(args, "site"));
229− const record = patFile === undefined ? readBox(server) : undefined;
230− if (patFile === undefined && (record === undefined || record.expiresAt <= Date.now()))
231− throw new UsageError(`this box isn't signed in to ${server}: abso login first, or --pat-file <file>`);
232− const handoff = await webHandoff(site, patFile === undefined ? record!.credential : patFromFile(patFile));
233− return { text: handoffText(handoff, site), json: { ...handoff } };
236+ throw new UsageError(`this box isn't signed in to ${server}: abso login first, or --pat-file <file>`);
Lines 21–71 at 318 (were 21–50 at 302)
2323
24−/** The website a server's handoff goes to: --site as given (https only), else the staging site beside it. */
25−export function siteFor(server: string, site?: string): string {
26− if (site !== undefined) {
27− let url: URL;
28− try {
29− url = new URL(site);
30− } catch {
31− throw new UsageError(
32− `--site takes the website's address, like https://abso-website-staging.chrisazy.workers.dev`,
33− );
34− }
35− if (url.protocol !== "https:" && url.hostname !== "localhost" && url.hostname !== "127.0.0.1")
36− throw new UsageError("--site has to be https, or this machine");
37− return url.origin;
38− }
25+ * The website a handoff's credential goes to (Security condition 6, Code Review): the staging website beside the folder's own
26+ * staging server, from the fixed list above, and never an origin from a flag. A server that isn't on the list is refused,
27+ * prod included. --site is only for a test account's PAT on this machine (http://localhost or 127.0.0.1); a box's sign-in
43− `abso login --web is for staging: ${origin} has no staging website beside it that abso knows, and agents never sign in to the website on prod. --site names one.`,
35+ `abso login --web is for staging: ${origin} has no staging website beside it that abso knows, and agents never sign in to the website on prod. Nothing was sent.`,
45− return known;
39+ throw new UsageError(`--site isn't taken with a box's sign-in, which goes only to ${known}. Nothing was sent.`);
46+ if (url === null || url.protocol !== "http:" || (url.hostname !== "localhost" && url.hostname !== "127.0.0.1"))
48+ "--site, with --pat-file, names this machine only (http://localhost:<port> or http://127.0.0.1:<port>). Nothing was sent.",
4752
54+ * abso login --web: where the credential would go is settled before it is read, so a refusal reads and sends nothing
55+ * (Security). `credential` reads the box's sign-in or the PAT only once the website is one it may go to.
68+
Lines 128–141 at 318 (were 107–117 at 302)
109130
110−/** What abso login --web says: the one link, how long it works, and who it signs in as. */
111−export function handoffText(h: Handoff, site: string, now = Date.now()): string {
131+/** What abso login --web says: the one link, how long it works, who it signs in as, and what it reaches (Security). */
135+ ? "only to the projects this box was granted, at most as a writer, until the box is revoked or ends"
114− `Open this link in your browser within ${seconds} seconds. It signs that browser in to ${site} as ${h.name}, until ${h.sessionEnds}, and works once:`,
138+ `Open this link in your browser within ${seconds} seconds. It signs that browser in to ${site} as ${h.name}, until ${h.sessionEnds}, and works once. It reaches ${reach}:`,
Lines 4–10 at 318 (were 4–10 at 302)
44
7−import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
7+import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
Lines 145–158 at 318 (were 145–153 at 302)
145145 it("a project's name can't start with a dot, so its folder stays inside the store", async () => {
148− const r = await run(dir, "init", "--local", "--project", "..", "--agent", "a");
149− assert.notEqual(r.exit, 0);
153158
Lines 5–57 at 318 (were 5–24 at 302)
8−import { handoffText, patFromFile, siteFor, webHandoff } from "../src/web-session.ts";
99
1315
14−test("the website is the staging one beside the server, or --site; prod has none, since agents never sign in there", () => {
15− assert.equal(siteFor("https://abso-staging.chrisazy.workers.dev"), SITE);
16− assert.equal(siteFor("https://avcs-staging.chrisazy.workers.dev/"), SITE);
17− assert.throws(() => siteFor("https://api.abso.dev"), /for staging.*never sign in to the website on prod/);
18− assert.equal(siteFor("https://api.abso.dev", "http://localhost:8871/x"), "http://localhost:8871");
19− assert.throws(() => siteFor("https://api.abso.dev", "http://elsewhere.example"), /https/);
16+test("the credential goes only to the staging website beside the folder's staging server (Security condition 6)", () => {
24+ assert.throws(() => siteFor("https://api.abso.dev", "http://localhost:8871", "pat"), /for staging/);
27+ assert.throws(() => siteFor(STAGING, "http://localhost:8871", "box"), /isn't taken with a box's sign-in/);
31+ for (const elsewhere of ["https://anywhere.example", SITE, "https://localhost:8871", "not a url"])
2134
37+ const fetcher = (async (url: string) => (sent.push(url), Response.json({}))) as unknown as typeof fetch;
47+ await assert.rejects(webLogin({ ...asked, credential, fetcher }), /Nothing was sent/, JSON.stringify(asked));
51+ await webLogin({ server: STAGING, site: undefined, kind: "pat", credential: () => PAT, fetcher }).catch(() => {});
54+
2255test("the credential goes in Authorization only, and the answer is the one link and who it signs in as", async () => {
Lines 66–76 at 318 (were 33–41 at 302)
3568 assert.deepEqual(seen, [{ url: `${SITE}/login/handoff`, authorization: `Bearer ${BOX}`, body: null }]);
36− const text = handoffText(h, SITE, NOW);
- MCP
- compare on this site's /mcp
- CLI
- abso diff 302 318 client --json
- JSON
- /christopher/abso-core/compare/302..318?file=client&format=json