@adcp/sdk 17.0.0-beta.21 → 17.0.0-beta.23

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 (223) hide show
  1. package/README.md +26 -2
  2. package/dist/lib/adapters/version/index.d.mts +1 -1
  3. package/dist/lib/adapters/version/index.d.ts +1 -1
  4. package/dist/lib/adapters/version/index.js +2 -0
  5. package/dist/lib/adapters/version/index.mjs +2 -0
  6. package/dist/lib/adapters/version/negotiate.d.mts +13 -0
  7. package/dist/lib/adapters/version/negotiate.d.ts +13 -0
  8. package/dist/lib/adapters/version/negotiate.js +6 -0
  9. package/dist/lib/adapters/version/negotiate.mjs +5 -0
  10. package/dist/lib/client/core.d.mts +4 -0
  11. package/dist/lib/client/core.d.ts +4 -0
  12. package/dist/lib/client/core.js +13 -0
  13. package/dist/lib/client/core.mjs +12 -0
  14. package/dist/lib/conformance/property-lists.d.mts +1 -1
  15. package/dist/lib/conformance/property-lists.d.ts +1 -1
  16. package/dist/lib/conformance/property-lists.js +1 -1
  17. package/dist/lib/conformance/property-lists.mjs +1 -1
  18. package/dist/lib/core/SingleAgentClient.d.mts +23 -1
  19. package/dist/lib/core/SingleAgentClient.d.ts +23 -1
  20. package/dist/lib/core/SingleAgentClient.js +102 -18
  21. package/dist/lib/core/SingleAgentClient.mjs +108 -18
  22. package/dist/lib/core/targeting-helpers.d.mts +123 -0
  23. package/dist/lib/core/targeting-helpers.d.ts +123 -0
  24. package/dist/lib/core/targeting-helpers.js +412 -0
  25. package/dist/lib/core/targeting-helpers.mjs +370 -0
  26. package/dist/lib/entrypoints/client-account-changes.d.mts +5 -0
  27. package/dist/lib/entrypoints/client-account-changes.d.ts +5 -0
  28. package/dist/lib/entrypoints/client-account-changes.js +28 -0
  29. package/dist/lib/entrypoints/client-account-changes.mjs +4 -0
  30. package/dist/lib/entrypoints/client-webhook-stores.d.mts +2 -0
  31. package/dist/lib/entrypoints/client-webhook-stores.d.ts +2 -0
  32. package/dist/lib/entrypoints/client-webhook-stores.js +37 -0
  33. package/dist/lib/entrypoints/client-webhook-stores.mjs +16 -0
  34. package/dist/lib/entrypoints/discovery.d.mts +9 -0
  35. package/dist/lib/entrypoints/discovery.d.ts +9 -0
  36. package/dist/lib/entrypoints/discovery.js +72 -0
  37. package/dist/lib/entrypoints/discovery.mjs +56 -0
  38. package/dist/lib/entrypoints/errors.d.mts +11 -0
  39. package/dist/lib/entrypoints/errors.d.ts +11 -0
  40. package/dist/lib/entrypoints/errors.js +159 -0
  41. package/dist/lib/entrypoints/errors.mjs +132 -0
  42. package/dist/lib/entrypoints/media-buy.d.mts +5 -0
  43. package/dist/lib/entrypoints/media-buy.d.ts +5 -0
  44. package/dist/lib/entrypoints/media-buy.js +119 -0
  45. package/dist/lib/entrypoints/media-buy.mjs +100 -0
  46. package/dist/lib/entrypoints/registry.d.mts +5 -0
  47. package/dist/lib/entrypoints/registry.d.ts +5 -0
  48. package/dist/lib/entrypoints/registry.js +61 -0
  49. package/dist/lib/entrypoints/registry.mjs +40 -0
  50. package/dist/lib/entrypoints/utils.d.mts +7 -0
  51. package/dist/lib/entrypoints/utils.d.ts +7 -0
  52. package/dist/lib/entrypoints/utils.js +100 -0
  53. package/dist/lib/entrypoints/utils.mjs +72 -0
  54. package/dist/lib/entrypoints/version.d.mts +3 -0
  55. package/dist/lib/entrypoints/version.d.ts +3 -0
  56. package/dist/lib/entrypoints/version.js +57 -0
  57. package/dist/lib/entrypoints/version.mjs +36 -0
  58. package/dist/lib/index.d.mts +1 -1
  59. package/dist/lib/index.d.ts +1 -1
  60. package/dist/lib/media-buy/action-contracts.js +3 -3
  61. package/dist/lib/media-buy/action-contracts.mjs +1 -1
  62. package/dist/lib/media-buy/creative-start-policy.d.mts +19 -0
  63. package/dist/lib/media-buy/creative-start-policy.d.ts +19 -0
  64. package/dist/lib/media-buy/creative-start-policy.js +59 -0
  65. package/dist/lib/media-buy/creative-start-policy.mjs +31 -0
  66. package/dist/lib/media-buy/valid-actions.d.mts +47 -0
  67. package/dist/lib/media-buy/valid-actions.d.ts +47 -0
  68. package/dist/lib/media-buy/valid-actions.js +42 -0
  69. package/dist/lib/media-buy/valid-actions.mjs +18 -0
  70. package/dist/lib/net/pin-and-bind-fetch.d.mts +121 -0
  71. package/dist/lib/net/pin-and-bind-fetch.d.ts +121 -0
  72. package/dist/lib/net/pin-and-bind-fetch.js +209 -0
  73. package/dist/lib/net/pin-and-bind-fetch.mjs +183 -0
  74. package/dist/lib/protocols/mcp-modern.js +20 -4
  75. package/dist/lib/protocols/mcp-modern.mjs +20 -4
  76. package/dist/lib/registry/types.generated.d.ts +224 -3
  77. package/dist/lib/reporting/ledger/index.d.mts +1 -0
  78. package/dist/lib/reporting/ledger/index.d.ts +1 -0
  79. package/dist/lib/reporting/ledger/index.js +3 -1
  80. package/dist/lib/reporting/ledger/index.mjs +1 -0
  81. package/dist/lib/reporting/ledger/instant.d.mts +5 -0
  82. package/dist/lib/reporting/ledger/instant.d.ts +5 -0
  83. package/dist/lib/reporting/ledger/instant.js +10 -0
  84. package/dist/lib/reporting/ledger/instant.mjs +9 -0
  85. package/dist/lib/reporting/ledger/issue-events.d.mts +333 -0
  86. package/dist/lib/reporting/ledger/issue-events.d.ts +333 -0
  87. package/dist/lib/reporting/ledger/issue-events.js +310 -0
  88. package/dist/lib/reporting/ledger/issue-events.mjs +282 -0
  89. package/dist/lib/reporting/service/index.d.mts +36 -1
  90. package/dist/lib/reporting/service/index.d.ts +36 -1
  91. package/dist/lib/reporting/service/index.js +51 -1
  92. package/dist/lib/reporting/service/index.mjs +52 -2
  93. package/dist/lib/reporting/service/scheduler-support.d.mts +1 -1
  94. package/dist/lib/reporting/service/scheduler-support.d.ts +1 -1
  95. package/dist/lib/reporting/service/scheduler-support.js +1 -1
  96. package/dist/lib/reporting/service/scheduler-support.mjs +1 -1
  97. package/dist/lib/server/capabilities-release-projection.d.mts +43 -0
  98. package/dist/lib/server/capabilities-release-projection.d.ts +43 -0
  99. package/dist/lib/server/capabilities-release-projection.js +128 -0
  100. package/dist/lib/server/capabilities-release-projection.mjs +112 -0
  101. package/dist/lib/server/create-adcp-server.d.mts +29 -5
  102. package/dist/lib/server/create-adcp-server.d.ts +29 -5
  103. package/dist/lib/server/create-adcp-server.js +97 -24
  104. package/dist/lib/server/create-adcp-server.mjs +108 -23
  105. package/dist/lib/server/decisioning/capabilities.d.mts +27 -0
  106. package/dist/lib/server/decisioning/capabilities.d.ts +27 -0
  107. package/dist/lib/server/decisioning/runtime/from-platform.js +99 -27
  108. package/dist/lib/server/decisioning/runtime/from-platform.mjs +103 -27
  109. package/dist/lib/server/declared-input-schema.d.mts +108 -0
  110. package/dist/lib/server/declared-input-schema.d.ts +108 -0
  111. package/dist/lib/server/declared-input-schema.js +167 -0
  112. package/dist/lib/server/declared-input-schema.mjs +137 -0
  113. package/dist/lib/server/envelope-allowlist.d.mts +1 -105
  114. package/dist/lib/server/envelope-allowlist.d.ts +1 -105
  115. package/dist/lib/server/envelope-allowlist.js +3 -79
  116. package/dist/lib/server/envelope-allowlist.mjs +1 -71
  117. package/dist/lib/server/errors.d.mts +1 -186
  118. package/dist/lib/server/errors.d.ts +1 -186
  119. package/dist/lib/server/errors.js +3 -98
  120. package/dist/lib/server/errors.mjs +1 -94
  121. package/dist/lib/server/index.d.mts +1 -1
  122. package/dist/lib/server/index.d.ts +1 -1
  123. package/dist/lib/server/mcp-modern-server.js +21 -4
  124. package/dist/lib/server/mcp-modern-server.mjs +21 -4
  125. package/dist/lib/server/media-buy-action-resolver.d.mts +7 -0
  126. package/dist/lib/server/media-buy-action-resolver.d.ts +7 -0
  127. package/dist/lib/server/media-buy-action-resolver.js +10 -1
  128. package/dist/lib/server/media-buy-action-resolver.mjs +10 -1
  129. package/dist/lib/server/media-buy-helpers.d.mts +1 -47
  130. package/dist/lib/server/media-buy-helpers.d.ts +1 -47
  131. package/dist/lib/server/media-buy-helpers.js +3 -23
  132. package/dist/lib/server/media-buy-helpers.mjs +1 -18
  133. package/dist/lib/server/pick-safe-details.d.mts +1 -89
  134. package/dist/lib/server/pick-safe-details.d.ts +1 -89
  135. package/dist/lib/server/pick-safe-details.js +3 -61
  136. package/dist/lib/server/pick-safe-details.mjs +1 -56
  137. package/dist/lib/server/pin-and-bind-fetch.d.mts +1 -121
  138. package/dist/lib/server/pin-and-bind-fetch.d.ts +1 -121
  139. package/dist/lib/server/pin-and-bind-fetch.js +3 -190
  140. package/dist/lib/server/pin-and-bind-fetch.mjs +1 -183
  141. package/dist/lib/server/targeting-helpers.d.mts +1 -123
  142. package/dist/lib/server/targeting-helpers.d.ts +1 -123
  143. package/dist/lib/server/targeting-helpers.js +3 -393
  144. package/dist/lib/server/targeting-helpers.mjs +1 -370
  145. package/dist/lib/server/test-controller.js +7 -3
  146. package/dist/lib/server/test-controller.mjs +7 -3
  147. package/dist/lib/storage/memory-ledger.js +219 -1
  148. package/dist/lib/storage/memory-ledger.mjs +223 -1
  149. package/dist/lib/testing/client.js +26 -5
  150. package/dist/lib/testing/client.mjs +24 -5
  151. package/dist/lib/testing/compliance/storyboard-tracks.js +0 -4
  152. package/dist/lib/testing/compliance/storyboard-tracks.mjs +0 -4
  153. package/dist/lib/testing/comply-controller.js +7 -2
  154. package/dist/lib/testing/comply-controller.mjs +7 -2
  155. package/dist/lib/testing/storyboard/request-signing/grader.d.mts +21 -0
  156. package/dist/lib/testing/storyboard/request-signing/grader.d.ts +21 -0
  157. package/dist/lib/testing/storyboard/request-signing/grader.js +31 -0
  158. package/dist/lib/testing/storyboard/request-signing/grader.mjs +30 -0
  159. package/dist/lib/testing/storyboard/request-signing/probe-dispatch.js +1 -1
  160. package/dist/lib/testing/storyboard/request-signing/probe-dispatch.mjs +2 -1
  161. package/dist/lib/testing/storyboard/request-signing/types.d.mts +12 -0
  162. package/dist/lib/testing/storyboard/request-signing/types.d.ts +12 -0
  163. package/dist/lib/testing/storyboard/request-signing/vector-loader.js +7 -2
  164. package/dist/lib/testing/storyboard/request-signing/vector-loader.mjs +7 -2
  165. package/dist/lib/testing/storyboard/runner.js +4 -4
  166. package/dist/lib/testing/storyboard/runner.mjs +4 -4
  167. package/dist/lib/testing/storyboard/task-map.js +4 -1
  168. package/dist/lib/testing/storyboard/task-map.mjs +4 -1
  169. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  170. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  171. package/dist/lib/utils/adcp-error-response.d.mts +196 -0
  172. package/dist/lib/utils/adcp-error-response.d.ts +196 -0
  173. package/dist/lib/utils/adcp-error-response.js +118 -0
  174. package/dist/lib/utils/adcp-error-response.mjs +95 -0
  175. package/dist/lib/utils/buyer-retry-policy.js +2 -2
  176. package/dist/lib/utils/buyer-retry-policy.mjs +1 -1
  177. package/dist/lib/utils/capabilities.d.mts +6 -0
  178. package/dist/lib/utils/capabilities.d.ts +6 -0
  179. package/dist/lib/utils/capabilities.js +6 -2
  180. package/dist/lib/utils/capabilities.mjs +6 -2
  181. package/dist/lib/utils/envelope-allowlist.d.mts +105 -0
  182. package/dist/lib/utils/envelope-allowlist.d.ts +105 -0
  183. package/dist/lib/utils/envelope-allowlist.js +98 -0
  184. package/dist/lib/utils/envelope-allowlist.mjs +71 -0
  185. package/dist/lib/utils/pick-safe-details.d.mts +89 -0
  186. package/dist/lib/utils/pick-safe-details.d.ts +89 -0
  187. package/dist/lib/utils/pick-safe-details.js +80 -0
  188. package/dist/lib/utils/pick-safe-details.mjs +56 -0
  189. package/dist/lib/v2/projection/augment-response.d.mts +4 -0
  190. package/dist/lib/v2/projection/augment-response.d.ts +4 -0
  191. package/dist/lib/v2/projection/creative-delivery.d.mts +20 -3
  192. package/dist/lib/v2/projection/creative-delivery.d.ts +20 -3
  193. package/dist/lib/v2/projection/creative-delivery.js +20 -4
  194. package/dist/lib/v2/projection/creative-delivery.mjs +19 -4
  195. package/dist/lib/v2/projection/index.d.mts +2 -2
  196. package/dist/lib/v2/projection/index.d.ts +2 -2
  197. package/dist/lib/v2/projection/index.js +4 -0
  198. package/dist/lib/v2/projection/index.mjs +5 -1
  199. package/dist/lib/v2/projection/legacy-metadata.d.mts +7 -0
  200. package/dist/lib/v2/projection/legacy-metadata.d.ts +7 -0
  201. package/dist/lib/v2/projection/legacy-metadata.js +14 -0
  202. package/dist/lib/v2/projection/legacy-metadata.mjs +12 -0
  203. package/dist/lib/v2/projection/legacy-routes.d.mts +11 -0
  204. package/dist/lib/v2/projection/legacy-routes.d.ts +11 -0
  205. package/dist/lib/v2/projection/legacy-routes.js +2 -1
  206. package/dist/lib/v2/projection/legacy-routes.mjs +7 -2
  207. package/dist/lib/v2/projection/v1-to-v2.d.mts +21 -1
  208. package/dist/lib/v2/projection/v1-to-v2.d.ts +21 -1
  209. package/dist/lib/v2/projection/v1-to-v2.js +18 -11
  210. package/dist/lib/v2/projection/v1-to-v2.mjs +19 -11
  211. package/dist/lib/version.d.mts +3 -3
  212. package/dist/lib/version.d.ts +3 -3
  213. package/dist/lib/version.js +3 -3
  214. package/dist/lib/version.mjs +3 -3
  215. package/docs/TYPE-SUMMARY.md +2 -2
  216. package/docs/guides/CREATIVE-DELIVERY.md +12 -0
  217. package/docs/guides/REPORTING-LEDGER.md +121 -0
  218. package/docs/guides/VALIDATE-YOUR-AGENT.md +1 -0
  219. package/docs/llms.txt +2 -2
  220. package/docs/migration-14.x-rc-worksheet.md +4 -4
  221. package/docs/migration-16-to-17.md +149 -0
  222. package/docs/migration-reporting-storage-package.md +10 -0
  223. package/package.json +106 -1
