@blamejs/core 0.15.29 → 0.15.30

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/CHANGELOG.md CHANGED
@@ -8,6 +8,8 @@ upgrading across more than a few patches at a time.
8
8
 
9
9
  ## v0.15.x
10
10
 
11
+ - v0.15.30 (2026-06-26) — **Importing the webhook module for inbound signature verification no longer pulls the Node HTTP client (or its `node:http` / `node:https` / `node:http2` chain), so `b.webhook.verify` runs in a Worker / edge runtime when the module is imported directly.** lib/webhook and its delivery store eagerly required the outbound HTTP client at module load — directly, and transitively through the persistence-backed dispatcher — so importing the webhook module threw in a Cloudflare Workers / edge runtime that has no node:http / node:net / node:tls, even though b.webhook.verify needs only HMAC-SHA-256 and a timing-safe compare. The HTTP client and the SQL-backed dispatcher are now resolved lazily, only on the outbound send / dispatch paths; importing the module for inbound verification loads no Node networking module. Verified by asserting no networking builtin appears in process.moduleLoadList on the verify path. The framework's aggregate entry point still initializes the networking stack eagerly, so the edge verify path is the webhook module imported directly rather than the aggregate b namespace. **Fixed:** *Inbound webhook verification loads without the Node networking stack (Worker / edge runtime)* — The webhook module and its dispatcher delivery store required the outbound HTTP client (node:http / node:https / node:http2) at module load, so importing the module threw in a runtime without those builtins — even though b.webhook.verify is HMAC-SHA-256 plus a timing-safe compare and the dispatcher (SQL-backed persistence) is only needed for outbound delivery. The HTTP client and the dispatcher are now resolved lazily, on the outbound send / dispatch paths only; the inbound verify path loads no Node networking module. An edge handler that imports the webhook module directly can pre-verify an inbound Stripe webhook signature with the primitive's hardening (Stripe-Signature size cap, v1-hex anti-DoS cap, minimum-tolerance floor, optional atomic replay store) instead of hand-rolling the t=/v1= parse, tolerance window, and timing-safe compare. The framework's aggregate entry still loads the networking stack eagerly; import the webhook module directly for the edge verify path.
12
+
11
13
  - v0.15.29 (2026-06-25) — **JSON parsing of operator and untrusted input is routed through `b.safeJson` everywhere, so a `"__proto__"` member is stripped and the parse is size-bounded — `b.openapi.parse`, `b.asyncapi.parse`, and `b.sandbox.run` were using a raw `JSON.parse`.** b.openapi.parse and b.asyncapi.parse parsed an operator-supplied document string with a raw JSON.parse, which re-creates a "__proto__" member as an own key and imposes no size bound; b.sandbox.run parsed the untrusted sandboxed code's serialized result the same way (proto member kept, depth unbounded). All three now route through b.safeJson, which strips the prototype-pollution keys and applies the depth / key / size caps. A new b.safeJson.parseStringOrObject primitive captures the recurring "accept a document as a JSON string OR a pre-built object" shape (a string is parsed safely, an object passes through) that openapi and asyncapi had each hand-rolled, with each consumer's typed error class and a generous document size cap passed as data. Valid input parses identically to before; a malicious or oversized document is now defused rather than accepted. **Added:** *b.safeJson.parseStringOrObject(input, opts?)* — Accepts either a JSON string — parsed through b.safeJson.parse, so the prototype-pollution-key strip and depth / key / size caps apply — or an already-decoded plain object (returned unchanged). For the recurring "operator hands me a document as a JSON string or a pre-built object" surface (b.openapi / b.asyncapi). The consumer's typed error class, error codes, label, and size cap are passed as options, so a raw JSON.parse on operator input cannot be hand-rolled per consumer. **Security:** *Operator and untrusted JSON parses strip __proto__ and bound size (no raw JSON.parse)* — A raw JSON.parse keeps a "__proto__" object member as an own key (a prototype-pollution gadget for any downstream merge) and parses unbounded input. b.openapi.parse and b.asyncapi.parse used it on operator document strings, and b.sandbox.run used it on the untrusted sandboxed code's JSON-serialized result. All now route through b.safeJson — the prototype-pollution keys are stripped and the depth / key / size caps apply (a 16 MiB document cap for openapi/asyncapi, the existing result-bytes cap for the sandbox). Internal JSON parses (the sealed DSR store payloads, the VEX canonical re-format) route through the same primitive too, so the guarantee cannot be bypassed one call site at a time. Valid input is unaffected; a "__proto__"-laden or oversized payload is defused.
12
14
 
