@blamejs/core 0.14.26 → 0.15.0

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.
Files changed (150) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +2 -2
  3. package/index.js +4 -0
  4. package/lib/agent-envelope-mac.js +104 -0
  5. package/lib/agent-event-bus.js +105 -4
  6. package/lib/agent-posture-chain.js +8 -42
  7. package/lib/ai-content-detect.js +9 -10
  8. package/lib/api-key.js +107 -74
  9. package/lib/atomic-file.js +62 -4
  10. package/lib/audit-chain.js +47 -11
  11. package/lib/audit-sign.js +77 -2
  12. package/lib/audit-tools.js +79 -51
  13. package/lib/audit.js +249 -123
  14. package/lib/auth/openid-federation.js +108 -47
  15. package/lib/backup/index.js +13 -10
  16. package/lib/break-glass.js +202 -144
  17. package/lib/cache.js +174 -105
  18. package/lib/chain-writer.js +38 -16
  19. package/lib/cli.js +19 -14
  20. package/lib/cluster-provider-db.js +130 -104
  21. package/lib/cluster-storage.js +119 -22
  22. package/lib/cluster.js +119 -71
  23. package/lib/compliance.js +169 -4
  24. package/lib/consent.js +73 -24
  25. package/lib/constants.js +16 -11
  26. package/lib/crypto-field.js +474 -92
  27. package/lib/db-declare-row-policy.js +35 -22
  28. package/lib/db-file-lifecycle.js +3 -2
  29. package/lib/db-query.js +497 -255
  30. package/lib/db-schema.js +209 -44
  31. package/lib/db.js +176 -95
  32. package/lib/error-page.js +14 -1
  33. package/lib/external-db-migrate.js +229 -139
  34. package/lib/external-db.js +25 -15
  35. package/lib/file-upload.js +52 -7
  36. package/lib/framework-error.js +14 -1
  37. package/lib/framework-files.js +73 -0
  38. package/lib/framework-schema.js +695 -394
  39. package/lib/gate-contract.js +649 -1
  40. package/lib/guard-agent-registry.js +26 -44
  41. package/lib/guard-all.js +1 -0
  42. package/lib/guard-auth.js +42 -112
  43. package/lib/guard-cidr.js +33 -154
  44. package/lib/guard-csv.js +46 -113
  45. package/lib/guard-domain.js +34 -157
  46. package/lib/guard-dsn.js +27 -43
  47. package/lib/guard-email.js +47 -69
  48. package/lib/guard-envelope.js +19 -32
  49. package/lib/guard-event-bus-payload.js +24 -42
  50. package/lib/guard-event-bus-topic.js +25 -43
  51. package/lib/guard-filename.js +42 -106
  52. package/lib/guard-graphql.js +42 -123
  53. package/lib/guard-html.js +53 -108
  54. package/lib/guard-idempotency-key.js +24 -42
  55. package/lib/guard-image.js +46 -103
  56. package/lib/guard-imap-command.js +18 -32
  57. package/lib/guard-jmap.js +16 -30
  58. package/lib/guard-json.js +38 -108
  59. package/lib/guard-jsonpath.js +38 -171
  60. package/lib/guard-jwt.js +49 -179
  61. package/lib/guard-list-id.js +25 -41
  62. package/lib/guard-list-unsubscribe.js +27 -43
  63. package/lib/guard-mail-compose.js +24 -42
  64. package/lib/guard-mail-move.js +26 -44
  65. package/lib/guard-mail-query.js +28 -46
  66. package/lib/guard-mail-reply.js +24 -42
  67. package/lib/guard-mail-sieve.js +24 -42
  68. package/lib/guard-managesieve-command.js +17 -31
  69. package/lib/guard-markdown.js +37 -104
  70. package/lib/guard-message-id.js +26 -45
  71. package/lib/guard-mime.js +39 -151
  72. package/lib/guard-oauth.js +54 -135
  73. package/lib/guard-pdf.js +45 -101
  74. package/lib/guard-pop3-command.js +21 -31
  75. package/lib/guard-posture-chain.js +24 -42
  76. package/lib/guard-regex.js +33 -107
  77. package/lib/guard-saga-config.js +24 -42
  78. package/lib/guard-shell.js +42 -172
  79. package/lib/guard-smtp-command.js +48 -54
  80. package/lib/guard-snapshot-envelope.js +24 -42
  81. package/lib/guard-sql.js +1491 -0
  82. package/lib/guard-stream-args.js +24 -43
  83. package/lib/guard-svg.js +47 -65
  84. package/lib/guard-template.js +35 -172
  85. package/lib/guard-tenant-id.js +26 -45
  86. package/lib/guard-time.js +32 -154
  87. package/lib/guard-trace-context.js +25 -44
  88. package/lib/guard-uuid.js +32 -153
  89. package/lib/guard-xml.js +38 -113
  90. package/lib/guard-yaml.js +51 -163
  91. package/lib/http-client.js +37 -9
  92. package/lib/inbox.js +120 -107
  93. package/lib/legal-hold.js +107 -50
  94. package/lib/log-stream-cloudwatch.js +47 -31
  95. package/lib/log-stream-otlp.js +32 -18
  96. package/lib/mail-crypto-smime.js +2 -6
  97. package/lib/mail-greylist.js +2 -6
  98. package/lib/mail-helo.js +2 -6
  99. package/lib/mail-journal.js +85 -64
  100. package/lib/mail-rbl.js +2 -6
  101. package/lib/mail-scan.js +2 -6
  102. package/lib/mail-server-jmap.js +117 -12
  103. package/lib/mail-spam-score.js +2 -6
  104. package/lib/mail-store.js +287 -154
  105. package/lib/middleware/body-parser.js +71 -25
  106. package/lib/middleware/csrf-protect.js +19 -8
  107. package/lib/middleware/fetch-metadata.js +17 -7
  108. package/lib/middleware/idempotency-key.js +54 -38
  109. package/lib/middleware/rate-limit.js +102 -32
  110. package/lib/middleware/security-headers.js +21 -5
  111. package/lib/migrations.js +108 -66
  112. package/lib/network-heartbeat.js +7 -0
  113. package/lib/nonce-store.js +31 -9
  114. package/lib/object-store/azure-blob-bucket-ops.js +9 -4
  115. package/lib/object-store/azure-blob.js +57 -3
  116. package/lib/object-store/sigv4.js +10 -0
  117. package/lib/observability.js +87 -0
  118. package/lib/otel-export.js +25 -1
  119. package/lib/outbox.js +136 -82
  120. package/lib/parsers/safe-xml.js +47 -7
  121. package/lib/pqc-agent.js +44 -0
  122. package/lib/pubsub-cluster.js +42 -20
  123. package/lib/queue-local.js +202 -139
  124. package/lib/queue-redis.js +9 -1
  125. package/lib/queue-sqs.js +6 -0
  126. package/lib/redact.js +68 -11
  127. package/lib/redis-client.js +160 -31
  128. package/lib/retention.js +82 -39
  129. package/lib/router.js +212 -5
  130. package/lib/safe-dns.js +29 -45
  131. package/lib/safe-ical.js +18 -33
  132. package/lib/safe-icap.js +27 -43
  133. package/lib/safe-sieve.js +21 -40
  134. package/lib/safe-sql.js +124 -3
  135. package/lib/safe-vcard.js +18 -33
  136. package/lib/scheduler.js +35 -12
  137. package/lib/seeders.js +122 -74
  138. package/lib/session-stores.js +42 -14
  139. package/lib/session.js +109 -72
  140. package/lib/sql.js +3885 -0
  141. package/lib/ssrf-guard.js +51 -4
  142. package/lib/static.js +177 -34
  143. package/lib/subject.js +55 -17
  144. package/lib/vault/index.js +3 -2
  145. package/lib/vault/passphrase-ops.js +3 -2
  146. package/lib/vault/rotate.js +104 -64
  147. package/lib/vendor-data.js +2 -0
  148. package/lib/websocket.js +35 -5
  149. package/package.json +1 -1
  150. package/sbom.cdx.json +6 -6
