dbsc-toolkit 2.9.1 → 2.9.2

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 +31 -28
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -11,11 +11,27 @@
11
11
  >
12
12
  > Works with **Express · Fastify · Hono · Next.js · Redis · PostgreSQL**.
13
13
 
14
+ ## Contents
15
+
16
+ - [Install](#install)
17
+ - [Quick start](#quick-start)
18
+ - [Live demo](#live-demo)
19
+ - [Why dbsc-toolkit](#why-dbsc-toolkit)
20
+ - [Comparison](#comparison)
21
+ - [Why not JWT?](#why-not-just-use-jwt)
22
+ - [How it works](#how-it-works-the-30-second-version)
23
+ - [Who is this for?](#who-is-this-for)
24
+ - [Adding to an existing app](#adding-to-an-existing-app)
25
+ - [Protect your routes](#protect-your-routes)
26
+ - [Production checklist](#production-checklist)
27
+ - [API](#subpath-imports)
28
+ - [Going deeper](#going-deeper)
29
+
14
30
  ## Why dbsc-toolkit
15
31
 
16
32
  Native DBSC ships on Chrome 146+ for Windows users with a TPM. That's about a third of internet users. Every other DBSC implementation gives the rest of your users nothing — they remain on plain bearer cookies.
17
33
 
18
- This library is the **only** DBSC implementation that covers the other two-thirds via a Web Crypto polyfill. Same wire-level protection against cookie theft, same `requireProof()` guard server-side, key stored non-extractably in IndexedDB instead of a TPM. No biometric prompt, no user interaction, no checkbox.
34
+ This library is among the first DBSC implementations to provide a Web Crypto fallback for browsers that don't support native DBSC. Same wire-level protection against cookie theft, same `requireProof()` guard server-side, key stored non-extractably in IndexedDB instead of a TPM. No biometric prompt, no user interaction, no checkbox.
19
35
 
20
36
  - ✅ **Native W3C DBSC** on Chromium 146+ (TPM / Secure Enclave / Android Keystore)
21
37
  - ✅ **Web Crypto polyfill** on Firefox, Safari, older Chromium — same protection, IndexedDB key
@@ -117,35 +133,12 @@ DBSC complements your existing auth (passwords, MFA, JWT/session cookies) — it
117
133
  ## How it works (the 30-second version)
118
134
 
119
135
  ```
120
- Browser Server
121
- ─────── ──────
122
- │ POST /login (username, password) │
123
- │ ───────────────────────────────────────────────────▶ │
124
- │ │ verify password
125
- │ 200 + Secure-Session-Registration header │
126
- │ ◀─────────────────────────────────────────────────── │
127
- │ │
128
- │ generate keypair │
129
- │ (TPM / Secure Enclave / IndexedDB) │
130
- │ │
131
- │ POST /dbsc/registration │
132
- │ Secure-Session-Response: <JWS containing pub key> │
133
- │ ───────────────────────────────────────────────────▶ │
134
- │ │ verify self-signature
135
- │ │ store sessionId → pubkey
136
- │ 200 + __Host-dbsc-session cookie (Max-Age 10 min) │
137
- │ ◀─────────────────────────────────────────────────── │
138
- │ │
139
- │ every ~10 min, browser hits /dbsc/refresh │
140
- │ signing a fresh server challenge with the key │
141
- │ ───────────────────────────────────────────────────▶ │
142
- │ │ verify signature
143
- │ │ reissue cookie
144
- │ 200 + fresh __Host-dbsc-session │
145
- │ ◀─────────────────────────────────────────────────── │
136
+ Login → Key Registration → Cookie Issued → Challenge → Signature Verification → Session Refresh
146
137
  ```
147
138
 
148
- A copy of `__Host-dbsc-session` pasted into another browser has no matching key — the next refresh fails, the session demotes to `tier: "none"`, and `requireProof()` 403s every guarded request immediately (not on the next refresh cycle). Full walk-through with the exact wire format: [HOW-IT-WORKS.md](./HOW-IT-WORKS.md).
139
+ On login the server responds with a `Secure-Session-Registration` header. The browser generates an ECDSA keypair in the TPM (Chrome) or IndexedDB (Firefox/Safari/polyfill), POSTs the public key, and gets back a short-lived session cookie. Every ~10 minutes the browser re-signs a fresh server challenge to renew the cookie. A copy of the cookie pasted into another device has no key — the next refresh fails and `requireProof()` 403s every guarded request immediately.
140
+
141
+ Full wire-format walk-through: [HOW-IT-WORKS.md](./HOW-IT-WORKS.md).
149
142
 
150
143
  ## Who is this for?
151
144
 
@@ -220,6 +213,16 @@ For apps with a stricter threat model (active MITM, log-spillage exposure), v2.8
220
213
 
221
214
  The full threat boundary, 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).
222
215
 
216
+ ## Production checklist
217
+
218
+ - [ ] HTTPS enabled — DBSC requires `Secure` cookies; plain HTTP locks every user to `tier: "none"`
219
+ - [ ] Redis or PostgreSQL storage — `MemoryStorage` is lost on restart; bound browsers loop registration
220
+ - [ ] `requireProof()` on every authenticated route — read-only public routes need no guard
221
+ - [ ] `wrapFetch({ signBody: true })` on the client side for those routes (already the default in v2.8+)
222
+ - [ ] Replay cache enabled — `replayCache: new RedisReplayCache(redis)` in `createDbsc({...})`
223
+ - [ ] `trust proxy` already set — `install()` sets it, but verify if you have your own app config overriding it
224
+ - [ ] Polyfill script loaded — the `<script type="module">` tag; without it Firefox/Safari stay on `tier: "none"`
225
+
223
226
  ## Subpath imports
224
227
 
225
228
  | Import | What it is |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbsc-toolkit",
3
- "version": "2.9.1",
3
+ "version": "2.9.2",
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",