@blamejs/core 0.14.0 → 0.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/lib/_test/crypto-fixtures.js +3 -3
- package/lib/a2a-tasks.js +18 -18
- package/lib/a2a.js +4 -4
- package/lib/acme.js +3 -3
- package/lib/agent-idempotency.js +1 -1
- package/lib/agent-orchestrator.js +8 -8
- package/lib/agent-posture-chain.js +2 -2
- package/lib/agent-saga.js +1 -1
- package/lib/agent-snapshot.js +1 -1
- package/lib/agent-stream.js +1 -1
- package/lib/agent-tenant.js +1 -1
- package/lib/agent-trace.js +3 -3
- package/lib/ai-capability.js +1 -1
- package/lib/ai-dp.js +4 -4
- package/lib/ai-input.js +3 -3
- package/lib/ai-model-manifest.js +7 -7
- package/lib/ai-pref.js +3 -3
- package/lib/archive-gz.js +2 -2
- package/lib/archive-read.js +25 -25
- package/lib/archive-tar-read.js +2 -2
- package/lib/archive-tar.js +20 -20
- package/lib/archive-wrap.js +10 -10
- package/lib/argon2-builtin.js +1 -1
- package/lib/asn1-der.js +45 -34
- package/lib/atomic-file.js +2 -2
- package/lib/audit-daily-review.js +3 -3
- package/lib/audit-sign.js +5 -5
- package/lib/audit-tools.js +1 -1
- package/lib/audit.js +2 -2
- package/lib/auth/acr-vocabulary.js +2 -2
- package/lib/auth/bot-challenge.js +3 -3
- package/lib/auth/ciba.js +7 -7
- package/lib/auth/dpop.js +3 -3
- package/lib/auth/fido-mds3.js +8 -8
- package/lib/auth/jar.js +11 -0
- package/lib/auth/jwt-external.js +5 -5
- package/lib/auth/oauth.js +7 -9
- package/lib/auth/oid4vci.js +10 -10
- package/lib/auth/oid4vp.js +2 -2
- package/lib/auth/openid-federation.js +2 -2
- package/lib/auth/passkey.js +3 -3
- package/lib/auth/saml.js +29 -25
- package/lib/auth/sd-jwt-vc-disclosure.js +1 -1
- package/lib/auth/sd-jwt-vc.js +4 -4
- package/lib/auth/status-list.js +10 -10
- package/lib/auth/step-up.js +1 -1
- package/lib/auth-bot-challenge.js +1 -1
- package/lib/backup/index.js +7 -7
- package/lib/base32.js +8 -8
- package/lib/budr.js +2 -2
- package/lib/cache-status.js +2 -2
- package/lib/calendar.js +23 -23
- package/lib/cbor.js +12 -12
- package/lib/cdn-cache-control.js +1 -1
- package/lib/cert.js +5 -5
- package/lib/cloud-events.js +5 -5
- package/lib/cms-codec.js +21 -21
- package/lib/codepoint-class.js +12 -12
- package/lib/compliance-sanctions-fuzzy.js +4 -4
- package/lib/compliance-sanctions.js +4 -4
- package/lib/compliance.js +29 -29
- package/lib/content-credentials.js +36 -36
- package/lib/cookies.js +1 -1
- package/lib/cose.js +13 -13
- package/lib/cra-report.js +1 -1
- package/lib/crdt.js +1 -1
- package/lib/crypto-field.js +2 -2
- package/lib/crypto-xwing.js +7 -7
- package/lib/crypto.js +6 -6
- package/lib/csp.js +2 -2
- package/lib/cwt.js +4 -4
- package/lib/dark-patterns.js +2 -2
- package/lib/data-act.js +2 -2
- package/lib/db-file-lifecycle.js +4 -4
- package/lib/db-query.js +1 -1
- package/lib/db.js +6 -6
- package/lib/dbsc.js +13 -13
- package/lib/did.js +17 -17
- package/lib/dora.js +4 -4
- package/lib/dsr.js +1 -1
- package/lib/early-hints.js +2 -2
- package/lib/eat.js +4 -4
- package/lib/external-db-migrate.js +1 -1
- package/lib/external-db.js +1 -1
- package/lib/flag-cache.js +1 -1
- package/lib/flag-evaluation-context.js +2 -2
- package/lib/graphql-federation.js +4 -4
- package/lib/guard-agent-registry.js +5 -5
- package/lib/guard-archive.js +24 -24
- package/lib/guard-cidr.js +33 -33
- package/lib/guard-csv.js +1 -1
- package/lib/guard-domain.js +10 -10
- package/lib/guard-dsn.js +4 -4
- package/lib/guard-email.js +19 -19
- package/lib/guard-event-bus-payload.js +4 -4
- package/lib/guard-event-bus-topic.js +6 -6
- package/lib/guard-filename.js +7 -7
- package/lib/guard-graphql.js +9 -9
- package/lib/guard-html-wcag-tagwalk.js +1 -1
- package/lib/guard-html-wcag.js +4 -4
- package/lib/guard-html.js +7 -7
- package/lib/guard-idempotency-key.js +6 -6
- package/lib/guard-image.js +4 -4
- package/lib/guard-imap-command.js +17 -17
- package/lib/guard-jmap.js +20 -20
- package/lib/guard-json.js +12 -12
- package/lib/guard-jsonpath.js +3 -3
- package/lib/guard-jwt.js +4 -4
- package/lib/guard-list-id.js +7 -7
- package/lib/guard-list-unsubscribe.js +8 -8
- package/lib/guard-mail-compose.js +4 -4
- package/lib/guard-mail-move.js +5 -5
- package/lib/guard-mail-query.js +3 -3
- package/lib/guard-mail-reply.js +3 -3
- package/lib/guard-mail-sieve.js +6 -6
- package/lib/guard-managesieve-command.js +25 -25
- package/lib/guard-markdown.js +31 -31
- package/lib/guard-message-id.js +5 -5
- package/lib/guard-mime.js +1 -1
- package/lib/guard-oauth.js +3 -3
- package/lib/guard-pdf.js +6 -6
- package/lib/guard-pop3-command.js +11 -11
- package/lib/guard-posture-chain.js +5 -5
- package/lib/guard-regex.js +10 -10
- package/lib/guard-saga-config.js +5 -5
- package/lib/guard-smtp-command.js +6 -6
- package/lib/guard-snapshot-envelope.js +3 -3
- package/lib/guard-stream-args.js +4 -4
- package/lib/guard-svg.js +11 -11
- package/lib/guard-tenant-id.js +5 -5
- package/lib/guard-time.js +15 -15
- package/lib/guard-trace-context.js +4 -4
- package/lib/guard-uuid.js +11 -11
- package/lib/guard-xml.js +12 -12
- package/lib/guard-yaml.js +16 -16
- package/lib/honeytoken.js +5 -5
- package/lib/http-client.js +1 -1
- package/lib/http-message-signature.js +2 -2
- package/lib/iab-mspa.js +3 -3
- package/lib/iab-tcf.js +70 -70
- package/lib/inbox.js +4 -4
- package/lib/ip-utils.js +15 -15
- package/lib/jose-jwe-experimental.js +2 -2
- package/lib/json-path.js +3 -3
- package/lib/json-schema.js +1 -1
- package/lib/jsonapi.js +3 -3
- package/lib/jtd.js +2 -2
- package/lib/link-header.js +1 -1
- package/lib/local-db-thin.js +1 -1
- package/lib/log.js +1 -1
- package/lib/lro.js +4 -4
- package/lib/mail-agent.js +1 -1
- package/lib/mail-arc-sign.js +6 -6
- package/lib/mail-auth.js +43 -43
- package/lib/mail-bimi.js +3 -3
- package/lib/mail-crypto-pgp.js +53 -45
- package/lib/mail-crypto-smime.js +5 -5
- package/lib/mail-dav.js +1 -1
- package/lib/mail-deploy.js +39 -39
- package/lib/mail-dkim.js +11 -11
- package/lib/mail-greylist.js +12 -12
- package/lib/mail-helo.js +1 -1
- package/lib/mail-journal.js +8 -8
- package/lib/mail-rbl.js +7 -7
- package/lib/mail-scan.js +7 -7
- package/lib/mail-send-deliver.js +2 -2
- package/lib/mail-server-imap.js +12 -12
- package/lib/mail-server-jmap.js +16 -16
- package/lib/mail-server-managesieve.js +4 -4
- package/lib/mail-server-mx.js +17 -17
- package/lib/mail-server-pop3.js +4 -4
- package/lib/mail-server-rate-limit.js +2 -2
- package/lib/mail-server-submission.js +21 -21
- package/lib/mail-sieve.js +2 -2
- package/lib/mail-spam-score.js +5 -5
- package/lib/mail-srs.js +12 -12
- package/lib/mail-store-fts.js +2 -2
- package/lib/mail-store.js +8 -8
- package/lib/mail-unsubscribe.js +4 -4
- package/lib/mail.js +4 -4
- package/lib/mcp-tool-registry.js +4 -4
- package/lib/mcp.js +8 -8
- package/lib/mdoc.js +2 -2
- package/lib/metrics.js +8 -8
- package/lib/middleware/age-gate.js +1 -1
- package/lib/middleware/api-encrypt.js +7 -7
- package/lib/middleware/assetlinks.js +2 -2
- package/lib/middleware/asyncapi-serve.js +2 -2
- package/lib/middleware/bearer-auth.js +5 -5
- package/lib/middleware/body-parser.js +5 -5
- package/lib/middleware/compose-pipeline.js +15 -15
- package/lib/middleware/csp-report.js +4 -4
- package/lib/middleware/daily-byte-quota.js +1 -1
- package/lib/middleware/dpop.js +1 -1
- package/lib/middleware/headers.js +2 -2
- package/lib/middleware/host-allowlist.js +1 -1
- package/lib/middleware/idempotency-key.js +12 -12
- package/lib/middleware/nel.js +1 -1
- package/lib/middleware/openapi-serve.js +2 -2
- package/lib/middleware/protected-resource-metadata.js +2 -2
- package/lib/middleware/require-aal.js +1 -1
- package/lib/middleware/require-bound-key.js +2 -2
- package/lib/middleware/require-content-type.js +1 -1
- package/lib/middleware/require-methods.js +1 -1
- package/lib/middleware/require-step-up.js +2 -2
- package/lib/middleware/scim-server.js +1 -1
- package/lib/middleware/security-txt.js +3 -3
- package/lib/middleware/tus-upload.js +12 -12
- package/lib/middleware/web-app-manifest.js +2 -2
- package/lib/network-byte-quota.js +1 -1
- package/lib/network-dns-resolver.js +23 -23
- package/lib/network-dns.js +29 -29
- package/lib/network-dnssec.js +33 -33
- package/lib/network-smtp-policy.js +10 -10
- package/lib/network-tls.js +99 -94
- package/lib/network-tsig.js +33 -33
- package/lib/nis2-report.js +1 -1
- package/lib/ntp-check.js +3 -3
- package/lib/observability-otlp-exporter.js +17 -17
- package/lib/observability-tracer.js +6 -6
- package/lib/observability.js +8 -8
- package/lib/openapi-yaml.js +1 -1
- package/lib/openapi.js +1 -1
- package/lib/outbox.js +6 -6
- package/lib/pqc-agent.js +4 -4
- package/lib/pqc-software.js +1 -1
- package/lib/privacy-pass.js +5 -5
- package/lib/problem-details.js +5 -5
- package/lib/promise-pool.js +1 -1
- package/lib/protobuf-encoder.js +9 -1
- package/lib/queue.js +4 -2
- package/lib/redact.js +2 -2
- package/lib/request-helpers.js +1 -1
- package/lib/router.js +10 -10
- package/lib/safe-async.js +2 -2
- package/lib/safe-dns.js +71 -71
- package/lib/safe-ical.js +19 -19
- package/lib/safe-icap.js +24 -24
- package/lib/safe-jsonpath.js +2 -2
- package/lib/safe-mime.js +10 -10
- package/lib/safe-mount-info.js +3 -3
- package/lib/safe-redirect.js +1 -1
- package/lib/safe-sieve.js +23 -23
- package/lib/safe-smtp.js +1 -1
- package/lib/safe-vcard.js +14 -14
- package/lib/sandbox.js +5 -5
- package/lib/sec-cyber.js +1 -1
- package/lib/self-update-standalone-verifier.js +3 -3
- package/lib/self-update.js +3 -3
- package/lib/server-timing.js +3 -3
- package/lib/session-device-binding.js +7 -7
- package/lib/session.js +8 -8
- package/lib/standard-webhooks.js +4 -4
- package/lib/storage.js +2 -2
- package/lib/stream-throttle.js +1 -1
- package/lib/structured-fields.js +15 -15
- package/lib/subject.js +1 -1
- package/lib/tcpa-10dlc.js +1 -1
- package/lib/tenant-quota.js +3 -3
- package/lib/test-harness.js +1 -1
- package/lib/tracing.js +1 -1
- package/lib/tsa.js +5 -5
- package/lib/uri-template.js +5 -5
- package/lib/vault/index.js +2 -2
- package/lib/vault/seal-pem-file.js +4 -4
- package/lib/vc.js +2 -2
- package/lib/vendor-data.js +1 -1
- package/lib/watcher.js +4 -4
- package/lib/web-push-vapid.js +21 -21
- package/lib/webhook.js +2 -2
- package/lib/websocket.js +3 -3
- package/lib/worker-pool.js +3 -3
- package/lib/ws-client.js +24 -24
- package/lib/xml-c14n.js +2 -2
- package/package.json +1 -1
- package/sbom.cdx.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,10 @@ upgrading across more than a few patches at a time.
|
|
|
8
8
|
|
|
9
9
|
## v0.14.x
|
|
10
10
|
|
|
11
|
+
- v0.14.2 (2026-05-29) — **Internal lint hygiene: the byte-literal check now flags only genuine byte-scale arithmetic, with no API or behavior changes.** A no-behavior-change cleanup of the source tree's internal lint markers. The byte-literal lint previously flagged every integer that was a multiple of 8 — which is most numbers — so the source carried a large number of suppression comments on values that were not byte sizes at all (status codes, counts, lengths, radixes, opcodes). The lint now flags only 1024-scale byte arithmetic (the case the C.BYTES.kib/mib/gib helpers exist to replace), and the now-unnecessary suppression comments have been removed while keeping their explanatory text. Several lint-suppression markers that named a check that does not exist were also corrected. None of this changes any API, wire format, or runtime behavior. **Changed:** *Source-tree lint markers cleaned up* — The internal byte-literal lint was tightened to flag only genuine byte-scale (`* 1024`) arithmetic, and the suppression comments it previously required on non-byte integers were removed (their explanatory text is retained as plain comments). A handful of suppression markers that referenced a non-existent check were pointed at the correct one or removed. This is source-comment hygiene only — there is no change to any exported API, error code, wire format, or runtime behavior.
|
|
12
|
+
|
|
13
|
+
- v0.14.1 (2026-05-29) — **Correctness fixes: JAR request-object typ enforcement, byte-faithful PGP multipart/signed, and SAML InResponseTo binding.** A set of correctness fixes across the auth, mail-crypto, TLS, and encoder surfaces. The most important: JWT-secured authorization requests (RFC 9101) now require the request object to carry the registered `oauth-authz-req+jwt` typ, closing a cross-JWT-confusion vector; the PGP multipart/signed wrapper is now assembled byte-faithfully so non-ASCII signed content can't be corrupted; and SAML response verification now returns the InResponseTo of the SubjectConfirmation that actually validated. Two of these change behavior — see Changed — and are bug fixes rather than new features. **Changed:** *JAR parsing rejects untyped request objects (breaking)* — Following the typ enforcement above, a request object whose header omits `typ` is now refused. An authorization server whose clients sign request objects without the `oauth-authz-req+jwt` typ must update those clients to set it. · *PGP sign() returns multipartSigned as a Buffer (breaking)* — `b.mail.crypto.pgp.sign(...).multipartSigned` is now a Buffer instead of a string. The OpenPGP signature covers the signed-part bytes exactly, and a JS-string round trip through latin1/utf8 could corrupt non-ASCII signed content and break verification, so the RFC 3156 multipart/signed wrapper is now assembled as bytes. Code that wrote the previous string to the wire works unchanged when it writes the Buffer; code that did string operations on the value should treat it as a Buffer (its `indexOf` / `toString` still work). **Fixed:** *SAML response verification binds InResponseTo to the validated confirmation* — `verifyResponse` returned the InResponseTo of the first SubjectConfirmationData in the assertion rather than of the SubjectConfirmation that actually passed bearer validation. When a response carried more than one SubjectConfirmation, the returned value could come from a non-validated confirmation. It is now the InResponseTo of the confirmation that validated. · *checkServerIdentity9525 emits the documented CN-fallback audit code* — A CN-only legacy certificate (a Common Name present, no subjectAltName) is now refused by the exported `b.network.tls.checkServerIdentity9525` with the distinct `tls/pkix-cn-fallback-refused` code its documentation promised, so audit logs can tell a CN-only certificate apart from one carrying neither a SAN nor a CN (which still yields `tls/pkix-san-required`). The accept/refuse outcome is unchanged — both are refused; only the audit granularity improved. · *OIDC back-channel logout / JARM no longer accept dead override parameters* — `verifyBackchannelLogoutToken` and `parseJarmResponse` passed `acceptedAlgs` / `jwksUri` / `maxClockSkewMs` through to the ID-token verifier, which ignored them and applied the configured (create()-time) values. The pass-throughs are removed so the code no longer reads as if those can be overridden per call; the configured trust anchor was — and remains — what applies. · *Queue lease failures are logged* — The consumer loop's lease-acquisition error path swallowed the backend error silently; it now logs at debug so a flapping backend that has not yet tripped the circuit breaker is visible. · *Protobuf and ASN.1 encoders reject out-of-range tags* — The protobuf tag encoder rejected nothing and would have emitted a wrong tag for field numbers at or above 2^28 (where the 32-bit shift overflows); the ASN.1 context-tag writers silently truncated tag numbers above 30 (which require the multi-byte high-tag-number form). Both now throw a RangeError rather than encode silently-wrong output. The values these encoders serve are well within range, so no current caller is affected. · *oid4vci proofAlgorithms default documented accurately* — The documented default proof-algorithm list now matches the code (`["ES256", "ES384", "EdDSA"]`); the doc previously omitted EdDSA, which the runtime has always accepted by default. **Security:** *JAR request objects must carry the registered typ (RFC 9101)* — `b.auth.jar.parse` now requires the request-object JWS header to carry `typ: "oauth-authz-req+jwt"` (with or without the `application/` prefix); a request object with an absent or different typ is refused with `auth-jar/bad-typ`. RFC 9101 §10.8 specifies this media type precisely to stop a JWT minted for another purpose (an ID token, an access token, a logout token) and signed by the same client key from being replayed as a request object. The existing `iss` / `aud` / `client_id` bindings already constrained that; this restores the explicit type check as well. This is stricter than before — see Changed.
|
|
14
|
+
|
|
11
15
|
- v0.14.0 (2026-05-29) — **Operator-configurable header and field names across SSE, request-id, rate-limit, age-gate, AI-Act disclosure, GraphQL federation, and the HTTP cache.** This release makes operator-facing identifiers that were hardcoded configurable. The framework already let operators rename most names (CSRF cookie/field, cookie parser, i18n header/query/cookie, mTLS CA name, and so on); this closes the remaining gaps so a custom or framework-specific name is never frozen. Every new option defaults to the value emitted today, so upgrading changes no behavior — these are additive knobs. It also fixes a request-id asymmetry (the response header is now written on the same name the inbound id is read from) and wires an SSE proxy-buffering option whose escape hatch was documented but never implemented. **Added:** *Configurable cache-status header on the HTTP client* — The outbound HTTP client annotated every cached response with a hardcoded `x-blamejs-cache: HIT|MISS|STALE|REVALIDATED` header. `b.httpClient.cache.create` now takes `statusHeader` (default "x-blamejs-cache") — pass a custom name (e.g. "x-cache") to rename it, or null/false to suppress it entirely. The decision remains available programmatically on `res.cacheStatus`. · *Configurable rate-limit header names* — `b.middleware.rateLimit` emitted the de-facto `X-RateLimit-Limit` / `X-RateLimit-Remaining` headers (which are not RFC-pinned). It now accepts `headerPrefix` (default "X-RateLimit-") so operators can match the unprefixed IETF-draft `RateLimit-*` names or an upstream gateway's convention; the limit/remaining pair is always built from the same prefix. · *Configurable age-gate and AI-Act disclosure header names* — `b.middleware.ageGate` now takes `privacyPostureHeader` (default "X-Privacy-Posture"; null/false to suppress), and `b.middleware.aiActDisclosure` takes `headerPrefix` (default "AI-Act-") that prefixes the emitted Notice / Article / Policy headers. The EU AI Act mandates the disclosure, not the HTTP spelling, so operators matching a downstream convention can rename these. · *Configurable GraphQL-federation replay-nonce header* — `b.graphqlFederation.guardSdl` read the replay nonce from the Apollo-vendor `x-apollographql-router-nonce` header with no override. It now accepts `nonceHeader` (default unchanged) so an operator fronting the gateway with a non-Apollo router can point the replay check at their own header. · *SSE proxy-buffering opt-out* — `b.sse.create` and `b.middleware.sse` set `X-Accel-Buffering: no` (the nginx hint that disables proxy buffering). They now accept `proxyBuffer` (default true) — pass false when not behind nginx, or when buffering is controlled at the load balancer, to suppress the nginx-specific header. The opt-out was previously referenced in the documentation but not implemented. **Fixed:** *Request-id middleware reflects the configured header name* — `b.log.middleware` read the inbound request id from a configurable `headerName` but always wrote the response on the literal `X-Request-Id`. An operator who set a custom `headerName` (e.g. `X-Correlation-Id`) therefore read from one header and emitted another. The response is now written on the same configured name; the default remains `X-Request-Id`, so deployments that did not set `headerName` are unaffected.
|
|
12
16
|
|
|
13
17
|
## v0.13.x
|
|
@@ -47,15 +47,15 @@ function mintLegacyEnvelope0xE1(plaintext, recipient) {
|
|
|
47
47
|
var nonce = bCrypto.generateBytes(C.BYTES.bytes(24));
|
|
48
48
|
// Legacy 0xE1 envelope header — 4 bytes: magic, kemId, cipherId, kdfId.
|
|
49
49
|
var headerAad = Buffer.from([
|
|
50
|
-
0xE1, //
|
|
50
|
+
0xE1, // legacy 0xE1 envelope magic byte
|
|
51
51
|
C.KEM_IDS.ML_KEM_1024_P384,
|
|
52
52
|
C.CIPHER_IDS.XCHACHA20_POLY1305,
|
|
53
53
|
C.KDF_IDS.SHAKE256,
|
|
54
54
|
]);
|
|
55
55
|
var ct = xchacha20poly1305(key, nonce, headerAad).encrypt(Buffer.from(plaintext, "utf8"));
|
|
56
|
-
var kemCtLen = Buffer.alloc(2); kemCtLen.writeUInt16BE(kem.ciphertext.length); //
|
|
56
|
+
var kemCtLen = Buffer.alloc(2); kemCtLen.writeUInt16BE(kem.ciphertext.length); // 16-bit length-prefix field
|
|
57
57
|
var ecEphDer = ephEc.publicKey;
|
|
58
|
-
var ecEphLen = Buffer.alloc(2); ecEphLen.writeUInt16BE(ecEphDer.length); //
|
|
58
|
+
var ecEphLen = Buffer.alloc(2); ecEphLen.writeUInt16BE(ecEphDer.length); // 16-bit length-prefix field
|
|
59
59
|
return Buffer.concat([
|
|
60
60
|
headerAad,
|
|
61
61
|
kemCtLen, kem.ciphertext, ecEphLen, ecEphDer, nonce, Buffer.from(ct),
|
package/lib/a2a-tasks.js
CHANGED
|
@@ -80,7 +80,7 @@ var TASK_ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
|
|
|
80
80
|
// Same identifier shape as MCP tool-name; consolidating would couple
|
|
81
81
|
// MCP + A2A protocol identifiers into a single primitive.
|
|
82
82
|
var SKILL_NAME_RE = /^[a-zA-Z][a-zA-Z0-9._-]{0,63}$/; // allow:duplicate-regex — RFC-3986-unreserved identifier shape, shared across mcp.js + mcp-tool-registry.js
|
|
83
|
-
//
|
|
83
|
+
// RFC-3986-unreserved identifier shape (length cap inside regex), not a byte count
|
|
84
84
|
|
|
85
85
|
function _emitAudit(action, metadata, outcome) {
|
|
86
86
|
try {
|
|
@@ -99,7 +99,7 @@ var bCrypto = lazyRequire(function () { return require("./crypto"); });
|
|
|
99
99
|
// satisfies the framework's unused-var policy so the helper stays
|
|
100
100
|
// available without an explicit disable directive.
|
|
101
101
|
function _newTaskId() {
|
|
102
|
-
return bCrypto().generateToken(12); //
|
|
102
|
+
return bCrypto().generateToken(12); // 96-bit task id, not byte arithmetic on payload
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
function _validateTaskShape(task, where) {
|
|
@@ -108,7 +108,7 @@ function _validateTaskShape(task, where) {
|
|
|
108
108
|
where + ": task must be a non-null object", true);
|
|
109
109
|
}
|
|
110
110
|
validateOpts.requireNonEmptyString(task.skill, where + ".skill", A2aTasksError, "a2a-tasks/bad-skill");
|
|
111
|
-
if (task.skill.length > 64 || !SKILL_NAME_RE.test(task.skill)) { //
|
|
111
|
+
if (task.skill.length > 64 || !SKILL_NAME_RE.test(task.skill)) { // A2A skill-name length cap, not byte count
|
|
112
112
|
|
|
113
113
|
throw new A2aTasksError("a2a-tasks/bad-skill",
|
|
114
114
|
where + ".skill '" + task.skill + "' must match " + SKILL_NAME_RE);
|
|
@@ -196,7 +196,7 @@ async function get(opts) {
|
|
|
196
196
|
}
|
|
197
197
|
validateOpts.requireNonEmptyString(opts.peerUrl, "tasks.get.peerUrl", A2aTasksError, "a2a-tasks/bad-peer-url");
|
|
198
198
|
validateOpts.requireNonEmptyString(opts.taskId, "tasks.get.taskId", A2aTasksError, "a2a-tasks/bad-task-id");
|
|
199
|
-
if (opts.taskId.length > 64 || !TASK_ID_RE.test(opts.taskId)) { //
|
|
199
|
+
if (opts.taskId.length > 64 || !TASK_ID_RE.test(opts.taskId)) { // A2A task-id length cap, not byte count
|
|
200
200
|
throw new A2aTasksError("a2a-tasks/bad-task-id",
|
|
201
201
|
"tasks.get: taskId must match " + TASK_ID_RE);
|
|
202
202
|
}
|
|
@@ -239,7 +239,7 @@ async function cancel(opts) {
|
|
|
239
239
|
}
|
|
240
240
|
validateOpts.requireNonEmptyString(opts.peerUrl, "tasks.cancel.peerUrl", A2aTasksError, "a2a-tasks/bad-peer-url");
|
|
241
241
|
validateOpts.requireNonEmptyString(opts.taskId, "tasks.cancel.taskId", A2aTasksError, "a2a-tasks/bad-task-id");
|
|
242
|
-
if (opts.taskId.length > 64 || !TASK_ID_RE.test(opts.taskId)) { //
|
|
242
|
+
if (opts.taskId.length > 64 || !TASK_ID_RE.test(opts.taskId)) { // A2A task-id length cap, not byte count
|
|
243
243
|
throw new A2aTasksError("a2a-tasks/bad-task-id",
|
|
244
244
|
"tasks.cancel: taskId must match " + TASK_ID_RE);
|
|
245
245
|
}
|
|
@@ -280,7 +280,7 @@ async function _jsonRpc(url, method, params, opts) {
|
|
|
280
280
|
throw new A2aTasksError("a2a-tasks/transport",
|
|
281
281
|
"tasks." + method.split("/")[1] + ": transport error: " + (transportErr.message || transportErr));
|
|
282
282
|
}
|
|
283
|
-
if (rsp.statusCode < 200 || rsp.statusCode >= 300) { //
|
|
283
|
+
if (rsp.statusCode < 200 || rsp.statusCode >= 300) { // HTTP status class boundaries
|
|
284
284
|
if (opts.audit) {
|
|
285
285
|
_emitAudit("a2a.tasks.http_error",
|
|
286
286
|
{ method: method, url: url, statusCode: rsp.statusCode, elapsedMs: Date.now() - startMs },
|
|
@@ -395,7 +395,7 @@ function middlewareTasks(opts) {
|
|
|
395
395
|
|
|
396
396
|
return function a2aTasksMiddleware(req, res) {
|
|
397
397
|
if ((req.method || "").toUpperCase() !== "POST") {
|
|
398
|
-
res.statusCode = 405; //
|
|
398
|
+
res.statusCode = 405; // HTTP 405 Method Not Allowed
|
|
399
399
|
res.setHeader("Content-Type", "application/json");
|
|
400
400
|
res.setHeader("Allow", "POST");
|
|
401
401
|
res.end(JSON.stringify(_jsonRpcError(null, JSONRPC_INVALID_REQUEST, "method must be POST")));
|
|
@@ -403,7 +403,7 @@ function middlewareTasks(opts) {
|
|
|
403
403
|
}
|
|
404
404
|
var ctype = (req.headers && (req.headers["content-type"] || req.headers["Content-Type"])) || "";
|
|
405
405
|
if (typeof ctype === "string" && ctype.indexOf("application/json") !== 0 && ctype.indexOf("application/json") === -1) {
|
|
406
|
-
res.statusCode = 415; //
|
|
406
|
+
res.statusCode = 415; // HTTP 415 Unsupported Media Type
|
|
407
407
|
res.setHeader("Content-Type", "application/json");
|
|
408
408
|
res.end(JSON.stringify(_jsonRpcError(null, JSONRPC_INVALID_REQUEST, "Content-Type must be application/json")));
|
|
409
409
|
return;
|
|
@@ -414,14 +414,14 @@ function middlewareTasks(opts) {
|
|
|
414
414
|
try {
|
|
415
415
|
body = safeJson.parse(rawBytes.toString("utf8"), { maxBytes: maxBytes });
|
|
416
416
|
} catch (_parseErr) {
|
|
417
|
-
res.statusCode = 400; //
|
|
417
|
+
res.statusCode = 400; // HTTP 400 Bad Request
|
|
418
418
|
res.setHeader("Content-Type", "application/json");
|
|
419
419
|
res.end(JSON.stringify(_jsonRpcError(null, JSONRPC_PARSE_ERROR, "invalid JSON body")));
|
|
420
420
|
return;
|
|
421
421
|
}
|
|
422
422
|
if (!body || typeof body !== "object" || body.jsonrpc !== JSONRPC_VERSION ||
|
|
423
423
|
typeof body.method !== "string") {
|
|
424
|
-
res.statusCode = 400; //
|
|
424
|
+
res.statusCode = 400; // HTTP 400 Bad Request
|
|
425
425
|
res.setHeader("Content-Type", "application/json");
|
|
426
426
|
res.end(JSON.stringify(_jsonRpcError(body && body.id, JSONRPC_INVALID_REQUEST,
|
|
427
427
|
"expected JSON-RPC 2.0 envelope { jsonrpc, id?, method, params? }")));
|
|
@@ -429,7 +429,7 @@ function middlewareTasks(opts) {
|
|
|
429
429
|
}
|
|
430
430
|
var reqId = body.id !== undefined ? body.id : null;
|
|
431
431
|
if (ALLOWED_METHODS.indexOf(body.method) === -1) {
|
|
432
|
-
res.statusCode = 200; //
|
|
432
|
+
res.statusCode = 200; // JSON-RPC errors return 200 with error envelope
|
|
433
433
|
res.setHeader("Content-Type", "application/json");
|
|
434
434
|
res.end(JSON.stringify(_jsonRpcError(reqId, JSONRPC_METHOD_NOT_FOUND,
|
|
435
435
|
"method '" + body.method + "' not in [" + ALLOWED_METHODS.join(", ") + "]")));
|
|
@@ -440,7 +440,7 @@ function middlewareTasks(opts) {
|
|
|
440
440
|
// Scope enforcement for tasks/send (task references a skill).
|
|
441
441
|
if (body.method === "tasks/send" && scopes) {
|
|
442
442
|
if (!params.task || typeof params.task !== "object" || typeof params.task.skill !== "string") {
|
|
443
|
-
res.statusCode = 200; //
|
|
443
|
+
res.statusCode = 200; // JSON-RPC error envelope returns 200
|
|
444
444
|
res.setHeader("Content-Type", "application/json");
|
|
445
445
|
res.end(JSON.stringify(_jsonRpcError(reqId, JSONRPC_INVALID_PARAMS,
|
|
446
446
|
"tasks/send: params.task.skill required")));
|
|
@@ -454,7 +454,7 @@ function middlewareTasks(opts) {
|
|
|
454
454
|
_emitAudit("a2a.tasks.scope_denied",
|
|
455
455
|
{ skill: params.task.skill, requiredScope: requiredScope }, "denied");
|
|
456
456
|
}
|
|
457
|
-
res.statusCode = 200; //
|
|
457
|
+
res.statusCode = 200; // JSON-RPC error envelope returns 200
|
|
458
458
|
res.setHeader("Content-Type", "application/json");
|
|
459
459
|
res.end(JSON.stringify(_jsonRpcError(reqId, A2A_SCOPE_DENIED,
|
|
460
460
|
"scope '" + requiredScope + "' required for skill '" + params.task.skill + "'")));
|
|
@@ -476,7 +476,7 @@ function middlewareTasks(opts) {
|
|
|
476
476
|
_emitAudit("a2a.tasks.handled",
|
|
477
477
|
{ method: body.method, skill: params.task && params.task.skill, taskId: params.taskId });
|
|
478
478
|
}
|
|
479
|
-
res.statusCode = 200; //
|
|
479
|
+
res.statusCode = 200; // JSON-RPC 200 with result envelope
|
|
480
480
|
res.setHeader("Content-Type", "application/json");
|
|
481
481
|
res.end(JSON.stringify({
|
|
482
482
|
jsonrpc: JSONRPC_VERSION,
|
|
@@ -491,12 +491,12 @@ function middlewareTasks(opts) {
|
|
|
491
491
|
_emitAudit("a2a.tasks.handler_error",
|
|
492
492
|
{ method: body.method, errorMessage: msg, errorCode: code }, "warning");
|
|
493
493
|
}
|
|
494
|
-
res.statusCode = 200; //
|
|
494
|
+
res.statusCode = 200; // JSON-RPC error envelope returns 200
|
|
495
495
|
res.setHeader("Content-Type", "application/json");
|
|
496
496
|
res.end(JSON.stringify(_jsonRpcError(reqId, code, msg)));
|
|
497
497
|
});
|
|
498
498
|
}).catch(function (readErr) {
|
|
499
|
-
res.statusCode = 400; //
|
|
499
|
+
res.statusCode = 400; // HTTP 400 Bad Request
|
|
500
500
|
res.setHeader("Content-Type", "application/json");
|
|
501
501
|
res.end(JSON.stringify(_jsonRpcError(null, JSONRPC_PARSE_ERROR,
|
|
502
502
|
"could not read request body: " + (readErr.message || readErr))));
|
|
@@ -573,12 +573,12 @@ function middlewareAgentCard(opts) {
|
|
|
573
573
|
var cardJson = JSON.stringify(opts.card);
|
|
574
574
|
return function a2aAgentCardMiddleware(req, res) {
|
|
575
575
|
if ((req.method || "").toUpperCase() !== "GET") {
|
|
576
|
-
res.statusCode = 405; //
|
|
576
|
+
res.statusCode = 405; // HTTP 405 Method Not Allowed
|
|
577
577
|
res.setHeader("Allow", "GET");
|
|
578
578
|
res.end();
|
|
579
579
|
return;
|
|
580
580
|
}
|
|
581
|
-
res.statusCode = 200; //
|
|
581
|
+
res.statusCode = 200; // HTTP 200 OK
|
|
582
582
|
res.setHeader("Content-Type", "application/json");
|
|
583
583
|
res.setHeader("Cache-Control", "public, max-age=" + maxAgeSec);
|
|
584
584
|
res.end(cardJson);
|
package/lib/a2a.js
CHANGED
|
@@ -39,10 +39,10 @@ var audit = require("./audit");
|
|
|
39
39
|
var { A2aError } = require("./framework-error");
|
|
40
40
|
|
|
41
41
|
var REQUIRED_CARD_FIELDS = ["issuer", "agentId", "capabilities", "version"];
|
|
42
|
-
var ID_MAX = 256; //
|
|
43
|
-
var SEMVER_MAX = 64; //
|
|
44
|
-
var CAP_NAME_MAX = 128; //
|
|
45
|
-
var SHAKE256_BYTES = 64; //
|
|
42
|
+
var ID_MAX = 256; // string-length cap, not bytes
|
|
43
|
+
var SEMVER_MAX = 64; // string-length cap, not bytes
|
|
44
|
+
var CAP_NAME_MAX = 128; // string-length cap, not bytes
|
|
45
|
+
var SHAKE256_BYTES = 64; // SHA3-512 output is 64 bytes (FIPS 202)
|
|
46
46
|
var ID_RE = /^[a-zA-Z0-9._:/-]{1,256}$/;
|
|
47
47
|
var SEMVER_RE = /^[0-9]+\.[0-9]+(?:\.[0-9]+)?(?:-[A-Za-z0-9.-]+)?$/;
|
|
48
48
|
|
package/lib/acme.js
CHANGED
|
@@ -138,7 +138,7 @@ function _signJws(privateKey, protectedHeader, payload) {
|
|
|
138
138
|
// ECDSA from node:crypto returns DER-encoded (r,s); RFC 7515 requires
|
|
139
139
|
// raw concatenation of r||s, each padded to the curve byte size (32
|
|
140
140
|
// for P-256).
|
|
141
|
-
var rawSig = _ecdsaDerToRaw(derSig, 32); //
|
|
141
|
+
var rawSig = _ecdsaDerToRaw(derSig, 32); // RFC 7518 §3.4 ES256 signature half-length (P-256 byte size)
|
|
142
142
|
return {
|
|
143
143
|
protected: protB64,
|
|
144
144
|
payload: payloadB64,
|
|
@@ -1432,8 +1432,8 @@ function _base32lc(buf) {
|
|
|
1432
1432
|
var bits = 0;
|
|
1433
1433
|
var value = 0;
|
|
1434
1434
|
for (var i = 0; i < buf.length; i += 1) {
|
|
1435
|
-
value = (value << 8) | buf[i]; //
|
|
1436
|
-
bits += 8; //
|
|
1435
|
+
value = (value << 8) | buf[i]; // bit-shift count, byte boundary
|
|
1436
|
+
bits += 8; // bits-per-byte constant
|
|
1437
1437
|
while (bits >= 5) {
|
|
1438
1438
|
out += alphabet[(value >>> (bits - 5)) & 31];
|
|
1439
1439
|
bits -= 5;
|
package/lib/agent-idempotency.js
CHANGED
|
@@ -430,7 +430,7 @@ function _actorIdHash(actorId) {
|
|
|
430
430
|
|
|
431
431
|
function _truncHash(hash) {
|
|
432
432
|
if (typeof hash !== "string") return "";
|
|
433
|
-
return hash.slice(0, 16); //
|
|
433
|
+
return hash.slice(0, 16); // audit-log truncation length, not a size cap
|
|
434
434
|
}
|
|
435
435
|
|
|
436
436
|
function _fingerprintArgs(args) {
|
|
@@ -117,7 +117,7 @@ function _unsealRegistryRow(row) {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
var DEFAULT_DRAIN_TIMEOUT_MS = C.TIME.minutes(2);
|
|
120
|
-
var STREAM_ID_RAND_BYTES = 8; //
|
|
120
|
+
var STREAM_ID_RAND_BYTES = 8; // stream-id random-suffix byte length, not a size cap
|
|
121
121
|
var DEFAULT_PER_CONSUMER_STOP_MS = C.TIME.seconds(5);
|
|
122
122
|
// SUBSTRATE-20 — FNV-1a offset basis salted with the first 32 bits of
|
|
123
123
|
// SHA3-512(vault master). Attackers who don't have read access to the
|
|
@@ -428,7 +428,7 @@ function _spawnConsumers(ctx, args) {
|
|
|
428
428
|
"spawnConsumers: queue with .consume() required");
|
|
429
429
|
}
|
|
430
430
|
var shards = typeof args.shards === "number" ? args.shards : 1;
|
|
431
|
-
if (!Number.isInteger(shards) || shards < 1 || shards > 256) { //
|
|
431
|
+
if (!Number.isInteger(shards) || shards < 1 || shards > 256) { // shard cap
|
|
432
432
|
throw new AgentOrchestratorError("agent-orchestrator/bad-shard-count",
|
|
433
433
|
"spawnConsumers: shards must be an integer in 1..256");
|
|
434
434
|
}
|
|
@@ -508,21 +508,21 @@ function _saltedFnvBasis() {
|
|
|
508
508
|
var v;
|
|
509
509
|
try { v = vault(); } catch (_e) { v = null; }
|
|
510
510
|
if (!v || typeof v.getKeysJson !== "function") {
|
|
511
|
-
_saltedFnvBasisCache = 2166136261; //
|
|
511
|
+
_saltedFnvBasisCache = 2166136261; // FNV-1a offset basis (vault-less fallback)
|
|
512
512
|
return _saltedFnvBasisCache;
|
|
513
513
|
}
|
|
514
514
|
var keysJson;
|
|
515
515
|
try { keysJson = v.getKeysJson(); }
|
|
516
516
|
catch (_e) {
|
|
517
|
-
_saltedFnvBasisCache = 2166136261; //
|
|
517
|
+
_saltedFnvBasisCache = 2166136261; // FNV-1a offset basis (vault-init-pending fallback)
|
|
518
518
|
return _saltedFnvBasisCache;
|
|
519
519
|
}
|
|
520
520
|
var hashHex = bCrypto.sha3Hash(keysJson);
|
|
521
521
|
// Read the first 32 bits as the salt; mix into the offset basis via
|
|
522
522
|
// XOR so the distribution properties of FNV are preserved.
|
|
523
|
-
var saltBuf = Buffer.from(hashHex.slice(0, 8), "hex"); //
|
|
523
|
+
var saltBuf = Buffer.from(hashHex.slice(0, 8), "hex"); // 32-bit prefix of SHA3-512 hex (4 bytes = 8 hex chars)
|
|
524
524
|
var salt = saltBuf.readUInt32BE(0);
|
|
525
|
-
_saltedFnvBasisCache = ((2166136261 ^ salt) >>> 0); //
|
|
525
|
+
_saltedFnvBasisCache = ((2166136261 ^ salt) >>> 0); // FNV-1a offset basis (vault-salted)
|
|
526
526
|
return _saltedFnvBasisCache;
|
|
527
527
|
}
|
|
528
528
|
|
|
@@ -535,7 +535,7 @@ function shardFor(shardKey, shards) {
|
|
|
535
535
|
var h = _saltedFnvBasis();
|
|
536
536
|
for (var i = 0; i < shardKey.length; i += 1) {
|
|
537
537
|
h ^= shardKey.charCodeAt(i);
|
|
538
|
-
h = (h * 16777619) >>> 0; //
|
|
538
|
+
h = (h * 16777619) >>> 0; // FNV-1a prime
|
|
539
539
|
}
|
|
540
540
|
return h % shards;
|
|
541
541
|
}
|
|
@@ -710,7 +710,7 @@ async function _quiesceInFlight(ctx, startedAt, timeoutMs) {
|
|
|
710
710
|
}
|
|
711
711
|
if (!anyInFlight) return true;
|
|
712
712
|
await new Promise(function (r) {
|
|
713
|
-
var t = setTimeout(r, 50); //
|
|
713
|
+
var t = setTimeout(r, 50); // 50ms in-flight poll interval
|
|
714
714
|
if (t && typeof t.unref === "function") t.unref();
|
|
715
715
|
});
|
|
716
716
|
}
|
|
@@ -72,12 +72,12 @@ var BUILTIN_REGIMES = Object.freeze(["hipaa", "pci-dss", "gdpr", "soc2"]);
|
|
|
72
72
|
// SHAPE, not authenticity). Defense is a keyed MAC over the canonical
|
|
73
73
|
// envelope bytes, computed at appendHop and verified at validate.
|
|
74
74
|
var ENVELOPE_MAC_LABEL = "blamejs.agent.postureChain/v1";
|
|
75
|
-
var ENVELOPE_MAC_KEY_BYTES = 32; //
|
|
75
|
+
var ENVELOPE_MAC_KEY_BYTES = 32; // HMAC-SHA3-512 keyed bytes
|
|
76
76
|
// SUBSTRATE-21 — hop count cap defends infinite recursion across
|
|
77
77
|
// agent delegation. 16 is the spec default; operators can lower via
|
|
78
78
|
// opts.maxHopCount but never raise (audit fan-out without a cap is a
|
|
79
79
|
// DoS class).
|
|
80
|
-
var DEFAULT_MAX_HOP_COUNT = 16; //
|
|
80
|
+
var DEFAULT_MAX_HOP_COUNT = 16; // hop count cap
|
|
81
81
|
var _macKeyCache = null; // memoized per-vault-master key
|
|
82
82
|
|
|
83
83
|
function _resolveMacKey() {
|
package/lib/agent-saga.js
CHANGED
|
@@ -80,7 +80,7 @@ var audit = lazyRequire(function () { return require("./audit"); })
|
|
|
80
80
|
|
|
81
81
|
var AgentSagaError = defineClass("AgentSagaError", { alwaysPermanent: true });
|
|
82
82
|
|
|
83
|
-
var SAGA_ID_RAND_BYTES = 8; //
|
|
83
|
+
var SAGA_ID_RAND_BYTES = 8; // saga-id random-suffix byte length
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
86
|
* @primitive b.agent.saga.create
|
package/lib/agent-snapshot.js
CHANGED
|
@@ -71,7 +71,7 @@ var DEFAULT_DRAIN_TIMEOUT_MS = C.TIME.minutes(2);
|
|
|
71
71
|
var DEFAULT_SNAPSHOT_INTERVAL_MS = C.TIME.minutes(5);
|
|
72
72
|
var DEFAULT_MAX_SNAPSHOT_BYTES = C.BYTES.mib(50);
|
|
73
73
|
var SCHEMA_VERSION = 1;
|
|
74
|
-
var SNAPSHOT_ID_RAND_BYTES = 8; //
|
|
74
|
+
var SNAPSHOT_ID_RAND_BYTES = 8; // snapshot-id random suffix
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* @primitive b.agent.snapshot.create
|
package/lib/agent-stream.js
CHANGED
|
@@ -66,7 +66,7 @@ var audit = lazyRequire(function () { return require("./audit"); });
|
|
|
66
66
|
|
|
67
67
|
var AgentStreamError = defineClass("AgentStreamError", { alwaysPermanent: true });
|
|
68
68
|
|
|
69
|
-
var DEFAULT_BATCH_SIZE = 256; //
|
|
69
|
+
var DEFAULT_BATCH_SIZE = 256; // cursor batch row count, not bytes
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* @primitive b.agent.stream.create
|
package/lib/agent-tenant.js
CHANGED
|
@@ -121,7 +121,7 @@ var TENANT_KDF_LABEL = "blamejs.agent.tenant/v1";
|
|
|
121
121
|
// 32 bytes — XChaCha20-Poly1305 key length. Distinct from the audit
|
|
122
122
|
// truncation buffer so future key-length bumps don't have to chase a
|
|
123
123
|
// magic constant.
|
|
124
|
-
var TENANT_KEY_BYTES = 32; //
|
|
124
|
+
var TENANT_KEY_BYTES = 32; // XChaCha20-Poly1305 key length (256 bits)
|
|
125
125
|
|
|
126
126
|
/**
|
|
127
127
|
* @primitive b.agent.tenant.create
|
package/lib/agent-trace.js
CHANGED
|
@@ -78,7 +78,7 @@ function _emitFirstFailureAudit(auditImpl, kind, message) {
|
|
|
78
78
|
if (_failureAuditEmittedFor[kind]) return;
|
|
79
79
|
_failureAuditEmittedFor[kind] = true;
|
|
80
80
|
agentAudit.safeAudit(auditImpl, "agent.trace.tracer_failure", null, {
|
|
81
|
-
kind: kind, message: message ? String(message).slice(0, 256) : "", //
|
|
81
|
+
kind: kind, message: message ? String(message).slice(0, 256) : "", // audit-message char cap
|
|
82
82
|
rateLimited: "first-occurrence-only",
|
|
83
83
|
});
|
|
84
84
|
}
|
|
@@ -249,8 +249,8 @@ function _shouldSample(globalRate, perMethod, method, traceId) {
|
|
|
249
249
|
// Use the low 32 bits of the trace-id as the sampling roll
|
|
250
250
|
// (W3C-compatible). Hash modulo 1e9 → divide by 1e9 puts the
|
|
251
251
|
// result in [0,1) deterministically.
|
|
252
|
-
var lo = parseInt(traceId.slice(-8), 16); //
|
|
253
|
-
var roll = (lo >>> 0) / 0x100000000; //
|
|
252
|
+
var lo = parseInt(traceId.slice(-8), 16); // low 32 bits of trace-id hex
|
|
253
|
+
var roll = (lo >>> 0) / 0x100000000; // 2^32 normalization divisor
|
|
254
254
|
return roll < rate;
|
|
255
255
|
}
|
|
256
256
|
// No trace-id supplied — start of a new trace. Operators wire
|
package/lib/ai-capability.js
CHANGED
|
@@ -74,7 +74,7 @@ var REASONING_TIERS = ["none", "basic", "standard", "advanced"];
|
|
|
74
74
|
// descriptor fields are costPer1kInputTokens / costPer1kOutputTokens).
|
|
75
75
|
// Dividing a token count by this rate unit converts a per-1k rate into
|
|
76
76
|
// the per-token multiplier — a rate denominator, not a byte size.
|
|
77
|
-
var COST_RATE_TOKEN_UNIT = 1000; //
|
|
77
|
+
var COST_RATE_TOKEN_UNIT = 1000; // per-1k-token cost-rate denominator, not a byte count
|
|
78
78
|
|
|
79
79
|
var DESCRIPTOR_KEYS = [
|
|
80
80
|
"maxContextTokens", "maxOutputTokens", "modalitiesIn", "modalitiesOut",
|
package/lib/ai-dp.js
CHANGED
|
@@ -73,7 +73,7 @@ var ACCOUNTINGS = ["basic", "rdp"];
|
|
|
73
73
|
// integer-exact discrete-Gaussian sampler. 2^32 keeps the deviation
|
|
74
74
|
// from the target σ² below 2^-32 — far under the noise scale — while
|
|
75
75
|
// keeping the BigInt denominators bounded.
|
|
76
|
-
var SIGMA2_RATIONAL_DEN = 4294967296; //
|
|
76
|
+
var SIGMA2_RATIONAL_DEN = 4294967296; // 2^32 rational-approx denominator, not a byte size
|
|
77
77
|
|
|
78
78
|
// ---- Minimal exact rational (BigInt num / den, den > 0) ----
|
|
79
79
|
|
|
@@ -105,7 +105,7 @@ function _uniformBelow(m) {
|
|
|
105
105
|
if (m <= 0n) throw new AiDpError("ai-dp/internal", "ai.dp: _uniformBelow needs m > 0");
|
|
106
106
|
if (m === 1n) return 0n;
|
|
107
107
|
var bits = m.toString(2).length;
|
|
108
|
-
var bytes = Math.ceil(bits / 8); //
|
|
108
|
+
var bytes = Math.ceil(bits / 8); // bits-per-byte divisor, not a size
|
|
109
109
|
var mask = (1n << BigInt(bits)) - 1n;
|
|
110
110
|
for (;;) {
|
|
111
111
|
var buf = bCrypto.generateBytes(bytes);
|
|
@@ -121,7 +121,7 @@ function _uniformBelow(m) {
|
|
|
121
121
|
// the BigInt rejection sampler (accumulating 53 bits in a JS Number
|
|
122
122
|
// would overflow the 2^53 safe-integer range and skew the draw), then
|
|
123
123
|
// mapped (val + 1) / 2^53 → (0, 1].
|
|
124
|
-
var TWO_POW_53 = 9007199254740992; //
|
|
124
|
+
var TWO_POW_53 = 9007199254740992; // 2^53 mantissa range, not a byte size
|
|
125
125
|
function _uniformOpen() {
|
|
126
126
|
var v = Number(_uniformBelow(9007199254740992n)); // [0, 2^53) exact
|
|
127
127
|
return (v + 1) / TWO_POW_53; // (0, 1]
|
|
@@ -231,7 +231,7 @@ function _snappingLaplace(value, scale, bound) {
|
|
|
231
231
|
|
|
232
232
|
// ---- Rényi-DP costs (Mironov 2017) ----
|
|
233
233
|
|
|
234
|
-
var RDP_ORDERS = [1.25, 1.5, 1.75, 2, 2.5, 3, 4, 5, 6, 8, 12, 16, 24, 32, 48, 64, 128, 256]; //
|
|
234
|
+
var RDP_ORDERS = [1.25, 1.5, 1.75, 2, 2.5, 3, 4, 5, 6, 8, 12, 16, 24, 32, 48, 64, 128, 256]; // Rényi DP orders (α), not byte sizes
|
|
235
235
|
|
|
236
236
|
// Gaussian mechanism with noise-to-sensitivity z = sigma / sensitivity:
|
|
237
237
|
// RDP(alpha) = alpha / (2 z^2).
|
package/lib/ai-input.js
CHANGED
|
@@ -25,7 +25,7 @@ var numericBounds = require("./numeric-bounds");
|
|
|
25
25
|
var audit = require("./audit");
|
|
26
26
|
var { AiInputError } = require("./framework-error");
|
|
27
27
|
|
|
28
|
-
var SAMPLE_TRUNC = 80; //
|
|
28
|
+
var SAMPLE_TRUNC = 80; // sample truncation length, not bytes
|
|
29
29
|
var CONFIDENCE_BASE = 60; // allow:raw-byte-literal — confidence percentage base / allow:raw-time-literal — not seconds
|
|
30
30
|
|
|
31
31
|
var PATTERNS = [
|
|
@@ -44,7 +44,7 @@ var PATTERNS = [
|
|
|
44
44
|
{ id: "exfil-callback", severity: 3, re:
|
|
45
45
|
/\b(?:send|post|fetch|exfil|leak|paste|forward)\b[\s\S]{0,40}(?:secret|key|token|password|cred|env|\.ssh|private)/i },
|
|
46
46
|
{ id: "base64-marker-around-instructions", severity: 2, re:
|
|
47
|
-
/(?:[A-Za-z0-9+/]{40,}={0,2})\s+(?:means|decodes?\s+to|=)/i }, //
|
|
47
|
+
/(?:[A-Za-z0-9+/]{40,}={0,2})\s+(?:means|decodes?\s+to|=)/i }, // regex repetition floor, not bytes
|
|
48
48
|
{ id: "rot13-shape", severity: 2, re:
|
|
49
49
|
/\b(?:rot13|rotcipher|cipher|caesar)\s*[:=]\s*[a-zA-Z]{20,}/i },
|
|
50
50
|
{ id: "markdown-injection", severity: 2, re:
|
|
@@ -138,7 +138,7 @@ function classify(input, opts) {
|
|
|
138
138
|
else if (signals[j].severity === 2) sev2++;
|
|
139
139
|
}
|
|
140
140
|
var verdict = sev3 > 0 ? "malicious" : (sev2 >= 2 ? "suspicious" : "clean");
|
|
141
|
-
var confidence = sev3 === 0 && sev2 === 0 ? 0 : Math.min(100, CONFIDENCE_BASE + sev3 * 15 + sev2 * 5); //
|
|
141
|
+
var confidence = sev3 === 0 && sev2 === 0 ? 0 : Math.min(100, CONFIDENCE_BASE + sev3 * 15 + sev2 * 5); // confidence ceiling 100, not bytes/seconds
|
|
142
142
|
|
|
143
143
|
if (auditOn && verdict !== "clean") {
|
|
144
144
|
audit.safeEmit({
|
package/lib/ai-model-manifest.js
CHANGED
|
@@ -50,7 +50,7 @@ var VALID_DATA_TYPES = Object.freeze({
|
|
|
50
50
|
patch: true, platform: true, "test-case": true,
|
|
51
51
|
});
|
|
52
52
|
var ISO8601_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/; // allow:duplicate-regex — ISO-8601 instant shape ships in three primitives (metrics text-render, content-credentials, mail-server-imap APPEND); each is bounded by its own caller and the regex itself is 50 bytes — extracting into a cross-module dep wouldn't carry its weight
|
|
53
|
-
var BOM_REF_RE = /^[A-Za-z0-9._:/+-]{1,256}$/; //
|
|
53
|
+
var BOM_REF_RE = /^[A-Za-z0-9._:/+-]{1,256}$/; // CycloneDX bom-ref string-length cap, not bytes
|
|
54
54
|
|
|
55
55
|
function _requireString(obj, key, ownerName) {
|
|
56
56
|
if (typeof obj[key] !== "string" || obj[key].length === 0) {
|
|
@@ -67,7 +67,7 @@ function _validateModelComponent(c) {
|
|
|
67
67
|
_requireString(c, "name", "build.model");
|
|
68
68
|
_requireString(c, "version", "build.model");
|
|
69
69
|
if (c["bom-ref"] !== undefined) {
|
|
70
|
-
if (typeof c["bom-ref"] !== "string" || c["bom-ref"].length > 256) { //
|
|
70
|
+
if (typeof c["bom-ref"] !== "string" || c["bom-ref"].length > 256) { // bom-ref string-length cap, not bytes
|
|
71
71
|
throw new AiModelManifestError("aibom/bad-bom-ref",
|
|
72
72
|
"build.model: bom-ref must be a string of length 1-256");
|
|
73
73
|
}
|
|
@@ -332,12 +332,12 @@ function verify(envelope, publicKeyPem, opts) {
|
|
|
332
332
|
// UUIDv4 via the framework's CSPRNG path. Used for `serialNumber`
|
|
333
333
|
// defaults — operators may supply their own for cross-build stability.
|
|
334
334
|
function _uuidUrn() {
|
|
335
|
-
var b = bCrypto.generateBytes(16); //
|
|
336
|
-
b[6] = (b[6] & 0x0f) | 0x40; //
|
|
337
|
-
b[8] = (b[8] & 0x3f) | 0x80; //
|
|
335
|
+
var b = bCrypto.generateBytes(16); // RFC 9562 §4.1 UUIDv4 is a 16-byte (128-bit) primitive
|
|
336
|
+
b[6] = (b[6] & 0x0f) | 0x40; // UUIDv4 version nibble (RFC 9562 §4.4)
|
|
337
|
+
b[8] = (b[8] & 0x3f) | 0x80; // UUIDv4 variant nibble (RFC 9562 §4.4)
|
|
338
338
|
var h = b.toString("hex");
|
|
339
|
-
return "urn:uuid:" + h.slice(0, 8) + "-" + h.slice(8, 12) + "-" + //
|
|
340
|
-
h.slice(12, 16) + "-" + h.slice(16, 20) + "-" + h.slice(20); //
|
|
339
|
+
return "urn:uuid:" + h.slice(0, 8) + "-" + h.slice(8, 12) + "-" + // RFC 9562 §4 UUID text representation hex offsets (8-4-4-4-12)
|
|
340
|
+
h.slice(12, 16) + "-" + h.slice(16, 20) + "-" + h.slice(20); // RFC 9562 §4 UUID hex offsets
|
|
341
341
|
}
|
|
342
342
|
|
|
343
343
|
// package.json read lives behind the call to dodge a circular-load
|
package/lib/ai-pref.js
CHANGED
|
@@ -142,7 +142,7 @@ function parseHeader(value) {
|
|
|
142
142
|
if (typeof value !== "string" || value.length === 0) {
|
|
143
143
|
throw AiPrefError.factory("ai-pref/bad-header", "aiPref.parseHeader: value required");
|
|
144
144
|
}
|
|
145
|
-
if (value.length > 1024) { //
|
|
145
|
+
if (value.length > 1024) { // header value cap, not bytes
|
|
146
146
|
throw AiPrefError.factory("ai-pref/header-too-large",
|
|
147
147
|
"aiPref.parseHeader: value exceeds 1024 chars");
|
|
148
148
|
}
|
|
@@ -205,7 +205,7 @@ function parseHeader(value) {
|
|
|
205
205
|
function robotsBlock(opts) {
|
|
206
206
|
var v = _validate(opts);
|
|
207
207
|
var ua = opts.userAgent || "*";
|
|
208
|
-
if (typeof ua !== "string" || ua.length === 0 || ua.length > 256) { //
|
|
208
|
+
if (typeof ua !== "string" || ua.length === 0 || ua.length > 256) { // UA-string cap, not bytes
|
|
209
209
|
throw AiPrefError.factory("ai-pref/bad-user-agent",
|
|
210
210
|
"aiPref.robotsBlock: userAgent must be 1-256 char string (or omit for *)");
|
|
211
211
|
}
|
|
@@ -314,7 +314,7 @@ function refusePaidCrawl(req, res, opts) {
|
|
|
314
314
|
res.setHeader("Content-Type", "application/json");
|
|
315
315
|
res.setHeader("Cache-Control", "no-store");
|
|
316
316
|
}
|
|
317
|
-
res.statusCode = 402; //
|
|
317
|
+
res.statusCode = 402; // HTTP 402 Payment Required (RFC 9110)
|
|
318
318
|
res.end(body);
|
|
319
319
|
audit.safeEmit({
|
|
320
320
|
action: "aipref.paid_crawl_refused",
|
package/lib/archive-gz.js
CHANGED
|
@@ -25,8 +25,8 @@ var archiveRead = lazyRequire(function () { return require("./archive-read"); })
|
|
|
25
25
|
var archiveTarRead = lazyRequire(function () { return require("./archive-tar-read"); });
|
|
26
26
|
|
|
27
27
|
// gzip magic — RFC 1952 §2.2 ("ID1=0x1f, ID2=0x8b").
|
|
28
|
-
var GZIP_MAGIC_0 = 0x1f; //
|
|
29
|
-
var GZIP_MAGIC_1 = 0x8b; //
|
|
28
|
+
var GZIP_MAGIC_0 = 0x1f; // RFC 1952 §2.2 ID1
|
|
29
|
+
var GZIP_MAGIC_1 = 0x8b; // RFC 1952 §2.2 ID2
|
|
30
30
|
|
|
31
31
|
var DEFAULT_MAX_OUTPUT_BYTES = C.BYTES.gib(1);
|
|
32
32
|
var DEFAULT_MAX_RATIO = 100;
|