13
15
  - v0.15.28 (2026-06-25) — **`b.network.dns` and `b.network.tls` errors now carry a usable terminal-vs-transient signal on `err.permanent`, so a caller's retry loop re-attempts only the failures a retry can fix.** DnsError was declared always-transient and NetworkTlsError always-permanent, so a consumer driving its own retry loop got the wrong signal in both directions: it would retry a permanent DNS failure (a bad host, bad options, an unsupported query, an NXDOMAIN-style no-result, or a caller-shape/config error such as an unconfigured transport or an invalid resolver list) forever, and it would refuse to retry a transient TLS-over-network failure (an ECH connection failure, a handshake timeout, DNS momentarily unavailable). err.permanent now reflects each error's actual transience, derived from its code and failing closed (an unknown code is permanent, so a hopeless target is not retried indefinitely): for DnsError only a failed network round-trip (a lookup timeout, a resolve/reverse query that failed on the wire, a failed DoH/DoT exchange, a DDR discovery that found nothing) is transient — config, input, and environment errors raised before any network work are permanent; for NetworkTlsError only the network-layer ECH failures are transient. TlsTrustError remains always-permanent by design — a trust-verification failure (bad CA, fingerprint mismatch, OCSP not-good, CT violation, an unreachable OCSP responder) must never be silently retried past the trust decision. **Fixed:** *DnsError / NetworkTlsError expose a correct terminal/transient signal; TlsTrustError stays terminal* — b.network.dns's DnsError was always-transient and b.network.tls's NetworkTlsError always-permanent, so err.permanent misled a consumer's retry loop in both directions — retrying a permanent DNS error (bad host / options / unsupported type / no-result) indefinitely, and never retrying a transient TLS network error (ECH connect failure, handshake timeout, DNS unavailable). err.permanent now reflects each error's actual transience by code and fails closed (unknown codes are permanent): DnsError is transient only for a failed network round-trip (dns/lookup-timeout, dns/resolve-failed, dns/reverse-failed, dns/doh-failed, dns/dot-failed, dns/dot-handshake-failed, dns/ddr-not-discovered, dns/system-failed), and permanent otherwise — including the caller-shape / environment errors raised before any network work (dns/transport-unavailable for an unconfigured transport, dns/dnr-no-resolvers for an empty/invalid resolver list, dns/setservers-failed for an invalid address, dns/no-system-resolvers when none are configured). NetworkTlsError is transient only for the network-layer ECH failures (tls/ech-connect-failed, tls/ech-timeout, tls/ech-dns-unavailable), permanent otherwise. TlsTrustError remains always-permanent so a trust-verification failure is never silently retried.
@@ -26,7 +26,6 @@ var safeSql = require("./safe-sql");
26
26
  var safeUrl = require("./safe-url");
27
27
  var safeJson = require("./safe-json");
28
28
  var bCrypto = require("./crypto");
29
- var httpClient = require("./http-client");
30
29
  var frameworkSchema = require("./framework-schema");
31
30
  var validateOpts = require("./validate-opts");
32
31
  var lazyRequire = require("./lazy-require");
@@ -44,6 +43,11 @@ var vault = lazyRequire(function () { return require("./vault"); });
44
43
  var ssrfGuard = lazyRequire(function () { return require("./ssrf-guard"); });
45
44
  var audit = lazyRequire(function () { return require("./audit"); });
46
45
  var observability = lazyRequire(function () { return require("./observability"); });
46
+ // Lazy — http-client pulls in node:http / node:https / node:http2; only the
47
+ // default delivery transport touches it. Keeping it lazy keeps b.webhook (which
48
+ // re-exports this module) free of the Node networking chain on its inbound
49
+ // verify path, so b.webhook.verify stays loadable in a Worker / edge runtime.
50
+ var httpClient = lazyRequire(function () { return require("./http-client"); });
47
51
 
48
52
  var _err = WebhookDispatcherError.factory;
49
53
 
