@abelxiaoxing/cadence 2.1.8 → 2.1.9

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
@@ -66,7 +66,9 @@ The token grants access to your workspace: keep the link private.
66
66
 
67
67
  ### Browser
68
68
 
69
- 1. Open the printed link once (`cadence token-link --reveal` prints it again).
69
+ 1. Open the ordinary address (for example `http://127.0.0.1:17423`) and enter your access key.
70
+ This browser stays signed in for up to a year, including after service restarts, while the token and cookie remain valid.
71
+ The printed private link still works (`cadence token-link --reveal` prints it again).
70
72
  2. Pick a working folder with the lower-right button.
71
73
  3. Send `/cadence [goal]`, then answer the clarifying questions.
72
74
  4. Click **Implement this plan** and follow the board and the **Subagents** dock.
package/README.zh-CN.md CHANGED
@@ -66,7 +66,9 @@ cadence server install # 可选的 WebUI 与开机服务
66
66
 
67
67
  ### 浏览器
68
68
 
69
- 1. 打开打印出的链接一次(`cadence token-link --reveal` 可再次打印)。
69
+ 1. 打开普通地址(例如 `http://127.0.0.1:17423`)并输入访问口令。
70
+ 同一浏览器、同一地址、令牌未变且 Cookie 有效时,最长一年内无需重新输入,重启服务后也继续有效。
71
+ 原有私有链接仍可使用(`cadence token-link --reveal` 可再次打印)。
70
72
  2. 用右下角按钮选择工作文件夹。
71
73
  3. 发送 `/cadence [目标]`,回答澄清问题。
72
74
  4. 点击 **Implement this plan**,在看板和 **Subagents** 面板中跟进。
@@ -48,10 +48,19 @@ Audit any additional proxy-generated forwarding headers against the exact backen
48
48
  HTTP and WebSocket upgrade must use the same authenticated route; no public backend bypass or insecure credential-bearing HTTP.
49
49
  This example does not install Caddy, provision DNS/certificates, change a firewall or deploy a service.
50
50
 
51
- Use `cadence-service token-link --workspace /absolute/project --reveal` to reveal a private entry link deliberately; the background service prints its link at `cadence server install` and `restart`.
52
- Only root GET token entry accepts query credentials; subsequent private reads, exports and WS use the HttpOnly SameSite=Strict Secure cookie.
53
- Browser mutations/readonly POSTs require exact Origin and CSRF; access does not grant Start/check/review consent.
51
+ Use `cadence-service token-link --workspace /absolute/project --reveal` to reveal a private entry link deliberately.
52
+ The background service prints its link at `cadence server install` and `restart`.
53
+ Unauthenticated `GET /` and `GET /app` answer 401 with a script-free password page (no script, no value backfill, no storage) that posts the key to `POST /auth`.
54
+ That page is the only `Referrer-Policy: same-origin` response, so a browser native form submits a valid Origin.
55
+ A correct key sets the `HttpOnly` `SameSite=Strict` cookie for one year (`Max-Age=31536000`) and 303s to the sanitized entry.
56
+ A wrong key redirects to the error page with a neutral notice and expires any stale cookie it carried; a sanitized `next` parameter preserves the selected project for another attempt.
57
+ Only the root `GET /?token=` bootstrap still accepts query credentials, and it sets the same one-year cookie.
58
+ Subsequent private reads, exports and WS use that cookie.
59
+ Browser mutations/readonly POSTs require exact Origin and CSRF.
60
+ `POST /auth` requires a present, exact Origin (missing/`null`/external is 403).
61
+ Access does not grant Start/check/review consent.
54
62
  A bad explicit token refuses even with an older cookie.
63
+ An invalid or rotated cookie is answered 401 (password page for HTML acceptors, JSON otherwise) and the cookie is expired.
55
64
  Never put provider credentials in a browser or URL.
56
65
 
57
66
  `token-rotate` invalidates old links/cookies, pending grants, authenticated sockets and incomplete downloads without canceling admitted tasks.
@@ -68,6 +77,7 @@ Use the same `proxy.origin` and trusted immediate proxy addresses as above; the
68
77
  The selected policy is retained in private workbench state, so after orderly `cadence workbench stop` a default `cadence server install` can register that entry without a project or a default workspace.
69
78
  Do not install over an independently running detached entry; stop it explicitly first.
70
79
  The gateway authenticates and validates Host/Origin before routing, rejects browser local-capability headers and management paths, and forwards project requests with browser cookies, not native authority.
80
+ Its unauthenticated `GET /` and `GET /app?project=` answer the same script-free 401 password page and `POST /auth` one-year cookie login as the owner; the sanitized entry preserves the `?project=` parameter.
71
81
  Project attachment IDs, owner CSRF/build compatibility, consent, retained read proofs and exports remain owner-validated.
