@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.
- package/README.md +26 -2
- package/dist/lib/adapters/version/index.d.mts +1 -1
- package/dist/lib/adapters/version/index.d.ts +1 -1
- package/dist/lib/adapters/version/index.js +2 -0
- package/dist/lib/adapters/version/index.mjs +2 -0
- package/dist/lib/adapters/version/negotiate.d.mts +13 -0
- package/dist/lib/adapters/version/negotiate.d.ts +13 -0
- package/dist/lib/adapters/version/negotiate.js +6 -0
- package/dist/lib/adapters/version/negotiate.mjs +5 -0
- package/dist/lib/client/core.d.mts +4 -0
- package/dist/lib/client/core.d.ts +4 -0
- package/dist/lib/client/core.js +13 -0
- package/dist/lib/client/core.mjs +12 -0
- package/dist/lib/conformance/property-lists.d.mts +1 -1
- package/dist/lib/conformance/property-lists.d.ts +1 -1
- package/dist/lib/conformance/property-lists.js +1 -1
- package/dist/lib/conformance/property-lists.mjs +1 -1
- package/dist/lib/core/SingleAgentClient.d.mts +23 -1
- package/dist/lib/core/SingleAgentClient.d.ts +23 -1
- package/dist/lib/core/SingleAgentClient.js +102 -18
- package/dist/lib/core/SingleAgentClient.mjs +108 -18
- package/dist/lib/core/targeting-helpers.d.mts +123 -0
- package/dist/lib/core/targeting-helpers.d.ts +123 -0
- package/dist/lib/core/targeting-helpers.js +412 -0
- package/dist/lib/core/targeting-helpers.mjs +370 -0
- package/dist/lib/entrypoints/client-account-changes.d.mts +5 -0
- package/dist/lib/entrypoints/client-account-changes.d.ts +5 -0
- package/dist/lib/entrypoints/client-account-changes.js +28 -0
- package/dist/lib/entrypoints/client-account-changes.mjs +4 -0
- package/dist/lib/entrypoints/client-webhook-stores.d.mts +2 -0
- package/dist/lib/entrypoints/client-webhook-stores.d.ts +2 -0
- package/dist/lib/entrypoints/client-webhook-stores.js +37 -0
- package/dist/lib/entrypoints/client-webhook-stores.mjs +16 -0
- package/dist/lib/entrypoints/discovery.d.mts +9 -0
- package/dist/lib/entrypoints/discovery.d.ts +9 -0
- package/dist/lib/entrypoints/discovery.js +72 -0
- package/dist/lib/entrypoints/discovery.mjs +56 -0
- package/dist/lib/entrypoints/errors.d.mts +11 -0
- package/dist/lib/entrypoints/errors.d.ts +11 -0
- package/dist/lib/entrypoints/errors.js +159 -0
- package/dist/lib/entrypoints/errors.mjs +132 -0
- package/dist/lib/entrypoints/media-buy.d.mts +5 -0
- package/dist/lib/entrypoints/media-buy.d.ts +5 -0
- package/dist/lib/entrypoints/media-buy.js +119 -0
- package/dist/lib/entrypoints/media-buy.mjs +100 -0
- package/dist/lib/entrypoints/registry.d.mts +5 -0
- package/dist/lib/entrypoints/registry.d.ts +5 -0
- package/dist/lib/entrypoints/registry.js +61 -0
- package/dist/lib/entrypoints/registry.mjs +40 -0
- package/dist/lib/entrypoints/utils.d.mts +7 -0
- package/dist/lib/entrypoints/utils.d.ts +7 -0
- package/dist/lib/entrypoints/utils.js +100 -0
- package/dist/lib/entrypoints/utils.mjs +72 -0
- package/dist/lib/entrypoints/version.d.mts +3 -0
- package/dist/lib/entrypoints/version.d.ts +3 -0
- package/dist/lib/entrypoints/version.js +57 -0
- package/dist/lib/entrypoints/version.mjs +36 -0
- package/dist/lib/index.d.mts +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/media-buy/action-contracts.js +3 -3
- package/dist/lib/media-buy/action-contracts.mjs +1 -1
- package/dist/lib/media-buy/creative-start-policy.d.mts +19 -0
- package/dist/lib/media-buy/creative-start-policy.d.ts +19 -0
- package/dist/lib/media-buy/creative-start-policy.js +59 -0
- package/dist/lib/media-buy/creative-start-policy.mjs +31 -0
- package/dist/lib/media-buy/valid-actions.d.mts +47 -0
- package/dist/lib/media-buy/valid-actions.d.ts +47 -0
- package/dist/lib/media-buy/valid-actions.js +42 -0
- package/dist/lib/media-buy/valid-actions.mjs +18 -0
- package/dist/lib/net/pin-and-bind-fetch.d.mts +121 -0
- package/dist/lib/net/pin-and-bind-fetch.d.ts +121 -0
- package/dist/lib/net/pin-and-bind-fetch.js +209 -0
- package/dist/lib/net/pin-and-bind-fetch.mjs +183 -0
- package/dist/lib/protocols/mcp-modern.js +20 -4
- package/dist/lib/protocols/mcp-modern.mjs +20 -4
- package/dist/lib/registry/types.generated.d.ts +224 -3
- package/dist/lib/reporting/ledger/index.d.mts +1 -0
- package/dist/lib/reporting/ledger/index.d.ts +1 -0
- package/dist/lib/reporting/ledger/index.js +3 -1
- package/dist/lib/reporting/ledger/index.mjs +1 -0
- package/dist/lib/reporting/ledger/instant.d.mts +5 -0
- package/dist/lib/reporting/ledger/instant.d.ts +5 -0
- package/dist/lib/reporting/ledger/instant.js +10 -0
- package/dist/lib/reporting/ledger/instant.mjs +9 -0
- package/dist/lib/reporting/ledger/issue-events.d.mts +333 -0
- package/dist/lib/reporting/ledger/issue-events.d.ts +333 -0
- package/dist/lib/reporting/ledger/issue-events.js +310 -0
- package/dist/lib/reporting/ledger/issue-events.mjs +282 -0
- package/dist/lib/reporting/service/index.d.mts +36 -1
- package/dist/lib/reporting/service/index.d.ts +36 -1
- package/dist/lib/reporting/service/index.js +51 -1
- package/dist/lib/reporting/service/index.mjs +52 -2
- package/dist/lib/reporting/service/scheduler-support.d.mts +1 -1
- package/dist/lib/reporting/service/scheduler-support.d.ts +1 -1
- package/dist/lib/reporting/service/scheduler-support.js +1 -1
- package/dist/lib/reporting/service/scheduler-support.mjs +1 -1
- package/dist/lib/server/capabilities-release-projection.d.mts +43 -0
- package/dist/lib/server/capabilities-release-projection.d.ts +43 -0
- package/dist/lib/server/capabilities-release-projection.js +128 -0
- package/dist/lib/server/capabilities-release-projection.mjs +112 -0
- package/dist/lib/server/create-adcp-server.d.mts +29 -5
- package/dist/lib/server/create-adcp-server.d.ts +29 -5
- package/dist/lib/server/create-adcp-server.js +97 -24
- package/dist/lib/server/create-adcp-server.mjs +108 -23
- package/dist/lib/server/decisioning/capabilities.d.mts +27 -0
- package/dist/lib/server/decisioning/capabilities.d.ts +27 -0
- package/dist/lib/server/decisioning/runtime/from-platform.js +99 -27
- package/dist/lib/server/decisioning/runtime/from-platform.mjs +103 -27
- package/dist/lib/server/declared-input-schema.d.mts +108 -0
- package/dist/lib/server/declared-input-schema.d.ts +108 -0
- package/dist/lib/server/declared-input-schema.js +167 -0
- package/dist/lib/server/declared-input-schema.mjs +137 -0
- package/dist/lib/server/envelope-allowlist.d.mts +1 -105
- package/dist/lib/server/envelope-allowlist.d.ts +1 -105
- package/dist/lib/server/envelope-allowlist.js +3 -79
- package/dist/lib/server/envelope-allowlist.mjs +1 -71
- package/dist/lib/server/errors.d.mts +1 -186
- package/dist/lib/server/errors.d.ts +1 -186
- package/dist/lib/server/errors.js +3 -98
- package/dist/lib/server/errors.mjs +1 -94
- package/dist/lib/server/index.d.mts +1 -1
- package/dist/lib/server/index.d.ts +1 -1
- package/dist/lib/server/mcp-modern-server.js +21 -4
- package/dist/lib/server/mcp-modern-server.mjs +21 -4
- package/dist/lib/server/media-buy-action-resolver.d.mts +7 -0
- package/dist/lib/server/media-buy-action-resolver.d.ts +7 -0
- package/dist/lib/server/media-buy-action-resolver.js +10 -1
- package/dist/lib/server/media-buy-action-resolver.mjs +10 -1
- package/dist/lib/server/media-buy-helpers.d.mts +1 -47
- package/dist/lib/server/media-buy-helpers.d.ts +1 -47
- package/dist/lib/server/media-buy-helpers.js +3 -23
- package/dist/lib/server/media-buy-helpers.mjs +1 -18
- package/dist/lib/server/pick-safe-details.d.mts +1 -89
- package/dist/lib/server/pick-safe-details.d.ts +1 -89
- package/dist/lib/server/pick-safe-details.js +3 -61
- package/dist/lib/server/pick-safe-details.mjs +1 -56
- package/dist/lib/server/pin-and-bind-fetch.d.mts +1 -121
- package/dist/lib/server/pin-and-bind-fetch.d.ts +1 -121
- package/dist/lib/server/pin-and-bind-fetch.js +3 -190
- package/dist/lib/server/pin-and-bind-fetch.mjs +1 -183
- package/dist/lib/server/targeting-helpers.d.mts +1 -123
- package/dist/lib/server/targeting-helpers.d.ts +1 -123
- package/dist/lib/server/targeting-helpers.js +3 -393
- package/dist/lib/server/targeting-helpers.mjs +1 -370
- package/dist/lib/server/test-controller.js +7 -3
- package/dist/lib/server/test-controller.mjs +7 -3
- package/dist/lib/storage/memory-ledger.js +219 -1
- package/dist/lib/storage/memory-ledger.mjs +223 -1
- package/dist/lib/testing/client.js +26 -5
- package/dist/lib/testing/client.mjs +24 -5
- package/dist/lib/testing/compliance/storyboard-tracks.js +0 -4
- package/dist/lib/testing/compliance/storyboard-tracks.mjs +0 -4
- package/dist/lib/testing/comply-controller.js +7 -2
- package/dist/lib/testing/comply-controller.mjs +7 -2
- package/dist/lib/testing/storyboard/request-signing/grader.d.mts +21 -0
- package/dist/lib/testing/storyboard/request-signing/grader.d.ts +21 -0
- package/dist/lib/testing/storyboard/request-signing/grader.js +31 -0
- package/dist/lib/testing/storyboard/request-signing/grader.mjs +30 -0
- package/dist/lib/testing/storyboard/request-signing/probe-dispatch.js +1 -1
- package/dist/lib/testing/storyboard/request-signing/probe-dispatch.mjs +2 -1
- package/dist/lib/testing/storyboard/request-signing/types.d.mts +12 -0
- package/dist/lib/testing/storyboard/request-signing/types.d.ts +12 -0
- package/dist/lib/testing/storyboard/request-signing/vector-loader.js +7 -2
- package/dist/lib/testing/storyboard/request-signing/vector-loader.mjs +7 -2
- package/dist/lib/testing/storyboard/runner.js +4 -4
- package/dist/lib/testing/storyboard/runner.mjs +4 -4
- package/dist/lib/testing/storyboard/task-map.js +4 -1
- package/dist/lib/testing/storyboard/task-map.mjs +4 -1
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/utils/adcp-error-response.d.mts +196 -0
- package/dist/lib/utils/adcp-error-response.d.ts +196 -0
- package/dist/lib/utils/adcp-error-response.js +118 -0
- package/dist/lib/utils/adcp-error-response.mjs +95 -0
- package/dist/lib/utils/buyer-retry-policy.js +2 -2
- package/dist/lib/utils/buyer-retry-policy.mjs +1 -1
- package/dist/lib/utils/capabilities.d.mts +6 -0
- package/dist/lib/utils/capabilities.d.ts +6 -0
- package/dist/lib/utils/capabilities.js +6 -2
- package/dist/lib/utils/capabilities.mjs +6 -2
- package/dist/lib/utils/envelope-allowlist.d.mts +105 -0
- package/dist/lib/utils/envelope-allowlist.d.ts +105 -0
- package/dist/lib/utils/envelope-allowlist.js +98 -0
- package/dist/lib/utils/envelope-allowlist.mjs +71 -0
- package/dist/lib/utils/pick-safe-details.d.mts +89 -0
- package/dist/lib/utils/pick-safe-details.d.ts +89 -0
- package/dist/lib/utils/pick-safe-details.js +80 -0
- package/dist/lib/utils/pick-safe-details.mjs +56 -0
- package/dist/lib/v2/projection/augment-response.d.mts +4 -0
- package/dist/lib/v2/projection/augment-response.d.ts +4 -0
- package/dist/lib/v2/projection/creative-delivery.d.mts +20 -3
- package/dist/lib/v2/projection/creative-delivery.d.ts +20 -3
- package/dist/lib/v2/projection/creative-delivery.js +20 -4
- package/dist/lib/v2/projection/creative-delivery.mjs +19 -4
- package/dist/lib/v2/projection/index.d.mts +2 -2
- package/dist/lib/v2/projection/index.d.ts +2 -2
- package/dist/lib/v2/projection/index.js +4 -0
- package/dist/lib/v2/projection/index.mjs +5 -1
- package/dist/lib/v2/projection/legacy-metadata.d.mts +7 -0
- package/dist/lib/v2/projection/legacy-metadata.d.ts +7 -0
- package/dist/lib/v2/projection/legacy-metadata.js +14 -0
- package/dist/lib/v2/projection/legacy-metadata.mjs +12 -0
- package/dist/lib/v2/projection/legacy-routes.d.mts +11 -0
- package/dist/lib/v2/projection/legacy-routes.d.ts +11 -0
- package/dist/lib/v2/projection/legacy-routes.js +2 -1
- package/dist/lib/v2/projection/legacy-routes.mjs +7 -2
- package/dist/lib/v2/projection/v1-to-v2.d.mts +21 -1
- package/dist/lib/v2/projection/v1-to-v2.d.ts +21 -1
- package/dist/lib/v2/projection/v1-to-v2.js +18 -11
- package/dist/lib/v2/projection/v1-to-v2.mjs +19 -11
- package/dist/lib/version.d.mts +3 -3
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.js +3 -3
- package/dist/lib/version.mjs +3 -3
- package/docs/TYPE-SUMMARY.md +2 -2
- package/docs/guides/CREATIVE-DELIVERY.md +12 -0
- package/docs/guides/REPORTING-LEDGER.md +121 -0
- package/docs/guides/VALIDATE-YOUR-AGENT.md +1 -0
- package/docs/llms.txt +2 -2
- package/docs/migration-14.x-rc-worksheet.md +4 -4
- package/docs/migration-16-to-17.md +149 -0
- package/docs/migration-reporting-storage-package.md +10 -0
- package/package.json +106 -1
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
6
|
var __copyProps = (to, from, except, desc) => {
|
|
13
7
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
8
|
for (let key of __getOwnPropNames(from))
|
|
@@ -17,396 +11,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
11
|
}
|
|
18
12
|
return to;
|
|
19
13
|
};
|
|
20
|
-
var
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
28
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
16
|
var targeting_helpers_exports = {};
|
|
30
|
-
__export(targeting_helpers_exports, {
|
|
31
|
-
DEFAULT_RESOLVE_LIST_PAGE_SIZE: () => DEFAULT_RESOLVE_LIST_PAGE_SIZE,
|
|
32
|
-
clearDefaultResolvedListCache: () => clearDefaultResolvedListCache,
|
|
33
|
-
createResolvedListCache: () => createResolvedListCache,
|
|
34
|
-
defaultResolvedListCache: () => defaultResolvedListCache,
|
|
35
|
-
matchesCollectionList: () => matchesCollectionList,
|
|
36
|
-
matchesPropertyList: () => matchesPropertyList,
|
|
37
|
-
resolveCollectionList: () => resolveCollectionList,
|
|
38
|
-
resolvePropertyList: () => resolvePropertyList,
|
|
39
|
-
resolvedListCacheKey: () => resolvedListCacheKey
|
|
40
|
-
});
|
|
41
17
|
module.exports = __toCommonJS(targeting_helpers_exports);
|
|
42
|
-
|
|
43
|
-
var import_promises = require("node:dns/promises");
|
|
44
|
-
var import_mcp = require('../protocols/mcp.js');
|
|
45
|
-
var import_net = require('../net/index.js');
|
|
46
|
-
var import_probe_policy = require('../utils/probe-policy.js');
|
|
47
|
-
var import_pin_and_bind_fetch = require('./pin-and-bind-fetch.js');
|
|
48
|
-
var import_response_unwrapper = require('../utils/response-unwrapper.js');
|
|
49
|
-
const DEFAULT_RESOLVE_LIST_PAGE_SIZE = 1e3;
|
|
50
|
-
class MemoryResolvedListCache {
|
|
51
|
-
entries = /* @__PURE__ */ new Map();
|
|
52
|
-
get(key, nowMs = Date.now()) {
|
|
53
|
-
const entry = this.entries.get(key);
|
|
54
|
-
if (!entry) return void 0;
|
|
55
|
-
if (entry.expiresAtMs <= nowMs) {
|
|
56
|
-
this.entries.delete(key);
|
|
57
|
-
return void 0;
|
|
58
|
-
}
|
|
59
|
-
return cloneResolvedList(entry.value);
|
|
60
|
-
}
|
|
61
|
-
set(key, entry) {
|
|
62
|
-
this.entries.set(key, {
|
|
63
|
-
expiresAtMs: entry.expiresAtMs,
|
|
64
|
-
value: cloneResolvedList(entry.value)
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
delete(key) {
|
|
68
|
-
return this.entries.delete(key);
|
|
69
|
-
}
|
|
70
|
-
clear() {
|
|
71
|
-
this.entries.clear();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
function createResolvedListCache() {
|
|
75
|
-
return new MemoryResolvedListCache();
|
|
76
|
-
}
|
|
77
|
-
const defaultResolvedListCache = createResolvedListCache();
|
|
78
|
-
function clearDefaultResolvedListCache() {
|
|
79
|
-
defaultResolvedListCache.clear();
|
|
80
|
-
}
|
|
81
|
-
const defaultResolveListFetchBase = (0, import_pin_and_bind_fetch.createPinAndBindFetch)();
|
|
82
|
-
const defaultResolveListFetch = (input, init) => defaultResolveListFetchBase(input, { ...init, redirect: "manual" });
|
|
83
|
-
const defaultResolveListCallTool = (agentUrl, toolName, args, authToken) => (0, import_mcp.callMCPTool)(agentUrl, toolName, args, authToken, [], void 0, void 0, defaultResolveListFetch);
|
|
84
|
-
function resolvedListPayload(result, kind) {
|
|
85
|
-
if (!result || typeof result !== "object" || Array.isArray(result)) return result;
|
|
86
|
-
const envelope = result;
|
|
87
|
-
const isMcp = "structuredContent" in envelope || "content" in envelope || "isError" in envelope;
|
|
88
|
-
let payload;
|
|
89
|
-
try {
|
|
90
|
-
payload = isMcp ? (0, import_response_unwrapper.unwrapProtocolResponse)(envelope, void 0, "mcp") : envelope;
|
|
91
|
-
} catch (cause) {
|
|
92
|
-
throw new Error(`${kind}_list_invalid_response`, { cause });
|
|
93
|
-
}
|
|
94
|
-
const data = payload && typeof payload === "object" ? payload : void 0;
|
|
95
|
-
if (envelope.isError === true || data?.adcp_error !== void 0) {
|
|
96
|
-
throw Object.assign(new Error(`${kind}_list_invalid_response`, { cause: data?.adcp_error }), {
|
|
97
|
-
adcp_error: data?.adcp_error
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
return payload;
|
|
101
|
-
}
|
|
102
|
-
async function resolvePropertyList(ref, options = {}) {
|
|
103
|
-
const structurallyNormalizedRef = await normalizePropertyListReference(ref, { resolveDns: false });
|
|
104
|
-
const cache = cacheForOptions(options);
|
|
105
|
-
const nowMs = nowMsForOptions(options);
|
|
106
|
-
const cacheKey = resolvedListCacheKey("property", structurallyNormalizedRef, options);
|
|
107
|
-
const cached = cacheKey && !options.strictResponseValidation ? cache?.get(cacheKey, nowMs) : void 0;
|
|
108
|
-
if (cached) return cached;
|
|
109
|
-
const normalizedRef = options.callTool ? structurallyNormalizedRef : await normalizePropertyListReference(structurallyNormalizedRef, { resolveDns: false });
|
|
110
|
-
const result = await fetchResolvedPropertyList(normalizedRef, options);
|
|
111
|
-
cacheResolvedList(cache, cacheKey, result, nowMs);
|
|
112
|
-
return result;
|
|
113
|
-
}
|
|
114
|
-
async function fetchResolvedPropertyList(ref, options) {
|
|
115
|
-
const callTool = options.callTool ?? defaultResolveListCallTool;
|
|
116
|
-
const identifiers = [];
|
|
117
|
-
let listId;
|
|
118
|
-
let cacheValidUntil;
|
|
119
|
-
let missingCacheValidUntil = false;
|
|
120
|
-
let cursor;
|
|
121
|
-
const seenCursors = /* @__PURE__ */ new Set();
|
|
122
|
-
for (let pageIndex = 0; pageIndex < maxPagesForOptions(options); pageIndex += 1) {
|
|
123
|
-
const args = buildResolveListArgs(ref.list_id, pageSizeForOptions(options), cursor);
|
|
124
|
-
const raw = resolvedListPayload(
|
|
125
|
-
await callTool(ref.agent_url, "get_property_list", args, ref.auth_token),
|
|
126
|
-
"property"
|
|
127
|
-
);
|
|
128
|
-
if (!raw || typeof raw !== "object" || !("list" in raw)) {
|
|
129
|
-
throw new Error("property_list_invalid_response");
|
|
130
|
-
}
|
|
131
|
-
const response = raw;
|
|
132
|
-
if (response.status !== void 0 && response.status !== "completed" || raw.errors !== void 0 && (!Array.isArray(raw.errors) || raw.errors.some((error) => !error || typeof error !== "object" || error.severity !== "warning")) || raw.adcp_error !== void 0 || !Array.isArray(response.identifiers)) {
|
|
133
|
-
throw new Error("property_list_invalid_response");
|
|
134
|
-
}
|
|
135
|
-
if (options.strictResponseValidation) {
|
|
136
|
-
const { GetPropertyListResponseSchema } = await import("../types/schemas.generated.js");
|
|
137
|
-
if (!GetPropertyListResponseSchema.safeParse(raw).success || response.status !== "completed" || response.identifiers.length > pageSizeForOptions(options)) {
|
|
138
|
-
throw new Error("property_list_invalid_response");
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
if (!response.list || response.list.list_id !== ref.list_id || response.identifiers !== void 0 && (!Array.isArray(response.identifiers) || response.identifiers.some(
|
|
142
|
-
(identifier) => !identifier || typeof identifier !== "object" || typeof identifier.type !== "string" || typeof identifier.value !== "string"
|
|
143
|
-
))) {
|
|
144
|
-
throw new Error("property_list_invalid_response");
|
|
145
|
-
}
|
|
146
|
-
listId = response.list.list_id;
|
|
147
|
-
identifiers.push(...response.identifiers ?? []);
|
|
148
|
-
if (typeof response.cache_valid_until === "string") {
|
|
149
|
-
cacheValidUntil = earliestIsoTimestamp(cacheValidUntil, response.cache_valid_until);
|
|
150
|
-
} else {
|
|
151
|
-
missingCacheValidUntil = true;
|
|
152
|
-
}
|
|
153
|
-
const pagination = readPagination(response.pagination);
|
|
154
|
-
if (pagination.invalid) {
|
|
155
|
-
throw new Error("property_list_invalid_pagination");
|
|
156
|
-
}
|
|
157
|
-
if (!pagination.hasMore) {
|
|
158
|
-
return {
|
|
159
|
-
listId,
|
|
160
|
-
agentUrl: ref.agent_url,
|
|
161
|
-
identifiers,
|
|
162
|
-
cacheValidUntil: missingCacheValidUntil ? void 0 : cacheValidUntil
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
if (!pagination.cursor) {
|
|
166
|
-
throw new Error("property_list_invalid_pagination");
|
|
167
|
-
}
|
|
168
|
-
if (seenCursors.has(pagination.cursor)) throw new Error("property_list_invalid_pagination");
|
|
169
|
-
seenCursors.add(pagination.cursor);
|
|
170
|
-
cursor = pagination.cursor;
|
|
171
|
-
}
|
|
172
|
-
throw new Error("property_list_pagination_limit_exceeded");
|
|
173
|
-
}
|
|
174
|
-
async function resolveCollectionList(ref, options = {}) {
|
|
175
|
-
const structurallyNormalizedRef = await normalizeCollectionListReference(ref, { resolveDns: false });
|
|
176
|
-
const cache = cacheForOptions(options);
|
|
177
|
-
const nowMs = nowMsForOptions(options);
|
|
178
|
-
const cacheKey = resolvedListCacheKey("collection", structurallyNormalizedRef, options);
|
|
179
|
-
const cached = cacheKey && !options.strictResponseValidation ? cache?.get(cacheKey, nowMs) : void 0;
|
|
180
|
-
if (cached) return cached;
|
|
181
|
-
const normalizedRef = options.callTool ? structurallyNormalizedRef : await normalizeCollectionListReference(structurallyNormalizedRef, { resolveDns: false });
|
|
182
|
-
const result = await fetchResolvedCollectionList(normalizedRef, options);
|
|
183
|
-
cacheResolvedList(cache, cacheKey, result, nowMs);
|
|
184
|
-
return result;
|
|
185
|
-
}
|
|
186
|
-
async function fetchResolvedCollectionList(ref, options) {
|
|
187
|
-
const callTool = options.callTool ?? defaultResolveListCallTool;
|
|
188
|
-
const collections = [];
|
|
189
|
-
let listId;
|
|
190
|
-
let cacheValidUntil;
|
|
191
|
-
let missingCacheValidUntil = false;
|
|
192
|
-
let cursor;
|
|
193
|
-
for (let pageIndex = 0; pageIndex < maxPagesForOptions(options); pageIndex += 1) {
|
|
194
|
-
const args = buildResolveListArgs(ref.list_id, pageSizeForOptions(options), cursor);
|
|
195
|
-
const raw = resolvedListPayload(
|
|
196
|
-
await callTool(ref.agent_url, "get_collection_list", args, ref.auth_token),
|
|
197
|
-
"collection"
|
|
198
|
-
);
|
|
199
|
-
if (!raw || typeof raw !== "object" || !("list" in raw)) {
|
|
200
|
-
throw new Error("collection_list_invalid_response");
|
|
201
|
-
}
|
|
202
|
-
const response = raw;
|
|
203
|
-
if (response.status !== void 0 && response.status !== "completed" || raw.errors !== void 0 && (!Array.isArray(raw.errors) || raw.errors.some((error) => !error || typeof error !== "object" || error.severity !== "warning")) || !response.list || response.list.list_id !== ref.list_id || !Array.isArray(response.collections) || response.collections.some(
|
|
204
|
-
(collection) => !collection || typeof collection !== "object" || Array.isArray(collection) || ["publisher_domain", "collection_id", "collection_rid", "name"].some(
|
|
205
|
-
(field) => field in collection && typeof collection[field] !== "string"
|
|
206
|
-
) || collection.distribution_ids !== void 0 && (!Array.isArray(collection.distribution_ids) || collection.distribution_ids.some(
|
|
207
|
-
(identifier) => !identifier || typeof identifier !== "object" || typeof identifier.type !== "string" || typeof identifier.value !== "string"
|
|
208
|
-
))
|
|
209
|
-
)) {
|
|
210
|
-
throw new Error("collection_list_invalid_response");
|
|
211
|
-
}
|
|
212
|
-
if (options.strictResponseValidation) {
|
|
213
|
-
const { GetCollectionListResponseSchema } = await import("../types/schemas.generated.js");
|
|
214
|
-
if (!GetCollectionListResponseSchema.safeParse(raw).success || response.status !== "completed" || response.collections.length > pageSizeForOptions(options)) {
|
|
215
|
-
throw new Error("collection_list_invalid_response");
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
listId = response.list.list_id;
|
|
219
|
-
collections.push(...response.collections ?? []);
|
|
220
|
-
if (typeof response.cache_valid_until === "string") {
|
|
221
|
-
cacheValidUntil = earliestIsoTimestamp(cacheValidUntil, response.cache_valid_until);
|
|
222
|
-
} else {
|
|
223
|
-
missingCacheValidUntil = true;
|
|
224
|
-
}
|
|
225
|
-
const pagination = readPagination(response.pagination);
|
|
226
|
-
if (pagination.invalid) {
|
|
227
|
-
throw new Error("collection_list_invalid_pagination");
|
|
228
|
-
}
|
|
229
|
-
if (!pagination.hasMore) {
|
|
230
|
-
return {
|
|
231
|
-
listId,
|
|
232
|
-
agentUrl: ref.agent_url,
|
|
233
|
-
collections,
|
|
234
|
-
cacheValidUntil: missingCacheValidUntil ? void 0 : cacheValidUntil
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
if (!pagination.cursor) {
|
|
238
|
-
throw new Error("collection_list_invalid_pagination");
|
|
239
|
-
}
|
|
240
|
-
cursor = pagination.cursor;
|
|
241
|
-
}
|
|
242
|
-
throw new Error("collection_list_pagination_limit_exceeded");
|
|
243
|
-
}
|
|
244
|
-
function resolvedListCacheKey(kind, ref, options = {}) {
|
|
245
|
-
const scope = ref.auth_token ?? options.cacheScopeKey;
|
|
246
|
-
if (!scope) return void 0;
|
|
247
|
-
const material = JSON.stringify({
|
|
248
|
-
kind,
|
|
249
|
-
agent_url: ref.agent_url,
|
|
250
|
-
list_id: ref.list_id,
|
|
251
|
-
scope_sha256: sha256(scope),
|
|
252
|
-
page_size: options.pageSize ?? DEFAULT_RESOLVE_LIST_PAGE_SIZE,
|
|
253
|
-
resolve: true
|
|
254
|
-
});
|
|
255
|
-
return `adcp-resolved-list:${sha256(material)}`;
|
|
256
|
-
}
|
|
257
|
-
async function normalizePropertyListReference(ref, options) {
|
|
258
|
-
return {
|
|
259
|
-
...ref,
|
|
260
|
-
agent_url: await normalizeListAgentUrl(ref.agent_url, options)
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
async function normalizeCollectionListReference(ref, options) {
|
|
264
|
-
return {
|
|
265
|
-
...ref,
|
|
266
|
-
agent_url: await normalizeListAgentUrl(ref.agent_url, options)
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
async function normalizeListAgentUrl(raw, options) {
|
|
270
|
-
let url;
|
|
271
|
-
try {
|
|
272
|
-
url = new URL(raw);
|
|
273
|
-
} catch {
|
|
274
|
-
throw new Error("list_agent_url_invalid");
|
|
275
|
-
}
|
|
276
|
-
if (url.username || url.password || url.search || url.hash) {
|
|
277
|
-
throw new Error("list_agent_url_malformed");
|
|
278
|
-
}
|
|
279
|
-
const allowInternal = (0, import_probe_policy.isInternalProbesAllowed)();
|
|
280
|
-
if (url.protocol !== "https:" && !(allowInternal && url.protocol === "http:")) {
|
|
281
|
-
throw new Error("list_agent_url_insecure");
|
|
282
|
-
}
|
|
283
|
-
const hostname = url.hostname.replace(/^\[|\]$/g, "");
|
|
284
|
-
if ((0, import_net.isAlwaysBlocked)(hostname)) {
|
|
285
|
-
throw new Error("list_agent_url_always_blocked");
|
|
286
|
-
}
|
|
287
|
-
if (!allowInternal && (0, import_net.isPrivateIp)(hostname)) {
|
|
288
|
-
throw new Error("list_agent_url_private_address");
|
|
289
|
-
}
|
|
290
|
-
if (options.resolveDns) {
|
|
291
|
-
let addresses;
|
|
292
|
-
try {
|
|
293
|
-
addresses = await (0, import_promises.lookup)(hostname, { all: true });
|
|
294
|
-
} catch {
|
|
295
|
-
throw new Error("list_agent_url_dns_failed");
|
|
296
|
-
}
|
|
297
|
-
if (addresses.length === 0) {
|
|
298
|
-
throw new Error("list_agent_url_dns_empty");
|
|
299
|
-
}
|
|
300
|
-
for (const { address } of addresses) {
|
|
301
|
-
if ((0, import_net.isAlwaysBlocked)(address)) {
|
|
302
|
-
throw new Error("list_agent_url_always_blocked");
|
|
303
|
-
}
|
|
304
|
-
if (!allowInternal && (0, import_net.isPrivateIp)(address)) {
|
|
305
|
-
throw new Error("list_agent_url_private_address");
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
return url.toString();
|
|
310
|
-
}
|
|
311
|
-
function buildResolveListArgs(listId, pageSize, cursor) {
|
|
312
|
-
const args = {
|
|
313
|
-
list_id: listId,
|
|
314
|
-
resolve: true
|
|
315
|
-
};
|
|
316
|
-
const pagination = {};
|
|
317
|
-
pagination.max_results = pageSize;
|
|
318
|
-
if (cursor) pagination.cursor = cursor;
|
|
319
|
-
if (Object.keys(pagination).length > 0) args.pagination = pagination;
|
|
320
|
-
return args;
|
|
321
|
-
}
|
|
322
|
-
function cacheForOptions(options) {
|
|
323
|
-
if (options.callTool && options.cache === void 0) return void 0;
|
|
324
|
-
return options.cache === false ? void 0 : options.cache ?? defaultResolvedListCache;
|
|
325
|
-
}
|
|
326
|
-
function cacheResolvedList(cache, cacheKey, value, nowMs) {
|
|
327
|
-
if (!cache || !cacheKey || !value.cacheValidUntil) return;
|
|
328
|
-
const expiresAtMs = Date.parse(value.cacheValidUntil);
|
|
329
|
-
if (!Number.isFinite(expiresAtMs) || expiresAtMs <= nowMs) return;
|
|
330
|
-
cache.set(cacheKey, { value, expiresAtMs });
|
|
331
|
-
}
|
|
332
|
-
function nowMsForOptions(options) {
|
|
333
|
-
const now = options.now?.();
|
|
334
|
-
if (now instanceof Date) return now.getTime();
|
|
335
|
-
if (typeof now === "number") return now;
|
|
336
|
-
return Date.now();
|
|
337
|
-
}
|
|
338
|
-
function maxPagesForOptions(options) {
|
|
339
|
-
return options.maxPages ?? 100;
|
|
340
|
-
}
|
|
341
|
-
function pageSizeForOptions(options) {
|
|
342
|
-
return options.pageSize ?? DEFAULT_RESOLVE_LIST_PAGE_SIZE;
|
|
343
|
-
}
|
|
344
|
-
function readPagination(value) {
|
|
345
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return { hasMore: false, invalid: false };
|
|
346
|
-
const pagination = value;
|
|
347
|
-
const cursor = typeof pagination.cursor === "string" && pagination.cursor.length > 0 ? pagination.cursor : void 0;
|
|
348
|
-
const invalid = pagination.has_more !== void 0 && typeof pagination.has_more !== "boolean" || cursor !== void 0 && pagination.has_more !== true;
|
|
349
|
-
return {
|
|
350
|
-
hasMore: pagination.has_more === true,
|
|
351
|
-
cursor,
|
|
352
|
-
invalid
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
function earliestIsoTimestamp(current, next) {
|
|
356
|
-
if (!current) return next;
|
|
357
|
-
const currentMs = Date.parse(current);
|
|
358
|
-
const nextMs = Date.parse(next);
|
|
359
|
-
if (!Number.isFinite(currentMs)) return next;
|
|
360
|
-
if (!Number.isFinite(nextMs)) return current;
|
|
361
|
-
return nextMs < currentMs ? next : current;
|
|
362
|
-
}
|
|
363
|
-
function cloneResolvedList(value) {
|
|
364
|
-
return structuredClone(value);
|
|
365
|
-
}
|
|
366
|
-
function sha256(value) {
|
|
367
|
-
return (0, import_node_crypto.createHash)("sha256").update(value, "utf8").digest("hex");
|
|
368
|
-
}
|
|
369
|
-
function matchesPropertyList(property, list) {
|
|
370
|
-
return list.identifiers.some((entry) => identifiersMatch(property, entry));
|
|
371
|
-
}
|
|
372
|
-
function identifiersMatch(property, entry) {
|
|
373
|
-
if (property.type !== entry.type) return false;
|
|
374
|
-
if (property.type !== "domain") {
|
|
375
|
-
return property.value === entry.value;
|
|
376
|
-
}
|
|
377
|
-
return domainMatches(property.value, entry.value);
|
|
378
|
-
}
|
|
379
|
-
function domainMatches(candidate, pattern) {
|
|
380
|
-
const c = candidate.toLowerCase();
|
|
381
|
-
const p = pattern.toLowerCase();
|
|
382
|
-
if (c === p) return true;
|
|
383
|
-
if (p.startsWith("*.")) {
|
|
384
|
-
const suffix = p.slice(1);
|
|
385
|
-
return c.endsWith(suffix) && c !== p.slice(2);
|
|
386
|
-
}
|
|
387
|
-
return c === `www.${p}` || c === `m.${p}`;
|
|
388
|
-
}
|
|
389
|
-
function matchesCollectionList(collection, list) {
|
|
390
|
-
return list.collections.some((entry) => collectionsMatch(collection, entry));
|
|
391
|
-
}
|
|
392
|
-
function collectionsMatch(a, b) {
|
|
393
|
-
if (a.collection_rid && b.collection_rid && a.collection_rid === b.collection_rid) {
|
|
394
|
-
return true;
|
|
395
|
-
}
|
|
396
|
-
if (!a.distribution_ids?.length || !b.distribution_ids?.length) return false;
|
|
397
|
-
return a.distribution_ids.some(
|
|
398
|
-
(aid) => b.distribution_ids.some((bid) => aid.type === bid.type && aid.value === bid.value)
|
|
399
|
-
);
|
|
400
|
-
}
|
|
18
|
+
__reExport(targeting_helpers_exports, require('../core/targeting-helpers.js'), module.exports);
|
|
401
19
|
// Annotate the CommonJS export names for ESM import in node:
|
|
402
20
|
0 && (module.exports = {
|
|
403
|
-
|
|
404
|
-
clearDefaultResolvedListCache,
|
|
405
|
-
createResolvedListCache,
|
|
406
|
-
defaultResolvedListCache,
|
|
407
|
-
matchesCollectionList,
|
|
408
|
-
matchesPropertyList,
|
|
409
|
-
resolveCollectionList,
|
|
410
|
-
resolvePropertyList,
|
|
411
|
-
resolvedListCacheKey
|
|
21
|
+
...require('../core/targeting-helpers.js')
|
|
412
22
|
});
|