@adcp/sdk 14.4.0 → 15.2.0
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/bin/adcp-grade.js +46 -2
- package/bin/adcp.js +13 -3
- package/dist/lib/auth/oauth/ClientCredentialsFlow.js +4 -1
- package/dist/lib/auth/oauth/ClientCredentialsFlow.mjs +4 -1
- package/dist/lib/auth/oauth/MCPOAuthProvider.d.mts +19 -6
- package/dist/lib/auth/oauth/MCPOAuthProvider.d.ts +19 -6
- package/dist/lib/auth/oauth/MCPOAuthProvider.js +95 -30
- package/dist/lib/auth/oauth/MCPOAuthProvider.mjs +96 -30
- package/dist/lib/auth/oauth/NonInteractiveFlowHandler.d.mts +1 -1
- package/dist/lib/auth/oauth/NonInteractiveFlowHandler.d.ts +1 -1
- package/dist/lib/auth/oauth/NonInteractiveFlowHandler.js +1 -1
- package/dist/lib/auth/oauth/NonInteractiveFlowHandler.mjs +1 -1
- package/dist/lib/auth/oauth/client-credentials-schema.d.mts +17 -0
- package/dist/lib/auth/oauth/client-credentials-schema.d.ts +17 -0
- package/dist/lib/auth/oauth/client-credentials-schema.js +37 -0
- package/dist/lib/auth/oauth/client-credentials-schema.mjs +13 -0
- package/dist/lib/auth/oauth/file-storage.d.mts +3 -3
- package/dist/lib/auth/oauth/file-storage.d.ts +3 -3
- package/dist/lib/auth/oauth/file-storage.js +12 -5
- package/dist/lib/auth/oauth/file-storage.mjs +12 -5
- package/dist/lib/auth/oauth/index.d.mts +10 -6
- package/dist/lib/auth/oauth/index.d.ts +10 -6
- package/dist/lib/auth/oauth/index.js +9 -3
- package/dist/lib/auth/oauth/index.mjs +8 -3
- package/dist/lib/auth/oauth/types.d.mts +9 -2
- package/dist/lib/auth/oauth/types.d.ts +9 -2
- package/dist/lib/auth/oauth/types.js +3 -2
- package/dist/lib/auth/oauth/types.mjs +3 -2
- package/dist/lib/auth/oauth/web-flow.d.mts +2 -0
- package/dist/lib/auth/oauth/web-flow.d.ts +2 -0
- package/dist/lib/auth/oauth/web-flow.js +42 -9
- package/dist/lib/auth/oauth/web-flow.mjs +42 -9
- package/dist/lib/canonical-references/index.d.mts +19 -1
- package/dist/lib/canonical-references/index.d.ts +19 -1
- package/dist/lib/canonical-references/index.js +81 -9
- package/dist/lib/canonical-references/index.mjs +80 -9
- package/dist/lib/client/core.d.mts +1 -0
- package/dist/lib/client/core.d.ts +1 -0
- package/dist/lib/core/AgentClient.d.mts +9 -1
- package/dist/lib/core/AgentClient.d.ts +9 -1
- package/dist/lib/core/AgentClient.js +10 -0
- package/dist/lib/core/AgentClient.mjs +10 -0
- package/dist/lib/core/SingleAgentClient.d.mts +13 -2
- package/dist/lib/core/SingleAgentClient.d.ts +13 -2
- package/dist/lib/core/SingleAgentClient.js +23 -5
- package/dist/lib/core/SingleAgentClient.mjs +23 -5
- package/dist/lib/index.d.mts +2 -2
- package/dist/lib/index.d.ts +2 -2
- package/dist/lib/index.js +2 -0
- package/dist/lib/index.mjs +3 -1
- package/dist/lib/reporting/gcs/adapter.d.mts +31 -0
- package/dist/lib/reporting/gcs/adapter.d.ts +31 -0
- package/dist/lib/reporting/gcs/adapter.js +342 -0
- package/dist/lib/reporting/gcs/adapter.mjs +325 -0
- package/dist/lib/reporting/gcs/bucket-policy.d.mts +3 -0
- package/dist/lib/reporting/gcs/bucket-policy.d.ts +3 -0
- package/dist/lib/reporting/gcs/bucket-policy.js +31 -0
- package/dist/lib/reporting/gcs/bucket-policy.mjs +7 -0
- package/dist/lib/reporting/gcs/errors.d.mts +5 -0
- package/dist/lib/reporting/gcs/errors.d.ts +5 -0
- package/dist/lib/reporting/gcs/errors.js +41 -0
- package/dist/lib/reporting/gcs/errors.mjs +16 -0
- package/dist/lib/reporting/gcs/fence.d.mts +36 -0
- package/dist/lib/reporting/gcs/fence.d.ts +36 -0
- package/dist/lib/reporting/gcs/fence.js +250 -0
- package/dist/lib/reporting/gcs/fence.mjs +230 -0
- package/dist/lib/reporting/gcs/index.d.mts +7 -0
- package/dist/lib/reporting/gcs/index.d.ts +7 -0
- package/dist/lib/reporting/gcs/index.js +41 -0
- package/dist/lib/reporting/gcs/index.mjs +12 -0
- package/dist/lib/reporting/gcs/io.d.mts +7 -0
- package/dist/lib/reporting/gcs/io.d.ts +7 -0
- package/dist/lib/reporting/gcs/io.js +95 -0
- package/dist/lib/reporting/gcs/io.mjs +69 -0
- package/dist/lib/reporting/gcs/reader.d.mts +43 -0
- package/dist/lib/reporting/gcs/reader.d.ts +43 -0
- package/dist/lib/reporting/gcs/reader.js +193 -0
- package/dist/lib/reporting/gcs/reader.mjs +169 -0
- package/dist/lib/reporting/gcs/validation.d.mts +5 -0
- package/dist/lib/reporting/gcs/validation.d.ts +5 -0
- package/dist/lib/reporting/gcs/validation.js +49 -0
- package/dist/lib/reporting/gcs/validation.mjs +25 -0
- package/dist/lib/reporting/ledger/handler.d.mts +1 -0
- package/dist/lib/reporting/ledger/handler.d.ts +1 -0
- 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 +2 -0
- package/dist/lib/reporting/ledger/index.mjs +1 -0
- package/dist/lib/reporting/ledger/managed-postgres.d.mts +16 -1
- package/dist/lib/reporting/ledger/managed-postgres.d.ts +16 -1
- package/dist/lib/reporting/ledger/managed-postgres.js +243 -2
- package/dist/lib/reporting/ledger/managed-postgres.mjs +248 -2
- package/dist/lib/reporting/ledger/object-writes.d.mts +69 -0
- package/dist/lib/reporting/ledger/object-writes.d.ts +69 -0
- package/dist/lib/reporting/ledger/object-writes.js +147 -0
- package/dist/lib/reporting/ledger/object-writes.mjs +114 -0
- package/dist/lib/schemas/index.d.mts +2 -0
- package/dist/lib/schemas/index.d.ts +2 -0
- package/dist/lib/schemas/index.js +3 -0
- package/dist/lib/schemas/index.mjs +2 -0
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/server/a2a-adapter.d.mts +50 -1
- package/dist/lib/server/a2a-adapter.d.ts +50 -1
- package/dist/lib/server/a2a-adapter.js +230 -7
- package/dist/lib/server/a2a-adapter.mjs +237 -7
- package/dist/lib/server/auth-signature.d.mts +84 -46
- package/dist/lib/server/auth-signature.d.ts +84 -46
- package/dist/lib/server/auth-signature.js +48 -14
- package/dist/lib/server/auth-signature.mjs +58 -15
- package/dist/lib/server/create-adcp-server.js +5 -16
- package/dist/lib/server/create-adcp-server.mjs +5 -16
- package/dist/lib/server/index.d.mts +1 -1
- package/dist/lib/server/index.d.ts +1 -1
- package/dist/lib/server/index.js +2 -0
- package/dist/lib/server/index.mjs +3 -1
- package/dist/lib/signing/agent-fetch.js +3 -33
- package/dist/lib/signing/agent-fetch.mjs +3 -33
- package/dist/lib/signing/middleware.d.mts +9 -1
- package/dist/lib/signing/middleware.d.ts +9 -1
- package/dist/lib/signing/operation-resolution.d.mts +37 -0
- package/dist/lib/signing/operation-resolution.d.ts +37 -0
- package/dist/lib/signing/operation-resolution.js +154 -0
- package/dist/lib/signing/operation-resolution.mjs +125 -0
- package/dist/lib/signing/postgres-replay-store.d.mts +1 -1
- package/dist/lib/signing/postgres-replay-store.d.ts +1 -1
- package/dist/lib/signing/redis-replay-store.d.mts +1 -1
- package/dist/lib/signing/redis-replay-store.d.ts +1 -1
- package/dist/lib/signing/server.d.mts +1 -0
- package/dist/lib/signing/server.d.ts +1 -0
- package/dist/lib/signing/server.js +7 -0
- package/dist/lib/signing/server.mjs +8 -0
- package/dist/lib/signing/verifier.d.mts +36 -1
- package/dist/lib/signing/verifier.d.ts +36 -1
- package/dist/lib/signing/verifier.js +66 -34
- package/dist/lib/signing/verifier.mjs +61 -34
- package/dist/lib/testing/client.js +8 -3
- package/dist/lib/testing/client.mjs +8 -3
- package/dist/lib/testing/storyboard/request-signing/a2a-dispatch.d.mts +12 -0
- package/dist/lib/testing/storyboard/request-signing/a2a-dispatch.d.ts +12 -0
- package/dist/lib/testing/storyboard/request-signing/a2a-dispatch.js +29 -2
- package/dist/lib/testing/storyboard/request-signing/a2a-dispatch.mjs +27 -1
- package/dist/lib/testing/storyboard/request-signing/a2a-operation-resolution.d.mts +61 -0
- package/dist/lib/testing/storyboard/request-signing/a2a-operation-resolution.d.ts +61 -0
- package/dist/lib/testing/storyboard/request-signing/a2a-operation-resolution.js +298 -0
- package/dist/lib/testing/storyboard/request-signing/a2a-operation-resolution.mjs +276 -0
- package/dist/lib/testing/storyboard/request-signing/grader.d.mts +31 -1
- package/dist/lib/testing/storyboard/request-signing/grader.d.ts +31 -1
- package/dist/lib/testing/storyboard/request-signing/grader.js +11 -0
- package/dist/lib/testing/storyboard/request-signing/grader.mjs +11 -0
- package/dist/lib/testing/storyboard/request-signing/index.d.mts +5 -4
- package/dist/lib/testing/storyboard/request-signing/index.d.ts +5 -4
- package/dist/lib/testing/storyboard/request-signing/index.js +13 -0
- package/dist/lib/testing/storyboard/request-signing/index.mjs +18 -2
- package/dist/lib/testing/storyboard/request-signing/types.d.mts +43 -0
- package/dist/lib/testing/storyboard/request-signing/types.d.ts +43 -0
- package/dist/lib/testing/storyboard/request-signing/types.js +3 -0
- package/dist/lib/testing/storyboard/request-signing/types.mjs +2 -0
- package/dist/lib/testing/storyboard/request-signing/vector-loader.d.mts +42 -1
- package/dist/lib/testing/storyboard/request-signing/vector-loader.d.ts +42 -1
- package/dist/lib/testing/storyboard/request-signing/vector-loader.js +100 -1
- package/dist/lib/testing/storyboard/request-signing/vector-loader.mjs +104 -3
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/testing/types.d.mts +10 -1
- package/dist/lib/testing/types.d.ts +10 -1
- 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/ZOD-SCHEMAS.md +19 -0
- package/docs/guides/BUILD-AN-AGENT.md +9 -4
- package/docs/guides/CREATIVE-DELIVERY.md +34 -0
- package/docs/guides/OAUTH-ISSUER-BINDING.md +46 -0
- package/docs/guides/REPORTING-GCS-FENCE.md +52 -0
- package/docs/guides/REPORTING-GCS-MANAGED.md +56 -0
- package/docs/guides/REPORTING-OPERATIONS.md +4 -0
- package/docs/guides/SIGNING-GUIDE.md +20 -6
- package/docs/guides/VALIDATE-YOUR-AGENT.md +4 -0
- package/docs/guides/WEB-OAUTH.md +58 -163
- package/docs/guides/account-resolution.md +1 -1
- package/docs/llms.txt +2 -2
- package/docs/migration-14.0-to-14.1.md +1 -1
- package/docs/migration-14.x-rc-worksheet.md +8 -7
- package/docs/migration-buyer-agent-registry.md +1 -1
- package/docs/migration-oauth-issuer-bindings.md +14 -79
- package/package.json +19 -1
- package/skills/build-seller-agent/specialisms/signed-requests.md +2 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var reader_exports = {};
|
|
20
|
+
__export(reader_exports, {
|
|
21
|
+
createGcsReportingReferenceResolverV1: () => createGcsReportingReferenceResolverV1,
|
|
22
|
+
createGcsReportingResourceReaderV1: () => createGcsReportingResourceReaderV1,
|
|
23
|
+
createGcsScopedObjectReadV1: () => createGcsScopedObjectReadV1,
|
|
24
|
+
gcsReportingObjectFromUriV1: () => gcsReportingObjectFromUriV1
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(reader_exports);
|
|
27
|
+
var import_canonical_references = require('../../canonical-references/index.js');
|
|
28
|
+
var import_object_writes = require('../ledger/object-writes.js');
|
|
29
|
+
var import_errors = require('./errors.js');
|
|
30
|
+
var import_io = require('./io.js');
|
|
31
|
+
function gcsReportingObjectFromUriV1(uri, bucket, prefix) {
|
|
32
|
+
if (typeof uri !== "string" || uri.length > 2048) throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
|
|
33
|
+
const expectedBase = `https://storage.googleapis.com/${bucket}/`;
|
|
34
|
+
let parsed;
|
|
35
|
+
try {
|
|
36
|
+
parsed = new URL(uri);
|
|
37
|
+
} catch {
|
|
38
|
+
throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
|
|
39
|
+
}
|
|
40
|
+
const name = uri.startsWith(expectedBase) ? uri.slice(expectedBase.length) : "";
|
|
41
|
+
if (parsed.href !== uri || parsed.username || parsed.password || parsed.search || parsed.hash || !name.startsWith(prefix) || name.length <= prefix.length || name.length > 1024 || !/^[A-Za-z0-9/_.-]+$/.test(name) || name.split("/").some((part) => !part || part === "." || part === ".."))
|
|
42
|
+
throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
|
|
43
|
+
return name;
|
|
44
|
+
}
|
|
45
|
+
function createGcsScopedObjectReadV1(options) {
|
|
46
|
+
let scope;
|
|
47
|
+
try {
|
|
48
|
+
scope = structuredClone(options.scope);
|
|
49
|
+
(0, import_object_writes.assertReportingObjectWriteScope)(scope);
|
|
50
|
+
} catch {
|
|
51
|
+
throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
|
|
52
|
+
}
|
|
53
|
+
if (typeof scope.principal_id !== "string" || scope.principal_id.length < 1 || scope.principal_id.length > 255 || typeof options.bucket !== "string" || !/^[a-z0-9][a-z0-9.-]{1,220}[a-z0-9]$/.test(options.bucket) || typeof options.objectPrefix !== "string" || !/^[A-Za-z0-9/_.-]+\/$/.test(options.objectPrefix) || options.objectPrefix.length > 1e3 || options.objectPrefix.split("/").slice(0, -1).some((p) => !p || p === "." || p === "..") || typeof options.authorize !== "function" || typeof options.getStorage !== "function")
|
|
54
|
+
throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
|
|
55
|
+
Object.freeze(scope);
|
|
56
|
+
const { bucket, objectPrefix, authorize, getStorage, signal: parentSignal } = options;
|
|
57
|
+
if (parentSignal !== void 0 && !(parentSignal instanceof AbortSignal))
|
|
58
|
+
throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
|
|
59
|
+
const maximum = options.maxBytes ?? 64 * 1024 * 1024;
|
|
60
|
+
const milliseconds = options.operationDeadlineMilliseconds ?? 6e4;
|
|
61
|
+
if (!Number.isSafeInteger(maximum) || maximum < 1 || maximum > 64 * 1024 * 1024 || !Number.isSafeInteger(milliseconds) || milliseconds < 1 || milliseconds > 6e4)
|
|
62
|
+
throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
|
|
63
|
+
async function authorized(signal, objectName) {
|
|
64
|
+
(0, import_io.activeGcsSignal)(signal);
|
|
65
|
+
const allowed = await authorize({ scope, bucket, objectPrefix, objectName }, { signal });
|
|
66
|
+
(0, import_io.activeGcsSignal)(signal);
|
|
67
|
+
if (allowed !== true) throw new import_errors.ReportingGcsFenceError("REVOKED");
|
|
68
|
+
}
|
|
69
|
+
return async (uri, maxBytes, signal, nativeVersion) => (0, import_io.withGcsDeadline)(
|
|
70
|
+
async (active) => {
|
|
71
|
+
const name = gcsReportingObjectFromUriV1(uri, bucket, objectPrefix);
|
|
72
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 1 || nativeVersion !== void 0 && !/^[1-9][0-9]{0,39}$/.test(nativeVersion))
|
|
73
|
+
throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
|
|
74
|
+
await authorized(active, name);
|
|
75
|
+
const storage = await getStorage(scope, { signal: active });
|
|
76
|
+
(0, import_io.activeGcsSignal)(active);
|
|
77
|
+
try {
|
|
78
|
+
const file = storage.bucket(bucket).file(name, nativeVersion ? { generation: nativeVersion } : void 0);
|
|
79
|
+
const [metadata] = await file.getMetadata();
|
|
80
|
+
(0, import_io.activeGcsSignal)(active);
|
|
81
|
+
if (metadata.metadata?.adcp_reporting_tombstone !== void 0) throw new import_errors.ReportingGcsFenceError("REVOKED");
|
|
82
|
+
const generation = String(metadata.generation);
|
|
83
|
+
if (nativeVersion !== void 0 && generation !== nativeVersion)
|
|
84
|
+
throw new import_errors.ReportingGcsFenceError("CONTENT_CONFLICT");
|
|
85
|
+
if (!/^[1-9][0-9]{0,39}$/.test(generation) || !/^(?:0|[1-9][0-9]{0,19})$/.test(String(metadata.size)) || BigInt(String(metadata.size)) > BigInt(Math.min(maxBytes, maximum)))
|
|
86
|
+
throw new import_errors.ReportingGcsFenceError("CONTENT_CONFLICT");
|
|
87
|
+
const body = await (0, import_io.readGcsBytes)(
|
|
88
|
+
storage.bucket(bucket).file(name, { generation }),
|
|
89
|
+
Math.min(maxBytes, maximum),
|
|
90
|
+
active
|
|
91
|
+
);
|
|
92
|
+
(0, import_io.activeGcsSignal)(active);
|
|
93
|
+
await authorized(active, name);
|
|
94
|
+
return { body, contentType: metadata.contentType, generation };
|
|
95
|
+
} catch (error) {
|
|
96
|
+
(0, import_io.activeGcsSignal)(active);
|
|
97
|
+
if ((0, import_errors.isReportingGcsFenceError)(error)) throw error;
|
|
98
|
+
await authorized(active, name);
|
|
99
|
+
throw new import_errors.ReportingGcsFenceError("PROVIDER_UNAVAILABLE");
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
signal: parentSignal && signal ? AbortSignal.any([parentSignal, signal]) : parentSignal ?? signal,
|
|
104
|
+
milliseconds
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
function createGcsReportingResourceReaderV1(options) {
|
|
109
|
+
const read = createGcsScopedObjectReadV1(options);
|
|
110
|
+
const scope = structuredClone(options.scope);
|
|
111
|
+
const { bucket, objectPrefix } = options;
|
|
112
|
+
return {
|
|
113
|
+
async read(request) {
|
|
114
|
+
if (!request?.context?.materialization?.resource || !["manifest", "object"].includes(request.role) || request.context.obligation?.account_id !== scope.account_id || request.location !== request.context.materialization.resource.location || request.context.materialization.destination_ref !== scope.destination_ref)
|
|
115
|
+
throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
|
|
116
|
+
let uri = request.location;
|
|
117
|
+
if (request.role === "object") {
|
|
118
|
+
if (typeof request.objectRef !== "string" || !/^[A-Za-z0-9_.-]+$/.test(request.objectRef) || request.objectRef === "." || request.objectRef === "..")
|
|
119
|
+
throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
|
|
120
|
+
const name = gcsReportingObjectFromUriV1(request.location, bucket, objectPrefix);
|
|
121
|
+
uri = `https://storage.googleapis.com/${bucket}/${name.slice(0, name.lastIndexOf("/") + 1)}${request.objectRef}`;
|
|
122
|
+
}
|
|
123
|
+
return read(
|
|
124
|
+
uri,
|
|
125
|
+
request.maxBytes,
|
|
126
|
+
request.signal,
|
|
127
|
+
request.role === "manifest" ? request.context.materialization.resource?.native_version_ref : void 0
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function createGcsReportingReferenceResolverV1(options) {
|
|
133
|
+
const read = createGcsScopedObjectReadV1(options);
|
|
134
|
+
const documentReader = {
|
|
135
|
+
async read(request) {
|
|
136
|
+
try {
|
|
137
|
+
return await read(request.uri, request.maxBytes, request.signal);
|
|
138
|
+
} catch (error) {
|
|
139
|
+
if ((0, import_errors.isReportingGcsFenceError)(error)) {
|
|
140
|
+
if (error.code === "ABORTED") throw new import_canonical_references.CanonicalDocumentReadError("aborted");
|
|
141
|
+
if (error.code === "INVALID_INPUT") throw new import_canonical_references.CanonicalDocumentReadError("unsafe_url");
|
|
142
|
+
if (error.code === "REVOKED") throw new import_canonical_references.CanonicalDocumentReadError("access_denied");
|
|
143
|
+
if (error.code === "CONTENT_CONFLICT") throw new import_canonical_references.CanonicalDocumentReadError("body_too_large");
|
|
144
|
+
}
|
|
145
|
+
throw new import_canonical_references.CanonicalDocumentReadError("network_error");
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
const parentSignal = options.signal;
|
|
150
|
+
const resolver = (0, import_canonical_references.createCanonicalReferenceResolver)({ documentReader, signal: parentSignal });
|
|
151
|
+
const routing = { bucket: options.bucket, objectPrefix: options.objectPrefix };
|
|
152
|
+
const forced = (input) => ({
|
|
153
|
+
...input,
|
|
154
|
+
documentReader,
|
|
155
|
+
signal: parentSignal && input?.signal ? AbortSignal.any([parentSignal, input.signal]) : parentSignal ?? input?.signal
|
|
156
|
+
});
|
|
157
|
+
function blocked(ref, kind) {
|
|
158
|
+
try {
|
|
159
|
+
gcsReportingObjectFromUriV1(ref.uri, routing.bucket, routing.objectPrefix);
|
|
160
|
+
return void 0;
|
|
161
|
+
} catch {
|
|
162
|
+
return {
|
|
163
|
+
ok: false,
|
|
164
|
+
status: "blocked_unsafe_url",
|
|
165
|
+
kind,
|
|
166
|
+
ref: {
|
|
167
|
+
uri: "https://storage.googleapis.com/redacted-invalid-reference",
|
|
168
|
+
digest: /^sha256:[a-f0-9]{64}$/.test(ref?.digest) ? ref.digest : "invalid"
|
|
169
|
+
},
|
|
170
|
+
cacheKey: "private-reference-refused",
|
|
171
|
+
fromCache: false,
|
|
172
|
+
error: {
|
|
173
|
+
code: "unsafe_url",
|
|
174
|
+
message: "Private reference is outside the saved destination scope",
|
|
175
|
+
retryable: false
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
cache: resolver.cache,
|
|
182
|
+
resolve: async (ref, context) => blocked(ref, "generic") ?? resolver.resolve(ref, forced(context)),
|
|
183
|
+
resolveFormatSchema: async (ref, context) => blocked(ref, "format_schema") ?? resolver.resolveFormatSchema(ref, forced(context)),
|
|
184
|
+
resolvePlatformExtensions: async (ref, context) => blocked(ref, "platform_extensions") ?? resolver.resolvePlatformExtensions(ref, forced(context))
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
188
|
+
0 && (module.exports = {
|
|
189
|
+
createGcsReportingReferenceResolverV1,
|
|
190
|
+
createGcsReportingResourceReaderV1,
|
|
191
|
+
createGcsScopedObjectReadV1,
|
|
192
|
+
gcsReportingObjectFromUriV1
|
|
193
|
+
});
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CanonicalDocumentReadError,
|
|
3
|
+
createCanonicalReferenceResolver
|
|
4
|
+
} from "../../canonical-references/index.mjs";
|
|
5
|
+
import { assertReportingObjectWriteScope } from "../ledger/object-writes.mjs";
|
|
6
|
+
import { ReportingGcsFenceError, isReportingGcsFenceError } from "./errors.mjs";
|
|
7
|
+
import { activeGcsSignal, readGcsBytes, withGcsDeadline } from "./io.mjs";
|
|
8
|
+
function gcsReportingObjectFromUriV1(uri, bucket, prefix) {
|
|
9
|
+
if (typeof uri !== "string" || uri.length > 2048) throw new ReportingGcsFenceError("INVALID_INPUT");
|
|
10
|
+
const expectedBase = `https://storage.googleapis.com/${bucket}/`;
|
|
11
|
+
let parsed;
|
|
12
|
+
try {
|
|
13
|
+
parsed = new URL(uri);
|
|
14
|
+
} catch {
|
|
15
|
+
throw new ReportingGcsFenceError("INVALID_INPUT");
|
|
16
|
+
}
|
|
17
|
+
const name = uri.startsWith(expectedBase) ? uri.slice(expectedBase.length) : "";
|
|
18
|
+
if (parsed.href !== uri || parsed.username || parsed.password || parsed.search || parsed.hash || !name.startsWith(prefix) || name.length <= prefix.length || name.length > 1024 || !/^[A-Za-z0-9/_.-]+$/.test(name) || name.split("/").some((part) => !part || part === "." || part === ".."))
|
|
19
|
+
throw new ReportingGcsFenceError("INVALID_INPUT");
|
|
20
|
+
return name;
|
|
21
|
+
}
|
|
22
|
+
function createGcsScopedObjectReadV1(options) {
|
|
23
|
+
let scope;
|
|
24
|
+
try {
|
|
25
|
+
scope = structuredClone(options.scope);
|
|
26
|
+
assertReportingObjectWriteScope(scope);
|
|
27
|
+
} catch {
|
|
28
|
+
throw new ReportingGcsFenceError("INVALID_INPUT");
|
|
29
|
+
}
|
|
30
|
+
if (typeof scope.principal_id !== "string" || scope.principal_id.length < 1 || scope.principal_id.length > 255 || typeof options.bucket !== "string" || !/^[a-z0-9][a-z0-9.-]{1,220}[a-z0-9]$/.test(options.bucket) || typeof options.objectPrefix !== "string" || !/^[A-Za-z0-9/_.-]+\/$/.test(options.objectPrefix) || options.objectPrefix.length > 1e3 || options.objectPrefix.split("/").slice(0, -1).some((p) => !p || p === "." || p === "..") || typeof options.authorize !== "function" || typeof options.getStorage !== "function")
|
|
31
|
+
throw new ReportingGcsFenceError("INVALID_INPUT");
|
|
32
|
+
Object.freeze(scope);
|
|
33
|
+
const { bucket, objectPrefix, authorize, getStorage, signal: parentSignal } = options;
|
|
34
|
+
if (parentSignal !== void 0 && !(parentSignal instanceof AbortSignal))
|
|
35
|
+
throw new ReportingGcsFenceError("INVALID_INPUT");
|
|
36
|
+
const maximum = options.maxBytes ?? 64 * 1024 * 1024;
|
|
37
|
+
const milliseconds = options.operationDeadlineMilliseconds ?? 6e4;
|
|
38
|
+
if (!Number.isSafeInteger(maximum) || maximum < 1 || maximum > 64 * 1024 * 1024 || !Number.isSafeInteger(milliseconds) || milliseconds < 1 || milliseconds > 6e4)
|
|
39
|
+
throw new ReportingGcsFenceError("INVALID_INPUT");
|
|
40
|
+
async function authorized(signal, objectName) {
|
|
41
|
+
activeGcsSignal(signal);
|
|
42
|
+
const allowed = await authorize({ scope, bucket, objectPrefix, objectName }, { signal });
|
|
43
|
+
activeGcsSignal(signal);
|
|
44
|
+
if (allowed !== true) throw new ReportingGcsFenceError("REVOKED");
|
|
45
|
+
}
|
|
46
|
+
return async (uri, maxBytes, signal, nativeVersion) => withGcsDeadline(
|
|
47
|
+
async (active) => {
|
|
48
|
+
const name = gcsReportingObjectFromUriV1(uri, bucket, objectPrefix);
|
|
49
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 1 || nativeVersion !== void 0 && !/^[1-9][0-9]{0,39}$/.test(nativeVersion))
|
|
50
|
+
throw new ReportingGcsFenceError("INVALID_INPUT");
|
|
51
|
+
await authorized(active, name);
|
|
52
|
+
const storage = await getStorage(scope, { signal: active });
|
|
53
|
+
activeGcsSignal(active);
|
|
54
|
+
try {
|
|
55
|
+
const file = storage.bucket(bucket).file(name, nativeVersion ? { generation: nativeVersion } : void 0);
|
|
56
|
+
const [metadata] = await file.getMetadata();
|
|
57
|
+
activeGcsSignal(active);
|
|
58
|
+
if (metadata.metadata?.adcp_reporting_tombstone !== void 0) throw new ReportingGcsFenceError("REVOKED");
|
|
59
|
+
const generation = String(metadata.generation);
|
|
60
|
+
if (nativeVersion !== void 0 && generation !== nativeVersion)
|
|
61
|
+
throw new ReportingGcsFenceError("CONTENT_CONFLICT");
|
|
62
|
+
if (!/^[1-9][0-9]{0,39}$/.test(generation) || !/^(?:0|[1-9][0-9]{0,19})$/.test(String(metadata.size)) || BigInt(String(metadata.size)) > BigInt(Math.min(maxBytes, maximum)))
|
|
63
|
+
throw new ReportingGcsFenceError("CONTENT_CONFLICT");
|
|
64
|
+
const body = await readGcsBytes(
|
|
65
|
+
storage.bucket(bucket).file(name, { generation }),
|
|
66
|
+
Math.min(maxBytes, maximum),
|
|
67
|
+
active
|
|
68
|
+
);
|
|
69
|
+
activeGcsSignal(active);
|
|
70
|
+
await authorized(active, name);
|
|
71
|
+
return { body, contentType: metadata.contentType, generation };
|
|
72
|
+
} catch (error) {
|
|
73
|
+
activeGcsSignal(active);
|
|
74
|
+
if (isReportingGcsFenceError(error)) throw error;
|
|
75
|
+
await authorized(active, name);
|
|
76
|
+
throw new ReportingGcsFenceError("PROVIDER_UNAVAILABLE");
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
signal: parentSignal && signal ? AbortSignal.any([parentSignal, signal]) : parentSignal ?? signal,
|
|
81
|
+
milliseconds
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
function createGcsReportingResourceReaderV1(options) {
|
|
86
|
+
const read = createGcsScopedObjectReadV1(options);
|
|
87
|
+
const scope = structuredClone(options.scope);
|
|
88
|
+
const { bucket, objectPrefix } = options;
|
|
89
|
+
return {
|
|
90
|
+
async read(request) {
|
|
91
|
+
if (!request?.context?.materialization?.resource || !["manifest", "object"].includes(request.role) || request.context.obligation?.account_id !== scope.account_id || request.location !== request.context.materialization.resource.location || request.context.materialization.destination_ref !== scope.destination_ref)
|
|
92
|
+
throw new ReportingGcsFenceError("INVALID_INPUT");
|
|
93
|
+
let uri = request.location;
|
|
94
|
+
if (request.role === "object") {
|
|
95
|
+
if (typeof request.objectRef !== "string" || !/^[A-Za-z0-9_.-]+$/.test(request.objectRef) || request.objectRef === "." || request.objectRef === "..")
|
|
96
|
+
throw new ReportingGcsFenceError("INVALID_INPUT");
|
|
97
|
+
const name = gcsReportingObjectFromUriV1(request.location, bucket, objectPrefix);
|
|
98
|
+
uri = `https://storage.googleapis.com/${bucket}/${name.slice(0, name.lastIndexOf("/") + 1)}${request.objectRef}`;
|
|
99
|
+
}
|
|
100
|
+
return read(
|
|
101
|
+
uri,
|
|
102
|
+
request.maxBytes,
|
|
103
|
+
request.signal,
|
|
104
|
+
request.role === "manifest" ? request.context.materialization.resource?.native_version_ref : void 0
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function createGcsReportingReferenceResolverV1(options) {
|
|
110
|
+
const read = createGcsScopedObjectReadV1(options);
|
|
111
|
+
const documentReader = {
|
|
112
|
+
async read(request) {
|
|
113
|
+
try {
|
|
114
|
+
return await read(request.uri, request.maxBytes, request.signal);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
if (isReportingGcsFenceError(error)) {
|
|
117
|
+
if (error.code === "ABORTED") throw new CanonicalDocumentReadError("aborted");
|
|
118
|
+
if (error.code === "INVALID_INPUT") throw new CanonicalDocumentReadError("unsafe_url");
|
|
119
|
+
if (error.code === "REVOKED") throw new CanonicalDocumentReadError("access_denied");
|
|
120
|
+
if (error.code === "CONTENT_CONFLICT") throw new CanonicalDocumentReadError("body_too_large");
|
|
121
|
+
}
|
|
122
|
+
throw new CanonicalDocumentReadError("network_error");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const parentSignal = options.signal;
|
|
127
|
+
const resolver = createCanonicalReferenceResolver({ documentReader, signal: parentSignal });
|
|
128
|
+
const routing = { bucket: options.bucket, objectPrefix: options.objectPrefix };
|
|
129
|
+
const forced = (input) => ({
|
|
130
|
+
...input,
|
|
131
|
+
documentReader,
|
|
132
|
+
signal: parentSignal && input?.signal ? AbortSignal.any([parentSignal, input.signal]) : parentSignal ?? input?.signal
|
|
133
|
+
});
|
|
134
|
+
function blocked(ref, kind) {
|
|
135
|
+
try {
|
|
136
|
+
gcsReportingObjectFromUriV1(ref.uri, routing.bucket, routing.objectPrefix);
|
|
137
|
+
return void 0;
|
|
138
|
+
} catch {
|
|
139
|
+
return {
|
|
140
|
+
ok: false,
|
|
141
|
+
status: "blocked_unsafe_url",
|
|
142
|
+
kind,
|
|
143
|
+
ref: {
|
|
144
|
+
uri: "https://storage.googleapis.com/redacted-invalid-reference",
|
|
145
|
+
digest: /^sha256:[a-f0-9]{64}$/.test(ref?.digest) ? ref.digest : "invalid"
|
|
146
|
+
},
|
|
147
|
+
cacheKey: "private-reference-refused",
|
|
148
|
+
fromCache: false,
|
|
149
|
+
error: {
|
|
150
|
+
code: "unsafe_url",
|
|
151
|
+
message: "Private reference is outside the saved destination scope",
|
|
152
|
+
retryable: false
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
cache: resolver.cache,
|
|
159
|
+
resolve: async (ref, context) => blocked(ref, "generic") ?? resolver.resolve(ref, forced(context)),
|
|
160
|
+
resolveFormatSchema: async (ref, context) => blocked(ref, "format_schema") ?? resolver.resolveFormatSchema(ref, forced(context)),
|
|
161
|
+
resolvePlatformExtensions: async (ref, context) => blocked(ref, "platform_extensions") ?? resolver.resolvePlatformExtensions(ref, forced(context))
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
export {
|
|
165
|
+
createGcsReportingReferenceResolverV1,
|
|
166
|
+
createGcsReportingResourceReaderV1,
|
|
167
|
+
createGcsScopedObjectReadV1,
|
|
168
|
+
gcsReportingObjectFromUriV1
|
|
169
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ReportingManagedDeliveryAdapterV1 } from '../ledger/managed.mjs';
|
|
2
|
+
import type { ExpectedReportingPeriod } from '../reconciliation.mjs';
|
|
3
|
+
type DeliveryInput = Parameters<ReportingManagedDeliveryAdapterV1['deliver']>[0];
|
|
4
|
+
export declare function assertExpectedBinding(input: DeliveryInput, expected: ExpectedReportingPeriod): void;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ReportingManagedDeliveryAdapterV1 } from '../ledger/managed';
|
|
2
|
+
import type { ExpectedReportingPeriod } from '../reconciliation';
|
|
3
|
+
type DeliveryInput = Parameters<ReportingManagedDeliveryAdapterV1['deliver']>[0];
|
|
4
|
+
export declare function assertExpectedBinding(input: DeliveryInput, expected: ExpectedReportingPeriod): void;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var validation_exports = {};
|
|
20
|
+
__export(validation_exports, {
|
|
21
|
+
assertExpectedBinding: () => assertExpectedBinding
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(validation_exports);
|
|
24
|
+
var import_jcs = require('../../utils/jcs.js');
|
|
25
|
+
var import_errors = require('./errors.js');
|
|
26
|
+
function assertExpectedBinding(input, expected) {
|
|
27
|
+
const {
|
|
28
|
+
binding,
|
|
29
|
+
revision: { wireRevision: r },
|
|
30
|
+
obligation
|
|
31
|
+
} = input;
|
|
32
|
+
const shaMatches = (a, b) => typeof a === "string" && /^[a-fA-F0-9]{64}$/.test(a) && /^[a-fA-F0-9]{64}$/.test(b) && a.toLowerCase() === b.toLowerCase();
|
|
33
|
+
if (expected.verificationProfile !== binding.verification_profile || expected.destinationRef !== binding.destination_ref || expected.deliveryMethod !== binding.method || expected.deliveryConfigId !== binding.delivery_config_id || expected.deliveryConfigVersion !== binding.delivery_config_version || expected.reportDefinitionId !== r.report_definition_id || expected.feedPurpose !== binding.feed_purpose || expected.reportingProfile !== r.reporting_profile || expected.reconciliationMode !== binding.reconciliation_mode || expected.requiredFinality !== obligation.requiredFinality || expected.periodStart !== r.period.start || expected.periodEnd !== r.period.end || (0, import_jcs.canonicalize)([...expected.mediaBuyIds].sort()) !== (0, import_jcs.canonicalize)([...r.media_buy_ids].sort()) || expected.reportDefinitionUri !== r.report_definition_uri || !shaMatches(r.report_definition_sha256, expected.reportDefinitionSha256) || expected.schemaUri !== r.schema_uri || !shaMatches(r.schema_sha256, expected.schemaSha256) || expected.schemaVersion !== r.schema_version || expected.schemaDialect !== r.schema_dialect || expected.schemaRefPolicy !== r.schema_ref_policy || r.finality === "official" && (!expected.officialFinality || expected.officialFinality.policyId !== r.finality_policy_id || expected.officialFinality.basis !== r.finality_basis))
|
|
34
|
+
throw new import_errors.ReportingGcsFenceError("CONTENT_CONFLICT");
|
|
35
|
+
const coverage = (value) => Object.fromEntries(
|
|
36
|
+
Object.entries(value).filter(([key]) => !["evaluated_at", "limitations"].includes(key)).map(([key, item]) => [key, Array.isArray(item) ? [...item].sort() : item])
|
|
37
|
+
);
|
|
38
|
+
if ((0, import_jcs.canonicalize)(coverage(expected.coverage)) !== (0, import_jcs.canonicalize)(coverage(r.coverage)))
|
|
39
|
+
throw new import_errors.ReportingGcsFenceError("CONTENT_CONFLICT");
|
|
40
|
+
if (expected.verificationProfile === "canonical_digest") {
|
|
41
|
+
const pin = expected.canonicalization, digest = r.canonical_content_digest;
|
|
42
|
+
if (!digest || digest.canonicalization_id !== pin.id || digest.canonicalization_uri !== pin.uri || !shaMatches(digest.canonicalization_sha256, pin.sha256))
|
|
43
|
+
throw new import_errors.ReportingGcsFenceError("CONTENT_CONFLICT");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
assertExpectedBinding
|
|
49
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { canonicalize } from "../../utils/jcs.mjs";
|
|
2
|
+
import { ReportingGcsFenceError } from "./errors.mjs";
|
|
3
|
+
function assertExpectedBinding(input, expected) {
|
|
4
|
+
const {
|
|
5
|
+
binding,
|
|
6
|
+
revision: { wireRevision: r },
|
|
7
|
+
obligation
|
|
8
|
+
} = input;
|
|
9
|
+
const shaMatches = (a, b) => typeof a === "string" && /^[a-fA-F0-9]{64}$/.test(a) && /^[a-fA-F0-9]{64}$/.test(b) && a.toLowerCase() === b.toLowerCase();
|
|
10
|
+
if (expected.verificationProfile !== binding.verification_profile || expected.destinationRef !== binding.destination_ref || expected.deliveryMethod !== binding.method || expected.deliveryConfigId !== binding.delivery_config_id || expected.deliveryConfigVersion !== binding.delivery_config_version || expected.reportDefinitionId !== r.report_definition_id || expected.feedPurpose !== binding.feed_purpose || expected.reportingProfile !== r.reporting_profile || expected.reconciliationMode !== binding.reconciliation_mode || expected.requiredFinality !== obligation.requiredFinality || expected.periodStart !== r.period.start || expected.periodEnd !== r.period.end || canonicalize([...expected.mediaBuyIds].sort()) !== canonicalize([...r.media_buy_ids].sort()) || expected.reportDefinitionUri !== r.report_definition_uri || !shaMatches(r.report_definition_sha256, expected.reportDefinitionSha256) || expected.schemaUri !== r.schema_uri || !shaMatches(r.schema_sha256, expected.schemaSha256) || expected.schemaVersion !== r.schema_version || expected.schemaDialect !== r.schema_dialect || expected.schemaRefPolicy !== r.schema_ref_policy || r.finality === "official" && (!expected.officialFinality || expected.officialFinality.policyId !== r.finality_policy_id || expected.officialFinality.basis !== r.finality_basis))
|
|
11
|
+
throw new ReportingGcsFenceError("CONTENT_CONFLICT");
|
|
12
|
+
const coverage = (value) => Object.fromEntries(
|
|
13
|
+
Object.entries(value).filter(([key]) => !["evaluated_at", "limitations"].includes(key)).map(([key, item]) => [key, Array.isArray(item) ? [...item].sort() : item])
|
|
14
|
+
);
|
|
15
|
+
if (canonicalize(coverage(expected.coverage)) !== canonicalize(coverage(r.coverage)))
|
|
16
|
+
throw new ReportingGcsFenceError("CONTENT_CONFLICT");
|
|
17
|
+
if (expected.verificationProfile === "canonical_digest") {
|
|
18
|
+
const pin = expected.canonicalization, digest = r.canonical_content_digest;
|
|
19
|
+
if (!digest || digest.canonicalization_id !== pin.id || digest.canonicalization_uri !== pin.uri || !shaMatches(digest.canonicalization_sha256, pin.sha256))
|
|
20
|
+
throw new ReportingGcsFenceError("CONTENT_CONFLICT");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
assertExpectedBinding
|
|
25
|
+
};
|
|
@@ -13,6 +13,7 @@ export interface ReportingStatusConsumerScopeOptionsV1<TContext = unknown> {
|
|
|
13
13
|
*/
|
|
14
14
|
consumerMismatchEscalation?: ReportingConsumerMismatchEscalationV1;
|
|
15
15
|
}
|
|
16
|
+
export declare function createReportingStatusHandler(store: ReportingLedgerStore): (request: Parameters<ReportingStatusHandlerV1>[0], context: Pick<Parameters<ReportingStatusHandlerV1>[1], 'account' | 'signal'>) => ReturnType<ReportingStatusHandlerV1>;
|
|
16
17
|
export declare function createReportingStatusHandler<TContext = unknown>(store: ReportingLedgerStore, options?: ReportingStatusConsumerScopeOptionsV1<TContext>): ReportingStatusHandlerV1;
|
|
17
18
|
/** Exact revision reader for createAdcpServer's getMediaBuyDelivery slot. */
|
|
18
19
|
export declare function createReportingDeliveryHandler(store: ReportingLedgerStore): ReportingDeliveryHandlerV1;
|
|
@@ -13,6 +13,7 @@ export interface ReportingStatusConsumerScopeOptionsV1<TContext = unknown> {
|
|
|
13
13
|
*/
|
|
14
14
|
consumerMismatchEscalation?: ReportingConsumerMismatchEscalationV1;
|
|
15
15
|
}
|
|
16
|
+
export declare function createReportingStatusHandler(store: ReportingLedgerStore): (request: Parameters<ReportingStatusHandlerV1>[0], context: Pick<Parameters<ReportingStatusHandlerV1>[1], 'account' | 'signal'>) => ReturnType<ReportingStatusHandlerV1>;
|
|
16
17
|
export declare function createReportingStatusHandler<TContext = unknown>(store: ReportingLedgerStore, options?: ReportingStatusConsumerScopeOptionsV1<TContext>): ReportingStatusHandlerV1;
|
|
17
18
|
/** Exact revision reader for createAdcpServer's getMediaBuyDelivery slot. */
|
|
18
19
|
export declare function createReportingDeliveryHandler(store: ReportingLedgerStore): ReportingDeliveryHandlerV1;
|
|
@@ -26,6 +26,7 @@ __reExport(ledger_exports, require('./status-ingest.js'), module.exports);
|
|
|
26
26
|
__reExport(ledger_exports, require('./consumer-status-identity.js'), module.exports);
|
|
27
27
|
__reExport(ledger_exports, require('./managed.js'), module.exports);
|
|
28
28
|
__reExport(ledger_exports, require('./managed-postgres.js'), module.exports);
|
|
29
|
+
__reExport(ledger_exports, require('./object-writes.js'), module.exports);
|
|
29
30
|
__reExport(ledger_exports, require('./notification-activity.js'), module.exports);
|
|
30
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
31
32
|
0 && (module.exports = {
|
|
@@ -40,5 +41,6 @@ __reExport(ledger_exports, require('./notification-activity.js'), module.exports
|
|
|
40
41
|
...require('./consumer-status-identity.js'),
|
|
41
42
|
...require('./managed.js'),
|
|
42
43
|
...require('./managed-postgres.js'),
|
|
44
|
+
...require('./object-writes.js'),
|
|
43
45
|
...require('./notification-activity.js')
|
|
44
46
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ReportingMaterialization, SyncReportingReceiptsResponse } from '../../types/index.mjs';
|
|
2
2
|
import type { ReportingPgPool } from './postgres.mjs';
|
|
3
3
|
import type { ReportingLedgerNotificationActivityPortV1, ReportingLedgerTransactionV1, ReportingManagedDeliveryBindingV1, ReportingLedgerStore } from './types.mjs';
|
|
4
|
+
import { type ReportingObjectWritePlanV1, type ReportingObjectWriteScopeV1, type ReportingObjectWriteCursorV1, type ReportingObjectWriteV1, type ReportingObjectWriteBindingV1, type ReportingObjectWriteContextV1, type ReportingObjectWriteStoreV1, type ReportingObjectWriteAuthorityStoreV1 } from './object-writes.mjs';
|
|
4
5
|
import { type ReportingDestinationAuthorizationV1, type ReportingDestinationRevocationLeaseV1, type ReportingManagedDeliveryLeaseV1, type ReportingManagedDeliveryAdvertisedPoliciesV1, type ReportingManagedDeliveryStore, type ReportingReceiptBatchInputV1 } from './managed.mjs';
|
|
5
6
|
/**
|
|
6
7
|
* Additive migration owned by #2944. It intentionally does not alter the Core
|
|
@@ -52,7 +53,7 @@ export interface PostgresReportingManagedDeliveryStoreOptions {
|
|
|
52
53
|
*/
|
|
53
54
|
evidenceRetentionDays?: number;
|
|
54
55
|
}
|
|
55
|
-
export declare class PostgresReportingManagedDeliveryStore implements ReportingManagedDeliveryStore {
|
|
56
|
+
export declare class PostgresReportingManagedDeliveryStore implements ReportingManagedDeliveryStore, ReportingObjectWriteStoreV1, ReportingObjectWriteAuthorityStoreV1 {
|
|
56
57
|
private readonly pool;
|
|
57
58
|
private readonly evidenceRetentionDays;
|
|
58
59
|
private readonly statusRetentionDays;
|
|
@@ -213,6 +214,20 @@ export declare class PostgresReportingManagedDeliveryStore implements ReportingM
|
|
|
213
214
|
};
|
|
214
215
|
binding: ReportingManagedDeliveryBindingV1;
|
|
215
216
|
} | null>;
|
|
217
|
+
/** Freeze all writable names under the same locks as revokeDestination. */
|
|
218
|
+
registerObjectWritePlan(input: ReportingObjectWritePlanV1, context?: ReportingObjectWriteContextV1): Promise<'registered' | 'unchanged' | 'revoked'>;
|
|
219
|
+
listRevokedObjectWrites(inputScope: ReportingObjectWriteScopeV1, inputOptions?: {
|
|
220
|
+
after?: ReportingObjectWriteCursorV1;
|
|
221
|
+
limit?: number;
|
|
222
|
+
}, context?: ReportingObjectWriteContextV1): Promise<Array<ReportingObjectWriteV1 & ReportingObjectWriteCursorV1>>;
|
|
223
|
+
markObjectWriteFenced(input: ReportingObjectWriteScopeV1 & ReportingObjectWriteCursorV1 & {
|
|
224
|
+
tombstone_generation: string;
|
|
225
|
+
}, context?: ReportingObjectWriteContextV1): Promise<void>;
|
|
226
|
+
getObjectWriteBinding(input: ReportingObjectWriteScopeV1, context?: ReportingObjectWriteContextV1): Promise<ReportingObjectWriteBindingV1 | null>;
|
|
227
|
+
probeObjectWriteAuthority(context?: ReportingObjectWriteContextV1): Promise<boolean>;
|
|
228
|
+
getObjectWriteAuthorityId(context?: ReportingObjectWriteContextV1): Promise<string>;
|
|
229
|
+
getAuthorizedObjectWriteBinding(input: ReportingObjectWriteScopeV1, context?: ReportingObjectWriteContextV1): Promise<ReportingObjectWriteBindingV1 | null>;
|
|
230
|
+
getObjectWritePlan(input: ReportingObjectWriteScopeV1, planId: string, context?: ReportingObjectWriteContextV1): Promise<ReportingObjectWritePlanV1 | null>;
|
|
216
231
|
isAuthorizationCurrent(input: {
|
|
217
232
|
account_id: string;
|
|
218
233
|
destination_ref: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ReportingMaterialization, SyncReportingReceiptsResponse } from '../../types';
|
|
2
2
|
import type { ReportingPgPool } from './postgres';
|
|
3
3
|
import type { ReportingLedgerNotificationActivityPortV1, ReportingLedgerTransactionV1, ReportingManagedDeliveryBindingV1, ReportingLedgerStore } from './types';
|
|
4
|
+
import { type ReportingObjectWritePlanV1, type ReportingObjectWriteScopeV1, type ReportingObjectWriteCursorV1, type ReportingObjectWriteV1, type ReportingObjectWriteBindingV1, type ReportingObjectWriteContextV1, type ReportingObjectWriteStoreV1, type ReportingObjectWriteAuthorityStoreV1 } from './object-writes';
|
|
4
5
|
import { type ReportingDestinationAuthorizationV1, type ReportingDestinationRevocationLeaseV1, type ReportingManagedDeliveryLeaseV1, type ReportingManagedDeliveryAdvertisedPoliciesV1, type ReportingManagedDeliveryStore, type ReportingReceiptBatchInputV1 } from './managed';
|
|
5
6
|
/**
|
|
6
7
|
* Additive migration owned by #2944. It intentionally does not alter the Core
|
|
@@ -52,7 +53,7 @@ export interface PostgresReportingManagedDeliveryStoreOptions {
|
|
|
52
53
|
*/
|
|
53
54
|
evidenceRetentionDays?: number;
|
|
54
55
|
}
|
|
55
|
-
export declare class PostgresReportingManagedDeliveryStore implements ReportingManagedDeliveryStore {
|
|
56
|
+
export declare class PostgresReportingManagedDeliveryStore implements ReportingManagedDeliveryStore, ReportingObjectWriteStoreV1, ReportingObjectWriteAuthorityStoreV1 {
|
|
56
57
|
private readonly pool;
|
|
57
58
|
private readonly evidenceRetentionDays;
|
|
58
59
|
private readonly statusRetentionDays;
|
|
@@ -213,6 +214,20 @@ export declare class PostgresReportingManagedDeliveryStore implements ReportingM
|
|
|
213
214
|
};
|
|
214
215
|
binding: ReportingManagedDeliveryBindingV1;
|
|
215
216
|
} | null>;
|
|
217
|
+
/** Freeze all writable names under the same locks as revokeDestination. */
|
|
218
|
+
registerObjectWritePlan(input: ReportingObjectWritePlanV1, context?: ReportingObjectWriteContextV1): Promise<'registered' | 'unchanged' | 'revoked'>;
|
|
219
|
+
listRevokedObjectWrites(inputScope: ReportingObjectWriteScopeV1, inputOptions?: {
|
|
220
|
+
after?: ReportingObjectWriteCursorV1;
|
|
221
|
+
limit?: number;
|
|
222
|
+
}, context?: ReportingObjectWriteContextV1): Promise<Array<ReportingObjectWriteV1 & ReportingObjectWriteCursorV1>>;
|
|
223
|
+
markObjectWriteFenced(input: ReportingObjectWriteScopeV1 & ReportingObjectWriteCursorV1 & {
|
|
224
|
+
tombstone_generation: string;
|
|
225
|
+
}, context?: ReportingObjectWriteContextV1): Promise<void>;
|
|
226
|
+
getObjectWriteBinding(input: ReportingObjectWriteScopeV1, context?: ReportingObjectWriteContextV1): Promise<ReportingObjectWriteBindingV1 | null>;
|
|
227
|
+
probeObjectWriteAuthority(context?: ReportingObjectWriteContextV1): Promise<boolean>;
|
|
228
|
+
getObjectWriteAuthorityId(context?: ReportingObjectWriteContextV1): Promise<string>;
|
|
229
|
+
getAuthorizedObjectWriteBinding(input: ReportingObjectWriteScopeV1, context?: ReportingObjectWriteContextV1): Promise<ReportingObjectWriteBindingV1 | null>;
|
|
230
|
+
getObjectWritePlan(input: ReportingObjectWriteScopeV1, planId: string, context?: ReportingObjectWriteContextV1): Promise<ReportingObjectWritePlanV1 | null>;
|
|
216
231
|
isAuthorizationCurrent(input: {
|
|
217
232
|
account_id: string;
|
|
218
233
|
destination_ref: string;
|