@adcp/sdk 16.0.0-beta.3 → 16.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/dist/lib/auth/oauth/diagnose.js +3 -11
  2. package/dist/lib/auth/oauth/diagnose.mjs +4 -12
  3. package/dist/lib/auth/oauth/diagnostics.d.mts +2 -1
  4. package/dist/lib/auth/oauth/diagnostics.d.ts +2 -1
  5. package/dist/lib/auth/oauth/diagnostics.js +8 -10
  6. package/dist/lib/auth/oauth/diagnostics.mjs +7 -10
  7. package/dist/lib/index.d.mts +1 -1
  8. package/dist/lib/index.d.ts +1 -1
  9. package/dist/lib/index.js +2 -0
  10. package/dist/lib/index.mjs +7 -1
  11. package/dist/lib/reporting/consumer-runtime.js +2 -1
  12. package/dist/lib/reporting/consumer-runtime.mjs +2 -1
  13. package/dist/lib/reporting/ledger/handler.js +50 -11
  14. package/dist/lib/reporting/ledger/handler.mjs +50 -12
  15. package/dist/lib/reporting/ledger/index.d.mts +17 -14
  16. package/dist/lib/reporting/ledger/index.d.ts +17 -14
  17. package/dist/lib/reporting/ledger/index.js +32 -20
  18. package/dist/lib/reporting/ledger/index.mjs +21 -10
  19. package/dist/lib/reporting/ledger/offering-validation.d.mts +9 -0
  20. package/dist/lib/reporting/ledger/offering-validation.d.ts +9 -0
  21. package/dist/lib/reporting/{gcs/bucket-policy.js → ledger/offering-validation.js} +9 -8
  22. package/dist/lib/reporting/ledger/offering-validation.mjs +8 -0
  23. package/dist/lib/reporting/ledger/receipts.d.mts +48 -0
  24. package/dist/lib/reporting/ledger/receipts.d.ts +48 -0
  25. package/dist/lib/reporting/ledger/receipts.js +186 -0
  26. package/dist/lib/reporting/ledger/receipts.mjs +161 -0
  27. package/dist/lib/reporting/ledger/status-ingest.js +3 -3
  28. package/dist/lib/reporting/ledger/status-ingest.mjs +4 -5
  29. package/dist/lib/reporting/ledger/types.d.mts +43 -0
  30. package/dist/lib/reporting/ledger/types.d.ts +43 -0
  31. package/dist/lib/reporting/ledger/types.js +31 -2
  32. package/dist/lib/reporting/ledger/types.mjs +26 -1
  33. package/dist/lib/reporting/pagination.d.mts +6 -0
  34. package/dist/lib/reporting/pagination.d.ts +6 -0
  35. package/dist/lib/reporting/{gcs/errors.js → pagination.js} +12 -17
  36. package/dist/lib/reporting/pagination.mjs +12 -0
  37. package/dist/lib/reporting/reconciliation.d.mts +1 -0
  38. package/dist/lib/reporting/reconciliation.d.ts +1 -0
  39. package/dist/lib/reporting/reconciliation.js +3 -2
  40. package/dist/lib/reporting/reconciliation.mjs +3 -2
  41. package/dist/lib/reporting/service/index.d.mts +79 -153
  42. package/dist/lib/reporting/service/index.d.ts +79 -153
  43. package/dist/lib/reporting/service/index.js +34 -491
  44. package/dist/lib/reporting/service/index.mjs +36 -510
  45. package/dist/lib/reporting/service/scheduler-support.d.mts +43 -0
  46. package/dist/lib/reporting/service/scheduler-support.d.ts +43 -0
  47. package/dist/lib/reporting/service/scheduler-support.js +125 -0
  48. package/dist/lib/reporting/service/scheduler-support.mjs +96 -0
  49. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  50. package/dist/lib/signing/canonicalize.d.mts +4 -0
  51. package/dist/lib/signing/canonicalize.d.ts +4 -0
  52. package/dist/lib/signing/canonicalize.js +14 -8
  53. package/dist/lib/signing/canonicalize.mjs +14 -8
  54. package/dist/lib/signing/content-digest.d.mts +8 -0
  55. package/dist/lib/signing/content-digest.d.ts +8 -0
  56. package/dist/lib/signing/content-digest.js +11 -5
  57. package/dist/lib/signing/content-digest.mjs +10 -5
  58. package/dist/lib/signing/signer.js +9 -6
  59. package/dist/lib/signing/signer.mjs +10 -7
  60. package/dist/lib/signing/web-bot-auth.js +103 -37
  61. package/dist/lib/signing/web-bot-auth.mjs +108 -37
  62. package/dist/lib/testing/storyboard/junit.js +16 -3
  63. package/dist/lib/testing/storyboard/junit.mjs +16 -3
  64. package/dist/lib/testing/storyboard/request-signing/builder.js +10 -9
  65. package/dist/lib/testing/storyboard/request-signing/builder.mjs +10 -9
  66. package/dist/lib/testing/storyboard/runner.js +94 -25
  67. package/dist/lib/testing/storyboard/runner.mjs +94 -25
  68. package/dist/lib/testing/storyboard/types.d.mts +6 -0
  69. package/dist/lib/testing/storyboard/types.d.ts +6 -0
  70. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  71. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  72. package/dist/lib/types/schemas.generated.d.ts +907 -60
  73. package/dist/lib/types/schemas.generated.js +7 -7
  74. package/dist/lib/types/schemas.generated.mjs +7 -7
  75. package/dist/lib/version.d.mts +3 -3
  76. package/dist/lib/version.d.ts +3 -3
  77. package/dist/lib/version.js +3 -3
  78. package/dist/lib/version.mjs +3 -3
  79. package/docs/TYPE-SUMMARY.md +23 -5
  80. package/docs/guides/REPORTING-GCS-FENCE.md +3 -3
  81. package/docs/guides/REPORTING-GCS-MANAGED.md +4 -4
  82. package/docs/guides/REPORTING-LEDGER-CUTOVER.md +7 -7
  83. package/docs/guides/REPORTING-LEDGER.md +107 -51
  84. package/docs/guides/REPORTING-OPERATIONS.md +66 -5
  85. package/docs/guides/REPORTING-STABILITY.md +36 -32
  86. package/docs/llms.txt +4 -3
  87. package/docs/migration-14.x-rc-worksheet.md +4 -7
  88. package/docs/migration-reporting-storage-package.md +186 -0
  89. package/examples/README.md +1 -1
  90. package/package.json +13 -78
  91. package/dist/lib/reporting/azure/index.d.mts +0 -31
  92. package/dist/lib/reporting/azure/index.d.ts +0 -31
  93. package/dist/lib/reporting/azure/index.js +0 -266
  94. package/dist/lib/reporting/azure/index.mjs +0 -249
  95. package/dist/lib/reporting/bigquery/index.d.mts +0 -246
  96. package/dist/lib/reporting/bigquery/index.d.ts +0 -246
  97. package/dist/lib/reporting/bigquery/index.js +0 -633
  98. package/dist/lib/reporting/bigquery/index.mjs +0 -594
  99. package/dist/lib/reporting/gcs/adapter.d.mts +0 -38
  100. package/dist/lib/reporting/gcs/adapter.d.ts +0 -38
  101. package/dist/lib/reporting/gcs/adapter.js +0 -342
  102. package/dist/lib/reporting/gcs/adapter.mjs +0 -325
  103. package/dist/lib/reporting/gcs/bucket-policy.d.mts +0 -3
  104. package/dist/lib/reporting/gcs/bucket-policy.d.ts +0 -3
  105. package/dist/lib/reporting/gcs/bucket-policy.mjs +0 -7
  106. package/dist/lib/reporting/gcs/errors.d.mts +0 -11
  107. package/dist/lib/reporting/gcs/errors.d.ts +0 -11
  108. package/dist/lib/reporting/gcs/errors.mjs +0 -16
  109. package/dist/lib/reporting/gcs/fence.d.mts +0 -41
  110. package/dist/lib/reporting/gcs/fence.d.ts +0 -41
  111. package/dist/lib/reporting/gcs/fence.js +0 -250
  112. package/dist/lib/reporting/gcs/fence.mjs +0 -230
  113. package/dist/lib/reporting/gcs/index.d.mts +0 -18
  114. package/dist/lib/reporting/gcs/index.d.ts +0 -18
  115. package/dist/lib/reporting/gcs/index.js +0 -44
  116. package/dist/lib/reporting/gcs/index.mjs +0 -14
  117. package/dist/lib/reporting/gcs/io.d.mts +0 -7
  118. package/dist/lib/reporting/gcs/io.d.ts +0 -7
  119. package/dist/lib/reporting/gcs/io.js +0 -95
  120. package/dist/lib/reporting/gcs/io.mjs +0 -69
  121. package/dist/lib/reporting/gcs/reader.d.mts +0 -67
  122. package/dist/lib/reporting/gcs/reader.d.ts +0 -67
  123. package/dist/lib/reporting/gcs/reader.js +0 -193
  124. package/dist/lib/reporting/gcs/reader.mjs +0 -169
  125. package/dist/lib/reporting/gcs/row-provider.d.mts +0 -39
  126. package/dist/lib/reporting/gcs/row-provider.d.ts +0 -39
  127. package/dist/lib/reporting/gcs/row-provider.js +0 -225
  128. package/dist/lib/reporting/gcs/row-provider.mjs +0 -208
  129. package/dist/lib/reporting/gcs/validation.d.mts +0 -5
  130. package/dist/lib/reporting/gcs/validation.d.ts +0 -5
  131. package/dist/lib/reporting/gcs/validation.js +0 -49
  132. package/dist/lib/reporting/gcs/validation.mjs +0 -25
  133. package/dist/lib/reporting/ledger/change-feed.d.mts +0 -69
  134. package/dist/lib/reporting/ledger/change-feed.d.ts +0 -69
  135. package/dist/lib/reporting/ledger/change-feed.js +0 -107
  136. package/dist/lib/reporting/ledger/change-feed.mjs +0 -80
  137. package/dist/lib/reporting/ledger/managed-postgres.d.mts +0 -293
  138. package/dist/lib/reporting/ledger/managed-postgres.d.ts +0 -293
  139. package/dist/lib/reporting/ledger/managed-postgres.js +0 -2346
  140. package/dist/lib/reporting/ledger/managed-postgres.mjs +0 -2332
  141. package/dist/lib/reporting/ledger/managed-router.d.mts +0 -148
  142. package/dist/lib/reporting/ledger/managed-router.d.ts +0 -148
  143. package/dist/lib/reporting/ledger/managed-router.js +0 -280
  144. package/dist/lib/reporting/ledger/managed-router.mjs +0 -258
  145. package/dist/lib/reporting/ledger/managed.d.mts +0 -535
  146. package/dist/lib/reporting/ledger/managed.d.ts +0 -535
  147. package/dist/lib/reporting/ledger/managed.js +0 -761
  148. package/dist/lib/reporting/ledger/managed.mjs +0 -729
  149. package/dist/lib/reporting/ledger/notification-activity.d.mts +0 -332
  150. package/dist/lib/reporting/ledger/notification-activity.d.ts +0 -332
  151. package/dist/lib/reporting/ledger/notification-activity.js +0 -1366
  152. package/dist/lib/reporting/ledger/notification-activity.mjs +0 -1337
  153. package/dist/lib/reporting/ledger/object-writes.d.mts +0 -128
  154. package/dist/lib/reporting/ledger/object-writes.d.ts +0 -128
  155. package/dist/lib/reporting/ledger/object-writes.js +0 -147
  156. package/dist/lib/reporting/ledger/object-writes.mjs +0 -114
  157. package/dist/lib/reporting/ledger/postgres.d.mts +0 -689
  158. package/dist/lib/reporting/ledger/postgres.d.ts +0 -689
  159. package/dist/lib/reporting/ledger/postgres.js +0 -4462
  160. package/dist/lib/reporting/ledger/postgres.mjs +0 -4462
  161. package/dist/lib/reporting/ledger/row-storage-migration.d.mts +0 -59
  162. package/dist/lib/reporting/ledger/row-storage-migration.d.ts +0 -59
  163. package/dist/lib/reporting/ledger/row-storage-migration.js +0 -365
  164. package/dist/lib/reporting/ledger/row-storage-migration.mjs +0 -339
  165. package/dist/lib/reporting/ledger/row-storage-object.d.mts +0 -203
  166. package/dist/lib/reporting/ledger/row-storage-object.d.ts +0 -203
  167. package/dist/lib/reporting/ledger/row-storage-object.js +0 -379
  168. package/dist/lib/reporting/ledger/row-storage-object.mjs +0 -335
  169. package/dist/lib/reporting/ledger/row-storage-provider-io.d.mts +0 -44
  170. package/dist/lib/reporting/ledger/row-storage-provider-io.d.ts +0 -44
  171. package/dist/lib/reporting/ledger/row-storage-provider-io.js +0 -142
  172. package/dist/lib/reporting/ledger/row-storage-provider-io.mjs +0 -111
  173. package/dist/lib/reporting/ledger/row-storage.d.mts +0 -316
  174. package/dist/lib/reporting/ledger/row-storage.d.ts +0 -316
  175. package/dist/lib/reporting/ledger/row-storage.js +0 -812
  176. package/dist/lib/reporting/ledger/row-storage.mjs +0 -802
  177. package/dist/lib/reporting/s3/index.d.mts +0 -34
  178. package/dist/lib/reporting/s3/index.d.ts +0 -34
  179. package/dist/lib/reporting/s3/index.js +0 -347
  180. package/dist/lib/reporting/s3/index.mjs +0 -340
  181. package/dist/lib/reporting/service/maintenance.d.mts +0 -148
  182. package/dist/lib/reporting/service/maintenance.d.ts +0 -148
  183. package/dist/lib/reporting/service/maintenance.js +0 -185
  184. package/dist/lib/reporting/service/maintenance.mjs +0 -159
  185. package/examples/reliable-reporting-service/README.md +0 -169
