dbsc-toolkit 2.13.2 → 2.13.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"require-proof.d.ts","sourceRoot":"","sources":["../../src/express/require-proof.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmC,cAAc,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAmB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAI7E;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,mBAAwB,GAAG,cAAc,CA2C3E"}
1
+ {"version":3,"file":"require-proof.d.ts","sourceRoot":"","sources":["../../src/express/require-proof.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmC,cAAc,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAmB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAI7E;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,mBAAwB,GAAG,cAAc,CAyC3E"}
@@ -18,7 +18,6 @@ import { DBSC_INTERNAL } from "./index.js";
18
18
  * middleware populates; pass `{ storage }` only to override.
19
19
  */
20
20
  export function requireProof(opts = {}) {
21
- let proofHandler;
22
21
  return (req, res, next) => {
23
22
  const dbsc = res.locals.dbsc;
24
23
  const tier = dbsc?.tier ?? "none";
@@ -32,27 +31,27 @@ export function requireProof(opts = {}) {
32
31
  });
33
32
  return;
34
33
  }
35
- if (!proofHandler) {
36
- const internal = res.locals[DBSC_INTERNAL];
37
- const storage = opts.storage ?? internal?.storage;
38
- if (!storage) {
39
- res.status(500).json({
40
- error: "requireProof: storage unavailable — mount dbsc() / createDbsc().install() before this route, or pass { storage }",
41
- });
42
- return;
43
- }
44
- // When the bound polyfill is disabled, no bound key is ever registered,
45
- // so a native dbsc-tier session has nothing to prove with. Auto-relax:
46
- // pass dbsc through. An explicit option still wins.
47
- const allowDbscWithoutProof = opts.allowDbscWithoutProof ?? (internal?.boundEnabled === false ? true : undefined);
48
- proofHandler = requireBoundProof({
49
- storage,
50
- signBody: true,
51
- ...(allowDbscWithoutProof !== undefined && { allowDbscWithoutProof }),
52
- ...(opts.timestampWindowMs !== undefined && { timestampWindowMs: opts.timestampWindowMs }),
53
- ...(internal?.replayCache !== undefined && { replayCache: internal.replayCache }),
34
+ const internal = res.locals[DBSC_INTERNAL];
35
+ const storage = opts.storage ?? internal?.storage;
36
+ if (!storage) {
37
+ res.status(500).json({
38
+ error: "requireProof: storage unavailable — mount dbsc() / createDbsc().install() before this route, or pass { storage }",
54
39
  });
40
+ return;
55
41
  }
42
+ // When the bound polyfill is disabled, no bound key is ever registered, so a
43
+ // native dbsc-tier session has nothing to prove with. Auto-relax: pass dbsc
44
+ // through. An explicit option still wins. Resolved per request — boundEnabled
45
+ // can differ between requests (e.g. two kits dispatched by mode), so the
46
+ // handler must not be memoized across the first call's value.
47
+ const allowDbscWithoutProof = opts.allowDbscWithoutProof ?? (internal?.boundEnabled === false ? true : undefined);
48
+ const proofHandler = requireBoundProof({
49
+ storage,
50
+ signBody: true,
51
+ ...(allowDbscWithoutProof !== undefined && { allowDbscWithoutProof }),
52
+ ...(opts.timestampWindowMs !== undefined && { timestampWindowMs: opts.timestampWindowMs }),
53
+ ...(internal?.replayCache !== undefined && { replayCache: internal.replayCache }),
54
+ });
56
55
  proofHandler(req, res, next);
57
56
  };
58
57
  }
@@ -1 +1 @@
1
- {"version":3,"file":"require-proof.js","sourceRoot":"","sources":["../../src/express/require-proof.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAA4B,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAqB,MAAM,YAAY,CAAC;AAE9D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,YAAY,CAAC,OAA4B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AE,OAAO,CAAC;QAClD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACnB,KAAK,EACH,kHAAkH;aACrH,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QACD,6EAA6E;QAC7E,4EAA4E;QAC5E,8EAA8E;QAC9E,yEAAyE;QACzE,8DAA8D;QAC9D,MAAM,qBAAqB,GACzB,IAAI,CAAC,qBAAqB,IAAI,CAAC,QAAQ,EAAE,YAAY,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACtF,MAAM,YAAY,GAAG,iBAAiB,CAAC;YACrC,OAAO;YACP,QAAQ,EAAE,IAAI;YACd,GAAG,CAAC,qBAAqB,KAAK,SAAS,IAAI,EAAE,qBAAqB,EAAE,CAAC;YACrE,GAAG,CAAC,IAAI,CAAC,iBAAiB,KAAK,SAAS,IAAI,EAAE,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC1F,GAAG,CAAC,QAAQ,EAAE,WAAW,KAAK,SAAS,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC;SAClF,CAAC,CAAC;QACH,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"require-proof.d.ts","sourceRoot":"","sources":["../../src/fastify/require-proof.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgC,0BAA0B,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAmB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAI7E;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,mBAAwB,GAAG,0BAA0B,CAyCvF"}
1
+ {"version":3,"file":"require-proof.d.ts","sourceRoot":"","sources":["../../src/fastify/require-proof.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgC,0BAA0B,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAmB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAI7E;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,mBAAwB,GAAG,0BAA0B,CAuCvF"}
@@ -12,7 +12,6 @@ import { DBSC_INTERNAL } from "./index.js";
12
12
  * context the `dbsc` plugin populates; pass `{ storage }` only to override.
13
13
  */
14
14
  export function requireProof(opts = {}) {
15
- let proofHandler;
16
15
  return async function preHandler(req, reply) {
17
16
  const dbsc = req.dbsc;
18
17
  const tier = dbsc?.tier ?? "none";
@@ -26,25 +25,25 @@ export function requireProof(opts = {}) {
26
25
  });
27
26
  return;
28
27
  }
29
- if (!proofHandler) {
30
- const internal = req[DBSC_INTERNAL];
31
- const storage = opts.storage ?? internal?.storage;
32
- if (!storage) {
33
- reply.status(500).send({
34
- error: "requireProof: storage unavailable — register the dbsc plugin / createDbsc().install() first, or pass { storage }",
35
- });
36
- return;
37
- }
38
- // bound polyfill off → no bound key exists → auto-relax the dbsc tier.
39
- const allowDbscWithoutProof = opts.allowDbscWithoutProof ?? (internal?.boundEnabled === false ? true : undefined);
40
- proofHandler = requireBoundProof({
41
- storage,
42
- signBody: true,
43
- ...(allowDbscWithoutProof !== undefined && { allowDbscWithoutProof }),
44
- ...(opts.timestampWindowMs !== undefined && { timestampWindowMs: opts.timestampWindowMs }),
45
- ...(internal?.replayCache !== undefined && { replayCache: internal.replayCache }),
28
+ const internal = req[DBSC_INTERNAL];
29
+ const storage = opts.storage ?? internal?.storage;
30
+ if (!storage) {
31
+ reply.status(500).send({
32
+ error: "requireProof: storage unavailable — register the dbsc plugin / createDbsc().install() first, or pass { storage }",
46
33
  });
34
+ return;
47
35
  }
36
+ // bound polyfill off → no bound key exists → auto-relax the dbsc tier.
37
+ // Resolved per request — boundEnabled can differ between requests (e.g. two
38
+ // plugins dispatched by mode), so the handler must not be memoized.
39
+ const allowDbscWithoutProof = opts.allowDbscWithoutProof ?? (internal?.boundEnabled === false ? true : undefined);
40
+ const proofHandler = requireBoundProof({
41
+ storage,
42
+ signBody: true,
43
+ ...(allowDbscWithoutProof !== undefined && { allowDbscWithoutProof }),
44
+ ...(opts.timestampWindowMs !== undefined && { timestampWindowMs: opts.timestampWindowMs }),
45
+ ...(internal?.replayCache !== undefined && { replayCache: internal.replayCache }),
46
+ });
48
47
  await proofHandler(req, reply);
49
48
  };
50
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"require-proof.js","sourceRoot":"","sources":["../../src/fastify/require-proof.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAA4B,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAqB,MAAM,YAAY,CAAC;AAE9D;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CAAC,OAA4B,EAAE;IACzD,IAAI,YAAoD,CAAC;IAEzD,OAAO,KAAK,UAAU,UAAU,CAAC,GAAmB,EAAE,KAAmB;QACvE,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,MAAM,IAAI,GAAG,IAAI,EAAE,IAAI,IAAI,MAAM,CAAC;QAClC,MAAM,OAAO,GAAG,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC;QACpC,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YACpB,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACrB,KAAK,EAAE,+BAA+B;gBACtC,WAAW,EAAE,MAAM;gBACnB,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC;gBAChC,OAAO;aACR,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QACD,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,QAAQ,GAAI,GAA+C,CAAC,aAAa,CAElE,CAAC;Y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C,WAAW,EAAE,CAAC;SAClF,CAAC,CAAC;QACH,MAAO,YAA4E,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAClG,CAAC,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"require-proof.d.ts","sourceRoot":"","sources":["../../src/hono/require-proof.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAmB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAI7E;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,mBAAwB,GAAG,iBAAiB,CA6C9E"}
1
+ {"version":3,"file":"require-proof.d.ts","sourceRoot":"","sources":["../../src/hono/require-proof.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAmB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAI7E;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,mBAAwB,GAAG,iBAAiB,CA2C9E"}
@@ -11,7 +11,6 @@ import { DBSC_INTERNAL } from "./index.js";
11
11
  * populates; pass `{ storage }` only to override.
12
12
  */
13
13
  export function requireProof(opts = {}) {
14
- let proofHandler;
15
14
  return async (c, next) => {
16
15
  const dbsc = c.get("dbsc");
17
16
  const tier = dbsc?.tier ?? "none";
@@ -24,24 +23,24 @@ export function requireProof(opts = {}) {
24
23
  skipped,
25
24
  }, 403);
26
25
  }
27
- if (!proofHandler) {
28
- const internal = dbsc?.[DBSC_INTERNAL];
29
- const storage = opts.storage ?? internal?.storage;
30
- if (!storage) {
31
- return c.json({
32
- error: "requireProof: storage unavailable — mount dbsc() / createDbsc().install() before this route, or pass { storage }",
33
- }, 500);
34
- }
35
- // bound polyfill off → no bound key exists → auto-relax the dbsc tier.
36
- const allowDbscWithoutProof = opts.allowDbscWithoutProof ?? (internal?.boundEnabled === false ? true : undefined);
37
- proofHandler = requireBoundProof({
38
- storage,
39
- signBody: true,
40
- ...(allowDbscWithoutProof !== undefined && { allowDbscWithoutProof }),
41
- ...(opts.timestampWindowMs !== undefined && { timestampWindowMs: opts.timestampWindowMs }),
42
- ...(internal?.replayCache !== undefined && { replayCache: internal.replayCache }),
43
- });
26
+ const internal = dbsc?.[DBSC_INTERNAL];
27
+ const storage = opts.storage ?? internal?.storage;
28
+ if (!storage) {
29
+ return c.json({
30
+ error: "requireProof: storage unavailable — mount dbsc() / createDbsc().install() before this route, or pass { storage }",
31
+ }, 500);
44
32
  }
33
+ // bound polyfill off → no bound key exists → auto-relax the dbsc tier.
34
+ // Resolved per request — boundEnabled can differ between requests (e.g. two
35
+ // middlewares dispatched by mode), so the handler must not be memoized.
36
+ const allowDbscWithoutProof = opts.allowDbscWithoutProof ?? (internal?.boundEnabled === false ? true : undefined);
37
+ const proofHandler = requireBoundProof({
38
+ storage,
39
+ signBody: true,
40
+ ...(allowDbscWithoutProof !== undefined && { allowDbscWithoutProof }),
41
+ ...(opts.timestampWindowMs !== undefined && { timestampWindowMs: opts.timestampWindowMs }),
42
+ ...(internal?.replayCache !== undefined && { replayCache: internal.replayCache }),
43
+ });
45
44
  return proofHandler(c, next);
46
45
  };
47
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"require-proof.js","sourceRoot":"","sources":["../../src/hono/require-proof.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAA4B,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAqB,MAAM,YAAY,CAAC;AAE9D;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,OAA4B,EAAE;IACzD,IAAI,YAA2C,CAAC;IAEhD,OAAO,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;QACvB,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,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,YAAY,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACtF,MAAM,YAAY,GAAG,iBAAiB,CAAC;YACrC,OAAO;YACP,QAAQ,EAAE,IAAI;YACd,GAAG,CAAC,qBAAqB,KAAK,SAAS,IAAI,EAAE,qBAAqB,EAAE,CAAC;YACrE,GAAG,CAAC,IAAI,CAAC,iBAAiB,KAAK,SAAS,IAAI,EAAE,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC1F,GAAG,CAAC,QAAQ,EAAE,WAAW,KAAK,SAAS,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC;SAClF,CAAC,CAAC;QACH,OAAO,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbsc-toolkit",
3
- "version": "2.13.2",
3
+ "version": "2.13.3",
4
4
  "description": "Server-side Device Bound Session Credentials (DBSC) for Node.js — Express, Fastify, Hono and Next.js adapters — 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",