@adcp/sdk 16.0.0-beta.2 → 16.0.0-beta.4

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 (248) hide show
  1. package/README.md +54 -0
  2. package/dist/lib/auth/oauth/diagnose.js +3 -11
  3. package/dist/lib/auth/oauth/diagnose.mjs +4 -12
  4. package/dist/lib/auth/oauth/diagnostics.d.mts +2 -1
  5. package/dist/lib/auth/oauth/diagnostics.d.ts +2 -1
  6. package/dist/lib/auth/oauth/diagnostics.js +8 -10
  7. package/dist/lib/auth/oauth/diagnostics.mjs +7 -10
  8. package/dist/lib/core/ConversationTypes.d.mts +8 -3
  9. package/dist/lib/core/ConversationTypes.d.ts +8 -3
  10. package/dist/lib/core/SingleAgentClient.d.mts +5 -3
  11. package/dist/lib/core/SingleAgentClient.d.ts +5 -3
  12. package/dist/lib/core/TaskExecutor.js +5 -1
  13. package/dist/lib/core/TaskExecutor.mjs +5 -1
  14. package/dist/lib/errors/index.d.mts +9 -4
  15. package/dist/lib/errors/index.d.ts +9 -4
  16. package/dist/lib/index.d.mts +3 -3
  17. package/dist/lib/index.d.ts +3 -3
  18. package/dist/lib/index.js +8 -0
  19. package/dist/lib/index.mjs +14 -2
  20. package/dist/lib/negotiation/types.d.mts +20 -39
  21. package/dist/lib/negotiation/types.d.ts +20 -39
  22. package/dist/lib/protocols/index.d.mts +60 -24
  23. package/dist/lib/protocols/index.d.ts +60 -24
  24. package/dist/lib/protocols/index.js +9 -4
  25. package/dist/lib/protocols/index.mjs +3 -0
  26. package/dist/lib/protocols/mcp-modern.js +1 -0
  27. package/dist/lib/protocols/mcp-modern.mjs +2 -1
  28. package/dist/lib/protocols/mcp.js +1 -0
  29. package/dist/lib/protocols/mcp.mjs +2 -1
  30. package/dist/lib/protocols/responseSizeLimit.d.mts +91 -5
  31. package/dist/lib/protocols/responseSizeLimit.d.ts +91 -5
  32. package/dist/lib/protocols/responseSizeLimit.js +195 -31
  33. package/dist/lib/protocols/responseSizeLimit.mjs +192 -31
  34. package/dist/lib/reporting/consumer-runtime.js +2 -1
  35. package/dist/lib/reporting/consumer-runtime.mjs +2 -1
  36. package/dist/lib/reporting/ledger/handler.js +50 -11
  37. package/dist/lib/reporting/ledger/handler.mjs +50 -12
  38. package/dist/lib/reporting/ledger/index.d.mts +17 -14
  39. package/dist/lib/reporting/ledger/index.d.ts +17 -14
  40. package/dist/lib/reporting/ledger/index.js +32 -20
  41. package/dist/lib/reporting/ledger/index.mjs +21 -10
  42. package/dist/lib/reporting/ledger/offering-validation.d.mts +9 -0
  43. package/dist/lib/reporting/ledger/offering-validation.d.ts +9 -0
  44. package/dist/lib/reporting/{gcs/bucket-policy.js → ledger/offering-validation.js} +9 -8
  45. package/dist/lib/reporting/ledger/offering-validation.mjs +8 -0
  46. package/dist/lib/reporting/ledger/receipts.d.mts +48 -0
  47. package/dist/lib/reporting/ledger/receipts.d.ts +48 -0
  48. package/dist/lib/reporting/ledger/receipts.js +186 -0
  49. package/dist/lib/reporting/ledger/receipts.mjs +161 -0
  50. package/dist/lib/reporting/ledger/status-ingest.js +3 -3
  51. package/dist/lib/reporting/ledger/status-ingest.mjs +4 -5
  52. package/dist/lib/reporting/ledger/types.d.mts +43 -0
  53. package/dist/lib/reporting/ledger/types.d.ts +43 -0
  54. package/dist/lib/reporting/ledger/types.js +31 -2
  55. package/dist/lib/reporting/ledger/types.mjs +26 -1
  56. package/dist/lib/reporting/pagination.d.mts +6 -0
  57. package/dist/lib/reporting/pagination.d.ts +6 -0
  58. package/dist/lib/reporting/{gcs/errors.js → pagination.js} +12 -17
  59. package/dist/lib/reporting/pagination.mjs +12 -0
  60. package/dist/lib/reporting/reconciliation.d.mts +1 -0
  61. package/dist/lib/reporting/reconciliation.d.ts +1 -0
  62. package/dist/lib/reporting/reconciliation.js +3 -2
  63. package/dist/lib/reporting/reconciliation.mjs +3 -2
  64. package/dist/lib/reporting/service/index.d.mts +79 -153
  65. package/dist/lib/reporting/service/index.d.ts +79 -153
  66. package/dist/lib/reporting/service/index.js +34 -491
  67. package/dist/lib/reporting/service/index.mjs +36 -510
  68. package/dist/lib/reporting/service/scheduler-support.d.mts +43 -0
  69. package/dist/lib/reporting/service/scheduler-support.d.ts +43 -0
  70. package/dist/lib/reporting/service/scheduler-support.js +125 -0
  71. package/dist/lib/reporting/service/scheduler-support.mjs +96 -0
  72. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  73. package/dist/lib/signing/canonicalize.d.mts +4 -0
  74. package/dist/lib/signing/canonicalize.d.ts +4 -0
  75. package/dist/lib/signing/canonicalize.js +14 -8
  76. package/dist/lib/signing/canonicalize.mjs +14 -8
  77. package/dist/lib/signing/content-digest.d.mts +8 -0
  78. package/dist/lib/signing/content-digest.d.ts +8 -0
  79. package/dist/lib/signing/content-digest.js +11 -5
  80. package/dist/lib/signing/content-digest.mjs +10 -5
  81. package/dist/lib/signing/crypto.d.mts +15 -0
  82. package/dist/lib/signing/crypto.d.ts +15 -0
  83. package/dist/lib/signing/crypto.js +75 -3
  84. package/dist/lib/signing/crypto.mjs +78 -3
  85. package/dist/lib/signing/server.d.mts +1 -1
  86. package/dist/lib/signing/server.d.ts +1 -1
  87. package/dist/lib/signing/server.js +2 -0
  88. package/dist/lib/signing/server.mjs +2 -1
  89. package/dist/lib/signing/signer.js +11 -14
  90. package/dist/lib/signing/signer.mjs +13 -16
  91. package/dist/lib/signing/testing.js +2 -6
  92. package/dist/lib/signing/testing.mjs +3 -7
  93. package/dist/lib/signing/verifier.js +2 -2
  94. package/dist/lib/signing/verifier.mjs +3 -3
  95. package/dist/lib/signing/web-bot-auth.js +122 -43
  96. package/dist/lib/signing/web-bot-auth.mjs +128 -44
  97. package/dist/lib/signing/webhook-verifier.js +2 -2
  98. package/dist/lib/signing/webhook-verifier.mjs +3 -3
  99. package/dist/lib/substitution/compile.js +2 -1
  100. package/dist/lib/substitution/compile.mjs +2 -1
  101. package/dist/lib/substitution/consent-macros.d.mts +4 -0
  102. package/dist/lib/substitution/consent-macros.d.ts +4 -0
  103. package/dist/lib/substitution/consent-macros.js +45 -0
  104. package/dist/lib/substitution/consent-macros.mjs +20 -0
  105. package/dist/lib/substitution/index.d.mts +1 -1
  106. package/dist/lib/substitution/index.d.ts +1 -1
  107. package/dist/lib/substitution/index.js +2 -0
  108. package/dist/lib/substitution/index.mjs +2 -1
  109. package/dist/lib/substitution/translate.d.mts +15 -2
  110. package/dist/lib/substitution/translate.d.ts +15 -2
  111. package/dist/lib/substitution/translate.js +148 -26
  112. package/dist/lib/substitution/translate.mjs +147 -26
  113. package/dist/lib/testing/client.js +2 -1
  114. package/dist/lib/testing/client.mjs +2 -1
  115. package/dist/lib/testing/scenarios/capabilities.js +1 -1
  116. package/dist/lib/testing/scenarios/capabilities.mjs +1 -1
  117. package/dist/lib/testing/storyboard/junit.js +16 -3
  118. package/dist/lib/testing/storyboard/junit.mjs +16 -3
  119. package/dist/lib/testing/storyboard/request-signing/builder.js +12 -14
  120. package/dist/lib/testing/storyboard/request-signing/builder.mjs +13 -15
  121. package/dist/lib/testing/storyboard/runner.js +94 -25
  122. package/dist/lib/testing/storyboard/runner.mjs +94 -25
  123. package/dist/lib/testing/storyboard/signer-grader/grader.js +2 -7
  124. package/dist/lib/testing/storyboard/signer-grader/grader.mjs +2 -7
  125. package/dist/lib/testing/storyboard/types.d.mts +6 -0
  126. package/dist/lib/testing/storyboard/types.d.ts +6 -0
  127. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  128. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  129. package/dist/lib/types/enums.generated.d.mts +3 -0
  130. package/dist/lib/types/enums.generated.d.ts +3 -0
  131. package/dist/lib/types/enums.generated.js +9 -0
  132. package/dist/lib/types/enums.generated.mjs +6 -0
  133. package/dist/lib/validation/schema-loader.js +25 -0
  134. package/dist/lib/validation/schema-loader.mjs +24 -0
  135. package/dist/lib/version.d.mts +3 -3
  136. package/dist/lib/version.d.ts +3 -3
  137. package/dist/lib/version.js +3 -3
  138. package/dist/lib/version.mjs +3 -3
  139. package/docs/TYPE-SUMMARY.md +28 -5
  140. package/docs/guides/DISCOVERY-CACHE-AND-SESSION-REUSE.md +3 -2
  141. package/docs/guides/REPORTING-GCS-FENCE.md +3 -3
  142. package/docs/guides/REPORTING-GCS-MANAGED.md +4 -4
  143. package/docs/guides/REPORTING-LEDGER-CUTOVER.md +7 -7
  144. package/docs/guides/REPORTING-LEDGER.md +107 -51
  145. package/docs/guides/REPORTING-OPERATIONS.md +66 -5
  146. package/docs/guides/REPORTING-STABILITY.md +36 -32
  147. package/docs/guides/UNIVERSAL-MACRO-COMPILATION.md +38 -0
  148. package/docs/guides/VALIDATE-YOUR-AGENT.md +12 -0
  149. package/docs/llms.txt +4 -3
  150. package/docs/migration-14.x-rc-worksheet.md +4 -7
  151. package/docs/migration-reporting-storage-package.md +186 -0
  152. package/examples/README.md +1 -1
  153. package/package.json +14 -78
  154. package/dist/lib/reporting/azure/index.d.mts +0 -31
  155. package/dist/lib/reporting/azure/index.d.ts +0 -31
  156. package/dist/lib/reporting/azure/index.js +0 -266
  157. package/dist/lib/reporting/azure/index.mjs +0 -249
  158. package/dist/lib/reporting/bigquery/index.d.mts +0 -246
  159. package/dist/lib/reporting/bigquery/index.d.ts +0 -246
  160. package/dist/lib/reporting/bigquery/index.js +0 -633
  161. package/dist/lib/reporting/bigquery/index.mjs +0 -594
  162. package/dist/lib/reporting/gcs/adapter.d.mts +0 -38
  163. package/dist/lib/reporting/gcs/adapter.d.ts +0 -38
  164. package/dist/lib/reporting/gcs/adapter.js +0 -342
  165. package/dist/lib/reporting/gcs/adapter.mjs +0 -325
  166. package/dist/lib/reporting/gcs/bucket-policy.d.mts +0 -3
  167. package/dist/lib/reporting/gcs/bucket-policy.d.ts +0 -3
  168. package/dist/lib/reporting/gcs/bucket-policy.mjs +0 -7
  169. package/dist/lib/reporting/gcs/errors.d.mts +0 -11
  170. package/dist/lib/reporting/gcs/errors.d.ts +0 -11
  171. package/dist/lib/reporting/gcs/errors.mjs +0 -16
  172. package/dist/lib/reporting/gcs/fence.d.mts +0 -41
  173. package/dist/lib/reporting/gcs/fence.d.ts +0 -41
  174. package/dist/lib/reporting/gcs/fence.js +0 -250
  175. package/dist/lib/reporting/gcs/fence.mjs +0 -230
  176. package/dist/lib/reporting/gcs/index.d.mts +0 -18
  177. package/dist/lib/reporting/gcs/index.d.ts +0 -18
  178. package/dist/lib/reporting/gcs/index.js +0 -44
  179. package/dist/lib/reporting/gcs/index.mjs +0 -14
  180. package/dist/lib/reporting/gcs/io.d.mts +0 -7
  181. package/dist/lib/reporting/gcs/io.d.ts +0 -7
  182. package/dist/lib/reporting/gcs/io.js +0 -95
  183. package/dist/lib/reporting/gcs/io.mjs +0 -69
  184. package/dist/lib/reporting/gcs/reader.d.mts +0 -67
  185. package/dist/lib/reporting/gcs/reader.d.ts +0 -67
  186. package/dist/lib/reporting/gcs/reader.js +0 -193
  187. package/dist/lib/reporting/gcs/reader.mjs +0 -169
  188. package/dist/lib/reporting/gcs/row-provider.d.mts +0 -39
  189. package/dist/lib/reporting/gcs/row-provider.d.ts +0 -39
  190. package/dist/lib/reporting/gcs/row-provider.js +0 -225
  191. package/dist/lib/reporting/gcs/row-provider.mjs +0 -208
  192. package/dist/lib/reporting/gcs/validation.d.mts +0 -5
  193. package/dist/lib/reporting/gcs/validation.d.ts +0 -5
  194. package/dist/lib/reporting/gcs/validation.js +0 -49
  195. package/dist/lib/reporting/gcs/validation.mjs +0 -25
  196. package/dist/lib/reporting/ledger/change-feed.d.mts +0 -69
  197. package/dist/lib/reporting/ledger/change-feed.d.ts +0 -69
  198. package/dist/lib/reporting/ledger/change-feed.js +0 -107
  199. package/dist/lib/reporting/ledger/change-feed.mjs +0 -80
  200. package/dist/lib/reporting/ledger/managed-postgres.d.mts +0 -293
  201. package/dist/lib/reporting/ledger/managed-postgres.d.ts +0 -293
  202. package/dist/lib/reporting/ledger/managed-postgres.js +0 -2346
  203. package/dist/lib/reporting/ledger/managed-postgres.mjs +0 -2332
  204. package/dist/lib/reporting/ledger/managed-router.d.mts +0 -148
  205. package/dist/lib/reporting/ledger/managed-router.d.ts +0 -148
  206. package/dist/lib/reporting/ledger/managed-router.js +0 -280
  207. package/dist/lib/reporting/ledger/managed-router.mjs +0 -258
  208. package/dist/lib/reporting/ledger/managed.d.mts +0 -535
  209. package/dist/lib/reporting/ledger/managed.d.ts +0 -535
  210. package/dist/lib/reporting/ledger/managed.js +0 -761
  211. package/dist/lib/reporting/ledger/managed.mjs +0 -729
  212. package/dist/lib/reporting/ledger/notification-activity.d.mts +0 -332
  213. package/dist/lib/reporting/ledger/notification-activity.d.ts +0 -332
  214. package/dist/lib/reporting/ledger/notification-activity.js +0 -1366
  215. package/dist/lib/reporting/ledger/notification-activity.mjs +0 -1337
  216. package/dist/lib/reporting/ledger/object-writes.d.mts +0 -128
  217. package/dist/lib/reporting/ledger/object-writes.d.ts +0 -128
  218. package/dist/lib/reporting/ledger/object-writes.js +0 -147
  219. package/dist/lib/reporting/ledger/object-writes.mjs +0 -114
  220. package/dist/lib/reporting/ledger/postgres.d.mts +0 -689
  221. package/dist/lib/reporting/ledger/postgres.d.ts +0 -689
  222. package/dist/lib/reporting/ledger/postgres.js +0 -4462
  223. package/dist/lib/reporting/ledger/postgres.mjs +0 -4462
  224. package/dist/lib/reporting/ledger/row-storage-migration.d.mts +0 -59
  225. package/dist/lib/reporting/ledger/row-storage-migration.d.ts +0 -59
  226. package/dist/lib/reporting/ledger/row-storage-migration.js +0 -365
  227. package/dist/lib/reporting/ledger/row-storage-migration.mjs +0 -339
  228. package/dist/lib/reporting/ledger/row-storage-object.d.mts +0 -203
  229. package/dist/lib/reporting/ledger/row-storage-object.d.ts +0 -203
  230. package/dist/lib/reporting/ledger/row-storage-object.js +0 -379
  231. package/dist/lib/reporting/ledger/row-storage-object.mjs +0 -335
  232. package/dist/lib/reporting/ledger/row-storage-provider-io.d.mts +0 -44
  233. package/dist/lib/reporting/ledger/row-storage-provider-io.d.ts +0 -44
  234. package/dist/lib/reporting/ledger/row-storage-provider-io.js +0 -142
  235. package/dist/lib/reporting/ledger/row-storage-provider-io.mjs +0 -111
  236. package/dist/lib/reporting/ledger/row-storage.d.mts +0 -316
  237. package/dist/lib/reporting/ledger/row-storage.d.ts +0 -316
  238. package/dist/lib/reporting/ledger/row-storage.js +0 -812
  239. package/dist/lib/reporting/ledger/row-storage.mjs +0 -802
  240. package/dist/lib/reporting/s3/index.d.mts +0 -34
  241. package/dist/lib/reporting/s3/index.d.ts +0 -34
  242. package/dist/lib/reporting/s3/index.js +0 -347
  243. package/dist/lib/reporting/s3/index.mjs +0 -340
  244. package/dist/lib/reporting/service/maintenance.d.mts +0 -148
  245. package/dist/lib/reporting/service/maintenance.d.ts +0 -148
  246. package/dist/lib/reporting/service/maintenance.js +0 -185
  247. package/dist/lib/reporting/service/maintenance.mjs +0 -159
  248. package/examples/reliable-reporting-service/README.md +0 -169