@@ -334,14 +334,23 @@ function _applyOnePolicy(metadata, policy) {
334
334
  * @signature b.auth.openidFederation.applyMetadataPolicy(metadata, chain, kind)
335
335
  * @since 0.8.62
336
336
  *
337
- * Apply every metadata_policy in the chain (top-down) to the leaf's
337
+ * Apply the federation's metadata_policy (top-down) to the leaf's
338
338
  * declared metadata for the given entity-kind ("openid_relying_party"
339
339
  * / "openid_provider" / "federation_entity" / etc.) and return the
340
340
  * effective metadata. Throws on any policy violation.
341
341
  *
342
- * The chain is leaf-first; we reverse for top-down application so
343
- * the trust anchor's policy applies first, then each intermediate's,
344
- * then the leaf's claimed metadata is the starting object.
342
+ * Per OpenID Federation 1.0 §6.2, an entity's metadata_policy comes
343
+ * from the SUPERIOR-SIGNED subordinate statement about that entity
344
+ * (`chain[i].subordinate.metadata_policy`), NOT from the entity's own
345
+ * self-published configuration. An entity cannot self-declare the
346
+ * policy that constrains it — that would let a leaf widen or drop the
347
+ * trust anchor's value / subset_of / essential constraints. The leaf's
348
+ * own self-config metadata_policy is therefore ignored.
349
+ *
350
+ * The chain is leaf-first; each `chain[i].subordinate` is the statement
351
+ * signed by the superior directly above entity `i`, so walking high
352
+ * index → low index applies the anchor's policy first, then each
353
+ * intermediate's, narrowing down to the leaf (§6.2 narrow-only merge).
345
354
  *
346
355
  * @example
347
356
  * var effective = b.auth.openidFederation.applyMetadataPolicy(
@@ -361,12 +370,17 @@ function applyMetadataPolicy(metadata, chain, kind) {
361
370
  "applyMetadataPolicy: chain must be an array");
362
371
  }
363
372
  var out = Object.assign({}, metadata);
364
- // Walk top-down (anchor last in leaf-first array).
373
+ // Walk top-down (anchor last in leaf-first array). Read the policy
374
+ // from each node's SUPERIOR-SIGNED subordinate statement — never from
375
+ // the entity's own self-config — so the anchor/intermediate
376
+ // constraints can't be dropped by a self-declared policy. The anchor
377
+ // node carries no `.subordinate` (it terminates the chain) and is
378
+ // skipped; the leaf's self-config policy is never read.
365
379
  for (var i = chain.length - 1; i >= 0; i--) {
366
380
  var stmt = chain[i];
367
- if (!stmt || !stmt.claims) continue;
368
- if (stmt.claims.metadata_policy && stmt.claims.metadata_policy[kind]) {
369
- out = _applyOnePolicy(out, stmt.claims.metadata_policy[kind]);
381
+ if (!stmt || !stmt.subordinate) continue;
382
+ if (stmt.subordinate.metadata_policy && stmt.subordinate.metadata_policy[kind]) {
383
+ out = _applyOnePolicy(out, stmt.subordinate.metadata_policy[kind]);
370
384
  }
371
385
  }
372
386
  return out;
@@ -433,6 +447,18 @@ async function buildTrustChain(opts) {
433
447
  };
434
448
  var maxDepth = opts.maxDepth || MAX_CHAIN_DEPTH;
435
449
 
450
+ // ---- Phase 1: collect the chain bottom-up (leaf → anchor) ----------
451
+ // Fetch each entity's self-config + the superior-signed subordinate
452
+ // statement about it, but DEFER cryptographic chain verification to
453
+ // Phase 2. The signature on a subordinate statement must be checked
454
+ // against the keys ATTESTED for the signing authority by ITS superior
455
+ // — flowing down from the operator-pinned anchor — not against the
456
+ // authority's own self-published config jwks. Verifying eagerly here
457
+ // (against self-published keys) is a fetch-time TOCTOU: an attacker
458
+ // controlling the authority's endpoint can serve attacker jwks to the
459
+ // statement-verify fetch while serving genuine config elsewhere, and
460
+ // the only operator-pinned trust (the anchor key) never gates the
461
+ // subordinate links.
436
462
  var chain = [];
437
463
  var current = opts.leafEntityId;
438
464
  var depth = 0;
@@ -446,6 +472,7 @@ async function buildTrustChain(opts) {
446
472
  // hostile-federation probes immediately.
447
473
  var visited = Object.create(null);
448
474
  visited[current] = true;
475
+ var reachedAnchor = false;
449
476
  while (depth < maxDepth) {
450
477
  var entityConfigUrl = current.replace(/\/$/, "") + "/.well-known/openid-federation";
451
478
  var entityConfigJwt = await fetcher(entityConfigUrl);
@@ -454,21 +481,22 @@ async function buildTrustChain(opts) {
454
481
  throw new AuthError("auth-openid-federation/bad-self-statement",
455
482
  "entity configuration for \"" + current + "\" must have iss==sub==entity_id");
456
483
  }
457
- // Self-signed: verify with its own jwks.
484
+ // Self-statement integrity: a well-formed entity config is self-signed
485
+ // over its own jwks. This proves the document isn't truncated/garbled
486
+ // — it is NOT the trust decision. Trust flows from the anchor through
487
+ // the subordinate statements verified top-down in Phase 2.
458
488
  verifyEntityStatement(entityConfigJwt, parsedEC.claims.jwks || {});
459
489
 
460
490
  // Is this entity a trust anchor?
461
491
  if (Object.prototype.hasOwnProperty.call(opts.trustAnchors, current)) {
462
492
  // Verify the anchor's self-statement using the operator-pinned
463
493
  // JWKS — defends against a compromised anchor key by trusting
464
- // the configured one over what the anchor publishes today.
494
+ // the configured one over what the anchor publishes today. The
495
+ // pinned keys become the root of the top-down verification.
465
496
  verifyEntityStatement(entityConfigJwt, opts.trustAnchors[current]);
466
497
  chain.push({ jwt: entityConfigJwt, claims: parsedEC.claims, role: "trust_anchor" });
467
- _emitAudit("chain_built", "success", {
468
- leaf: opts.leafEntityId, depth: chain.length, anchor: current,
469
- });
470
- _emitMetric("chain-built");
471
- return chain;
498
+ reachedAnchor = true;
499
+ break;
472
500
  }
473
501
  // Not the anchor — add to chain, ascend via authority_hints.
474
502
  chain.push({
@@ -481,16 +509,15 @@ async function buildTrustChain(opts) {
481
509
  throw new AuthError("auth-openid-federation/no-authority-hints",
482
510
  "entity \"" + current + "\" has no authority_hints; cannot ascend to a trust anchor");
483
511
  }
484
- // Pick the FIRST authority_hint that resolves to a trust anchor,
485
- // OR the first that returns a valid subordinate statement. Real
486
- // operators with multiple federations usually have one anchor
487
- // active; we walk in order and pick the first success.
488
- // Track every per-authority failure reason and surface them on
489
- // `no-ascent` rather than masking silently
490
- // swallowing `catch (_e) {}` lets a hostile intermediate that
491
- // serves a malformed-then-valid pair shape-walk the verifier.
492
- // We continue past 404 / fetch errors but refuse on
493
- // signature-verify failure (cryptographic refusal is a hard stop).
512
+ // Pick the FIRST authority_hint that yields a fetchable subordinate
513
+ // statement with matching iss/sub. We continue past 404 / fetch /
514
+ // parse errors (acceptable "try the next hint") and surface every
515
+ // failure reason on `no-ascent` rather than masking it silently
516
+ // swallowing `catch (_e) {}` lets a hostile intermediate that serves
517
+ // a malformed-then-valid pair shape-walk the verifier. Cryptographic
518
+ // verification is NOT done here; the selected statement is verified
519
+ // against the superior-attested keys in Phase 2, so a forged
520
+ // signature fails the whole chain regardless of which hint picked it.
494
521
  var ascended = false;
495
522
  var ascentErrors = [];
496
523
  for (var ai = 0; ai < parsedEC.claims.authority_hints.length; ai++) {
@@ -502,49 +529,83 @@ async function buildTrustChain(opts) {
502
529
  ascentErrors.push({ authority: authority, code: "iss-sub-mismatch" });
503
530
  continue;
504
531
  }
505
- var authorityCfgJwt = await fetcher(authority.replace(/\/$/, "") + "/.well-known/openid-federation");
506
- var authorityCfgClaims = parseEntityStatement(authorityCfgJwt).claims;
507
- // Cryptographic verification — any throw here is a hard
508
- // refusal, NOT a "try next authority" signal. A malformed-
509
- // signature subordinate from an authority listed by the
510
- // entity means that authority is hostile or compromised;
511
- // moving on lets a chain-shaping attacker bypass the gate.
512
- verifyEntityStatement(subordinateJwt, authorityCfgClaims.jwks || {});
513
- chain[chain.length - 1].claims.jwks = parsedSub.claims.jwks || chain[chain.length - 1].claims.jwks;
514
- chain[chain.length - 1].subordinateJwt = subordinateJwt;
515
- chain[chain.length - 1].subordinate = parsedSub.claims;
516
- // Refuse revisit. A trust anchor terminates the loop
517
- // before re-entry, so a revisit here ALWAYS means a cyclic
532
+ // Refuse revisit. A trust anchor terminates the loop before
533
+ // re-entry, so a revisit here ALWAYS means a cyclic
518
534
  // authority_hints graph.
519
535
  if (visited[authority]) {
520
536
  throw new AuthError("auth-openid-federation/chain-cycle",
521
537
  "buildTrustChain: authority \"" + authority + "\" already visited — " +
522
538
  "cyclic authority_hints graph refused");
523
539
  }
540
+ // Stash the superior-signed subordinate statement on the entity
541
+ // it is ABOUT. Phase 2 verifies its signature against the
542
+ // attested keys for `authority` and applies its metadata_policy.
543
+ chain[chain.length - 1].subordinateJwt = subordinateJwt;
544
+ chain[chain.length - 1].subordinate = parsedSub.claims;
524
545
  visited[authority] = true;
525
546
  current = authority;
526
547
  ascended = true;
527
548
  break;
528
549
  } catch (err) {
550
+ // A cycle refusal is a hard stop, not a "try next hint" signal.
551
+ if (err && err.code === "auth-openid-federation/chain-cycle") throw err;
529
552
  var errCode = (err && err.code) || "unknown";
530
- // Network / 404 / parse errors at the AUTHORITY-fetch step
531
- // are acceptable "try the next hint" signals. Verify-side
532
- // failures (crypto) are NOT — surface them and abort.
533
- if (/^auth-openid-federation\/(?:bad-jwk|alg-kty-mismatch|bad-signature|signature-failed)$/.test(errCode)) {
534
- throw err;
535
- }
536
553
  ascentErrors.push({ authority: authority, code: errCode, message: (err && err.message) || String(err) });
537
554
  }
538
555
  }
539
556
  if (!ascended) {
540
557
  throw new AuthError("auth-openid-federation/no-ascent",
541
- "entity \"" + current + "\" has authority_hints but none yielded a verifiable subordinate statement: " +
558
+ "entity \"" + current + "\" has authority_hints but none yielded a fetchable subordinate statement: " +
542
559
  JSON.stringify(ascentErrors));
543
560
  }
544
561
  depth += 1;
545
562
  }
546
- throw new AuthError("auth-openid-federation/chain-too-deep",
547
- "buildTrustChain: max depth " + maxDepth + " exceeded; refused");
563
+ if (!reachedAnchor) {
564
+ throw new AuthError("auth-openid-federation/chain-too-deep",
565
+ "buildTrustChain: max depth " + maxDepth + " exceeded; refused");
566
+ }
567
+
568
+ // ---- Phase 2: verify top-down against attested keys ----------------
569
+ // Trust flows from the operator-pinned anchor downward. Each
570
+ // subordinate statement is signed by the superior directly above the
571
+ // entity it describes, and pins that entity's jwks. We start with the
572
+ // anchor's pinned keys and, for each step down, verify the subordinate
573
+ // statement with the keys attested for its SIGNER (never the signer's
574
+ // self-published config), then adopt the statement's attested jwks as
575
+ // the trusted keys for the next step. This closes the fetch-time TOCTOU
576
+ // and makes the anchor key gate every link, not just the anchor's own
577
+ // self-config.
578
+ var anchorEntityId = chain[chain.length - 1].claims.iss;
579
+ var attestedJwks = opts.trustAnchors[anchorEntityId];
580
+ for (var ci = chain.length - 2; ci >= 0; ci--) {
581
+ var node = chain[ci];
582
+ if (!node.subordinate || !node.subordinateJwt) {
583
+ // Every non-anchor node must carry the superior-signed statement
584
+ // collected in Phase 1; its absence is an internal invariant break.
585
+ throw new AuthError("auth-openid-federation/no-subordinate",
586
+ "buildTrustChain: entity \"" + node.claims.iss + "\" has no superior-signed subordinate statement");
587
+ }
588
+ // Verify against the SIGNER's attested keys (flowed down), not the
589
+ // signer's self-published config jwks.
590
+ verifyEntityStatement(node.subordinateJwt, attestedJwks || {});
591
+ // The subordinate statement pins this entity's jwks — adopt the
592
+ // attested keys for the next link down, and reflect them on the node.
593
+ if (node.subordinate.jwks && Array.isArray(node.subordinate.jwks.keys)) {
594
+ node.claims.jwks = node.subordinate.jwks;
595
+ attestedJwks = node.subordinate.jwks;
596
+ } else {
597
+ // A subordinate statement that pins no keys cannot attest the next
598
+ // link — refuse rather than fall back to self-published keys.
599
+ throw new AuthError("auth-openid-federation/no-attested-jwks",
600
+ "subordinate statement for \"" + node.claims.iss + "\" pins no jwks; cannot attest the chain downward");
601
+ }
602
+ }
603
+
604
+ _emitAudit("chain_built", "success", {
605
+ leaf: opts.leafEntityId, depth: chain.length, anchor: anchorEntityId,
606
+ });
607
+ _emitMetric("chain-built");
608
+ return chain;
548
609
  }
549
610
 
550
611
  /**
@@ -54,6 +54,7 @@ var nodePath = require("node:path");
54
54
  var bCrypto = require("../crypto");
55
55
  var atomicFile = require("../atomic-file");
56
56
  var backupBundle = require("./bundle");
57
+ var frameworkFiles = require("../framework-files");
57
58
  var backupManifest = require("./manifest");
58
59
  var lazyRequire = require("../lazy-require");
59
60
  var validateOpts = require("../validate-opts");
@@ -887,21 +888,23 @@ function recommendedFiles(opts) {
887
888
  var files = [];
888
889
 
889
890
  if (atRest === "encrypted") {
890
- files.push({ relativePath: "db.enc", kind: "raw", required: true });
891
- files.push({ relativePath: "db.key.enc", kind: "raw", required: true });
891
+ files.push({ relativePath: frameworkFiles.fileName("dbEnc"), kind: "raw", required: true });
892
+ files.push({ relativePath: frameworkFiles.fileName("dbKeyEnc"), kind: "raw", required: true });
892
893
  } else {
893
894
  files.push({ relativePath: dbName, kind: "raw", required: true });
894
895
  }
895
896
 
896
897
  if (vaultMode === "wrapped") {
897
- files.push({ relativePath: "vault.key.sealed", kind: "raw", required: true });
898
+ files.push({ relativePath: frameworkFiles.fileName("vaultKey") + ".sealed", kind: "raw", required: true });
898
899
  } else {
899
- files.push({ relativePath: "vault.key", kind: "raw", required: true });
900
+ files.push({ relativePath: frameworkFiles.fileName("vaultKey"), kind: "raw", required: true });
900
901
  }
901
902
 
902
903
  // Audit-signing key (always present; sealed in wrapped mode)
903
904
  files.push({
904
- relativePath: vaultMode === "wrapped" ? "audit-sign.key.sealed" : "audit-sign.key",
905
+ relativePath: vaultMode === "wrapped"
906
+ ? frameworkFiles.fileName("auditSignKey") + ".sealed"
907
+ : frameworkFiles.fileName("auditSignKey"),
905
908
  kind: "raw", required: false,
906
909
  });
907
910
 
@@ -2368,7 +2371,7 @@ bundleAdapterStorage.objectStoreAdapter = function (client, osOpts) {
2368
2371
  // b.objectStore surfaces NOT_FOUND via the framework's
2369
2372
  // err.code === "NOT_FOUND" convention — translate to the
2370
2373
  // backup adapter contract's no-key error.
2371
- if (e && (e.code === "NOT_FOUND" || /NOT_FOUND|not found/i.test(e.message || ""))) {
2374
+ if (e && (e.code === "NOT_FOUND" || e.statusCode === 404 || /NOT_FOUND|not found/i.test(e.message || ""))) {
2372
2375
  throw new BackupError("backup/no-key",
2373
2376
  "objectStoreAdapter: key not found: " + JSON.stringify(key));
2374
2377
  }
@@ -2425,7 +2428,7 @@ bundleAdapterStorage.objectStoreAdapter = function (client, osOpts) {
2425
2428
  } catch (e) {
2426
2429
  // drop-silent on NOT_FOUND — adapter contract is idempotent
2427
2430
  // delete (fsAdapter same shape).
2428
- if (e && (e.code === "NOT_FOUND" || /NOT_FOUND|not found/i.test(e.message || ""))) {
2431
+ if (e && (e.code === "NOT_FOUND" || e.statusCode === 404 || /NOT_FOUND|not found/i.test(e.message || ""))) {
2429
2432
  return;
2430
2433
  }
2431
2434
  throw e;
@@ -2436,7 +2439,7 @@ bundleAdapterStorage.objectStoreAdapter = function (client, osOpts) {
2436
2439
  await client.head(_scopedKey(key));
2437
2440
  return true;
2438
2441
  } catch (e) {
2439
- if (e && (e.code === "NOT_FOUND" || /NOT_FOUND|not found/i.test(e.message || ""))) {
2442
+ if (e && (e.code === "NOT_FOUND" || e.statusCode === 404 || /NOT_FOUND|not found/i.test(e.message || ""))) {
2440
2443
  return false;
2441
2444
  }
2442
2445
  throw e;
@@ -2453,7 +2456,7 @@ bundleAdapterStorage.objectStoreAdapter = function (client, osOpts) {
2453
2456
  var buf = Buffer.isBuffer(body) ? body : Buffer.from(body);
2454
2457
  return buf.slice(0, length);
2455
2458
  } catch (e) {
2456
- if (e && (e.code === "NOT_FOUND" || /NOT_FOUND|not found/i.test(e.message || ""))) {
2459
+ if (e && (e.code === "NOT_FOUND" || e.statusCode === 404 || /NOT_FOUND|not found/i.test(e.message || ""))) {
2457
2460
  throw new BackupError("backup/no-key",
2458
2461
  "objectStoreAdapter.readPartial: key not found: " + JSON.stringify(key));
2459
2462
  }
@@ -2466,7 +2469,7 @@ bundleAdapterStorage.objectStoreAdapter = function (client, osOpts) {
2466
2469
  if (!meta || typeof meta.size !== "number") return null;
2467
2470
  return { size: meta.size, mtimeMs: meta.lastModified || null };
2468
2471
  } catch (e) {
2469
- if (e && (e.code === "NOT_FOUND" || /NOT_FOUND|not found/i.test(e.message || ""))) {
2472
+ if (e && (e.code === "NOT_FOUND" || e.statusCode === 404 || /NOT_FOUND|not found/i.test(e.message || ""))) {
2470
2473
  return null;
2471
2474
  }
2472
2475
  throw e;