@blamejs/core 0.15.21 → 0.15.23
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 +4 -0
- package/lib/framework-error.js +14 -0
- package/lib/safe-path.js +24 -10
- package/lib/ws-client.js +39 -28
- package/package.json +1 -1
- package/sbom.cdx.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,10 @@ upgrading across more than a few patches at a time.
|
|
|
8
8
|
|
|
9
9
|
## v0.15.x
|
|
10
10
|
|
|
11
|
+
- v0.15.23 (2026-06-24) — **`b.wsClient` error objects now carry a usable terminal-vs-transient signal (and the client's auto-reconnect, previously dead, works again), and `b.safePath` resolves cross-platform containment with the target platform's path semantics — fixing both a false refusal of in-base paths and a backslash-traversal escape when validating for Windows on a POSIX host.** Two correctness fixes. b.wsClient marked every WsClientError permanent, so a consumer driving its own reconnect loop could not tell a terminal handshake failure (a bad URL, a 4xx rejection, an accept-mismatch, a protocol-violation frame) from a transient one (a 5xx handshake rejection, a pong/handshake timeout, a dropped socket) and had to re-derive the taxonomy from error codes. err.permanent now reflects the actual transience of each error, the single bad-status code is split by the carried HTTP status (4xx terminal, 5xx transient) with the status exposed as err.statusCode, and — because the client's own auto-reconnect keyed off the same always-true flag — auto-reconnect was silently disabled for every transient failure and now fires correctly. Separately, b.safePath.resolve / resolveOrNull / validate performed its lexical containment with the runtime path module while the per-segment naming walk used opts.platform. The two disagreeing broke cross-platform validation both ways: every legitimate in-base path was refused with safe-path/escapes-base when opts.platform differed from the host, and — more seriously — a POSIX host validating opts.platform: "windows" accepted a backslash traversal (ok\..\..\outside), because the runtime resolver treats \ as an ordinary filename character and never collapsed the .. segments, so the path escaped the base once a Windows consumer read the backslashes. The lexical resolve and containment boundary now use the target platform's path module (node:path.win32 / node:path.posix), matching the segment walk, so in-base paths resolve and cross-platform traversals are refused under any opts.platform override; the realpath check, which touches the live filesystem, keeps its runtime resolve. **Fixed:** *b.wsClient: WsClientError carries a real terminal/transient signal, and auto-reconnect works again* — WsClientError was declared always-permanent, so err.permanent was true for every error — a consumer's reconnect loop could not distinguish a terminal handshake failure (bad URL, bad subprotocol, malformed handshake header, accept-mismatch, bad upgrade, bad status line, a 4xx rejection, an oversized/protocol-violation frame) from a transient one (a 5xx handshake rejection, a pong- or handshake-timeout, a dropped socket) and had to maintain its own error-code list tracking the framework's taxonomy. err.permanent now reflects each error's actual transience, derived from its code (a new/unknown code defaults to terminal, so it fails closed rather than redialing a hopeless target forever); the single ws-client/bad-status code is split by the response status (4xx terminal, 5xx transient) and the status is exposed as err.statusCode (the existing err.status alias is preserved). The same always-permanent flag also drove the client's built-in auto-reconnect, which therefore never retried any framework-surfaced transient failure (a 5xx handshake or a keepalive timeout); reconnect now fires for transient failures and still skips terminal ones. · *b.safePath: cross-platform containment resolves with the target platform's path semantics* — b.safePath.resolve / resolveOrNull / validate performed its lexical containment (resolve rel under base, then bound the result with a separator slice) using the runtime path module, while the per-segment naming walk used opts.platform. When the two disagreed, validation broke both ways. Benign direction: a Linux service validating server-origin names against the stricter Windows ruleset (the recommended cross-platform pattern) had every legitimate in-base path refused with safe-path/escapes-base, because the runtime-separated resolved path could never match a Windows-separator boundary. Security direction: a POSIX host validating opts.platform: "windows" accepted a backslash traversal such as ok\..\..\outside — the segment walk splits on \ for Windows, but the runtime resolver on POSIX treats \ as an ordinary filename character and never collapsed the .. segments, so the path passed containment and resolved to <base>/ok\..\..\outside, which escapes the base once a Windows consumer interprets the backslashes. The lexical resolve and the containment boundary now use the target platform's path module (node:path.win32 when validating for Windows, node:path.posix otherwise), matching the segment walk, so in-base paths resolve correctly and a genuine traversal is refused under any opts.platform override. The realpath check, which resolves symlinks on the live filesystem, keeps a separate runtime resolve because a foreign-platform path cannot be symlink-resolved on the host. opts.platform continues to gate the per-segment naming rules (reserved names, trailing dot/space, NTFS ADS colon).
|
|
12
|
+
|
|
13
|
+
- v0.15.22 (2026-06-24) — **Internal test-harness reliability only — the published library is byte-for-byte identical to 0.15.21.** This release changes only the repository's own test harness and test files; nothing under the shipped tarball (index.js, bin/, lib/) is touched, so the API, behavior, and published files are identical to 0.15.21 and operators have nothing to do. The smoke worker now attributes a fire-and-forget failure — an unawaited promise or an unreleased handle (a retry timer, a shutdown wait, a watcher/reload restart) that throws AFTER a test's assertions already passed — to the exact test that caused it and retries it once, instead of the prior unattributable, intermittent failure that only surfaced on a resource-starved CI runner. Five test files that invoked their run() at module scope (re-running and, in some cases, exiting the worker before it could report a result) are corrected to run only under require.main === module, and a test-discipline check keeps the pattern from returning. An opt-in handle-leak audit (SMOKE_AUDIT_HANDLES) surfaces tests that hold a timer / socket / server / worker past completion, for a follow-up cleanup pass. **Changed:** *Smoke test harness attributes late-async-error failures and fixes module-level test self-execution* — The forked smoke worker installs unhandledRejection / uncaughtException handlers and a settle tick so a failure that fires after a test's assertions pass — a leaked handle's callback or an unawaited promise from retry / shutdown / reload logic — is reported against the test that caused it and retried once (a transient passes, a persistent one fails again and names the bug), replacing the prior intermittent, unattributable 'fork failed' that only appeared on a starved CI runner. Five test files (two integration, three layer-0, plus two wiki-suite harnesses) that called run() at module scope are corrected to execute only under require.main === module so they no longer double-run or exit the worker prematurely when required, and a codebase-patterns test-discipline detector prevents the unguarded-module-level-run shape from recurring. A SMOKE_AUDIT_HANDLES opt-in reports per-file handle leaks for a tracked cleanup. None of this is in the published package.
|
|
14
|
+
|
|
11
15
|
- v0.15.21 (2026-06-24) — **Adds a portable compare-and-swap UPDATE, an IPv6 /64 rate-limit key, a verify-only legacy-TOTP path, request-id AsyncLocalStorage scoping, schema-agnostic backup signing, side-effect-free FSM transition resolution, and the public codepoint-threat catalog — and fixes an FSM state transition that committed without an audit record when its entry hook threw.** A batch of additive primitives that close gaps operators hit composing the framework: b.sql.guardedUpdate builds the cross-instance-safe compare-and-swap UPDATE (the conditional-INSERT sibling) with b.sql.casWon reading the won/lost result; b.requestHelpers.ipKey (and a rateLimit ipKeyMode) key an IPv6 client by its routing-significant /64 so one end-site can't rotate the low 64 bits to evade a per-IP limit; b.auth.totp gains an opt-in verify-only SHA-1 path for one-final-login legacy-secret migration while generation stays SHA-512-only; b.middleware.requestId can bind the id into an AsyncLocalStorage scope that survives the awaited route chain; b.backupManifest.signBytes/verifyBytes authenticate a consumer's own canonical bytes with the framework signing key; b.fsm gains a side-effect-free instance.target() and a way to defer its transition audit when composed with an external claim; and the codepoint-threat catalog the guard family composes is exposed as b.codepointClass. A correctness fix: an FSM transition whose onEnter hook threw left the state committed but emitted no audit record — the record now always fires (stamped a failure outcome with the hook error) so a state change is never unaudited. **Added:** *b.sql.guardedUpdate + b.sql.casWon — portable compare-and-swap UPDATE* — b.sql.guardedUpdate(table) builds an UPDATE whose required guardWhere(col, expected) fence makes it land only when the row is still in the expected value — the cross-instance-safe way to advance a status or version on a single-statement-per-request backend (a D1-over-HTTP bridge or any autocommit-only adapter without interactive transactions), and the conditional-UPDATE sibling of b.sql.insertSelectWhere. It refuses to render without a fence (an unfenced guardedUpdate is just a plain update). b.sql.casWon(result) reads the won/lost verdict from the affected-row count, normalizing the rowCount / changes / affectedRows field-name divergence across adapters and throwing on an indeterminate result so a phantom win can't ship. Standard SQL across SQLite / Postgres / MySQL; guardWhereOp(col, op, expected) supports a non-equality fence (an optimistic-version or balance guard), and a null fence renders IS NULL. · *b.requestHelpers.ipKey + rateLimit ipKeyMode — IPv6 /64 keying* — b.requestHelpers.ipKey(ip, { ipv6Bits }) derives a stable rate-limit / blocklist key: an IPv4 address verbatim (one IPv4 is one host) but an IPv6 address collapsed to its routing-significant /64 prefix. A single IPv6 end-site is allocated a whole /64 (RFC 6177 / RFC 4291) and freely rotates the low 64 bits, so keying on the full 128-bit address lets one site mint unlimited fresh keys and walk a per-IP throttle or evade an exact-address block; keying on the /64 closes that while still distinguishing real end-sites. b.middleware.rateLimit gains ipKeyMode: "prefix64" to apply this to its default key (the audit record still logs the full client IP). · *b.auth.totp verify-only SHA-1 path for legacy-secret migration* — b.auth.totp.verify(secret, code, { algorithm: "sha1", verifyOnly: true }) authenticates a single legacy code during a re-enrollment flow, so a consumer migrating pre-existing RFC-6238-default (SHA-1) secrets can reuse the maintained verifier — separator stripping, 64-bit counter, drift / replay semantics — instead of hand-rolling a parallel HOTP. SHA-1 is still refused on every generation path (compute / generate / uri), so new-enrollment posture stays SHA-512-only, and the flag is honored only by verify(); each such verification emits an auth.totp.legacy_sha1_verify audit signal. · *b.middleware.requestId AsyncLocalStorage scoping* — b.middleware.requestId({ asyncContext: true }) binds the request id into the framework's AsyncLocalStorage scope so b.log.getRequestId() (and every b.log.create-built logger) returns it inside awaited route-handler code, not just on req.requestId. Because the b.router dispatch model runs the route handler after the middleware returns, the binding uses AsyncLocalStorage.enterWith (which persists forward across the awaited chain) rather than a callback wrap that would close before the handler runs; each request runs in its own async context so the binding stays request-scoped. The underlying b.log.enterRequestId(id) is exposed for callers wiring their own middleware. · *b.backupManifest.signBytes / verifyBytes — schema-agnostic signing* — b.backupManifest.signBytes(canonicalBytes) and verifyBytes(canonicalBytes, signatureBlock, { expectedFingerprint }) sign and verify a consumer's own canonical bytes with the same audit-sign keypair and fingerprint pinning as the v1-manifest sign() / verifySignature(), without adopting the framework's manifest schema — so a bespoke backup-header format can authenticate itself against the framework signing key. Fingerprint pinning is bound to the key the signature actually verifies under: the pin is checked against the fingerprint recomputed from the signature block's own public key (the new b.auditSign.fingerprintOf(publicKeyPem) helper), not the block's self-asserted fingerprint field, so a block can't claim a trusted fingerprint while being signed by a different key. The same binding now also applies to the v1-manifest verifySignature(). b.auditSign.verify additionally no longer requires init() when given an explicit public key, so a downstream verifier that holds only a trusted public key can check a detached signature. · *b.fsm side-effect-free transition resolution + deferrable audit* — instance.target(event) resolves a transition's destination state side-effect-free — the same edge and guard check as can() but returning the to-state (or null when the edge is illegal or guard-refused) — so a consumer composing an external compare-and-swap (b.sql.guardedUpdate on an autocommit-only substrate) can build the SET status = <to> claim without calling transition(), which would mutate state and emit an audit before the cross-instance claim is known to land. transition(event, { audit: false }) suppresses the built-in emit so that composition can emit its own enriched record once the claim resolves. · *b.codepointClass — the codepoint-threat catalog on the public surface* — The Unicode bidi-override / C0-control / zero-width / null-byte / Unicode-Tags tables and the UTS #39 confusable-script detector that the b.guard* family composes internally are now exposed as b.codepointClass, so a consumer can build a custom unconstrained-free-text screen — detectCharThreats / assertNoCharThreats / applyCharStripPolicies / scriptFor / detectMixedScripts plus the compiled regexes — without re-rolling the regexes (where the zero-width class is mistyped and the astral Unicode-Tags block forgotten) or coupling to an internal module path. For a ready-made free-text guard, b.guardText remains the first-class entry point. **Fixed:** *An FSM transition committed its state change without an audit record when the entry hook threw* — b.fsm commits the new state and pushes the history entry before running the destination state's onEnter hook. When that hook threw, control skipped the audit emission entirely — leaving a committed state transition with no audit record, a compliance gap for any regime that requires state changes to be auditable. The transition audit now always fires even when onEnter throws: it records the committed transition stamped with a failure outcome and the hook error, and still re-raises the error to the caller (the documented contract that an onEnter throw surfaces so the operator can roll back is unchanged).
|
|
12
16
|
|
|
13
17
|
- v0.15.20 (2026-06-24) — **Vendored SBOM version fields are derived from the bundle so they cannot drift, and the Public Suffix List + @simplewebauthn/server bundles are refreshed.** The vendor manifest recorded each bundled package's version in two scanner-facing places that were hand-maintained and could drift from the code actually shipped — the structured components[].version (the CycloneDX component versions) and the cpe string. Two had drifted: peculiar-pki's @peculiar/x509 component read 1.13.0 while the bundle shipped 2.0.0, and @noble/curves' cpe read 0.0.0 while the bundle shipped 2.2.0. A CVE scanner (Trivy / Grype / a CycloneDX export, or a consumer mirroring the manifest into its own SBOM) keys on those structured fields, so an advisory was matched against the wrong version — a false negative on a real fix or a false positive on a patched one. Both fields are corrected, the vendor-bundle script now derives them from the actually-installed package versions at bundle time so they cannot drift again, and a manifest gate fails the build if they ever disagree. Separately, the vendored Mozilla Public Suffix List is refreshed to the current upstream revision and @simplewebauthn/server is refreshed to 13.3.2. **Changed:** *Vendored Public Suffix List and @simplewebauthn/server refreshed* — The vendored Mozilla Public Suffix List is refreshed to the current upstream revision (used by b.publicSuffix for DMARC / BIMI / cookie-scope / same-site domain classification). @simplewebauthn/server is refreshed from 13.3.1 to 13.3.2, which improves WebAuthn attestation certificate-path validation; the published-tarball diff was reviewed (no install scripts, no network/eval, a self-contained code change) before re-vendoring. **Fixed:** *Vendored SBOM version metadata is bundle-derived, not hand-maintained* — lib/vendor/MANIFEST.json recorded each package's version in two places a CVE/SBOM scanner reads — the structured components[].version sub-object and the cpe string — both hand-maintained alongside the human version string, so they could (and did) drift from the bundled code. @peculiar/x509's component version read 1.13.0 while the bundle shipped 2.0.0; @noble/curves' cpe read 0.0.0 while the bundle shipped 2.2.0. Either drift makes a scanner match advisories against the wrong version. Both are corrected to the shipped versions, and the durable fix is structural: scripts/vendor-update.sh now writes both the structured component versions and the cpe version from the ACTUALLY-INSTALLED package versions captured at bundle time, so a maintainer can no longer update one field and forget the other. A smoke-time manifest gate additionally fails the build if any component or cpe version disagrees with the package version, catching a manual drift before it ships.
|
package/lib/framework-error.js
CHANGED
|
@@ -73,9 +73,19 @@ function defineClass(name, opts) {
|
|
|
73
73
|
var alwaysPermanent = !!opts.alwaysPermanent;
|
|
74
74
|
var withStatusCode = !!opts.withStatusCode;
|
|
75
75
|
var withCause = !!opts.withCause;
|
|
76
|
+
// permanentClassifier(code, statusCode) => bool — DERIVES this.permanent from
|
|
77
|
+
// the error's own code (+ optional status) at EVERY construction, so a class
|
|
78
|
+
// whose terminal/transient nature depends on the code (a network client whose
|
|
79
|
+
// 4xx is terminal but 5xx is transient) classifies identically no matter which
|
|
80
|
+
// call site or helper builds it. The classifier's default governs a forgotten
|
|
81
|
+
// code, so it can fail closed. Constructor shape: (code, message, statusCode).
|
|
82
|
+
var permanentClassifier = typeof opts.permanentClassifier === "function" ? opts.permanentClassifier : null;
|
|
76
83
|
if (alwaysPermanent && (withStatusCode || withCause)) {
|
|
77
84
|
throw new Error("defineClass: alwaysPermanent is mutually exclusive with withStatusCode / withCause");
|
|
78
85
|
}
|
|
86
|
+
if (permanentClassifier && (alwaysPermanent || withStatusCode || withCause)) {
|
|
87
|
+
throw new Error("defineClass: permanentClassifier is mutually exclusive with alwaysPermanent / withStatusCode / withCause");
|
|
88
|
+
}
|
|
79
89
|
var flagKey = "is" + name;
|
|
80
90
|
|
|
81
91
|
// Generated class — uses an anonymous class expression so we can set
|
|
@@ -88,6 +98,10 @@ function defineClass(name, opts) {
|
|
|
88
98
|
this[flagKey] = true;
|
|
89
99
|
if (alwaysPermanent) {
|
|
90
100
|
this.permanent = true;
|
|
101
|
+
} else if (permanentClassifier) {
|
|
102
|
+
// (code, message, statusCode) — permanent derived from the code (+ status).
|
|
103
|
+
this.statusCode = arg3;
|
|
104
|
+
this.permanent = !!permanentClassifier(code, arg3);
|
|
91
105
|
} else if (withCause) {
|
|
92
106
|
this.cause = arg3;
|
|
93
107
|
} else {
|
package/lib/safe-path.js
CHANGED
|
@@ -206,19 +206,33 @@ function _resolveCore(base, rel, opts) {
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
// Lexical resolve
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
//
|
|
213
|
-
//
|
|
214
|
-
|
|
209
|
+
// Lexical resolve + containment using the TARGET platform's path semantics
|
|
210
|
+
// (nodePath.win32 / nodePath.posix), NOT the runtime's. The runtime nodePath
|
|
211
|
+
// would treat the OTHER platform's separator as an ordinary filename
|
|
212
|
+
// character — so a Windows-target validation on a POSIX host would NOT collapse
|
|
213
|
+
// `ok\..\..\outside` and would wrongly accept a path that escapes the base
|
|
214
|
+
// when later interpreted with Windows path rules (the cross-platform
|
|
215
|
+
// backslash-traversal hole). The target module collapses the target's
|
|
216
|
+
// separators + `..` and its sep matches the resolved output, which both closes
|
|
217
|
+
// that hole AND stops the inverse false-refusal of legitimate in-base paths.
|
|
218
|
+
var pathMod = isWin ? nodePath.win32 : nodePath.posix;
|
|
219
|
+
var baseResolved = pathMod.resolve(base);
|
|
220
|
+
var joined = pathMod.resolve(baseResolved, rel);
|
|
221
|
+
var sepChar = pathMod.sep;
|
|
215
222
|
if (joined !== baseResolved && joined.slice(0, baseResolved.length + 1) !== baseResolved + sepChar) {
|
|
216
223
|
_refuse("safe-path/escapes-base",
|
|
217
224
|
"b.safePath.resolve: rel resolves outside base ('" + joined + "' not inside '" + baseResolved + "')");
|
|
218
225
|
}
|
|
219
226
|
if (opts.realpath === true) {
|
|
227
|
+
// realpath resolves symlinks on the RUNTIME filesystem, so it must use the
|
|
228
|
+
// runtime path module and runtime-resolved paths (a foreign-platform path
|
|
229
|
+
// can't be symlink-resolved on this host). The lexical check above already
|
|
230
|
+
// refused a cross-platform escape; this adds the on-disk symlink check.
|
|
231
|
+
var rtBaseResolved = nodePath.resolve(base);
|
|
232
|
+
var rtJoined = nodePath.resolve(rtBaseResolved, rel);
|
|
233
|
+
var rtSep = nodePath.sep;
|
|
220
234
|
var baseRealpath;
|
|
221
|
-
try { baseRealpath = nodeFs.realpathSync.native(
|
|
235
|
+
try { baseRealpath = nodeFs.realpathSync.native(rtBaseResolved); }
|
|
222
236
|
catch (e) {
|
|
223
237
|
_refuse("safe-path/realpath-base-unresolvable",
|
|
224
238
|
"b.safePath.resolve: opts.realpath set but base realpath failed: " + (e && e.message));
|
|
@@ -227,12 +241,12 @@ function _resolveCore(base, rel, opts) {
|
|
|
227
241
|
// ancestor that exists, and check its realpath. Operators want
|
|
228
242
|
// refusal when ANY ancestor symlink escapes — nodeFs.realpathSync on a
|
|
229
243
|
// non-existent path would throw.
|
|
230
|
-
var ancestor =
|
|
231
|
-
while (ancestor.length >
|
|
244
|
+
var ancestor = rtJoined;
|
|
245
|
+
while (ancestor.length > rtBaseResolved.length) {
|
|
232
246
|
try {
|
|
233
247
|
var ancRealpath = nodeFs.realpathSync.native(ancestor);
|
|
234
248
|
if (ancRealpath !== baseRealpath &&
|
|
235
|
-
ancRealpath.slice(0, baseRealpath.length + 1) !== baseRealpath +
|
|
249
|
+
ancRealpath.slice(0, baseRealpath.length + 1) !== baseRealpath + rtSep) {
|
|
236
250
|
_refuse("safe-path/realpath-escapes-base",
|
|
237
251
|
"b.safePath.resolve: symlink resolution at '" + ancestor +
|
|
238
252
|
"' escapes base realpath '" + baseRealpath + "'");
|
package/lib/ws-client.js
CHANGED
|
@@ -64,7 +64,33 @@ var structuredFields = require("./structured-fields");
|
|
|
64
64
|
var C = require("./constants");
|
|
65
65
|
var { defineClass } = require("./framework-error");
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
// Codes that are TRANSIENT — a consumer's reconnect loop (and the client's own
|
|
68
|
+
// auto-reconnect) SHOULD retry. Everything else is terminal: a bad URL / config
|
|
69
|
+
// error, a 4xx handshake rejection, an accept-mismatch, or a protocol-violation
|
|
70
|
+
// / oversized / malicious frame, where redialing the same hopeless target
|
|
71
|
+
// forever is the worse failure. bad-status is split by status below (5xx
|
|
72
|
+
// transient, 4xx terminal). Default-terminal so a new/forgotten code fails
|
|
73
|
+
// closed (no infinite redial) rather than open.
|
|
74
|
+
var WS_TRANSIENT_CODES = {
|
|
75
|
+
"ws-client/handshake-timeout": true, // server slow to complete the upgrade
|
|
76
|
+
"ws-client/pong-timeout": true, // keepalive lapse on an otherwise-live link
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
function _wsErrorIsPermanent(code, statusCode) {
|
|
80
|
+
if (code === "ws-client/bad-status") {
|
|
81
|
+
// 5xx handshake rejection is transient (server overloaded / restarting);
|
|
82
|
+
// 4xx (and any non-5xx) is terminal (auth / bad request / not-found).
|
|
83
|
+
return !(typeof statusCode === "number" && statusCode >= 500 && statusCode < 600);
|
|
84
|
+
}
|
|
85
|
+
// hasOwnProperty membership so a code of "__proto__" / "constructor" can't
|
|
86
|
+
// index the prototype and be misread as transient.
|
|
87
|
+
return !Object.prototype.hasOwnProperty.call(WS_TRANSIENT_CODES, code);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// permanent is DERIVED per-error from the code (+ status) at every construction
|
|
91
|
+
// — so err.permanent is a usable terminal/transient signal for a consumer's
|
|
92
|
+
// reconnect loop, not a blanket sentinel. Constructor: (code, message, status).
|
|
93
|
+
var WsClientError = defineClass("WsClientError", { permanentClassifier: _wsErrorIsPermanent });
|
|
68
94
|
|
|
69
95
|
var WS_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; // RFC 6455 §1.3
|
|
70
96
|
|
|
@@ -88,33 +114,15 @@ var CLOSE_NORMAL = 1000; // RFC 6455 close code
|
|
|
88
114
|
var CLOSE_GOING_AWAY = 1001; // RFC 6455 close code
|
|
89
115
|
var CLOSE_ABNORMAL = 1006; // RFC 6455 close code (synthetic — never on wire)
|
|
90
116
|
|
|
91
|
-
// Permanent vs transient
|
|
92
|
-
//
|
|
93
|
-
//
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
"ws-client/bad-upgrade": true,
|
|
99
|
-
"ws-client/bad-status-line": true,
|
|
100
|
-
"ws-client/bad-subprotocol": true,
|
|
101
|
-
"ws-client/bad-header": true,
|
|
102
|
-
"ws-client/handshake-too-large": true,
|
|
103
|
-
"ws-client/control-too-big": true,
|
|
104
|
-
"ws-client/control-fragmented": true,
|
|
105
|
-
"ws-client/protocol-error": true,
|
|
106
|
-
"ws-client/invalid-utf8": true,
|
|
107
|
-
"ws-client/rsv1-on-continuation": true,
|
|
108
|
-
"ws-client/message-too-big": true,
|
|
109
|
-
"ws-client/deflate-error": true,
|
|
110
|
-
"ws-client/payload-too-big": true,
|
|
111
|
-
};
|
|
112
|
-
|
|
117
|
+
// Permanent vs transient classifier for the reconnect logic. WsClientError now
|
|
118
|
+
// carries a per-code permanent flag (see _wsErrorIsPermanent), so this reads it
|
|
119
|
+
// directly. A raw socket error (ECONNRESET / ECONNREFUSED mid-dial, no
|
|
120
|
+
// .permanent) is treated as transient — the connection dropped, retrying (up to
|
|
121
|
+
// reconnect.maxAttempts) is correct. Previously WsClientError was alwaysPermanent
|
|
122
|
+
// so this returned true for EVERY framework error, silently disabling the
|
|
123
|
+
// advertised auto-reconnect for transient handshake/keepalive failures.
|
|
113
124
|
function _isPermanentError(err) {
|
|
114
|
-
|
|
115
|
-
if (err.permanent === true) return true; // defineClass-marked
|
|
116
|
-
if (err.code && PERMANENT_CODES[err.code]) return true;
|
|
117
|
-
return false;
|
|
125
|
+
return !!(err && err.permanent === true);
|
|
118
126
|
}
|
|
119
127
|
|
|
120
128
|
// Synchronous bounded inflate — runs zlib.inflateRawSync with
|
|
@@ -513,8 +521,11 @@ class WsClient extends EventEmitter {
|
|
|
513
521
|
// the message string.
|
|
514
522
|
var bodyText = "";
|
|
515
523
|
try { bodyText = rest.toString("utf8"); } catch (_e) { /* drop-silent */ }
|
|
524
|
+
// Pass status as the 3rd arg so the classifier derives permanent from it
|
|
525
|
+
// (4xx terminal, 5xx transient) and statusCode is set; keep .status as the
|
|
526
|
+
// pre-existing alias callers may already read.
|
|
516
527
|
var statusErr = new WsClientError("ws-client/bad-status",
|
|
517
|
-
"handshake response status was " + status + " (expected 101 Switching Protocols)");
|
|
528
|
+
"handshake response status was " + status + " (expected 101 Switching Protocols)", status);
|
|
518
529
|
statusErr.status = status;
|
|
519
530
|
statusErr.body = bodyText;
|
|
520
531
|
this._handleSocketError(statusErr);
|
package/package.json
CHANGED
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:
|
|
5
|
+
"serialNumber": "urn:uuid:8b15a312-89a7-49e1-b4c1-f90240608195",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-06-
|
|
8
|
+
"timestamp": "2026-06-25T09:42:41.053Z",
|
|
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.
|
|
22
|
+
"bom-ref": "@blamejs/core@0.15.23",
|
|
23
23
|
"type": "application",
|
|
24
24
|
"name": "blamejs",
|
|
25
|
-
"version": "0.15.
|
|
25
|
+
"version": "0.15.23",
|
|
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
|
+
"purl": "pkg:npm/%40blamejs/core@0.15.23",
|
|
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.
|
|
57
|
+
"ref": "@blamejs/core@0.15.23",
|
|
58
58
|
"dependsOn": []
|
|
59
59
|
}
|
|
60
60
|
]
|