@tokenfactory/acc-runner 0.41.7 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +87 -4
  2. package/dist/acc.d.ts +3 -0
  3. package/dist/acc.d.ts.map +1 -0
  4. package/dist/acc.js +21 -0
  5. package/dist/acc.js.map +1 -0
  6. package/dist/cli-name.d.ts +29 -0
  7. package/dist/cli-name.d.ts.map +1 -0
  8. package/dist/cli-name.js +17 -0
  9. package/dist/cli-name.js.map +1 -0
  10. package/dist/cli.d.ts +20 -2
  11. package/dist/cli.d.ts.map +1 -1
  12. package/dist/cli.js +45 -289
  13. package/dist/cli.js.map +1 -1
  14. package/dist/keychain.d.ts +17 -0
  15. package/dist/keychain.d.ts.map +1 -1
  16. package/dist/keychain.js +36 -0
  17. package/dist/keychain.js.map +1 -1
  18. package/dist/login.d.ts +45 -1
  19. package/dist/login.d.ts.map +1 -1
  20. package/dist/login.js +91 -4
  21. package/dist/login.js.map +1 -1
  22. package/dist/program.d.ts +16 -0
  23. package/dist/program.d.ts.map +1 -0
  24. package/dist/program.js +342 -0
  25. package/dist/program.js.map +1 -0
  26. package/dist/user-auth/device-login.d.ts +47 -0
  27. package/dist/user-auth/device-login.d.ts.map +1 -0
  28. package/dist/user-auth/device-login.js +189 -0
  29. package/dist/user-auth/device-login.js.map +1 -0
  30. package/dist/user-auth/liveness.d.ts +27 -0
  31. package/dist/user-auth/liveness.d.ts.map +1 -0
  32. package/dist/user-auth/liveness.js +128 -0
  33. package/dist/user-auth/liveness.js.map +1 -0
  34. package/dist/user-auth/session.d.ts +82 -0
  35. package/dist/user-auth/session.d.ts.map +1 -0
  36. package/dist/user-auth/session.js +172 -0
  37. package/dist/user-auth/session.js.map +1 -0
  38. package/dist/user-cli/chat.d.ts +44 -0
  39. package/dist/user-cli/chat.d.ts.map +1 -0
  40. package/dist/user-cli/chat.js +199 -0
  41. package/dist/user-cli/chat.js.map +1 -0
  42. package/dist/user-cli/client.d.ts +20 -0
  43. package/dist/user-cli/client.d.ts.map +1 -0
  44. package/dist/user-cli/client.js +60 -0
  45. package/dist/user-cli/client.js.map +1 -0
  46. package/dist/user-cli/tasks.d.ts +37 -0
  47. package/dist/user-cli/tasks.d.ts.map +1 -0
  48. package/dist/user-cli/tasks.js +131 -0
  49. package/dist/user-cli/tasks.js.map +1 -0
  50. package/package.json +3 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"program.js","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAoB,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAwB,MAAM,qBAAqB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAA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AE,CAAC,CAAC;QAC7D,OAAO,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,gBAAgB,EAAE,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;IAEL,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,SAAiB;IAC5C,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC9B,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,KAAK,CAAC,KAAK,YAAY,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IACxE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,UAAU,CAAC,OAAgB;IACzC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QAC7C,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAM,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { type GoTrueDeps, type StoredUserSession } from "./session.js";
