@blamejs/blamejs-shop 0.4.31 → 0.4.32

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 (336) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/lib/asset-manifest.json +1 -1
  3. package/lib/vendor/MANIFEST.json +392 -278
  4. package/lib/vendor/blamejs/.github/workflows/ci.yml +34 -3
  5. package/lib/vendor/blamejs/.github/workflows/npm-publish.yml +21 -4
  6. package/lib/vendor/blamejs/.gitignore +6 -0
  7. package/lib/vendor/blamejs/CHANGELOG.md +26 -0
  8. package/lib/vendor/blamejs/MIGRATING.md +43 -0
  9. package/lib/vendor/blamejs/README.md +8 -6
  10. package/lib/vendor/blamejs/SECURITY.md +19 -3
  11. package/lib/vendor/blamejs/api-snapshot.json +2190 -664
  12. package/lib/vendor/blamejs/docker/caddy/localstack.Caddyfile +19 -0
  13. package/lib/vendor/blamejs/docker/init/generate-certs.sh +1 -1
  14. package/lib/vendor/blamejs/docker/otel/config.yaml +42 -0
  15. package/lib/vendor/blamejs/docker/otel/export/.gitkeep +0 -0
  16. package/lib/vendor/blamejs/docker/postgres/initdb/10-replication.sh +15 -0
  17. package/lib/vendor/blamejs/docker/postgres/replica-entrypoint.sh +38 -0
  18. package/lib/vendor/blamejs/docker/toxiproxy/toxiproxy.json +14 -0
  19. package/lib/vendor/blamejs/docker-compose.test.yml +209 -0
  20. package/lib/vendor/blamejs/examples/wiki/lib/page-generator.js +132 -0
  21. package/lib/vendor/blamejs/examples/wiki/lib/source-comment-block-validator.js +221 -61
  22. package/lib/vendor/blamejs/examples/wiki/lib/source-doc-parser.js +144 -9
  23. package/lib/vendor/blamejs/examples/wiki/test/e2e.js +99 -0
  24. package/lib/vendor/blamejs/fuzz/guard-sql.fuzz.js +36 -0
  25. package/lib/vendor/blamejs/index.js +4 -0
  26. package/lib/vendor/blamejs/lib/agent-envelope-mac.js +104 -0
  27. package/lib/vendor/blamejs/lib/agent-event-bus.js +105 -4
  28. package/lib/vendor/blamejs/lib/agent-posture-chain.js +8 -42
  29. package/lib/vendor/blamejs/lib/ai-content-detect.js +9 -10
  30. package/lib/vendor/blamejs/lib/api-key.js +158 -77
  31. package/lib/vendor/blamejs/lib/atomic-file.js +62 -4
  32. package/lib/vendor/blamejs/lib/audit-chain.js +47 -11
  33. package/lib/vendor/blamejs/lib/audit-sign.js +77 -2
  34. package/lib/vendor/blamejs/lib/audit-tools.js +79 -51
  35. package/lib/vendor/blamejs/lib/audit.js +259 -123
  36. package/lib/vendor/blamejs/lib/auth/oauth.js +53 -9
  37. package/lib/vendor/blamejs/lib/auth/openid-federation.js +108 -47
  38. package/lib/vendor/blamejs/lib/auth/saml.js +6 -8
  39. package/lib/vendor/blamejs/lib/auth/sd-jwt-vc.js +31 -5
  40. package/lib/vendor/blamejs/lib/backup/index.js +45 -10
  41. package/lib/vendor/blamejs/lib/break-glass.js +355 -147
  42. package/lib/vendor/blamejs/lib/cache.js +174 -105
  43. package/lib/vendor/blamejs/lib/chain-writer.js +38 -16
  44. package/lib/vendor/blamejs/lib/cli.js +19 -14
  45. package/lib/vendor/blamejs/lib/cluster-provider-db.js +130 -104
  46. package/lib/vendor/blamejs/lib/cluster-storage.js +119 -22
  47. package/lib/vendor/blamejs/lib/cluster.js +119 -71
  48. package/lib/vendor/blamejs/lib/codepoint-class.js +23 -0
  49. package/lib/vendor/blamejs/lib/compliance.js +206 -4
  50. package/lib/vendor/blamejs/lib/consent.js +82 -29
  51. package/lib/vendor/blamejs/lib/constants.js +27 -11
  52. package/lib/vendor/blamejs/lib/crypto-field.js +916 -156
  53. package/lib/vendor/blamejs/lib/db-declare-row-policy.js +35 -22
  54. package/lib/vendor/blamejs/lib/db-file-lifecycle.js +3 -2
  55. package/lib/vendor/blamejs/lib/db-query.js +882 -260
  56. package/lib/vendor/blamejs/lib/db-schema.js +228 -44
  57. package/lib/vendor/blamejs/lib/db.js +249 -99
  58. package/lib/vendor/blamejs/lib/dsr.js +385 -55
  59. package/lib/vendor/blamejs/lib/error-page.js +14 -1
  60. package/lib/vendor/blamejs/lib/external-db-migrate.js +239 -137
  61. package/lib/vendor/blamejs/lib/external-db.js +549 -34
  62. package/lib/vendor/blamejs/lib/file-upload.js +52 -7
  63. package/lib/vendor/blamejs/lib/framework-error.js +20 -1
  64. package/lib/vendor/blamejs/lib/framework-files.js +73 -0
  65. package/lib/vendor/blamejs/lib/framework-schema.js +695 -394
  66. package/lib/vendor/blamejs/lib/gate-contract.js +659 -1
  67. package/lib/vendor/blamejs/lib/guard-agent-registry.js +26 -44
  68. package/lib/vendor/blamejs/lib/guard-all.js +1 -0
  69. package/lib/vendor/blamejs/lib/guard-auth.js +42 -112
  70. package/lib/vendor/blamejs/lib/guard-cidr.js +33 -154
  71. package/lib/vendor/blamejs/lib/guard-csv.js +46 -113
  72. package/lib/vendor/blamejs/lib/guard-domain.js +34 -157
  73. package/lib/vendor/blamejs/lib/guard-dsn.js +27 -43
  74. package/lib/vendor/blamejs/lib/guard-email.js +47 -69
  75. package/lib/vendor/blamejs/lib/guard-envelope.js +19 -32
  76. package/lib/vendor/blamejs/lib/guard-event-bus-payload.js +24 -42
  77. package/lib/vendor/blamejs/lib/guard-event-bus-topic.js +25 -43
  78. package/lib/vendor/blamejs/lib/guard-filename.js +42 -106
  79. package/lib/vendor/blamejs/lib/guard-graphql.js +42 -123
  80. package/lib/vendor/blamejs/lib/guard-html.js +53 -108
  81. package/lib/vendor/blamejs/lib/guard-idempotency-key.js +24 -42
  82. package/lib/vendor/blamejs/lib/guard-image.js +46 -103
  83. package/lib/vendor/blamejs/lib/guard-imap-command.js +18 -32
  84. package/lib/vendor/blamejs/lib/guard-jmap.js +16 -30
  85. package/lib/vendor/blamejs/lib/guard-json.js +38 -108
  86. package/lib/vendor/blamejs/lib/guard-jsonpath.js +38 -171
  87. package/lib/vendor/blamejs/lib/guard-jwt.js +49 -179
  88. package/lib/vendor/blamejs/lib/guard-list-id.js +25 -41
  89. package/lib/vendor/blamejs/lib/guard-list-unsubscribe.js +27 -43
  90. package/lib/vendor/blamejs/lib/guard-mail-compose.js +24 -42
  91. package/lib/vendor/blamejs/lib/guard-mail-move.js +26 -44
  92. package/lib/vendor/blamejs/lib/guard-mail-query.js +28 -46
  93. package/lib/vendor/blamejs/lib/guard-mail-reply.js +24 -42
  94. package/lib/vendor/blamejs/lib/guard-mail-sieve.js +24 -42
  95. package/lib/vendor/blamejs/lib/guard-managesieve-command.js +17 -31
  96. package/lib/vendor/blamejs/lib/guard-markdown.js +37 -104
  97. package/lib/vendor/blamejs/lib/guard-message-id.js +26 -45
  98. package/lib/vendor/blamejs/lib/guard-mime.js +39 -151
  99. package/lib/vendor/blamejs/lib/guard-oauth.js +54 -135
  100. package/lib/vendor/blamejs/lib/guard-pdf.js +45 -101
  101. package/lib/vendor/blamejs/lib/guard-pop3-command.js +21 -31
  102. package/lib/vendor/blamejs/lib/guard-posture-chain.js +24 -42
  103. package/lib/vendor/blamejs/lib/guard-regex.js +33 -107
  104. package/lib/vendor/blamejs/lib/guard-saga-config.js +24 -42
  105. package/lib/vendor/blamejs/lib/guard-shell.js +42 -172
  106. package/lib/vendor/blamejs/lib/guard-smtp-command.js +48 -54
  107. package/lib/vendor/blamejs/lib/guard-snapshot-envelope.js +24 -42
  108. package/lib/vendor/blamejs/lib/guard-sql.js +1491 -0
  109. package/lib/vendor/blamejs/lib/guard-stream-args.js +24 -43
  110. package/lib/vendor/blamejs/lib/guard-svg.js +47 -65
  111. package/lib/vendor/blamejs/lib/guard-template.js +35 -172
  112. package/lib/vendor/blamejs/lib/guard-tenant-id.js +26 -45
  113. package/lib/vendor/blamejs/lib/guard-time.js +32 -154
  114. package/lib/vendor/blamejs/lib/guard-trace-context.js +25 -44
  115. package/lib/vendor/blamejs/lib/guard-uuid.js +32 -153
  116. package/lib/vendor/blamejs/lib/guard-xml.js +38 -113
  117. package/lib/vendor/blamejs/lib/guard-yaml.js +51 -163
  118. package/lib/vendor/blamejs/lib/http-client.js +37 -9
  119. package/lib/vendor/blamejs/lib/inbox.js +120 -107
  120. package/lib/vendor/blamejs/lib/legal-hold.js +121 -50
  121. package/lib/vendor/blamejs/lib/log-stream-cloudwatch.js +47 -31
  122. package/lib/vendor/blamejs/lib/log-stream-otlp.js +32 -18
  123. package/lib/vendor/blamejs/lib/mail-auth.js +236 -0
  124. package/lib/vendor/blamejs/lib/mail-crypto-smime.js +2 -6
  125. package/lib/vendor/blamejs/lib/mail-dkim.js +1 -0
  126. package/lib/vendor/blamejs/lib/mail-greylist.js +2 -6
  127. package/lib/vendor/blamejs/lib/mail-helo.js +2 -6
  128. package/lib/vendor/blamejs/lib/mail-journal.js +85 -64
  129. package/lib/vendor/blamejs/lib/mail-rbl.js +2 -6
  130. package/lib/vendor/blamejs/lib/mail-scan.js +2 -6
  131. package/lib/vendor/blamejs/lib/mail-server-jmap.js +117 -12
  132. package/lib/vendor/blamejs/lib/mail-server-mx.js +276 -7
  133. package/lib/vendor/blamejs/lib/mail-spam-score.js +2 -6
  134. package/lib/vendor/blamejs/lib/mail-store.js +293 -154
  135. package/lib/vendor/blamejs/lib/mail.js +8 -4
  136. package/lib/vendor/blamejs/lib/middleware/body-parser.js +71 -25
  137. package/lib/vendor/blamejs/lib/middleware/csrf-protect.js +19 -8
  138. package/lib/vendor/blamejs/lib/middleware/dpop.js +10 -1
  139. package/lib/vendor/blamejs/lib/middleware/fetch-metadata.js +17 -7
  140. package/lib/vendor/blamejs/lib/middleware/idempotency-key.js +75 -51
  141. package/lib/vendor/blamejs/lib/middleware/rate-limit.js +102 -32
  142. package/lib/vendor/blamejs/lib/middleware/security-headers.js +21 -5
  143. package/lib/vendor/blamejs/lib/migrations.js +108 -66
  144. package/lib/vendor/blamejs/lib/network-heartbeat.js +7 -0
  145. package/lib/vendor/blamejs/lib/network-proxy.js +24 -1
  146. package/lib/vendor/blamejs/lib/nonce-store.js +31 -9
  147. package/lib/vendor/blamejs/lib/object-store/azure-blob-bucket-ops.js +9 -4
  148. package/lib/vendor/blamejs/lib/object-store/azure-blob.js +57 -3
  149. package/lib/vendor/blamejs/lib/object-store/gcs.js +4 -1
  150. package/lib/vendor/blamejs/lib/object-store/sigv4-bucket-ops.js +5 -2
  151. package/lib/vendor/blamejs/lib/object-store/sigv4.js +38 -6
  152. package/lib/vendor/blamejs/lib/observability-otlp-exporter.js +9 -1
  153. package/lib/vendor/blamejs/lib/observability.js +124 -0
  154. package/lib/vendor/blamejs/lib/otel-export.js +12 -3
  155. package/lib/vendor/blamejs/lib/outbox.js +184 -83
  156. package/lib/vendor/blamejs/lib/parsers/safe-xml.js +47 -7
  157. package/lib/vendor/blamejs/lib/pqc-agent.js +44 -0
  158. package/lib/vendor/blamejs/lib/pubsub-cluster.js +42 -20
  159. package/lib/vendor/blamejs/lib/queue-local.js +225 -140
  160. package/lib/vendor/blamejs/lib/queue-redis.js +9 -1
  161. package/lib/vendor/blamejs/lib/queue-sqs.js +6 -0
  162. package/lib/vendor/blamejs/lib/queue.js +7 -0
  163. package/lib/vendor/blamejs/lib/redact.js +68 -11
  164. package/lib/vendor/blamejs/lib/redis-client.js +160 -31
  165. package/lib/vendor/blamejs/lib/request-helpers.js +7 -0
  166. package/lib/vendor/blamejs/lib/retention.js +101 -40
  167. package/lib/vendor/blamejs/lib/router.js +212 -5
  168. package/lib/vendor/blamejs/lib/safe-dns.js +29 -45
  169. package/lib/vendor/blamejs/lib/safe-ical.js +18 -33
  170. package/lib/vendor/blamejs/lib/safe-icap.js +27 -43
  171. package/lib/vendor/blamejs/lib/safe-sieve.js +21 -40
  172. package/lib/vendor/blamejs/lib/safe-sql.js +212 -3
  173. package/lib/vendor/blamejs/lib/safe-url.js +170 -3
  174. package/lib/vendor/blamejs/lib/safe-vcard.js +18 -33
  175. package/lib/vendor/blamejs/lib/scheduler.js +35 -12
  176. package/lib/vendor/blamejs/lib/seeders.js +122 -74
  177. package/lib/vendor/blamejs/lib/session-stores.js +42 -14
  178. package/lib/vendor/blamejs/lib/session.js +175 -77
  179. package/lib/vendor/blamejs/lib/sql.js +3842 -0
  180. package/lib/vendor/blamejs/lib/sse.js +26 -0
  181. package/lib/vendor/blamejs/lib/ssrf-guard.js +151 -4
  182. package/lib/vendor/blamejs/lib/static.js +177 -34
  183. package/lib/vendor/blamejs/lib/subject.js +96 -49
  184. package/lib/vendor/blamejs/lib/vault/index.js +3 -2
  185. package/lib/vendor/blamejs/lib/vault/passphrase-ops.js +3 -2
  186. package/lib/vendor/blamejs/lib/vault/rotate.js +168 -108
  187. package/lib/vendor/blamejs/lib/vault-aad.js +6 -0
  188. package/lib/vendor/blamejs/lib/vendor-data.js +2 -0
  189. package/lib/vendor/blamejs/lib/websocket.js +35 -5
  190. package/lib/vendor/blamejs/lib/worker-pool.js +11 -0
  191. package/lib/vendor/blamejs/package.json +2 -2
  192. package/lib/vendor/blamejs/release-notes/v0.14.x.json +1503 -0
  193. package/lib/vendor/blamejs/release-notes/v0.15.0.json +77 -0
  194. package/lib/vendor/blamejs/release-notes/v0.15.1.json +22 -0
  195. package/lib/vendor/blamejs/release-notes/v0.15.2.json +22 -0
  196. package/lib/vendor/blamejs/release-notes/v0.15.3.json +39 -0
  197. package/lib/vendor/blamejs/release-notes/v0.15.4.json +39 -0
  198. package/lib/vendor/blamejs/release-notes/v0.15.5.json +22 -0
  199. package/lib/vendor/blamejs/release-notes/v0.15.6.json +59 -0
  200. package/lib/vendor/blamejs/scripts/check-services.js +21 -0
  201. package/lib/vendor/blamejs/scripts/gen-migrating.js +51 -0
  202. package/lib/vendor/blamejs/scripts/release.js +398 -38
  203. package/lib/vendor/blamejs/test/00-primitives.js +117 -0
  204. package/lib/vendor/blamejs/test/10-state.js +140 -14
  205. package/lib/vendor/blamejs/test/20-db.js +65 -2
  206. package/lib/vendor/blamejs/test/helpers/db.js +9 -0
  207. package/lib/vendor/blamejs/test/helpers/drivers.js +27 -15
  208. package/lib/vendor/blamejs/test/helpers/services.js +21 -0
  209. package/lib/vendor/blamejs/test/integration/audit-actor-binding-pg.test.js +246 -0
  210. package/lib/vendor/blamejs/test/integration/audit-chain-external-db.test.js +517 -0
  211. package/lib/vendor/blamejs/test/integration/audit-stack-mysql.test.js +639 -0
  212. package/lib/vendor/blamejs/test/integration/audit-stack-postgres.test.js +832 -0
  213. package/lib/vendor/blamejs/test/integration/backup-restore-objectstore.test.js +453 -0
  214. package/lib/vendor/blamejs/test/integration/data-layer-cluster-mysql.test.js +649 -0
  215. package/lib/vendor/blamejs/test/integration/data-layer-cluster-pg.test.js +770 -0
  216. package/lib/vendor/blamejs/test/integration/data-layer-mysql-privacy.test.js +630 -0
  217. package/lib/vendor/blamejs/test/integration/data-layer-mysql.test.js +610 -0
  218. package/lib/vendor/blamejs/test/integration/data-layer-pg.test.js +577 -0
  219. package/lib/vendor/blamejs/test/integration/data-layer-postgres.test.js +771 -0
  220. package/lib/vendor/blamejs/test/integration/db-layer-mysql.test.js +549 -0
  221. package/lib/vendor/blamejs/test/integration/db-layer-postgres.test.js +598 -0
  222. package/lib/vendor/blamejs/test/integration/distributed-scheduler-fencing-pg.test.js +602 -0
  223. package/lib/vendor/blamejs/test/integration/external-db-postgres.test.js +576 -0
  224. package/lib/vendor/blamejs/test/integration/framework-schema-mysql.test.js +353 -0
  225. package/lib/vendor/blamejs/test/integration/log-stream-cloudwatch.test.js +224 -0
  226. package/lib/vendor/blamejs/test/integration/mail-crypto-smime.test.js +142 -17
  227. package/lib/vendor/blamejs/test/integration/network-heartbeat.test.js +25 -10
  228. package/lib/vendor/blamejs/test/integration/object-store-azure.test.js +101 -0
  229. package/lib/vendor/blamejs/test/integration/object-store-gcs.test.js +239 -0
  230. package/lib/vendor/blamejs/test/integration/object-store-sigv4.test.js +35 -16
  231. package/lib/vendor/blamejs/test/integration/object-store-worm-lock.test.js +291 -0
  232. package/lib/vendor/blamejs/test/integration/pubsub.test.js +14 -0
  233. package/lib/vendor/blamejs/test/integration/queue-sqs.test.js +322 -0
  234. package/lib/vendor/blamejs/test/integration/redis-reconnect-toxiproxy.test.js +300 -0
  235. package/lib/vendor/blamejs/test/integration/sql-fts5-catalog-sqlite.test.js +154 -0
  236. package/lib/vendor/blamejs/test/integration/tls-classical-downgrade-audit.test.js +71 -0
  237. package/lib/vendor/blamejs/test/layer-0-primitives/agent-event-bus.test.js +175 -12
  238. package/lib/vendor/blamejs/test/layer-0-primitives/atomic-file-exclusive-temp.test.js +216 -0
  239. package/lib/vendor/blamejs/test/layer-0-primitives/audit-checkpoint-false-rollback.test.js +203 -0
  240. package/lib/vendor/blamejs/test/layer-0-primitives/audit-query-self-log.test.js +126 -0
  241. package/lib/vendor/blamejs/test/layer-0-primitives/audit-safeemit-redacts-secrets.test.js +196 -0
  242. package/lib/vendor/blamejs/test/layer-0-primitives/audit-signing-key-rotation.test.js +197 -0
  243. package/lib/vendor/blamejs/test/layer-0-primitives/audit-verifybundle-tamper.test.js +209 -0
  244. package/lib/vendor/blamejs/test/layer-0-primitives/azure-blob-key-encoding.test.js +121 -0
  245. package/lib/vendor/blamejs/test/layer-0-primitives/backup-residency-posture.test.js +168 -0
  246. package/lib/vendor/blamejs/test/layer-0-primitives/backup-scheduletest-drill.test.js +318 -0
  247. package/lib/vendor/blamejs/test/layer-0-primitives/break-glass.test.js +233 -7
  248. package/lib/vendor/blamejs/test/layer-0-primitives/codebase-patterns.test.js +1120 -14
  249. package/lib/vendor/blamejs/test/layer-0-primitives/compliance.test.js +229 -0
  250. package/lib/vendor/blamejs/test/layer-0-primitives/crypto-field-derived-hash.test.js +24 -7
  251. package/lib/vendor/blamejs/test/layer-0-primitives/crypto-field-dual-read-migrate.test.js +165 -0
  252. package/lib/vendor/blamejs/test/layer-0-primitives/crypto-field-per-row-key.test.js +350 -0
  253. package/lib/vendor/blamejs/test/layer-0-primitives/crypto-field-unseal-rate-cap.test.js +27 -9
  254. package/lib/vendor/blamejs/test/layer-0-primitives/crypto-field-upgrade-dialect.test.js +76 -0
  255. package/lib/vendor/blamejs/test/layer-0-primitives/crypto-interop-oracles.test.js +392 -0
  256. package/lib/vendor/blamejs/test/layer-0-primitives/csrf-protect.test.js +159 -0
  257. package/lib/vendor/blamejs/test/layer-0-primitives/db-column-gate.test.js +180 -1
  258. package/lib/vendor/blamejs/test/layer-0-primitives/db-query-cross-schema.test.js +5 -2
  259. package/lib/vendor/blamejs/test/layer-0-primitives/db-query-sealed-field-in.test.js +101 -0
  260. package/lib/vendor/blamejs/test/layer-0-primitives/db-raw-residency-gate.test.js +128 -0
  261. package/lib/vendor/blamejs/test/layer-0-primitives/db-schema-drift.test.js +38 -5
  262. package/lib/vendor/blamejs/test/layer-0-primitives/db-schema-reconcile-emittable.test.js +127 -0
  263. package/lib/vendor/blamejs/test/layer-0-primitives/db-stream-and-payload-shape.test.js +267 -0
  264. package/lib/vendor/blamejs/test/layer-0-primitives/db-worm.test.js +150 -0
  265. package/lib/vendor/blamejs/test/layer-0-primitives/defineguard-default-gate-posture-caps.test.js +30 -0
  266. package/lib/vendor/blamejs/test/layer-0-primitives/dpop-middleware-replaystore-required.test.js +46 -0
  267. package/lib/vendor/blamejs/test/layer-0-primitives/dsr.test.js +218 -0
  268. package/lib/vendor/blamejs/test/layer-0-primitives/erase-posture-vacuum.test.js +210 -0
  269. package/lib/vendor/blamejs/test/layer-0-primitives/external-db-hardening.test.js +4 -1
  270. package/lib/vendor/blamejs/test/layer-0-primitives/external-db-migrate.test.js +48 -2
  271. package/lib/vendor/blamejs/test/layer-0-primitives/federation-vc-suite.test.js +237 -5
  272. package/lib/vendor/blamejs/test/layer-0-primitives/fetch-metadata.test.js +20 -9
  273. package/lib/vendor/blamejs/test/layer-0-primitives/file-upload-content-safety-skip-audit.test.js +193 -0
  274. package/lib/vendor/blamejs/test/layer-0-primitives/guard-csv.test.js +90 -0
  275. package/lib/vendor/blamejs/test/layer-0-primitives/http-client-stream.test.js +85 -0
  276. package/lib/vendor/blamejs/test/layer-0-primitives/idempotency-key.test.js +10 -6
  277. package/lib/vendor/blamejs/test/layer-0-primitives/inbox.test.js +15 -4
  278. package/lib/vendor/blamejs/test/layer-0-primitives/legal-hold.test.js +146 -0
  279. package/lib/vendor/blamejs/test/layer-0-primitives/mail-auth.test.js +189 -0
  280. package/lib/vendor/blamejs/test/layer-0-primitives/mail-journal.test.js +3 -1
  281. package/lib/vendor/blamejs/test/layer-0-primitives/mail-server-jmap.test.js +123 -4
  282. package/lib/vendor/blamejs/test/layer-0-primitives/mail-server-mx.test.js +207 -2
  283. package/lib/vendor/blamejs/test/layer-0-primitives/mail-store.test.js +74 -0
  284. package/lib/vendor/blamejs/test/layer-0-primitives/oauth-callback.test.js +43 -0
  285. package/lib/vendor/blamejs/test/layer-0-primitives/otel-export.test.js +133 -0
  286. package/lib/vendor/blamejs/test/layer-0-primitives/otlp-attr-redaction.test.js +101 -0
  287. package/lib/vendor/blamejs/test/layer-0-primitives/outbox-inflight-reaper.test.js +136 -0
  288. package/lib/vendor/blamejs/test/layer-0-primitives/parsers-standalone.test.js +83 -0
  289. package/lib/vendor/blamejs/test/layer-0-primitives/passkey-real-vectors.test.js +429 -0
  290. package/lib/vendor/blamejs/test/layer-0-primitives/pqc-agent-curve.test.js +21 -11
  291. package/lib/vendor/blamejs/test/layer-0-primitives/queue-byo-db.test.js +40 -0
  292. package/lib/vendor/blamejs/test/layer-0-primitives/redact-dlp.test.js +83 -0
  293. package/lib/vendor/blamejs/test/layer-0-primitives/redis-client.test.js +113 -0
  294. package/lib/vendor/blamejs/test/layer-0-primitives/retention-dryrun-no-vacuum.test.js +99 -0
  295. package/lib/vendor/blamejs/test/layer-0-primitives/router-use-path-scope.test.js +255 -0
  296. package/lib/vendor/blamejs/test/layer-0-primitives/safe-url-canonicalize.test.js +309 -0
  297. package/lib/vendor/blamejs/test/layer-0-primitives/safe-xml.test.js +143 -0
  298. package/lib/vendor/blamejs/test/layer-0-primitives/saml-subjectconfirmation-notonorafter.test.js +287 -0
  299. package/lib/vendor/blamejs/test/layer-0-primitives/sd-jwt-vc-ecdsa-p1363.test.js +79 -0
  300. package/lib/vendor/blamejs/test/layer-0-primitives/sd-jwt-vc.test.js +50 -0
  301. package/lib/vendor/blamejs/test/layer-0-primitives/security-headers.test.js +31 -4
  302. package/lib/vendor/blamejs/test/layer-0-primitives/session-extensions.test.js +45 -0
  303. package/lib/vendor/blamejs/test/layer-0-primitives/sigv4-bucket-ops.test.js +49 -0
  304. package/lib/vendor/blamejs/test/layer-0-primitives/sql.test.js +595 -0
  305. package/lib/vendor/blamejs/test/layer-0-primitives/sse-backpressure.test.js +91 -0
  306. package/lib/vendor/blamejs/test/layer-0-primitives/ssrf-guard.test.js +69 -0
  307. package/lib/vendor/blamejs/test/layer-0-primitives/static.test.js +194 -2
  308. package/lib/vendor/blamejs/test/layer-0-primitives/websocket-extension-header.test.js +88 -0
  309. package/lib/vendor/blamejs/test/layer-0-primitives/worker-pool-recycle-race.test.js +66 -0
  310. package/lib/vendor/blamejs/test/layer-1-state/api-key.test.js +84 -0
  311. package/lib/vendor/blamejs/test/layer-5-integration/external-db-residency.test.js +638 -0
  312. package/lib/vendor/blamejs/test/layer-5-integration/guard-host-integration.test.js +21 -0
  313. package/lib/vendor/blamejs/test/smoke.js +79 -21
  314. package/package.json +1 -1
  315. package/lib/vendor/blamejs/release-notes/v0.14.0.json +0 -43
  316. package/lib/vendor/blamejs/release-notes/v0.14.1.json +0 -60
  317. package/lib/vendor/blamejs/release-notes/v0.14.10.json +0 -54
  318. package/lib/vendor/blamejs/release-notes/v0.14.11.json +0 -72
  319. package/lib/vendor/blamejs/release-notes/v0.14.12.json +0 -95
  320. package/lib/vendor/blamejs/release-notes/v0.14.13.json +0 -52
  321. package/lib/vendor/blamejs/release-notes/v0.14.14.json +0 -31
  322. package/lib/vendor/blamejs/release-notes/v0.14.16.json +0 -45
  323. package/lib/vendor/blamejs/release-notes/v0.14.17.json +0 -57
  324. package/lib/vendor/blamejs/release-notes/v0.14.18.json +0 -127
  325. package/lib/vendor/blamejs/release-notes/v0.14.19.json +0 -61
  326. package/lib/vendor/blamejs/release-notes/v0.14.2.json +0 -18
  327. package/lib/vendor/blamejs/release-notes/v0.14.20.json +0 -73
  328. package/lib/vendor/blamejs/release-notes/v0.14.21.json +0 -98
  329. package/lib/vendor/blamejs/release-notes/v0.14.22.json +0 -91
  330. package/lib/vendor/blamejs/release-notes/v0.14.3.json +0 -18
  331. package/lib/vendor/blamejs/release-notes/v0.14.4.json +0 -18
  332. package/lib/vendor/blamejs/release-notes/v0.14.5.json +0 -18
  333. package/lib/vendor/blamejs/release-notes/v0.14.6.json +0 -60
  334. package/lib/vendor/blamejs/release-notes/v0.14.7.json +0 -77
  335. package/lib/vendor/blamejs/release-notes/v0.14.8.json +0 -27
  336. package/lib/vendor/blamejs/release-notes/v0.14.9.json +0 -40
