@blamejs/blamejs-shop 0.4.87 → 0.4.89
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/SECURITY.md +22 -9
- package/lib/asset-manifest.json +1 -1
- package/lib/gift-card-ledger.js +72 -15
- package/lib/store-credit.js +340 -89
- package/lib/vendor/MANIFEST.json +53 -31
- package/lib/vendor/blamejs/.clusterfuzzlite/Dockerfile +7 -2
- package/lib/vendor/blamejs/.github/dependabot.yml +12 -0
- package/lib/vendor/blamejs/.github/workflows/ci.yml +16 -12
- package/lib/vendor/blamejs/.github/workflows/npm-publish.yml +3 -1
- package/lib/vendor/blamejs/.github/workflows/release-container.yml +23 -0
- package/lib/vendor/blamejs/CHANGELOG.md +6 -0
- package/lib/vendor/blamejs/api-snapshot.json +10 -2
- package/lib/vendor/blamejs/examples/wiki/Dockerfile +19 -2
- package/lib/vendor/blamejs/lib/atomic-file.js +32 -9
- package/lib/vendor/blamejs/lib/middleware/api-encrypt.js +105 -40
- package/lib/vendor/blamejs/lib/middleware/dpop.js +54 -31
- package/lib/vendor/blamejs/lib/middleware/span-http-server.js +7 -0
- package/lib/vendor/blamejs/lib/network-tls.js +12 -2
- package/lib/vendor/blamejs/lib/queue-local.js +123 -46
- package/lib/vendor/blamejs/lib/queue.js +13 -9
- package/lib/vendor/blamejs/lib/request-helpers.js +90 -0
- package/lib/vendor/blamejs/lib/self-update-standalone-verifier.js +69 -7
- package/lib/vendor/blamejs/lib/self-update.js +11 -2
- package/lib/vendor/blamejs/lib/vendor/MANIFEST.json +11 -11
- package/lib/vendor/blamejs/lib/vendor/public-suffix-list.dat +6 -2
- package/lib/vendor/blamejs/lib/vendor/public-suffix-list.data.js +689 -688
- package/lib/vendor/blamejs/oss-fuzz/projects/blamejs/Dockerfile +5 -0
- package/lib/vendor/blamejs/package.json +1 -1
- package/lib/vendor/blamejs/release-notes/v0.15.17.json +52 -0
- package/lib/vendor/blamejs/release-notes/v0.15.18.json +49 -0
- package/lib/vendor/blamejs/release-notes/v0.15.19.json +18 -0
- package/lib/vendor/blamejs/scripts/check-vendor-currency.js +24 -0
- package/lib/vendor/blamejs/test/integration/queue-cluster-mysql.test.js +419 -0
- package/lib/vendor/blamejs/test/integration/queue-cluster-pg.test.js +471 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/api-encrypt-rejection-envelope.test.js +309 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/api-encrypt.test.js +35 -8
- package/lib/vendor/blamejs/test/layer-0-primitives/atomic-file-fd-read-errorfor-bypass.test.js +138 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/codebase-patterns.test.js +26 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/dpop-htu-peergating.test.js +227 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/queue-flow-repeat.test.js +83 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/self-update-poll-asset-digest.test.js +90 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/self-update-standalone-verifier-ecdsa-encoding.test.js +274 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/tls-ocsp-freshness.test.js +192 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/vendor-currency-classify.test.js +36 -0
- package/package.json +1 -1
|
@@ -230,14 +230,28 @@ function create(config) {
|
|
|
230
230
|
// open each verb builder pre-bound to this table so the table reference
|
|
231
231
|
// is resolved in exactly one place.
|
|
232
232
|
var ref = _resolveTableRef(config);
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
//
|
|
238
|
-
//
|
|
239
|
-
//
|
|
240
|
-
|
|
233
|
+
// Resolve the ACTIVE backend dialect every verb builds for — sqlite in
|
|
234
|
+
// single-node, the operator-configured postgres/mysql in cluster mode — so
|
|
235
|
+
// b.sql emits dialect-correct identifier quoting (backticks on MySQL, not
|
|
236
|
+
// double-quotes that MySQL reads as string literals) and its own dialect
|
|
237
|
+
// guards fire. The default store IS clusterStorage (it knows the live
|
|
238
|
+
// dialect); a bring-your-own store declares config.dialect (or exposes its
|
|
239
|
+
// own dialect()), defaulting to sqlite. Resolved per call (lazy) like the
|
|
240
|
+
// sibling clusterStorage data-layer files, since cluster.init may run after
|
|
241
|
+
// queue.create.
|
|
242
|
+
function _dialect() {
|
|
243
|
+
if (store === clusterStorage) return clusterStorage.dialect();
|
|
244
|
+
if (typeof store.dialect === "function") return store.dialect();
|
|
245
|
+
return (typeof config.dialect === "string" && config.dialect) ? config.dialect : "sqlite";
|
|
246
|
+
}
|
|
247
|
+
function _opts() { return Object.assign({}, ref.opts, { dialect: _dialect() }); }
|
|
248
|
+
function _select() { return sql.select(ref.name, _opts()); }
|
|
249
|
+
function _insert() { return sql.insert(ref.name, _opts()); }
|
|
250
|
+
function _update() { return sql.update(ref.name, _opts()); }
|
|
251
|
+
function _delete() { return sql.delete(ref.name, _opts()); }
|
|
252
|
+
// Quoted column expression for a setRaw RHS that references the column's own
|
|
253
|
+
// pre-update value (attempts/availableAt), quoted for the ACTIVE dialect.
|
|
254
|
+
function _qc(col) { return safeSql.quoteIdentifier(col, _dialect(), { allowReserved: true }); }
|
|
241
255
|
|
|
242
256
|
async function enqueue(queueName, payload, opts) {
|
|
243
257
|
cluster.requireLeader();
|
|
@@ -324,22 +338,9 @@ function create(config) {
|
|
|
324
338
|
};
|
|
325
339
|
}
|
|
326
340
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
var leaseExpiresAt = nowMs + leaseMs;
|
|
331
|
-
var maxRows = count != null ? count : 1;
|
|
332
|
-
|
|
333
|
-
// Single-statement atomic lease. The IN-subquery picks the head of
|
|
334
|
-
// the queue; the outer UPDATE locks those rows and only updates
|
|
335
|
-
// rows that still match status='pending' after the lock acquires
|
|
336
|
-
// (Postgres EvalPlanQual; SQLite is single-writer so the same row
|
|
337
|
-
// can't be picked twice). RETURNING hands back the leased columns
|
|
338
|
-
// so we don't need a separate SELECT after the UPDATE. maxRows is a
|
|
339
|
-
// framework-computed integer emitted inline via b.sql's .limit() (a
|
|
340
|
-
// bound LIMIT param has no portable form across the subquery path);
|
|
341
|
-
// attempts = attempts + 1 is a setRaw over the column's own value.
|
|
342
|
-
var leaseInner = _select()
|
|
341
|
+
// Build the head-of-queue candidate SELECT (shared by both lease paths).
|
|
342
|
+
function _leaseCandidates(queueName, nowMs, maxRows) {
|
|
343
|
+
return _select()
|
|
343
344
|
.columns(["_id"])
|
|
344
345
|
.where("queueName", queueName)
|
|
345
346
|
.where("status", "pending")
|
|
@@ -348,20 +349,87 @@ function create(config) {
|
|
|
348
349
|
.orderBy("availableAt", "asc")
|
|
349
350
|
.orderBy("enqueuedAt", "asc")
|
|
350
351
|
.limit(maxRows);
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
var
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
async function lease(queueName, leaseMs, count) {
|
|
355
|
+
cluster.requireLeader();
|
|
356
|
+
var nowMs = Date.now();
|
|
357
|
+
var leaseExpiresAt = nowMs + leaseMs;
|
|
358
|
+
var maxRows = count != null ? count : 1;
|
|
359
|
+
var dialect = _dialect();
|
|
360
|
+
var i;
|
|
361
|
+
|
|
362
|
+
// SQLite (single-writer): one self-contained statement is atomic. The
|
|
363
|
+
// IN-subquery picks the head of the queue, the outer UPDATE flips it, and
|
|
364
|
+
// RETURNING hands the leased rows back. This shape is valid ONLY on
|
|
365
|
+
// sqlite — Postgres freezes the materialized subquery qual (so a
|
|
366
|
+
// concurrent leaser double-claims the same row) and MySQL refuses both
|
|
367
|
+
// RETURNING and updating a table named in its own subquery (error 1093).
|
|
368
|
+
if (dialect === "sqlite") {
|
|
369
|
+
var leaseBuilt = _update()
|
|
370
|
+
.set("status", "inflight")
|
|
371
|
+
.set("leasedAt", nowMs)
|
|
372
|
+
.set("leaseExpiresAt", leaseExpiresAt)
|
|
373
|
+
.setRaw("attempts", _qc("attempts") + " + 1", [])
|
|
374
|
+
.whereIn("_id", _leaseCandidates(queueName, nowMs, maxRows))
|
|
375
|
+
.returning(LEASE_RETURN_COLS)
|
|
376
|
+
.toSql();
|
|
377
|
+
var result = await store.execute(leaseBuilt.sql, leaseBuilt.params);
|
|
378
|
+
var leased = [];
|
|
379
|
+
for (i = 0; i < result.rows.length; i++) leased.push(_shapeLeasedRow(result.rows[i]));
|
|
380
|
+
return leased;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// Postgres / MySQL: claim inside a transaction. SELECT ... FOR UPDATE SKIP
|
|
384
|
+
// LOCKED row-locks the head-of-queue ids so concurrent leasers see
|
|
385
|
+
// disjoint sets (no double-lease); the guarded UPDATE ... WHERE
|
|
386
|
+
// status='pending' AND _id IN (locked ids) uses a LITERAL id list (not a
|
|
387
|
+
// self-referencing subquery — avoids MySQL 1093), with the status guard as
|
|
388
|
+
// belt-and-suspenders. Postgres reads the leased rows back via RETURNING;
|
|
389
|
+
// MySQL (no RETURNING) re-selects them by the locked ids. Mirrors
|
|
390
|
+
// outbox._claimBatch — the framework's canonical competing-consumer claim.
|
|
391
|
+
if (typeof store.transaction !== "function") {
|
|
392
|
+
throw _err("CLUSTER_TX_UNSUPPORTED",
|
|
393
|
+
"queue lease on a '" + dialect + "' backend requires an interactive transaction, but the " +
|
|
394
|
+
"configured store exposes no transaction(); use the default cluster store or supply a " +
|
|
395
|
+
"transaction-capable store", true);
|
|
363
396
|
}
|
|
364
|
-
return
|
|
397
|
+
return await store.transaction(async function (tx) {
|
|
398
|
+
var selBuilt = _leaseCandidates(queueName, nowMs, maxRows)
|
|
399
|
+
.forUpdate({ skipLocked: true })
|
|
400
|
+
.toSql();
|
|
401
|
+
var selRes = await tx.execute(selBuilt.sql, selBuilt.params);
|
|
402
|
+
var ids = ((selRes && selRes.rows) || []).map(function (r) { return r._id; });
|
|
403
|
+
if (ids.length === 0) return [];
|
|
404
|
+
|
|
405
|
+
var upd = _update()
|
|
406
|
+
.set("status", "inflight")
|
|
407
|
+
.set("leasedAt", nowMs)
|
|
408
|
+
.set("leaseExpiresAt", leaseExpiresAt)
|
|
409
|
+
.setRaw("attempts", _qc("attempts") + " + 1", [])
|
|
410
|
+
.where("status", "pending")
|
|
411
|
+
.whereInArray("_id", ids);
|
|
412
|
+
|
|
413
|
+
var rows;
|
|
414
|
+
if (dialect === "postgres") {
|
|
415
|
+
var updBuilt = upd.returning(LEASE_RETURN_COLS).toSql();
|
|
416
|
+
var updRes = await tx.execute(updBuilt.sql, updBuilt.params);
|
|
417
|
+
rows = (updRes && updRes.rows) || [];
|
|
418
|
+
} else {
|
|
419
|
+
var u = upd.toSql();
|
|
420
|
+
await tx.execute(u.sql, u.params);
|
|
421
|
+
var rbBuilt = _select()
|
|
422
|
+
.columns(LEASE_RETURN_COLS)
|
|
423
|
+
.where("status", "inflight")
|
|
424
|
+
.whereInArray("_id", ids)
|
|
425
|
+
.toSql();
|
|
426
|
+
var rbRes = await tx.execute(rbBuilt.sql, rbBuilt.params);
|
|
427
|
+
rows = (rbRes && rbRes.rows) || [];
|
|
428
|
+
}
|
|
429
|
+
var out = [];
|
|
430
|
+
for (i = 0; i < rows.length; i++) out.push(_shapeLeasedRow(rows[i]));
|
|
431
|
+
return out;
|
|
432
|
+
});
|
|
365
433
|
}
|
|
366
434
|
|
|
367
435
|
// extendLease — push the lease expiry forward for a long-running job.
|
|
@@ -633,19 +701,28 @@ function create(config) {
|
|
|
633
701
|
return result.rowCount || 0;
|
|
634
702
|
}
|
|
635
703
|
|
|
636
|
-
// patchFlowDeps — the second pass of enqueueFlow.
|
|
637
|
-
// dependsOn
|
|
638
|
-
//
|
|
639
|
-
// so it targets THIS backend's configured store +
|
|
640
|
-
// bring-your-own table receives the flow graph the same way the
|
|
641
|
-
// first-pass enqueue did, instead of the dispatcher writing to the
|
|
642
|
-
//
|
|
643
|
-
//
|
|
704
|
+
// patchFlowDeps — the second pass of enqueueFlow. Rewrites the child's
|
|
705
|
+
// dependsOn from the dependency NAMES the first pass wrote to the resolved
|
|
706
|
+
// sibling jobIds (now that every sibling's jobId is known). Lives on the
|
|
707
|
+
// backend (not in queue.js) so it targets THIS backend's configured store +
|
|
708
|
+
// table — a bring-your-own table receives the flow graph the same way the
|
|
709
|
+
// first-pass enqueue did, instead of the dispatcher writing to the default
|
|
710
|
+
// jobs table behind the backend's back. depIds is serialized to JSON.
|
|
711
|
+
//
|
|
712
|
+
// It must NOT touch availableAt: the first pass already parked the child at
|
|
713
|
+
// FLOW_BLOCKED_AVAILABLE_AT (it enqueues deps-bearing children WITH their
|
|
714
|
+
// dependsOn), and a dependency that completes in the window between the two
|
|
715
|
+
// passes drives complete() → _maybeReleaseFlowChildren, which bumps the
|
|
716
|
+
// child's availableAt to now. Re-parking here would clobber that release,
|
|
717
|
+
// and since the dependency is already done it never completes again — the
|
|
718
|
+
// child would sit pending-but-unleaseable forever. Parking is owned by the
|
|
719
|
+
// first-pass enqueue; releasing is owned by completion. This pass only
|
|
720
|
+
// resolves names → ids (harmless to rewrite even on an already-released
|
|
721
|
+
// child: a leased child's own dependsOn is never re-read).
|
|
644
722
|
async function patchFlowDeps(jobId, depIds) {
|
|
645
723
|
cluster.requireLeader();
|
|
646
724
|
var built = _update()
|
|
647
725
|
.set("dependsOn", JSON.stringify(depIds))
|
|
648
|
-
.set("availableAt", FLOW_BLOCKED_AVAILABLE_AT)
|
|
649
726
|
.where("_id", jobId)
|
|
650
727
|
.toSql();
|
|
651
728
|
var result = await store.execute(built.sql, built.params);
|
|
@@ -938,14 +938,16 @@ function enqueueFlow(spec) {
|
|
|
938
938
|
{ queueName: spec.queueName, flowId: flowId, childCount: spec.children.length },
|
|
939
939
|
async function () {
|
|
940
940
|
var jobs = [];
|
|
941
|
-
// Two-pass insert: first pass enqueues all children
|
|
942
|
-
//
|
|
943
|
-
//
|
|
944
|
-
//
|
|
941
|
+
// Two-pass insert: first pass enqueues all children (so the second pass
|
|
942
|
+
// can resolve dependsOn names → sibling jobIds); a deps-bearing child is
|
|
943
|
+
// PARKED at enqueue time by passing its dependsOn through, so it is never
|
|
944
|
+
// leaseable in the window between the two passes (a concurrent consumer
|
|
945
|
+
// could otherwise lease it before its deps run). The second pass only
|
|
946
|
+
// rewrites the parked child's dependsOn from names to the resolved jobIds.
|
|
945
947
|
var nameToJobId = {};
|
|
946
948
|
for (var p = 0; p < spec.children.length; p++) {
|
|
947
949
|
var ch = spec.children[p];
|
|
948
|
-
|
|
950
|
+
var hasDeps = Array.isArray(ch.dependsOn) && ch.dependsOn.length > 0;
|
|
949
951
|
var enqOpts = {
|
|
950
952
|
backend: flowBackend.name,
|
|
951
953
|
flowId: flowId,
|
|
@@ -954,10 +956,12 @@ function enqueueFlow(spec) {
|
|
|
954
956
|
classification: ch.classification || null,
|
|
955
957
|
traceId: ch.traceId || null,
|
|
956
958
|
maxAttempts: ch.maxAttempts,
|
|
957
|
-
//
|
|
958
|
-
//
|
|
959
|
-
//
|
|
960
|
-
//
|
|
959
|
+
// Park a deps-bearing child immediately (queue-local parks when
|
|
960
|
+
// opts.dependsOn is present); the second pass replaces these dep
|
|
961
|
+
// NAMES with the resolved sibling jobIds, keeping it parked until
|
|
962
|
+
// completion bumps availableAt. Root children (no deps) stay
|
|
963
|
+
// immediately leaseable.
|
|
964
|
+
dependsOn: hasDeps ? ch.dependsOn : undefined,
|
|
961
965
|
};
|
|
962
966
|
var result = await enqueue(spec.queueName, ch.payload, enqOpts);
|
|
963
967
|
nameToJobId[ch.name] = result.jobId;
|
|
@@ -636,6 +636,94 @@ function requestProtocol(req, opts) {
|
|
|
636
636
|
return "http";
|
|
637
637
|
}
|
|
638
638
|
|
|
639
|
+
/**
|
|
640
|
+
* @primitive b.requestHelpers.trustedHost
|
|
641
|
+
* @signature b.requestHelpers.trustedHost(opts?)
|
|
642
|
+
* @since 0.15.18
|
|
643
|
+
* @related b.requestHelpers.requestHost, b.requestHelpers.trustedProtocol
|
|
644
|
+
*
|
|
645
|
+
* Peer-gated companion to trustedProtocol for the request authority (host).
|
|
646
|
+
* Reconstructing the absolute request URL — the DPoP `htu`, an origin/issuer
|
|
647
|
+
* string, a redirect base — depends on the host the client addressed; behind a
|
|
648
|
+
* proxy that comes from X-Forwarded-Host, which is forgeable unless the
|
|
649
|
+
* immediate peer is a trusted proxy. Returns `{ resolve(req)=>string|null,
|
|
650
|
+
* peerGated }`. With `trustedProxies` (CIDRs) X-Forwarded-Host is honored only
|
|
651
|
+
* from a trusted peer; with `hostResolver(req)` the operator owns it; with
|
|
652
|
+
* neither only the request's own Host header is used (forwarded host ignored).
|
|
653
|
+
*
|
|
654
|
+
* @opts
|
|
655
|
+
* trustedProxies: string | string[],
|
|
656
|
+
* hostResolver: function(req): string|null,
|
|
657
|
+
*
|
|
658
|
+
* @example
|
|
659
|
+
* var th = b.requestHelpers.trustedHost({ trustedProxies: ["10.0.0.0/8"] });
|
|
660
|
+
* th.resolve(req); // X-Forwarded-Host only when it came via a trusted peer
|
|
661
|
+
*/
|
|
662
|
+
function trustedHost(opts) {
|
|
663
|
+
opts = opts || {};
|
|
664
|
+
var resolver = opts.hostResolver;
|
|
665
|
+
if (resolver != null && typeof resolver !== "function") {
|
|
666
|
+
throw new TypeError("trustedHost: hostResolver must be a function(req) => string|null");
|
|
667
|
+
}
|
|
668
|
+
var predicate = _trustedProxyPredicate(_normTrustedProxies(opts), "trustedHost");
|
|
669
|
+
return {
|
|
670
|
+
peerGated: !!(resolver || predicate),
|
|
671
|
+
resolve: function (req) {
|
|
672
|
+
if (resolver) return resolver(req);
|
|
673
|
+
if (predicate) return requestHost(req, { trustProxy: predicate });
|
|
674
|
+
return requestHost(req, { trustProxy: false });
|
|
675
|
+
},
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* @primitive b.requestHelpers.requestHost
|
|
681
|
+
* @signature b.requestHelpers.requestHost(req, opts?)
|
|
682
|
+
* @since 0.15.18
|
|
683
|
+
* @related b.requestHelpers.requestProtocol, b.requestHelpers.trustedHost
|
|
684
|
+
*
|
|
685
|
+
* Resolve the inbound authority (host[:port]). Default returns the request's
|
|
686
|
+
* own `Host` header. Behind a trusted reverse proxy that rewrites the host,
|
|
687
|
+
* pass `trustProxy` as a PREDICATE `function(addr)=>boolean` (build it via
|
|
688
|
+
* `b.requestHelpers.trustedHost`): `X-Forwarded-Host` is then honored only when
|
|
689
|
+
* the immediate peer is a trusted proxy, so a direct caller can't forge it. The
|
|
690
|
+
* legacy `trustProxy: true` reads the leftmost forwarded hop without checking
|
|
691
|
+
* the peer — forgeable. Returns the host string, or `null` when absent.
|
|
692
|
+
*
|
|
693
|
+
* @opts
|
|
694
|
+
* trustProxy: boolean | function // false (default) | predicate (peer-gated) | legacy true
|
|
695
|
+
*
|
|
696
|
+
* @example
|
|
697
|
+
* b.requestHelpers.requestHost({ headers: { host: "app.example.com" } });
|
|
698
|
+
* // → "app.example.com"
|
|
699
|
+
*/
|
|
700
|
+
function requestHost(req, opts) {
|
|
701
|
+
if (!req || !req.headers) return null;
|
|
702
|
+
var trust = opts && opts.trustProxy;
|
|
703
|
+
if (trust) {
|
|
704
|
+
var fwd = req.headers["x-forwarded-host"];
|
|
705
|
+
if (typeof fwd === "string" && fwd.length > 0) {
|
|
706
|
+
var hops = parseListHeader(fwd);
|
|
707
|
+
if (hops.length > 0) {
|
|
708
|
+
if (typeof trust === "function") {
|
|
709
|
+
// Peer-gated: honor X-Forwarded-Host only when the immediate TCP peer
|
|
710
|
+
// is a trusted proxy. A direct caller's forged header is ignored —
|
|
711
|
+
// fall through to the request's own Host header.
|
|
712
|
+
var peer =
|
|
713
|
+
(req.socket && typeof req.socket.remoteAddress === "string" && req.socket.remoteAddress) ? req.socket.remoteAddress
|
|
714
|
+
: (req.connection && typeof req.connection.remoteAddress === "string" && req.connection.remoteAddress) ? req.connection.remoteAddress
|
|
715
|
+
: null;
|
|
716
|
+
if (peer && trust(peer)) return hops[0];
|
|
717
|
+
// peer not a trusted proxy → ignore forgeable header, fall through
|
|
718
|
+
} else {
|
|
719
|
+
return hops[0]; // legacy true — spoofable, see docstring
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
return typeof req.headers.host === "string" ? req.headers.host : null;
|
|
725
|
+
}
|
|
726
|
+
|
|
639
727
|
// RFC 9110 §5.6.2 token grammar — letters, digits, and the
|
|
640
728
|
// punctuation set `!#$%&'*+-.^_`|~`. Used by header-list parsers
|
|
641
729
|
// that consume protocol tokens (Connection, Sec-WebSocket-Protocol,
|
|
@@ -1221,6 +1309,8 @@ module.exports = {
|
|
|
1221
1309
|
ipPrefix: ipPrefix,
|
|
1222
1310
|
requestProtocol: requestProtocol,
|
|
1223
1311
|
trustedProtocol: trustedProtocol,
|
|
1312
|
+
requestHost: requestHost,
|
|
1313
|
+
trustedHost: trustedHost,
|
|
1224
1314
|
appendVary: appendVary,
|
|
1225
1315
|
// CVE-2026-21710 wrap — safe alternative to req.headersDistinct
|
|
1226
1316
|
safeHeadersDistinct: safeHeadersDistinct,
|
|
@@ -116,6 +116,49 @@ function _detectAlg(pubkeyPem) {
|
|
|
116
116
|
"(need ecdsa-p384, ed25519, or ml-dsa-87)");
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
// _looksLikeDerEcdsa — true iff `sig` is a structurally-well-formed ASN.1
|
|
120
|
+
// DER ECDSA signature: SEQUENCE { INTEGER r, INTEGER s }. We dispatch the
|
|
121
|
+
// dsaEncoding by STRUCTURE, never by length: a P-384 DER signature whose r
|
|
122
|
+
// and s both encode short can total exactly 96 bytes — the same length as a
|
|
123
|
+
// raw IEEE-P1363 P-384 signature (48-byte r || 48-byte s) — so a length-only
|
|
124
|
+
// test mis-decodes the valid DER signature as raw and spuriously rejects an
|
|
125
|
+
// otherwise-valid update. This is a shape check only; cryptographic validity
|
|
126
|
+
// is still decided by the single verifier.verify() call below.
|
|
127
|
+
//
|
|
128
|
+
// DER layout: 0x30 <seqLen> 0x02 <rLen> <r...> 0x02 <sLen> <s...>, where each
|
|
129
|
+
// declared length must exactly frame the bytes that follow (definite-form,
|
|
130
|
+
// short or long encoding) and the SEQUENCE body must consume the whole sig.
|
|
131
|
+
function _readDerLen(buf, off) {
|
|
132
|
+
if (off >= buf.length) return null;
|
|
133
|
+
var first = buf[off];
|
|
134
|
+
if (first < 0x80) return { len: first, next: off + 1 }; // short form
|
|
135
|
+
var numBytes = first & 0x7f;
|
|
136
|
+
if (numBytes === 0 || numBytes > 4) return null; // indefinite / oversized: reject
|
|
137
|
+
if (off + 1 + numBytes > buf.length) return null;
|
|
138
|
+
var len = 0;
|
|
139
|
+
for (var i = 0; i < numBytes; i++) len = (len * 256) + buf[off + 1 + i];
|
|
140
|
+
return { len: len, next: off + 1 + numBytes };
|
|
141
|
+
}
|
|
142
|
+
function _readDerInteger(buf, off) {
|
|
143
|
+
if (off >= buf.length || buf[off] !== 0x02) return null; // INTEGER tag
|
|
144
|
+
var l = _readDerLen(buf, off + 1);
|
|
145
|
+
if (l === null || l.len === 0) return null;
|
|
146
|
+
var end = l.next + l.len;
|
|
147
|
+
if (end > buf.length) return null;
|
|
148
|
+
return { next: end };
|
|
149
|
+
}
|
|
150
|
+
function _looksLikeDerEcdsa(sig) {
|
|
151
|
+
if (sig.length < 8 || sig[0] !== 0x30) return false; // SEQUENCE tag
|
|
152
|
+
var seq = _readDerLen(sig, 1);
|
|
153
|
+
if (seq === null) return false;
|
|
154
|
+
if (seq.next + seq.len !== sig.length) return false; // body must frame to end
|
|
155
|
+
var r = _readDerInteger(sig, seq.next);
|
|
156
|
+
if (r === null) return false;
|
|
157
|
+
var s = _readDerInteger(sig, r.next);
|
|
158
|
+
if (s === null) return false;
|
|
159
|
+
return s.next === sig.length; // exactly two INTEGERs, no trailing bytes
|
|
160
|
+
}
|
|
161
|
+
|
|
119
162
|
/**
|
|
120
163
|
* @primitive b.selfUpdate.standaloneVerifier.verify
|
|
121
164
|
* @signature b.selfUpdate.standaloneVerifier.verify(assetPath, signaturePath, pubkeyPem)
|
|
@@ -285,13 +328,32 @@ function verify(assetPath, signaturePath, pubkeyPem) {
|
|
|
285
328
|
|
|
286
329
|
var ok = false;
|
|
287
330
|
if (alg === "ecdsa-p384") {
|
|
288
|
-
//
|
|
289
|
-
//
|
|
290
|
-
//
|
|
291
|
-
//
|
|
292
|
-
//
|
|
293
|
-
//
|
|
294
|
-
|
|
331
|
+
// Pick the ECDSA signature encoding by STRUCTURE, not by length. A P-384
|
|
332
|
+
// DER signature whose r and s both encode short can total exactly 96
|
|
333
|
+
// bytes — the same length as a raw IEEE-P1363 P-384 signature (48-byte r
|
|
334
|
+
// || 48-byte s) — so a length-only test mis-decodes the valid DER
|
|
335
|
+
// signature as raw and spuriously rejects an otherwise-valid update.
|
|
336
|
+
//
|
|
337
|
+
// A well-formed ASN.1 DER ECDSA signature is a SEQUENCE { INTEGER r,
|
|
338
|
+
// INTEGER s }; raw IEEE-P1363 is exactly 2*coordLen bytes (coordLen =
|
|
339
|
+
// 48 for the P-384 field). If it parses as DER, treat as DER; else if it
|
|
340
|
+
// is exactly 2*coordLen, treat as raw; else fail closed. We call
|
|
341
|
+
// verifier.verify() ONCE — a second call after a failed verify returns
|
|
342
|
+
// stale state and can silently pass tampered assets.
|
|
343
|
+
var coordLen = 48; // P-384 field element width in bytes; protocol constant, not a byte-size cap
|
|
344
|
+
var dsaEncoding;
|
|
345
|
+
if (_looksLikeDerEcdsa(signature)) {
|
|
346
|
+
dsaEncoding = "der";
|
|
347
|
+
} else if (signature.length === coordLen * 2) {
|
|
348
|
+
dsaEncoding = "ieee-p1363";
|
|
349
|
+
} else {
|
|
350
|
+
// assetFd was already closed by the read loop's `finally`; this is a
|
|
351
|
+
// pure fail-closed refusal, same as the `if (!ok)` path below.
|
|
352
|
+
throw new Error("standalone-verifier.verify: ecdsa-p384 signature is neither a " +
|
|
353
|
+
"well-formed DER SEQUENCE nor a raw " + (coordLen * 2) +
|
|
354
|
+
"-byte IEEE-P1363 pair (length " + signature.length +
|
|
355
|
+
") — refusing to guess the encoding");
|
|
356
|
+
}
|
|
295
357
|
ok = verifier.verify({ key: key, dsaEncoding: dsaEncoding }, signature);
|
|
296
358
|
} else if (alg === "ed25519") {
|
|
297
359
|
// fullBuf may be shorter than allocated (sparse files / size-races);
|
|
@@ -297,6 +297,13 @@ function _matchAsset(name, pattern, fallback) {
|
|
|
297
297
|
* with conservative fallbacks. Throws SelfUpdateError on a non-2xx
|
|
298
298
|
* upstream, malformed JSON, or unexpected shape.
|
|
299
299
|
*
|
|
300
|
+
* Each matched asset / signature is reported as
|
|
301
|
+
* `{ name, url, size, digest }`. `digest` carries the release API's
|
|
302
|
+
* published `assets[].digest` (e.g. `"sha256:<hex>"`) verbatim when the
|
|
303
|
+
* upstream supplies it, or `null` when absent — a consumer can use it
|
|
304
|
+
* for a defense-in-depth in-flight integrity check of the downloaded
|
|
305
|
+
* bytes alongside the detached-signature verify.
|
|
306
|
+
*
|
|
300
307
|
* @opts
|
|
301
308
|
* releasesUrl: string, // required — feed URL
|
|
302
309
|
* currentVersion: string, // required — e.g. "0.8.43" or "v0.8.43"
|
|
@@ -446,11 +453,13 @@ async function poll(opts) {
|
|
|
446
453
|
var a = assets[i] || {};
|
|
447
454
|
if (typeof a.name !== "string" || typeof a.browser_download_url !== "string") continue;
|
|
448
455
|
if (signatureMatch === null && _matchAsset(a.name, opts.signaturePattern, /\.sig$|\.asc$|\.sig\.bin$/i)) {
|
|
449
|
-
signatureMatch = { name: a.name, url: a.browser_download_url, size: a.size || null
|
|
456
|
+
signatureMatch = { name: a.name, url: a.browser_download_url, size: a.size || null,
|
|
457
|
+
digest: typeof a.digest === "string" ? a.digest : null };
|
|
450
458
|
continue;
|
|
451
459
|
}
|
|
452
460
|
if (assetMatch === null && _matchAsset(a.name, opts.assetPattern, /\.(tar\.gz|tgz|zip|node|exe|bin)$/i)) {
|
|
453
|
-
assetMatch = { name: a.name, url: a.browser_download_url, size: a.size || null
|
|
461
|
+
assetMatch = { name: a.name, url: a.browser_download_url, size: a.size || null,
|
|
462
|
+
digest: typeof a.digest === "string" ? a.digest : null };
|
|
454
463
|
}
|
|
455
464
|
}
|
|
456
465
|
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"hashes": {
|
|
19
19
|
"server": "sha256:5d539dfc9ef47121d4c09bd7256d76448a1f5ac47ee09ac44c78ff6a062af9ab"
|
|
20
20
|
},
|
|
21
|
-
"refreshedAt": "2026-06-
|
|
21
|
+
"refreshedAt": "2026-06-22T16:29:46.590Z"
|
|
22
22
|
},
|
|
23
23
|
"@noble/curves": {
|
|
24
24
|
"version": "2.2.0",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"hashes": {
|
|
41
41
|
"server": "sha256:ebf254d5eb56aef8705a1c4af9603f47987b4870a9bb5e657e06907b701e2731"
|
|
42
42
|
},
|
|
43
|
-
"refreshedAt": "2026-06-
|
|
43
|
+
"refreshedAt": "2026-06-22T16:29:46.590Z"
|
|
44
44
|
},
|
|
45
45
|
"@noble/post-quantum": {
|
|
46
46
|
"version": "0.6.1",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"hashes": {
|
|
72
72
|
"server": "sha256:f9190309daadca4c2e2cc2b76beaa6b96e463429cc3c390bd9f0ceaf7b588c68"
|
|
73
73
|
},
|
|
74
|
-
"refreshedAt": "2026-06-
|
|
74
|
+
"refreshedAt": "2026-06-22T16:29:46.590Z"
|
|
75
75
|
},
|
|
76
76
|
"@simplewebauthn/server": {
|
|
77
77
|
"version": "13.3.1",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"hashes": {
|
|
95
95
|
"server": "sha256:f359a782ac57e3ff56ac71083d17f5c082f88ab49d645fc2bede398b47adebdb"
|
|
96
96
|
},
|
|
97
|
-
"refreshedAt": "2026-06-
|
|
97
|
+
"refreshedAt": "2026-06-22T16:29:46.590Z"
|
|
98
98
|
},
|
|
99
99
|
"SecLists-common-passwords-top-10000": {
|
|
100
100
|
"version": "10k-most-common (master)",
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
},
|
|
115
115
|
"runtime_artifact": "lib/vendor/common-passwords-top-10000.data.js",
|
|
116
116
|
"integrity_layers": "sha256 + sha3-512 + SLH-DSA-SHAKE-256f signature + in-payload canary (where applicable)",
|
|
117
|
-
"refreshedAt": "2026-06-
|
|
117
|
+
"refreshedAt": "2026-06-22T16:29:46.590Z"
|
|
118
118
|
},
|
|
119
119
|
"bimi-trust-anchors": {
|
|
120
120
|
"version": "operator-managed",
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
},
|
|
140
140
|
"runtime_artifact": "lib/vendor/bimi-trust-anchors.data.js",
|
|
141
141
|
"integrity_layers": "sha256 + sha3-512 + SLH-DSA-SHAKE-256f signature + in-payload canary (where applicable)",
|
|
142
|
-
"refreshedAt": "2026-06-
|
|
142
|
+
"refreshedAt": "2026-06-22T16:29:46.590Z"
|
|
143
143
|
},
|
|
144
144
|
"publicsuffix-list": {
|
|
145
145
|
"version": "master",
|
|
@@ -152,14 +152,14 @@
|
|
|
152
152
|
"data_js": "lib/vendor/public-suffix-list.data.js"
|
|
153
153
|
},
|
|
154
154
|
"bundler": "curl https://publicsuffix.org/list/public_suffix_list.dat",
|
|
155
|
-
"bundledAt": "2026-
|
|
155
|
+
"bundledAt": "2026-06-22T00:00:00Z",
|
|
156
156
|
"hashes": {
|
|
157
|
-
"server": "sha256:
|
|
158
|
-
"data_js": "sha256:
|
|
157
|
+
"server": "sha256:0adddeb62057d8d40799dffb29fe14f65dd009259afe02eb2f0b4602b791aae6",
|
|
158
|
+
"data_js": "sha256:82af512cacf0fd2c60925e63f877b69477b1b2f7bb5af698fd862af61369902e"
|
|
159
159
|
},
|
|
160
160
|
"runtime_artifact": "lib/vendor/public-suffix-list.data.js",
|
|
161
161
|
"integrity_layers": "sha256 + sha3-512 + SLH-DSA-SHAKE-256f signature + in-payload canary (where applicable)",
|
|
162
|
-
"refreshedAt": "2026-06-
|
|
162
|
+
"refreshedAt": "2026-06-22T16:29:46.590Z"
|
|
163
163
|
},
|
|
164
164
|
"peculiar-pki": {
|
|
165
165
|
"version": "2.0.0+pkijs-3.4.0",
|
|
@@ -190,7 +190,7 @@
|
|
|
190
190
|
"hashes": {
|
|
191
191
|
"server": "sha256:9bbc191afaaa2b1e5757f00480457c08134cdc2c55d541df18d9155bba9cbf77"
|
|
192
192
|
},
|
|
193
|
-
"refreshedAt": "2026-06-
|
|
193
|
+
"refreshedAt": "2026-06-22T16:29:46.590Z"
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
// Please pull this list from, and only from https://publicsuffix.org/list/public_suffix_list.dat,
|
|
6
6
|
// rather than any other VCS sites. Pulling from any other URL is not guaranteed to be supported.
|
|
7
7
|
|
|
8
|
-
// VERSION: 2026-06-
|
|
9
|
-
// COMMIT:
|
|
8
|
+
// VERSION: 2026-06-22_11-46-12_UTC
|
|
9
|
+
// COMMIT: 27a7b5d881b91def306422e6cc243f05c49f3a58
|
|
10
10
|
|
|
11
11
|
// Instructions on pulling and using this list can be found at https://publicsuffix.org/list/.
|
|
12
12
|
|
|
@@ -14721,6 +14721,10 @@ mittwaldserver.info
|
|
|
14721
14721
|
typo3server.info
|
|
14722
14722
|
project.space
|
|
14723
14723
|
|
|
14724
|
+
// MKM : https://mkm.fan/
|
|
14725
|
+
// Submitted by Kashi Ahmer <admin@mkm.fan>
|
|
14726
|
+
mkm.fan
|
|
14727
|
+
|
|
14724
14728
|
// Mocha : https://getmocha.com
|
|
14725
14729
|
// Submitted by Ben Reinhart <security@getmocha.com>
|
|
14726
14730
|
mocha.app
|