2
+ export declare const DEVICE_CODE_PATH = "/api/auth/device-code";
3
+ /** Consecutive transient exchange failures tolerated before giving up. */
4
+ export declare const MAX_POLL_FAILURES = 5;
5
+ export interface DeviceLoginDeps extends GoTrueDeps {
6
+ sleep?: (ms: number) => Promise<unknown>;
7
+ openBrowser?: (url: string) => Promise<unknown>;
8
+ log?: (line: string) => void;
9
+ /** Override the polling cadence / deadline (tests). */
10
+ intervalSeconds?: number;
11
+ timeoutSeconds?: number;
12
+ }
13
+ /**
14
+ * Run the whole handshake and return the session, WITHOUT persisting it — so the
15
+ * flow is testable end to end and the keychain write stays one explicit step in
16
+ * the command below.
17
+ *
18
+ * A transient failure (503 `retry`, a cold function, a pooler hiccup) must not
19
+ * abort a login whose code is still valid: it is counted, not fatal, and the
20
+ * real deadline is the code's TTL. This is the DEVICE-BIND-FIX rule the runner
21
+ * lane learned the hard way — only `expired` is terminal.
22
+ */
23
+ export declare function deviceLogin(deps?: DeviceLoginDeps): Promise<StoredUserSession>;
24
+ export declare function authLoginCommand(deps?: DeviceLoginDeps): Promise<void>;
25
+ /**
26
+ * "Am I still signed in?" — which is a question about the SERVER's copy of the
27
+ * session, not this machine's. A keychain entry alone proves nothing: the session
28
+ * may have been revoked from Settings → Sessions while this terminal was closed,
29
+ * and the stored access token would still look perfectly valid. So the local facts
30
+ * are printed first (they work offline) and then the server is asked.
31
+ */
32
+ export declare function authStatusCommand(deps?: DeviceLoginDeps): Promise<void>;
33
+ /**
34
+ * Sign out for real. Deleting the keychain entry alone would leave the session
35
+ * live in `auth.sessions` — visible on the sessions surface, refreshable by
36
+ * anyone who had copied the token. So GoTrue is told first, and the local copy
37
+ * is removed whether or not that call reached it (an offline machine must still
38
+ * be able to drop its credential).
39
+ *
40
+ * `scope=local` is not a nicety, it is the whole contract of this command:
41
+ * GoTrue's default scope is GLOBAL, which would also sign the operator out of
42
+ * their browser and every other terminal. "Log this terminal out" must mean
43
+ * exactly one session — the one this keychain entry holds.
44
+ */
45
+ export declare const LOGOUT_PATH = "/auth/v1/logout?scope=local";
46
+ export declare function authLogoutCommand(deps?: DeviceLoginDeps): Promise<void>;
47
+ //# sourceMappingURL=device-login.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device-login.d.ts","sourceRoot":"","sources":["../../src/user-auth/device-login.ts"],"names":[],"mappings":"AAqBA,OAAO,EAML,KAAK,UAAU,EACf,KAAK,iBAAiB,EACvB,MAAM,cAAc,CAAC;AAGtB,eAAO,MAAM,gBAAgB,0BAA0B,CAAC;AAuBxD,0EAA0E;AAC1E,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC,MAAM,WAAW,eAAgB,SAAQ,UAAU;IACjD,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACzC,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAChD,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,uDAAuD;IACvD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAwBD;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAAC,IAAI,GAAE,eAAoB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAiExF;AAED,wBAAsB,gBAAgB,CAAC,IAAI,GAAE,eAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAahF;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,GAAE,eAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBjF;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,WAAW,gCAAgC,CAAC;AAEzD,wBAAsB,iBAAiB,CAAC,IAAI,GAAE,eAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4BjF"}
@@ -0,0 +1,189 @@
1
+ /**
2
+ * `acc-runner auth login|status|logout` — the device-code flow for a PERSON
3
+ * (AX-G1 DEVICE-FLOW-GENERALIZE, gap G-16).
4
+ *
5
+ * Same three beats as `acc-runner login`, and deliberately so — an operator who
6
+ * has enrolled a runner already knows this flow:
7
+ *
8
+ * 1. ask /api/auth/device-code for a pair, print the short code
9
+ * 2. poll the exchange while the human binds it in a browser
10
+ * 3. spend the returned one-time grant against GoTrue, keychain the session
11
+ *
12
+ * What is NOT here is the fourth beat the runner flow has: no runner row, no
13
+ * `register_runner`, no fleet membership. This terminal is a person, not a
14
+ * machine, and `acc-runner login` is untouched by it.
15
+ */
16
+ import chalk from "chalk";
17
+ import open from "open";
18
+ import { setTimeout as sleep } from "node:timers/promises";
19
+ import { loadConfig } from "../config.js";
20
+ import { cliName, signInCommand } from "../cli-name.js";
21
+ import { PROTOCOL_VERSION } from "../types.js";
22
+ import { clearUserSession, cliUserAgent, loadUserSession, saveUserSession, verifyEmailOtp, } from "./session.js";
23
+ import { probeUserSession, revokedMessage } from "./liveness.js";
24
+ export const DEVICE_CODE_PATH = "/api/auth/device-code";
25
+ /** Consecutive transient exchange failures tolerated before giving up. */
26
+ export const MAX_POLL_FAILURES = 5;
27
+ async function post(doFetch, url, body) {
28
+ const res = await doFetch(url, {
29
+ method: "POST",
30
+ headers: {
31
+ "Content-Type": "application/json",
32
+ "User-Agent": `acc-runner/${PROTOCOL_VERSION}`,
33
+ },
34
+ body: JSON.stringify(body ?? {}),
35
+ });
36
+ let json = {};
37
+ try {
38
+ json = (await res.json());
39
+ }
40
+ catch {
41
+ /* callers judge on status + shape */
42
+ }
43
+ return { status: res.status, json };
44
+ }
45
+ /**
46
+ * Run the whole handshake and return the session, WITHOUT persisting it — so the
47
+ * flow is testable end to end and the keychain write stays one explicit step in
48
+ * the command below.
49
+ *
50
+ * A transient failure (503 `retry`, a cold function, a pooler hiccup) must not
51
+ * abort a login whose code is still valid: it is counted, not fatal, and the
52
+ * real deadline is the code's TTL. This is the DEVICE-BIND-FIX rule the runner
53
+ * lane learned the hard way — only `expired` is terminal.
54
+ */
55
+ export async function deviceLogin(deps = {}) {
56
+ const cfg = loadConfig();
57
+ const doFetch = deps.fetch ?? fetch;
58
+ const nap = deps.sleep ?? ((ms) => sleep(ms));
59
+ const say = deps.log ?? ((line) => console.log(line));
60
+ const endpoint = `${cfg.publicUrl.replace(/\/+$/, "")}${DEVICE_CODE_PATH}`;
61
+ const created = await post(doFetch, endpoint, { action: "create" });
62
+ if (created.status !== 200 || !created.json.device_code) {
63
+ throw new Error(`Could not start device login (HTTP ${created.status}).`);
64
+ }
65
+ const start = created.json;
66
+ say("");
67
+ say(chalk.bold("To sign in to ACC from this terminal:"));
68
+ say("");
69
+ say(` ${chalk.cyan("1.")} Visit ${chalk.underline(start.verification_url)}`);
70
+ say(` ${chalk.cyan("2.")} Enter code: ${chalk.bold.green(start.user_code)}`);
71
+ say("");
72
+ say(chalk.gray("Waiting for confirmation…"));
73
+ const openBrowser = deps.openBrowser ?? ((url) => open(url));
74
+ void Promise.resolve(openBrowser(start.verification_url)).catch(() => {
75
+ /* headless box; the printed URL is the fallback */
76
+ });
77
+ const interval = (deps.intervalSeconds ?? start.interval) * 1000;
78
+ const now = () => deps.now?.() ?? Date.now();
79
+ const deadline = now() + (deps.timeoutSeconds ?? start.expires_in) * 1000;
80
+ let failures = 0;
81
+ let lastFailure = null;
82
+ while (now() < deadline) {
83
+ await nap(interval);
84
+ const { status, json } = await post(doFetch, endpoint, {
85
+ action: "exchange",
86
+ device_code: start.device_code,
87
+ });
88
+ if (status !== 200 || json.status === "retry") {
89
+ failures += 1;
90
+ lastFailure = json.status === "retry" ? (json.error ?? "retry") : `HTTP ${status}`;
91
+ if (failures >= MAX_POLL_FAILURES) {
92
+ throw new Error(`Device-code exchange failed ${failures} times in a row: ${lastFailure}`);
93
+ }
94
+ continue;
95
+ }
96
+ failures = 0;
97
+ if (json.status === "expired") {
98
+ throw new Error("Device code expired before sign-in completed. Run the command again.");
99
+ }
100
+ if (json.status === "ok") {
101
+ if (!json.email) {
102
+ throw new Error("This account has no email address, so a CLI session cannot be issued.");
103
+ }
104
+ // The grant is spent from HERE, not on the server: GoTrue records this
105
+ // machine's agent and address on the session row, which is what makes the
106
+ // session recognisable (and therefore revocable) on Settings → Sessions.
107
+ return verifyEmailOtp({ supabaseUrl: json.supabase_url, anonKey: json.anon_key }, { email: json.email, token: json.token }, deps);
108
+ }
109
+ }
110
+ throw new Error("Device code timed out before sign-in completed.");
111
+ }
112
+ export async function authLoginCommand(deps = {}) {
113
+ const session = await deviceLogin(deps);
114
+ await saveUserSession(session);
115
+ const say = deps.log ?? ((line) => console.log(line));
116
+ say(chalk.green(`✓ Signed in as ${session.email ?? session.user_id}`));
117
+ say(chalk.green("✓ Stored session in OS keychain (acc-runner · user)"));
118
+ say("");
119
+ say(chalk.gray(`This session appears on Settings → Sessions as "${cliUserAgent()}".`));
120
+ say(chalk.gray(`Revoke it there, or run \`${cliName() === "acc" ? "acc logout" : "acc-runner auth logout"}\`.`));
121
+ }
122
+ /**
123
+ * "Am I still signed in?" — which is a question about the SERVER's copy of the
124
+ * session, not this machine's. A keychain entry alone proves nothing: the session
125
+ * may have been revoked from Settings → Sessions while this terminal was closed,
126
+ * and the stored access token would still look perfectly valid. So the local facts
127
+ * are printed first (they work offline) and then the server is asked.
128
+ */
129
+ export async function authStatusCommand(deps = {}) {
130
+ const say = deps.log ?? ((line) => console.log(line));
131
+ const session = await loadUserSession();
132
+ if (!session) {
133
+ say(`Not signed in. Run \`${signInCommand()}\`.`);
134
+ return;
135
+ }
136
+ say(`Signed in as ${session.email ?? session.user_id}`);
137
+ say(`Access token expires ${session.access_expires_at}`);
138
+ const verdict = await probeUserSession(session, deps);
139
+ if (!verdict.live) {
140
+ await clearUserSession();
141
+ say(chalk.yellow(`✗ ${revokedMessage()}`));
142
+ return;
143
+ }
144
+ say(verdict.verified
145
+ ? chalk.green("✓ The session is still live server-side.")
146
+ : chalk.gray("Could not reach ACC to confirm the session; treating it as live."));
147
+ }
148
+ /**
149
+ * Sign out for real. Deleting the keychain entry alone would leave the session
150
+ * live in `auth.sessions` — visible on the sessions surface, refreshable by
151
+ * anyone who had copied the token. So GoTrue is told first, and the local copy
152
+ * is removed whether or not that call reached it (an offline machine must still
153
+ * be able to drop its credential).
154
+ *
155
+ * `scope=local` is not a nicety, it is the whole contract of this command:
156
+ * GoTrue's default scope is GLOBAL, which would also sign the operator out of
157
+ * their browser and every other terminal. "Log this terminal out" must mean
158
+ * exactly one session — the one this keychain entry holds.
159
+ */
160
+ export const LOGOUT_PATH = "/auth/v1/logout?scope=local";
161
+ export async function authLogoutCommand(deps = {}) {
162
+ const say = deps.log ?? ((line) => console.log(line));
163
+ const session = await loadUserSession();
164
+ if (!session) {
165
+ say("Not signed in.");
166
+ return;
167
+ }
168
+ let revoked = false;
169
+ try {
170
+ const doFetch = deps.fetch ?? fetch;
171
+ const res = await doFetch(`${session.supabase_url.replace(/\/+$/, "")}${LOGOUT_PATH}`, {
172
+ method: "POST",
173
+ headers: {
174
+ apikey: session.anon_key,
175
+ Authorization: `Bearer ${session.access_token}`,
176
+ "User-Agent": deps.userAgent ?? cliUserAgent(),
177
+ },
178
+ });
179
+ revoked = res.status < 400;
180
+ }
181
+ catch {
182
+ revoked = false;
183
+ }
184
+ await clearUserSession();
185
+ say(revoked
186
+ ? chalk.green("✓ Signed out (session revoked server-side).")
187
+ : chalk.yellow("✓ Local session cleared. The server session may still be live — revoke it on Settings → Sessions."));
188
+ }
189
+ //# sourceMappingURL=device-login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device-login.js","sourceRoot":"","sources":["../../src/user-auth/device-login.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,cAAc,GAGf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEjE,MAAM,CAAC,MAAM,gBA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AAG,CAAC,gBAAgB,CAAC,CAAC;QACtB,OAAO;IACT,CAAC;IACD,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC;QACpC,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,WAAW,EAAE,EAAE;YACrF,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,MAAM,EAAE,OAAO,CAAC,QAAQ;gBACxB,aAAa,EAAE,UAAU,OAAO,CAAC,YAAY,EAAE;gBAC/C,YAAY,EAAE,IAAI,CAAC,SAAS,IAAI,YAAY,EAAE;aAC/C;SACF,CAAC,CAAC;QACH,OAAO,GAAG,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,KAAK,CAAC;IAClB,CAAC;IACD,MAAM,gBAAgB,EAAE,CAAC;IACzB,GAAG,CACD,OAAO;QACL,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,6CAA6C,CAAC;QAC5D,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,mGAAmG,CAAC,CACtH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { type GoTrueDeps, type StoredUserSession } from "./session.js";
2
+ export declare const SESSION_STATUS_PATH = "/api/auth/session-status";
3
+ /** What the probe concluded. `verified` false means "could not check". */
4
+ export interface LivenessVerdict {
5
+ live: boolean;
6
+ verified: boolean;
7
+ reason: string;
8
+ }
9
+ /**
10
+ * Map one HTTP answer onto a verdict. Pure, so every branch is asserted directly
11
+ * rather than through a fetch double.
12
+ */
13
+ export declare function decideLiveness(status: number, body: unknown): LivenessVerdict;
14
+ /** Ask the control plane about this session. Never throws — a transport failure
15
+ * is an unverified verdict, not a sign-out. */
16
+ export declare function probeUserSession(session: StoredUserSession, deps?: GoTrueDeps): Promise<LivenessVerdict>;
17
+ /** The message an operator sees when their terminal was revoked from the web. */
18
+ export declare function revokedMessage(): string;
19
+ /** Test seam: forget the memoized verdict. */
20
+ export declare function resetSessionLivenessProbe(): void;
21
+ /**
22
+ * Called at the top of every person-lane command. Throws SignedOutError when the
23
+ * session has been revoked; returns silently in every other case, including every
24
+ * case where we could not tell.
25
+ */
26
+ export declare function ensureUserSessionLive(deps?: GoTrueDeps): Promise<void>;
27
+ //# sourceMappingURL=liveness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liveness.d.ts","sourceRoot":"","sources":["../../src/user-auth/liveness.ts"],"names":[],"mappings":"AA0BA,OAAO,EAML,KAAK,UAAU,EACf,KAAK,iBAAiB,EACvB,MAAM,cAAc,CAAC;AAEtB,eAAO,MAAM,mBAAmB,6BAA6B,CAAC;AAE9D,0EAA0E;AAC1E,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,eAAe,CAuB7E;AAED;gDACgD;AAChD,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,iBAAiB,EAC1B,IAAI,GAAE,UAAe,GACpB,OAAO,CAAC,eAAe,CAAC,CAqB1B;AAED,iFAAiF;AACjF,wBAAgB,cAAc,IAAI,MAAM,CAKvC;AASD,8CAA8C;AAC9C,wBAAgB,yBAAyB,IAAI,IAAI,CAEhD;AAoBD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,GAAE,UAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAK1E"}
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Does this terminal's session still exist server-side? (AX-G3, gap G-16.)
3
+ *
4
+ * THE PROBLEM. Revoking a CLI login on Settings → Sessions deletes the
5
+ * `auth.sessions` row and cascades its refresh-token family, so this machine can
6
+ * never mint another access token. But the access token already in the keychain
7
+ * stays cryptographically valid until it expires — and PostgREST, which every
8
+ * `acc task` read goes through, verifies a JWT's signature without ever looking at
9
+ * the session table. So a revoked terminal would keep reading the board for the
10
+ * rest of the token's life, which is up to an hour of a revoke not being a revoke.
11
+ *
12
+ * The refresh path already handles the other half: once the token IS stale,
13
+ * refreshUserSession gets a 4xx and raises SignedOutError. This module covers the
14
+ * window before that — one cheap read of /api/auth/session-status per command.
15
+ *
16
+ * FAIL OPEN, ON PURPOSE. Only a positive `live: false` signs the operator out.
17
+ * An unreachable control plane, a 5xx, a deployment that predates the endpoint
18
+ * (404), an unwired session directory, a token with no session claim — all of
19
+ * those leave the session alone. The alternative is a pooler hiccup logging out
20
+ * every terminal in the fleet at once, which is a worse failure than the one this
21
+ * module exists to fix. The only thing we treat as definitive besides `live:false`
22
+ * is a 401 whose reason is `invalid_token`: that is the auth authority itself
23
+ * saying this credential is not a credential.
24
+ */
25
+ import { loadConfig } from "../config.js";
26
+ import { signInCommand } from "../cli-name.js";
27
+ import { accessTokenIsFresh, clearUserSession, cliUserAgent, loadUserSession, SignedOutError, } from "./session.js";
28
+ export const SESSION_STATUS_PATH = "/api/auth/session-status";
29
+ /**
30
+ * Map one HTTP answer onto a verdict. Pure, so every branch is asserted directly
31
+ * rather than through a fetch double.
32
+ */
33
+ export function decideLiveness(status, body) {
34
+ const b = (body ?? {});
35
+ if (status === 401) {
36
+ // requireUser answers 401 with a discriminated reason. `invalid_token` is the
37
+ // authority rejecting the credential — definitive. `auth_unreachable` and the
38
+ // header-shape classes are not about this session at all.
39
+ const reason = typeof b.reason === "string" ? b.reason : "unauthenticated";
40
+ if (reason === "invalid_token")
41
+ return { live: false, verified: true, reason };
42
+ return { live: true, verified: false, reason };
43
+ }
44
+ if (status !== 200) {
45
+ // 404 = an older deployment without this endpoint. 5xx = the control plane.
46
+ // Neither is evidence about the session.
47
+ return { live: true, verified: false, reason: `http_${status}` };
48
+ }
49
+ if (b.live === false && b.verified === true) {
50
+ return { live: false, verified: true, reason: typeof b.reason === "string" ? b.reason : "revoked" };
51
+ }
52
+ return {
53
+ live: true,
54
+ verified: b.verified === true,
55
+ reason: typeof b.reason === "string" ? b.reason : "live",
56
+ };
57
+ }
58
+ /** Ask the control plane about this session. Never throws — a transport failure
59
+ * is an unverified verdict, not a sign-out. */
60
+ export async function probeUserSession(session, deps = {}) {
61
+ const doFetch = deps.fetch ?? fetch;
62
+ const base = loadConfig().publicUrl.replace(/\/+$/, "");
63
+ try {
64
+ const res = await doFetch(`${base}${SESSION_STATUS_PATH}`, {
65
+ method: "GET",
66
+ headers: {
67
+ Accept: "application/json",
68
+ Authorization: `Bearer ${session.access_token}`,
69
+ "User-Agent": deps.userAgent ?? cliUserAgent(),
70
+ },
71
+ });
72
+ const body = await res.json().catch(() => ({}));
73
+ return decideLiveness(res.status, body);
74
+ }
75
+ catch (err) {
76
+ return {
77
+ live: true,
78
+ verified: false,
79
+ reason: `unreachable: ${err.message?.slice(0, 120) ?? "error"}`,
80
+ };
81
+ }
82
+ }
83
+ /** The message an operator sees when their terminal was revoked from the web. */
84
+ export function revokedMessage() {
85
+ return ("This terminal's ACC session is no longer valid — it was revoked from " +
86
+ `Settings → Sessions, or it expired. Run \`${signInCommand()}\` to sign in again.`);
87
+ }
88
+ /**
89
+ * One probe per process, so two calls inside a single command do not both go to
90
+ * the network. A new command is a new process, which is what "takes effect on its
91
+ * next call" means for a CLI.
92
+ */
93
+ let inFlight = null;
94
+ /** Test seam: forget the memoized verdict. */
95
+ export function resetSessionLivenessProbe() {
96
+ inFlight = null;
97
+ }
98
+ async function runCheck(deps) {
99
+ const session = await loadUserSession();
100
+ // No session at all: the command's own "not signed in" error is the right
101
+ // message, and it does not need a network call to say it.
102
+ if (!session)
103
+ return;
104
+ // A stale token is about to be refreshed, and a refresh against a revoked
105
+ // session already fails with the same error. Probing would be a second network
106
+ // call to learn what the first one is about to tell us.
107
+ if (!accessTokenIsFresh(session, deps.now?.() ?? Date.now()))
108
+ return;
109
+ const verdict = await probeUserSession(session, deps);
110
+ if (verdict.live)
111
+ return;
112
+ // Drop the dead credential: leaving it would make every later command fail the
113
+ // same way, and would make `whoami` claim a session that no longer exists.
114
+ await clearUserSession();
115
+ throw new SignedOutError(revokedMessage());
116
+ }
117
+ /**
118
+ * Called at the top of every person-lane command. Throws SignedOutError when the
119
+ * session has been revoked; returns silently in every other case, including every
120
+ * case where we could not tell.
121
+ */
122
+ export function ensureUserSessionLive(deps = {}) {
123
+ // A rejected memo is deliberately kept: a second caller in the same process
124
+ // should see the same sign-out, not probe a session we already know is gone.
125
+ inFlight ??= runCheck(deps);
126
+ return inFlight;
127
+ }
128
+ //# sourceMappingURL=liveness.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liveness.js","sourceRoot":"","sources":["../../src/user-auth/liveness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,cAAc,GAGf,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;AAS9D;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc,EAAE,IAAa;IAC1D,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAA4B,CAAC;IAClD,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;QACnB,8EAA8E;QAC9E,8EAA8E;QAC9E,0DAA0D;QAC1D,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,iBAAiB,CAAC;QAC3E,IAAI,MA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M,OAAO,GAAG,MAAM,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACtD,IAAI,OAAO,CAAC,IAAI;QAAE,OAAO;IACzB,+EAA+E;IAC/E,2EAA2E;IAC3E,MAAM,gBAAgB,EAAE,CAAC;IACzB,MAAM,IAAI,cAAc,CAAC,cAAc,EAAE,CAAC,CAAC;AAC7C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAmB,EAAE;IACzD,4EAA4E;IAC5E,6EAA6E;IAC7E,QAAQ,KAAK,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC5B,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,82 @@
1
+ /** Keychain account for the person session. The runner's is "default". */
2
+ export declare const USER_SESSION_SLOT: "user";
3
+ /** Refresh this far ahead of expiry, so a long RPC never straddles it. */
4
+ export declare const REFRESH_SKEW_SECONDS = 120;
5
+ export interface StoredUserSession {
6
+ access_token: string;
7
+ refresh_token: string;
8
+ /** ISO-8601 instant at which access_token expires. */
9
+ access_expires_at: string;
10
+ user_id: string;
11
+ email: string | null;
12
+ /** Resolved by the exchange, so a fresh machine needs no connection env. */
13
+ supabase_url: string;
14
+ anon_key: string;
15
+ }
16
+ /**
17
+ * `acc-cli/1.2.3 (darwin; my-laptop)`. The hostname is filtered to header-safe
18
+ * characters — a hostname with a stray byte must not make an auth call throw
19
+ * where it would otherwise have succeeded.
20
+ */
21
+ export declare function cliUserAgent(hostname?: string): string;
22
+ /** Raised when the session is gone for good — revoked, expired, or never there. */
23
+ export declare class SignedOutError extends Error {
24
+ constructor(message: string);
25
+ }
26
+ export declare function saveUserSession(session: StoredUserSession): Promise<void>;
27
+ export declare function loadUserSession(): Promise<StoredUserSession | null>;
28
+ export declare function clearUserSession(): Promise<boolean>;
29
+ /** The token payload GoTrue answers `/verify` and `/token` with. */
30
+ export interface GoTrueTokenResponse {
31
+ access_token?: string;
32
+ refresh_token?: string;
33
+ expires_in?: number;
34
+ expires_at?: number;
35
+ user?: {
36
+ id?: string;
37
+ email?: string | null;
38
+ } | null;
39
+ }
40
+ export interface GoTrueTarget {
41
+ supabaseUrl: string;
42
+ anonKey: string;
43
+ }
44
+ /** Injectable so the tests drive the rules without a network. */
45
+ export interface GoTrueDeps {
46
+ fetch?: typeof fetch;
47
+ now?: () => number;
48
+ userAgent?: string;
49
+ }
50
+ /**
51
+ * Fold a token response into a session, or fail loudly. A response missing
52
+ * either token, or the user id, is not a session however cheerful its status
53
+ * code was — better to refuse than to persist a credential we cannot refresh.
54
+ */
55
+ export declare function toStoredSession(json: GoTrueTokenResponse, target: GoTrueTarget, now: number): StoredUserSession;
56
+ /** Spend the one-time grant from /api/auth/device-code for a real session. */
57
+ export declare function verifyEmailOtp(target: GoTrueTarget, params: {
58
+ email: string;
59
+ token: string;
60
+ }, deps?: GoTrueDeps): Promise<StoredUserSession>;
61
+ /**
62
+ * Trade the refresh token for a fresh pair. A 4xx here is the revocation path,
63
+ * not an outage: GoTrue answers 400/401 for a token that was revoked (the
64
+ * sessions surface deleted the row) or already rotated, and both mean the same
65
+ * thing to the operator — sign in again.
66
+ */
67
+ export declare function refreshUserSession(session: StoredUserSession, deps?: GoTrueDeps): Promise<StoredUserSession>;
68
+ export declare function accessTokenIsFresh(session: StoredUserSession, now?: number): boolean;
69
+ /**
70
+ * The accessor everything downstream should use: a live access token for the
71
+ * signed-in human, refreshed and re-persisted when it is close to expiry.
72
+ *
73
+ * The rotated successor is written back BEFORE the token is returned, because a
74
+ * caller that used a token whose refresh partner never landed would be one crash
75
+ * away from replaying a spent token — which GoTrue treats as reuse.
76
+ *
77
+ * A revoked session clears the keychain slot on the way out. Leaving a dead
78
+ * credential in the keychain would make every later command fail the same way
79
+ * with nothing to show for it; removing it makes `auth status` honest.
80
+ */
81
+ export declare function getUserAccessToken(deps?: GoTrueDeps): Promise<string>;
82
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.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