@@ -50,10 +50,16 @@ var bCrypto = require("./crypto");
50
50
  var lazyRequire = require("./lazy-require");
51
51
  var safeAsync = require("./safe-async");
52
52
  var validateOpts = require("./validate-opts");
53
- var { GateContractError } = require("./framework-error");
53
+ var { GateContractError, defineClass } = require("./framework-error");
54
54
 
55
55
  var observability = lazyRequire(function () { return require("./observability"); });
56
56
  var compliance = lazyRequire(function () { return require("./compliance"); });
57
+ var audit = lazyRequire(function () { return require("./audit"); });
58
+
59
+ // One-time dedupe for the "global posture pinned but this guard maps no
60
+ // overlay" warning. Keyed `<posture>::<errCodePrefix>` so each guard
61
+ // family surfaces the gap once instead of on every gate construction.
62
+ var _unmappedPostureWarned = Object.create(null);
57
63
 
58
64
  // Forensic-id token width (bytes); 64 bits is enough for cross-gate
59
65
  // correlation in a single request scope.
@@ -1096,6 +1102,153 @@ function lookupCompliancePosture(name, postures, errorFactory, codePrefix) {
1096
1102
  return Object.assign({}, postures[name]);
1097
1103
  }
1098
1104
 
1105
+ // "GuardCidrError" -> "guardCidr" — the guard's audit/message identity, derived
1106
+ // once from its error class name. Used for the default gate's audit/metric
1107
+ // prefix AND the profile resolver's error message, so neither re-cases the name.
1108
+ function _guardLabelFromError(ErrorClass) {
1109
+ var n = String(ErrorClass.name).replace(/Error$/, "");
1110
+ return n.charAt(0).toLowerCase() + n.slice(1);
1111
+ }
1112
+
1113
+ /**
1114
+ * @primitive b.gateContract.makeProfileResolver
1115
+ * @signature b.gateContract.makeProfileResolver(cfg)
1116
+ * @since 0.15.0
1117
+ * @status stable
1118
+ * @related b.gateContract.makeProfileBuilder, b.gateContract.lookupCompliancePosture
1119
+ *
1120
+ * Closes over a guard's profile config and returns a `resolveProfile(opts)`
1121
+ * function: maps `opts.posture` through the compliance-posture table, else
1122
+ * falls back to `opts.profile || cfg.defaults`, validates the name against
1123
+ * `cfg.profiles`, and throws `cfg.errorClass.factory(cfg.codePrefix +
1124
+ * "/bad-profile")` on an unknown name. The sibling of `makeProfileBuilder` /
1125
+ * `makeRulePackLoader` / `lookupCompliancePosture` for the resolution step —
1126
+ * every `defineParser`-shaped line-protocol / mail / agent guard reuses it
1127
+ * instead of re-declaring an identical `_resolveProfile`.
1128
+ *
1129
+ * @opts
1130
+ * profiles: object, // the guard's PROFILES map; required
1131
+ * postures: object, // COMPLIANCE_POSTURES (posture -> profile name)
1132
+ * defaults: string, // fallback profile name when no posture/profile given
1133
+ * errorClass: function, // the guard's FrameworkError subclass
1134
+ * codePrefix: string, // error-code namespace (e.g. "mail-compose")
1135
+ * byObject: boolean, // true -> return the profile config object, not its name
1136
+ *
1137
+ * @example
1138
+ * var resolveProfile = b.gateContract.makeProfileResolver({
1139
+ * profiles: PROFILES, postures: COMPLIANCE_POSTURES,
1140
+ * defaults: "strict", errorClass: GuardMailComposeError,
1141
+ * codePrefix: "mail-compose",
1142
+ * });
1143
+ * resolveProfile({ posture: "hipaa" }); // → "strict"
1144
+ */
1145
+ function makeProfileResolver(cfg) {
1146
+ var profiles = cfg.profiles;
1147
+ var postures = cfg.postures;
1148
+ var dft = cfg.defaults;
1149
+ var ErrorClass = cfg.errorClass;
1150
+ var codePrefix = cfg.codePrefix;
1151
+ var byObject = cfg.byObject === true;
1152
+ var label = _guardLabelFromError(ErrorClass);
1153
+ return function resolveProfile(opts) {
1154
+ opts = opts || {};
1155
+ if (opts.posture && postures && postures[opts.posture]) {
1156
+ var pn = postures[opts.posture];
1157
+ return byObject ? profiles[pn] : pn;
1158
+ }
1159
+ var p = opts.profile || dft;
1160
+ if (!profiles[p]) {
1161
+ throw ErrorClass.factory(codePrefix + "/bad-profile",
1162
+ label + ": unknown profile '" + p + "' (use " +
1163
+ Object.keys(profiles).join(" / ") + ")");
1164
+ }
1165
+ return byObject ? profiles[p] : p;
1166
+ };
1167
+ }
1168
+
1169
+ /**
1170
+ * @primitive b.gateContract.throwOnRefusalSeverity
1171
+ * @signature b.gateContract.throwOnRefusalSeverity(issues, cfg)
1172
+ * @since 0.15.0
1173
+ * @status stable
1174
+ * @related b.gateContract.aggregateIssues, b.gateContract.makeProfileResolver
1175
+ *
1176
+ * Throw on the first critical/high-severity issue in a detector's issue
1177
+ * list — the refusal step every guard `sanitize` runs after detection
1178
+ * (sanitize can serve a clean value but never repair a critical/high
1179
+ * finding). Builds the guard's error via `cfg.errorClass.factory` with code
1180
+ * `issue.ruleId || (cfg.codePrefix + ".refused")` and message
1181
+ * `guard<Name>.<op>: <issue.snippet>` (op default `"sanitize"`; the guard
1182
+ * identity derives from the error class name). The throw sibling of
1183
+ * `aggregateIssues` (which returns `{ ok, issues }` instead of throwing) —
1184
+ * replaces the per-guard hand-rolled severity-gating loop.
1185
+ *
1186
+ * @opts
1187
+ * errorClass: function, // the guard's FrameworkError subclass; required
1188
+ * codePrefix: string, // error-code namespace; the `.refused` fallback code
1189
+ * op: string, // operation name in the message (default "sanitize")
1190
+ * severities: string[], // refusal severities (default ["critical","high"])
1191
+ *
1192
+ * @example
1193
+ * var issues = detect(input, opts);
1194
+ * b.gateContract.throwOnRefusalSeverity(issues, {
1195
+ * errorClass: GuardCidrError, codePrefix: "cidr",
1196
+ * });
1197
+ * // throws GuardCidrError(ruleId || "cidr.refused", "guardCidr.sanitize: " + snippet)
1198
+ * // on the first critical/high issue
1199
+ */
1200
+ function throwOnRefusalSeverity(issues, cfg) {
1201
+ var errFactory = cfg.errorClass.factory;
1202
+ var prefix = _guardLabelFromError(cfg.errorClass) + "." + (cfg.op || "sanitize");
1203
+ var fallback = cfg.codePrefix + ".refused";
1204
+ // Default refuses critical + high; cfg.severities narrows it (e.g.
1205
+ // ["critical"] for guards that strip high-severity findings but refuse
1206
+ // only unrepairable critical shapes — email / markdown / xml / yaml).
1207
+ var severities = cfg.severities || ["critical", "high"];
1208
+ for (var i = 0; i < issues.length; i += 1) {
1209
+ var iss = issues[i];
1210
+ if (severities.indexOf(iss.severity) !== -1) {
1211
+ throw errFactory(iss.ruleId || fallback, prefix + ": " + iss.snippet);
1212
+ }
1213
+ }
1214
+ }
1215
+
1216
+ /**
1217
+ * @primitive b.gateContract.ALL_STRICT_POSTURES
1218
+ * @signature b.gateContract.ALL_STRICT_POSTURES
1219
+ * @since 0.15.0
1220
+ * @status stable
1221
+ * @compliance hipaa, pci-dss, gdpr, soc2
1222
+ * @related b.gateContract.lookupCompliancePosture, b.gateContract.makeProfileBuilder
1223
+ *
1224
+ * Canonical strict-all `COMPLIANCE_POSTURES` map every command/parser
1225
+ * guard composes. Maps each of the four baseline regulatory postures —
1226
+ * `hipaa` / `pci-dss` / `gdpr` / `soc2` — onto the guard's `strict`
1227
+ * profile name. Guards whose four postures all resolve to `strict`
1228
+ * (the command/protocol validators: POP3 / IMAP / SMTP / ManageSieve
1229
+ * commands, mail-compose / query / sieve / move / reply, the envelope
1230
+ * and event-bus shapes, the mail pipeline scorers, and the
1231
+ * `safe-*` line-protocol parsers) reference this single frozen object
1232
+ * instead of re-declaring it. Guards that overlay per-posture
1233
+ * byte-limits or redaction flags (the content guards: CSV / HTML /
1234
+ * JSON / XML / YAML / JWT / OAuth / template, etc.) keep their own
1235
+ * posture map and do not compose this.
1236
+ *
1237
+ * Frozen once and shared by reference: every consumer reads it through
1238
+ * its own `COMPLIANCE_POSTURES` binding and never mutates it.
1239
+ *
1240
+ * @example
1241
+ * var COMPLIANCE_POSTURES = b.gateContract.ALL_STRICT_POSTURES;
1242
+ * COMPLIANCE_POSTURES.hipaa; // → "strict"
1243
+ * Object.isFrozen(COMPLIANCE_POSTURES); // → true
1244
+ */
1245
+ var ALL_STRICT_POSTURES = Object.freeze({
1246
+ hipaa: "strict",
1247
+ "pci-dss": "strict",
1248
+ gdpr: "strict",
1249
+ soc2: "strict",
1250
+ });
1251
+
1099
1252
  /**
1100
1253
  * @primitive b.gateContract.makeRulePackLoader
1101
1254
  * @signature b.gateContract.makeRulePackLoader(errorClass, codePrefix)
@@ -1415,6 +1568,16 @@ function resolveProfileAndPosture(opts, cfg) {
1415
1568
  if (typeof globalPosture === "string" &&
1416
1569
  cfg.compliancePostures && cfg.compliancePostures[globalPosture]) {
1417
1570
  posture = globalPosture;
1571
+ } else if (typeof globalPosture === "string" && globalPosture.length > 0) {
1572
+ // A global posture IS pinned, but this guard family ships no
1573
+ // COMPLIANCE_POSTURES overlay for it (e.g. fedramp-rev5-moderate
1574
+ // against a guard whose table only covers hipaa/pci-dss/gdpr/soc2).
1575
+ // Falling through to the unposture-d default is the SAFE behavior,
1576
+ // but operators must know the posture is a no-op for THIS guard —
1577
+ // silently no-oping reads as "enforced" (compliance theater).
1578
+ // Emit a one-time, grep-able audit warning per (posture, guard)
1579
+ // and keep the safe default.
1580
+ _warnUnmappedPosture(globalPosture, prefix);
1418
1581
  }
1419
1582
  }
1420
1583
  if (typeof posture === "string") {
@@ -1427,6 +1590,42 @@ function resolveProfileAndPosture(opts, cfg) {
1427
1590
  return Object.assign({}, cfg.defaults || {}, overlay, opts);
1428
1591
  }
1429
1592
 
1593
+ // _warnUnmappedPosture — emit a one-time, grep-able audit warning that a
1594
+ // globally-pinned posture has no overlay in THIS guard family's
1595
+ // COMPLIANCE_POSTURES table, so the operator doesn't read the
1596
+ // safe-default fall-through as "the posture is enforced here." Drop-
1597
+ // silent (hot-path observability sink): a warning emit must never throw
1598
+ // past the guard-gate construction that triggered it.
1599
+ function _warnUnmappedPosture(posture, prefix) {
1600
+ var dedupeKey = posture + "::" + (prefix || "guard");
1601
+ if (_unmappedPostureWarned[dedupeKey]) return;
1602
+ _unmappedPostureWarned[dedupeKey] = true;
1603
+ try {
1604
+ // Canonical audit outcome triple is success/failure/denied; a
1605
+ // posture that maps no overlay is an advisory NOTICE, not a failure
1606
+ // of this construction — the severity rides in metadata.severity so
1607
+ // the audit row carries the warning intent without abusing outcome.
1608
+ audit().safeEmit({
1609
+ action: "gateContract.posture.unmapped",
1610
+ outcome: "success",
1611
+ metadata: {
1612
+ severity: "warning",
1613
+ posture: posture,
1614
+ guard: prefix || "guard",
1615
+ recommendation: "The pinned compliance posture '" + posture +
1616
+ "' has no overlay in this guard's COMPLIANCE_POSTURES table, so " +
1617
+ "its gate runs the unposture-d default. Pass an explicit " +
1618
+ "compliancePosture this guard maps, or add the overlay, if the " +
1619
+ "posture is meant to tighten this surface.",
1620
+ },
1621
+ });
1622
+ } catch (_e) { /* drop-silent — warning must not break gate construction */ }
1623
+ }
1624
+
1625
+ function _resetForTest() {
1626
+ for (var k in _unmappedPostureWarned) delete _unmappedPostureWarned[k];
1627
+ }
1628
+
1430
1629
  /**
1431
1630
  * @primitive b.gateContract.buildProfile
1432
1631
  * @signature b.gateContract.buildProfile(opts)
@@ -1628,8 +1827,463 @@ function composeHooks(hooks) {
1628
1827
  };
1629
1828
  }
1630
1829
 
1830
+ // ---- Guard-module factories ----
1831
+ //
1832
+ // Every b.guard* primitive of the gate-bearing kinds (content / filename
1833
+ // / identifier) hand-wires the SAME export surface: an error class, a
1834
+ // resolveProfileAndPosture-backed _resolveOpts, a buildGuardGate-backed
1835
+ // gate, a makeProfileBuilder-backed buildProfile, a
1836
+ // lookupCompliancePosture-backed compliancePosture, a makeRulePackLoader-
1837
+ // backed loadRulePack, and a frozen module.exports carrying the
1838
+ // guard-* registry fields (NAME / KIND / MIME_TYPES / EXTENSIONS /
1839
+ // PROFILES / DEFAULTS / COMPLIANCE_POSTURES / INTEGRATION_FIXTURES) plus
1840
+ // the per-guard inspection surface (validate / sanitize / gate). They
1841
+ // differ only in the per-guard inspection LOGIC + the PROFILES /
1842
+ // COMPLIANCE_POSTURES / DEFAULTS tables. `defineGuard` assembles the
1843
+ // boilerplate; the spec injects the logic and the tables.
1844
+ //
1845
+ // `defineParser` is the sibling for the minimal command / line-protocol
1846
+ // / safe-* parser shape — the guards whose four postures all resolve to
1847
+ // `strict` (ALL_STRICT_POSTURES) and whose surface is a self-contained
1848
+ // `validate` / `parse` plus a `compliancePosture(name)` that returns the
1849
+ // effective PROFILE NAME (or null) rather than an overlay clone. Those
1850
+ // guards carry no gate / buildProfile / loadRulePack, so forcing them
1851
+ // through `defineGuard` would be a leaky abstraction.
1852
+
1853
+ // _KIND_CTX_FIELDS — per-KIND ordered list of ctx field names a
1854
+ // buildGuardGate-backed default gate reads, mirroring the hand-written
1855
+ // gate bodies: filename reads ctx.filename || ctx.name, identifier reads
1856
+ // ctx.identifier || ctx.token || ctx.jwt, command reads ctx.line ||
1857
+ // ctx.command. content has no entry — it falls through to
1858
+ // extractBytesAsText (the ctx.bytes string/Buffer normalizer).
1859
+ var _KIND_CTX_FIELDS = Object.freeze({
1860
+ filename: ["filename", "name"],
1861
+ identifier: ["identifier", "token", "jwt"],
1862
+ command: ["line", "command"],
1863
+ });
1864
+
1865
+ // override (when given) replaces the per-KIND field table — lets a guard whose
1866
+ // gate is the standard chain but reads a custom ctx field take the default gate.
1867
+ function _ctxValueForKind(kind, ctx, override) {
1868
+ ctx = ctx || {};
1869
+ var fields = override || _KIND_CTX_FIELDS[kind];
1870
+ if (!fields) return extractBytesAsText(ctx); // content (default)
1871
+ for (var i = 0; i < fields.length; i += 1) {
1872
+ if (ctx[fields[i]]) return ctx[fields[i]];
1873
+ }
1874
+ return "";
1875
+ }
1876
+
1877
+ /**
1878
+ * @primitive b.gateContract.defineGuard
1879
+ * @signature b.gateContract.defineGuard(spec)
1880
+ * @since 0.15.0
1881
+ * @status stable
1882
+ * @related b.gateContract.defineParser, b.gateContract.buildGuardGate, b.gateContract.resolveProfileAndPosture
1883
+ *
1884
+ * Assemble a complete `b.guard*` module from a spec. Mints the per-guard
1885
+ * error class (via `framework-error.defineClass`, or accepts a supplied
1886
+ * `errorClass`), wires `resolveProfileAndPosture` / `buildGuardGate` /
1887
+ * `makeProfileBuilder` / `lookupCompliancePosture` / `makeRulePackLoader`,
1888
+ * and returns the frozen module.exports object every guard ships —
1889
+ * `NAME` / `KIND` / `PROFILES` / `DEFAULTS` / `COMPLIANCE_POSTURES` /
1890
+ * `INTEGRATION_FIXTURES` / `validate` / `sanitize?` / `gate?` /
1891
+ * `buildProfile` / `compliancePosture` / `loadRulePack` plus the spec's
1892
+ * `extra` exports (verb tables, `escapeCell`, `schema`, `kidSafe`, …) and
1893
+ * the error class under its own name.
1894
+ *
1895
+ * The per-guard inspection logic is INJECTED, not abstracted: `validate`
1896
+ * / `sanitize` / `gate` are spec functions that close over the resolved
1897
+ * opts. A guard whose `gate` body is the standard
1898
+ * serve→audit-only→sanitize→refuse chain can omit `spec.gate` and take
1899
+ * the factory default (built from `spec.validate` + `spec.sanitize` per
1900
+ * KIND); a guard with a bespoke gate (CSV's sanitize-reparse-reserialize,
1901
+ * filename's per-policy canSanitize matrix) passes its own. Behavior is
1902
+ * preserved byte-for-byte because the genuinely-divergent code stays
1903
+ * verbatim in the spec — the factory only removes the wiring every guard
1904
+ * copies.
1905
+ *
1906
+ * @opts
1907
+ * name: string, // NAME (e.g. "csv"); required
1908
+ * kind: string, // "content"|"filename"|"identifier"|"command" for the default gate; any non-empty label with a bespoke spec.gate; required
1909
+ * errCodePrefix: string, // error-code namespace (default name)
1910
+ * errorName: string, // defineClass name (mutually exclusive with errorClass)
1911
+ * errorClass: function, // pre-built FrameworkError subclass
1912
+ * profiles: object, // PROFILES (must include strict/balanced/permissive); required
1913
+ * defaults: object, // DEFAULTS baseline (default profiles.strict)
1914
+ * postures: object, // COMPLIANCE_POSTURES (default ALL_STRICT_POSTURES)
1915
+ * mimeTypes: string[], // content guards only
1916
+ * extensions: string[], // content guards only
1917
+ * integrationFixtures: object, // INTEGRATION_FIXTURES (consumed by host harness)
1918
+ * validate: function, // (input, resolvedOpts) -> { ok, issues }; required
1919
+ * sanitize: function, // (input, resolvedOpts) -> cleaned (optional)
1920
+ * gate: function, // (resolvedOpts) -> async (ctx) -> decision (optional; default built per kind)
1921
+ * ctxFields: string[], // ordered ctx field names the default gate reads (overrides the per-KIND table; e.g. ["identifier","cidr"])
1922
+ * defaultGateCheck: function, // override the default gate's per-ctx check
1923
+ * extra: object, // additional exports merged verbatim into module.exports
1924
+ *
1925
+ * @example
1926
+ * module.exports = b.gateContract.defineGuard({
1927
+ * name: "csv", kind: "content", errorClass: GuardCsvError,
1928
+ * profiles: PROFILES, defaults: DEFAULTS, postures: COMPLIANCE_POSTURES,
1929
+ * mimeTypes: ["text/csv"], extensions: [".csv"],
1930
+ * integrationFixtures: INTEGRATION_FIXTURES,
1931
+ * validate: validate, sanitize: sanitize, gate: gate,
1932
+ * extra: { serialize: serialize, escapeCell: escapeCell, schema: schema },
1933
+ * });
1934
+ */
1935
+ function defineGuard(spec) {
1936
+ validateOpts.requireObject(spec, "gateContract.defineGuard", GateContractError);
1937
+ validateOpts.requireNonEmptyString(spec.name, "gateContract.defineGuard: name",
1938
+ GateContractError, "gate-contract/bad-opt");
1939
+ validateOpts.requireNonEmptyString(spec.kind, "gateContract.defineGuard: kind",
1940
+ GateContractError, "gate-contract/bad-opt");
1941
+ // The four known kinds drive the default gate's ctx-field dispatch
1942
+ // (_ctxValueForKind). A guard with a bespoke spec.gate reads its own ctx
1943
+ // fields, so any non-empty kind is allowed there — the kind is then just
1944
+ // the KIND export label (e.g. "oauth-flow" / "graphql-request" / "sql" /
1945
+ // "metadata"). A custom kind WITHOUT a bespoke gate is refused, because
1946
+ // the default gate could not dispatch it to the right ctx field.
1947
+ if (["content", "filename", "identifier", "command"].indexOf(spec.kind) === -1 &&
1948
+ typeof spec.gate !== "function") {
1949
+ throw _err("gate-contract/bad-opt",
1950
+ "defineGuard: kind must be content|filename|identifier|command for the " +
1951
+ "default gate, got " + JSON.stringify(spec.kind) +
1952
+ " — pass spec.gate for a custom kind (the bespoke gate reads its own ctx fields)");
1953
+ }
1954
+ validateOpts.requireObject(spec.profiles, "gateContract.defineGuard: profiles",
1955
+ GateContractError);
1956
+ if (typeof spec.validate !== "function") {
1957
+ throw _err("gate-contract/bad-opt", "defineGuard: validate must be a function");
1958
+ }
1959
+ if (spec.errorClass && spec.errorName) {
1960
+ throw _err("gate-contract/bad-opt",
1961
+ "defineGuard: pass errorClass OR errorName, not both");
1962
+ }
1963
+
1964
+ var prefix = spec.errCodePrefix || spec.name;
1965
+ var ErrorClass = spec.errorClass ||
1966
+ defineClass(spec.errorName || ("Guard" +
1967
+ spec.name.charAt(0).toUpperCase() + spec.name.slice(1) + "Error"),
1968
+ { alwaysPermanent: true });
1969
+ var profiles = spec.profiles;
1970
+ var defaults = spec.defaults || profiles.strict || {};
1971
+ var postures = spec.postures || ALL_STRICT_POSTURES;
1972
+
1973
+ var buildProfileFn = makeProfileBuilder(profiles);
1974
+ function compliancePostureFn(name) {
1975
+ return lookupCompliancePosture(name, postures, ErrorClass.factory, prefix);
1976
+ }
1977
+ var rulePacks = makeRulePackLoader(ErrorClass, prefix);
1978
+
1979
+ // spec.ctxFields (ordered field names) overrides the per-KIND table that
1980
+ // the default gate's _ctxValueForKind reads — lets a guard whose gate is the
1981
+ // standard chain but reads a custom ctx field (e.g. ctx.cidr) drop its
1982
+ // bespoke gate and take the default. null -> _ctxValueForKind uses the
1983
+ // per-KIND table.
1984
+ var ctxFields = Array.isArray(spec.ctxFields) ? spec.ctxFields.slice() : null;
1985
+ // Gate identity is surfaced in audit events / metric counters / cache keys.
1986
+ // Preserve the "guard<Name>:profile" naming the hand-written gates used so
1987
+ // moving a guard onto the default gate does not rename its audit/metric
1988
+ // stream (e.g. "guardCidr:strict"), via the shared error-name derivation.
1989
+ var gateNamePrefix = _guardLabelFromError(ErrorClass);
1990
+
1991
+ // Default gate — the standard serve→audit-only→refuse chain, dispatched
1992
+ // to the right ctx field by KIND (or spec.ctxFields). Guards with a bespoke
1993
+ // gate pass spec.gate; guards whose gate is the standard chain take this
1994
+ // default.
1995
+ // Resolve the profile + posture BEFORE buildGuardGate reads its runtime /
1996
+ // forensic caps: forensicSnippetBytes lives on the posture and maxRuntimeMs
1997
+ // on the profile, NOT on the raw caller opts. Passing raw opts through dropped
1998
+ // a regulated posture's forensic cap to 0 (no forensic snapshot on a refusal)
1999
+ // and the profile's runtime cap to uncapped — the hand-written gates resolve
2000
+ // in their own gate(), and the default gate must match. resolveProfileAndPosture
2001
+ // is idempotent over an already-resolved opts, so spec.validate's internal
2002
+ // resolution stays correct.
2003
+ function defaultGate(rawOpts) {
2004
+ var opts = resolveProfileAndPosture(rawOpts || {}, {
2005
+ profiles: profiles,
2006
+ compliancePostures: postures,
2007
+ defaults: defaults,
2008
+ errorClass: ErrorClass,
2009
+ errCodePrefix: prefix,
2010
+ });
2011
+ var perCtx = spec.defaultGateCheck || function (ctx) {
2012
+ var value = _ctxValueForKind(spec.kind, ctx, ctxFields);
2013
+ if (!value) return { ok: true, action: "serve" };
2014
+ var rv = spec.validate(value, opts);
2015
+ if (!rv.issues || rv.issues.length === 0) return { ok: true, action: "serve" };
2016
+ var hasBlocking = rv.issues.some(function (i) {
2017
+ return i.severity === "critical" || i.severity === "high";
2018
+ });
2019
+ if (!hasBlocking) return { ok: true, action: "audit-only", issues: rv.issues };
2020
+ return { ok: false, action: "refuse", issues: rv.issues };
2021
+ };
2022
+ return buildGuardGate(
2023
+ opts.name || (gateNamePrefix + ":" + (opts.profile || "default")),
2024
+ opts,
2025
+ async function (ctx) { return perCtx(ctx, opts); });
2026
+ }
2027
+
2028
+ var gateFn = spec.gate || defaultGate;
2029
+
2030
+ var out = {
2031
+ NAME: spec.name,
2032
+ KIND: spec.kind,
2033
+ validate: spec.validate,
2034
+ buildProfile: buildProfileFn,
2035
+ compliancePosture: compliancePostureFn,
2036
+ loadRulePack: rulePacks.load,
2037
+ PROFILES: profiles,
2038
+ DEFAULTS: defaults,
2039
+ COMPLIANCE_POSTURES: postures,
2040
+ };
2041
+ if (spec.kind === "content") {
2042
+ out.MIME_TYPES = Object.freeze((spec.mimeTypes || []).slice());
2043
+ out.EXTENSIONS = Object.freeze((spec.extensions || []).slice());
2044
+ }
2045
+ if (spec.integrationFixtures) out.INTEGRATION_FIXTURES = spec.integrationFixtures;
2046
+ if (typeof spec.sanitize === "function") out.sanitize = spec.sanitize;
2047
+ out.gate = gateFn;
2048
+ // Error class exported under its own constructor name (GuardCsvError etc.)
2049
+ out[ErrorClass.name] = ErrorClass;
2050
+ // Per-guard extras (verb tables, escapeCell, schema, kidSafe, …) merged
2051
+ // verbatim via the prototype-safe own-enumerable copy (no computed-name
2052
+ // write; __proto__/constructor/prototype are skipped). Extras win over
2053
+ // factory defaults only when the guard explicitly re-exports a shared
2054
+ // name (rare; documented per guard).
2055
+ if (spec.extra) validateOpts.assignOwnEnumerable(out, spec.extra);
2056
+ return out;
2057
+ }
2058
+
2059
+ /**
2060
+ * @primitive b.gateContract.defineParser
2061
+ * @signature b.gateContract.defineParser(spec)
2062
+ * @since 0.15.0
2063
+ * @status stable
2064
+ * @related b.gateContract.defineGuard, b.gateContract.ALL_STRICT_POSTURES
2065
+ *
2066
+ * Assemble the minimal command / line-protocol / `safe-*` parser module
2067
+ * shape — guards whose four compliance postures all resolve to `strict`
2068
+ * (composing `ALL_STRICT_POSTURES`) and whose surface is a single
2069
+ * self-contained `validate` / `parse` entry point plus a
2070
+ * `compliancePosture(name)` that returns the effective PROFILE NAME (or
2071
+ * `null` for unknown names) rather than an overlay clone. These guards
2072
+ * carry no `gate` / `buildProfile` / `loadRulePack`, so `defineGuard`'s
2073
+ * full assembly would be wrong for them.
2074
+ *
2075
+ * Mints the error class (or accepts one), exposes the spec's primary
2076
+ * entry point under `spec.entryName` (default `"validate"`), and returns
2077
+ * the frozen module.exports with `PROFILES` / `COMPLIANCE_POSTURES` /
2078
+ * `compliancePosture` plus the spec's `extra` exports and the error
2079
+ * class.
2080
+ *
2081
+ * @opts
2082
+ * name: string, // module identity / error-name stem; required
2083
+ * entry: function, // the validate/parse entry point; required
2084
+ * entryName: string, // export key for the entry (default "validate")
2085
+ * profiles: object, // PROFILES; required
2086
+ * postures: object, // COMPLIANCE_POSTURES (default ALL_STRICT_POSTURES)
2087
+ * errorClass: function, // pre-built FrameworkError subclass
2088
+ * errorName: string, // defineClass name (mutually exclusive with errorClass)
2089
+ * extra: object, // additional exports (verb tables, KNOWN_*, …)
2090
+ *
2091
+ * @example
2092
+ * module.exports = b.gateContract.defineParser({
2093
+ * name: "pop3-command", entry: validate,
2094
+ * errorClass: GuardPop3CommandError,
2095
+ * profiles: PROFILES, postures: COMPLIANCE_POSTURES,
2096
+ * extra: { KNOWN_VERBS: KNOWN_VERBS, ZERO_ARG_VERBS: ZERO_ARG_VERBS },
2097
+ * });
2098
+ */
2099
+ function defineParser(spec) {
2100
+ validateOpts.requireObject(spec, "gateContract.defineParser", GateContractError);
2101
+ validateOpts.requireNonEmptyString(spec.name, "gateContract.defineParser: name",
2102
+ GateContractError, "gate-contract/bad-opt");
2103
+ if (typeof spec.entry !== "function") {
2104
+ throw _err("gate-contract/bad-opt", "defineParser: entry must be a function");
2105
+ }
2106
+ validateOpts.requireObject(spec.profiles, "gateContract.defineParser: profiles",
2107
+ GateContractError);
2108
+ if (spec.errorClass && spec.errorName) {
2109
+ throw _err("gate-contract/bad-opt",
2110
+ "defineParser: pass errorClass OR errorName, not both");
2111
+ }
2112
+ var ErrorClass = spec.errorClass ||
2113
+ defineClass(spec.errorName || ("Guard" +
2114
+ spec.name.charAt(0).toUpperCase() + spec.name.slice(1) + "Error"),
2115
+ { alwaysPermanent: true });
2116
+ var postures = spec.postures || ALL_STRICT_POSTURES;
2117
+
2118
+ function compliancePostureFn(name) {
2119
+ return postures[name] || null;
2120
+ }
2121
+
2122
+ var out = {
2123
+ compliancePosture: compliancePostureFn,
2124
+ PROFILES: spec.profiles,
2125
+ COMPLIANCE_POSTURES: postures,
2126
+ };
2127
+ out[spec.entryName || "validate"] = spec.entry;
2128
+ out[ErrorClass.name] = ErrorClass;
2129
+ if (spec.extra) validateOpts.assignOwnEnumerable(out, spec.extra);
2130
+ return out;
2131
+ }
2132
+
2133
+ // ---- ABI doc templates (single-sourced; rendered per guard) ----
2134
+ //
2135
+ // Every guard built through `defineGuard` / `defineParser` exposes the
2136
+ // SAME factory-generated ABI methods (`compliancePosture` and, for
2137
+ // `defineGuard`, `buildProfile` / `loadRulePack` / a default `gate`).
2138
+ // Those methods have no per-guard `function` declaration — the factory
2139
+ // wires them — so a refactored guard that wants its wiki page to keep
2140
+ // listing them used to carry a floating `@primitive` block per method,
2141
+ // duplicating the same prose across every member of the family.
2142
+ //
2143
+ // The `@abiTemplate` blocks below are the ONE copy of that prose. The
2144
+ // wiki parser (`examples/wiki/lib/source-doc-parser.js`) collects them
2145
+ // into a per-factory template bucket (keyed `defineGuard` / `defineParser`)
2146
+ // instead of the gateContract primitive list, and the page generator
2147
+ // (`examples/wiki/lib/page-generator.js`) instantiates them per guard —
2148
+ // substituting `{NS}` (the guard namespace, e.g. `guardCsv`) and `{ERR}`
2149
+ // (its error class, e.g. `GuardCsvError`) and filling `@since` from the
2150
+ // guard's own `@module` / first-primitive metadata — so each guard's page
2151
+ // renders every ABI method with usage correct for THAT guard. The
2152
+ // duplicated prose collapses to a single source; the rendered surface is
2153
+ // unchanged. A guard that keeps a bespoke per-method block (a custom
2154
+ // `gate`, or a guard that documents its own `compliancePosture`) wins —
2155
+ // the page generator skips the template for any method already present.
2156
+ //
2157
+ // These blocks intentionally carry the placeholder primitive form
2158
+ // `b.{NS}.<method>` and placeholder-bearing `@example` bodies; the
2159
+ // validator routes them through its template-shape pass, not the
2160
+ // resolvable-primitive pass.
2161
+
2162
+ /**
2163
+ * @abiTemplate defineGuard
2164
+ * @method compliancePosture
2165
+ * @signature b.{NS}.compliancePosture(name)
2166
+ * @status stable
2167
+ * @compliance hipaa, pci-dss, gdpr, soc2
2168
+ * @related b.{NS}.gate, b.{NS}.buildProfile
2169
+ *
2170
+ * Look up a compliance-posture overlay by name (one of `"hipaa"` /
2171
+ * `"pci-dss"` / `"gdpr"` / `"soc2"`). Returns a fresh clone of the
2172
+ * posture overlay so the caller may mutate it freely without disturbing
2173
+ * the shared table. Throws `{ERR}` with code `"{CODE}.bad-posture"` when
2174
+ * the name is not one this guard maps. Wired by `gateContract.defineGuard`
2175
+ * through `gateContract.lookupCompliancePosture`, so the clone semantics
2176
+ * and error code are identical across every guard in the family.
2177
+ *
2178
+ * @example
2179
+ * var posture = b.{NS}.compliancePosture("hipaa");
2180
+ * posture; // → overlay clone (mutable)
2181
+ *
2182
+ * try {
2183
+ * b.{NS}.compliancePosture("not-a-regime");
2184
+ * } catch (e) {
2185
+ * e.code; // → "{CODE}.bad-posture"
2186
+ * }
2187
+ */
2188
+
2189
+ /**
2190
+ * @abiTemplate defineGuard
2191
+ * @method buildProfile
2192
+ * @signature b.{NS}.buildProfile(opts)
2193
+ * @status stable
2194
+ * @related b.{NS}.gate, b.{NS}.compliancePosture
2195
+ *
2196
+ * Compose a derived profile from one or more named bases plus inline
2197
+ * overrides, resolving names through this guard's own `PROFILES` table.
2198
+ * `opts.extends` is a base profile name (`"strict"` / `"balanced"` /
2199
+ * `"permissive"`) or an array of names — later entries shadow earlier
2200
+ * ones, and inline `opts` keys win last. Wired by
2201
+ * `gateContract.defineGuard` through `gateContract.makeProfileBuilder`,
2202
+ * so operator-defined profiles stay traceable to a baseline instead of a
2203
+ * hand-typed dictionary.
2204
+ *
2205
+ * @opts
2206
+ * extends: string|string[], // base profile name(s) to compose
2207
+ * ...: any guard key, // inline override of resolved keys
2208
+ *
2209
+ * @example
2210
+ * var custom = b.{NS}.buildProfile({ extends: "strict" });
2211
+ * custom; // → composed profile object
2212
+ */
2213
+
2214
+ /**
2215
+ * @abiTemplate defineGuard
2216
+ * @method loadRulePack
2217
+ * @signature b.{NS}.loadRulePack(pack)
2218
+ * @status stable
2219
+ * @related b.{NS}.gate
2220
+ *
2221
+ * Register an operator-supplied rule pack with this guard's rule-pack
2222
+ * registry. The pack is identified by `pack.id` (a non-empty string) and
2223
+ * stored for later dispatch by gates that opt in via `opts.rulePackId`.
2224
+ * Returns the pack unchanged on success; throws `{ERR}` with code
2225
+ * `"{CODE}.bad-opt"` when `pack` is missing or `pack.id` is not a non-empty
2226
+ * string. Wired by `gateContract.defineGuard` through
2227
+ * `gateContract.makeRulePackLoader`, so storage shape and validation are
2228
+ * identical across the family.
2229
+ *
2230
+ * @example
2231
+ * var pack = b.{NS}.loadRulePack({ id: "tenant-policy", rules: [] });
2232
+ * pack.id; // → "tenant-policy"
2233
+ */
2234
+
2235
+ /**
2236
+ * @abiTemplate defineGuard
2237
+ * @method gate
2238
+ * @signature b.{NS}.gate(opts?)
2239
+ * @status stable
2240
+ * @related b.{NS}.validate, b.gateContract.buildGuardGate
2241
+ *
2242
+ * Build the guard's request-boundary gate — a contract-shaped object
2243
+ * exposing `check(ctx)` that host primitives call at their byte moment.
2244
+ * This is the factory default chain: `serve` when no issue, `audit-only`
2245
+ * for `info` / `warn` issues, and `refuse` for any `high` / `critical`
2246
+ * issue, dispatched to the right `ctx` field by the guard's KIND. Wired
2247
+ * by `gateContract.defineGuard` through `gateContract.buildGuardGate`; a
2248
+ * guard whose gate diverges (a bespoke sanitize-and-reserialize chain,
2249
+ * for example) ships its own `gate` block instead of this template.
2250
+ *
2251
+ * @opts
2252
+ * profile: string, // one of PROFILES; default this guard's default
2253
+ * compliancePosture: string, // overlay one of hipaa/pci-dss/gdpr/soc2
2254
+ * mode: string, // one of gateContract MODES; default "enforce"
2255
+ *
2256
+ * @example
2257
+ * var gate = b.{NS}.gate({ profile: "strict" });
2258
+ * var decision = await gate.check({ bytes: Buffer.from("...") });
2259
+ * decision.action; // → "serve" | "refuse" | …
2260
+ */
2261
+
2262
+ /**
2263
+ * @abiTemplate defineParser
2264
+ * @method compliancePosture
2265
+ * @signature b.{NS}.compliancePosture(name)
2266
+ * @status stable
2267
+ * @compliance hipaa, pci-dss, gdpr, soc2
2268
+ * @related b.{NS}.validate, b.gateContract.ALL_STRICT_POSTURES
2269
+ *
2270
+ * Return the effective profile NAME for a compliance posture, or `null`
2271
+ * for a name this parser does not map. Unlike the content-guard variant
2272
+ * this returns the resolved profile string (every line-protocol parser
2273
+ * composes `gateContract.ALL_STRICT_POSTURES`, so `"hipaa"` / `"pci-dss"`
2274
+ * / `"gdpr"` / `"soc2"` all resolve to `"strict"`) and never throws —
2275
+ * the parser shape carries no overlay-clone, no `buildProfile`, and no
2276
+ * `loadRulePack`. Wired by `gateContract.defineParser`.
2277
+ *
2278
+ * @example
2279
+ * b.{NS}.compliancePosture("hipaa"); // → "strict"
2280
+ * b.{NS}.compliancePosture("not-a-regime"); // → null
2281
+ */
2282
+
1631
2283
  module.exports = {
1632
2284
  defineGate: defineGate,
2285
+ defineGuard: defineGuard,
2286
+ defineParser: defineParser,
1633
2287
  validateGateShape: validateGateShape,
1634
2288
  runGate: runGate,
1635
2289
  composeGates: composeGates,
@@ -1648,8 +2302,11 @@ module.exports = {
1648
2302
  buildGuardGate: buildGuardGate,
1649
2303
  extractBytesAsText: extractBytesAsText,
1650
2304
  lookupCompliancePosture: lookupCompliancePosture,
2305
+ ALL_STRICT_POSTURES: ALL_STRICT_POSTURES,
1651
2306
  makeRulePackLoader: makeRulePackLoader,
1652
2307
  makeProfileBuilder: makeProfileBuilder,
2308
+ makeProfileResolver: makeProfileResolver,
2309
+ throwOnRefusalSeverity: throwOnRefusalSeverity,
1653
2310
  badInputResultIfNotStringOrBuffer: badInputResultIfNotStringOrBuffer,
1654
2311
  aggregateIssues: aggregateIssues,
1655
2312
  composeHooks: composeHooks,
@@ -1658,4 +2315,5 @@ module.exports = {
1658
2315
  MODES: MODES,
1659
2316
  ISSUE_SEVERITIES: ISSUE_SEVERITIES,
1660
2317
  GateContractError: GateContractError,
2318
+ _resetForTest: _resetForTest,
1661
2319
  };