edisoncks/dsh-cookie-renew ↗★ 0

dsh-cookie-renew

在使用Web端时自动延长会话Cookie寿命 适合长期挂机使用Web端,免去频繁重新扫码或登录的用户。

包名
dsh-cookie-renew
兼容性
待验证
版本
1.0.0
许可证
MIT
最近更新
2026年10月25日

安装

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:edisoncks/dsh-cookie-renew

dsh-cookie-renew

CI

Sliding renewal for the DSH web GUI's browser-session cookie.

DSH mints its dsh-auth-* cookie once, during the ?token= exchange at GET /, with an absolute expiry (connection.cookieMaxAgeDays, default 30 days). Nothing refreshes it afterwards, so even a browser that visits every day has to reopen the tokenized startup URL once that absolute lifetime elapses.

This host plugin keeps the session alive while the GUI is in use. It listens on Connection's connection/request waterfall — which wraps every authenticated /api HTTP request after admission — and, when the cookie's remaining lifetime drops below a fraction of its total lifetime, re-runs DSH's own token exchange and attaches the fresh Set-Cookie to the live response.

  • One runtime dependency (@deepseek-ai/schemastery), host-side only, Node >= 20.
  • Installs from a pinned tag: dsh plugin --profile web add github:edisoncks/dsh-cookie-renew#v1.0.0 (see Install).
  • Never reads the signing secret and never signs a cookie itself.
  • Turns an absolute 30-day credential into a renewable one (see Caveats).

How it works

  1. connection/request fires after /api admission and before the response is written. The listener always calls next(), so API traffic is untouched.
  2. The plugin locates the dsh-auth-* cookie whose payload names the request's normalized authority (host:port over HTTP, https://host[:port] over TLS). The payload is only a scheduling hint — its signature is not trusted or checked. Candidates with a degenerate or already-elapsed payload are skipped, so a stale or planted value cannot mask the real cookie.
  3. When remaining = 20, engines.dsh ^0.2.1-rc.3. | | LICENSE | MIT license text. | | CHANGELOG.md | Release notes, one section per tag. | | package-lock.json | Lockfile for CI's npm ci; ignored when the package is consumed as a dependency. | | .github/workflows/ci.yml | CI: npm ci and npm test on Node 20/22/24, plus the packed-file-list check. |

Test

node --test test/*.test.js

The suite uses only node:test, so it needs no extra tooling. CI runs it on Node 20, 22, and 24 against the lockfile, then checks that npm pack still ships only the intended files.

Releases

Releases are annotated git tags named vX.Y.Z on main, and CHANGELOG.md records what changed. Installs should pin a tag (github:edisoncks/dsh-cookie-renew#v1.0.0), so an upgrade is an explicit edit of that tag rather than a silent move of a branch.

To cut one: bump version in package.json, add the matching CHANGELOG.md heading, commit, then:

git tag -a v1.0.0 -m v1.0.0
git push --follow-tags

Caveats

  • Only while valid. Admission rejects an expired cookie before the hook runs, so a lapsed session still needs the printed ?token= URL. This is a keep-alive, not a re-login.
  • Only /api HTTP requests. WebSocket frames, static assets, and the index page do not trigger a mint. Every page load issues API calls, so normal use is covered.
  • Tied to the 0.2.1 line. The hook and the two Connection methods are public, including the synthetic request/response shape, but the cookie prefix, the v1 payload shape, the authority spelling, the 303 status, and the lowercase set-cookie key are internal. engines.dsh pins the verified line, and an unknown payload version is logged once instead of stopping silently.
  • A stolen cookie becomes perpetually renewable. Keep the GUI loopback-only, or bound exposure with trustedHosts and TLS.
  • Per authority. Browsers ignore ports when sending cookies; DSH binds this cookie's name and payload to the request authority (host:port over HTTP, https://host[:port] over TLS) instead. Moving the GUI to another port therefore needs a fresh token exchange.

Uninstall

Switch it off, then remove it — the manager drops both the bundle selection and the profile dependency:

dsh plugin --profile web remove dsh-cookie-renew

Restart dsh web. Existing cookies remain valid until they expire. If you installed it by hand around an older layout, also delete any leftover - insert: block for it from ~/.dsh/profiles/web/cordis.patch.yml, or the entry comes back the next time the module resolves.

Troubleshooting

  • ERR_PNPM_STORE_DIR_OPEN_OPERATION_LOCK / read-only file system when installing inside a file sandbox: pnpm 12 keeps its store operation lock under $XDG_RUNTIME_DIR, which may be read-only there. Retry with env -u XDG_RUNTIME_DIR dsh plugin ….
  • No renewals: the cookie must already be below the threshold. Lower renewBelowFraction or enable debug.
  • A settings-form write is rejected: the schema is strict; the value is out of range or the wrong type. The profile is unchanged and the plugin keeps running.
  • Plugin entry fails after a manual config edit: the strict schema rejects wrong types and out-of-range values. Fix the field in the profile patch (Settings → General → Open configuration file) and restart dsh web; the rest of DSH keeps running and renewal is off until then.
  • unsupported payload version warning: DSH changed its cookie payload format. Update the plugin and its engines.dsh pin; the plugin stops renewing (it leaves the existing cookie untouched) until then.
  • could not mint ... status N: the token exchange returned an unexpected status (or no Set-Cookie). That usually means a harness change; check the pin.
  • Connection does not expose ... at mount: the harness no longer matches the pinned range. The plugin disables itself instead of failing every request.
  • Plugin missing from the sidebar Plugins page: that page lists bundles, so check "dsh-cookie-renew" in dsh.profile.bundles and that package.json still declares dsh.bundle.patch. A bundle selected without a bundle patch shows up with a not-bundle problem instead.
  • The row is mounted at boot: restart dsh web after changing the bundle selection or the patch.

License

MIT © 2026 Edison Chong.