@blamejs/core 0.14.20 → 0.14.21

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.
@@ -169,11 +169,36 @@ function create(opts) {
169
169
  var useTls = opts.tls !== undefined ? !!opts.tls : parsed.tls;
170
170
  var password = opts.password !== undefined ? opts.password : parsed.password;
171
171
  var username = opts.username !== undefined ? opts.username : parsed.username;
172
- var db = opts.db !== undefined ? Number(opts.db) : parsed.db;
173
- var connectTimeoutMs = Number(opts.connectTimeoutMs) || 5000;
174
- var commandTimeoutMs = Number(opts.commandTimeoutMs) || 10000;
172
+ // Config-time entry-point opts: a bad type must fail at create() rather
173
+ // than coerce-or-default silently. connectTimeoutMs:"abc" NaN would
174
+ // otherwise fall through to the default; a negative timeout would sail
175
+ // into setTimeout; maxReconnectAttempts:"abc" → NaN would make the
176
+ // `>= 0` reconnect-cap check below false and SILENTLY disable the bound
177
+ // (unbounded reconnects). db and maxReconnectAttempts must allow 0
178
+ // (db 0 = no SELECT; maxReconnectAttempts 0 = give up immediately).
179
+ if (opts.db !== undefined &&
180
+ (typeof opts.db !== "number" || !Number.isInteger(opts.db) || opts.db < 0)) {
181
+ throw _err("BAD_OPTS",
182
+ "redis.create: opts.db must be a non-negative integer, got " +
183
+ (typeof opts.db === "number" ? String(opts.db) : typeof opts.db));
184
+ }
185
+ if (opts.maxReconnectAttempts !== undefined &&
186
+ (typeof opts.maxReconnectAttempts !== "number" ||
187
+ !Number.isInteger(opts.maxReconnectAttempts) || opts.maxReconnectAttempts < 0)) {
188
+ throw _err("BAD_OPTS",
189
+ "redis.create: opts.maxReconnectAttempts must be a non-negative integer, got " +
190
+ (typeof opts.maxReconnectAttempts === "number"
191
+ ? String(opts.maxReconnectAttempts) : typeof opts.maxReconnectAttempts));
192
+ }
193
+ validateOpts.optionalPositiveInt(opts.connectTimeoutMs,
194
+ "redis.create: opts.connectTimeoutMs", RedisError, "BAD_OPTS");
195
+ validateOpts.optionalPositiveInt(opts.commandTimeoutMs,
196
+ "redis.create: opts.commandTimeoutMs", RedisError, "BAD_OPTS");
197
+ var db = opts.db !== undefined ? opts.db : parsed.db;
198
+ var connectTimeoutMs = opts.connectTimeoutMs !== undefined ? opts.connectTimeoutMs : 5000;
199
+ var commandTimeoutMs = opts.commandTimeoutMs !== undefined ? opts.commandTimeoutMs : 10000;
175
200
  var maxReconnectAttempts = opts.maxReconnectAttempts === undefined ? 10
176
- : Number(opts.maxReconnectAttempts);
201
+ : opts.maxReconnectAttempts;
177
202
  // TLS verification controls. Operators using rediss:// against private
178
203
  // CAs (managed Redis services, on-prem clusters with internal PKI)
179
204
  // pin the trust roots via opts.ca; rejectUnauthorized stays on by
@@ -470,6 +495,9 @@ function create(opts) {
470
495
  pending: pending.length, backlog: backlog.length,
471
496
  reconnect: reconnectAttempt,
472
497
  host: host, port: port, db: db, tls: useTls,
498
+ connectTimeoutMs: connectTimeoutMs,
499
+ commandTimeoutMs: commandTimeoutMs,
500
+ maxReconnectAttempts: maxReconnectAttempts,
473
501
  };
474
502
  },
475
503
  };
@@ -76,8 +76,21 @@ function resolve(rawTarget, opts) {
76
76
  // Full URL — parse and check against allowlist.
77
77
  var allowedOrigins = Array.isArray(opts.allowedOrigins) ? opts.allowedOrigins : null;
78
78
  var allowedHosts = Array.isArray(opts.allowedHosts) ? opts.allowedHosts : null;
79
- if (!allowedOrigins && !allowedHosts) {
80
- // Operator gave no allowlist refuse all full URLs (the safe default).
79
+
80
+ // The application's own origin (opts.base) is same-origin by
81
+ // definition, so a full URL pointing at it is safe even when the
82
+ // operator supplied no explicit allowedOrigins / allowedHosts. Derive
83
+ // the origin from base and treat it as an implicitly-allowed origin.
84
+ var baseOrigin = null;
85
+ if (typeof opts.base === "string" && opts.base.length > 0) {
86
+ try {
87
+ baseOrigin = safeUrl.parse(opts.base, { allowedProtocols: safeUrl.ALLOW_HTTP_TLS }).origin;
88
+ } catch (_e) { baseOrigin = null; }
89
+ }
90
+
91
+ if (!allowedOrigins && !allowedHosts && baseOrigin === null) {
92
+ // Operator gave no allowlist and no usable base — refuse all full
93
+ // URLs (the safe default).
81
94
  return fallback;
82
95
  }
83
96
 
@@ -85,6 +98,7 @@ function resolve(rawTarget, opts) {
85
98
  try { parsed = safeUrl.parse(rawTarget, { allowedProtocols: safeUrl.ALLOW_HTTP_TLS }); }
86
99
  catch (_e) { return fallback; }
87
100
 
101
+ if (baseOrigin !== null && parsed.origin === baseOrigin) return rawTarget;
88
102
  if (allowedOrigins) {
89
103
  for (var i = 0; i < allowedOrigins.length; i += 1) {
90
104
  if (parsed.origin === allowedOrigins[i]) return rawTarget;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blamejs/core",
3
- "version": "0.14.20",
3
+ "version": "0.14.21",
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:e7a00583-46e2-4fd3-a1bf-9cc0789bed7f",
5
+ "serialNumber": "urn:uuid:37cb0e0e-7cba-440b-89c3-febfeb9f7eef",
6
6
  "version": 1,
7
7
  "metadata": {
8
- "timestamp": "2026-06-02T23:52:58.690Z",
8
+ "timestamp": "2026-06-05T04:48:42.555Z",
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.14.20",
22
+ "bom-ref": "@blamejs/core@0.14.21",
23
23
  "type": "application",
24
24
  "name": "blamejs",
25
- "version": "0.14.20",
25
+ "version": "0.14.21",
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.14.20",
29
+ "purl": "pkg:npm/%40blamejs/core@0.14.21",
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.14.20",
57
+ "ref": "@blamejs/core@0.14.21",
58
58
  "dependsOn": []
59
59
  }
60
60
  ]