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

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 (89) 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/discovery/property-crawler.d.mts +11 -0
  6. package/dist/lib/discovery/property-crawler.d.ts +11 -0
  7. package/dist/lib/discovery/property-crawler.js +15 -2
  8. package/dist/lib/discovery/property-crawler.mjs +15 -2
  9. package/dist/lib/discovery/resolve-agent-properties.d.mts +81 -8
  10. package/dist/lib/discovery/resolve-agent-properties.d.ts +81 -8
  11. package/dist/lib/discovery/resolve-agent-properties.js +94 -14
  12. package/dist/lib/discovery/resolve-agent-properties.mjs +91 -13
  13. package/dist/lib/discovery/validate-adagents.d.mts +7 -0
  14. package/dist/lib/discovery/validate-adagents.d.ts +7 -0
  15. package/dist/lib/entrypoints/discovery.d.mts +1 -1
  16. package/dist/lib/entrypoints/discovery.d.ts +1 -1
  17. package/dist/lib/entrypoints/discovery.js +4 -0
  18. package/dist/lib/entrypoints/discovery.mjs +5 -1
  19. package/dist/lib/index.d.mts +1 -1
  20. package/dist/lib/index.d.ts +1 -1
  21. package/dist/lib/index.js +4 -0
  22. package/dist/lib/index.mjs +5 -1
  23. package/dist/lib/reporting/evidence.d.mts +8 -0
  24. package/dist/lib/reporting/evidence.d.ts +8 -0
  25. package/dist/lib/reporting/evidence.js +10 -2
  26. package/dist/lib/reporting/evidence.mjs +8 -1
  27. package/dist/lib/reporting/ledger/index.d.mts +1 -1
  28. package/dist/lib/reporting/ledger/index.d.ts +1 -1
  29. package/dist/lib/reporting/ledger/index.js +3 -1
  30. package/dist/lib/reporting/ledger/index.mjs +4 -2
  31. package/dist/lib/reporting/ledger/status-ingest.js +3 -2
  32. package/dist/lib/reporting/ledger/status-ingest.mjs +3 -2
  33. package/dist/lib/reporting/subscriptions/engine.js +1 -1
  34. package/dist/lib/reporting/subscriptions/engine.mjs +1 -1
  35. package/dist/lib/server/account-response-identity.d.mts +4 -3
  36. package/dist/lib/server/account-response-identity.d.ts +4 -3
  37. package/dist/lib/server/account-response-identity.js +8 -4
  38. package/dist/lib/server/account-response-identity.mjs +8 -4
  39. package/dist/lib/server/credential-policy.js +5 -0
  40. package/dist/lib/server/credential-policy.mjs +5 -0
  41. package/dist/lib/server/decisioning/account.js +14 -3
  42. package/dist/lib/server/decisioning/account.mjs +16 -4
  43. package/dist/lib/server/notification-subscriptions/runtime.d.mts +6 -0
  44. package/dist/lib/server/notification-subscriptions/runtime.d.ts +6 -0
  45. package/dist/lib/server/notification-subscriptions/runtime.js +99 -0
  46. package/dist/lib/server/notification-subscriptions/runtime.mjs +98 -0
  47. package/dist/lib/server/principal/reporting-subscriptions.js +4 -1
  48. package/dist/lib/server/principal/reporting-subscriptions.mjs +4 -1
  49. package/dist/lib/server/reporting-delivery-config.d.mts +2 -2
  50. package/dist/lib/server/reporting-delivery-config.d.ts +2 -2
  51. package/dist/lib/server/reporting-delivery-config.js +9 -3
  52. package/dist/lib/server/reporting-delivery-config.mjs +9 -3
  53. package/dist/lib/server/wire-safe.js +3 -0
  54. package/dist/lib/server/wire-safe.mjs +3 -0
  55. package/dist/lib/supply-path/validation.d.mts +8 -0
  56. package/dist/lib/supply-path/validation.d.ts +8 -0
  57. package/dist/lib/testing/compliance/comply.js +1 -1
  58. package/dist/lib/testing/compliance/comply.mjs +3 -2
  59. package/dist/lib/testing/storyboard/index.d.mts +1 -1
  60. package/dist/lib/testing/storyboard/index.d.ts +1 -1
  61. package/dist/lib/testing/storyboard/index.js +6 -0
  62. package/dist/lib/testing/storyboard/index.mjs +6 -0
  63. package/dist/lib/testing/storyboard/loader.js +52 -28
  64. package/dist/lib/testing/storyboard/loader.mjs +52 -28
  65. package/dist/lib/testing/storyboard/runner.d.mts +24 -1
  66. package/dist/lib/testing/storyboard/runner.d.ts +24 -1
  67. package/dist/lib/testing/storyboard/runner.js +75 -7
  68. package/dist/lib/testing/storyboard/runner.mjs +72 -7
  69. package/dist/lib/testing/storyboard/types.d.mts +51 -6
  70. package/dist/lib/testing/storyboard/types.d.ts +51 -6
  71. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  72. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  73. package/dist/lib/types/wellknown-schemas.generated.d.mts +16 -16
  74. package/dist/lib/types/wellknown-schemas.generated.d.ts +16 -16
  75. package/dist/lib/utils/json-depth.d.mts +8 -0
  76. package/dist/lib/utils/json-depth.d.ts +8 -0
  77. package/dist/lib/utils/json-depth.js +18 -2
  78. package/dist/lib/utils/json-depth.mjs +16 -1
  79. package/dist/lib/version.d.mts +3 -3
  80. package/dist/lib/version.d.ts +3 -3
  81. package/dist/lib/version.js +3 -3
  82. package/dist/lib/version.mjs +3 -3
  83. package/docs/TYPE-SUMMARY.md +2 -2
  84. package/docs/guides/STORYBOARD-CAPABILITY-GATES.md +96 -0
  85. package/docs/guides/VALIDATE-YOUR-AGENT.md +5 -0
  86. package/docs/llms.txt +2 -2
  87. package/docs/migration-14.x-rc-worksheet.md +4 -4
  88. package/docs/migration-16-to-17.md +47 -8
  89. package/package.json +1 -1
