dbsc-toolkit 2.3.0 → 2.3.1

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 (2) hide show
  1. package/README.md +11 -8
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -100,17 +100,20 @@ You don't rewrite login, you don't migrate the session store. DBSC sits alongsid
100
100
 
101
101
  `sessionId` on line 5 is whatever id your existing session store already issues. DBSC binds to that same id; you don't manage a second id-space.
102
102
 
103
- **One guard per sensitive route required, not optional:**
103
+ ## Choose your protection level per route
104
104
 
105
- ```ts
106
- app.post("/payment", requireBoundProof({ storage: dbscStorage }), paymentHandler);
107
- app.post("/settings/password", requireBoundProof({ storage: dbscStorage }), passwordHandler);
108
- app.use("/admin", requireBoundProof({ storage: dbscStorage })); // gates everything under /admin
109
- ```
105
+ After the 6-line setup, every request through the middleware has a `tier` field on the request context. The library does not auto-protect anything — you pick the level per route. The library exposes three levers; this table tells you which one to reach for.
106
+
107
+ | Your route does… | Use this guard | What it stops | Detailed in |
108
+ |---|---|---|---|
109
+ | Public / read-only (feed, search, public profile) | Nothing | n/a — no auth gate at all | n/a |
110
+ | Authenticated action with no money / takeover risk (post, comment, upvote, edit own bio) | `if (req.dbsc.tier === "none") return 403` | Stolen cookie loses access after one refresh cycle (~60s–10min depending on `boundCookieTtl`) | [docs/integrating-existing-auth.md](./docs/integrating-existing-auth.md) (per-route policy table) |
111
+ | Account takeover risk (password change, email change, admin actions) | `requireBoundProof({ storage })` | Stolen cookie cannot ride along even while the victim is online — Firefox / Safari now have the same guarantee Chrome gets from native DBSC | [docs/per-request-signing.md](./docs/per-request-signing.md) |
112
+ | Moves money or numeric input that matters (payment, transfer, refund, withdraw) | `requireBoundProof({ storage, signBody: true })` on the server + `wrapFetch({ signBody: true })` on the client | All of the above PLUS an active MITM cannot substitute the request body (amount, recipient, etc.) within the timestamp window | [docs/per-request-signing.md#body-signing-setup-v230](./docs/per-request-signing.md) |
110
113
 
111
- The `tier` field on every request is informational. Without a guard, a stolen cookie still reaches your handler the library cannot infer which routes are sensitive, you mark them. `requireBoundProof` lets native DBSC traffic (`tier: "dbsc"`) through automatically (Chromium enforces session validity browser-side); Firefox / Safari traffic (`tier: "bound"`) must carry a fresh per-request signature, which the client-side [`wrapFetch()`](./docs/per-request-signing.md) adds for you. For payment routes, pass `signBody: true` to both helpers (v2.3.0+) so the body hash is signed into the proof closes the MITM body-substitution gap.
114
+ **Each row is opt-in and additive.** A route can sit at row 2 today and graduate to row 3 next quarter when you ship payments no migration, no wire-format change, no version bump. The defaults (no guard) give DBSC's binding semantics without enforcement; pick the row your threat model needs.
112
115
 
113
- Fastify / Hono / Next.js variants of these six lines, plus the per-route policy table and a 30-day rollout timeline, are in [docs/integrating-existing-auth.md](./docs/integrating-existing-auth.md).
116
+ The full threat boundary for each level, the per-framework wiring (Fastify / Hono / Next.js), and the migration timeline for an existing app are in [docs/integrating-existing-auth.md](./docs/integrating-existing-auth.md) and [docs/per-request-signing.md](./docs/per-request-signing.md).
114
117
 
115
118
  ## Subpath imports
116
119
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbsc-toolkit",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Server-side Device Bound Session Credentials (DBSC) for Node.js plus a Web Crypto polyfill for Firefox, Safari, and older Chromium. Cookie-theft protection on every modern browser.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",