shadok-ai 0.19.90 → 0.19.92

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.
package/README.md CHANGED
@@ -1036,7 +1036,8 @@ know before opening it up:
1036
1036
  else you do. Accounts belong to **one instance** (one launch directory), like
1037
1037
  its channels and its scheduled prompts. With no password there are no
1038
1038
  accounts and no login screen — nothing changes for a machine you use alone.
1039
- When a signed-in session **expires** (the cookie lasts a week), the open tab
1039
+ When a signed-in session **expires** (after a week without a visit — using
1040
+ the cockpit renews it — or 30 days after the sign-in at the latest), the open tab
1040
1041
  returns you to the login screen on its next request instead of failing in
1041
1042
  place — a paste that would not send, an agent list that would not refresh.
1042
1043
  - **Two-factor sign-in (passkeys).** From the **Users** panel, anyone signed in
@@ -28,7 +28,8 @@ and automatically starts the shadok-ai server when it is not running (port
28
28
  | `freetext <id> <n> "text"` | the "Type something" option: a free answer |
29
29
  | `list [--cwd DIR]` | driven agents (local state + alive/dead) and resumable sessions. With `--peer X`: the agents running ON X (from X itself, tagged `peer`), plus X's resumable sessions only for a `--cwd` you name — a path on X |
30
30
  | `diff <id>` | the agent's changes (git status + diff against the worktree's base) |
31
- | `stop <id>` | ends the session (for ALL its clients) |
31
+ | `stop <id> [--force]` | ends the session (for ALL its clients), whether it is running or dormant — sent by id, nothing is resumed — and answers `stopped:true` only once the server confirms. Works over `--peer` with no local state (a restricted peer may close only what it spawned). A local agent this pilotctl never drove needs `--force` |
32
+ | `reap [--idle 30m] [--dry-run]` | closes every finished agent you spawned: not busy, nobody watching, idle for `--idle` (default 30m). Over a restricted `--peer` that is every agent the peer lists for you (its own, dormant ones included); anywhere else only the ids in your local state. Use it to clear a backlog |
32
33
  | `set-parent <id> <parent-id\|none>` | re-link an agent to a parent, or **detach** it with `none` (it then reports to nobody). The link is what makes the parent hear when the agent finishes, blocks or dies — set automatically at spawn, flipped here when a side task is done and you want it off a lead's back |
33
34
  | `screen <id>` | raw TUI screen (debug) |
34
35
  | `profile-prompt "<text>" [--name NAME] [--readonly]` | rewrites a profile's **system prompt**: your own by default; any of them (and creation with `--name`) under the lead profile |
@@ -190,7 +191,8 @@ pilotctl peer add brasdroit1 https://brasdroit1.example.com <token> # once
190
191
  pilotctl spawn --peer brasdroit1 --profile dev --cwd /workspace # spawn there
191
192
  pilotctl prompt <id> "run the migration" --peer brasdroit1 # drive it
192
193
  pilotctl diff <id> --peer brasdroit1 # read its work
193
- pilotctl stop <id> --peer brasdroit1
194
+ pilotctl stop <id> --peer brasdroit1 # close it when done
195
+ pilotctl reap --peer brasdroit1 --dry-run # what you left open there
194
196
  ```
195
197
 
196
198
  - The **token** is minted by the REMOTE instance's admin (a human, in its
@@ -200,8 +202,10 @@ pilotctl stop <id> --peer brasdroit1
200
202
  - What you may touch on X depends on the **scope** its admin gave you when they
201
203
  invited you:
202
204
  - **restricted** (the default) — only the agents YOU spawned on X; `--peer X
203
- list` and a diff of someone else's agent come back refused (`peer-scope` /
204
- `403`). Assume this one unless you were told otherwise.
205
+ list` shows those (dormant ones included) and nothing else, and a diff or
206
+ stop of someone else's agent comes back refused (`peer-scope` / `403`). An
207
+ older X refuses `list` outright. Assume this scope unless you were told
208
+ otherwise.
205
209
  - **member** — you act like an invited user: `list`, `diff`, resume/drive/stop
