@adcp/sdk 17.0.0-beta.24 → 17.0.0-beta.25

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 (51) hide show
  1. package/dist/lib/adapters/version/schema-projection.d.mts +11 -0
  2. package/dist/lib/adapters/version/schema-projection.d.ts +11 -0
  3. package/dist/lib/adapters/version/schema-projection.js +52 -0
  4. package/dist/lib/adapters/version/schema-projection.mjs +51 -0
  5. package/dist/lib/reporting/evidence.d.mts +8 -0
  6. package/dist/lib/reporting/evidence.d.ts +8 -0
  7. package/dist/lib/reporting/evidence.js +10 -2
  8. package/dist/lib/reporting/evidence.mjs +8 -1
  9. package/dist/lib/reporting/ledger/index.d.mts +1 -1
  10. package/dist/lib/reporting/ledger/index.d.ts +1 -1
  11. package/dist/lib/reporting/ledger/index.js +3 -1
  12. package/dist/lib/reporting/ledger/index.mjs +4 -2
  13. package/dist/lib/reporting/ledger/status-ingest.js +3 -2
  14. package/dist/lib/reporting/ledger/status-ingest.mjs +3 -2
  15. package/dist/lib/reporting/subscriptions/engine.js +1 -1
  16. package/dist/lib/reporting/subscriptions/engine.mjs +1 -1
  17. package/dist/lib/server/account-response-identity.d.mts +4 -3
  18. package/dist/lib/server/account-response-identity.d.ts +4 -3
  19. package/dist/lib/server/account-response-identity.js +8 -4
  20. package/dist/lib/server/account-response-identity.mjs +8 -4
  21. package/dist/lib/server/credential-policy.js +5 -0
  22. package/dist/lib/server/credential-policy.mjs +5 -0
  23. package/dist/lib/server/decisioning/account.js +14 -3
  24. package/dist/lib/server/decisioning/account.mjs +16 -4
  25. package/dist/lib/server/notification-subscriptions/runtime.d.mts +6 -0
  26. package/dist/lib/server/notification-subscriptions/runtime.d.ts +6 -0
  27. package/dist/lib/server/notification-subscriptions/runtime.js +99 -0
  28. package/dist/lib/server/notification-subscriptions/runtime.mjs +98 -0
  29. package/dist/lib/server/principal/reporting-subscriptions.js +4 -1
  30. package/dist/lib/server/principal/reporting-subscriptions.mjs +4 -1
  31. package/dist/lib/server/reporting-delivery-config.d.mts +2 -2
  32. package/dist/lib/server/reporting-delivery-config.d.ts +2 -2
  33. package/dist/lib/server/reporting-delivery-config.js +9 -3
  34. package/dist/lib/server/reporting-delivery-config.mjs +9 -3
  35. package/dist/lib/server/wire-safe.js +3 -0
  36. package/dist/lib/server/wire-safe.mjs +3 -0
  37. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  38. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  39. package/dist/lib/utils/json-depth.d.mts +8 -0
  40. package/dist/lib/utils/json-depth.d.ts +8 -0
  41. package/dist/lib/utils/json-depth.js +18 -2
  42. package/dist/lib/utils/json-depth.mjs +16 -1
  43. package/dist/lib/version.d.mts +3 -3
  44. package/dist/lib/version.d.ts +3 -3
  45. package/dist/lib/version.js +3 -3
  46. package/dist/lib/version.mjs +3 -3
  47. package/docs/TYPE-SUMMARY.md +2 -2
  48. package/docs/llms.txt +2 -2
  49. package/docs/migration-14.x-rc-worksheet.md +4 -4
  50. package/docs/migration-16-to-17.md +22 -8
  51. package/package.json +1 -1
