@adcp/sdk 15.0.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 +7 -2
- 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 +1 -1
- package/dist/lib/index.d.ts +1 -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-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/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/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/BUILD-AN-AGENT.md +9 -4
- package/docs/guides/CREATIVE-DELIVERY.md +34 -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/llms.txt +2 -2
- package/docs/migration-14.x-rc-worksheet.md +5 -4
- package/docs/migration-buyer-agent-registry.md +1 -1
- package/package.json +19 -1
- package/skills/build-seller-agent/specialisms/signed-requests.md +2 -0
|
@@ -4566,7 +4566,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
4566
4566
|
if (hasCreativeFormatData) {
|
|
4567
4567
|
this.validateBeforeCreativeCapabilityProbe("create_media_buy", params, taskOptions);
|
|
4568
4568
|
}
|
|
4569
|
-
const wireMode = hasCreativeFormatData ? this.resolveCreativeFormatWireMode("create_media_buy",
|
|
4569
|
+
const wireMode = hasCreativeFormatData ? await this.resolveCreativeFormatWireMode("create_media_buy", taskOptions) : "canonical";
|
|
4570
4570
|
const wireParams = params;
|
|
4571
4571
|
const result = await this.executeAndHandle(
|
|
4572
4572
|
"create_media_buy",
|
|
@@ -4648,7 +4648,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
4648
4648
|
if (hasCreativeFormatData) {
|
|
4649
4649
|
this.validateBeforeCreativeCapabilityProbe("update_media_buy", params, taskOptions);
|
|
4650
4650
|
}
|
|
4651
|
-
const wireMode = hasCreativeFormatData ? this.resolveCreativeFormatWireMode("update_media_buy",
|
|
4651
|
+
const wireMode = hasCreativeFormatData ? await this.resolveCreativeFormatWireMode("update_media_buy", taskOptions) : "canonical";
|
|
4652
4652
|
const result = await this.executeAndHandle(
|
|
4653
4653
|
"update_media_buy",
|
|
4654
4654
|
"onUpdateMediaBuyStatusChange",
|
|
@@ -4731,7 +4731,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
4731
4731
|
projectionCatalogs ?? this.config.projectionCatalogs
|
|
4732
4732
|
);
|
|
4733
4733
|
this.validateBeforeCreativeCapabilityProbe("sync_creatives", params, taskOptions);
|
|
4734
|
-
const wireMode = this.resolveCreativeFormatWireMode("sync_creatives",
|
|
4734
|
+
const wireMode = await this.resolveCreativeFormatWireMode("sync_creatives", taskOptions);
|
|
4735
4735
|
const configuredSelectorContainers = [
|
|
4736
4736
|
...creativeFormatProjection?.selectorContainers ?? []
|
|
4737
4737
|
];
|
|
@@ -4775,10 +4775,28 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
4775
4775
|
"onSyncCreativesStatusChange"
|
|
4776
4776
|
);
|
|
4777
4777
|
}
|
|
4778
|
-
|
|
4778
|
+
/**
|
|
4779
|
+
* Resolve the creative wire mode used by the canonical write methods without
|
|
4780
|
+
* sending a mutation. Discovers capabilities and the current tool's input
|
|
4781
|
+
* schema, or reuses fresh cached/primed evidence, with this client's wire pin.
|
|
4782
|
+
*
|
|
4783
|
+
* `unknown` preserves the conservative legacy projection for older peers
|
|
4784
|
+
* whose capabilities and schema do not establish support. Projection still
|
|
4785
|
+
* requires an unambiguous legacy reference for each creative in that case.
|
|
4786
|
+
* Conflicting evidence and unproven support with a 3.2+ buyer pin throw
|
|
4787
|
+
* `CreativeFormatCapabilityError`, just as they do during a write.
|
|
4788
|
+
*/
|
|
4789
|
+
async resolveCreativeFormatWireMode(taskType, options) {
|
|
4790
|
+
const discoveryContext = {};
|
|
4791
|
+
const capabilities = await this.getCapabilities({
|
|
4792
|
+
...options,
|
|
4793
|
+
[CAPABILITY_DISCOVERY_CONTEXT]: discoveryContext
|
|
4794
|
+
});
|
|
4795
|
+
const usesScopedFetch = (0, import_protocols.normalizeTransportOptions)(options?.transport ?? this.config.transport)?.trustedFetchFn !== void 0;
|
|
4796
|
+
const toolSchemas = discoveryContext.toolSchemas ?? (usesScopedFetch ? void 0 : this.cachedToolSchemas);
|
|
4779
4797
|
const wireRelease = this.config.wireAdcpVersion ?? this.resolvedAdcpVersion;
|
|
4780
4798
|
const declared = (0, import_creative_delivery.resolveCreativeFormatWireMode)(capabilities, wireRelease);
|
|
4781
|
-
const schema = creativeSchemaSupport(
|
|
4799
|
+
const schema = creativeSchemaSupport(toolSchemas?.get(taskType));
|
|
4782
4800
|
if (declared !== "unknown" && schema !== "unknown" && declared !== schema) {
|
|
4783
4801
|
throw new import_creative_delivery.CreativeFormatCapabilityError(
|
|
4784
4802
|
`Seller capability and ${taskType} input schema disagree about canonical creative support`
|
|
@@ -4636,7 +4636,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
4636
4636
|
if (hasCreativeFormatData) {
|
|
4637
4637
|
this.validateBeforeCreativeCapabilityProbe("create_media_buy", params, taskOptions);
|
|
4638
4638
|
}
|
|
4639
|
-
const wireMode = hasCreativeFormatData ? this.resolveCreativeFormatWireMode("create_media_buy",
|
|
4639
|
+
const wireMode = hasCreativeFormatData ? await this.resolveCreativeFormatWireMode("create_media_buy", taskOptions) : "canonical";
|
|
4640
4640
|
const wireParams = params;
|
|
4641
4641
|
const result = await this.executeAndHandle(
|
|
4642
4642
|
"create_media_buy",
|
|
@@ -4718,7 +4718,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
4718
4718
|
if (hasCreativeFormatData) {
|
|
4719
4719
|
this.validateBeforeCreativeCapabilityProbe("update_media_buy", params, taskOptions);
|
|
4720
4720
|
}
|
|
4721
|
-
const wireMode = hasCreativeFormatData ? this.resolveCreativeFormatWireMode("update_media_buy",
|
|
4721
|
+
const wireMode = hasCreativeFormatData ? await this.resolveCreativeFormatWireMode("update_media_buy", taskOptions) : "canonical";
|
|
4722
4722
|
const result = await this.executeAndHandle(
|
|
4723
4723
|
"update_media_buy",
|
|
4724
4724
|
"onUpdateMediaBuyStatusChange",
|
|
@@ -4801,7 +4801,7 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
4801
4801
|
projectionCatalogs ?? this.config.projectionCatalogs
|
|
4802
4802
|
);
|
|
4803
4803
|
this.validateBeforeCreativeCapabilityProbe("sync_creatives", params, taskOptions);
|
|
4804
|
-
const wireMode = this.resolveCreativeFormatWireMode("sync_creatives",
|
|
4804
|
+
const wireMode = await this.resolveCreativeFormatWireMode("sync_creatives", taskOptions);
|
|
4805
4805
|
const configuredSelectorContainers = [
|
|
4806
4806
|
...creativeFormatProjection?.selectorContainers ?? []
|
|
4807
4807
|
];
|
|
@@ -4845,10 +4845,28 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
4845
4845
|
"onSyncCreativesStatusChange"
|
|
4846
4846
|
);
|
|
4847
4847
|
}
|
|
4848
|
-
|
|
4848
|
+
/**
|
|
4849
|
+
* Resolve the creative wire mode used by the canonical write methods without
|
|
4850
|
+
* sending a mutation. Discovers capabilities and the current tool's input
|
|
4851
|
+
* schema, or reuses fresh cached/primed evidence, with this client's wire pin.
|
|
4852
|
+
*
|
|
4853
|
+
* `unknown` preserves the conservative legacy projection for older peers
|
|
4854
|
+
* whose capabilities and schema do not establish support. Projection still
|
|
4855
|
+
* requires an unambiguous legacy reference for each creative in that case.
|
|
4856
|
+
* Conflicting evidence and unproven support with a 3.2+ buyer pin throw
|
|
4857
|
+
* `CreativeFormatCapabilityError`, just as they do during a write.
|
|
4858
|
+
*/
|
|
4859
|
+
async resolveCreativeFormatWireMode(taskType, options) {
|
|
4860
|
+
const discoveryContext = {};
|
|
4861
|
+
const capabilities = await this.getCapabilities({
|
|
4862
|
+
...options,
|
|
4863
|
+
[CAPABILITY_DISCOVERY_CONTEXT]: discoveryContext
|
|
4864
|
+
});
|
|
4865
|
+
const usesScopedFetch = normalizeTransportOptions(options?.transport ?? this.config.transport)?.trustedFetchFn !== void 0;
|
|
4866
|
+
const toolSchemas = discoveryContext.toolSchemas ?? (usesScopedFetch ? void 0 : this.cachedToolSchemas);
|
|
4849
4867
|
const wireRelease = this.config.wireAdcpVersion ?? this.resolvedAdcpVersion;
|
|
4850
4868
|
const declared = resolveCreativeFormatWireMode(capabilities, wireRelease);
|
|
4851
|
-
const schema = creativeSchemaSupport(
|
|
4869
|
+
const schema = creativeSchemaSupport(toolSchemas?.get(taskType));
|
|
4852
4870
|
if (declared !== "unknown" && schema !== "unknown" && declared !== schema) {
|
|
4853
4871
|
throw new CreativeFormatCapabilityError(
|
|
4854
4872
|
`Seller capability and ${taskType} input schema disagree about canonical creative support`
|
package/dist/lib/index.d.mts
CHANGED
|
@@ -214,7 +214,7 @@ export { FormatAsset, imageAssetSlot, videoAssetSlot, audioAssetSlot, textAssetS
|
|
|
214
214
|
export { Render, urlRender, htmlRender, bothRender } from './utils/render-builders.mjs';
|
|
215
215
|
export { FormatRender, displayRender, parameterizedRender, templateRender, type DimensionsRender, type ParameterizedRender, type RenderItem, } from './utils/format-render-builders.mjs';
|
|
216
216
|
export { CanonicalFormat, canonicalFormatDeclaration, type CanonicalFormatDeclaration, type CanonicalFormatDeclaration as Format, type CanonicalFormatDeclarationFields, type CanonicalFormatKind, type CanonicalFormatParams, type ProductCardDetailedFields, type ProductCardFields, } from './v2/projection/index.mjs';
|
|
217
|
-
export { toCanonicalFormatOptionsWithRoutes, toAdditiveCanonicalProduct, withAdditiveCanonicalFormatOptions, toCanonicalOnlyProduct, toCanonicalOnlyResponse, packageRefsForFormatOptions, FormatOptionRefsLookupError, CreativeFormatCapabilityError, CreativeFormatProjectionError, type LegacyFormatConversionContext, type LegacyFormatConverter, type LegacyFormatResolutionContext, type LegacyFormatResolver, legacyFormatConverterFromCatalogSnapshots, canonicalFormatLegacyResolverFromCatalogSnapshots, canonicalFormatLegacyResolverFromRoutes, legacyRoutesForProduct, projectionAdaptersFromCatalogSnapshots, type ProjectionCatalogAdapters, type ProjectionCatalogSnapshot, type ProjectionCatalogSource, type CanonicalFormatLegacyResolver, type CanonicalFormatLegacyResolutionContext, type CanonicalFormatLegacyRoute, type AdditiveCanonicalProduct, type CanonicalOnlyProduct, type CanonicalCreativeAsset, type CanonicalCreativeAsset as CreativeAsset, type CanonicalSyncCreativeAsset, type CanonicalCreateMediaBuyInput, type CanonicalCreateMediaBuyRequest, type CanonicalCreateMediaBuyRequest as CreateMediaBuyRequest, type CanonicalCreateMediaBuyResponse, type CanonicalCreateMediaBuyResponse as CreateMediaBuyResponse, type CanonicalCreativeResponse, type CanonicalCreativeFilters, type CanonicalCreativeFilters as CreativeFilters, type CanonicalGetCreativeDeliveryResponse, type CanonicalGetCreativeDeliveryResponse as GetCreativeDeliveryResponse, type CanonicalGetMediaBuyDeliveryResponse, type CanonicalGetMediaBuyDeliveryResponse as GetMediaBuyDeliveryResponse, type CanonicalGetMediaBuysResponse, type CanonicalGetMediaBuysResponse as GetMediaBuysResponse, type CanonicalGetProductsResponse as GetProductsResponse, type CanonicalGetProductsRequest, type CanonicalGetProductsRequest as GetProductsRequest, type CanonicalListCreativesRequest, type CanonicalListCreativesRequest as ListCreativesRequest, type CanonicalListCreativesResponse, type CanonicalListCreativesResponse as ListCreativesResponse, type CanonicalListedCreative, type CanonicalPackageRequest, type CanonicalPackageRequest as PackageRequest, type CanonicalPackageUpdate, type CanonicalPackageUpdate as PackageUpdate, type CanonicalPackage, type CanonicalPackage as Package, type CanonicalPlacement, type CanonicalPlacement as Placement, type CanonicalPreviewCreativeRequest, type CanonicalPreviewCreativeRequest as PreviewCreativeRequest, type CanonicalPreviewCreativeResponse, type CanonicalPreviewCreativeResponse as PreviewCreativeResponse, type CanonicalProduct, type CanonicalProduct as Product, type CanonicalProjectedCreative, type CanonicalSyncCreativesRequest, type CanonicalSyncCreativesRequest as SyncCreativesRequest, type CanonicalSyncCreativesResponse, type CanonicalSyncCreativesResponse as SyncCreativesResponse, type CanonicalUpdateMediaBuyRequest, type CanonicalUpdateMediaBuyRequest as UpdateMediaBuyRequest, type CanonicalUpdateMediaBuyResponse, type CanonicalUpdateMediaBuyResponse as UpdateMediaBuyResponse, type LegacyCreativeAsset, type CanonicalCreativeFormatSelectorContainer, type PackageFormatRefs, type ProjectionDiagnostic, type SyncCreativeFormatProjection, } from './v2/projection/index.mjs';
|
|
217
|
+
export { toCanonicalFormatOptionsWithRoutes, toAdditiveCanonicalProduct, withAdditiveCanonicalFormatOptions, toCanonicalOnlyProduct, toCanonicalOnlyResponse, packageRefsForFormatOptions, FormatOptionRefsLookupError, CreativeFormatCapabilityError, CreativeFormatProjectionError, type CreativeFormatWireMode, type LegacyFormatConversionContext, type LegacyFormatConverter, type LegacyFormatResolutionContext, type LegacyFormatResolver, legacyFormatConverterFromCatalogSnapshots, canonicalFormatLegacyResolverFromCatalogSnapshots, canonicalFormatLegacyResolverFromRoutes, legacyRoutesForProduct, projectionAdaptersFromCatalogSnapshots, type ProjectionCatalogAdapters, type ProjectionCatalogSnapshot, type ProjectionCatalogSource, type CanonicalFormatLegacyResolver, type CanonicalFormatLegacyResolutionContext, type CanonicalFormatLegacyRoute, type AdditiveCanonicalProduct, type CanonicalOnlyProduct, type CanonicalCreativeAsset, type CanonicalCreativeAsset as CreativeAsset, type CanonicalSyncCreativeAsset, type CanonicalCreateMediaBuyInput, type CanonicalCreateMediaBuyRequest, type CanonicalCreateMediaBuyRequest as CreateMediaBuyRequest, type CanonicalCreateMediaBuyResponse, type CanonicalCreateMediaBuyResponse as CreateMediaBuyResponse, type CanonicalCreativeResponse, type CanonicalCreativeFilters, type CanonicalCreativeFilters as CreativeFilters, type CanonicalGetCreativeDeliveryResponse, type CanonicalGetCreativeDeliveryResponse as GetCreativeDeliveryResponse, type CanonicalGetMediaBuyDeliveryResponse, type CanonicalGetMediaBuyDeliveryResponse as GetMediaBuyDeliveryResponse, type CanonicalGetMediaBuysResponse, type CanonicalGetMediaBuysResponse as GetMediaBuysResponse, type CanonicalGetProductsResponse as GetProductsResponse, type CanonicalGetProductsRequest, type CanonicalGetProductsRequest as GetProductsRequest, type CanonicalListCreativesRequest, type CanonicalListCreativesRequest as ListCreativesRequest, type CanonicalListCreativesResponse, type CanonicalListCreativesResponse as ListCreativesResponse, type CanonicalListedCreative, type CanonicalPackageRequest, type CanonicalPackageRequest as PackageRequest, type CanonicalPackageUpdate, type CanonicalPackageUpdate as PackageUpdate, type CanonicalPackage, type CanonicalPackage as Package, type CanonicalPlacement, type CanonicalPlacement as Placement, type CanonicalPreviewCreativeRequest, type CanonicalPreviewCreativeRequest as PreviewCreativeRequest, type CanonicalPreviewCreativeResponse, type CanonicalPreviewCreativeResponse as PreviewCreativeResponse, type CanonicalProduct, type CanonicalProduct as Product, type CanonicalProjectedCreative, type CanonicalSyncCreativesRequest, type CanonicalSyncCreativesRequest as SyncCreativesRequest, type CanonicalSyncCreativesResponse, type CanonicalSyncCreativesResponse as SyncCreativesResponse, type CanonicalUpdateMediaBuyRequest, type CanonicalUpdateMediaBuyRequest as UpdateMediaBuyRequest, type CanonicalUpdateMediaBuyResponse, type CanonicalUpdateMediaBuyResponse as UpdateMediaBuyResponse, type LegacyCreativeAsset, type CanonicalCreativeFormatSelectorContainer, type PackageFormatRefs, type ProjectionDiagnostic, type SyncCreativeFormatProjection, } from './v2/projection/index.mjs';
|
|
218
218
|
export { activationKey, segmentIdActivationKey, keyValueActivationKey } from './utils/activation-key-builders.mjs';
|
|
219
219
|
export { signalId, catalogSignalId, agentSignalId, getSignalId, getSignalIssuer } from './utils/signal-id-builders.mjs';
|
|
220
220
|
export { buildActivateSignalRequest, getSignalActivationId, getSignalPricingOptionIds, normalizeDiscoveredSignal, } from './utils/signal-discovery-helpers.mjs';
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -214,7 +214,7 @@ export { FormatAsset, imageAssetSlot, videoAssetSlot, audioAssetSlot, textAssetS
|
|
|
214
214
|
export { Render, urlRender, htmlRender, bothRender } from './utils/render-builders';
|
|
215
215
|
export { FormatRender, displayRender, parameterizedRender, templateRender, type DimensionsRender, type ParameterizedRender, type RenderItem, } from './utils/format-render-builders';
|
|
216
216
|
export { CanonicalFormat, canonicalFormatDeclaration, type CanonicalFormatDeclaration, type CanonicalFormatDeclaration as Format, type CanonicalFormatDeclarationFields, type CanonicalFormatKind, type CanonicalFormatParams, type ProductCardDetailedFields, type ProductCardFields, } from './v2/projection';
|
|
217
|
-
export { toCanonicalFormatOptionsWithRoutes, toAdditiveCanonicalProduct, withAdditiveCanonicalFormatOptions, toCanonicalOnlyProduct, toCanonicalOnlyResponse, packageRefsForFormatOptions, FormatOptionRefsLookupError, CreativeFormatCapabilityError, CreativeFormatProjectionError, type LegacyFormatConversionContext, type LegacyFormatConverter, type LegacyFormatResolutionContext, type LegacyFormatResolver, legacyFormatConverterFromCatalogSnapshots, canonicalFormatLegacyResolverFromCatalogSnapshots, canonicalFormatLegacyResolverFromRoutes, legacyRoutesForProduct, projectionAdaptersFromCatalogSnapshots, type ProjectionCatalogAdapters, type ProjectionCatalogSnapshot, type ProjectionCatalogSource, type CanonicalFormatLegacyResolver, type CanonicalFormatLegacyResolutionContext, type CanonicalFormatLegacyRoute, type AdditiveCanonicalProduct, type CanonicalOnlyProduct, type CanonicalCreativeAsset, type CanonicalCreativeAsset as CreativeAsset, type CanonicalSyncCreativeAsset, type CanonicalCreateMediaBuyInput, type CanonicalCreateMediaBuyRequest, type CanonicalCreateMediaBuyRequest as CreateMediaBuyRequest, type CanonicalCreateMediaBuyResponse, type CanonicalCreateMediaBuyResponse as CreateMediaBuyResponse, type CanonicalCreativeResponse, type CanonicalCreativeFilters, type CanonicalCreativeFilters as CreativeFilters, type CanonicalGetCreativeDeliveryResponse, type CanonicalGetCreativeDeliveryResponse as GetCreativeDeliveryResponse, type CanonicalGetMediaBuyDeliveryResponse, type CanonicalGetMediaBuyDeliveryResponse as GetMediaBuyDeliveryResponse, type CanonicalGetMediaBuysResponse, type CanonicalGetMediaBuysResponse as GetMediaBuysResponse, type CanonicalGetProductsResponse as GetProductsResponse, type CanonicalGetProductsRequest, type CanonicalGetProductsRequest as GetProductsRequest, type CanonicalListCreativesRequest, type CanonicalListCreativesRequest as ListCreativesRequest, type CanonicalListCreativesResponse, type CanonicalListCreativesResponse as ListCreativesResponse, type CanonicalListedCreative, type CanonicalPackageRequest, type CanonicalPackageRequest as PackageRequest, type CanonicalPackageUpdate, type CanonicalPackageUpdate as PackageUpdate, type CanonicalPackage, type CanonicalPackage as Package, type CanonicalPlacement, type CanonicalPlacement as Placement, type CanonicalPreviewCreativeRequest, type CanonicalPreviewCreativeRequest as PreviewCreativeRequest, type CanonicalPreviewCreativeResponse, type CanonicalPreviewCreativeResponse as PreviewCreativeResponse, type CanonicalProduct, type CanonicalProduct as Product, type CanonicalProjectedCreative, type CanonicalSyncCreativesRequest, type CanonicalSyncCreativesRequest as SyncCreativesRequest, type CanonicalSyncCreativesResponse, type CanonicalSyncCreativesResponse as SyncCreativesResponse, type CanonicalUpdateMediaBuyRequest, type CanonicalUpdateMediaBuyRequest as UpdateMediaBuyRequest, type CanonicalUpdateMediaBuyResponse, type CanonicalUpdateMediaBuyResponse as UpdateMediaBuyResponse, type LegacyCreativeAsset, type CanonicalCreativeFormatSelectorContainer, type PackageFormatRefs, type ProjectionDiagnostic, type SyncCreativeFormatProjection, } from './v2/projection';
|
|
217
|
+
export { toCanonicalFormatOptionsWithRoutes, toAdditiveCanonicalProduct, withAdditiveCanonicalFormatOptions, toCanonicalOnlyProduct, toCanonicalOnlyResponse, packageRefsForFormatOptions, FormatOptionRefsLookupError, CreativeFormatCapabilityError, CreativeFormatProjectionError, type CreativeFormatWireMode, type LegacyFormatConversionContext, type LegacyFormatConverter, type LegacyFormatResolutionContext, type LegacyFormatResolver, legacyFormatConverterFromCatalogSnapshots, canonicalFormatLegacyResolverFromCatalogSnapshots, canonicalFormatLegacyResolverFromRoutes, legacyRoutesForProduct, projectionAdaptersFromCatalogSnapshots, type ProjectionCatalogAdapters, type ProjectionCatalogSnapshot, type ProjectionCatalogSource, type CanonicalFormatLegacyResolver, type CanonicalFormatLegacyResolutionContext, type CanonicalFormatLegacyRoute, type AdditiveCanonicalProduct, type CanonicalOnlyProduct, type CanonicalCreativeAsset, type CanonicalCreativeAsset as CreativeAsset, type CanonicalSyncCreativeAsset, type CanonicalCreateMediaBuyInput, type CanonicalCreateMediaBuyRequest, type CanonicalCreateMediaBuyRequest as CreateMediaBuyRequest, type CanonicalCreateMediaBuyResponse, type CanonicalCreateMediaBuyResponse as CreateMediaBuyResponse, type CanonicalCreativeResponse, type CanonicalCreativeFilters, type CanonicalCreativeFilters as CreativeFilters, type CanonicalGetCreativeDeliveryResponse, type CanonicalGetCreativeDeliveryResponse as GetCreativeDeliveryResponse, type CanonicalGetMediaBuyDeliveryResponse, type CanonicalGetMediaBuyDeliveryResponse as GetMediaBuyDeliveryResponse, type CanonicalGetMediaBuysResponse, type CanonicalGetMediaBuysResponse as GetMediaBuysResponse, type CanonicalGetProductsResponse as GetProductsResponse, type CanonicalGetProductsRequest, type CanonicalGetProductsRequest as GetProductsRequest, type CanonicalListCreativesRequest, type CanonicalListCreativesRequest as ListCreativesRequest, type CanonicalListCreativesResponse, type CanonicalListCreativesResponse as ListCreativesResponse, type CanonicalListedCreative, type CanonicalPackageRequest, type CanonicalPackageRequest as PackageRequest, type CanonicalPackageUpdate, type CanonicalPackageUpdate as PackageUpdate, type CanonicalPackage, type CanonicalPackage as Package, type CanonicalPlacement, type CanonicalPlacement as Placement, type CanonicalPreviewCreativeRequest, type CanonicalPreviewCreativeRequest as PreviewCreativeRequest, type CanonicalPreviewCreativeResponse, type CanonicalPreviewCreativeResponse as PreviewCreativeResponse, type CanonicalProduct, type CanonicalProduct as Product, type CanonicalProjectedCreative, type CanonicalSyncCreativesRequest, type CanonicalSyncCreativesRequest as SyncCreativesRequest, type CanonicalSyncCreativesResponse, type CanonicalSyncCreativesResponse as SyncCreativesResponse, type CanonicalUpdateMediaBuyRequest, type CanonicalUpdateMediaBuyRequest as UpdateMediaBuyRequest, type CanonicalUpdateMediaBuyResponse, type CanonicalUpdateMediaBuyResponse as UpdateMediaBuyResponse, type LegacyCreativeAsset, type CanonicalCreativeFormatSelectorContainer, type PackageFormatRefs, type ProjectionDiagnostic, type SyncCreativeFormatProjection, } from './v2/projection';
|
|
218
218
|
export { activationKey, segmentIdActivationKey, keyValueActivationKey } from './utils/activation-key-builders';
|
|
219
219
|
export { signalId, catalogSignalId, agentSignalId, getSignalId, getSignalIssuer } from './utils/signal-id-builders';
|
|
220
220
|
export { buildActivateSignalRequest, getSignalActivationId, getSignalPricingOptionIds, normalizeDiscoveredSignal, } from './utils/signal-discovery-helpers';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Storage } from '@google-cloud/storage';
|
|
2
|
+
import type { ExpectedReportingPeriod } from '../reconciliation.mjs';
|
|
3
|
+
import type { ReportingManagedDeliveryAdapterV1, ReportingManagedDeliveryStore } from '../ledger/managed.mjs';
|
|
4
|
+
import type { ReportingLedgerStore } from '../ledger/types.mjs';
|
|
5
|
+
import { type ReportingObjectWriteAuthorityStoreV1 } from '../ledger/object-writes.mjs';
|
|
6
|
+
import { type GcsReportingReaderOptionsV1 } from './reader.mjs';
|
|
7
|
+
type DeliveryInput = Parameters<ReportingManagedDeliveryAdapterV1['deliver']>[0];
|
|
8
|
+
export interface CreateGcsReportingManagedDeliveryAdapterOptionsV1 {
|
|
9
|
+
storage: Storage;
|
|
10
|
+
coreStore: ReportingLedgerStore;
|
|
11
|
+
store: ReportingManagedDeliveryStore & ReportingObjectWriteAuthorityStoreV1;
|
|
12
|
+
bucket: string;
|
|
13
|
+
namespace: string;
|
|
14
|
+
/** Bucket was dedicated and safe before any reporting bytes existed; its policy remains host-controlled. */
|
|
15
|
+
acknowledgeDedicatedFreshBucket: true;
|
|
16
|
+
/** Independently selected contract from authenticated saved host configuration, not returned producer evidence. */
|
|
17
|
+
resolveExpectedPeriod(input: DeliveryInput, context: {
|
|
18
|
+
signal: AbortSignal;
|
|
19
|
+
}): Promise<ExpectedReportingPeriod>;
|
|
20
|
+
/** Exact saved private-contract scope, with principal and bucket/prefix ownership checks. */
|
|
21
|
+
resolveContractReader(input: DeliveryInput, context: {
|
|
22
|
+
signal: AbortSignal;
|
|
23
|
+
}): Promise<GcsReportingReaderOptionsV1>;
|
|
24
|
+
operationDeadlineMilliseconds?: number;
|
|
25
|
+
minimumResourceRetentionDays?: number;
|
|
26
|
+
}
|
|
27
|
+
/** Complete file-transfer adapter. Availability and cleanup lease commits remain with the managed runtime. */
|
|
28
|
+
export declare function createGcsReportingManagedDeliveryAdapterV1(options: CreateGcsReportingManagedDeliveryAdapterOptionsV1, context?: {
|
|
29
|
+
signal?: AbortSignal;
|
|
30
|
+
}): Promise<ReportingManagedDeliveryAdapterV1>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Storage } from '@google-cloud/storage';
|
|
2
|
+
import type { ExpectedReportingPeriod } from '../reconciliation';
|
|
3
|
+
import type { ReportingManagedDeliveryAdapterV1, ReportingManagedDeliveryStore } from '../ledger/managed';
|
|
4
|
+
import type { ReportingLedgerStore } from '../ledger/types';
|
|
5
|
+
import { type ReportingObjectWriteAuthorityStoreV1 } from '../ledger/object-writes';
|
|
6
|
+
import { type GcsReportingReaderOptionsV1 } from './reader';
|
|
7
|
+
type DeliveryInput = Parameters<ReportingManagedDeliveryAdapterV1['deliver']>[0];
|
|
8
|
+
export interface CreateGcsReportingManagedDeliveryAdapterOptionsV1 {
|
|
9
|
+
storage: Storage;
|
|
10
|
+
coreStore: ReportingLedgerStore;
|
|
11
|
+
store: ReportingManagedDeliveryStore & ReportingObjectWriteAuthorityStoreV1;
|
|
12
|
+
bucket: string;
|
|
13
|
+
namespace: string;
|
|
14
|
+
/** Bucket was dedicated and safe before any reporting bytes existed; its policy remains host-controlled. */
|
|
15
|
+
acknowledgeDedicatedFreshBucket: true;
|
|
16
|
+
/** Independently selected contract from authenticated saved host configuration, not returned producer evidence. */
|
|
17
|
+
resolveExpectedPeriod(input: DeliveryInput, context: {
|
|
18
|
+
signal: AbortSignal;
|
|
19
|
+
}): Promise<ExpectedReportingPeriod>;
|
|
20
|
+
/** Exact saved private-contract scope, with principal and bucket/prefix ownership checks. */
|
|
21
|
+
resolveContractReader(input: DeliveryInput, context: {
|
|
22
|
+
signal: AbortSignal;
|
|
23
|
+
}): Promise<GcsReportingReaderOptionsV1>;
|
|
24
|
+
operationDeadlineMilliseconds?: number;
|
|
25
|
+
minimumResourceRetentionDays?: number;
|
|
26
|
+
}
|
|
27
|
+
/** Complete file-transfer adapter. Availability and cleanup lease commits remain with the managed runtime. */
|
|
28
|
+
export declare function createGcsReportingManagedDeliveryAdapterV1(options: CreateGcsReportingManagedDeliveryAdapterOptionsV1, context?: {
|
|
29
|
+
signal?: AbortSignal;
|
|
30
|
+
}): Promise<ReportingManagedDeliveryAdapterV1>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,342 @@
|
|
|
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 adapter_exports = {};
|
|
20
|
+
__export(adapter_exports, {
|
|
21
|
+
createGcsReportingManagedDeliveryAdapterV1: () => createGcsReportingManagedDeliveryAdapterV1
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(adapter_exports);
|
|
24
|
+
var import_node_crypto = require("node:crypto");
|
|
25
|
+
var import_jcs = require('../../utils/jcs.js');
|
|
26
|
+
var import_inspection = require('../inspection.js');
|
|
27
|
+
var import_handler = require('../ledger/handler.js');
|
|
28
|
+
var import_object_writes = require('../ledger/object-writes.js');
|
|
29
|
+
var import_fence = require('./fence.js');
|
|
30
|
+
var import_errors = require('./errors.js');
|
|
31
|
+
var import_io = require('./io.js');
|
|
32
|
+
var import_validation = require('./validation.js');
|
|
33
|
+
var import_reader = require('./reader.js');
|
|
34
|
+
const hash = (bytes) => (0, import_node_crypto.createHash)("sha256").update(bytes).digest("hex");
|
|
35
|
+
const scopeFor = (binding) => ({
|
|
36
|
+
account_id: binding.account_id,
|
|
37
|
+
destination_ref: binding.destination_ref,
|
|
38
|
+
generation: binding.authorization_generation
|
|
39
|
+
});
|
|
40
|
+
function deliveryIdentity(input) {
|
|
41
|
+
return hash(
|
|
42
|
+
(0, import_jcs.canonicalize)([
|
|
43
|
+
input.binding.configurationId,
|
|
44
|
+
input.binding.delivery_config_id,
|
|
45
|
+
input.binding.delivery_config_version,
|
|
46
|
+
input.materialization.reporting_materialization_id,
|
|
47
|
+
input.materialization.reporting_revision_id,
|
|
48
|
+
input.materialization.reporting_obligation_id
|
|
49
|
+
])
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
function matchingBinding(input) {
|
|
53
|
+
const { materialization: m, binding: b } = input;
|
|
54
|
+
if (b.method !== "file_transfer" || b.transport !== "gcs" || m.method !== b.method || m.transport !== b.transport || m.destination_ref !== b.destination_ref || m.delivery_config_id !== b.delivery_config_id || m.delivery_config_version !== b.delivery_config_version || m.feed_purpose !== b.feed_purpose || !["manifest_checksums", "canonical_digest"].includes(b.verification_profile) || !Number.isSafeInteger(b.resource_retention_days) || b.resource_retention_days < 1 || b.resource_retention_days > 3650)
|
|
55
|
+
throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
|
|
56
|
+
}
|
|
57
|
+
async function createGcsReportingManagedDeliveryAdapterV1(options, context = {}) {
|
|
58
|
+
const milliseconds = options.operationDeadlineMilliseconds ?? 6e4;
|
|
59
|
+
const { resolveExpectedPeriod, resolveContractReader, namespace: hostNamespace } = options;
|
|
60
|
+
const minimumDays = options.minimumResourceRetentionDays ?? 1;
|
|
61
|
+
if (options.acknowledgeDedicatedFreshBucket !== true || typeof hostNamespace !== "string" || hostNamespace.length < 1 || hostNamespace.length > 255 || !Number.isSafeInteger(minimumDays) || minimumDays < 1 || minimumDays > 3650 || typeof options.resolveExpectedPeriod !== "function" || typeof options.resolveContractReader !== "function")
|
|
62
|
+
throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
|
|
63
|
+
const { storage, coreStore, store, bucket } = options;
|
|
64
|
+
const { id, fence } = await (0, import_io.withGcsDeadline)(
|
|
65
|
+
async (signal) => {
|
|
66
|
+
if (await store.probeObjectWriteAuthority({ signal }) !== true)
|
|
67
|
+
throw new import_errors.ReportingGcsFenceError("STATE_UNAVAILABLE");
|
|
68
|
+
(0, import_io.activeGcsSignal)(signal);
|
|
69
|
+
if (await store.probe(coreStore) !== true) throw new import_errors.ReportingGcsFenceError("STATE_UNAVAILABLE");
|
|
70
|
+
(0, import_io.activeGcsSignal)(signal);
|
|
71
|
+
const id2 = await store.getObjectWriteAuthorityId({ signal });
|
|
72
|
+
(0, import_io.activeGcsSignal)(signal);
|
|
73
|
+
const fence2 = (0, import_fence.createGcsReportingObjectFenceV1)({
|
|
74
|
+
storage,
|
|
75
|
+
store,
|
|
76
|
+
bucket,
|
|
77
|
+
namespace: hash((0, import_jcs.canonicalize)([hostNamespace, id2])),
|
|
78
|
+
operationDeadlineMilliseconds: milliseconds
|
|
79
|
+
});
|
|
80
|
+
await fence2.probe({ signal });
|
|
81
|
+
(0, import_io.activeGcsSignal)(signal);
|
|
82
|
+
return { id: id2, fence: fence2 };
|
|
83
|
+
},
|
|
84
|
+
{ signal: context.signal, milliseconds }
|
|
85
|
+
);
|
|
86
|
+
const getStatus = (0, import_handler.createReportingStatusHandler)(coreStore);
|
|
87
|
+
async function readerOptions(binding, signal) {
|
|
88
|
+
const scope = scopeFor(binding);
|
|
89
|
+
const provider = await store.getAuthorizedObjectWriteBinding(scope, { signal });
|
|
90
|
+
(0, import_io.activeGcsSignal)(signal);
|
|
91
|
+
if (!provider) throw new import_errors.ReportingGcsFenceError("REVOKED");
|
|
92
|
+
const prefix = `adcp-reporting/${provider.namespace_key}/${(0, import_object_writes.reportingObjectWriteScopeKey)(scope)}/`;
|
|
93
|
+
return {
|
|
94
|
+
scope: { ...scope, principal_id: `producer:${id}` },
|
|
95
|
+
bucket: provider.bucket,
|
|
96
|
+
objectPrefix: prefix,
|
|
97
|
+
getStorage: async () => storage,
|
|
98
|
+
authorize: async (request, call) => {
|
|
99
|
+
if (request.bucket !== provider.bucket || request.objectPrefix !== prefix || request.scope.principal_id !== `producer:${id}` || request.scope.account_id !== scope.account_id || request.scope.destination_ref !== scope.destination_ref || request.scope.generation !== scope.generation)
|
|
100
|
+
return false;
|
|
101
|
+
const current = await store.getAuthorizedObjectWriteBinding(scope, { signal: call.signal });
|
|
102
|
+
return current?.bucket === provider.bucket && current.namespace_key === provider.namespace_key;
|
|
103
|
+
},
|
|
104
|
+
operationDeadlineMilliseconds: milliseconds
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
async function trueObligation(input, signal) {
|
|
108
|
+
let cursor;
|
|
109
|
+
for (let page = 0; page < 25; page++) {
|
|
110
|
+
(0, import_io.activeGcsSignal)(signal);
|
|
111
|
+
const status = await getStatus(
|
|
112
|
+
{
|
|
113
|
+
account: { account_id: input.binding.account_id },
|
|
114
|
+
view: "periods",
|
|
115
|
+
delivery_config_ids: [input.binding.delivery_config_id],
|
|
116
|
+
period: input.revision.wireRevision.period,
|
|
117
|
+
pagination: { max_results: 100, ...cursor ? { cursor } : {} }
|
|
118
|
+
},
|
|
119
|
+
{ account: { id: input.binding.account_id, account_id: input.binding.account_id }, signal }
|
|
120
|
+
);
|
|
121
|
+
(0, import_io.activeGcsSignal)(signal);
|
|
122
|
+
const selected = status.periods?.find(
|
|
123
|
+
(value) => value.reporting_obligation_id === input.obligation.reporting_obligation_id
|
|
124
|
+
);
|
|
125
|
+
if (selected) return selected;
|
|
126
|
+
cursor = status.pagination?.cursor;
|
|
127
|
+
if (!cursor) break;
|
|
128
|
+
}
|
|
129
|
+
throw new import_errors.ReportingGcsFenceError("STATE_UNAVAILABLE");
|
|
130
|
+
}
|
|
131
|
+
async function hostCallback(work, signal) {
|
|
132
|
+
try {
|
|
133
|
+
const result = await work();
|
|
134
|
+
(0, import_io.activeGcsSignal)(signal);
|
|
135
|
+
return result;
|
|
136
|
+
} catch {
|
|
137
|
+
(0, import_io.activeGcsSignal)(signal);
|
|
138
|
+
throw new import_errors.ReportingGcsFenceError("HOST_CALLBACK_FAILED");
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
verificationProfiles: Object.freeze(["manifest_checksums", "canonical_digest"]),
|
|
143
|
+
revocationFencesDeliveryGenerations: true,
|
|
144
|
+
async deliver(caller, call) {
|
|
145
|
+
return (0, import_io.withGcsDeadline)(
|
|
146
|
+
async (signal) => {
|
|
147
|
+
matchingBinding(caller);
|
|
148
|
+
if (!Number.isSafeInteger(caller.maxBytes) || caller.maxBytes < 1 || caller.maxBytes > 64 * 1024 * 1024 || caller.revision.binding.byteCount > caller.maxBytes || caller.revision.rows.length > 1e5)
|
|
149
|
+
throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
|
|
150
|
+
const input = structuredClone(caller);
|
|
151
|
+
matchingBinding(input);
|
|
152
|
+
if (input.revision.rows.length > 1e5 || input.revision.binding.byteCount > input.maxBytes || !Number.isSafeInteger(input.maxBytes) || input.maxBytes < 1 || input.maxBytes > 64 * 1024 * 1024)
|
|
153
|
+
throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
|
|
154
|
+
const { revision, binding, materialization, obligation } = input;
|
|
155
|
+
if (revision.reporting_revision_id !== materialization.reporting_revision_id || revision.reporting_obligation_id !== obligation.reporting_obligation_id || materialization.reporting_obligation_id !== obligation.reporting_obligation_id || obligation.account.account_id !== binding.account_id || obligation.configurationId !== binding.configurationId || obligation.delivery_config_id !== binding.delivery_config_id || obligation.delivery_config_version !== binding.delivery_config_version)
|
|
156
|
+
throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
|
|
157
|
+
const coreBytes = Buffer.from(
|
|
158
|
+
(0, import_jcs.canonicalize)({
|
|
159
|
+
reporting_revision_id: revision.reporting_revision_id,
|
|
160
|
+
row_count: revision.wireRevision.row_count,
|
|
161
|
+
control_totals: revision.wireRevision.control_totals,
|
|
162
|
+
reporting_rows: revision.rows
|
|
163
|
+
})
|
|
164
|
+
);
|
|
165
|
+
if (revision.binding.algorithm !== "rfc8785_jcs_v1" || coreBytes.length !== revision.binding.byteCount || hash(coreBytes) !== revision.binding.sha256 || revision.wireRevision.revision_content_sha256 !== revision.binding.sha256 || revision.binding.rowCount !== revision.rows.length || revision.wireRevision.row_count !== revision.rows.length)
|
|
166
|
+
throw new import_errors.ReportingGcsFenceError("CONTENT_CONFLICT");
|
|
167
|
+
const expected = await hostCallback(async () => {
|
|
168
|
+
const value = structuredClone(await resolveExpectedPeriod(structuredClone(input), { signal }));
|
|
169
|
+
if (!value || typeof value !== "object" || !Array.isArray(value.mediaBuyIds) || !value.coverage || typeof value.coverage !== "object" || Array.isArray(value.coverage) || value.verificationProfile === "canonical_digest" && (!value.canonicalization || typeof value.canonicalization !== "object"))
|
|
170
|
+
throw new import_errors.ReportingGcsFenceError("HOST_CALLBACK_FAILED");
|
|
171
|
+
return value;
|
|
172
|
+
}, signal);
|
|
173
|
+
(0, import_io.activeGcsSignal)(signal);
|
|
174
|
+
(0, import_validation.assertExpectedBinding)(input, expected);
|
|
175
|
+
const actualObligation = await trueObligation(input, signal);
|
|
176
|
+
const contractOptions = await hostCallback(
|
|
177
|
+
() => resolveContractReader(structuredClone(input), { signal }),
|
|
178
|
+
signal
|
|
179
|
+
);
|
|
180
|
+
(0, import_io.activeGcsSignal)(signal);
|
|
181
|
+
if (!contractOptions || typeof contractOptions !== "object" || !contractOptions.scope)
|
|
182
|
+
throw new import_errors.ReportingGcsFenceError("HOST_CALLBACK_FAILED");
|
|
183
|
+
let contractResolver;
|
|
184
|
+
try {
|
|
185
|
+
contractResolver = (0, import_reader.createGcsReportingReferenceResolverV1)({
|
|
186
|
+
...contractOptions,
|
|
187
|
+
signal: contractOptions.signal ? AbortSignal.any([signal, contractOptions.signal]) : signal
|
|
188
|
+
});
|
|
189
|
+
} catch {
|
|
190
|
+
throw new import_errors.ReportingGcsFenceError("HOST_CALLBACK_FAILED");
|
|
191
|
+
}
|
|
192
|
+
if (contractOptions.scope.account_id !== binding.account_id || contractOptions.scope.destination_ref !== binding.destination_ref || contractOptions.scope.generation !== binding.authorization_generation)
|
|
193
|
+
throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
|
|
194
|
+
const rows = Buffer.from(revision.rows.map((row) => (0, import_jcs.canonicalize)(row) + "\n").join(""));
|
|
195
|
+
const manifestBytes = Buffer.from(
|
|
196
|
+
(0, import_jcs.canonicalize)({
|
|
197
|
+
manifest_version: "1.0",
|
|
198
|
+
complete: true,
|
|
199
|
+
reporting_revision_id: revision.reporting_revision_id,
|
|
200
|
+
reporting_obligation_id: obligation.reporting_obligation_id,
|
|
201
|
+
reporting_materialization_id: materialization.reporting_materialization_id,
|
|
202
|
+
period: revision.wireRevision.period,
|
|
203
|
+
format: "jsonl",
|
|
204
|
+
compression: "none",
|
|
205
|
+
files: [
|
|
206
|
+
{ object_ref: "0", size_bytes: rows.length, sha256: hash(rows), row_count: revision.rows.length }
|
|
207
|
+
],
|
|
208
|
+
total_size_bytes: rows.length,
|
|
209
|
+
row_count: revision.rows.length,
|
|
210
|
+
control_totals: revision.wireRevision.control_totals,
|
|
211
|
+
created_at: revision.createdAt
|
|
212
|
+
})
|
|
213
|
+
);
|
|
214
|
+
if (rows.length + manifestBytes.length > input.maxBytes) throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
|
|
215
|
+
const scope = scopeFor(binding);
|
|
216
|
+
const plan = await fence.register(scope, deliveryIdentity(input), [rows, manifestBytes], { signal });
|
|
217
|
+
(0, import_io.activeGcsSignal)(signal);
|
|
218
|
+
await fence.write(plan, 0, rows, { signal });
|
|
219
|
+
await fence.write(plan, 1, manifestBytes, { signal });
|
|
220
|
+
(0, import_io.activeGcsSignal)(signal);
|
|
221
|
+
const readerConfig = await readerOptions(binding, signal);
|
|
222
|
+
const location = `https://storage.googleapis.com/${plan.provider.bucket}/${plan.objects[1].object_name}`;
|
|
223
|
+
const read = await (0, import_reader.createGcsScopedObjectReadV1)(readerConfig)(location, input.maxBytes, signal);
|
|
224
|
+
(0, import_io.activeGcsSignal)(signal);
|
|
225
|
+
if (hash(read.body) !== hash(manifestBytes)) throw new import_errors.ReportingGcsFenceError("CONTENT_CONFLICT");
|
|
226
|
+
const resource = {
|
|
227
|
+
resource_ref: `gcs:${plan.plan_id}`,
|
|
228
|
+
kind: "manifest",
|
|
229
|
+
location,
|
|
230
|
+
manifest_version: "1.0",
|
|
231
|
+
manifest_sha256: hash(read.body),
|
|
232
|
+
immutability: "native_version",
|
|
233
|
+
native_version_ref: read.generation,
|
|
234
|
+
expires_at: new Date(
|
|
235
|
+
Date.now() + Math.max(minimumDays, binding.resource_retention_days) * 864e5
|
|
236
|
+
).toISOString(),
|
|
237
|
+
reader_compatibility: ["jsonl", "utf-8"]
|
|
238
|
+
};
|
|
239
|
+
const inspectionContext = {
|
|
240
|
+
obligation: actualObligation,
|
|
241
|
+
revision: revision.wireRevision,
|
|
242
|
+
materialization: { ...materialization, resource },
|
|
243
|
+
expected
|
|
244
|
+
};
|
|
245
|
+
const reader = (0, import_reader.createGcsReportingResourceReaderV1)(readerConfig);
|
|
246
|
+
const observedChecksums = /* @__PURE__ */ new Map();
|
|
247
|
+
const inspect = (0, import_inspection.createReportingManifestInspector)({
|
|
248
|
+
reader: {
|
|
249
|
+
async read(request) {
|
|
250
|
+
const result = await reader.read({
|
|
251
|
+
...request,
|
|
252
|
+
signal: request.signal ? AbortSignal.any([signal, request.signal]) : signal
|
|
253
|
+
});
|
|
254
|
+
(0, import_io.activeGcsSignal)(signal);
|
|
255
|
+
if (request.role === "object")
|
|
256
|
+
observedChecksums.set(request.objectRef, {
|
|
257
|
+
object_ref: request.objectRef,
|
|
258
|
+
algorithm: "sha256",
|
|
259
|
+
value: hash(result.body)
|
|
260
|
+
});
|
|
261
|
+
return result;
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
referenceResolver: contractResolver,
|
|
265
|
+
referenceAllowedOrigins: ["https://storage.googleapis.com"],
|
|
266
|
+
maxTotalBytes: input.maxBytes,
|
|
267
|
+
maxObjectBytes: input.maxBytes,
|
|
268
|
+
maxRows: 1e5
|
|
269
|
+
});
|
|
270
|
+
const observation = await inspect(inspectionContext);
|
|
271
|
+
(0, import_io.activeGcsSignal)(signal);
|
|
272
|
+
if (!observedChecksums.size) throw new import_errors.ReportingGcsFenceError("CONTENT_CONFLICT");
|
|
273
|
+
resource.expires_at = new Date(
|
|
274
|
+
Date.now() + Math.max(minimumDays, binding.resource_retention_days) * 864e5 + milliseconds
|
|
275
|
+
).toISOString();
|
|
276
|
+
const checksums = [...observedChecksums.values()];
|
|
277
|
+
if (checksums.length !== 1 || checksums[0].object_ref !== "0" || checksums[0].value !== plan.objects[0].sha256)
|
|
278
|
+
throw new import_errors.ReportingGcsFenceError("CONTENT_CONFLICT");
|
|
279
|
+
const verification = {
|
|
280
|
+
verified_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
281
|
+
verification_path: "producer",
|
|
282
|
+
verification_profile: binding.verification_profile,
|
|
283
|
+
row_count: observation.rowCount,
|
|
284
|
+
control_totals: observation.controlTotals,
|
|
285
|
+
physical_checksums: [checksums[0], ...checksums.slice(1)],
|
|
286
|
+
...observation.canonicalContentDigest ? { canonical_content_digest: observation.canonicalContentDigest } : {}
|
|
287
|
+
};
|
|
288
|
+
if (!await store.getAuthorizedObjectWriteBinding(scope, { signal }))
|
|
289
|
+
throw new import_errors.ReportingGcsFenceError("REVOKED");
|
|
290
|
+
(0, import_io.activeGcsSignal)(signal);
|
|
291
|
+
return { status: "available", resource, verification };
|
|
292
|
+
},
|
|
293
|
+
{ signal: call.signal, milliseconds }
|
|
294
|
+
);
|
|
295
|
+
},
|
|
296
|
+
async read(caller, call) {
|
|
297
|
+
return (0, import_io.withGcsDeadline)(
|
|
298
|
+
async (signal) => {
|
|
299
|
+
const input = structuredClone(caller);
|
|
300
|
+
matchingBinding(input);
|
|
301
|
+
const planId = hash(deliveryIdentity(input));
|
|
302
|
+
const scope = scopeFor(input.binding);
|
|
303
|
+
const plan = await store.getObjectWritePlan(scope, planId, { signal });
|
|
304
|
+
(0, import_io.activeGcsSignal)(signal);
|
|
305
|
+
if (!plan) throw new import_errors.ReportingGcsFenceError("REVOKED");
|
|
306
|
+
const location = `https://storage.googleapis.com/${plan.provider.bucket}/${(0, import_object_writes.reportingObjectWriteName)(scope, plan.provider, planId, 1)}`;
|
|
307
|
+
if (plan.objects.length !== 2 || input.resource.resource_ref !== `gcs:${planId}` || input.resource.location !== location || input.resource.kind !== "manifest" || input.resource.immutability !== "native_version" || !input.resource.native_version_ref || !Number.isFinite(Date.parse(input.resource.expires_at ?? "")) || input.resource.manifest_sha256 !== plan.objects[1]?.sha256)
|
|
308
|
+
throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
|
|
309
|
+
const config = await readerOptions(input.binding, signal);
|
|
310
|
+
const result = await (0, import_reader.createGcsScopedObjectReadV1)(config)(
|
|
311
|
+
location,
|
|
312
|
+
input.maxBytes,
|
|
313
|
+
signal,
|
|
314
|
+
input.resource.native_version_ref
|
|
315
|
+
);
|
|
316
|
+
if (hash(result.body) !== input.resource.manifest_sha256)
|
|
317
|
+
throw new import_errors.ReportingGcsFenceError("CONTENT_CONFLICT");
|
|
318
|
+
return result.body;
|
|
319
|
+
},
|
|
320
|
+
{ signal: call.signal, milliseconds }
|
|
321
|
+
);
|
|
322
|
+
},
|
|
323
|
+
async revoke(input, call) {
|
|
324
|
+
await (0, import_io.withGcsDeadline)(
|
|
325
|
+
async (signal) => {
|
|
326
|
+
for (let page = 0; page < 1e3; page++) {
|
|
327
|
+
(0, import_io.activeGcsSignal)(signal);
|
|
328
|
+
const result = await fence.revoke(input.authorization, { signal });
|
|
329
|
+
if (result.complete) return;
|
|
330
|
+
if (result.fenced < 1) throw new import_errors.ReportingGcsFenceError("STATE_UNAVAILABLE");
|
|
331
|
+
}
|
|
332
|
+
throw new import_errors.ReportingGcsFenceError("STATE_UNAVAILABLE");
|
|
333
|
+
},
|
|
334
|
+
{ signal: call.signal, milliseconds }
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
340
|
+
0 && (module.exports = {
|
|
341
|
+
createGcsReportingManagedDeliveryAdapterV1
|
|
342
|
+
});
|