@@ -1,342 +0,0 @@
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
- });
@@ -1,325 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { canonicalize } from "../../utils/jcs.mjs";
3
- import { createReportingManifestInspector } from "../inspection.mjs";
4
- import { createReportingStatusHandler } from "../ledger/handler.mjs";
5
- import {
6
- reportingObjectWriteName,
7
- reportingObjectWriteScopeKey
8
- } from "../ledger/object-writes.mjs";
9
- import { createGcsReportingObjectFenceV1 } from "./fence.mjs";
10
- import { ReportingGcsFenceError } from "./errors.mjs";
11
- import { activeGcsSignal, withGcsDeadline } from "./io.mjs";
12
- import { assertExpectedBinding } from "./validation.mjs";
13
- import {
14
- createGcsReportingResourceReaderV1,
15
- createGcsReportingReferenceResolverV1,
16
- createGcsScopedObjectReadV1
17
- } from "./reader.mjs";
18
- const hash = (bytes) => createHash("sha256").update(bytes).digest("hex");
19
- const scopeFor = (binding) => ({
20
- account_id: binding.account_id,
21
- destination_ref: binding.destination_ref,
22
- generation: binding.authorization_generation
23
- });
24
- function deliveryIdentity(input) {
25
- return hash(
26
- canonicalize([
27
- input.binding.configurationId,
28
- input.binding.delivery_config_id,
29
- input.binding.delivery_config_version,
30
- input.materialization.reporting_materialization_id,
31
- input.materialization.reporting_revision_id,
32
- input.materialization.reporting_obligation_id
33
- ])
34
- );
35
- }
36
- function matchingBinding(input) {
37
- const { materialization: m, binding: b } = input;
38
- 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)
39
- throw new ReportingGcsFenceError("INVALID_INPUT");
40
- }
41
- async function createGcsReportingManagedDeliveryAdapterV1(options, context = {}) {
42
- const milliseconds = options.operationDeadlineMilliseconds ?? 6e4;
43
- const { resolveExpectedPeriod, resolveContractReader, namespace: hostNamespace } = options;
44
- const minimumDays = options.minimumResourceRetentionDays ?? 1;
45
- 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")
46
- throw new ReportingGcsFenceError("INVALID_INPUT");
47
- const { storage, coreStore, store, bucket } = options;
48
- const { id, fence } = await withGcsDeadline(
49
- async (signal) => {
50
- if (await store.probeObjectWriteAuthority({ signal }) !== true)
51
- throw new ReportingGcsFenceError("STATE_UNAVAILABLE");
52
- activeGcsSignal(signal);
53
- if (await store.probe(coreStore) !== true) throw new ReportingGcsFenceError("STATE_UNAVAILABLE");
54
- activeGcsSignal(signal);
55
- const id2 = await store.getObjectWriteAuthorityId({ signal });
56
- activeGcsSignal(signal);
57
- const fence2 = createGcsReportingObjectFenceV1({
58
- storage,
59
- store,
60
- bucket,
61
- namespace: hash(canonicalize([hostNamespace, id2])),
62
- operationDeadlineMilliseconds: milliseconds
63
- });
64
- await fence2.probe({ signal });
65
- activeGcsSignal(signal);
66
- return { id: id2, fence: fence2 };
67
- },
68
- { signal: context.signal, milliseconds }
69
- );
70
- const getStatus = createReportingStatusHandler(coreStore);
71
- async function readerOptions(binding, signal) {
72
- const scope = scopeFor(binding);
73
- const provider = await store.getAuthorizedObjectWriteBinding(scope, { signal });
74
- activeGcsSignal(signal);
75
- if (!provider) throw new ReportingGcsFenceError("REVOKED");
76
- const prefix = `adcp-reporting/${provider.namespace_key}/${reportingObjectWriteScopeKey(scope)}/`;
77
- return {
78
- scope: { ...scope, principal_id: `producer:${id}` },
79
- bucket: provider.bucket,
80
- objectPrefix: prefix,
81
- getStorage: async () => storage,
82
- authorize: async (request, call) => {
83
- 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)
84
- return false;
85
- const current = await store.getAuthorizedObjectWriteBinding(scope, { signal: call.signal });
86
- return current?.bucket === provider.bucket && current.namespace_key === provider.namespace_key;
87
- },
88
- operationDeadlineMilliseconds: milliseconds
89
- };
90
- }
91
- async function trueObligation(input, signal) {
92
- let cursor;
93
- for (let page = 0; page < 25; page++) {
94
- activeGcsSignal(signal);
95
- const status = await getStatus(
96
- {
97
- account: { account_id: input.binding.account_id },
98
- view: "periods",
99
- delivery_config_ids: [input.binding.delivery_config_id],
100
- period: input.revision.wireRevision.period,
101
- pagination: { max_results: 100, ...cursor ? { cursor } : {} }
102
- },
103
- { account: { id: input.binding.account_id, account_id: input.binding.account_id }, signal }
104
- );
105
- activeGcsSignal(signal);
106
- const selected = status.periods?.find(
107
- (value) => value.reporting_obligation_id === input.obligation.reporting_obligation_id
108
- );
109
- if (selected) return selected;
110
- cursor = status.pagination?.cursor;
111
- if (!cursor) break;
112
- }
113
- throw new ReportingGcsFenceError("STATE_UNAVAILABLE");
114
- }
115
- async function hostCallback(work, signal) {
116
- try {
117
- const result = await work();
118
- activeGcsSignal(signal);
119
- return result;
120
- } catch {
121
- activeGcsSignal(signal);
122
- throw new ReportingGcsFenceError("HOST_CALLBACK_FAILED");
123
- }
124
- }
125
- return {
126
- verificationProfiles: Object.freeze(["manifest_checksums", "canonical_digest"]),
127
- revocationFencesDeliveryGenerations: true,
128
- async deliver(caller, call) {
129
- return withGcsDeadline(
130
- async (signal) => {
131
- matchingBinding(caller);
132
- if (!Number.isSafeInteger(caller.maxBytes) || caller.maxBytes < 1 || caller.maxBytes > 64 * 1024 * 1024 || caller.revision.binding.byteCount > caller.maxBytes || caller.revision.rows.length > 1e5)
133
- throw new ReportingGcsFenceError("INVALID_INPUT");
134
- const input = structuredClone(caller);
135
- matchingBinding(input);
136
- if (input.revision.rows.length > 1e5 || input.revision.binding.byteCount > input.maxBytes || !Number.isSafeInteger(input.maxBytes) || input.maxBytes < 1 || input.maxBytes > 64 * 1024 * 1024)
137
- throw new ReportingGcsFenceError("INVALID_INPUT");
138
- const { revision, binding, materialization, obligation } = input;
139
- 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)
140
- throw new ReportingGcsFenceError("INVALID_INPUT");
141
- const coreBytes = Buffer.from(
142
- canonicalize({
143
- reporting_revision_id: revision.reporting_revision_id,
144
- row_count: revision.wireRevision.row_count,
145
- control_totals: revision.wireRevision.control_totals,
146
- reporting_rows: revision.rows
147
- })
148
- );
149
- 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)
150
- throw new ReportingGcsFenceError("CONTENT_CONFLICT");
151
- const expected = await hostCallback(async () => {
152
- const value = structuredClone(await resolveExpectedPeriod(structuredClone(input), { signal }));
153
- 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"))
154
- throw new ReportingGcsFenceError("HOST_CALLBACK_FAILED");
155
- return value;
156
- }, signal);
157
- activeGcsSignal(signal);
158
- assertExpectedBinding(input, expected);
159
- const actualObligation = await trueObligation(input, signal);
160
- const contractOptions = await hostCallback(
161
- () => resolveContractReader(structuredClone(input), { signal }),
162
- signal
163
- );
164
- activeGcsSignal(signal);
165
- if (!contractOptions || typeof contractOptions !== "object" || !contractOptions.scope)
166
- throw new ReportingGcsFenceError("HOST_CALLBACK_FAILED");
167
- let contractResolver;
168
- try {
169
- contractResolver = createGcsReportingReferenceResolverV1({
170
- ...contractOptions,
171
- signal: contractOptions.signal ? AbortSignal.any([signal, contractOptions.signal]) : signal
172
- });
173
- } catch {
174
- throw new ReportingGcsFenceError("HOST_CALLBACK_FAILED");
175
- }
176
- if (contractOptions.scope.account_id !== binding.account_id || contractOptions.scope.destination_ref !== binding.destination_ref || contractOptions.scope.generation !== binding.authorization_generation)
177
- throw new ReportingGcsFenceError("INVALID_INPUT");
178
- const rows = Buffer.from(revision.rows.map((row) => canonicalize(row) + "\n").join(""));
179
- const manifestBytes = Buffer.from(
180
- canonicalize({
181
- manifest_version: "1.0",
182
- complete: true,
183
- reporting_revision_id: revision.reporting_revision_id,
184
- reporting_obligation_id: obligation.reporting_obligation_id,
185
- reporting_materialization_id: materialization.reporting_materialization_id,
186
- period: revision.wireRevision.period,
187
- format: "jsonl",
188
- compression: "none",
189
- files: [
190
- { object_ref: "0", size_bytes: rows.length, sha256: hash(rows), row_count: revision.rows.length }
191
- ],
192
- total_size_bytes: rows.length,
193
- row_count: revision.rows.length,
194
- control_totals: revision.wireRevision.control_totals,
195
- created_at: revision.createdAt
196
- })
197
- );
198
- if (rows.length + manifestBytes.length > input.maxBytes) throw new ReportingGcsFenceError("INVALID_INPUT");
199
- const scope = scopeFor(binding);
200
- const plan = await fence.register(scope, deliveryIdentity(input), [rows, manifestBytes], { signal });
201
- activeGcsSignal(signal);
202
- await fence.write(plan, 0, rows, { signal });
203
- await fence.write(plan, 1, manifestBytes, { signal });
204
- activeGcsSignal(signal);
205
- const readerConfig = await readerOptions(binding, signal);
206
- const location = `https://storage.googleapis.com/${plan.provider.bucket}/${plan.objects[1].object_name}`;
207
- const read = await createGcsScopedObjectReadV1(readerConfig)(location, input.maxBytes, signal);
208
- activeGcsSignal(signal);
209
- if (hash(read.body) !== hash(manifestBytes)) throw new ReportingGcsFenceError("CONTENT_CONFLICT");
210
- const resource = {
211
- resource_ref: `gcs:${plan.plan_id}`,
212
- kind: "manifest",
213
- location,
214
- manifest_version: "1.0",
215
- manifest_sha256: hash(read.body),
216
- immutability: "native_version",
217
- native_version_ref: read.generation,
218
- expires_at: new Date(
219
- Date.now() + Math.max(minimumDays, binding.resource_retention_days) * 864e5
220
- ).toISOString(),
221
- reader_compatibility: ["jsonl", "utf-8"]
222
- };
223
- const inspectionContext = {
224
- obligation: actualObligation,
225
- revision: revision.wireRevision,
226
- materialization: { ...materialization, resource },
227
- expected
228
- };
229
- const reader = createGcsReportingResourceReaderV1(readerConfig);
230
- const observedChecksums = /* @__PURE__ */ new Map();
231
- const inspect = createReportingManifestInspector({
232
- reader: {
233
- async read(request) {
234
- const result = await reader.read({
235
- ...request,
236
- signal: request.signal ? AbortSignal.any([signal, request.signal]) : signal
237
- });
238
- activeGcsSignal(signal);
239
- if (request.role === "object")
240
- observedChecksums.set(request.objectRef, {
241
- object_ref: request.objectRef,
242
- algorithm: "sha256",
243
- value: hash(result.body)
244
- });
245
- return result;
246
- }
247
- },
248
- referenceResolver: contractResolver,
249
- referenceAllowedOrigins: ["https://storage.googleapis.com"],
250
- maxTotalBytes: input.maxBytes,
251
- maxObjectBytes: input.maxBytes,
252
- maxRows: 1e5
253
- });
254
- const observation = await inspect(inspectionContext);
255
- activeGcsSignal(signal);
256
- if (!observedChecksums.size) throw new ReportingGcsFenceError("CONTENT_CONFLICT");
257
- resource.expires_at = new Date(
258
- Date.now() + Math.max(minimumDays, binding.resource_retention_days) * 864e5 + milliseconds
259
- ).toISOString();
260
- const checksums = [...observedChecksums.values()];
261
- if (checksums.length !== 1 || checksums[0].object_ref !== "0" || checksums[0].value !== plan.objects[0].sha256)
262
- throw new ReportingGcsFenceError("CONTENT_CONFLICT");
263
- const verification = {
264
- verified_at: (/* @__PURE__ */ new Date()).toISOString(),
265
- verification_path: "producer",
266
- verification_profile: binding.verification_profile,
267
- row_count: observation.rowCount,
268
- control_totals: observation.controlTotals,
269
- physical_checksums: [checksums[0], ...checksums.slice(1)],
270
- ...observation.canonicalContentDigest ? { canonical_content_digest: observation.canonicalContentDigest } : {}
271
- };
272
- if (!await store.getAuthorizedObjectWriteBinding(scope, { signal }))
273
- throw new ReportingGcsFenceError("REVOKED");
274
- activeGcsSignal(signal);
275
- return { status: "available", resource, verification };
276
- },
277
- { signal: call.signal, milliseconds }
278
- );
279
- },
280
- async read(caller, call) {
281
- return withGcsDeadline(
282
- async (signal) => {
283
- const input = structuredClone(caller);
284
- matchingBinding(input);
285
- const planId = hash(deliveryIdentity(input));
286
- const scope = scopeFor(input.binding);
287
- const plan = await store.getObjectWritePlan(scope, planId, { signal });
288
- activeGcsSignal(signal);
289
- if (!plan) throw new ReportingGcsFenceError("REVOKED");
290
- const location = `https://storage.googleapis.com/${plan.provider.bucket}/${reportingObjectWriteName(scope, plan.provider, planId, 1)}`;
291
- 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)
292
- throw new ReportingGcsFenceError("INVALID_INPUT");
293
- const config = await readerOptions(input.binding, signal);
294
- const result = await createGcsScopedObjectReadV1(config)(
295
- location,
296
- input.maxBytes,
297
- signal,
298
- input.resource.native_version_ref
299
- );
300
- if (hash(result.body) !== input.resource.manifest_sha256)
301
- throw new ReportingGcsFenceError("CONTENT_CONFLICT");
302
- return result.body;
303
- },
304
- { signal: call.signal, milliseconds }
305
- );
306
- },
307
- async revoke(input, call) {
308
- await withGcsDeadline(
309
- async (signal) => {
310
- for (let page = 0; page < 1e3; page++) {
311
- activeGcsSignal(signal);
312
- const result = await fence.revoke(input.authorization, { signal });
313
- if (result.complete) return;
314
- if (result.fenced < 1) throw new ReportingGcsFenceError("STATE_UNAVAILABLE");
315
- }
316
- throw new ReportingGcsFenceError("STATE_UNAVAILABLE");
317
- },
318
- { signal: call.signal, milliseconds }
319
- );
320
- }
321
- };
322
- }
323
- export {
324
- createGcsReportingManagedDeliveryAdapterV1
325
- };
@@ -1,3 +0,0 @@
1
- import type { BucketMetadata } from '@google-cloud/storage';
2
- /** Pure policy guard shared by the real-provider probe and deterministic negative controls. */
3
- export declare function assertGcsReportingBucketPolicy(metadata: BucketMetadata): void;