@@ -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;
@@ -20,6 +20,7 @@ var runtime_exports = {};
20
20
  __export(runtime_exports, {
21
21
  ACCOUNT_NOTIFICATION_TYPES: () => ACCOUNT_NOTIFICATION_TYPES,
22
22
  CALLER_NOTIFICATION_TYPES: () => CALLER_NOTIFICATION_TYPES,
23
+ NOTIFICATION_WEBHOOK_SCHEMAS: () => NOTIFICATION_WEBHOOK_SCHEMAS,
23
24
  createPersistentNotificationRuntime: () => createPersistentNotificationRuntime,
24
25
  notificationSuppressionDisposition: () => notificationSuppressionDisposition,
25
26
  projectNotificationSubscriptionReadback: () => projectNotificationSubscriptionReadback,
@@ -30,6 +31,7 @@ module.exports = __toCommonJS(runtime_exports);
30
31
  var import_node_crypto = require("node:crypto");
31
32
  var import_promises = require("node:dns/promises");
32
33
  var import_jcs = require('../../utils/jcs.js');
34
+ var import_schema_loader = require('../../validation/schema-loader.js');
33
35
  var import_common = require('../webhook-delivery/common.js');
34
36
  var import_ssrf = require('../../substitution/observer/ssrf.js');
35
37
  var import_pin_and_bind_fetch = require('../pin-and-bind-fetch.js');
@@ -835,8 +837,23 @@ function assertEvent(event, accountEventTypes, callerOnlyEventTypes) {
835
837
  field
836
838
  );
837
839
  }
840
+ assertWebhookExclusions(event);
838
841
  }
