@blamejs/core 0.8.42 → 0.8.49
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 +93 -0
- package/README.md +10 -10
- package/index.js +52 -0
- package/lib/a2a.js +159 -34
- package/lib/acme.js +762 -0
- package/lib/ai-pref.js +166 -43
- package/lib/api-key.js +108 -47
- package/lib/api-snapshot.js +157 -40
- package/lib/app-shutdown.js +113 -77
- package/lib/archive.js +337 -40
- package/lib/arg-parser.js +697 -0
- package/lib/asyncapi.js +99 -55
- package/lib/atomic-file.js +465 -104
- package/lib/audit-chain.js +123 -34
- package/lib/audit-daily-review.js +389 -0
- package/lib/audit-sign.js +302 -56
- package/lib/audit-tools.js +412 -63
- package/lib/audit.js +656 -35
- package/lib/auth/jwt-external.js +17 -0
- package/lib/auth/oauth.js +7 -0
- package/lib/auth-bot-challenge.js +505 -0
- package/lib/auth-header.js +92 -25
- package/lib/backup/bundle.js +26 -0
- package/lib/backup/index.js +512 -89
- package/lib/backup/manifest.js +168 -7
- package/lib/break-glass.js +415 -39
- package/lib/budr.js +103 -30
- package/lib/bundler.js +86 -66
- package/lib/cache.js +192 -72
- package/lib/chain-writer.js +65 -40
- package/lib/circuit-breaker.js +56 -33
- package/lib/cli-helpers.js +106 -75
- package/lib/cli.js +6 -30
- package/lib/cloud-events.js +99 -32
- package/lib/cluster-storage.js +162 -37
- package/lib/cluster.js +340 -49
- package/lib/codepoint-class.js +66 -0
- package/lib/compliance.js +424 -24
- package/lib/config-drift.js +111 -46
- package/lib/config.js +94 -40
- package/lib/consent.js +165 -18
- package/lib/constants.js +1 -0
- package/lib/content-credentials.js +153 -48
- package/lib/cookies.js +154 -62
- package/lib/credential-hash.js +133 -61
- package/lib/crypto-field.js +702 -18
- package/lib/crypto-hpke.js +256 -0
- package/lib/crypto.js +744 -22
- package/lib/csv.js +178 -35
- package/lib/daemon.js +456 -0
- package/lib/dark-patterns.js +186 -55
- package/lib/db-query.js +79 -2
- package/lib/db.js +1431 -60
- package/lib/ddl-change-control.js +523 -0
- package/lib/deprecate.js +195 -40
- package/lib/dev.js +82 -39
- package/lib/dora.js +67 -48
- package/lib/dr-runbook.js +368 -0
- package/lib/dsr.js +142 -11
- package/lib/dual-control.js +91 -56
- package/lib/events.js +120 -41
- package/lib/external-db-migrate.js +192 -2
- package/lib/external-db.js +795 -50
- package/lib/fapi2.js +122 -1
- package/lib/fda-21cfr11.js +395 -0
- package/lib/fdx.js +132 -2
- package/lib/file-type.js +87 -0
- package/lib/file-upload.js +93 -0
- package/lib/flag.js +82 -20
- package/lib/forms.js +132 -29
- package/lib/framework-error.js +169 -0
- package/lib/framework-schema.js +163 -35
- package/lib/gate-contract.js +849 -175
- package/lib/graphql-federation.js +68 -7
- package/lib/guard-all.js +172 -55
- package/lib/guard-archive.js +286 -124
- package/lib/guard-auth.js +194 -21
- package/lib/guard-cidr.js +190 -28
- package/lib/guard-csv.js +397 -51
- package/lib/guard-domain.js +213 -91
- package/lib/guard-email.js +236 -29
- package/lib/guard-filename.js +307 -75
- package/lib/guard-graphql.js +263 -30
- package/lib/guard-html.js +310 -116
- package/lib/guard-image.js +243 -30
- package/lib/guard-json.js +260 -54
- package/lib/guard-jsonpath.js +235 -23
- package/lib/guard-jwt.js +284 -30
- package/lib/guard-markdown.js +204 -22
- package/lib/guard-mime.js +190 -26
- package/lib/guard-oauth.js +277 -28
- package/lib/guard-pdf.js +251 -27
- package/lib/guard-regex.js +226 -18
- package/lib/guard-shell.js +229 -26
- package/lib/guard-svg.js +177 -10
- package/lib/guard-template.js +232 -21
- package/lib/guard-time.js +195 -29
- package/lib/guard-uuid.js +189 -30
- package/lib/guard-xml.js +259 -36
- package/lib/guard-yaml.js +241 -44
- package/lib/honeytoken.js +63 -27
- package/lib/html-balance.js +83 -0
- package/lib/http-client.js +486 -59
- package/lib/http-message-signature.js +582 -0
- package/lib/i18n.js +102 -49
- package/lib/iab-mspa.js +112 -32
- package/lib/iab-tcf.js +107 -2
- package/lib/inbox.js +90 -52
- package/lib/keychain.js +865 -0
- package/lib/legal-hold.js +374 -0
- package/lib/local-db-thin.js +320 -0
- package/lib/log-stream.js +281 -51
- package/lib/log.js +184 -86
- package/lib/mail-bounce.js +107 -62
- package/lib/mail.js +295 -58
- package/lib/mcp.js +108 -27
- package/lib/metrics.js +98 -89
- package/lib/middleware/age-gate.js +36 -0
- package/lib/middleware/ai-act-disclosure.js +37 -0
- package/lib/middleware/api-encrypt.js +45 -0
- package/lib/middleware/assetlinks.js +40 -0
- package/lib/middleware/asyncapi-serve.js +35 -0
- package/lib/middleware/attach-user.js +40 -0
- package/lib/middleware/bearer-auth.js +40 -0
- package/lib/middleware/body-parser.js +230 -0
- package/lib/middleware/bot-disclose.js +34 -0
- package/lib/middleware/bot-guard.js +39 -0
- package/lib/middleware/compression.js +37 -0
- package/lib/middleware/cookies.js +32 -0
- package/lib/middleware/cors.js +40 -0
- package/lib/middleware/csp-nonce.js +40 -0
- package/lib/middleware/csp-report.js +34 -0
- package/lib/middleware/csrf-protect.js +43 -0
- package/lib/middleware/daily-byte-quota.js +53 -85
- package/lib/middleware/db-role-for.js +40 -0
- package/lib/middleware/dpop.js +40 -0
- package/lib/middleware/error-handler.js +37 -14
- package/lib/middleware/fetch-metadata.js +39 -0
- package/lib/middleware/flag-context.js +34 -0
- package/lib/middleware/gpc.js +33 -0
- package/lib/middleware/headers.js +35 -0
- package/lib/middleware/health.js +46 -0
- package/lib/middleware/host-allowlist.js +30 -0
- package/lib/middleware/network-allowlist.js +38 -0
- package/lib/middleware/openapi-serve.js +34 -0
- package/lib/middleware/rate-limit.js +160 -18
- package/lib/middleware/request-id.js +36 -18
- package/lib/middleware/request-log.js +37 -0
- package/lib/middleware/require-aal.js +29 -0
- package/lib/middleware/require-auth.js +32 -0
- package/lib/middleware/require-bound-key.js +41 -0
- package/lib/middleware/require-content-type.js +32 -0
- package/lib/middleware/require-methods.js +27 -0
- package/lib/middleware/require-mtls.js +33 -0
- package/lib/middleware/require-step-up.js +37 -0
- package/lib/middleware/security-headers.js +44 -0
- package/lib/middleware/security-txt.js +38 -0
- package/lib/middleware/span-http-server.js +37 -0
- package/lib/middleware/sse.js +36 -0
- package/lib/middleware/trace-log-correlation.js +33 -0
- package/lib/middleware/trace-propagate.js +32 -0
- package/lib/middleware/tus-upload.js +90 -0
- package/lib/middleware/web-app-manifest.js +53 -0
- package/lib/mtls-ca.js +100 -70
- package/lib/network-byte-quota.js +308 -0
- package/lib/network-heartbeat.js +135 -0
- package/lib/network-tls.js +534 -4
- package/lib/network.js +103 -0
- package/lib/notify.js +114 -43
- package/lib/ntp-check.js +192 -51
- package/lib/observability.js +145 -47
- package/lib/openapi.js +90 -44
- package/lib/outbox.js +99 -1
- package/lib/pagination.js +168 -86
- package/lib/parsers/index.js +16 -5
- package/lib/permissions.js +93 -40
- package/lib/pqc-agent.js +84 -8
- package/lib/pqc-software.js +94 -60
- package/lib/process-spawn.js +95 -21
- package/lib/pubsub.js +96 -66
- package/lib/queue.js +375 -54
- package/lib/redact.js +793 -21
- package/lib/render.js +139 -47
- package/lib/request-helpers.js +485 -121
- package/lib/restore-bundle.js +142 -39
- package/lib/restore-rollback.js +136 -45
- package/lib/retention.js +178 -50
- package/lib/retry.js +116 -33
- package/lib/router.js +475 -23
- package/lib/safe-async.js +543 -94
- package/lib/safe-buffer.js +337 -41
- package/lib/safe-json.js +467 -62
- package/lib/safe-jsonpath.js +285 -0
- package/lib/safe-schema.js +631 -87
- package/lib/safe-sql.js +221 -59
- package/lib/safe-url.js +278 -46
- package/lib/sandbox-worker.js +135 -0
- package/lib/sandbox.js +358 -0
- package/lib/scheduler.js +135 -70
- package/lib/self-update.js +647 -0
- package/lib/session-device-binding.js +431 -0
- package/lib/session.js +259 -49
- package/lib/slug.js +138 -26
- package/lib/ssrf-guard.js +316 -56
- package/lib/storage.js +433 -70
- package/lib/subject.js +405 -23
- package/lib/template.js +148 -8
- package/lib/tenant-quota.js +545 -0
- package/lib/testing.js +440 -53
- package/lib/time.js +291 -23
- package/lib/tls-exporter.js +239 -0
- package/lib/tracing.js +90 -74
- package/lib/uuid.js +97 -22
- package/lib/vault/index.js +284 -22
- package/lib/vault/seal-pem-file.js +66 -0
- package/lib/watcher.js +368 -0
- package/lib/webhook.js +196 -63
- package/lib/websocket.js +393 -68
- package/lib/wiki-concepts.js +338 -0
- package/lib/worker-pool.js +464 -0
- package/package.json +3 -3
- package/sbom.cyclonedx.json +7 -7
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* @module b.graphqlFederation
|
|
4
|
+
* @nav AI
|
|
5
|
+
* @title GraphQL Federation
|
|
4
6
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
7
|
+
* @intro
|
|
8
|
+
* GraphQL federation gateway with SDL trust boundary, sub-graph
|
|
9
|
+
* health, subgraph SDL signing, query plan caps.
|
|
8
10
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
11
|
+
* Apollo Federation subgraphs expose the schema via the
|
|
12
|
+
* `_service { sdl }` query and `_entities` resolver — independent of
|
|
13
|
+
* the introspection toggle. Operators who disable introspection in
|
|
14
|
+
* production still leak the full SDL through these federation
|
|
15
|
+
* probes. The guard refuses such queries unless they carry a
|
|
16
|
+
* shared-secret router token (timing-safe-compared, 32-char
|
|
17
|
+
* minimum), with optional nonce-store replay protection so a
|
|
18
|
+
* captured router token can't be replayed across requests.
|
|
19
|
+
*
|
|
20
|
+
* @card
|
|
21
|
+
* GraphQL federation gateway with SDL trust boundary, sub-graph health, subgraph SDL signing, query plan caps.
|
|
12
22
|
*/
|
|
13
23
|
|
|
14
24
|
var crypto = require("crypto");
|
|
@@ -27,6 +37,26 @@ var NONCE_MAX_LEN = 256;
|
|
|
27
37
|
var NONCE_PREVIEW_LEN = 8; // allow:raw-byte-literal — log-preview slice length, not bytes
|
|
28
38
|
var SDL_PROBE_RE = /(^|[\s,{])_service\b|_entities\b/;
|
|
29
39
|
|
|
40
|
+
/**
|
|
41
|
+
* @primitive b.graphqlFederation.queryProbesSdl
|
|
42
|
+
* @signature b.graphqlFederation.queryProbesSdl(query)
|
|
43
|
+
* @since 0.7.68
|
|
44
|
+
* @related b.graphqlFederation.guardSdl
|
|
45
|
+
*
|
|
46
|
+
* Cheap textual probe — does the GraphQL query reference `_service`
|
|
47
|
+
* or `_entities`? Returns `true` for anything that matches the
|
|
48
|
+
* federation-SDL detector after a 64 KiB length bound, `false`
|
|
49
|
+
* otherwise. Used by `guardSdl` to skip the auth gate for non-
|
|
50
|
+
* federation queries; operator-callable so a custom middleware can
|
|
51
|
+
* apply the same gate to a non-HTTP transport (queue worker, RPC).
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* b.graphqlFederation.queryProbesSdl("query { _service { sdl } }");
|
|
55
|
+
* // → true
|
|
56
|
+
*
|
|
57
|
+
* b.graphqlFederation.queryProbesSdl("query { user(id: 1) { name } }");
|
|
58
|
+
* // → false
|
|
59
|
+
*/
|
|
30
60
|
function queryProbesSdl(query) {
|
|
31
61
|
if (typeof query !== "string") return false;
|
|
32
62
|
if (query.length > SDL_PROBE_MAX) return false; // length-bound before regex test
|
|
@@ -69,6 +99,37 @@ function _readBody(req, errorClass) {
|
|
|
69
99
|
});
|
|
70
100
|
}
|
|
71
101
|
|
|
102
|
+
/**
|
|
103
|
+
* @primitive b.graphqlFederation.guardSdl
|
|
104
|
+
* @signature b.graphqlFederation.guardSdl(opts)
|
|
105
|
+
* @since 0.7.68
|
|
106
|
+
* @related b.graphqlFederation.queryProbesSdl
|
|
107
|
+
*
|
|
108
|
+
* Build the federation-SDL trust-boundary middleware. Reads the
|
|
109
|
+
* GraphQL query from the JSON body (capped at 1 MiB), passes
|
|
110
|
+
* non-federation queries straight through, and refuses
|
|
111
|
+
* `_service { sdl }` / `_entities` queries with HTTP 401 unless the
|
|
112
|
+
* request carries a `Bearer <routerToken>` (timing-safe compare,
|
|
113
|
+
* 32-char minimum) — or `publicSchemaOk:true` is explicitly set.
|
|
114
|
+
* Optional `nonceStore` keyed off `x-apollographql-router-nonce`
|
|
115
|
+
* blocks replay of a captured token across requests; default TTL is
|
|
116
|
+
* 5 minutes. Returns a `(req, res, next)` middleware function.
|
|
117
|
+
*
|
|
118
|
+
* @opts
|
|
119
|
+
* publicSchemaOk: boolean, // default false — explicit override to publish the SDL
|
|
120
|
+
* routerToken: string, // required unless publicSchemaOk; 32+ chars
|
|
121
|
+
* nonceStore: { has(nonce): bool, remember(nonce, ttlMs) }, // optional — replay protection
|
|
122
|
+
* nonceTtlMs: number, // default 5 minutes
|
|
123
|
+
* errorClass: Function, // default GraphqlFederationError
|
|
124
|
+
* audit: boolean, // default true
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* var guard = b.graphqlFederation.guardSdl({
|
|
128
|
+
* routerToken: "router-shared-secret-thirty-two-chars",
|
|
129
|
+
* });
|
|
130
|
+
* typeof guard;
|
|
131
|
+
* // → "function"
|
|
132
|
+
*/
|
|
72
133
|
function guardSdl(opts) {
|
|
73
134
|
opts = opts || {};
|
|
74
135
|
var errorClass = opts.errorClass || GraphqlFederationError;
|
package/lib/guard-all.js
CHANGED
|
@@ -1,61 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* @module b.guardAll
|
|
4
|
+
* @featured true
|
|
5
|
+
* @nav Guards
|
|
6
|
+
* @title Guard All
|
|
5
7
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* @intro
|
|
9
|
+
* Aggregate gate that dispatches to every registered b.guard* member
|
|
10
|
+
* by KIND. Content guards (csv / html / svg / archive / json / yaml /
|
|
11
|
+
* xml / markdown / email) route by MIME type or file extension;
|
|
12
|
+
* standalone guards (filename / domain / uuid / cidr / time / mime /
|
|
13
|
+
* jwt / oauth / graphql / shell / regex / jsonpath / template /
|
|
14
|
+
* image / pdf / auth) operate on non-content axes and surface via
|
|
15
|
+
* `allGuards()` for the adaptive integration harness.
|
|
10
16
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* // Opt-out is explicit, named, and audited.
|
|
17
|
-
* var safety = b.guardAll.gate({
|
|
18
|
-
* profile: "strict",
|
|
19
|
-
* exceptFor: {
|
|
20
|
-
* html: { reason: "every HTML response is server-rendered + CSP-locked" },
|
|
21
|
-
* pdf: { reason: "no PDF uploads in this app" },
|
|
22
|
-
* },
|
|
23
|
-
* override: {
|
|
24
|
-
* csv: { profile: "email-attachment" },
|
|
25
|
-
* },
|
|
26
|
-
* audit: b.audit,
|
|
27
|
-
* observability: b.observability,
|
|
28
|
-
* });
|
|
29
|
-
*
|
|
30
|
-
* // Drop straight into the existing composition points.
|
|
31
|
-
* b.staticServe.create({
|
|
32
|
-
* contentSafety: b.guardAll.byExtension({ profile: "strict" }),
|
|
33
|
-
* });
|
|
34
|
-
* b.fileUpload.create({
|
|
35
|
-
* contentSafety: b.guardAll.gate({ profile: "strict" }),
|
|
36
|
-
* });
|
|
17
|
+
* The framework thesis applied to content safety: every shipped
|
|
18
|
+
* guard is ON by default; operators opt OUT explicitly with an
|
|
19
|
+
* audited `reason` per guard. New guards added in future slices
|
|
20
|
+
* auto-register through GUARDS / STANDALONE_GUARDS and operators
|
|
21
|
+
* inherit the new coverage without re-wiring.
|
|
37
22
|
*
|
|
38
|
-
*
|
|
39
|
-
* export
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* - COMPLIANCE_POSTURES — object map; must include the SHARED_POSTURES
|
|
46
|
-
* vocabulary (hipaa / pci-dss / gdpr / soc2)
|
|
47
|
-
* - gate(opts) — returns a b.gateContract-shaped gate
|
|
23
|
+
* Registry contract — every primitive registered into guard-all
|
|
24
|
+
* MUST export NAME / MIME_TYPES / EXTENSIONS (content guards only) /
|
|
25
|
+
* PROFILES (must include strict / balanced / permissive) /
|
|
26
|
+
* COMPLIANCE_POSTURES (must include hipaa / pci-dss / gdpr / soc2) /
|
|
27
|
+
* gate(opts). A parity check at module load throws GuardAllError if
|
|
28
|
+
* any member drifts from the contract — that's the registry gate
|
|
29
|
+
* that keeps every future guard slice conformant.
|
|
48
30
|
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
31
|
+
* Per-guard extension profiles (e.g. csv's "email-attachment") are
|
|
32
|
+
* reached via the `override` map; the aggregator's `profile` opt
|
|
33
|
+
* only takes the shared vocabulary so one string applies cleanly
|
|
34
|
+
* across every member.
|
|
52
35
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* NOT accepted by b.guardAll.gate({ profile: ... }) — the aggregator
|
|
56
|
-
* only takes the shared vocabulary so the same string applies cleanly
|
|
57
|
-
* across every member. Operators reach for guard-specific profiles via
|
|
58
|
-
* the override map.
|
|
36
|
+
* @card
|
|
37
|
+
* Aggregate gate that dispatches to every registered b.guard* member by KIND.
|
|
59
38
|
*/
|
|
60
39
|
|
|
61
40
|
var lazyRequire = require("./lazy-require");
|
|
@@ -353,6 +332,53 @@ function _emitCreationAudit(opts, resolved) {
|
|
|
353
332
|
|
|
354
333
|
// ---- Public surface ----
|
|
355
334
|
|
|
335
|
+
/**
|
|
336
|
+
* @primitive b.guardAll.gate
|
|
337
|
+
* @signature b.guardAll.gate(opts)
|
|
338
|
+
* @since 0.7.16
|
|
339
|
+
* @status stable
|
|
340
|
+
* @compliance hipaa, pci-dss, gdpr, soc2
|
|
341
|
+
* @related b.guardAll.byExtension, b.guardAll.byContentType, b.guardAll.list
|
|
342
|
+
*
|
|
343
|
+
* Build a single composite gate that dispatches by `Content-Type` to
|
|
344
|
+
* the active member of every registered content-bytes guard. Active
|
|
345
|
+
* set is the full GUARDS list minus any names listed in `exceptFor`
|
|
346
|
+
* (each requires a non-empty `reason` string — opting a guard out is
|
|
347
|
+
* auditable). A `guardAll.gate.created` audit row records the active +
|
|
348
|
+
* skipped roster so a security review can reconstruct what this deploy
|
|
349
|
+
* did and didn't defend against.
|
|
350
|
+
*
|
|
351
|
+
* @opts
|
|
352
|
+
* profile: "strict" | "balanced" | "permissive",
|
|
353
|
+
* compliancePosture: "hipaa" | "pci-dss" | "gdpr" | "soc2",
|
|
354
|
+
* mode: "enforce" | "audit-only",
|
|
355
|
+
* exceptFor: { [name]: { reason: string } },
|
|
356
|
+
* override: { [name]: object }, // per-guard opts merged in
|
|
357
|
+
* audit: object, // b.audit handle
|
|
358
|
+
* observability: object, // b.observability handle
|
|
359
|
+
* forensicEvidenceStore: object,
|
|
360
|
+
* forensicSnippetBytes: number,
|
|
361
|
+
* cache: object,
|
|
362
|
+
* cacheTtlMs: number,
|
|
363
|
+
* maxRuntimeMs: number,
|
|
364
|
+
* beforeCheck: function,
|
|
365
|
+
* afterCheck: function,
|
|
366
|
+
* onIssue: function,
|
|
367
|
+
* onSanitize: function,
|
|
368
|
+
* onRefuse: function,
|
|
369
|
+
* onAudit: function,
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* var b = require("@blamejs/core");
|
|
373
|
+
* var safety = b.guardAll.gate({
|
|
374
|
+
* profile: "strict",
|
|
375
|
+
* exceptFor: {
|
|
376
|
+
* html: { reason: "every HTML response is server-rendered + CSP-locked" },
|
|
377
|
+
* },
|
|
378
|
+
* override: { csv: { profile: "email-attachment" } },
|
|
379
|
+
* });
|
|
380
|
+
* // → contentTypeMux gate dispatching by Content-Type to each active member
|
|
381
|
+
*/
|
|
356
382
|
function gate(opts) {
|
|
357
383
|
opts = opts || {};
|
|
358
384
|
var resolved = _resolveActiveGuards(opts);
|
|
@@ -371,6 +397,33 @@ function gate(opts) {
|
|
|
371
397
|
});
|
|
372
398
|
}
|
|
373
399
|
|
|
400
|
+
/**
|
|
401
|
+
* @primitive b.guardAll.byExtension
|
|
402
|
+
* @signature b.guardAll.byExtension(opts)
|
|
403
|
+
* @since 0.7.16
|
|
404
|
+
* @status stable
|
|
405
|
+
* @related b.guardAll.gate, b.guardAll.byContentType
|
|
406
|
+
*
|
|
407
|
+
* Return a map of file extension (".csv", ".svg", ...) to the gate of
|
|
408
|
+
* the guard that owns it. Drops directly into `b.staticServe.create
|
|
409
|
+
* ({ contentSafety })` so on-disk content is gated by extension match
|
|
410
|
+
* rather than served Content-Type. Honours the same `exceptFor` /
|
|
411
|
+
* `override` shape as `gate()`.
|
|
412
|
+
*
|
|
413
|
+
* @opts
|
|
414
|
+
* profile: "strict" | "balanced" | "permissive",
|
|
415
|
+
* compliancePosture: "hipaa" | "pci-dss" | "gdpr" | "soc2",
|
|
416
|
+
* exceptFor: { [name]: { reason: string } },
|
|
417
|
+
* override: { [name]: object },
|
|
418
|
+
* audit: object,
|
|
419
|
+
* observability: object,
|
|
420
|
+
*
|
|
421
|
+
* @example
|
|
422
|
+
* var b = require("@blamejs/core");
|
|
423
|
+
* var byExt = b.guardAll.byExtension({ profile: "strict" });
|
|
424
|
+
* var csvGate = byExt[".csv"];
|
|
425
|
+
* // → b.gateContract gate for guard-csv at strict profile
|
|
426
|
+
*/
|
|
374
427
|
function byExtension(opts) {
|
|
375
428
|
opts = opts || {};
|
|
376
429
|
var resolved = _resolveActiveGuards(opts);
|
|
@@ -387,6 +440,32 @@ function byExtension(opts) {
|
|
|
387
440
|
return map;
|
|
388
441
|
}
|
|
389
442
|
|
|
443
|
+
/**
|
|
444
|
+
* @primitive b.guardAll.byContentType
|
|
445
|
+
* @signature b.guardAll.byContentType(opts)
|
|
446
|
+
* @since 0.7.16
|
|
447
|
+
* @status stable
|
|
448
|
+
* @related b.guardAll.gate, b.guardAll.byExtension
|
|
449
|
+
*
|
|
450
|
+
* Return a map of canonical MIME type to the gate of the guard that
|
|
451
|
+
* owns it. Useful when the operator already has a non-mux dispatch
|
|
452
|
+
* shape (custom router / per-route content-safety) and wants the
|
|
453
|
+
* per-type gate keyed by MIME directly. `gate()` wraps this map in
|
|
454
|
+
* `gateContract.contentTypeMux`; this primitive surfaces the raw map.
|
|
455
|
+
*
|
|
456
|
+
* @opts
|
|
457
|
+
* profile: "strict" | "balanced" | "permissive",
|
|
458
|
+
* compliancePosture: "hipaa" | "pci-dss" | "gdpr" | "soc2",
|
|
459
|
+
* exceptFor: { [name]: { reason: string } },
|
|
460
|
+
* override: { [name]: object },
|
|
461
|
+
* audit: object,
|
|
462
|
+
*
|
|
463
|
+
* @example
|
|
464
|
+
* var b = require("@blamejs/core");
|
|
465
|
+
* var byMime = b.guardAll.byContentType({ profile: "balanced" });
|
|
466
|
+
* var jsonGate = byMime["application/json"];
|
|
467
|
+
* // → b.gateContract gate for guard-json at balanced profile
|
|
468
|
+
*/
|
|
390
469
|
function byContentType(opts) {
|
|
391
470
|
opts = opts || {};
|
|
392
471
|
var resolved = _resolveActiveGuards(opts);
|
|
@@ -403,6 +482,25 @@ function byContentType(opts) {
|
|
|
403
482
|
return map;
|
|
404
483
|
}
|
|
405
484
|
|
|
485
|
+
/**
|
|
486
|
+
* @primitive b.guardAll.list
|
|
487
|
+
* @signature b.guardAll.list()
|
|
488
|
+
* @since 0.7.16
|
|
489
|
+
* @status stable
|
|
490
|
+
* @related b.guardAll.allGuards, b.guardAll.gate
|
|
491
|
+
*
|
|
492
|
+
* Enumerate the registered content-bytes guards with their NAME, owned
|
|
493
|
+
* MIME types, owned extensions, and supported profile + posture
|
|
494
|
+
* vocabularies. Operators dump this at boot to surface "what is my
|
|
495
|
+
* deploy actually defending" in their audit attestation.
|
|
496
|
+
*
|
|
497
|
+
* @example
|
|
498
|
+
* var b = require("@blamejs/core");
|
|
499
|
+
* var rows = b.guardAll.list();
|
|
500
|
+
* // → [{ name: "csv", mimeTypes: ["text/csv"], extensions: [".csv"],
|
|
501
|
+
* // profiles: ["strict","balanced","permissive","email-attachment"],
|
|
502
|
+
* // postures: ["hipaa","pci-dss","gdpr","soc2"] }, ...]
|
|
503
|
+
*/
|
|
406
504
|
function list() {
|
|
407
505
|
return GUARDS.map(function (g) {
|
|
408
506
|
return {
|
|
@@ -415,10 +513,29 @@ function list() {
|
|
|
415
513
|
});
|
|
416
514
|
}
|
|
417
515
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
516
|
+
/**
|
|
517
|
+
* @primitive b.guardAll.allGuards
|
|
518
|
+
* @signature b.guardAll.allGuards()
|
|
519
|
+
* @since 0.7.16
|
|
520
|
+
* @status stable
|
|
521
|
+
* @related b.guardAll.list, b.guardAll.gate
|
|
522
|
+
*
|
|
523
|
+
* Return every guard module in the family — registered (content-bytes)
|
|
524
|
+
* AND standalone (filename / domain / uuid / cidr / time / mime / jwt /
|
|
525
|
+
* oauth / graphql / shell / regex / jsonpath / template / image / pdf /
|
|
526
|
+
* auth). Used by the adaptive integration harness to iterate the full
|
|
527
|
+
* family without hardcoding the list, so future guards added to either
|
|
528
|
+
* registry pick up automatically.
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* var b = require("@blamejs/core");
|
|
532
|
+
* var all = b.guardAll.allGuards();
|
|
533
|
+
* var names = all.map(function (g) { return g.NAME; });
|
|
534
|
+
* // → ["csv","html","svg","archive","json","yaml","xml","markdown",
|
|
535
|
+
* // "email","filename","domain","uuid","cidr","time","mime","jwt",
|
|
536
|
+
* // "oauth","graphql","shell","regex","jsonpath","template",
|
|
537
|
+
* // "image","pdf","auth"]
|
|
538
|
+
*/
|
|
422
539
|
function allGuards() {
|
|
423
540
|
return GUARDS.concat(STANDALONE_GUARDS);
|
|
424
541
|
}
|