206
210
  **any** agent on X, spawn more, read its usage. You are not an admin (no
207
211
  account or peer management).
@@ -149,10 +149,10 @@ export function parseArgs(argv) {
149
149
  const pos = [];
150
150
  for (let i = 0; i < rest.length; i++) {
151
151
  const a = rest[i];
152
- if (a === "--worktree" || a === "--continue" || a === "--readonly") flags[a.slice(2)] = true;
152
+ if (a === "--worktree" || a === "--continue" || a === "--readonly" || a === "--force" || a === "--dry-run") flags[a.slice(2)] = true;
153
153
  else if (
154
154
  a === "--cwd" || a === "--resume" || a === "--timeout" || a === "--profile" || a === "--parent" ||
155
- a === "--name" || a === "--peer" || a === "--peer-url" || a === "--peer-token"
155
+ a === "--name" || a === "--peer" || a === "--peer-url" || a === "--peer-token" || a === "--idle"
156
156
  ) flags[a.slice(2)] = rest[++i];
157
157
  // Repeatable: a Skill Factory skill the new agent is born with, `name` or `name@N`.
158
158
  else if (a === "--skill") (flags.skill ||= []).push(rest[++i]);
@@ -565,45 +565,113 @@ async function cmdSetParent(id, parentArg, flags) {
565
565
  return { sessionId: id, parent: r.parent ?? null };
566
566
  }
567
567
 
568
- async function cmdStop(id) {
568
+ /**
569
+ * Send `stop` for `id` on a BARE socket — no `start`, so nothing is resumed —
570
+ * and wait for the server's `stop-result`. The old path went through the local
571
+ * holder: with the holder gone (it is, once a `prompt` over a peer link returns
572
+ * and its socket drops) it sent NOTHING and only cleared local state, so the
573
+ * agent stayed open on the other instance for ever. Whether the caller may stop
574
+ * it is the server's call (a restricted peer: only its own), not the holder's.
575
+ */
576
+ async function stopById(id) {
577
+ const ws = await connect();
578
+ try {
579
+ return await new Promise((resolve) => {
580
+ const t = setTimeout(() => resolve({ type: "timeout" }), 30_000);
581
+ ws.on("message", (raw) => {
582
+ let m;
583
+ try {
584
+ m = JSON.parse(String(raw));
585
+ } catch {
586
+ return;
587
+ }
588
+ if ((m.type === "stop-result" && m.sessionId === id) || m.type === "error") {
589
+ clearTimeout(t);
590
+ resolve(m);
591
+ }
592
+ });
593
+ ws.on("close", () => {
594
+ clearTimeout(t);
595
+ resolve({ type: "socket-closed" });
596
+ });
597
+ ws.send(JSON.stringify({ type: "stop", sessionId: id }));
598
+ });
599
+ } finally {
600
+ ws.close();
601
+ }
602
+ }
603
+
604
+ /** Pure: what a `stop-result` / refusal means for the caller. */
605
+ export function stopOutcome(id, reply) {
606
+ if (reply.type === "stop-result" && reply.ok) return { stopped: true, sessionId: id };
607
+ if (reply.type === "stop-result") return { stopped: false, sessionId: id, note: "the server kept it (the home agent is never closed)" };
608
+ if (reply.type === "error") return { stopped: false, sessionId: id, error: reply.message, ...(reply.code ? { code: reply.code } : {}) };
609
+ return {
610
+ stopped: false,
611
+ sessionId: id,
612
+ note: "the server did not confirm the stop within 30s (an older shadok-ai answers nothing) — check with `list`",
613
+ };
614
+ }
615
+
616
+ async function cmdStop(id, flags = {}) {
569
617
  await ensureServer();
570
618
  const st = readState(id);
571
- const holderLive = !!(st?.holderPid && pidAlive(st.holderPid));
572
- if (!holderLive) {
573
- // No holder → we never kept this session alive; don't resurrect it just
574
- // to stop it (it may belong to a browser client). Clear local state only.
575
- deleteState(id);
576
- return { stopped: false, sessionId: id, note: "no live holder; local state cleared" };
577
- }
578
- let client;
579
- try {
580
- client = await openSession({ resume: id, cwd: st?.cwd ?? undefined });
581
- } catch (err) {
582
- // Holder pid is alive but session is dead (zombie holder, dead server session).
583
- // Kill the holder and clean up state.
584
- if (st.holderPid !== process.pid && pidAlive(st.holderPid)) {
619
+ // A LOCAL agent this pilotctl never drove may be someone's in the web UI: ask
620
+ // for --force. Over a peer link the peer's own scope already decides (a
621
+ // restricted peer can only close what it spawned).
622
+ if (!st && !PEER && !flags.force)
623
+ return { stopped: false, sessionId: id, note: "not an agent this pilotctl drove — pass --force to stop it anyway" };
624
+ const out = stopOutcome(id, await stopById(id));
625
+ if (out.stopped) {
626
+ if (st?.holderPid && st.holderPid !== process.pid && pidAlive(st.holderPid)) {
585
627
  try {
586
628
  process.kill(st.holderPid);
587
629
  } catch {}
588
630
  }
589
631
  deleteState(id);
590
- const msg = err instanceof Error ? err.message : String(err);
591
- return { stopped: false, sessionId: id, note: `session not reattachable (${msg}); holder killed and local state cleared` };
592
- }
593
- client.send({ type: "stop" });
594
- const result = await client.waitFor(["stopped", "socket-closed"], 30_000);
595
- client.ws.close();
596
- if (result.type === "timeout") {
597
- // Stop was not confirmed within 30s; don't kill holder or delete state (leave for retry).
598
- return { stopped: false, sessionId: id, note: "stop not confirmed within 30s; session may still be running" };
599
632
  }
600
- if (st.holderPid !== process.pid && pidAlive(st.holderPid)) {
601
- try {
602
- process.kill(st.holderPid);
603
- } catch {}
604
- }
605
- deleteState(id);
606
- return { stopped: true, sessionId: id };
633
+ return out;
634
+ }
635
+
636
+ /**
637
+ * Pure: which agents `reap` closes. Never a busy one, never one with someone
638
+ * watching it, never one active more recently than `idleSec` (a non-running
639
+ * row, idleSec -1, is idle by definition). Over a RESTRICTED peer link the list
640
+ * is already narrowed to what this peer spawned, so every row is ours; anywhere
641
+ * else the list holds other people's agents too, so only the ids this pilotctl
642
+ * spawned (its state files) are eligible.
643
+ */
644
+ export function reapCandidates(rows, { restricted, ownIds, idleSec }) {
645
+ return rows
646
+ .filter((r) => restricted || ownIds.has(r.id))
647
+ .filter((r) => !r.busy && !(r.clients > 0) && (r.idleSec < 0 || r.idleSec >= idleSec))
648
+ .map((r) => r.id);
649
+ }
650
+
651
+ /** Parse `30m` / `2h` / `90s` / a bare number of minutes → seconds. */
652
+ export function parseIdle(v, dflt = 1800) {
653
+ if (v === undefined || v === true) return dflt;
654
+ const m = /^(\d+)\s*([smh]?)$/.exec(String(v).trim());
655
+ if (!m) throw new Error(`--idle: expected e.g. 30m, 2h, 90s — got "${v}"`);
656
+ return Number(m[1]) * ({ s: 1, m: 60, h: 3600 }[m[2] || "m"]);
657
+ }
658
+
659
+ /** Close every finished agent this caller spawned — the backlog `stop` left behind. */
660
+ async function cmdReap(flags) {
661
+ await ensureServer();
662
+ const r = await fetch(`${httpBase()}/live`, { headers: authHeaders() });
663
+ if (!r.ok) throw new Error(`${httpBase()} answered HTTP ${r.status} to /live`);
664
+ const rows = await r.json();
665
+ const dir = stateDir();
666
+ const ownIds = new Set(
667
+ fs.existsSync(dir) ? fs.readdirSync(dir).filter((f) => f.endsWith(".json")).map((f) => f.slice(0, -5)) : [],
668
+ );
669
+ const restricted = r.headers.get("x-shadok-peer-scope") === "restricted";
670
+ const ids = reapCandidates(rows, { restricted, ownIds, idleSec: parseIdle(flags.idle) });
671
+ if (flags["dry-run"]) return { wouldStop: ids };
672
+ const results = [];
673
+ for (const id of ids) results.push(await cmdStop(id, { force: true }));
674
+ return { stopped: results.filter((x) => x.stopped).map((x) => x.sessionId), failed: results.filter((x) => !x.stopped) };
607
675
  }
608
676
 
609
677
  /**
@@ -690,7 +758,7 @@ async function cmdScreen(id, flags) {
690
758
  }
691
759
 
692
760
  const HELP =
693
- "usage: pilotctl <spawn|prompt|dialog|choose|toggle|confirm|freetext|list|diff|stop|set-parent|screen|profile-prompt|talk|talk-handle|peer> …\n" +
761
+ "usage: pilotctl <spawn|prompt|dialog|choose|toggle|confirm|freetext|list|diff|stop|reap|set-parent|screen|profile-prompt|talk|talk-handle|peer> …\n" +
694
762
  " pilotctl set-parent <id> <parent-id|none> # re-link or detach an agent from its parent\n" +
695
763
  " add --peer <alias> to any command to run it against another instance's agents\n" +
696
764
  " pilotctl peer <add <alias> <url> <ticket> [--token]|list|rm <alias>>";
@@ -797,7 +865,9 @@ export async function run(argv) {
797
865
  case "diff":
798
866
  return cmdDiff(pos[0]);
799
867
  case "stop":
800
- return cmdStop(pos[0]);
868
+ return cmdStop(pos[0], flags);
869
+ case "reap":
870
+ return cmdReap(flags);
801
871
  case "set-parent":
802
872
  return cmdSetParent(pos[0], pos[1], flags);
803
873
  case "screen":
@@ -36,3 +36,25 @@ test("state: write, read, delete", () => {
36
36
  deleteState("abc");
37
37
  assert.equal(readState("abc"), null);
38
38
  });
39
+
40
+ test("reapCandidates: only our ids outside a restricted peer, never busy/watched/recent", async () => {
41
+ const { reapCandidates } = await import("../pilotctl.mjs");
42
+ const rows = [
43
+ { id: "mine-idle", busy: false, clients: 0, idleSec: 4000 },
44
+ { id: "theirs-idle", busy: false, clients: 0, idleSec: 4000 },
45
+ { id: "mine-busy", busy: true, clients: 0, idleSec: 4000 },
46
+ ];
47
+ const ownIds = new Set(["mine-idle", "mine-busy"]);
48
+ assert.deepEqual(reapCandidates(rows, { restricted: false, ownIds, idleSec: 1800 }), ["mine-idle"]);
49
+ assert.deepEqual(reapCandidates(rows, { restricted: true, ownIds: new Set(), idleSec: 1800 }), ["mine-idle", "theirs-idle"]);
50
+ });
51
+
52
+ test("parseIdle reads 30m / 2h / 90s / bare minutes", async () => {
53
+ const { parseIdle } = await import("../pilotctl.mjs");
54
+ assert.equal(parseIdle(undefined), 1800);
55
+ assert.equal(parseIdle("30m"), 1800);
56
+ assert.equal(parseIdle("2h"), 7200);
57
+ assert.equal(parseIdle("90s"), 90);
58
+ assert.equal(parseIdle("45"), 2700);
59
+ assert.throws(() => parseIdle("soon"));
60
+ });
@@ -130,32 +130,81 @@ test("the diff fallback includes untracked files", async () => {
130
130
  }
131
131
  });
132
132
 
133
- test("stop with no live holder cleans the state without reattaching", async () => {
134
- const mock = await startMockServer();
133
+ // `stop` used to go through the local holder: with the holder gone (always, once
134
+ // a `prompt` over a peer link returned) it sent nothing and only cleared local
135
+ // state, so peers piled up finished agents. It now sends `stop` by id on a bare
136
+ // socket — no `start`, nothing resumed — and trusts only the server's answer.
137
+ test("stop with no live holder still stops the agent, by id, without resuming it", async () => {
138
+ const mock = await startMockServer({ stop: [{ type: "stop-result", sessionId: "dead", ok: true }] });
135
139
  process.env.SHADOK_PORT = String(mock.port);
136
140
  writeState("dead", { sessionId: "dead", cwd: "/tmp/x", holderPid: 999999 });
137
141
  try {
138
142
  const r = await run(["stop", "dead"]);
139
- assert.equal(r.stopped, false);
143
+ assert.equal(r.stopped, true);
140
144
  assert.equal(readState("dead"), null);
141
- assert.equal(mock.received.length, 0); // no start sent
145
+ assert.deepEqual(mock.received.map((m) => m.type), ["stop"]); // no start → no resume
146
+ assert.equal(mock.received[0].sessionId, "dead");
147
+ } finally {
148
+ await mock.close();
149
+ }
150
+ });
151
+
152
+ test("stop over a peer link needs no local state and sends the stop to the peer", async () => {
153
+ const mock = await startMockServer({ stop: [{ type: "stop-result", sessionId: "w1", ok: true }] });
154
+ try {
155
+ const r = await run(["stop", "w1", "--peer-url", `http://127.0.0.1:${mock.port}`, "--peer-token", "T"]);
156
+ assert.equal(r.stopped, true);
157
+ assert.deepEqual(mock.received.map((m) => m.type), ["stop"]);
142
158
  } finally {
143
159
  await mock.close();
144
160
  }
145
161
  });
146
162
 
147
- test("stop with a live session sends stop and cleans up", async () => {
163
+ test("a refused stop keeps the local state and says why", async () => {
164
+ const mock = await startMockServer({ stop: [{ type: "error", message: "a restricted peer may only stop its own agents", code: "peer-scope" }] });
165
+ process.env.SHADOK_PORT = String(mock.port);
166
+ writeState("theirs", { sessionId: "theirs", cwd: "/tmp/x", holderPid: null });
167
+ try {
168
+ const r = await run(["stop", "theirs"]);
169
+ assert.equal(r.stopped, false);
170
+ assert.equal(r.code, "peer-scope");
171
+ assert.ok(readState("theirs"));
172
+ } finally {
173
+ await mock.close();
174
+ }
175
+ });
176
+
177
+ test("a local agent pilotctl never drove needs --force", async () => {
178
+ const mock = await startMockServer({ stop: [{ type: "stop-result", sessionId: "ui-1", ok: true }] });
179
+ process.env.SHADOK_PORT = String(mock.port);
180
+ try {
181
+ const r = await run(["stop", "ui-1"]);
182
+ assert.equal(r.stopped, false);
183
+ assert.match(r.note, /--force/);
184
+ assert.equal(mock.received.length, 0);
185
+ assert.equal((await run(["stop", "ui-1", "--force"])).stopped, true);
186
+ } finally {
187
+ await mock.close();
188
+ }
189
+ });
190
+
191
+ test("reap over a restricted peer closes its idle leftovers, never a busy or watched one", async () => {
148
192
  const mock = await startMockServer({
149
- start: [{ type: "ready", sessionId: "abc", cwd: "/tmp/x" }],
150
- stop: [{ type: "stopped" }],
193
+ live: [
194
+ { id: "done", busy: false, clients: 0, idleSec: 4000 },
195
+ { id: "dormant", busy: false, clients: 0, idleSec: -1, running: false },
196
+ { id: "working", busy: true, clients: 0, idleSec: 9000 },
197
+ { id: "watched", busy: false, clients: 1, idleSec: 9000 },
198
+ { id: "fresh", busy: false, clients: 0, idleSec: 60 },
199
+ ],
200
+ liveHeaders: { "x-shadok-peer-scope": "restricted" },
201
+ stop: [{ type: "stop-result", sessionId: "done", ok: true }],
151
202
  });
152
- process.env.SHADOK_PORT = String(mock.port);
153
- // the test process' pid: alive, simulates an active holder
154
- writeState("abc", { sessionId: "abc", cwd: "/tmp/x", holderPid: process.pid });
155
203
  try {
156
- const r = await run(["stop", "abc"]);
157
- assert.equal(r.stopped, true);
158
- assert.equal(readState("abc"), null);
204
+ const url = `http://127.0.0.1:${mock.port}`;
205
+ const dry = await run(["reap", "--peer-url", url, "--peer-token", "T", "--dry-run"]);
206
+ assert.deepEqual(dry.wouldStop, ["done", "dormant"]);
207
+ assert.equal(mock.received.length, 0);
159
208
  } finally {
160
209
  await mock.close();
161
210
  }
@@ -178,18 +227,3 @@ test("screen returns the last screen received", async () => {
178
227
  }
179
228
  });
180
229
 
181
- test("stop with a live holder but a dead session cleans up and reports stopped:false", async () => {
182
- const mock = await startMockServer({
183
- start: [{ type: "error", message: "no session" }],
184
- });
185
- process.env.SHADOK_PORT = String(mock.port);
186
- writeState("zombie", { sessionId: "zombie", cwd: "/tmp/x", holderPid: process.pid });
187
- try {
188
- const r = await run(["stop", "zombie"]);
189
- assert.equal(r.stopped, false);
190
- assert.match(r.note, /not reattachable/);
191
- assert.equal(readState("zombie"), null);
192
- } finally {
193
- await mock.close();
194
- }
195
- });
@@ -23,6 +23,7 @@ export function startMockServer(script = {}) {
23
23
  res.setHeader("content-type", "application/json");
24
24
  if (req.url.startsWith("/live")) {
25
25
  if (script.liveStatus) res.statusCode = script.liveStatus;
26
+ for (const [k, v] of Object.entries(script.liveHeaders ?? {})) res.setHeader(k, v);
26
27
  return res.end(JSON.stringify(script.live ?? []));
27
28
  }
28
29
  if (req.url.startsWith("/sessions")) return res.end(JSON.stringify(script.sessions ?? []));
@@ -105,22 +105,50 @@ export declare function sessionSecret(): Buffer;
105
105
  * Best-effort: a write that fails returns 0, i.e. today's behaviour.
106
106
  */
107
107
  export declare function bootstrapSessionsAfter(now: number): number;
108
- /** `<user base64url>.<issuedAt>.<mfa>.<hmac>` — the name is encoded so a dot in
109
- * it cannot shift the fields. The ROLE is deliberately absent: it is re-read
110
- * from the account file at use time, so a demotion takes effect immediately
111
- * instead of riding in a stale cookie. `mfa` says the second factor was
112
- * presented when the cookie was issued: once two-factor is switched on, a
113
- * cookie without it is refused, which kills every session issued before. */
114
- export declare function signSession(user: string, issuedAt: number, secret: Buffer, mfa?: boolean): string;
108
+ /** `<user base64url>.<issuedAt>.<mfa>.<since>.<hmac>` — the name is encoded so a
109
+ * dot in it cannot shift the fields. The ROLE is deliberately absent: it is
110
+ * re-read from the account file at use time, so a demotion takes effect
111
+ * immediately instead of riding in a stale cookie. `mfa` says the second factor
112
+ * was presented when the cookie was issued: once two-factor is switched on, a
113
+ * cookie without it is refused, which kills every session issued before.
114
+ * `since` is when the person actually SIGNED IN: a renewed cookie moves
115
+ * `issuedAt` forward and carries `since` along unchanged, which is what lets
116
+ * renewal have a ceiling (`sessionRenewal`). Omitted when it equals `issuedAt`
117
+ * — a sign-in — so that shape stays the four-field one it always was. */
118
+ export declare function signSession(user: string, issuedAt: number, secret: Buffer, mfa?: boolean, since?: number): string;
115
119
  /**
116
120
  * The user and second-factor flag a session cookie carries, or null. Reads the
117
121
  * pre-2FA three-field shape too — as `mfa: false`, which is what it was.
122
+ *
123
+ * Two clocks, two limits. `maxAgeMs` bounds the time since the cookie was last
124
+ * ISSUED (idle time, once cookies are renewed on use); `maxLifeMs` bounds the
125
+ * time since the SIGN-IN, which no renewal can push back.
118
126
  */
119
- export declare function readSessionFull(token: string, secret: Buffer, now: number, maxAgeMs: number): {
127
+ export declare function readSessionFull(token: string, secret: Buffer, now: number, maxAgeMs: number, maxLifeMs?: number): {
120
128
  user: string;
121
129
  mfa: boolean;
122
130
  issuedAt: number;
131
+ since: number;
123
132
  } | null;
133
+ /**
134
+ * Should this session's cookie be re-issued now?
135
+ *
136
+ * A session used to last a week from the sign-in whatever happened in between,
137
+ * so someone working in the cockpit every day was still thrown out once a week
138
+ * per device, mid-task. Renewing on use turns that week into a week of
139
+ * ABSENCE. Two bounds keep it honest: not more often than `renewAfterMs` (a
140
+ * cookie per request would be noise, and the page polls every few seconds),
141
+ * and never once `maxLifeMs` has passed since the sign-in — past that the
142
+ * cookie is refused outright (`readSessionFull`), so a stolen one cannot be
143
+ * kept alive for ever just by being used.
144
+ */
145
+ export declare function sessionRenewal(sess: {
146
+ issuedAt: number;
147
+ since: number;
148
+ }, now: number, o: {
149
+ renewAfterMs: number;
150
+ maxLifeMs: number;
151
+ }): boolean;
124
152
  export declare function readSession(token: string, secret: Buffer, now: number, maxAgeMs: number): string | null;
125
153
  /** Is a session issued at `issuedAt` still good for this account? */
126
154
  export declare function sessionAlive(issuedAt: number, acct: Pick<Account, "sessionsAfter">): boolean;
package/dist/accounts.js CHANGED
@@ -165,34 +165,45 @@ export function bootstrapSessionsAfter(now) {
165
165
  return 0;
166
166
  }
167
167
  }
168
- /** `<user base64url>.<issuedAt>.<mfa>.<hmac>` — the name is encoded so a dot in
169
- * it cannot shift the fields. The ROLE is deliberately absent: it is re-read
170
- * from the account file at use time, so a demotion takes effect immediately
171
- * instead of riding in a stale cookie. `mfa` says the second factor was
172
- * presented when the cookie was issued: once two-factor is switched on, a
173
- * cookie without it is refused, which kills every session issued before. */
174
- export function signSession(user, issuedAt, secret, mfa = false) {
168
+ /** `<user base64url>.<issuedAt>.<mfa>.<since>.<hmac>` — the name is encoded so a
169
+ * dot in it cannot shift the fields. The ROLE is deliberately absent: it is
170
+ * re-read from the account file at use time, so a demotion takes effect
171
+ * immediately instead of riding in a stale cookie. `mfa` says the second factor
172
+ * was presented when the cookie was issued: once two-factor is switched on, a
173
+ * cookie without it is refused, which kills every session issued before.
174
+ * `since` is when the person actually SIGNED IN: a renewed cookie moves
175
+ * `issuedAt` forward and carries `since` along unchanged, which is what lets
176
+ * renewal have a ceiling (`sessionRenewal`). Omitted when it equals `issuedAt`
177
+ * — a sign-in — so that shape stays the four-field one it always was. */
178
+ export function signSession(user, issuedAt, secret, mfa = false, since = issuedAt) {
175
179
  const u = Buffer.from(user, "utf8").toString("base64url");
176
- const body = `${u}.${issuedAt}.${mfa ? 1 : 0}`;
180
+ const body = `${u}.${issuedAt}.${mfa ? 1 : 0}` + (since === issuedAt ? "" : `.${since}`);
177
181
  return `${body}.${createHmac("sha256", secret).update(body).digest("hex")}`;
178
182
  }
179
183
  /**
180
184
  * The user and second-factor flag a session cookie carries, or null. Reads the
181
185
  * pre-2FA three-field shape too — as `mfa: false`, which is what it was.
186
+ *
187
+ * Two clocks, two limits. `maxAgeMs` bounds the time since the cookie was last
188
+ * ISSUED (idle time, once cookies are renewed on use); `maxLifeMs` bounds the
189
+ * time since the SIGN-IN, which no renewal can push back.
182
190
  */
183
- export function readSessionFull(token, secret, now, maxAgeMs) {
191
+ export function readSessionFull(token, secret, now, maxAgeMs, maxLifeMs = Infinity) {
184
192
  const parts = String(token ?? "").split(".");
185
- if (parts.length !== 3 && parts.length !== 4)
193
+ if (parts.length < 3 || parts.length > 5)
186
194
  return null;
187
195
  const mac = parts[parts.length - 1];
188
196
  const body = parts.slice(0, -1).join(".");
189
197
  const [u, at] = parts;
190
- const mfa = parts.length === 4 ? parts[2] : "0";
198
+ const mfa = parts.length >= 4 ? parts[2] : "0";
191
199
  if (mfa !== "0" && mfa !== "1")
192
200
  return null;
193
201
  const issuedAt = Number(at);
194
202
  if (!at || !Number.isFinite(issuedAt))
195
203
  return null;
204
+ const since = parts.length === 5 ? Number(parts[3]) : issuedAt;
205
+ if (!Number.isFinite(since) || since > issuedAt)
206
+ return null;
196
207
  const want = createHmac("sha256", secret).update(body).digest("hex");
197
208
  if (mac.length !== want.length)
198
209
  return null;
@@ -200,14 +211,31 @@ export function readSessionFull(token, secret, now, maxAgeMs) {
200
211
  return null;
201
212
  if (now - issuedAt > maxAgeMs)
202
213
  return null;
214
+ if (now - since > maxLifeMs)
215
+ return null;
203
216
  try {
204
217
  const user = Buffer.from(u, "base64url").toString("utf8");
205
- return user ? { user, mfa: mfa === "1", issuedAt } : null;
218
+ return user ? { user, mfa: mfa === "1", issuedAt, since } : null;
206
219
  }
207
220
  catch {
208
221
  return null;
209
222
  }
210
223
  }
224
+ /**
225
+ * Should this session's cookie be re-issued now?
226
+ *
227
+ * A session used to last a week from the sign-in whatever happened in between,
228
+ * so someone working in the cockpit every day was still thrown out once a week
229
+ * per device, mid-task. Renewing on use turns that week into a week of
230
+ * ABSENCE. Two bounds keep it honest: not more often than `renewAfterMs` (a
231
+ * cookie per request would be noise, and the page polls every few seconds),
232
+ * and never once `maxLifeMs` has passed since the sign-in — past that the
233
+ * cookie is refused outright (`readSessionFull`), so a stolen one cannot be
234
+ * kept alive for ever just by being used.
235
+ */
236
+ export function sessionRenewal(sess, now, o) {
237
+ return now - sess.issuedAt >= o.renewAfterMs && now - sess.since < o.maxLifeMs;
238
+ }
211
239
  export function readSession(token, secret, now, maxAgeMs) {
212
240
  return readSessionFull(token, secret, now, maxAgeMs)?.user ?? null;
213
241
  }
@@ -1 +1 @@
1
- {"version":3,"file":"accounts.js","sourceRoot":"","sources":["../src/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA8CzC,wEAAwE;AACxE,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AAEvC,SAAS,SAAS;IAChB,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,CAAC;AACjF,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;QAC3D,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAA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