@@ -0,0 +1,183 @@
1
+ import { Agent, fetch as undiciFetch, Request as UndiciRequest } from "undici";
2
+ import { lookup as nativeDnsLookup } from "node:dns";
3
+ import { isIPv6 } from "node:net";
4
+ import { isAlwaysBlocked, isLoopbackIp, isPrivateIp } from "./address-guards.mjs";
5
+ import { enforceSsrfPolicy, enforceSsrfPolicyResolved } from "../substitution/observer/ssrf.mjs";
6
+ const WEBHOOK_SSRF_POLICY = Object.freeze({
7
+ schemes_allowed: Object.freeze(["https"]),
8
+ schemes_denied: Object.freeze(["http", "file", "gopher", "ftp", "ftps", "data", "javascript", "about", "ws", "wss"]),
9
+ hosts_denied_ipv4_cidrs: Object.freeze([
10
+ "0.0.0.0/8",
11
+ "10.0.0.0/8",
12
+ "100.64.0.0/10",
13
+ "127.0.0.0/8",
14
+ "169.254.0.0/16",
15
+ "172.16.0.0/12",
16
+ "192.0.0.0/24",
17
+ "192.168.0.0/16",
18
+ "224.0.0.0/4",
19
+ "240.0.0.0/4"
20
+ ]),
21
+ hosts_denied_ipv6_cidrs: Object.freeze([
22
+ "::1/128",
23
+ "::/128",
24
+ "::ffff:0:0/96",
25
+ "64:ff9b::/96",
26
+ "fc00::/7",
27
+ "fe80::/10",
28
+ "ff00::/8"
29
+ ]),
30
+ hosts_denied_metadata: Object.freeze([
31
+ "metadata.google.internal",
32
+ "metadata",
33
+ "metadata.packet.net",
34
+ "fd00:ec2::254"
35
+ ]),
36
+ host_literal_policy: "allow",
37
+ shared_private_address_policy: "deny"
38
+ });
39
+ const LOOPBACK_OK_WEBHOOK_SSRF_POLICY = Object.freeze({
40
+ schemes_allowed: Object.freeze(["http", "https"]),
41
+ schemes_denied: Object.freeze(["file", "gopher", "ftp", "ftps", "data", "javascript", "about", "ws", "wss"]),
42
+ hosts_denied_ipv4_cidrs: Object.freeze([
43
+ "0.0.0.0/8",
44
+ "10.0.0.0/8",
45
+ "100.64.0.0/10",
46
+ // 127.0.0.0/8 omitted — loopback allowed for tests.
47
+ "169.254.0.0/16",
48
+ "172.16.0.0/12",
49
+ "192.0.0.0/24",
50
+ "192.168.0.0/16",
51
+ "224.0.0.0/4",
52
+ "240.0.0.0/4"
53
+ ]),
54
+ hosts_denied_ipv6_cidrs: Object.freeze([
55
+ // ::1/128 and ::/128 omitted — IPv6 loopback allowed for tests.
56
+ "::ffff:0:0/96",
57
+ "64:ff9b::/96",
58
+ "fc00::/7",
59
+ "fe80::/10",
60
+ "ff00::/8"
61
+ ]),
62
+ hosts_denied_metadata: Object.freeze([
63
+ "metadata.google.internal",
64
+ "metadata",
65
+ "metadata.packet.net",
66
+ "fd00:ec2::254"
67
+ ]),
68
+ host_literal_policy: "allow",
69
+ shared_private_address_policy: "allow_loopback"
70
+ });
71
+ const DEFAULT_LOOKUP_ALL = (hostname, options, callback) => {
72
+ nativeDnsLookup(hostname, { ...options, all: true }, (err, addresses) => {
73
+ callback(err, addresses);
74
+ });
75
+ };
76
+ function createPinAndBindFetch(options = {}) {
77
+ const policy = options.policy ?? WEBHOOK_SSRF_POLICY;
78
+ const lookupImpl = options.lookup ?? DEFAULT_LOOKUP_ALL;
79
+ const guardedLookup = (hostname, opts, callback) => {
80
+ const wantsAll = opts?.all === true;
81
+ lookupImpl(hostname, { ...opts ?? {}, all: true }, (err, addresses) => {
82
+ if (err) {
83
+ callback(err);
84
+ return;
85
+ }
86
+ if (!Array.isArray(addresses) || addresses.length === 0) {
87
+ callback(
88
+ makeSsrfError(`DNS resolution returned no addresses for ${hostname}`, "dns_revalidation:no_addresses")
89
+ );
90
+ return;
91
+ }
92
+ const url = new URL(`https://${bracketIfV6(hostname)}`);
93
+ const ips = addresses.map((a) => a.address);
94
+ if (ips.some(isAlwaysBlocked)) {
95
+ callback(makeSsrfError(`Host ${hostname} resolves to an always-blocked address`, "always_blocked_address"));
96
+ return;
97
+ }
98
+ const result = enforceSsrfPolicyResolved(url, ips, policy);
99
+ if (!result.allowed) {
100
+ callback(makeSsrfError(`Host ${hostname} resolves to an address denied by SSRF policy`, result.rule ?? "ssrf"));
101
+ return;
102
+ }
103
+ if (ips.some((ip) => isSharedPrivateAddressDenied(ip, policy))) {
104
+ callback(
105
+ makeSsrfError(
106
+ `Host ${hostname} resolves to a private, non-routable, or reserved address`,
107
+ "shared_private_address"
108
+ )
109
+ );
110
+ return;
111
+ }
112
+ if (wantsAll) {
113
+ callback(null, addresses);
114
+ return;
115
+ }
116
+ const first = addresses[0];
117
+ callback(null, first.address, first.family);
118
+ });
119
+ };
120
+ const dispatcher = new Agent({
121
+ ...options.agentOptions ?? {},
122
+ connect: {
123
+ ...options.agentOptions?.connect ?? {},
124
+ // undici's connect type accepts a lookup with the dns.lookup signature.
125
+ lookup: guardedLookup
126
+ }
127
+ });
128
+ const wrapped = async (input, init) => {
129
+ const url = resolveRequestUrl(input);
130
+ if (!url) {
131
+ throw makeSsrfError("Unsupported or invalid URL input", "invalid_url");
132
+ }
133
+ const hostname = url.hostname.replace(/^\[|\]$/g, "");
134
+ if (isAlwaysBlocked(hostname)) {
135
+ throw makeSsrfError(`Host ${hostname} is an always-blocked address`, "always_blocked_address");
136
+ }
137
+ const sync = enforceSsrfPolicy(url, policy);
138
+ if (!sync.allowed) {
139
+ throw makeSsrfError(sync.message ?? "SSRF policy denied URL", sync.rule ?? "ssrf");
140
+ }
141
+ if (isSharedPrivateAddressDenied(hostname, policy)) {
142
+ throw makeSsrfError(`Host ${hostname} is a private, non-routable, or reserved address`, "shared_private_address");
143
+ }
144
+ const redirect = init?.redirect === "error" ? "error" : "manual";
145
+ const runtimeInput = input;
146
+ const checkedInput = runtimeInput instanceof globalThis.Request || runtimeInput instanceof UndiciRequest ? new UndiciRequest(url.href, runtimeInput) : url.href;
147
+ return undiciFetch(checkedInput, {
148
+ ...init,
149
+ redirect,
150
+ dispatcher
151
+ });
152
+ };
153
+ return wrapped;
154
+ }
155
+ function isSharedPrivateAddressDenied(address, policy) {
156
+ if (!isPrivateIp(address)) return false;
157
+ if (policy.shared_private_address_policy === "deny") return true;
158
+ if (policy.shared_private_address_policy === "allow_loopback") return !isLoopbackIp(address);
159
+ return false;
160
+ }
161
+ function resolveRequestUrl(input) {
162
+ try {
163
+ if (typeof input === "string") return new URL(input);
164
+ if (input instanceof URL) return new URL(input.href);
165
+ if (input instanceof globalThis.Request || input instanceof UndiciRequest) return new URL(input.url);
166
+ } catch {
167
+ return null;
168
+ }
169
+ return null;
170
+ }
171
+ function bracketIfV6(host) {
172
+ return isIPv6(host) ? `[${host}]` : host;
173
+ }
174
+ function makeSsrfError(message, rule) {
175
+ const err = new Error(`pin-and-bind: ${rule}: ${message}`);
176
+ err.code = "EADCP_SSRF_BLOCKED";
177
+ return err;
178
+ }
179
+ export {
180
+ LOOPBACK_OK_WEBHOOK_SSRF_POLICY,
181
+ WEBHOOK_SSRF_POLICY,
182
+ createPinAndBindFetch
183
+ };
@@ -216,13 +216,20 @@ function evictLeastRecentlyUsed() {
216
216
  function isNegotiationAuthFailure(error) {
217
217
  return (0, import_errors.is401Error)(error) || httpStatusOf(error) === 403;
218
218
  }
219
- function presentedStaticCredential(authHeaders, authProvider) {
220
- if (authProvider) return false;
219
+ function mayRetryProbeRefusalOnLegacy(authProvider) {
220
+ return !authProvider;
221
+ }
222
+ function presentedStaticCredential(authHeaders) {
221
223
  return Object.keys(authHeaders).some((key) => {
222
224
  const lower = key.toLowerCase();
223
225
  return lower === "authorization" || lower === "x-adcp-auth";
224
226
  });
225
227
  }
228
+ function legacyFailureSupersedesProbe(error) {
229
+ if ((0, import_abort.isAbortOrTimeoutError)(error)) return true;
230
+ const status = httpStatusOf(error);
231
+ return status === 429 || status === 503 && retryAfterOf(error) !== void 0;
232
+ }
226
233
  async function createNegotiatedClient(cacheKey, options, authHeaders, useCachedDiscovery = true, skipProbe = false) {
227
234
  const generation = connectionGeneration;
228
235
  const clientRequestTimeoutMs = (0, import_abort.resolveClientRequestTimeoutMs)(options.requestTimeoutMs);
@@ -299,8 +306,17 @@ async function createNegotiatedClient(cacheKey, options, authHeaders, useCachedD
299
306
  if (prior && !skipProbe && import_client.SdkError.isInstance(error) && error.code === import_client.SdkErrorCode.EraNegotiationFailed) {
300
307
  return createNegotiatedClient(cacheKey, options, authHeaders, false);
301
308
  }
302
- if (isNegotiationAuthFailure(error) && !skipProbe && presentedStaticCredential(authHeaders, options.authProvider)) {
303
- return createNegotiatedClient(cacheKey, options, authHeaders, useCachedDiscovery, true);
309
+ if (isNegotiationAuthFailure(error) && !skipProbe && mayRetryProbeRefusalOnLegacy(options.authProvider)) {
310
+ options.debugLogs.push({
311
+ type: "info",
312
+ message: `MCP: server/discover was refused (HTTP ${httpStatusOf(error) ?? 401}); retrying with legacy initialize`,
313
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
314
+ });
315
+ const legacy = createNegotiatedClient(cacheKey, options, authHeaders, useCachedDiscovery, true);
316
+ if (presentedStaticCredential(authHeaders)) return legacy;
317
+ return legacy.catch((legacyError) => {
318
+ throw legacyFailureSupersedesProbe(legacyError) ? legacyError : withRetryAfter(error, throttleRetryAfter);
319
+ });
304
320
  }
305
321
  throw withRetryAfter(error, throttleRetryAfter);
306
322
  }
@@ -223,13 +223,20 @@ function evictLeastRecentlyUsed() {
223
223
  function isNegotiationAuthFailure(error) {
224
224
  return is401Error(error) || httpStatusOf(error) === 403;
225
225
  }
226
- function presentedStaticCredential(authHeaders, authProvider) {
227
- if (authProvider) return false;
226
+ function mayRetryProbeRefusalOnLegacy(authProvider) {
227
+ return !authProvider;
228
+ }
229
+ function presentedStaticCredential(authHeaders) {
228
230
  return Object.keys(authHeaders).some((key) => {
229
231
  const lower = key.toLowerCase();
230
232
  return lower === "authorization" || lower === "x-adcp-auth";
231
233
  });
232
234
  }
235
+ function legacyFailureSupersedesProbe(error) {
236
+ if (isAbortOrTimeoutError(error)) return true;
237
+ const status = httpStatusOf(error);
238
+ return status === 429 || status === 503 && retryAfterOf(error) !== void 0;
239
+ }
233
240
  async function createNegotiatedClient(cacheKey, options, authHeaders, useCachedDiscovery = true, skipProbe = false) {
234
241
  const generation = connectionGeneration;
235
242
  const clientRequestTimeoutMs = resolveClientRequestTimeoutMs(options.requestTimeoutMs);
@@ -306,8 +313,17 @@ async function createNegotiatedClient(cacheKey, options, authHeaders, useCachedD
306
313
  if (prior && !skipProbe && SdkError.isInstance(error) && error.code === SdkErrorCode.EraNegotiationFailed) {
307
314
  return createNegotiatedClient(cacheKey, options, authHeaders, false);
308
315
  }
309
- if (isNegotiationAuthFailure(error) && !skipProbe && presentedStaticCredential(authHeaders, options.authProvider)) {
310
- return createNegotiatedClient(cacheKey, options, authHeaders, useCachedDiscovery, true);
316
+ if (isNegotiationAuthFailure(error) && !skipProbe && mayRetryProbeRefusalOnLegacy(options.authProvider)) {
317
+ options.debugLogs.push({
318
+ type: "info",
319
+ message: `MCP: server/discover was refused (HTTP ${httpStatusOf(error) ?? 401}); retrying with legacy initialize`,
320
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
321
+ });
322
+ const legacy = createNegotiatedClient(cacheKey, options, authHeaders, useCachedDiscovery, true);
323
+ if (presentedStaticCredential(authHeaders)) return legacy;
324
+ return legacy.catch((legacyError) => {
325
+ throw legacyFailureSupersedesProbe(legacyError) ? legacyError : withRetryAfter(error, throttleRetryAfter);
326
+ });
311
327
  }
312
328
  throw withRetryAfter(error, throttleRetryAfter);
313
329
  }
@@ -68,6 +68,48 @@ export interface paths {
68
68
  patch?: never;
69
69
  trace?: never;
70
70
  };
71
+ "/assets/brands/{domain}/{logoId}.{ext}": {
72
+ parameters: {
73
+ query?: never;
74
+ header?: never;
75
+ path?: never;
76
+ cookie?: never;
77
+ };
78
+ /**
79
+ * Get brand logo
80
+ * @description Download an approved AgenticAdvertising.org-hosted brand logo. This is the URL form that `brand_manifest.logos[].url` uses. When `ext` does not match the stored type, the response is a 301 to the canonical extension, keeping `format` and `w`.
81
+ *
82
+ * Add `?format=png&w=<width>` for a PNG rendition, for clients that cannot draw SVG. Renditions are rasterised from the stored, sanitised logo only; the endpoint never fetches a remote URL.
83
+ */
84
+ get: operations["getBrandLogoAsset"];
85
+ put?: never;
86
+ post?: never;
87
+ delete?: never;
88
+ options?: never;
89
+ head?: never;
90
+ patch?: never;
91
+ trace?: never;
92
+ };
93
+ "/logos/brands/{domain}/{logoId}": {
94
+ parameters: {
95
+ query?: never;
96
+ header?: never;
97
+ path?: never;
98
+ cookie?: never;
99
+ };
100
+ /**
101
+ * Get brand logo (legacy URL)
102
+ * @description Legacy form of the brand logo URL, without an extension. Accepts the same `format` and `w` rendition parameters as `/assets/brands/{domain}/{logoId}.{ext}`.
103
+ */
104
+ get: operations["getBrandLogoLegacy"];
105
+ put?: never;
106
+ post?: never;
107
+ delete?: never;
108
+ options?: never;
109
+ head?: never;
110
+ patch?: never;
111
+ trace?: never;
112
+ };
71
113
  "/api/brands/brand-json": {
72
114
  parameters: {
73
115
  query?: never;
@@ -2346,10 +2388,11 @@ export interface components {
2346
2388
  suggestion?: string;
2347
2389
  }[];
2348
2390
  brand_agent_url?: string;
2391
+ /** @description Stored or origin brand manifest. Each logo object in `logos[]` (and in `brands[].logos[]`) carries `background`, the brand.json field naming the background the logo is drawn for: `light-bg` (dark ink), `dark-bg` (light ink) or `transparent-bg`. A declared `background` in that enum is returned as published; any other declared value is treated as undeclared and is never returned. Otherwise it comes from a `light-bg` or `dark-bg` tag, then a `transparent-bg` tag, and for AgenticAdvertising.org-hosted logos from the luminance of the rendered logo (`light-bg` or `dark-bg`). It is absent when none of these is known. */
2349
2392
  brand_manifest?: {
2350
2393
  [key: string]: unknown;
2351
2394
  };
2352
- /** @description Complete brand entry selected from the same source as this response, retaining brand.json field shapes including localized names, tagline, fonts, colors, and tone. A portfolio contributes only the uniquely selected inline entry; a canonical document contributes the brand document itself. Absent for unresolved/ambiguous entries and agent-only or unexpanded pointer documents. Existing brand_manifest semantics are unchanged; brand is identity data, not additional relationship authorization. */
2395
+ /** @description Complete brand entry selected from the same source as this response, retaining brand.json field shapes including localized names, tagline, fonts, colors, and tone. A portfolio contributes only the uniquely selected inline entry; a canonical document contributes the brand document itself. Absent for unresolved/ambiguous entries and agent-only or unexpanded pointer documents. Existing brand_manifest semantics are unchanged; brand is identity data, not additional relationship authorization. Logos in `brand.logos[]` carry `background` on the same rules as `brand_manifest.logos[]`. */
2353
2396
  brand?: {
2354
2397
  [key: string]: unknown;
2355
2398
  };
@@ -2645,7 +2688,7 @@ export interface components {
2645
2688
  tracks: {
2646
2689
  [key: string]: string;
2647
2690
  };
2648
- /** @description Latest-run per-track summary. Skipped tracks with has_coverage_gap_skip=true represent selected coverage gaps, such as missing_test_controller. */
2691
+ /** @description Latest-run per-track summary. A track with has_coverage_gap_skip=true has steps that were not exercised for a setup reason, such as a runner fixture gap (fixture_unavailable) or a missing comply_test_controller. The track may still pass. */
2649
2692
  track_details?: {
2650
2693
  track: string;
2651
2694
  status: string;
@@ -2653,7 +2696,13 @@ export interface components {
2653
2696
  passed_count: number;
2654
2697
  duration_ms: number;
2655
2698
  has_coverage_gap_skip?: boolean;
2699
+ /** @description Skipped steps in this track, counted by skip reason (e.g. fixture_unavailable, missing_test_controller, capability_unsupported). Absent when nothing was skipped. */
2700
+ skipped_by_reason?: {
2701
+ [key: string]: number;
2702
+ };
2656
2703
  }[];
2704
+ /** @description True when any track in the latest run has a coverage-gap skip. Reported beside status, not folded into it: a passing run can have incomplete coverage, and storyboards that were not exercised do not count toward verification badges. */
2705
+ coverage_incomplete?: boolean;
2657
2706
  streak_days: number;
2658
2707
  last_checked_at: string | null;
2659
2708
  headline: string | null;
@@ -4233,7 +4282,7 @@ export interface components {
4233
4282
  tracks?: {
4234
4283
  [key: string]: string;
4235
4284
  };
4236
- /** @description Latest-run per-track summary. Skipped tracks with has_coverage_gap_skip=true represent selected coverage gaps, such as missing_test_controller. */
4285
+ /** @description Latest-run per-track summary. A track with has_coverage_gap_skip=true has steps that were not exercised for a setup reason, such as a runner fixture gap (fixture_unavailable) or a missing comply_test_controller. The track may still pass. */
4237
4286
  track_details?: {
4238
4287
  track: string;
4239
4288
  status: string;
@@ -4241,7 +4290,13 @@ export interface components {
4241
4290
  passed_count: number;
4242
4291
  duration_ms: number;
4243
4292
  has_coverage_gap_skip?: boolean;
4293
+ /** @description Skipped steps in this track, counted by skip reason (e.g. fixture_unavailable, missing_test_controller, capability_unsupported). Absent when nothing was skipped. */
4294
+ skipped_by_reason?: {
4295
+ [key: string]: number;
4296
+ };
4244
4297
  }[];
4298
+ /** @description True when any track in the latest run has a coverage-gap skip. Reported beside status, not folded into it: a passing run can have incomplete coverage, and storyboards that were not exercised do not count toward verification badges. */
4299
+ coverage_incomplete?: boolean;
4245
4300
  streak_days?: number;
4246
4301
  last_checked_at?: string | null;
4247
4302
  last_passed_at?: string | null;
@@ -4623,6 +4678,8 @@ export interface components {
4623
4678
  relevant_bundle_ids: string[];
4624
4679
  failing_bundle_count: number;
4625
4680
  incomplete_bundle_count: number;
4681
+ /** @description Universal bundles left partial only because the agent advertises none of the tools for a surface it does not declare. They do not count as incomplete. */
4682
+ not_applicable_universal_bundle_ids?: string[];
4626
4683
  relevant_failure_count: number;
4627
4684
  missing_universal_bundle: boolean;
4628
4685
  missing_protocol_bundle: boolean;
@@ -4683,6 +4740,8 @@ export interface components {
4683
4740
  tracks_skipped: number;
4684
4741
  tracks_partial: number;
4685
4742
  tracks_json?: unknown;
4743
+ /** @description True when any track in this run has a coverage-gap skip (tracks_json[].has_coverage_gap_skip). */
4744
+ coverage_incomplete?: boolean;
4686
4745
  total_duration_ms: number | null;
4687
4746
  triggered_by: string;
4688
4747
  tested_at: string;
@@ -5278,6 +5337,168 @@ export interface operations {
5278
5337
  };
5279
5338
  };
5280
5339
  };
5340
+ getBrandLogoAsset: {
5341
+ parameters: {
5342
+ query?: {
5343
+ /** @description Return a PNG rendition instead of the stored bytes. SVG logos are rasterised at the requested width; raster logos are converted to PNG and never enlarged past their natural width. Omit `format` and `w` for the original bytes. */
5344
+ format?: "png";
5345
+ /** @description Rendition width in pixels; requires `format=png`. Defaults to 512. Height follows the logo's aspect ratio, capped at four times the width. */
5346
+ w?: "64" | "128" | "256" | "512" | "1024";
5347
+ };
5348
+ header?: never;
5349
+ path: {
5350
+ domain: string;
5351
+ logoId: string;
5352
+ ext: string;
5353
+ };
5354
+ cookie?: never;
5355
+ };
5356
+ requestBody?: never;
5357
+ responses: {
5358
+ /** @description The logo, or its PNG rendition. Served with `Cache-Control: public, max-age=2592000`: a logo id names immutable bytes, so a changed logo gets a new id and URL. */
5359
+ 200: {
5360
+ headers: {
5361
+ [name: string]: unknown;
5362
+ };
5363
+ content: {
5364
+ "image/png": string;
5365
+ "image/svg+xml": string;
5366
+ "image/jpeg": string;
5367
+ "image/webp": string;
5368
+ "image/gif": string;
5369
+ };
5370
+ };
5371
+ /** @description Redirect to the URL with the stored type's extension */
5372
+ 301: {
5373
+ headers: {
5374
+ [name: string]: unknown;
5375
+ };
5376
+ content?: never;
5377
+ };
5378
+ /** @description Invalid domain, logo id, `format` or `w` */
5379
+ 400: {
5380
+ headers: {
5381
+ [name: string]: unknown;
5382
+ };
5383
+ content: {
5384
+ "application/json": components["schemas"]["Error"];
5385
+ };
5386
+ };
5387
+ /** @description No approved logo with this id for this domain */
5388
+ 404: {
5389
+ headers: {
5390
+ [name: string]: unknown;
5391
+ };
5392
+ content: {
5393
+ "application/json": components["schemas"]["Error"];
5394
+ };
5395
+ };
5396
+ /** @description The stored logo type (for example ICO) has no PNG rendition */
5397
+ 415: {
5398
+ headers: {
5399
+ [name: string]: unknown;
5400
+ };
5401
+ content: {
5402
+ "application/json": components["schemas"]["Error"];
5403
+ };
5404
+ };
5405
+ /** @description The stored logo could not be rendered as PNG */
5406
+ 422: {
5407
+ headers: {
5408
+ [name: string]: unknown;
5409
+ };
5410
+ content: {
5411
+ "application/json": components["schemas"]["Error"];
5412
+ };
5413
+ };
5414
+ /** @description Too many renditions are already being rendered; retry after the `Retry-After` interval */
5415
+ 503: {
5416
+ headers: {
5417
+ [name: string]: unknown;
5418
+ };
5419
+ content: {
5420
+ "application/json": components["schemas"]["Error"];
5421
+ };
5422
+ };
5423
+ };
5424
+ };
5425
+ getBrandLogoLegacy: {
5426
+ parameters: {
5427
+ query?: {
5428
+ /** @description Return a PNG rendition instead of the stored bytes. SVG logos are rasterised at the requested width; raster logos are converted to PNG and never enlarged past their natural width. Omit `format` and `w` for the original bytes. */
5429
+ format?: "png";
5430
+ /** @description Rendition width in pixels; requires `format=png`. Defaults to 512. Height follows the logo's aspect ratio, capped at four times the width. */
5431
+ w?: "64" | "128" | "256" | "512" | "1024";
5432
+ };
5433
+ header?: never;
5434
+ path: {
5435
+ domain: string;
5436
+ logoId: string;
5437
+ };
5438
+ cookie?: never;
5439
+ };
5440
+ requestBody?: never;
5441
+ responses: {
5442
+ /** @description The logo, or its PNG rendition. Served with `Cache-Control: public, max-age=2592000`: a logo id names immutable bytes, so a changed logo gets a new id and URL. */
5443
+ 200: {
5444
+ headers: {
5445
+ [name: string]: unknown;
5446
+ };
5447
+ content: {
5448
+ "image/png": string;
5449
+ "image/svg+xml": string;
5450
+ "image/jpeg": string;
5451
+ "image/webp": string;
5452
+ "image/gif": string;
5453
+ };
5454
+ };
5455
+ /** @description Invalid domain, logo id, `format` or `w` */
5456
+ 400: {
5457
+ headers: {
5458
+ [name: string]: unknown;
5459
+ };
5460
+ content: {
5461
+ "application/json": components["schemas"]["Error"];
5462
+ };
5463
+ };
5464
+ /** @description No approved logo with this id for this domain */
5465
+ 404: {
5466
+ headers: {
5467
+ [name: string]: unknown;
5468
+ };
5469
+ content: {
5470
+ "application/json": components["schemas"]["Error"];
5471
+ };
5472
+ };
5473
+ /** @description The stored logo type (for example ICO) has no PNG rendition */
5474
+ 415: {
5475
+ headers: {
5476
+ [name: string]: unknown;
5477
+ };
5478
+ content: {
5479
+ "application/json": components["schemas"]["Error"];
5480
+ };
5481
+ };
5482
+ /** @description The stored logo could not be rendered as PNG */
5483
+ 422: {
5484
+ headers: {
5485
+ [name: string]: unknown;
5486
+ };
5487
+ content: {
5488
+ "application/json": components["schemas"]["Error"];
5489
+ };
5490
+ };
5491
+ /** @description Too many renditions are already being rendered; retry after the `Retry-After` interval */
5492
+ 503: {
5493
+ headers: {
5494
+ [name: string]: unknown;
5495
+ };
5496
+ content: {
5497
+ "application/json": components["schemas"]["Error"];
5498
+ };
5499
+ };
5500
+ };
5501
+ };
5281
5502
  getBrandJson: {
5282
5503
  parameters: {
5283
5504
  query: {
@@ -27,6 +27,7 @@ export * from './row-encoding.mjs';
27
27
  export * from './row-storage-errors.mjs';
28
28
  export * from './receipts.mjs';
29
29
  export * from './offering-validation.mjs';
30
+ export * from './issue-events.mjs';
30
31
  export { compareReportingInstants } from './instant.mjs';
31
32
  export { isFrozenCalendarRulesMismatch, reportingPeriodDate, reportingPeriodSchedule } from './schedule.mjs';
32
33
  export { isReportingAdjustmentReceiptEvidence, isReportingReceiptEvidence, isReportingVerificationEvidence, } from '../evidence.mjs';
@@ -27,6 +27,7 @@ export * from './row-encoding';
27
27
  export * from './row-storage-errors';
28
28
  export * from './receipts';
29
29
  export * from './offering-validation';
30
+ export * from './issue-events';
30
31
  export { compareReportingInstants } from './instant';
31
32
  export { isFrozenCalendarRulesMismatch, reportingPeriodDate, reportingPeriodSchedule } from './schedule';
32
33
  export { isReportingAdjustmentReceiptEvidence, isReportingReceiptEvidence, isReportingVerificationEvidence, } from '../evidence';
@@ -41,6 +41,7 @@ __reExport(ledger_exports, require('./row-encoding.js'), module.exports);
41
41
  __reExport(ledger_exports, require('./row-storage-errors.js'), module.exports);
42
42
  __reExport(ledger_exports, require('./receipts.js'), module.exports);
43
43
  __reExport(ledger_exports, require('./offering-validation.js'), module.exports);
44
+ __reExport(ledger_exports, require('./issue-events.js'), module.exports);
44
45
  var import_instant = require('./instant.js');
45
46
  var import_schedule = require('./schedule.js');
46
47
  var import_evidence = require('../evidence.js');
@@ -66,5 +67,6 @@ var import_well_formed_unicode = require('../../utils/well-formed-unicode.js');
66
67
  ...require('./row-encoding.js'),
67
68
  ...require('./row-storage-errors.js'),
68
69
  ...require('./receipts.js'),
69
- ...require('./offering-validation.js')
70
+ ...require('./offering-validation.js'),
71
+ ...require('./issue-events.js')
70
72
  });
@@ -10,6 +10,7 @@ export * from "./row-encoding.mjs";
10
10
  export * from "./row-storage-errors.mjs";
11
11
  export * from "./receipts.mjs";
12
12
  export * from "./offering-validation.mjs";
13
+ export * from "./issue-events.mjs";
13
14
  import { compareReportingInstants } from "./instant.mjs";
14
15
  import { isFrozenCalendarRulesMismatch, reportingPeriodDate, reportingPeriodSchedule } from "./schedule.mjs";
15
16
  import {
@@ -1,6 +1,11 @@
1
1
  export declare function compareReportingInstants(left: string, right: string): number;
2
2
  export declare function canonicalReportingInstant(value: string): string;
3
3
  export declare function compareReportingInstantToOffset(value: string, base: string, offsetMilliseconds: number): number;
4
+ /**
5
+ * `base` plus `offsetMilliseconds`, keeping every fractional digit of `base`. Going through `Date` would floor a
6
+ * sub-millisecond instant and land the result before the exact boundary.
7
+ */
8
+ export declare function addReportingInstantOffset(base: string, offsetMilliseconds: number): string;
4
9
  export declare function reportingInstantHasDuration(start: string, end: string, durationMilliseconds: number): boolean;
5
10
  export declare function reportingPeriodOrdinal(start: string, anchor: string, durationMilliseconds: number): bigint | null;
6
11
  export declare function reportingDurationCeilOrdinal(anchor: string, effectiveFrom: string, durationMilliseconds: number): bigint;
@@ -1,6 +1,11 @@
1
1
  export declare function compareReportingInstants(left: string, right: string): number;
2
2
  export declare function canonicalReportingInstant(value: string): string;
3
3
  export declare function compareReportingInstantToOffset(value: string, base: string, offsetMilliseconds: number): number;
4
+ /**
5
+ * `base` plus `offsetMilliseconds`, keeping every fractional digit of `base`. Going through `Date` would floor a
6
+ * sub-millisecond instant and land the result before the exact boundary.
7
+ */
8
+ export declare function addReportingInstantOffset(base: string, offsetMilliseconds: number): string;
4
9
  export declare function reportingInstantHasDuration(start: string, end: string, durationMilliseconds: number): boolean;
5
10
  export declare function reportingPeriodOrdinal(start: string, anchor: string, durationMilliseconds: number): bigint | null;
6
11
  export declare function reportingDurationCeilOrdinal(anchor: string, effectiveFrom: string, durationMilliseconds: number): bigint;
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var instant_exports = {};
20
20
  __export(instant_exports, {
21
+ addReportingInstantOffset: () => addReportingInstantOffset,
21
22
  canonicalReportingInstant: () => canonicalReportingInstant,
22
23
  compareReportingInstantToOffset: () => compareReportingInstantToOffset,
23
24
  compareReportingInstants: () => compareReportingInstants,
@@ -72,6 +73,14 @@ function compareReportingInstantToOffset(value, base, offsetMilliseconds) {
72
73
  const offset = durationUnits(offsetMilliseconds, delta.scale);
73
74
  return delta.units < offset ? -1 : delta.units > offset ? 1 : 0;
74
75
  }
76
+ function addReportingInstantOffset(base, offsetMilliseconds) {
77
+ const parsed = parseReportingInstant(base);
78
+ const scale = Math.max(3, parsed.fraction.length);
79
+ const units = scaledValue(parsed, scale) + durationUnits(offsetMilliseconds, scale);
80
+ const unit = 10n ** BigInt(scale);
81
+ const wholeSecond = new Date(Number(units / unit) * 1e3).toISOString().replace(".000Z", "");
82
+ return `${wholeSecond}.${(units % unit).toString().padStart(scale, "0")}Z`;
83
+ }
75
84
  function reportingInstantHasDuration(start, end, durationMilliseconds) {
76
85
  const delta = difference(end, start);
77
86
  return delta.units === durationUnits(durationMilliseconds, delta.scale);
@@ -90,6 +99,7 @@ function reportingDurationCeilOrdinal(anchor, effectiveFrom, durationMillisecond
90
99
  }
91
100
  // Annotate the CommonJS export names for ESM import in node:
92
101
  0 && (module.exports = {
102
+ addReportingInstantOffset,
93
103
  canonicalReportingInstant,
94
104
  compareReportingInstantToOffset,
95
105
  compareReportingInstants,