@@ -1,14 +1,43 @@
1
1
  import { encodeUnreserved } from "./rfc3986.mjs";
2
- const UNIVERSAL_MACRO = /\{[A-Z][A-Z0-9_]*\}/g;
3
- const NATIVE_TOKEN_SHAPE = /^(?:%%.+%%|\{\{.+\}\}|\$\{.+\}|\[[A-Z][A-Z0-9_]*\])$/;
4
- const CONSENT_MACROS = /* @__PURE__ */ new Set([
5
- "{GDPR}",
6
- "{GDPR_CONSENT}",
7
- "{US_PRIVACY}",
8
- "{GPP_STRING}",
9
- "{GPP_SID}",
10
- "{LIMIT_AD_TRACKING}"
11
- ]);
2
+ import { isConsentMacro, isVendorScopedConsentMacro } from "./consent-macros.mjs";
3
+ function* macroTokens(text) {
4
+ const missingClosers = /* @__PURE__ */ new Set();
5
+ let cursor = 0;
6
+ while (cursor < text.length) {
7
+ let end = -1;
8
+ let native = true;
9
+ const close = text.startsWith("%%", cursor) ? "%%" : text.startsWith("{{", cursor) ? "}}" : text.startsWith("${", cursor) ? "}" : null;
10
+ if (close && !missingClosers.has(close)) {
11
+ const closer = text.indexOf(close, cursor + 2);
12
+ if (closer === -1) missingClosers.add(close);
13
+ else end = closer + close.length;
14
+ }
15
+ if (end === -1 && (text[cursor] === "{" || text[cursor] === "[")) {
16
+ let nameEnd = cursor + 1;
17
+ if (/[A-Z]/.test(text[nameEnd] ?? "")) {
18
+ nameEnd += 1;
19
+ while (/[A-Z0-9_]/.test(text[nameEnd] ?? "")) nameEnd += 1;
20
+ if (text[nameEnd] === (text[cursor] === "{" ? "}" : "]")) {
21
+ end = nameEnd + 1;
22
+ native = text[cursor] === "[";
23
+ }
24
+ }
25
+ }
26
+ if (end === -1) {
27
+ cursor += 1;
28
+ continue;
29
+ }
30
+ yield { text: text.slice(cursor, end), start: cursor, end, native };
31
+ cursor = end;
32
+ }
33
+ }
34
+ function hasNativeTokenSyntax(value) {
35
+ for (const token of macroTokens(value)) {
36
+ const minimumLength = token.text.startsWith("${") ? 3 : token.text.startsWith("[") ? 2 : 4;
37
+ if (token.native && token.text.length > minimumLength) return true;
38
+ }
39
+ return false;
40
+ }
12
41
  const UNSAFE_NATIVE_CHARACTER = /[\u0000-\u001F\u007F]/;