72
82
  A workbench token rotation revokes its routes and retires its exact browser viewers without cancelling admitted project work.
73
83
  Project ports, backend cookies and local capabilities remain server-side.
@@ -185,7 +185,7 @@ After `npm install -g`, `pi install "$(npm root -g)/@abelxiaoxing/cadence"` reco
185
185
  Pi's own package install (`pi install npm:@abelxiaoxing/cadence`) also loads the native client and supports the WebUI update route above, but its copy puts no `cadence` on `PATH`; if you want the optional boot service, register it with `node ~/.pi/agent/npm/node_modules/@abelxiaoxing/cadence/src/service-cli.mjs server install`.
186
186
  Keep one copy: two copies drift apart on upgrade, and a native client refuses an owner whose service contract differs from its own.
187
187
  A unit registered by an earlier version's Pi install hook keeps running; `cadence server restart` from the copy you keep rewrites it, and `pi update` no longer restarts it.
188
- Opening the private link once leaves an HttpOnly cookie in that browser; the address without the token only explains how to get the link.
188
+ Opening the private link once leaves an HttpOnly `SameSite=Strict` cookie in that browser for one year; the address without the token shows a script-free password page that posts the key to `POST /auth` (a correct key sets the same one-year cookie).
189
189
 
190
190
  ### Port and token
191
191
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abelxiaoxing/cadence",
3
- "version": "2.1.8",
3
+ "version": "2.1.9",
4
4
  "description": "Conversation-driven Pi workspace: persistent native and WebUI workflows, explicit plan approval, checks and local delivery.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -19,6 +19,7 @@ var LIMITS = Object.freeze({
19
19
  stopWaitMs: 60000,
20
20
  authValidityMarginMs: 120000,
21
21
  browserLifetimeMs: 12 * 60 * 60 * 1000,
22
+ cookieLifetimeMs: 365 * 24 * 60 * 60 * 1000,
22
23
  terminateGraceMs: 1000,
23
24
  unconfirmedStopMs: 3000,
24
25
  graphBytes: 512 * 1024,
@@ -2,5 +2,5 @@
2
2
  export const nativeBuild = {
3
3
  kind: "native",
4
4
  contractHash:
5
- "6aa819700494584b707a8e1b44428c532cd7ac7b1c8a28126e401b43f527543b",
5
+ "d70dd3e63843be7df42ff10943fcdc78bcd27b881b0ac8222526e8dad7b0e6e2",
6
6
  } as const;
@@ -193,6 +193,7 @@ var LIMITS = Object.freeze({
193
193
  stopWaitMs: 60000,
194
194
  authValidityMarginMs: 120000,
195
195
  browserLifetimeMs: 12 * 60 * 60 * 1000,
196
+ cookieLifetimeMs: 365 * 24 * 60 * 60 * 1000,
196
197
  terminateGraceMs: 1000,
197
198
  unconfirmedStopMs: 3000,
198
199
  graphBytes: 512 * 1024,
@@ -4249,7 +4250,28 @@ class HttpAuthentication {
4249
4250
  throw new ContractError("forbidden");
4250
4251
  if (!this.material.matches(value))
4251
4252
  throw new ContractError("unauthenticated");
4252
- return buildTokenCookie(this.cookieName, encodeURIComponent(value), LIMITS.browserLifetimeMs / 1000, boundary.secure);
4253
+ return buildTokenCookie(this.cookieName, encodeURIComponent(value), LIMITS.cookieLifetimeMs / 1000, boundary.secure);
4254
+ }
4255
+ login(value, boundary) {
4256
+ this.material.assertCurrent();
4257
+ const origin = boundary.headers.get("origin");
4258
+ if (origin === undefined || origin !== boundary.origin)
4259
+ throw new ContractError("forbidden");
4260
+ if (!this.material.matches(value))
4261
+ throw new ContractError("unauthenticated");
4262
+ return buildTokenCookie(this.cookieName, encodeURIComponent(value), LIMITS.cookieLifetimeMs / 1000, boundary.secure);
4263
+ }
4264
+ clearCookie(secure) {
4265
+ return buildTokenCookie(this.cookieName, "", 0, secure);
4266
+ }
4267
+ carriesCookie(header) {
4268
+ if (!header)
4269
+ return false;
4270
+ for (const part of header.split(";")) {
4271
+ if (part.trim().split("=")[0] === this.cookieName)
4272
+ return true;
4273
+ }
4274
+ return false;
4253
4275
  }
4254
4276
  authenticate(boundary, attachmentId, mutation = false, websocket = false) {
4255
4277
  this.material.assertCurrent();