@@ -29,5 +29,16 @@ export interface ProjectionResult<T = unknown> {
29
29
  * nothing needs removing or when either release has no schema for the tool.
30
30
  */
31
31
  export declare function projectToolPayload<T>(toolName: string, direction: Direction, payload: T, fromVersion: string, toVersion: string): ProjectionResult<T>;
32
+ /**
33
+ * Remove every member the schema at `schemaRef` does not declare, at any depth.
34
+ * Declared free-form maps (objects whose schema declares no properties, such as
35
+ * `ext`) keep their contents, and a typed `additionalProperties` schema
36
+ * declares its keys; the boolean `additionalProperties: true` of an open object
37
+ * declares nothing. Used where AdCP 3.3.0-beta.6 opened schemas
38
+ * (adcontextprotocol/adcp#8866) that the SDK relied on to keep undeclared data
39
+ * out. Throws when the schema is unavailable or the value is deeper than the
40
+ * projection bound.
41
+ */
42
+ export declare function projectToDeclaredMembers<T>(schemaRef: string, value: T, version?: string): ProjectionResult<T>;
32
43
  /** Whether the release's schema bundle defines a request schema for the tool. */
33
44
  export declare function releaseDefinesTool(toolName: string, version: string): boolean;
@@ -29,5 +29,16 @@ export interface ProjectionResult<T = unknown> {
29
29
  * nothing needs removing or when either release has no schema for the tool.
30
30
  */
31
31
  export declare function projectToolPayload<T>(toolName: string, direction: Direction, payload: T, fromVersion: string, toVersion: string): ProjectionResult<T>;
32
+ /**
33
+ * Remove every member the schema at `schemaRef` does not declare, at any depth.
34
+ * Declared free-form maps (objects whose schema declares no properties, such as
35
+ * `ext`) keep their contents, and a typed `additionalProperties` schema
36
+ * declares its keys; the boolean `additionalProperties: true` of an open object
37
+ * declares nothing. Used where AdCP 3.3.0-beta.6 opened schemas
38
+ * (adcontextprotocol/adcp#8866) that the SDK relied on to keep undeclared data
39
+ * out. Throws when the schema is unavailable or the value is deeper than the
40
+ * projection bound.
41
+ */
42
+ export declare function projectToDeclaredMembers<T>(schemaRef: string, value: T, version?: string): ProjectionResult<T>;
32
43
  /** Whether the release's schema bundle defines a request schema for the tool. */
33
44
  export declare function releaseDefinesTool(toolName: string, version: string): boolean;
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var schema_projection_exports = {};
20
20
  __export(schema_projection_exports, {
21
+ projectToDeclaredMembers: () => projectToDeclaredMembers,
21
22
  projectToolPayload: () => projectToolPayload,
22
23
  releaseDefinesTool: () => releaseDefinesTool
23
24
  });
@@ -284,6 +285,56 @@ function projectToolPayload(toolName, direction, payload, fromVersion, toVersion
284
285
  const projected = project(payload, [source], [target], "", dropped, 0, envelopeKeys(toVersion));
285
286
  return { value: projected === OMIT ? payload : projected, dropped };
286
287
  }
288
+ function typesObject(schema) {
289
+ return schema.type === "object" || Array.isArray(schema.type) && schema.type.includes("object");
290
+ }
291
+ function keepDeclared(value, nodes, path, dropped, depth) {
292
+ if (depth > MAX_DEPTH) throw new RangeError("Value exceeds the maximum schema projection depth");
293
+ const expanded = nodes.flatMap((node) => expand(node, value, depth).nodes);
294
+ if (expanded.some((node) => typeof node.schema.$ref === "string")) {
295
+ throw new Error("Declared-member projection could not resolve a schema reference");
296
+ }
297
+ if (Array.isArray(value)) {
298
+ const items = expanded.map((node) => child(node, node.schema.items)).filter((n) => !!n);
299
+ if (items.length === 0) return value;
300
+ let changed2 = false;
301
+ const out2 = value.map((item, index2) => {
302
+ const projected = keepDeclared(item, items, `${path}[${index2}]`, dropped, depth + 1);
303
+ if (projected !== item) changed2 = true;
304
+ return projected;
305
+ });
306
+ return changed2 ? out2 : value;
307
+ }
308
+ if (!isObject(value)) return value;
309
+ const index = indexProperties(expanded);
310
+ if (!index.declares && expanded.some((node) => typesObject(node.schema))) return value;
311
+ let changed = false;
312
+ const out = {};
313
+ for (const [key, entry] of Object.entries(value)) {
314
+ const entryPath = joinPath(path, key);
315
+ const schemas = schemasForKey(index, key) ?? nonEmpty(index.additional);
316
+ if (!schemas) {
317
+ dropped.push({ path: entryPath, kind: "field" });
318
+ changed = true;
319
+ continue;
320
+ }
321
+ const projected = keepDeclared(entry, schemas, entryPath, dropped, depth + 1);
322
+ if (projected !== entry) changed = true;
323
+ out[key] = projected;
324
+ }
325
+ return changed ? out : value;
326
+ }
327
+ function projectToDeclaredMembers(schemaRef, value, version) {
328
+ const document = (0, import_schema_loader.getSchemaDocumentByRef)(schemaRef, version);
329
+ if (!document) throw new Error(`Schema unavailable for declared-member projection: ${schemaRef}`);
330
+ const root = document.schema;
331
+ const node = {
332
+ schema: root,
333
+ doc: { root, base: absoluteBase(root.$id), version: version ?? document.resolvedVersion }
334
+ };
335
+ const dropped = [];
336
+ return { value: keepDeclared(value, [node], "", dropped, 0), dropped };
337
+ }
287
338
  const NO_PROTECTED_KEYS = /* @__PURE__ */ new Set();
288
339
  const BASELINE_ENVELOPE_KEYS = [
289
340
  "adcp_error",
@@ -324,6 +375,7 @@ function releaseDefinesTool(toolName, version) {
324
375
  }
325
376
  // Annotate the CommonJS export names for ESM import in node:
326
377
  0 && (module.exports = {
378
+ projectToDeclaredMembers,
327
379
  projectToolPayload,
328
380
  releaseDefinesTool
329
381
  });
@@ -260,6 +260,56 @@ function projectToolPayload(toolName, direction, payload, fromVersion, toVersion
260
260
  const projected = project(payload, [source], [target], "", dropped, 0, envelopeKeys(toVersion));
261
261
  return { value: projected === OMIT ? payload : projected, dropped };
262
262
  }
263
+ function typesObject(schema) {
264
+ return schema.type === "object" || Array.isArray(schema.type) && schema.type.includes("object");
265
+ }
266
+ function keepDeclared(value, nodes, path, dropped, depth) {
267
+ if (depth > MAX_DEPTH) throw new RangeError("Value exceeds the maximum schema projection depth");
268
+ const expanded = nodes.flatMap((node) => expand(node, value, depth).nodes);
269
+ if (expanded.some((node) => typeof node.schema.$ref === "string")) {
270
+ throw new Error("Declared-member projection could not resolve a schema reference");
271
+ }
272
+ if (Array.isArray(value)) {
273
+ const items = expanded.map((node) => child(node, node.schema.items)).filter((n) => !!n);
274
+ if (items.length === 0) return value;
275
+ let changed2 = false;
276
+ const out2 = value.map((item, index2) => {
277
+ const projected = keepDeclared(item, items, `${path}[${index2}]`, dropped, depth + 1);
278
+ if (projected !== item) changed2 = true;
279
+ return projected;
280
+ });
281
+ return changed2 ? out2 : value;
282
+ }
283
+ if (!isObject(value)) return value;
284
+ const index = indexProperties(expanded);
285
+ if (!index.declares && expanded.some((node) => typesObject(node.schema))) return value;
286
+ let changed = false;
287
+ const out = {};
288
+ for (const [key, entry] of Object.entries(value)) {
289
+ const entryPath = joinPath(path, key);
290
+ const schemas = schemasForKey(index, key) ?? nonEmpty(index.additional);
291
+ if (!schemas) {
292
+ dropped.push({ path: entryPath, kind: "field" });
293
+ changed = true;
294
+ continue;
295
+ }
296
+ const projected = keepDeclared(entry, schemas, entryPath, dropped, depth + 1);
297
+ if (projected !== entry) changed = true;
298
+ out[key] = projected;
299
+ }
300
+ return changed ? out : value;
301
+ }
302
+ function projectToDeclaredMembers(schemaRef, value, version) {
303
+ const document = getSchemaDocumentByRef(schemaRef, version);
304
+ if (!document) throw new Error(`Schema unavailable for declared-member projection: ${schemaRef}`);
305
+ const root = document.schema;
306
+ const node = {
307
+ schema: root,
308
+ doc: { root, base: absoluteBase(root.$id), version: version ?? document.resolvedVersion }
309
+ };
310
+ const dropped = [];
311
+ return { value: keepDeclared(value, [node], "", dropped, 0), dropped };
312
+ }
263
313
  const NO_PROTECTED_KEYS = /* @__PURE__ */ new Set();
264
314
  const BASELINE_ENVELOPE_KEYS = [
265
315
  "adcp_error",
@@ -299,6 +349,7 @@ function releaseDefinesTool(toolName, version) {
299
349
  }
300
350
  }
301
351
  export {
352
+ projectToDeclaredMembers,
302
353
  projectToolPayload,
303
354
  releaseDefinesTool
304
355
  };
@@ -3,3 +3,11 @@ export declare function isReportingCanonicalDigest(value: unknown): boolean;
3
3
  export declare function isReportingVerificationEvidence(value: unknown): boolean;
4
4
  export declare function isReportingReceiptEvidence(value: unknown): boolean;
5
5
  export declare function isReportingAdjustmentReceiptEvidence(value: unknown): boolean;
6
+ /**
7
+ * JSON paths of members a materialization carries, at any depth, that its
8
+ * bundled schema does not declare. AdCP 3.3.0-beta.6 opened these schemas
9
+ * (adcontextprotocol/adcp#8866), so schema validation alone now accepts them; a
10
+ * store or managed runtime refuses evidence that reports any, as it did while
11
+ * the schemas were closed.
12
+ */
13
+ export declare function undeclaredReportingMaterializationMembers(materialization: unknown): string[];
@@ -3,3 +3,11 @@ export declare function isReportingCanonicalDigest(value: unknown): boolean;
3
3
  export declare function isReportingVerificationEvidence(value: unknown): boolean;
4
4
  export declare function isReportingReceiptEvidence(value: unknown): boolean;
5
5
  export declare function isReportingAdjustmentReceiptEvidence(value: unknown): boolean;
6
+ /**
7
+ * JSON paths of members a materialization carries, at any depth, that its
8
+ * bundled schema does not declare. AdCP 3.3.0-beta.6 opened these schemas
9
+ * (adcontextprotocol/adcp#8866), so schema validation alone now accepts them; a
10
+ * store or managed runtime refuses evidence that reports any, as it did while
11
+ * the schemas were closed.
12
+ */
13
+ export declare function undeclaredReportingMaterializationMembers(materialization: unknown): string[];
@@ -22,9 +22,11 @@ __export(evidence_exports, {
22
22
  isReportingCanonicalDigest: () => isReportingCanonicalDigest,
23
23
  isReportingControlTotals: () => isReportingControlTotals,
24
24
  isReportingReceiptEvidence: () => isReportingReceiptEvidence,
25
- isReportingVerificationEvidence: () => isReportingVerificationEvidence
25
+ isReportingVerificationEvidence: () => isReportingVerificationEvidence,
26
+ undeclaredReportingMaterializationMembers: () => undeclaredReportingMaterializationMembers
26
27
  });
27
28
  module.exports = __toCommonJS(evidence_exports);
29
+ var import_schema_projection = require('../adapters/version/schema-projection.js');
28
30
  const CONTROL_TOTAL_NAME = /^[A-Za-z][A-Za-z0-9_.:-]{0,127}$/;
29
31
  const CANONICAL_DECIMAL = /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$/;
30
32
  const SHA256_HEX = /^[A-Fa-f0-9]{64}$/;
@@ -155,11 +157,17 @@ function isReportingAdjustmentReceiptEvidence(value) {
155
157
  if (value.status === "accepted") return value.rejection_codes === void 0;
156
158
  return Array.isArray(value.rejection_codes) && value.rejection_codes.length > 0 && new Set(value.rejection_codes).size === value.rejection_codes.length && value.rejection_codes.every((code) => typeof code === "string" && /^[A-Z][A-Z0-9_]{0,127}$/.test(code));
157
159
  }
160
+ function undeclaredReportingMaterializationMembers(materialization) {
161
+ return (0, import_schema_projection.projectToDeclaredMembers)("core/reporting-materialization.json", materialization).dropped.map(
162
+ (drop) => drop.path
163
+ );
164
+ }
158
165
  // Annotate the CommonJS export names for ESM import in node:
159
166
  0 && (module.exports = {
160
167
  isReportingAdjustmentReceiptEvidence,
161
168
  isReportingCanonicalDigest,
162
169
  isReportingControlTotals,
163
170
  isReportingReceiptEvidence,
164
- isReportingVerificationEvidence
171
+ isReportingVerificationEvidence,
172
+ undeclaredReportingMaterializationMembers
165
173
  });
@@ -1,3 +1,4 @@
1
+ import { projectToDeclaredMembers } from "../adapters/version/schema-projection.mjs";
1
2
  const CONTROL_TOTAL_NAME = /^[A-Za-z][A-Za-z0-9_.:-]{0,127}$/;
2
3
  const CANONICAL_DECIMAL = /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$/;
3
4
  const SHA256_HEX = /^[A-Fa-f0-9]{64}$/;
@@ -128,10 +129,16 @@ function isReportingAdjustmentReceiptEvidence(value) {
128
129
  if (value.status === "accepted") return value.rejection_codes === void 0;
129
130
  return Array.isArray(value.rejection_codes) && value.rejection_codes.length > 0 && new Set(value.rejection_codes).size === value.rejection_codes.length && value.rejection_codes.every((code) => typeof code === "string" && /^[A-Z][A-Z0-9_]{0,127}$/.test(code));
130
131
  }
132
+ function undeclaredReportingMaterializationMembers(materialization) {
133
+ return projectToDeclaredMembers("core/reporting-materialization.json", materialization).dropped.map(
134
+ (drop) => drop.path
135
+ );
136
+ }
131
137
  export {
132
138
  isReportingAdjustmentReceiptEvidence,
133
139
  isReportingCanonicalDigest,
134
140
  isReportingControlTotals,
135
141
  isReportingReceiptEvidence,
136
- isReportingVerificationEvidence
142
+ isReportingVerificationEvidence,
143
+ undeclaredReportingMaterializationMembers
137
144
  };
@@ -30,5 +30,5 @@ export * from './offering-validation.mjs';
30
30
  export * from './issue-events.mjs';
31
31
  export { compareReportingInstants } from './instant.mjs';
32
32
  export { isFrozenCalendarRulesMismatch, reportingPeriodDate, reportingPeriodSchedule } from './schedule.mjs';
33
- export { isReportingAdjustmentReceiptEvidence, isReportingReceiptEvidence, isReportingVerificationEvidence, } from '../evidence.mjs';
33
+ export { isReportingAdjustmentReceiptEvidence, isReportingReceiptEvidence, isReportingVerificationEvidence, undeclaredReportingMaterializationMembers, } from '../evidence.mjs';
34
34
  export { isWellFormedUnicodeString } from '../../utils/well-formed-unicode.mjs';
@@ -30,5 +30,5 @@ export * from './offering-validation';
30
30
  export * from './issue-events';
31
31
  export { compareReportingInstants } from './instant';
32
32
  export { isFrozenCalendarRulesMismatch, reportingPeriodDate, reportingPeriodSchedule } from './schedule';
33
- export { isReportingAdjustmentReceiptEvidence, isReportingReceiptEvidence, isReportingVerificationEvidence, } from '../evidence';
33
+ export { isReportingAdjustmentReceiptEvidence, isReportingReceiptEvidence, isReportingVerificationEvidence, undeclaredReportingMaterializationMembers, } from '../evidence';
34
34
  export { isWellFormedUnicodeString } from '../../utils/well-formed-unicode';
@@ -26,7 +26,8 @@ __export(ledger_exports, {
26
26
  isReportingVerificationEvidence: () => import_evidence.isReportingVerificationEvidence,
27
27
  isWellFormedUnicodeString: () => import_well_formed_unicode.isWellFormedUnicodeString,
28
28
  reportingPeriodDate: () => import_schedule.reportingPeriodDate,
29
- reportingPeriodSchedule: () => import_schedule.reportingPeriodSchedule
29
+ reportingPeriodSchedule: () => import_schedule.reportingPeriodSchedule,
30
+ undeclaredReportingMaterializationMembers: () => import_evidence.undeclaredReportingMaterializationMembers
30
31
  });
31
32
  module.exports = __toCommonJS(ledger_exports);
32
33
  __reExport(ledger_exports, require('./types.js'), module.exports);
@@ -56,6 +57,7 @@ var import_well_formed_unicode = require('../../utils/well-formed-unicode.js');
56
57
  isWellFormedUnicodeString,
57
58
  reportingPeriodDate,
58
59
  reportingPeriodSchedule,
60
+ undeclaredReportingMaterializationMembers,
59
61
  ...require('./types.js'),
60
62
  ...require('./health.js'),
61
63
  ...require('./coverage.js'),
@@ -16,7 +16,8 @@ import { isFrozenCalendarRulesMismatch, reportingPeriodDate, reportingPeriodSche
16
16
  import {
17
17
  isReportingAdjustmentReceiptEvidence,
18
18
  isReportingReceiptEvidence,
19
- isReportingVerificationEvidence
19
+ isReportingVerificationEvidence,
20
+ undeclaredReportingMaterializationMembers
20
21
  } from "../evidence.mjs";
21
22
  import { isWellFormedUnicodeString } from "../../utils/well-formed-unicode.mjs";
22
23
  export {
@@ -27,5 +28,6 @@ export {
27
28
  isReportingVerificationEvidence,
28
29
  isWellFormedUnicodeString,
29
30
  reportingPeriodDate,
30
- reportingPeriodSchedule
31
+ reportingPeriodSchedule,
32
+ undeclaredReportingMaterializationMembers
31
33
  };
@@ -493,7 +493,7 @@ function boundedRecovery(value) {
493
493
  return value === "transient" || value === "correctable" || value === "terminal" ? value : void 0;
494
494
  }
495
495
  function boundedErrorField(value) {
496
- return typeof value === "string" && !value.includes("\0") && (0, import_well_formed_unicode.isWellFormedUnicodeString)(value) && Buffer.byteLength(value, "utf8") <= import_types.REPORTING_CONSUMER_STATUS_ERROR_FIELD_MAX_BYTES ? value : void 0;
496
+ return typeof value === "string" && !CONTROL_CHARACTER.test(value) && (0, import_well_formed_unicode.isWellFormedUnicodeString)(value) && Buffer.byteLength(value, "utf8") <= import_types.REPORTING_CONSUMER_STATUS_ERROR_FIELD_MAX_BYTES ? value : void 0;
497
497
  }
498
498
  function boundedErrorKeyword(value) {
499
499
  return typeof value === "string" && /^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(value) ? value : void 0;
@@ -536,11 +536,12 @@ function requestStatusIds(value) {
536
536
  const statuses = isRecord(value) && Array.isArray(value.statuses) ? value.statuses : [];
537
537
  return statuses.length > 0 && statuses.length <= 100 ? statuses.map(reportingStatusId) : ["invalid-reporting-status-id"];
538
538
  }
539
+ const CONTROL_CHARACTER = /[\u0000-\u001f\u007f-\u009f\u2028\u2029]/;
539
540
  function zodPathToPointer(path) {
540
541
  let pointer = "";
541
542
  for (const value of path) {
542
543
  const raw = String(value);
543
- if (raw.includes("\0") || !(0, import_well_formed_unicode.isWellFormedUnicodeString)(raw)) return void 0;
544
+ if (CONTROL_CHARACTER.test(raw) || !(0, import_well_formed_unicode.isWellFormedUnicodeString)(raw)) return void 0;
544
545
  if (Buffer.byteLength(raw, "utf8") > import_types.REPORTING_CONSUMER_STATUS_ERROR_FIELD_MAX_BYTES) return void 0;
545
546
  const segment = raw.replace(/~/g, "~0").replace(/\//g, "~1");
546
547
  const next = `${pointer}/${segment}`;
@@ -490,7 +490,7 @@ function boundedRecovery(value) {
490
490
  return value === "transient" || value === "correctable" || value === "terminal" ? value : void 0;
491
491
  }
492
492
  function boundedErrorField(value) {
493
- return typeof value === "string" && !value.includes("\0") && isWellFormedUnicodeString(value) && Buffer.byteLength(value, "utf8") <= REPORTING_CONSUMER_STATUS_ERROR_FIELD_MAX_BYTES ? value : void 0;
493
+ return typeof value === "string" && !CONTROL_CHARACTER.test(value) && isWellFormedUnicodeString(value) && Buffer.byteLength(value, "utf8") <= REPORTING_CONSUMER_STATUS_ERROR_FIELD_MAX_BYTES ? value : void 0;
494
494
  }
495
495
  function boundedErrorKeyword(value) {
496
496
  return typeof value === "string" && /^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(value) ? value : void 0;
@@ -533,11 +533,12 @@ function requestStatusIds(value) {
533
533
  const statuses = isRecord(value) && Array.isArray(value.statuses) ? value.statuses : [];
534
534
  return statuses.length > 0 && statuses.length <= 100 ? statuses.map(reportingStatusId) : ["invalid-reporting-status-id"];
535
535
  }
536
+ const CONTROL_CHARACTER = /[\u0000-\u001f\u007f-\u009f\u2028\u2029]/;
536
537
  function zodPathToPointer(path) {
537
538
  let pointer = "";
538
539
  for (const value of path) {
539
540
  const raw = String(value);
540
- if (raw.includes("\0") || !isWellFormedUnicodeString(raw)) return void 0;
541
+ if (CONTROL_CHARACTER.test(raw) || !isWellFormedUnicodeString(raw)) return void 0;
541
542
  if (Buffer.byteLength(raw, "utf8") > REPORTING_CONSUMER_STATUS_ERROR_FIELD_MAX_BYTES) return void 0;
542
543
  const segment = raw.replace(/~/g, "~0").replace(/\//g, "~1");
543
544
  const next = `${pointer}/${segment}`;
@@ -81,7 +81,7 @@ function membershipOf(version, accountId) {
81
81
  const configuration = version.configuration;
82
82
  const edits = (version.membershipEdits ?? []).filter((edit) => edit.accountId === accountId);
83
83
  const byAccountIds = configuration.scope.account_ids !== void 0;
84
- const memberNow = byAccountIds ? configuration.scope.account_ids.includes(accountId) : configuration.exclude_account_ids?.includes(accountId) !== true;
84
+ const memberNow = byAccountIds ? configuration.scope.account_ids.includes(accountId) : configuration.scope.all_authorized_accounts === true && configuration.exclude_account_ids?.includes(accountId) !== true;
85
85
  const lastRemoval = [...edits].reverse().find((edit) => !edit.member);
86
86
  const lastAdded = [...edits].reverse().find((edit) => edit.member);
87
87
  const result = {};
@@ -64,7 +64,7 @@ function membershipOf(version, accountId) {
64
64
  const configuration = version.configuration;
65
65
  const edits = (version.membershipEdits ?? []).filter((edit) => edit.accountId === accountId);
66
66
  const byAccountIds = configuration.scope.account_ids !== void 0;
67
- const memberNow = byAccountIds ? configuration.scope.account_ids.includes(accountId) : configuration.exclude_account_ids?.includes(accountId) !== true;
67
+ const memberNow = byAccountIds ? configuration.scope.account_ids.includes(accountId) : configuration.scope.all_authorized_accounts === true && configuration.exclude_account_ids?.includes(accountId) !== true;
68
68
  const lastRemoval = [...edits].reverse().find((edit) => !edit.member);
69
69
  const lastAdded = [...edits].reverse().find((edit) => edit.member);
70
70
  const result = {};
@@ -23,9 +23,10 @@ export declare function retainsNonResponseAccountMember(value: unknown): boolean
23
23
  * replay cache, even with whole-response validation off. These four core
24
24
  * contracts are shared by the maintained 3.2 and 3.3 bundles. Up to
25
25
  * 3.3.0-beta.5 their schemas were closed, so validation alone refused retained
26
- * fields; 3.3.0-beta.6 opened them (adcontextprotocol/adcp#8866), so
27
- * credential-shaped keys, SDK-internal fields and write-only members are
28
- * refused explicitly while ordinary extension members pass.
26
+ * fields; 3.3.0-beta.6 opened them (adcontextprotocol/adcp#8866). The
27
+ * projection now refuses credential-shaped keys, SDK-internal fields and
28
+ * write-only members outright, and strips every other member the schema does
29
+ * not declare, so only declared identity reaches the wire.
29
30
  */
30
31
  export declare function projectAccountResponseIdentityFields(account: object): IdentityFields;
31
32
  export {};
@@ -23,9 +23,10 @@ export declare function retainsNonResponseAccountMember(value: unknown): boolean
23
23
  * replay cache, even with whole-response validation off. These four core
24
24
  * contracts are shared by the maintained 3.2 and 3.3 bundles. Up to
25
25
  * 3.3.0-beta.5 their schemas were closed, so validation alone refused retained
26
- * fields; 3.3.0-beta.6 opened them (adcontextprotocol/adcp#8866), so
27
- * credential-shaped keys, SDK-internal fields and write-only members are
28
- * refused explicitly while ordinary extension members pass.
26
+ * fields; 3.3.0-beta.6 opened them (adcontextprotocol/adcp#8866). The
27
+ * projection now refuses credential-shaped keys, SDK-internal fields and
28
+ * write-only members outright, and strips every other member the schema does
29
+ * not declare, so only declared identity reaches the wire.
29
30
  */
30
31
  export declare function projectAccountResponseIdentityFields(account: object): IdentityFields;
31
32
  export {};
@@ -24,6 +24,8 @@ __export(account_response_identity_exports, {
24
24
  retainsNonResponseAccountMember: () => retainsNonResponseAccountMember
25
25
  });
26
26
  module.exports = __toCommonJS(account_response_identity_exports);
27
+ var import_schema_projection = require('../adapters/version/schema-projection.js');
28
+ var import_json_depth = require('../utils/json-depth.js');
27
29
  var import_schema_loader = require('../validation/schema-loader.js');
28
30
  var import_credential_policy = require('./credential-policy.js');
29
31
  const ACCOUNT_REQUEST_RESULT_KEYS = ["request_id", "resolution"];
@@ -75,11 +77,12 @@ const RESPONSE_CREDENTIAL_PATTERNS = {
75
77
  function retainsNonResponseAccountMember(value) {
76
78
  return (0, import_credential_policy.scanArgsForCredentials)(value, RESPONSE_CREDENTIAL_PATTERNS).length > 0 || hasNonResponseMember(value);
77
79
  }
78
- function hasNonResponseMember(value) {
79
- if (Array.isArray(value)) return value.some(hasNonResponseMember);
80
+ function hasNonResponseMember(value, depth = 0) {
81
+ if (depth > import_json_depth.MAX_JSON_DEPTH) return true;
82
+ if (Array.isArray(value)) return value.some((member) => hasNonResponseMember(member, depth + 1));
80
83
  if (value === null || typeof value !== "object") return false;
81
84
  return Object.entries(value).some(
82
- ([key, member]) => NON_RESPONSE_ACCOUNT_MEMBERS.has(key) || hasNonResponseMember(member)
85
+ ([key, member]) => NON_RESPONSE_ACCOUNT_MEMBERS.has(key) || hasNonResponseMember(member, depth + 1)
83
86
  );
84
87
  }
85
88
  function projectAccountResponseIdentityFields(account) {
@@ -88,6 +91,7 @@ function projectAccountResponseIdentityFields(account) {
88
91
  for (const [field, schemaRef] of Object.entries(IDENTITY_RESPONSE_SCHEMAS)) {
89
92
  const value = fields[field];
90
93
  if (value === void 0) continue;
94
+ if ((0, import_json_depth.exceedsJsonDepth)(value)) throw new Error(`Account response ${field} exceeds the maximum JSON depth.`);
91
95
  const snapshot = structuredClone(value);
92
96
  const validate = (0, import_schema_loader.getSchemaValidatorByRef)(schemaRef);
93
97
  if (!validate) throw new Error(`Account response identity schema unavailable: ${schemaRef}.`);
@@ -96,7 +100,7 @@ function projectAccountResponseIdentityFields(account) {
96
100
  `Account response ${field} must match its canonical identity schema without retained internal fields.`
97
101
  );
98
102
  }
99
- Object.assign(projected, { [field]: snapshot });
103
+ Object.assign(projected, { [field]: (0, import_schema_projection.projectToDeclaredMembers)(schemaRef, snapshot).value });
100
104
  }
101
105
  return projected;
102
106
  }
@@ -1,3 +1,5 @@
1
+ import { projectToDeclaredMembers } from "../adapters/version/schema-projection.mjs";
2
+ import { exceedsJsonDepth, MAX_JSON_DEPTH } from "../utils/json-depth.mjs";
1
3
  import { getSchemaDocumentByRef, getSchemaValidatorByRef } from "../validation/schema-loader.mjs";
2
4
  import { scanArgsForCredentials } from "./credential-policy.mjs";
3
5
  const ACCOUNT_REQUEST_RESULT_KEYS = ["request_id", "resolution"];
@@ -49,11 +51,12 @@ const RESPONSE_CREDENTIAL_PATTERNS = {
49
51
  function retainsNonResponseAccountMember(value) {
50
52
  return scanArgsForCredentials(value, RESPONSE_CREDENTIAL_PATTERNS).length > 0 || hasNonResponseMember(value);
51
53
  }
52
- function hasNonResponseMember(value) {
53
- if (Array.isArray(value)) return value.some(hasNonResponseMember);
54
+ function hasNonResponseMember(value, depth = 0) {
55
+ if (depth > MAX_JSON_DEPTH) return true;
56
+ if (Array.isArray(value)) return value.some((member) => hasNonResponseMember(member, depth + 1));
54
57
  if (value === null || typeof value !== "object") return false;
55
58
  return Object.entries(value).some(
56
- ([key, member]) => NON_RESPONSE_ACCOUNT_MEMBERS.has(key) || hasNonResponseMember(member)
59
+ ([key, member]) => NON_RESPONSE_ACCOUNT_MEMBERS.has(key) || hasNonResponseMember(member, depth + 1)
57
60
  );
58
61
  }
59
62
  function projectAccountResponseIdentityFields(account) {
@@ -62,6 +65,7 @@ function projectAccountResponseIdentityFields(account) {
62
65
  for (const [field, schemaRef] of Object.entries(IDENTITY_RESPONSE_SCHEMAS)) {
63
66
  const value = fields[field];
64
67
  if (value === void 0) continue;
68
+ if (exceedsJsonDepth(value)) throw new Error(`Account response ${field} exceeds the maximum JSON depth.`);
65
69
  const snapshot = structuredClone(value);
66
70
  const validate = getSchemaValidatorByRef(schemaRef);
67
71
  if (!validate) throw new Error(`Account response identity schema unavailable: ${schemaRef}.`);
@@ -70,7 +74,7 @@ function projectAccountResponseIdentityFields(account) {
70
74
  `Account response ${field} must match its canonical identity schema without retained internal fields.`
71
75
  );
72
76
  }
73
- Object.assign(projected, { [field]: snapshot });
77
+ Object.assign(projected, { [field]: projectToDeclaredMembers(schemaRef, snapshot).value });
74
78
  }
75
79
  return projected;
76
80
  }
@@ -24,6 +24,7 @@ __export(credential_policy_exports, {
24
24
  validateCredentialPolicy: () => validateCredentialPolicy
25
25
  });
26
26
  module.exports = __toCommonJS(credential_policy_exports);
27
+ var import_json_depth = require('../utils/json-depth.js');
27
28
  const DEFAULT_CREDENTIAL_PATTERNS = Object.freeze([
28
29
  /(?:^|[._\s/-])token$/i,
29
30
  /(?:^|[._\s/-])secret$/i,
@@ -60,6 +61,10 @@ function scanArgsForCredentials(value, patterns) {
60
61
  const walk = (node, path) => {
61
62
  if (node === null || typeof node !== "object") return;
62
63
  if (seen.has(node)) return;
64
+ if (path.length > import_json_depth.MAX_JSON_DEPTH) {
65
+ hits.push([...path.slice(0, 8), "<too-deep>"].join("."));
66
+ return;
67
+ }
63
68
  seen.add(node);
64
69
  if (Array.isArray(node)) {
65
70
  for (let i = 0; i < node.length; i++) {
@@ -1,3 +1,4 @@
1
+ import { MAX_JSON_DEPTH } from "../utils/json-depth.mjs";
1
2
  const DEFAULT_CREDENTIAL_PATTERNS = Object.freeze([
2
3
  /(?:^|[._\s/-])token$/i,
3
4
  /(?:^|[._\s/-])secret$/i,
@@ -34,6 +35,10 @@ function scanArgsForCredentials(value, patterns) {
34
35
  const walk = (node, path) => {
35
36
  if (node === null || typeof node !== "object") return;
36
37
  if (seen.has(node)) return;
38
+ if (path.length > MAX_JSON_DEPTH) {
39
+ hits.push([...path.slice(0, 8), "<too-deep>"].join("."));
40
+ return;
41
+ }
37
42
  seen.add(node);
38
43
  if (Array.isArray(node)) {
39
44
  for (let i = 0; i < node.length; i++) {
@@ -33,6 +33,8 @@ __export(account_exports, {
33
33
  module.exports = __toCommonJS(account_exports);
34
34
  var import_reporting_delivery_config = require('../reporting-delivery-config.js');
35
35
  var import_account_response_identity = require('../account-response-identity.js');
36
+ var import_schema_projection = require('../../adapters/version/schema-projection.js');
37
+ var import_json_depth = require('../../utils/json-depth.js');
36
38
  const ACCOUNT_AUTHORIZATION_WIRE_KEYS = [
37
39
  "allowed_tasks",
38
40
  "field_scopes",
@@ -182,9 +184,18 @@ function toWireSyncAccountRow(row) {
182
184
  }
183
185
  function projectNotificationConfig(config) {
184
186
  const { authentication, ...rest } = config;
185
- if (!authentication) return rest;
186
- const { credentials: _credentials, ...authenticationWithoutCredentials } = authentication;
187
- return { ...rest, authentication: authenticationWithoutCredentials };
187
+ let wire = rest;
188
+ if (authentication) {
189
+ const { credentials: _credentials, ...authenticationWithoutCredentials } = authentication;
190
+ wire = { ...rest, authentication: authenticationWithoutCredentials };
191
+ }
192
+ if ((0, import_json_depth.exceedsJsonDepth)(wire))
193
+ throw new Error("notification_configs contains a config that exceeds the maximum JSON depth");
194
+ const snapshot = structuredClone(wire);
195
+ if ((0, import_account_response_identity.retainsNonResponseAccountMember)(snapshot)) {
196
+ throw new Error("notification_configs contains a config that retains credential or internal fields");
197
+ }
198
+ return (0, import_schema_projection.projectToDeclaredMembers)("core/notification-config.json", snapshot).value;
188
199
  }
189
200
  function toWireSyncGovernanceRow(row) {
190
201
  const wire = {
@@ -1,8 +1,11 @@
1
1
  import { projectReportingDeliveryConfigStates } from "../reporting-delivery-config.mjs";
2
2
  import {
3
3
  projectAccountRequestResultFields,
4
- projectAccountResponseIdentityFields
4
+ projectAccountResponseIdentityFields,
5
+ retainsNonResponseAccountMember
5
6
  } from "../account-response-identity.mjs";
7
+ import { projectToDeclaredMembers } from "../../adapters/version/schema-projection.mjs";
8
+ import { exceedsJsonDepth } from "../../utils/json-depth.mjs";
6
9
  const ACCOUNT_AUTHORIZATION_WIRE_KEYS = [
7
10
  "allowed_tasks",
8
11
  "field_scopes",
@@ -152,9 +155,18 @@ function toWireSyncAccountRow(row) {
152
155
  }
153
156
  function projectNotificationConfig(config) {
154
157
  const { authentication, ...rest } = config;
155
- if (!authentication) return rest;
156
- const { credentials: _credentials, ...authenticationWithoutCredentials } = authentication;
157
- return { ...rest, authentication: authenticationWithoutCredentials };
158
+ let wire = rest;
159
+ if (authentication) {
160
+ const { credentials: _credentials, ...authenticationWithoutCredentials } = authentication;
161
+ wire = { ...rest, authentication: authenticationWithoutCredentials };
162
+ }
163
+ if (exceedsJsonDepth(wire))
164
+ throw new Error("notification_configs contains a config that exceeds the maximum JSON depth");
165
+ const snapshot = structuredClone(wire);
166
+ if (retainsNonResponseAccountMember(snapshot)) {
167
+ throw new Error("notification_configs contains a config that retains credential or internal fields");
168
+ }
169
+ return projectToDeclaredMembers("core/notification-config.json", snapshot).value;
158
170
  }
159
171
  function toWireSyncGovernanceRow(row) {
160
172
  const wire = {
@@ -23,6 +23,12 @@ export declare function projectStoredNotificationSubscriptionReadback(subscripti
23
23
  * that was legitimately revoked or denied.
24
24
  */
25
25
  export declare function notificationSuppressionDisposition(reason: WebhookAttemptSuppressionReason): NotificationSuppressionDisposition;
26
+ /**
27
+ * The webhook payload schema of each notification type the runtime emits.
28
+ * `test/lib/persistent-notification-runtime.test.js` checks this against every
29
+ * webhook schema in the pinned bundle.
30
+ */
31
+ export declare const NOTIFICATION_WEBHOOK_SCHEMAS: Readonly<Record<string, string>>;
26
32
  /** Point-in-time registration validation; delivery still re-resolves and pins every attempt. */
27
33
  export declare function validatePersistentNotificationDestination(input: {
28
34
  url: string;
@@ -23,6 +23,12 @@ export declare function projectStoredNotificationSubscriptionReadback(subscripti
23
23
  * that was legitimately revoked or denied.
24
24
  */
25
25
  export declare function notificationSuppressionDisposition(reason: WebhookAttemptSuppressionReason): NotificationSuppressionDisposition;
26
+ /**
27
+ * The webhook payload schema of each notification type the runtime emits.
28
+ * `test/lib/persistent-notification-runtime.test.js` checks this against every
29
+ * webhook schema in the pinned bundle.
30
+ */
31
+ export declare const NOTIFICATION_WEBHOOK_SCHEMAS: Readonly<Record<string, string>>;
26
32
  /** Point-in-time registration validation; delivery still re-resolves and pins every attempt. */
27
33
  export declare function validatePersistentNotificationDestination(input: {
28
34
  url: string;