13
42
  class UnsafeNativeMappingError extends Error {
14
43
  code = "unsafe_native_mapping";
@@ -22,6 +51,83 @@ class UnsafeNativeMappingError extends Error {
22
51
  this.macro = macro;
23
52
  }
24
53
  }
54
+ class MultipleVendorConsentMacrosError extends Error {
55
+ code = "multiple_vendor_consent_macros";
56
+ macro;
57
+ constructor(macro) {
58
+ super(`Multiple vendor-scoped consent macros; second token is ${JSON.stringify(macro)}`);
59
+ this.name = "MultipleVendorConsentMacrosError";
60
+ this.macro = macro;
61
+ }
62
+ }
63
+ function overlappingRange(ranges, candidate) {
64
+ let low = 0;
65
+ let high = ranges.length;
66
+ while (low < high) {
67
+ const middle = Math.floor((low + high) / 2);
68
+ if (ranges[middle].end <= candidate.start) low = middle + 1;
69
+ else high = middle;
70
+ }
71
+ const range = ranges[low];
72
+ return range && range.start < candidate.end ? range : void 0;
73
+ }
74
+ function assertSingleScopedConsent(spans, mapping) {
75
+ const url = spans.map((span) => span.text).join("");
76
+ const concrete = [];
77
+ const sources = [];
78
+ let offset = 0;
79
+ for (const span of spans) {
80
+ const range = { start: offset, end: offset + span.text.length };
81
+ if (span.concrete && range.start < range.end) {
82
+ const previous = concrete[concrete.length - 1];
83
+ if (previous?.end === range.start) previous.end = range.end;
84
+ else concrete.push(range);
85
+ }
86
+ if (span.scopedSource && span.text.length > 0) sources.push({ ...range, macro: span.scopedSource });
87
+ offset = range.end;
88
+ }
89
+ const occurrences = [];
90
+ const shells = [];
91
+ for (const token of macroTokens(url)) {
92
+ const range = { start: token.start, end: token.end };
93
+ shells.push(range);
94
+ const canonical = token.text.startsWith("${") ? token.text.slice(1) : token.text;
95
+ if (isVendorScopedConsentMacro(canonical)) {
96
+ occurrences.push({ ...range, macro: canonical });
97
+ }
98
+ }
99
+ const aliases = [];
100
+ for (const [macro, entry] of Object.entries(mapping)) {
101
+ if (!isVendorScopedConsentMacro(macro) || !("native" in entry) || entry.native.length === 0) continue;
102
+ let start = url.indexOf(entry.native);
103
+ while (start !== -1) {
104
+ const range = { start, end: start + entry.native.length };
105
+ const shell = overlappingRange(shells, range);
106
+ const completeShell = shell?.start === range.start && shell.end === range.end;
107
+ const insideShell = shell && shell.start <= range.start && range.end <= shell.end && !completeShell;
108
+ const data = overlappingRange(concrete, range);
109
+ const entirelyConcrete = data && data.start <= range.start && range.end <= data.end;
110
+ if (!insideShell && (completeShell || !entirelyConcrete) && !overlappingRange(occurrences, range)) {
111
+ aliases.push({ ...range, macro });
112
+ }
113
+ start = url.indexOf(entry.native, range.end);
114
+ }
115
+ }
116
+ aliases.sort((a, b) => a.start - b.start || b.end - a.end);
117
+ const selectedAliases = [];
118
+ for (const alias of aliases) {
119
+ const previous = selectedAliases[selectedAliases.length - 1];
120
+ if (!previous || previous.end <= alias.start) selectedAliases.push(alias);
121
+ }
122
+ for (const alias of selectedAliases) occurrences.push(alias);
123
+ occurrences.sort((a, b) => a.start - b.start);
124
+ const unmatchedSources = sources.filter((source) => !overlappingRange(occurrences, source));
125
+ for (const source of unmatchedSources) occurrences.push(source);
126
+ occurrences.sort((a, b) => a.start - b.start);
127
+ const second = occurrences[1];
128
+ if (second) throw new MultipleVendorConsentMacrosError(second.macro);
129
+ return url;
130
+ }
25
131
  function translateUniversalMacros(input_pixel_url, mapping) {
26
132
  const suspect_native_values = [];
27
133
  const suspectSeen = /* @__PURE__ */ new Set();
@@ -34,11 +140,11 @@ function translateUniversalMacros(input_pixel_url, mapping) {
34
140
  }
35
141
  continue;
36
142
  }