@@ -223,7 +227,7 @@ function dispatcher(opts) {
223
227
  // Default transport: a real signed POST through the framework http client.
224
228
  // Injectable so a test (or a non-HTTP transport) substitutes its own.
225
229
  var httpRequest = opts.httpRequest || function (url, body, headers) {
226
- return httpClient.request({
230
+ return httpClient().request({
227
231
  method: "POST",
228
232
  url: url,
229
233
  headers: headers,
package/lib/webhook.js CHANGED
@@ -50,7 +50,6 @@
50
50
  var nodeCrypto = require("node:crypto");
51
51
  var numericBounds = require("./numeric-bounds");
52
52
  var bCrypto = require("./crypto");
53
- var httpClient = require("./http-client");
54
53
  var safeBuffer = require("./safe-buffer");
55
54
  var safeUrl = require("./safe-url");
56
55
  var retryHelper = require("./retry");
@@ -60,12 +59,20 @@ var numericChecks = require("./numeric-checks");
60
59
  var requestHelpers = require("./request-helpers");
61
60
  // Lazy — ssrf-guard pulls in the DNS/network stack; only touched on send().
62
61
  var ssrfGuard = lazyRequire(function () { return require("./ssrf-guard"); });
62
+ // Lazy — http-client pulls in node:http / node:https / node:http2; only the
63
+ // outbound send() path touches it. Keeping it lazy lets b.webhook.verify (HMAC
64
+ // + timing-safe compare only) load in a Worker / edge runtime with no Node
65
+ // networking module available.
66
+ var httpClient = lazyRequire(function () { return require("./http-client"); });
63
67
  var validateOpts = require("./validate-opts");
64
68
  var { WebhookError } = require("./framework-error");
65
69
  // b.webhook.dispatcher — durable signed-webhook delivery store. Lives in its
66
- // own module (distinct domain: persistence) and lazyRequires this file back,
67
- // so this top-level require is cycle-safe.
68
- var webhookDispatcher = require("./webhook-dispatcher");
70
+ // own module (distinct domain: persistence) and pulls the SQL stack (and so
71
+ // node:fs). Lazy only resolved when b.webhook.dispatcher is accessed — so
72
+ // importing the webhook module for the inbound verify path stays free of the
73
+ // persistence/networking stack and loads in a Worker / edge runtime. The
74
+ // module lazyRequires this file back, so the cycle stays deferred on both ends.
75
+ var webhookDispatcher = lazyRequire(function () { return require("./webhook-dispatcher"); });
69
76
 
70
77
  var observability = lazyRequire(function () { return require("./observability"); });
71
78
 
@@ -472,7 +479,7 @@ function signer(opts) {
472
479
  } catch (_e) { hostLabel = ""; }
473
480
  try {
474
481
  var res = await retryHelper.withRetry(function () {
475
- return httpClient.request(requestOpts);
482
+ return httpClient().request(requestOpts);
476
483
  }, retryOpts);
477
484
  var statusCode = (res && (res.statusCode || res.status)) || 0;
478
485
  _emitEvent("webhook.send", 1, {
@@ -1011,7 +1018,14 @@ module.exports = {
1011
1018
  // v0.11.25 — Stripe-shaped inbound HMAC-SHA-256 verifier + signer.
1012
1019
  verify: verify,
1013
1020
  sign: sign,
1014
- // Durable signed-webhook delivery store (sign + persist + deliver + retry +
1015
- // dead-letter + operator replay). Defined in lib/webhook-dispatcher.js.
1016
- dispatcher: webhookDispatcher.dispatcher,
1017
1021
  };
1022
+
1023
+ // Durable signed-webhook delivery store (sign + persist + deliver + retry +
1024
+ // dead-letter + operator replay). Defined in lib/webhook-dispatcher.js, which
1025
+ // pulls the SQL/persistence stack — exposed as a lazy getter so requiring the
1026
+ // webhook module for the inbound verify path doesn't load it (edge-safe).
1027
+ Object.defineProperty(module.exports, "dispatcher", {
1028
+ enumerable: true,
1029
+ configurable: true,
1030
+ get: function () { return webhookDispatcher().dispatcher; },
1031
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blamejs/core",
3
- "version": "0.15.29",
3
+ "version": "0.15.30",
4
4
  "description": "The Node framework that owns its stack.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "blamejs contributors",
package/sbom.cdx.json CHANGED
@@ -2,10 +2,10 @@
2
2
  "$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
3
3
  "bomFormat": "CycloneDX",
4
4
  "specVersion": "1.5",
5
- "serialNumber": "urn:uuid:9d6b0acf-4b88-47bc-b14b-ba2342410a0e",
5
+ "serialNumber": "urn:uuid:4fb829b1-aa27-4095-8449-786674226709",
6
6
  "version": 1,
7
7
  "metadata": {
8
- "timestamp": "2026-06-26T09:20:08.812Z",
8
+ "timestamp": "2026-06-26T11:54:05.342Z",
9
9
  "lifecycles": [
10
10
  {
11
11
  "phase": "build"
@@ -19,14 +19,14 @@
19
19
  }
20
20
  ],
21
21
  "component": {
22
- "bom-ref": "@blamejs/core@0.15.29",
22
+ "bom-ref": "@blamejs/core@0.15.30",
23
23
  "type": "application",
24
24
  "name": "blamejs",
25
- "version": "0.15.29",
25
+ "version": "0.15.30",
26
26
  "scope": "required",
27
27
  "author": "blamejs contributors",
28
28
  "description": "The Node framework that owns its stack.",
29
- "purl": "pkg:npm/%40blamejs/core@0.15.29",
29
+ "purl": "pkg:npm/%40blamejs/core@0.15.30",
30
30
  "properties": [],
31
31
  "externalReferences": [
32
32
  {
@@ -54,7 +54,7 @@
54
54
  "components": [],
55
55
  "dependencies": [
56
56
  {
57
- "ref": "@blamejs/core@0.15.29",
57
+ "ref": "@blamejs/core@0.15.30",
58
58
  "dependsOn": []
59
59
  }
60
60
  ]