839
842
  const IDENTIFIERS_ONLY_PAYLOAD_FIELDS = {
843
+ // AdCP 3.3 experimental media_buy.seller_offers: the same identifiers-only rule.
844
+ "proposal.offered": /* @__PURE__ */ new Set([
845
+ "idempotency_key",
846
+ "notification_id",
847
+ "notification_type",
848
+ "fired_at",
849
+ "subscriber_id",
850
+ "account_id",
851
+ "media_buy_id",
852
+ "proposal_id",
853
+ "expires_at",
854
+ "offer_reason",
855
+ "ext"
856
+ ]),
840
857
  "proposal.created": /* @__PURE__ */ new Set([
841
858
  "idempotency_key",
842
859
  "notification_id",
@@ -852,6 +869,87 @@ const IDENTIFIERS_ONLY_PAYLOAD_FIELDS = {
852
869
  "ext"
853
870
  ])
854
871
  };
872
+ const NOTIFICATION_WEBHOOK_SCHEMAS = Object.freeze({
873
+ "capabilities.changed": "core/capabilities-changed-webhook.json",
874
+ "principal.changed": "core/principal-changed-webhook.json",
875
+ "account_request.changed": "core/account-request-changed-webhook.json",
876
+ "creative.status_changed": "creative/creative-status-changed-webhook.json",
877
+ "creative.assignment_changed": "creative/creative-assignment-changed-webhook.json",
878
+ "indicators.changed": "core/indicators-changed-webhook.json",
879
+ "creative.purged": "creative/creative-purged-webhook.json",
880
+ "creative.staged_update_changed": "creative/creative-staged-update-changed-webhook.json",
881
+ "account.status_changed": "core/account-status-changed-webhook.json",
882
+ "account.change_recorded": "core/account-change-recorded-webhook.json",
883
+ "product.created": "core/wholesale-feed-webhook.json",
884
+ "product.updated": "core/wholesale-feed-webhook.json",
885
+ "product.priced": "core/wholesale-feed-webhook.json",
886
+ "product.removed": "core/wholesale-feed-webhook.json",
887
+ "signal.created": "core/wholesale-feed-webhook.json",
888
+ "signal.updated": "core/wholesale-feed-webhook.json",
889
+ "signal.priced": "core/wholesale-feed-webhook.json",
890
+ "signal.removed": "core/wholesale-feed-webhook.json",
891
+ "wholesale_feed.bulk_change": "core/wholesale-feed-webhook.json",
892
+ "collection_card.updated": "core/wholesale-feed-webhook.json",
893
+ "collection_card.removed": "core/wholesale-feed-webhook.json",
894
+ "collection_catalog.bulk_change": "core/wholesale-feed-webhook.json",
895
+ "proposal.created": "core/proposal-created-webhook.json",
896
+ "proposal.offered": "core/proposal-offered-webhook.json",
897
+ "reporting.delivery_ready": "core/reporting-delivery-ready-webhook.json",
898
+ "reporting.status_changed": "core/reporting-status-changed-webhook.json",
899
+ "reporting.ledger_changed": "core/reporting-ledger-changed-webhook.json"
900
+ });
901
+ const PLAIN_MEMBER = /^[a-z][a-z0-9_]{0,63}$/;
902
+ function assertWebhookExclusions(event) {
903
+ const ref = NOTIFICATION_WEBHOOK_SCHEMAS[event.notificationType];
904
+ if (!ref) return;
905
+ const validate = (0, import_schema_loader.getSchemaValidatorByRef)(ref, void 0, void 0, { allErrors: true });
906
+ if (!validate) throw new Error(`Webhook payload schema unavailable for ${event.notificationType}: ${ref}`);
907
+ const body = {
908
+ ...event.payload,
909
+ notification_type: event.notificationType,
910
+ notification_id: event.notificationId,
911
+ ...event.accountId === void 0 ? {} : { account_id: event.accountId }
912
+ };
913
+ validate(body);
914
+ const exclusion = validate.errors?.find((error) => error.keyword === "not");
915
+ if (!exclusion) return;
916
+ const segments = exclusion.instancePath.split("/").slice(1).map((segment) => segment.replace(/~1/g, "/").replace(/~0/g, "~"));
917
+ const plain = segments.every((segment) => PLAIN_MEMBER.test(segment) || /^\d+$/.test(segment));
918
+ const location = plain ? ["payload", ...segments].join(".") : "payload";
919
+ let target = body;
920
+ for (const segment of plain ? segments : []) {
921
+ target = target && typeof target === "object" ? target[segment] : void 0;
922
+ }
923
+ const present = excludedMembers(ref, exclusion.schemaPath).filter(
924
+ (member) => plain && target !== null && typeof target === "object" && Object.hasOwn(target, member)
925
+ );
926
+ const field = present.length > 0 ? `${location}.${present[0]}` : location;
927
+ throw new import_types.NotificationSubscriptionValidationError(
928
+ `${event.notificationType} must not carry ${present.length > 0 ? present.map((member) => `${location}.${member}`).join(" with ") : `what its webhook schema excludes at ${location}`}`,
929
+ field
930
+ );
931
+ }
932
+ function excludedMembers(ref, schemaPath) {
933
+ if (!schemaPath.startsWith("#/")) return [];
934
+ let node = (0, import_schema_loader.getSchemaDocumentByRef)(ref)?.schema;
935
+ for (const segment of schemaPath.slice(2).split("/")) {
936
+ if (!node || typeof node !== "object") return [];
937
+ node = node[segment.replace(/~1/g, "/").replace(/~0/g, "~")];
938
+ }
939
+ const members = /* @__PURE__ */ new Set();
940
+ const collect = (value) => {
941
+ const required = value && typeof value === "object" ? value.required : void 0;
942
+ if (Array.isArray(required)) {
943
+ for (const key of required) if (typeof key === "string") members.add(key);
944
+ }
945
+ };
946
+ collect(node);
947
+ for (const keyword of ["anyOf", "oneOf"]) {
948
+ const branches = node && typeof node === "object" ? node[keyword] : void 0;
949
+ if (Array.isArray(branches)) branches.forEach(collect);
950
+ }
951
+ return [...members].filter((member) => PLAIN_MEMBER.test(member));
952
+ }
855
953
  function assertUniqueSubscribers(configs) {
856
954
  if (!Array.isArray(configs) || configs.length > 16) {
857
955
  throw new import_types.NotificationSubscriptionValidationError(
@@ -1040,6 +1138,7 @@ function validation(message, index, field) {
1040
1138
  0 && (module.exports = {
1041
1139
  ACCOUNT_NOTIFICATION_TYPES,
1042
1140
  CALLER_NOTIFICATION_TYPES,
1141
+ NOTIFICATION_WEBHOOK_SCHEMAS,
1043
1142
  createPersistentNotificationRuntime,
1044
1143
  notificationSuppressionDisposition,
1045
1144
  projectNotificationSubscriptionReadback,
@@ -1,6 +1,7 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { lookup } from "node:dns/promises";
3
3
  import { canonicalJsonSha256 } from "../../utils/jcs.mjs";
4
+ import { getSchemaDocumentByRef, getSchemaValidatorByRef } from "../../validation/schema-loader.mjs";
4
5
  import { isWebhookDeliveryTerminalError } from "../webhook-delivery/common.mjs";
5
6
  import { enforceSsrfPolicy, enforceSsrfPolicyResolved } from "../../substitution/observer/ssrf.mjs";
6
7
  import { WEBHOOK_SSRF_POLICY } from "../pin-and-bind-fetch.mjs";
@@ -806,8 +807,23 @@ function assertEvent(event, accountEventTypes, callerOnlyEventTypes) {
806
807
  field
807
808
  );
808
809
  }
810
+ assertWebhookExclusions(event);
809
811
  }
810
812
  const IDENTIFIERS_ONLY_PAYLOAD_FIELDS = {
813
+ // AdCP 3.3 experimental media_buy.seller_offers: the same identifiers-only rule.
814
+ "proposal.offered": /* @__PURE__ */ new Set([
815
+ "idempotency_key",
816
+ "notification_id",
817
+ "notification_type",
818
+ "fired_at",
819
+ "subscriber_id",
820
+ "account_id",
821
+ "media_buy_id",
822
+ "proposal_id",
823
+ "expires_at",
824
+ "offer_reason",
825
+ "ext"
826
+ ]),
811
827
  "proposal.created": /* @__PURE__ */ new Set([
812
828
  "idempotency_key",
813
829
  "notification_id",
@@ -823,6 +839,87 @@ const IDENTIFIERS_ONLY_PAYLOAD_FIELDS = {
823
839
  "ext"
824
840
  ])
825
841
  };
842
+ const NOTIFICATION_WEBHOOK_SCHEMAS = Object.freeze({
843
+ "capabilities.changed": "core/capabilities-changed-webhook.json",
844
+ "principal.changed": "core/principal-changed-webhook.json",
845
+ "account_request.changed": "core/account-request-changed-webhook.json",
846
+ "creative.status_changed": "creative/creative-status-changed-webhook.json",
847
+ "creative.assignment_changed": "creative/creative-assignment-changed-webhook.json",
848
+ "indicators.changed": "core/indicators-changed-webhook.json",
849
+ "creative.purged": "creative/creative-purged-webhook.json",
850
+ "creative.staged_update_changed": "creative/creative-staged-update-changed-webhook.json",
851
+ "account.status_changed": "core/account-status-changed-webhook.json",
852
+ "account.change_recorded": "core/account-change-recorded-webhook.json",
853
+ "product.created": "core/wholesale-feed-webhook.json",
854
+ "product.updated": "core/wholesale-feed-webhook.json",
855
+ "product.priced": "core/wholesale-feed-webhook.json",
856
+ "product.removed": "core/wholesale-feed-webhook.json",
857
+ "signal.created": "core/wholesale-feed-webhook.json",
858
+ "signal.updated": "core/wholesale-feed-webhook.json",
859
+ "signal.priced": "core/wholesale-feed-webhook.json",
860
+ "signal.removed": "core/wholesale-feed-webhook.json",
861
+ "wholesale_feed.bulk_change": "core/wholesale-feed-webhook.json",
862
+ "collection_card.updated": "core/wholesale-feed-webhook.json",
863
+ "collection_card.removed": "core/wholesale-feed-webhook.json",
864
+ "collection_catalog.bulk_change": "core/wholesale-feed-webhook.json",
865
+ "proposal.created": "core/proposal-created-webhook.json",
866
+ "proposal.offered": "core/proposal-offered-webhook.json",
867
+ "reporting.delivery_ready": "core/reporting-delivery-ready-webhook.json",
868
+ "reporting.status_changed": "core/reporting-status-changed-webhook.json",
869
+ "reporting.ledger_changed": "core/reporting-ledger-changed-webhook.json"
870
+ });
871
+ const PLAIN_MEMBER = /^[a-z][a-z0-9_]{0,63}$/;
872
+ function assertWebhookExclusions(event) {
873
+ const ref = NOTIFICATION_WEBHOOK_SCHEMAS[event.notificationType];
874
+ if (!ref) return;
875
+ const validate = getSchemaValidatorByRef(ref, void 0, void 0, { allErrors: true });
876
+ if (!validate) throw new Error(`Webhook payload schema unavailable for ${event.notificationType}: ${ref}`);
877
+ const body = {
878
+ ...event.payload,
879
+ notification_type: event.notificationType,
880
+ notification_id: event.notificationId,
881
+ ...event.accountId === void 0 ? {} : { account_id: event.accountId }
882
+ };
883
+ validate(body);
884
+ const exclusion = validate.errors?.find((error) => error.keyword === "not");
885
+ if (!exclusion) return;
886
+ const segments = exclusion.instancePath.split("/").slice(1).map((segment) => segment.replace(/~1/g, "/").replace(/~0/g, "~"));
887
+ const plain = segments.every((segment) => PLAIN_MEMBER.test(segment) || /^\d+$/.test(segment));
888
+ const location = plain ? ["payload", ...segments].join(".") : "payload";
889
+ let target = body;
890
+ for (const segment of plain ? segments : []) {
891
+ target = target && typeof target === "object" ? target[segment] : void 0;
892
+ }
893
+ const present = excludedMembers(ref, exclusion.schemaPath).filter(
894
+ (member) => plain && target !== null && typeof target === "object" && Object.hasOwn(target, member)
895
+ );
896
+ const field = present.length > 0 ? `${location}.${present[0]}` : location;
897
+ throw new NotificationSubscriptionValidationError(
898
+ `${event.notificationType} must not carry ${present.length > 0 ? present.map((member) => `${location}.${member}`).join(" with ") : `what its webhook schema excludes at ${location}`}`,
899
+ field
900
+ );
901
+ }
902
+ function excludedMembers(ref, schemaPath) {
903
+ if (!schemaPath.startsWith("#/")) return [];
904
+ let node = getSchemaDocumentByRef(ref)?.schema;
905
+ for (const segment of schemaPath.slice(2).split("/")) {
906
+ if (!node || typeof node !== "object") return [];
907
+ node = node[segment.replace(/~1/g, "/").replace(/~0/g, "~")];
908
+ }
909
+ const members = /* @__PURE__ */ new Set();
910
+ const collect = (value) => {
911
+ const required = value && typeof value === "object" ? value.required : void 0;
912
+ if (Array.isArray(required)) {
913
+ for (const key of required) if (typeof key === "string") members.add(key);
914
+ }
915
+ };
916
+ collect(node);
917
+ for (const keyword of ["anyOf", "oneOf"]) {
918
+ const branches = node && typeof node === "object" ? node[keyword] : void 0;
919
+ if (Array.isArray(branches)) branches.forEach(collect);
920
+ }
921
+ return [...members].filter((member) => PLAIN_MEMBER.test(member));
922
+ }
826
923
  function assertUniqueSubscribers(configs) {
827
924
  if (!Array.isArray(configs) || configs.length > 16) {
828
925
  throw new NotificationSubscriptionValidationError(
@@ -1010,6 +1107,7 @@ function validation(message, index, field) {
1010
1107
  export {
1011
1108
  ACCOUNT_NOTIFICATION_TYPES,
1012
1109
  CALLER_NOTIFICATION_TYPES,
1110
+ NOTIFICATION_WEBHOOK_SCHEMAS,
1013
1111
  createPersistentNotificationRuntime,
1014
1112
  notificationSuppressionDisposition,
1015
1113
  projectNotificationSubscriptionReadback,
@@ -37,6 +37,7 @@ class ReportingSubscriptionValidationError extends Error {
37
37
  }
38
38
  field;
39
39
  }
40
+ const REPORTING_SUBSCRIPTION_SCOPE_SELECTORS = /* @__PURE__ */ new Set(["all_authorized_accounts", "account_ids"]);
40
41
  const MAX_INACTIVE_INTERVALS = 64;
41
42
  const SUBSCRIPTION_ID = /^(?!\.{1,2}$)[A-Za-z0-9_.:-]{1,64}$/;
42
43
  const PATH_TEMPLATE = /^(?!\/)(?!(?:.*\/)?\.{1,2}(?:\/|$))[A-Za-z0-9_.=/{}-]+$/;
@@ -114,7 +115,9 @@ function validateReportingSubscription(subscription, destinations) {
114
115
  if (typeof subscription.active !== "boolean") fail("active is required");
115
116
  const scope = subscription.scope;
116
117
  const scopeKeys = scope && typeof scope === "object" ? Object.keys(scope) : [];
117
- if (scopeKeys.length !== 1) fail("scope must name exactly one of all_authorized_accounts or account_ids");
118
+ if (scopeKeys.length !== 1 || !REPORTING_SUBSCRIPTION_SCOPE_SELECTORS.has(scopeKeys[0])) {
119
+ fail("scope must name exactly one of all_authorized_accounts or account_ids");
120
+ }
118
121
  if (scope.all_authorized_accounts !== void 0 && scope.all_authorized_accounts !== true) {
119
122
  fail("scope.all_authorized_accounts must be true when present");
120
123
  }
@@ -8,6 +8,7 @@ class ReportingSubscriptionValidationError extends Error {
8
8
  }
9
9
  field;
10
10
  }
11
+ const REPORTING_SUBSCRIPTION_SCOPE_SELECTORS = /* @__PURE__ */ new Set(["all_authorized_accounts", "account_ids"]);
11
12
  const MAX_INACTIVE_INTERVALS = 64;
12
13
  const SUBSCRIPTION_ID = /^(?!\.{1,2}$)[A-Za-z0-9_.:-]{1,64}$/;
13
14
  const PATH_TEMPLATE = /^(?!\/)(?!(?:.*\/)?\.{1,2}(?:\/|$))[A-Za-z0-9_.=/{}-]+$/;
@@ -85,7 +86,9 @@ function validateReportingSubscription(subscription, destinations) {
85
86
  if (typeof subscription.active !== "boolean") fail("active is required");
86
87
  const scope = subscription.scope;
87
88
  const scopeKeys = scope && typeof scope === "object" ? Object.keys(scope) : [];
88
- if (scopeKeys.length !== 1) fail("scope must name exactly one of all_authorized_accounts or account_ids");
89
+ if (scopeKeys.length !== 1 || !REPORTING_SUBSCRIPTION_SCOPE_SELECTORS.has(scopeKeys[0])) {
90
+ fail("scope must name exactly one of all_authorized_accounts or account_ids");
91
+ }
89
92
  if (scope.all_authorized_accounts !== void 0 && scope.all_authorized_accounts !== true) {
90
93
  fail("scope.all_authorized_accounts must be true when present");
91
94
  }
@@ -12,7 +12,7 @@ import type { ReportingDeliveryConfigurationState } from '../types/tools.generat
12
12
  * persistence model fail closed, so they never reach a buyer or an
13
13
  * idempotency/replay cache. AdCP 3.3.0-beta.6 opened these schemas
14
14
  * (adcontextprotocol/adcp#8866), so schema validation alone no longer rejects
15
- * an unknown member; a credential-shaped key or SDK-internal field anywhere in
16
- * the record is refused explicitly.
15
+ * an unknown member: a credential-shaped key or SDK-internal field anywhere in
16
+ * the record is refused, and every other undeclared member is stripped.
17
17
  */
18
18
  export declare function projectReportingDeliveryConfigStates(states: readonly ReportingDeliveryConfigurationState[]): ReportingDeliveryConfigurationState[];
@@ -12,7 +12,7 @@ import type { ReportingDeliveryConfigurationState } from '../types/tools.generat
12
12
  * persistence model fail closed, so they never reach a buyer or an
13
13
  * idempotency/replay cache. AdCP 3.3.0-beta.6 opened these schemas
14
14
  * (adcontextprotocol/adcp#8866), so schema validation alone no longer rejects
15
- * an unknown member; a credential-shaped key or SDK-internal field anywhere in
16
- * the record is refused explicitly.
15
+ * an unknown member: a credential-shaped key or SDK-internal field anywhere in
16
+ * the record is refused, and every other undeclared member is stripped.
17
17
  */
18
18
  export declare function projectReportingDeliveryConfigStates(states: readonly ReportingDeliveryConfigurationState[]): ReportingDeliveryConfigurationState[];