37
- if (CONSENT_MACROS.has(macro) && !frozenConsentSeen.has(macro)) {
143
+ if (isConsentMacro(macro) && !frozenConsentSeen.has(macro)) {
38
144
  frozenConsentSeen.add(macro);
39
145
  frozen_consent_macros.push(macro);
40
146
  }
41
- if (NATIVE_TOKEN_SHAPE.test(entry.value) && !suspectSeen.has(macro)) {
147
+ if (hasNativeTokenSyntax(entry.value) && !suspectSeen.has(macro)) {
42
148
  suspectSeen.add(macro);
43
149
  suspect_native_values.push(macro);
44
150
  }
@@ -49,7 +155,7 @@ function translateUniversalMacros(input_pixel_url, mapping) {
49
155
  const queryIdx = withoutFragment.indexOf("?");
50
156
  if (queryIdx === -1) {
51
157
  return {
52
- url: input_pixel_url,
158
+ url: assertSingleScopedConsent([{ text: input_pixel_url }], mapping),
53
159
  dropped_params: [],
54
160
  unmapped_macros: [],
55
161
  dropped_consent_macros: [],
@@ -69,12 +175,12 @@ function translateUniversalMacros(input_pixel_url, mapping) {
69
175
  const eqIdx = rawParam.indexOf("=");
70
176
  const key = eqIdx === -1 ? rawParam : rawParam.slice(0, eqIdx);
71
177
  const value = eqIdx === -1 ? "" : rawParam.slice(eqIdx + 1);
72
- const tokens = value.match(UNIVERSAL_MACRO);
73
- if (!tokens) {
74
- outputParts.push(rawParam);
178
+ const tokens = [...macroTokens(value)].filter((token) => !token.native);
179
+ if (tokens.length === 0) {
180
+ outputParts.push([{ text: rawParam }]);
75
181
  continue;
76
182
  }
77
- const missing = tokens.filter((t) => !(t in mapping));
183
+ const missing = tokens.map((token) => token.text).filter((token) => !(token in mapping));
78
184
  if (missing.length > 0) {
79
185
  dropped_params.push(key);
80
186
  for (const m of missing) {
@@ -82,24 +188,38 @@ function translateUniversalMacros(input_pixel_url, mapping) {
82
188
  unmappedSeen.add(m);
83
189
  unmapped_macros.push(m);
84
190
  }
85
- if (CONSENT_MACROS.has(m) && !consentSeen.has(m)) {
191
+ if (isConsentMacro(m) && !consentSeen.has(m)) {
86
192
  consentSeen.add(m);
87
193
  dropped_consent_macros.push(m);
88
194
  }
89
195
  }
90
196
  continue;
91
197
  }
92
- const translated = value.replace(UNIVERSAL_MACRO, (token) => {
198
+ const translated = [{ text: `${key}=` }];
199
+ let cursor = 0;
200
+ for (const match of tokens) {
201
+ const token = match.text;
202
+ translated.push({ text: value.slice(cursor, match.start) });
93
203
  const entry = mapping[token];
94
- if (!entry) {
95
- return token;
204
+ if ("native" in entry) {
205
+ translated.push({
206
+ text: entry.native,
207
+ ...isVendorScopedConsentMacro(token) ? { scopedSource: token } : {}
208
+ });
209
+ } else {
210
+ translated.push({ text: encodeUnreserved(entry.value), concrete: true });
96
211
  }
97
- return "native" in entry ? entry.native : encodeUnreserved(entry.value);
98
- });
99
- outputParts.push(`${key}=${translated}`);
212
+ cursor = match.end;
213
+ }
214
+ translated.push({ text: value.slice(cursor) });
215
+ outputParts.push(translated);
100
216
  }
101
- const newQuery = outputParts.join("&");
102
- const url = newQuery ? `${base}?${newQuery}${fragment}` : `${base}${fragment}`;
217
+ const querySpans = outputParts.flatMap((part, index) => index === 0 ? part : [{ text: "&" }, ...part]);
218
+ const hasQuery = querySpans.some((span) => span.text.length > 0);
219
+ const url = assertSingleScopedConsent(
220
+ [{ text: base }, ...hasQuery ? [{ text: "?" }, ...querySpans] : [], { text: fragment }],
221
+ mapping
222
+ );
103
223
  return {
104
224
  url,
105
225
  dropped_params,
@@ -110,6 +230,7 @@ function translateUniversalMacros(input_pixel_url, mapping) {
110
230
  };
111
231
  }
112
232
  export {
233
+ MultipleVendorConsentMacrosError,
113
234
  UnsafeNativeMappingError,
114
235
  translateUniversalMacros
115
236
  };
@@ -55,6 +55,7 @@ var import_protocols = require('../protocols/index.js');
55
55
  var import_node_crypto = require("node:crypto");
56
56
  var import_node_async_hooks = require("node:async_hooks");
57
57
  var import_client_hooks = require('../validation/client-hooks.js');
58
+ var import_schema_loader = require('../validation/schema-loader.js');
58
59
  var import_error_extraction = require('../utils/error-extraction.js');
59
60
  var import_client = require('../signing/client.js');
60
61
  var import_storage_registry = require('../auth/oauth/storage-registry.js');
@@ -534,7 +535,7 @@ async function discoverAgentProfile(client, signal, schemaAdcpVersion) {
534
535
  caps.data,
535
536
  "strict",
536
537
  void 0,
537
- schemaAdcpVersion ?? client.getAdcpVersion()
538
+ (0, import_schema_loader.resolveServedValidationVersion)(caps.data, schemaAdcpVersion ?? client.getAdcpVersion())
538
539
  );
539
540
  if (!validation.valid) {
540
541
  profile.capabilities_schema_issues = validation.issues.map((issue) => ({
@@ -12,6 +12,7 @@ import { normalizeTransportOptions } from "../protocols/index.mjs";
12
12
  import { createHmac, hkdfSync, randomBytes } from "node:crypto";
13
13
  import { AsyncLocalStorage } from "node:async_hooks";
14
14
  import { validateIncomingResponse } from "../validation/client-hooks.mjs";
15
+ import { resolveServedValidationVersion } from "../validation/schema-loader.mjs";
15
16
  import { extractVersionUnsupportedDetails } from "../utils/error-extraction.mjs";
16
17
  import { buildAgentSigningContext } from "../signing/client.mjs";
17
18
  import { bindAgentStorage } from "../auth/oauth/storage-registry.mjs";
@@ -491,7 +492,7 @@ async function discoverAgentProfile(client, signal, schemaAdcpVersion) {
491
492
  caps.data,
492
493
  "strict",
493
494
  void 0,
494
- schemaAdcpVersion ?? client.getAdcpVersion()
495
+ resolveServedValidationVersion(caps.data, schemaAdcpVersion ?? client.getAdcpVersion())
495
496
  );
496
497
  if (!validation.valid) {
497
498
  profile.capabilities_schema_issues = validation.issues.map((issue) => ({
@@ -239,7 +239,7 @@ function crossValidateProtocolsAndTools(capabilities, tools) {
239
239
  creative: import_capabilities.CREATIVE_TOOLS,
240
240
  sponsored_intelligence: import_capabilities.SPONSORED_INTELLIGENCE_TOOLS,
241
241
  trusted_match: import_capabilities.TRUSTED_MATCH_TOOLS,
242
- compliance: import_capabilities.COMPLIANCE_TOOLS
242
+ compliance_testing: import_capabilities.COMPLIANCE_TOOLS
243
243
  };
244
244
  const perProtocolDiffs = {};
245
245
  for (const protocol of capabilities.protocols) {
@@ -225,7 +225,7 @@ function crossValidateProtocolsAndTools(capabilities, tools) {
225
225
  creative: CREATIVE_TOOLS,
226
226
  sponsored_intelligence: SPONSORED_INTELLIGENCE_TOOLS,
227
227
  trusted_match: TRUSTED_MATCH_TOOLS,
228
- compliance: COMPLIANCE_TOOLS
228
+ compliance_testing: COMPLIANCE_TOOLS
229
229
  };
230
230
  const perProtocolDiffs = {};
231
231
  for (const protocol of capabilities.protocols) {
@@ -82,8 +82,9 @@ function formatStoryboardResultsAsJUnit(results, options = {}) {
82
82
  const suiteGroup = options.suite_groups?.[sb.storyboard_id];
83
83
  const suiteClassname = suiteGroup ? `${suiteGroup}.${sb.storyboard_id}` : sb.storyboard_id;
84
84
  const suiteCases = [];
85
- let suiteFailures = sb.failed_count;
85
+ let suiteFailures = 0;
86
86
  let representedSkipped = 0;
87
+ let suiteSkipped = 0;
87
88
  const passPhases = sb.passes?.length ? sb.passes.map((pass) => ({ label: `Pass ${pass.pass_index} \u203A `, phases: pass.phases })) : [{ label: "", phases: sb.phases }];
88
89
  for (const pass of passPhases) {
89
90
  for (const phase of pass.phases) {
@@ -93,6 +94,7 @@ function formatStoryboardResultsAsJUnit(results, options = {}) {
93
94
  const time = ((step.duration_ms || 0) / 1e3).toFixed(3);
94
95
  if (step.skipped) {
95
96
  representedSkipped += 1;
97
+ suiteSkipped += 1;
96
98
  totalSkipped += 1;
97
99
  suiteCases.push(
98
100
  ` <testcase classname="${xmlEscape(suiteClassname)}" name="${xmlEscape(name)}" time="${time}">
@@ -102,7 +104,6 @@ function formatStoryboardResultsAsJUnit(results, options = {}) {
102
104
  continue;
103
105
  }
104
106
  if (!step.passed) {
105
- totalFailures += 1;
106
107
  const failureDetails = [
107
108
  step.error,
108
109
  ...step.validations.filter((v) => !v.passed).map(
@@ -114,6 +115,17 @@ function formatStoryboardResultsAsJUnit(results, options = {}) {
114
115
  // report body.
115
116
  ...hintLines(step.hints)
116
117
  ].filter(Boolean).join("\n");
118
+ if (step.counts_toward_failure === false) {
119
+ suiteCases.push(
120
+ ` <testcase classname="${xmlEscape(suiteClassname)}" name="${xmlEscape(name)}" time="${time}">
121
+ <system-out>${xmlEscape(`Optional phase failure; excluded from storyboard verdict.
122
+ ${failureDetails}`)}</system-out>
123
+ </testcase>`
124
+ );
125
+ continue;
126
+ }
127
+ totalFailures += 1;
128
+ suiteFailures += 1;
117
129
  const message = step.error || firstHintMessage(step) || "validation failed";
118
130
  suiteCases.push(
119
131
  ` <testcase classname="${xmlEscape(suiteClassname)}" name="${xmlEscape(name)}" time="${time}">
@@ -136,6 +148,7 @@ function formatStoryboardResultsAsJUnit(results, options = {}) {
136
148
  if (hasStoryboardFixtureSkip) {
137
149
  totalTests += 1;
138
150
  totalSkipped += 1;
151
+ suiteSkipped += 1;
139
152
  suiteCases.push(
140
153
  ` <testcase classname="${xmlEscape(suiteClassname)}" name="Fixture resolution" time="0.000">
141
154
  <skipped message="${xmlEscape(fixtureGap.detail)}"/>
@@ -159,7 +172,7 @@ ${assertion.error}` : ""}`;
159
172
  totalDuration += sb.total_duration_ms || 0;
160
173
  const suiteTests = suiteCases.length;
161
174
  suites.push(
162
- ` <testsuite name="${xmlEscape(suiteGroup ? `${suiteGroup} \u203A ${sb.storyboard_title}` : sb.storyboard_title)}"${suiteGroup ? ` package="${xmlEscape(`adcp.${suiteGroup}`)}"` : ""} tests="${suiteTests}" failures="${suiteFailures}" skipped="${sb.skipped_count}" time="${((sb.total_duration_ms || 0) / 1e3).toFixed(3)}" timestamp="${sb.tested_at || (/* @__PURE__ */ new Date()).toISOString()}">
175
+ ` <testsuite name="${xmlEscape(suiteGroup ? `${suiteGroup} \u203A ${sb.storyboard_title}` : sb.storyboard_title)}"${suiteGroup ? ` package="${xmlEscape(`adcp.${suiteGroup}`)}"` : ""} tests="${suiteTests}" failures="${suiteFailures}" skipped="${suiteSkipped}" time="${((sb.total_duration_ms || 0) / 1e3).toFixed(3)}" timestamp="${sb.tested_at || (/* @__PURE__ */ new Date()).toISOString()}">
163
176
  ` + suiteCases.join("\n") + `
164
177
  </testsuite>`
165
178
  );
@@ -58,8 +58,9 @@ function formatStoryboardResultsAsJUnit(results, options = {}) {
58
58
  const suiteGroup = options.suite_groups?.[sb.storyboard_id];
59
59
  const suiteClassname = suiteGroup ? `${suiteGroup}.${sb.storyboard_id}` : sb.storyboard_id;
60
60
  const suiteCases = [];
61
- let suiteFailures = sb.failed_count;
61
+ let suiteFailures = 0;
62
62
  let representedSkipped = 0;
63
+ let suiteSkipped = 0;
63
64
  const passPhases = sb.passes?.length ? sb.passes.map((pass) => ({ label: `Pass ${pass.pass_index} \u203A `, phases: pass.phases })) : [{ label: "", phases: sb.phases }];
64
65
  for (const pass of passPhases) {
65
66
  for (const phase of pass.phases) {
@@ -69,6 +70,7 @@ function formatStoryboardResultsAsJUnit(results, options = {}) {
69
70
  const time = ((step.duration_ms || 0) / 1e3).toFixed(3);
70
71
  if (step.skipped) {
71
72
  representedSkipped += 1;
73
+ suiteSkipped += 1;
72
74
  totalSkipped += 1;
73
75
  suiteCases.push(
74
76
  ` <testcase classname="${xmlEscape(suiteClassname)}" name="${xmlEscape(name)}" time="${time}">
@@ -78,7 +80,6 @@ function formatStoryboardResultsAsJUnit(results, options = {}) {
78
80
  continue;
79
81
  }
80
82
  if (!step.passed) {
81
- totalFailures += 1;
82
83
  const failureDetails = [
83
84
  step.error,
84
85
  ...step.validations.filter((v) => !v.passed).map(
@@ -90,6 +91,17 @@ function formatStoryboardResultsAsJUnit(results, options = {}) {
90
91
  // report body.
91
92
  ...hintLines(step.hints)
92
93
  ].filter(Boolean).join("\n");
94
+ if (step.counts_toward_failure === false) {
95
+ suiteCases.push(
96
+ ` <testcase classname="${xmlEscape(suiteClassname)}" name="${xmlEscape(name)}" time="${time}">
97
+ <system-out>${xmlEscape(`Optional phase failure; excluded from storyboard verdict.
98
+ ${failureDetails}`)}</system-out>
99
+ </testcase>`
100
+ );
101
+ continue;
102
+ }
103
+ totalFailures += 1;
104
+ suiteFailures += 1;
93
105
  const message = step.error || firstHintMessage(step) || "validation failed";
94
106
  suiteCases.push(
95
107
  ` <testcase classname="${xmlEscape(suiteClassname)}" name="${xmlEscape(name)}" time="${time}">
@@ -112,6 +124,7 @@ function formatStoryboardResultsAsJUnit(results, options = {}) {
112
124
  if (hasStoryboardFixtureSkip) {
113
125
  totalTests += 1;
114
126
  totalSkipped += 1;
127
+ suiteSkipped += 1;
115
128
  suiteCases.push(
116
129
  ` <testcase classname="${xmlEscape(suiteClassname)}" name="Fixture resolution" time="0.000">
117
130
  <skipped message="${xmlEscape(fixtureGap.detail)}"/>
@@ -135,7 +148,7 @@ ${assertion.error}` : ""}`;
135
148
  totalDuration += sb.total_duration_ms || 0;
136
149
  const suiteTests = suiteCases.length;
137
150
  suites.push(
138
- ` <testsuite name="${xmlEscape(suiteGroup ? `${suiteGroup} \u203A ${sb.storyboard_title}` : sb.storyboard_title)}"${suiteGroup ? ` package="${xmlEscape(`adcp.${suiteGroup}`)}"` : ""} tests="${suiteTests}" failures="${suiteFailures}" skipped="${sb.skipped_count}" time="${((sb.total_duration_ms || 0) / 1e3).toFixed(3)}" timestamp="${sb.tested_at || (/* @__PURE__ */ new Date()).toISOString()}">
151
+ ` <testsuite name="${xmlEscape(suiteGroup ? `${suiteGroup} \u203A ${sb.storyboard_title}` : sb.storyboard_title)}"${suiteGroup ? ` package="${xmlEscape(`adcp.${suiteGroup}`)}"` : ""} tests="${suiteTests}" failures="${suiteFailures}" skipped="${suiteSkipped}" time="${((sb.total_duration_ms || 0) / 1e3).toFixed(3)}" timestamp="${sb.tested_at || (/* @__PURE__ */ new Date()).toISOString()}">
139
152
  ` + suiteCases.join("\n") + `
140
153
  </testsuite>`
141
154
  );
@@ -24,6 +24,8 @@ __export(builder_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(builder_exports);
26
26
  var import_crypto = require("crypto");
27
+ var import_structured_headers = require("structured-headers");
28
+ var import_crypto2 = require('../../../signing/crypto.js');
27
29
  var import_signing = require('../../../signing/index.js');
28
30
  var import_vector_loader = require('./vector-loader.js');
29
31
  function buildPositiveRequest(vector, keys, options = {}) {
@@ -560,22 +562,18 @@ function refreshContentDigest(shaped, vector, shape) {
560
562
  });
561
563
  }
562
564
  function formatParamsWithOmissions(components, params, override) {
563
- const componentList = components.map((c) => `"${c}"`).join(" ");
564
- const pairs = [];
565
- pairs.push(`created=${params.created}`);
566
- if (!override.omitExpires) pairs.push(`expires=${params.expires}`);
567
- if (!override.omitNonce) pairs.push(`nonce="${params.nonce}"`);
568
- pairs.push(`keyid="${params.keyid}"`);
569
- pairs.push(`alg="${params.alg}"`);
570
- pairs.push(`tag="${params.tag}"`);
571
- return `(${componentList});${pairs.join(";")}`;
565
+ const omitted = /* @__PURE__ */ new Set([
566
+ ...override.omitExpires ? ["expires"] : [],
567
+ ...override.omitNonce ? ["nonce"] : []
568
+ ]);
569
+ const pairs = /* @__PURE__ */ new Map();
570
+ for (const key of ["created", "expires", "nonce", "keyid", "alg", "tag"]) {
571
+ if (!omitted.has(key) && params[key] !== void 0) pairs.set(key, params[key]);
572
+ }
573
+ return (0, import_structured_headers.serializeInnerList)([components.map((c) => [c, /* @__PURE__ */ new Map()]), pairs]);
572
574
  }
573
575
  function produceSignature(key, data) {
574
- const privateKey = (0, import_crypto.createPrivateKey)({ key: key.privateKey, format: "jwk" });
575
- if (key.alg === "ed25519") {
576
- return new Uint8Array((0, import_crypto.sign)(null, data, privateKey));
577
- }
578
- return new Uint8Array((0, import_crypto.sign)("sha256", data, { key: privateKey, dsaEncoding: "ieee-p1363" }));
576
+ return (0, import_crypto2.signWithPrivateJwk)(key.alg, key.privateKey, data);
579
577
  }
580
578
  function signerKeyFor(vector, keys) {
581
579
  const kid = vector.jwks_ref?.[0];
@@ -1,4 +1,6 @@
1
- import { createHash, createPrivateKey, randomBytes, randomUUID, sign as nodeSign } from "crypto";
1
+ import { createHash, randomBytes, randomUUID } from "crypto";
2
+ import { serializeInnerList } from "structured-headers";
3
+ import { signWithPrivateJwk } from "../../../signing/crypto.mjs";
2
4
  import {
3
5
  buildSignatureBase,
4
6
  computeContentDigest,
@@ -543,22 +545,18 @@ function refreshContentDigest(shaped, vector, shape) {
543
545
  });
544
546
  }
545
547
  function formatParamsWithOmissions(components, params, override) {
546
- const componentList = components.map((c) => `"${c}"`).join(" ");
547
- const pairs = [];
548
- pairs.push(`created=${params.created}`);
549
- if (!override.omitExpires) pairs.push(`expires=${params.expires}`);
550
- if (!override.omitNonce) pairs.push(`nonce="${params.nonce}"`);
551
- pairs.push(`keyid="${params.keyid}"`);
552
- pairs.push(`alg="${params.alg}"`);
553
- pairs.push(`tag="${params.tag}"`);
554
- return `(${componentList});${pairs.join(";")}`;
548
+ const omitted = /* @__PURE__ */ new Set([
549
+ ...override.omitExpires ? ["expires"] : [],
550
+ ...override.omitNonce ? ["nonce"] : []
551
+ ]);
552
+ const pairs = /* @__PURE__ */ new Map();
553
+ for (const key of ["created", "expires", "nonce", "keyid", "alg", "tag"]) {
554
+ if (!omitted.has(key) && params[key] !== void 0) pairs.set(key, params[key]);
555
+ }
556
+ return serializeInnerList([components.map((c) => [c, /* @__PURE__ */ new Map()]), pairs]);
555
557
  }
556
558
  function produceSignature(key, data) {
557
- const privateKey = createPrivateKey({ key: key.privateKey, format: "jwk" });
558
- if (key.alg === "ed25519") {
559
- return new Uint8Array(nodeSign(null, data, privateKey));
560
- }
561
- return new Uint8Array(nodeSign("sha256", data, { key: privateKey, dsaEncoding: "ieee-p1363" }));
559
+ return signWithPrivateJwk(key.alg, key.privateKey, data);
562
560
  }
563
561
  function signerKeyFor(vector, keys) {
564
562
  const kid = vector.jwks_ref?.[0];