@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.
- package/dist/lib/auth/oauth/diagnose.js +3 -11
- package/dist/lib/auth/oauth/diagnose.mjs +4 -12
- package/dist/lib/auth/oauth/diagnostics.d.mts +2 -1
- package/dist/lib/auth/oauth/diagnostics.d.ts +2 -1
- package/dist/lib/auth/oauth/diagnostics.js +8 -10
- package/dist/lib/auth/oauth/diagnostics.mjs +7 -10
- package/dist/lib/index.d.mts +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +2 -0
- package/dist/lib/index.mjs +7 -1
- package/dist/lib/reporting/consumer-runtime.js +2 -1
- package/dist/lib/reporting/consumer-runtime.mjs +2 -1
- package/dist/lib/reporting/ledger/handler.js +50 -11
- package/dist/lib/reporting/ledger/handler.mjs +50 -12
- package/dist/lib/reporting/ledger/index.d.mts +17 -14
- package/dist/lib/reporting/ledger/index.d.ts +17 -14
- package/dist/lib/reporting/ledger/index.js +32 -20
- package/dist/lib/reporting/ledger/index.mjs +21 -10
- package/dist/lib/reporting/ledger/offering-validation.d.mts +9 -0
- package/dist/lib/reporting/ledger/offering-validation.d.ts +9 -0
- package/dist/lib/reporting/{gcs/bucket-policy.js → ledger/offering-validation.js} +9 -8
- package/dist/lib/reporting/ledger/offering-validation.mjs +8 -0
- package/dist/lib/reporting/ledger/receipts.d.mts +48 -0
- package/dist/lib/reporting/ledger/receipts.d.ts +48 -0
- package/dist/lib/reporting/ledger/receipts.js +186 -0
- package/dist/lib/reporting/ledger/receipts.mjs +161 -0
- package/dist/lib/reporting/ledger/status-ingest.js +3 -3
- package/dist/lib/reporting/ledger/status-ingest.mjs +4 -5
- package/dist/lib/reporting/ledger/types.d.mts +43 -0
- package/dist/lib/reporting/ledger/types.d.ts +43 -0
- package/dist/lib/reporting/ledger/types.js +31 -2
- package/dist/lib/reporting/ledger/types.mjs +26 -1
- package/dist/lib/reporting/pagination.d.mts +6 -0
- package/dist/lib/reporting/pagination.d.ts +6 -0
- package/dist/lib/reporting/{gcs/errors.js → pagination.js} +12 -17
- package/dist/lib/reporting/pagination.mjs +12 -0
- package/dist/lib/reporting/reconciliation.d.mts +1 -0
- package/dist/lib/reporting/reconciliation.d.ts +1 -0
- package/dist/lib/reporting/reconciliation.js +3 -2
- package/dist/lib/reporting/reconciliation.mjs +3 -2
- package/dist/lib/reporting/service/index.d.mts +79 -153
- package/dist/lib/reporting/service/index.d.ts +79 -153
- package/dist/lib/reporting/service/index.js +34 -491
- package/dist/lib/reporting/service/index.mjs +36 -510
- package/dist/lib/reporting/service/scheduler-support.d.mts +43 -0
- package/dist/lib/reporting/service/scheduler-support.d.ts +43 -0
- package/dist/lib/reporting/service/scheduler-support.js +125 -0
- package/dist/lib/reporting/service/scheduler-support.mjs +96 -0
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/signing/canonicalize.d.mts +4 -0
- package/dist/lib/signing/canonicalize.d.ts +4 -0
- package/dist/lib/signing/canonicalize.js +14 -8
- package/dist/lib/signing/canonicalize.mjs +14 -8
- package/dist/lib/signing/content-digest.d.mts +8 -0
- package/dist/lib/signing/content-digest.d.ts +8 -0
- package/dist/lib/signing/content-digest.js +11 -5
- package/dist/lib/signing/content-digest.mjs +10 -5
- package/dist/lib/signing/signer.js +9 -6
- package/dist/lib/signing/signer.mjs +10 -7
- package/dist/lib/signing/web-bot-auth.js +103 -37
- package/dist/lib/signing/web-bot-auth.mjs +108 -37
- package/dist/lib/testing/storyboard/junit.js +16 -3
- package/dist/lib/testing/storyboard/junit.mjs +16 -3
- package/dist/lib/testing/storyboard/request-signing/builder.js +10 -9
- package/dist/lib/testing/storyboard/request-signing/builder.mjs +10 -9
- package/dist/lib/testing/storyboard/runner.js +94 -25
- package/dist/lib/testing/storyboard/runner.mjs +94 -25
- package/dist/lib/testing/storyboard/types.d.mts +6 -0
- package/dist/lib/testing/storyboard/types.d.ts +6 -0
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/types/schemas.generated.d.ts +907 -60
- package/dist/lib/types/schemas.generated.js +7 -7
- package/dist/lib/types/schemas.generated.mjs +7 -7
- 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 +23 -5
- package/docs/guides/REPORTING-GCS-FENCE.md +3 -3
- package/docs/guides/REPORTING-GCS-MANAGED.md +4 -4
- package/docs/guides/REPORTING-LEDGER-CUTOVER.md +7 -7
- package/docs/guides/REPORTING-LEDGER.md +107 -51
- package/docs/guides/REPORTING-OPERATIONS.md +66 -5
- package/docs/guides/REPORTING-STABILITY.md +36 -32
- package/docs/llms.txt +4 -3
- package/docs/migration-14.x-rc-worksheet.md +4 -7
- package/docs/migration-reporting-storage-package.md +186 -0
- package/examples/README.md +1 -1
- package/package.json +13 -78
- package/dist/lib/reporting/azure/index.d.mts +0 -31
- package/dist/lib/reporting/azure/index.d.ts +0 -31
- package/dist/lib/reporting/azure/index.js +0 -266
- package/dist/lib/reporting/azure/index.mjs +0 -249
- package/dist/lib/reporting/bigquery/index.d.mts +0 -246
- package/dist/lib/reporting/bigquery/index.d.ts +0 -246
- package/dist/lib/reporting/bigquery/index.js +0 -633
- package/dist/lib/reporting/bigquery/index.mjs +0 -594
- package/dist/lib/reporting/gcs/adapter.d.mts +0 -38
- package/dist/lib/reporting/gcs/adapter.d.ts +0 -38
- package/dist/lib/reporting/gcs/adapter.js +0 -342
- package/dist/lib/reporting/gcs/adapter.mjs +0 -325
- package/dist/lib/reporting/gcs/bucket-policy.d.mts +0 -3
- package/dist/lib/reporting/gcs/bucket-policy.d.ts +0 -3
- package/dist/lib/reporting/gcs/bucket-policy.mjs +0 -7
- package/dist/lib/reporting/gcs/errors.d.mts +0 -11
- package/dist/lib/reporting/gcs/errors.d.ts +0 -11
- package/dist/lib/reporting/gcs/errors.mjs +0 -16
- package/dist/lib/reporting/gcs/fence.d.mts +0 -41
- package/dist/lib/reporting/gcs/fence.d.ts +0 -41
- package/dist/lib/reporting/gcs/fence.js +0 -250
- package/dist/lib/reporting/gcs/fence.mjs +0 -230
- package/dist/lib/reporting/gcs/index.d.mts +0 -18
- package/dist/lib/reporting/gcs/index.d.ts +0 -18
- package/dist/lib/reporting/gcs/index.js +0 -44
- package/dist/lib/reporting/gcs/index.mjs +0 -14
- package/dist/lib/reporting/gcs/io.d.mts +0 -7
- package/dist/lib/reporting/gcs/io.d.ts +0 -7
- package/dist/lib/reporting/gcs/io.js +0 -95
- package/dist/lib/reporting/gcs/io.mjs +0 -69
- package/dist/lib/reporting/gcs/reader.d.mts +0 -67
- package/dist/lib/reporting/gcs/reader.d.ts +0 -67
- package/dist/lib/reporting/gcs/reader.js +0 -193
- package/dist/lib/reporting/gcs/reader.mjs +0 -169
- package/dist/lib/reporting/gcs/row-provider.d.mts +0 -39
- package/dist/lib/reporting/gcs/row-provider.d.ts +0 -39
- package/dist/lib/reporting/gcs/row-provider.js +0 -225
- package/dist/lib/reporting/gcs/row-provider.mjs +0 -208
- package/dist/lib/reporting/gcs/validation.d.mts +0 -5
- package/dist/lib/reporting/gcs/validation.d.ts +0 -5
- package/dist/lib/reporting/gcs/validation.js +0 -49
- package/dist/lib/reporting/gcs/validation.mjs +0 -25
- package/dist/lib/reporting/ledger/change-feed.d.mts +0 -69
- package/dist/lib/reporting/ledger/change-feed.d.ts +0 -69
- package/dist/lib/reporting/ledger/change-feed.js +0 -107
- package/dist/lib/reporting/ledger/change-feed.mjs +0 -80
- package/dist/lib/reporting/ledger/managed-postgres.d.mts +0 -293
- package/dist/lib/reporting/ledger/managed-postgres.d.ts +0 -293
- package/dist/lib/reporting/ledger/managed-postgres.js +0 -2346
- package/dist/lib/reporting/ledger/managed-postgres.mjs +0 -2332
- package/dist/lib/reporting/ledger/managed-router.d.mts +0 -148
- package/dist/lib/reporting/ledger/managed-router.d.ts +0 -148
- package/dist/lib/reporting/ledger/managed-router.js +0 -280
- package/dist/lib/reporting/ledger/managed-router.mjs +0 -258
- package/dist/lib/reporting/ledger/managed.d.mts +0 -535
- package/dist/lib/reporting/ledger/managed.d.ts +0 -535
- package/dist/lib/reporting/ledger/managed.js +0 -761
- package/dist/lib/reporting/ledger/managed.mjs +0 -729
- package/dist/lib/reporting/ledger/notification-activity.d.mts +0 -332
- package/dist/lib/reporting/ledger/notification-activity.d.ts +0 -332
- package/dist/lib/reporting/ledger/notification-activity.js +0 -1366
- package/dist/lib/reporting/ledger/notification-activity.mjs +0 -1337
- package/dist/lib/reporting/ledger/object-writes.d.mts +0 -128
- package/dist/lib/reporting/ledger/object-writes.d.ts +0 -128
- package/dist/lib/reporting/ledger/object-writes.js +0 -147
- package/dist/lib/reporting/ledger/object-writes.mjs +0 -114
- package/dist/lib/reporting/ledger/postgres.d.mts +0 -689
- package/dist/lib/reporting/ledger/postgres.d.ts +0 -689
- package/dist/lib/reporting/ledger/postgres.js +0 -4462
- package/dist/lib/reporting/ledger/postgres.mjs +0 -4462
- package/dist/lib/reporting/ledger/row-storage-migration.d.mts +0 -59
- package/dist/lib/reporting/ledger/row-storage-migration.d.ts +0 -59
- package/dist/lib/reporting/ledger/row-storage-migration.js +0 -365
- package/dist/lib/reporting/ledger/row-storage-migration.mjs +0 -339
- package/dist/lib/reporting/ledger/row-storage-object.d.mts +0 -203
- package/dist/lib/reporting/ledger/row-storage-object.d.ts +0 -203
- package/dist/lib/reporting/ledger/row-storage-object.js +0 -379
- package/dist/lib/reporting/ledger/row-storage-object.mjs +0 -335
- package/dist/lib/reporting/ledger/row-storage-provider-io.d.mts +0 -44
- package/dist/lib/reporting/ledger/row-storage-provider-io.d.ts +0 -44
- package/dist/lib/reporting/ledger/row-storage-provider-io.js +0 -142
- package/dist/lib/reporting/ledger/row-storage-provider-io.mjs +0 -111
- package/dist/lib/reporting/ledger/row-storage.d.mts +0 -316
- package/dist/lib/reporting/ledger/row-storage.d.ts +0 -316
- package/dist/lib/reporting/ledger/row-storage.js +0 -812
- package/dist/lib/reporting/ledger/row-storage.mjs +0 -802
- package/dist/lib/reporting/s3/index.d.mts +0 -34
- package/dist/lib/reporting/s3/index.d.ts +0 -34
- package/dist/lib/reporting/s3/index.js +0 -347
- package/dist/lib/reporting/s3/index.mjs +0 -340
- package/dist/lib/reporting/service/maintenance.d.mts +0 -148
- package/dist/lib/reporting/service/maintenance.d.ts +0 -148
- package/dist/lib/reporting/service/maintenance.js +0 -185
- package/dist/lib/reporting/service/maintenance.mjs +0 -159
- package/examples/reliable-reporting-service/README.md +0 -169
|
@@ -370,7 +370,7 @@ function rankH2(agentUrl, refreshStep, refreshedDecoded) {
|
|
|
370
370
|
];
|
|
371
371
|
return base;
|
|
372
372
|
}
|
|
373
|
-
const result = (0, import_diagnostics.
|
|
373
|
+
const result = (0, import_diagnostics.validateDecodedTokenAudience)(refreshedDecoded, agentUrl);
|
|
374
374
|
if (result.ok) {
|
|
375
375
|
base.verdict = "ruled_out";
|
|
376
376
|
base.summary = "Refreshed token `aud` claim matches the expected resource \u2014 AS honors RFC 8707 `resource`";
|
|
@@ -440,7 +440,7 @@ function rankH5(agentUrl, currentDecoded, prmStep) {
|
|
|
440
440
|
const prmResource = prmStep?.http?.body && typeof prmStep.http.body.resource === "string" ? prmStep.http.body.resource : void 0;
|
|
441
441
|
const expected = prmResource ?? agentUrl;
|
|
442
442
|
const prmDiffersFromAgent = prmResource !== void 0 && normalizeForCompare(prmResource) !== normalizeForCompare(agentUrl);
|
|
443
|
-
const result = (0, import_diagnostics.
|
|
443
|
+
const result = (0, import_diagnostics.validateDecodedTokenAudience)(currentDecoded, expected);
|
|
444
444
|
if (result.ok) {
|
|
445
445
|
base.verdict = "ruled_out";
|
|
446
446
|
base.summary = `Saved token \`aud\` matches expected resource (${expected})`;
|
|
@@ -477,7 +477,7 @@ function rankH6(agentUrl, currentDecoded, toolStep) {
|
|
|
477
477
|
base.summary = `tool_call returned HTTP ${toolStep.http.status} \u2014 agent did not accept the token blindly`;
|
|
478
478
|
return base;
|
|
479
479
|
}
|
|
480
|
-
const audResult = (0, import_diagnostics.
|
|
480
|
+
const audResult = (0, import_diagnostics.validateDecodedTokenAudience)(currentDecoded, agentUrl);
|
|
481
481
|
if (audResult.ok) {
|
|
482
482
|
base.verdict = "ruled_out";
|
|
483
483
|
base.summary = "Token `aud` matches agent URL and tool_call succeeded \u2014 cannot distinguish from correct behavior";
|
|
@@ -588,14 +588,6 @@ function isDefaultPort(scheme, port) {
|
|
|
588
588
|
if (scheme === "http:" && port === "80") return true;
|
|
589
589
|
return false;
|
|
590
590
|
}
|
|
591
|
-
function jwtFromDecoded(_decoded) {
|
|
592
|
-
const h = base64url(JSON.stringify(_decoded.header));
|
|
593
|
-
const c = base64url(JSON.stringify(_decoded.claims));
|
|
594
|
-
return `${h}.${c}.${_decoded.signature || "sig"}`;
|
|
595
|
-
}
|
|
596
|
-
function base64url(input) {
|
|
597
|
-
return Buffer.from(input).toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/={0,2}$/, "");
|
|
598
|
-
}
|
|
599
591
|
function formatError(err) {
|
|
600
592
|
if (err instanceof import_net.SsrfRefusedError) {
|
|
601
593
|
return `SSRF guard refused: ${err.code} (${err.message})`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ssrfSafeFetch, decodeBodyAsJsonOrText, SsrfRefusedError } from "../../net/index.mjs";
|
|
2
2
|
import { assertOAuthCredentialIssuer, assertOAuthServerIssuer, OAuthError } from "./types.mjs";
|
|
3
|
-
import { decodeAccessTokenClaims, parseWWWAuthenticate,
|
|
3
|
+
import { decodeAccessTokenClaims, parseWWWAuthenticate, validateDecodedTokenAudience } from "./diagnostics.mjs";
|
|
4
4
|
const AUTH_DIAGNOSIS_SCHEMA_VERSION = 1;
|
|
5
5
|
async function runAuthDiagnosis(agent, options = {}) {
|
|
6
6
|
const steps = [];
|
|
@@ -346,7 +346,7 @@ function rankH2(agentUrl, refreshStep, refreshedDecoded) {
|
|
|
346
346
|
];
|
|
347
347
|
return base;
|
|
348
348
|
}
|
|
349
|
-
const result =
|
|
349
|
+
const result = validateDecodedTokenAudience(refreshedDecoded, agentUrl);
|
|
350
350
|
if (result.ok) {
|
|
351
351
|
base.verdict = "ruled_out";
|
|
352
352
|
base.summary = "Refreshed token `aud` claim matches the expected resource \u2014 AS honors RFC 8707 `resource`";
|
|
@@ -416,7 +416,7 @@ function rankH5(agentUrl, currentDecoded, prmStep) {
|
|
|
416
416
|
const prmResource = prmStep?.http?.body && typeof prmStep.http.body.resource === "string" ? prmStep.http.body.resource : void 0;
|
|
417
417
|
const expected = prmResource ?? agentUrl;
|
|
418
418
|
const prmDiffersFromAgent = prmResource !== void 0 && normalizeForCompare(prmResource) !== normalizeForCompare(agentUrl);
|
|
419
|
-
const result =
|
|
419
|
+
const result = validateDecodedTokenAudience(currentDecoded, expected);
|
|
420
420
|
if (result.ok) {
|
|
421
421
|
base.verdict = "ruled_out";
|
|
422
422
|
base.summary = `Saved token \`aud\` matches expected resource (${expected})`;
|
|
@@ -453,7 +453,7 @@ function rankH6(agentUrl, currentDecoded, toolStep) {
|
|
|
453
453
|
base.summary = `tool_call returned HTTP ${toolStep.http.status} \u2014 agent did not accept the token blindly`;
|
|
454
454
|
return base;
|
|
455
455
|
}
|
|
456
|
-
const audResult =
|
|
456
|
+
const audResult = validateDecodedTokenAudience(currentDecoded, agentUrl);
|
|
457
457
|
if (audResult.ok) {
|
|
458
458
|
base.verdict = "ruled_out";
|
|
459
459
|
base.summary = "Token `aud` matches agent URL and tool_call succeeded \u2014 cannot distinguish from correct behavior";
|
|
@@ -564,14 +564,6 @@ function isDefaultPort(scheme, port) {
|
|
|
564
564
|
if (scheme === "http:" && port === "80") return true;
|
|
565
565
|
return false;
|
|
566
566
|
}
|
|
567
|
-
function jwtFromDecoded(_decoded) {
|
|
568
|
-
const h = base64url(JSON.stringify(_decoded.header));
|
|
569
|
-
const c = base64url(JSON.stringify(_decoded.claims));
|
|
570
|
-
return `${h}.${c}.${_decoded.signature || "sig"}`;
|
|
571
|
-
}
|
|
572
|
-
function base64url(input) {
|
|
573
|
-
return Buffer.from(input).toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/={0,2}$/, "");
|
|
574
|
-
}
|
|
575
567
|
function formatError(err) {
|
|
576
568
|
if (err instanceof SsrfRefusedError) {
|
|
577
569
|
return `SSRF guard refused: ${err.code} (${err.message})`;
|
|
@@ -92,7 +92,8 @@ export interface DecodedAccessToken {
|
|
|
92
92
|
*
|
|
93
93
|
* For diagnostics only — the returned claims MUST NOT be trusted for
|
|
94
94
|
* authorization decisions. Returns `null` if the token is not a well-formed
|
|
95
|
-
* three-part
|
|
95
|
+
* three-part JWS compact serialization: segments that are not base64url, or a
|
|
96
|
+
* header or claims set that is not a JSON object. Decoding uses `jose`.
|
|
96
97
|
*
|
|
97
98
|
* Opaque (non-JWT) tokens always return `null`, which is the expected outcome
|
|
98
99
|
* for servers that issue reference tokens rather than JWTs.
|
|
@@ -92,7 +92,8 @@ export interface DecodedAccessToken {
|
|
|
92
92
|
*
|
|
93
93
|
* For diagnostics only — the returned claims MUST NOT be trusted for
|
|
94
94
|
* authorization decisions. Returns `null` if the token is not a well-formed
|
|
95
|
-
* three-part
|
|
95
|
+
* three-part JWS compact serialization: segments that are not base64url, or a
|
|
96
|
+
* header or claims set that is not a JSON object. Decoding uses `jose`.
|
|
96
97
|
*
|
|
97
98
|
* Opaque (non-JWT) tokens always return `null`, which is the expected outcome
|
|
98
99
|
* for servers that issue reference tokens rather than JWTs.
|
|
@@ -20,9 +20,11 @@ var diagnostics_exports = {};
|
|
|
20
20
|
__export(diagnostics_exports, {
|
|
21
21
|
decodeAccessTokenClaims: () => decodeAccessTokenClaims,
|
|
22
22
|
parseWWWAuthenticate: () => parseWWWAuthenticate,
|
|
23
|
+
validateDecodedTokenAudience: () => validateDecodedTokenAudience,
|
|
23
24
|
validateTokenAudience: () => validateTokenAudience
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(diagnostics_exports);
|
|
27
|
+
var import_jose = require("jose");
|
|
26
28
|
function parseWWWAuthenticate(header) {
|
|
27
29
|
if (!header) return null;
|
|
28
30
|
const trimmed = header.trim();
|
|
@@ -82,10 +84,8 @@ function decodeAccessTokenClaims(token) {
|
|
|
82
84
|
const parts = token.split(".");
|
|
83
85
|
if (parts.length !== 3) return null;
|
|
84
86
|
try {
|
|
85
|
-
const header =
|
|
86
|
-
const claims =
|
|
87
|
-
if (typeof header !== "object" || header === null) return null;
|
|
88
|
-
if (typeof claims !== "object" || claims === null) return null;
|
|
87
|
+
const header = (0, import_jose.decodeProtectedHeader)(token);
|
|
88
|
+
const claims = (0, import_jose.decodeJwt)(token);
|
|
89
89
|
return { header, claims, signature: parts[2] };
|
|
90
90
|
} catch {
|
|
91
91
|
return null;
|
|
@@ -96,6 +96,9 @@ function validateTokenAudience(token, expectedResource) {
|
|
|
96
96
|
if (!decoded) {
|
|
97
97
|
return { ok: false, reason: "Token is opaque or not a valid JWT; audience cannot be inspected" };
|
|
98
98
|
}
|
|
99
|
+
return validateDecodedTokenAudience(decoded, expectedResource);
|
|
100
|
+
}
|
|
101
|
+
function validateDecodedTokenAudience(decoded, expectedResource) {
|
|
99
102
|
const aud = decoded.claims.aud;
|
|
100
103
|
if (aud === void 0) {
|
|
101
104
|
return { ok: false, reason: "Token has no `aud` claim (RFC 8707 violation for resource-indicator flows)" };
|
|
@@ -131,15 +134,10 @@ function isDefaultPort(scheme, port) {
|
|
|
131
134
|
if (scheme === "http:" && port === "80") return true;
|
|
132
135
|
return false;
|
|
133
136
|
}
|
|
134
|
-
function base64UrlDecode(input) {
|
|
135
|
-
const padded = input.replace(/-/g, "+").replace(/_/g, "/");
|
|
136
|
-
const padLen = padded.length % 4;
|
|
137
|
-
const full = padLen ? padded + "=".repeat(4 - padLen) : padded;
|
|
138
|
-
return Buffer.from(full, "base64").toString("utf8");
|
|
139
|
-
}
|
|
140
137
|
// Annotate the CommonJS export names for ESM import in node:
|
|
141
138
|
0 && (module.exports = {
|
|
142
139
|
decodeAccessTokenClaims,
|
|
143
140
|
parseWWWAuthenticate,
|
|
141
|
+
validateDecodedTokenAudience,
|
|
144
142
|
validateTokenAudience
|
|
145
143
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { decodeJwt, decodeProtectedHeader } from "jose";
|
|
1
2
|
function parseWWWAuthenticate(header) {
|
|
2
3
|
if (!header) return null;
|
|
3
4
|
const trimmed = header.trim();
|
|
@@ -57,10 +58,8 @@ function decodeAccessTokenClaims(token) {
|
|
|
57
58
|
const parts = token.split(".");
|
|
58
59
|
if (parts.length !== 3) return null;
|
|
59
60
|
try {
|
|
60
|
-
const header =
|
|
61
|
-
const claims =
|
|
62
|
-
if (typeof header !== "object" || header === null) return null;
|
|
63
|
-
if (typeof claims !== "object" || claims === null) return null;
|
|
61
|
+
const header = decodeProtectedHeader(token);
|
|
62
|
+
const claims = decodeJwt(token);
|
|
64
63
|
return { header, claims, signature: parts[2] };
|
|
65
64
|
} catch {
|
|
66
65
|
return null;
|
|
@@ -71,6 +70,9 @@ function validateTokenAudience(token, expectedResource) {
|
|
|
71
70
|
if (!decoded) {
|
|
72
71
|
return { ok: false, reason: "Token is opaque or not a valid JWT; audience cannot be inspected" };
|
|
73
72
|
}
|
|
73
|
+
return validateDecodedTokenAudience(decoded, expectedResource);
|
|
74
|
+
}
|
|
75
|
+
function validateDecodedTokenAudience(decoded, expectedResource) {
|
|
74
76
|
const aud = decoded.claims.aud;
|
|
75
77
|
if (aud === void 0) {
|
|
76
78
|
return { ok: false, reason: "Token has no `aud` claim (RFC 8707 violation for resource-indicator flows)" };
|
|
@@ -106,14 +108,9 @@ function isDefaultPort(scheme, port) {
|
|
|
106
108
|
if (scheme === "http:" && port === "80") return true;
|
|
107
109
|
return false;
|
|
108
110
|
}
|
|
109
|
-
function base64UrlDecode(input) {
|
|
110
|
-
const padded = input.replace(/-/g, "+").replace(/_/g, "/");
|
|
111
|
-
const padLen = padded.length % 4;
|
|
112
|
-
const full = padLen ? padded + "=".repeat(4 - padLen) : padded;
|
|
113
|
-
return Buffer.from(full, "base64").toString("utf8");
|
|
114
|
-
}
|
|
115
111
|
export {
|
|
116
112
|
decodeAccessTokenClaims,
|
|
117
113
|
parseWWWAuthenticate,
|
|
114
|
+
validateDecodedTokenAudience,
|
|
118
115
|
validateTokenAudience
|
|
119
116
|
};
|
package/dist/lib/index.d.mts
CHANGED
|
@@ -165,7 +165,7 @@ export { BrandJsonSchema, AdagentsJsonSchema } from './types/wellknown-schemas.g
|
|
|
165
165
|
export type { PlacementPresentationDocument, PlacementPresentationReference } from './types/core.generated.mjs';
|
|
166
166
|
export { PlacementPresentationDocumentSchema, PlacementPresentationReferenceSchema } from './types/schemas.generated.mjs';
|
|
167
167
|
export type { Error as TaskErrorDetail } from './types/core.generated.mjs';
|
|
168
|
-
export { STANDARD_ERROR_CODES, isStandardErrorCode, getErrorRecovery } from './types/error-codes.mjs';
|
|
168
|
+
export { STANDARD_ERROR_CODES, isStandardErrorCode, getErrorRecovery, DEFAULT_UNKNOWN_ERROR_RECOVERY, } from './types/error-codes.mjs';
|
|
169
169
|
export type { StandardErrorCode, ErrorRecovery } from './types/error-codes.mjs';
|
|
170
170
|
export { adcpError, legacyCapabilitiesResponse, legacyProductsResponse, legacyMediaBuyResponse, legacyDeliveryResponse, legacyListAccountsResponse, legacyListCreativeFormatsResponse, legacyUpdateMediaBuyResponse, legacyGetMediaBuysResponse, legacyPerformanceFeedbackResponse, legacyBuildCreativeResponse, legacyBuildCreativeMultiResponse, legacyPreviewCreativeResponse, legacyCreativeDeliveryResponse, legacyListCreativesResponse, legacyListPropertyListsResponse, legacyListCollectionListsResponse, legacyListContentStandardsResponse, legacyGetPlanAuditLogsResponse, legacySyncCreativesResponse, legacyGetSignalsResponse, legacyActivateSignalResponse, legacyCancelMediaBuyResponse, legacyAcquireRightsResponse, legacyAcquireRightsAcquired, legacyAcquireRightsPendingApproval, legacyAcquireRightsRejected, legacySyncAccountsResponse, legacySyncGovernanceResponse, legacyReportUsageResponse, validActionsForStatus, MEDIA_BUY_TRANSITIONS, CREATIVE_ASSET_TRANSITIONS, isLegalMediaBuyTransition, isLegalCreativeTransition, assertMediaBuyTransition, assertCreativeTransition, getAccountMode, isSandboxOrMockAccount, assertSandboxAccount, taskToolResponse, registerAdcpTaskTool, createTaskCapableServer, InMemoryTaskStore, isTerminal, serve, taskScopeFromPrincipal, UnknownHostError, hostname, resolveHost, verifyIntrospection, registerTestController, handleTestControllerRequest, TestControllerError, toMcpResponse, TOOL_INPUT_SHAPE, CONTROLLER_SCENARIOS, DISCOVERY_ARM_SCENARIOS, SEED_SCENARIOS, SESSION_ENTRY_CAP, enforceMapCap, createSeedFixtureCache, PostgresTaskStore, cleanupExpiredTasks, getMcpTasksMigration, MCP_TASKS_MIGRATION, ADCP_PRE_TRANSPORT, checkGovernance, governanceDeniedError, DEFAULT_REPORTING_CAPABILITIES, InMemoryStateStore, PostgresStateStore, getAdcpStateMigration, ADCP_STATE_MIGRATION, StateError, PatchConflictError, SESSION_KEY_FIELD, createSessionedStore, scopedStore, patchWithRetry, isPutIfMatchConflict, requireSessionKey, structuredSerialize, structuredDeserialize, createIdempotencyStore, memoryBackend, pgBackend, getIdempotencyMigration, IDEMPOTENCY_MIGRATION, cleanupExpiredIdempotency, redisBackend, createLazyBackend, hashPayload, IdempotencyClaimOwnershipError, getServeRequestContext, ADCP_SERVE_REQUEST_CONTEXT, createA2AAdapter, A2AInvocationError, MCP_APP_RESOURCE_MIME_TYPE, ADCP_MIRRORED_STRUCTURED_CONTENT_META_KEY, } from './server/index.mjs';
|
|
171
171
|
export type { AdcpErrorOptions, AdcpErrorResponse, McpToolResponse, ValidAction, CancelMediaBuyInput, AdcpTaskToolConfig, TaskStore, TaskMessageQueue, CreateTaskOptions, ToolTaskHandler, CreateTaskRequestHandlerExtra, TaskRequestHandlerExtra, CreateTaskResult, GetTaskResult, Task, ServeContext, ServeOptions, PgQueryable, PostgresTaskStoreOptions, TestControllerStore, TestControllerStoreFactory, TestControllerStoreOrFactory, ControllerScenario, SeedScenario, SeedFixtureCache, SessionContext, OnInstructionsError, MaybePromise, LegacyAdcpServerConfig, LegacyAdcpToolMap, AdcpServerToolName, AdcpCapabilitiesConfig, LegacyAdcpCustomToolConfig, LegacyAdcpCustomToolHandler, LegacyAdcpCustomToolHandlerExtra, McpAppUiMeta, McpAppMeta, AdcpMcpResourceDefinition, McpAppResourceCsp, McpAppResourcePermissions, McpAppResourceUiMeta, McpAppResourceMeta, McpAppResourceReadContext, AdcpLogger, LegacyHandlerContext, LegacyMediaBuyHandlers, LegacySignalsHandlers, LegacyCreativeHandlers, LegacyGovernanceHandlers, LegacyAccountHandlers, LegacyEventTrackingHandlers, LegacySponsoredIntelligenceHandlers, SignedRequestsConfig, AdcpPreTransport, AdcpServer, AdcpServerTransport, AdcpTestRequest, AdcpTestToolsCallRequest, AdcpTestResponse, AdcpInvokeOptions, StructuredContentFallbackTransport, StructuredContentTextFallback, StructuredContentTextFallbackContext, CheckGovernanceOptions, GovernanceCallResult, GovernanceApproved, GovernanceDenied, GovernanceConditions, AdcpStateStore, ListOptions as StateListOptions, ListResult as StateListResult, PostgresStateStoreOptions, InMemoryStateStoreOptions, VersionedDocument, PutIfMatchResult, PatchWithRetryOptions, StateErrorCode, SessionKeyContext, IdempotencyStore, IdempotencyStoreConfig, IdempotencyBackend, IdempotencyCacheEntry, IdempotencyCheckResult, MemoryBackendOptions, PgBackendOptions, RedisBackendOptions, RedisBackendClient, RedisLikeClient, LazyBackendFactory, LazyBackendOptions, A2AAdapter, A2AAdapterOptions, A2AAgentCardOverrides, A2AAgentCapabilitiesOverride, A2AAgentSkillOverride, A2AMountOptions, ExpressAppLike, LegacyHttpSecurityScheme, LegacySecurityScheme, AccountMode, RequireCacheScopeWhenProducts, ServerPayload, GetProductsPayload, CreateMediaBuyPayload, UpdateMediaBuyPayload, GetMediaBuysPayload, GetMediaBuyDeliveryPayload, ListCreativesPayload, GetCreativeDeliveryPayload, CanonicalPreviewCreativePayload, PreviewCreativePayload, LegacyGetProductsPayload, LegacyCreateMediaBuyPayload, LegacyUpdateMediaBuyPayload, LegacyGetMediaBuysPayload, LegacyGetMediaBuyDeliveryPayload, LegacyListCreativesPayload, LegacyGetCreativeDeliveryPayload, LegacyListCreativeFormatsPayload, LegacyListCreativeFormatsResponsePayload, LegacyListCreativeFormatsServerPayload, LegacyBuildCreativePayload, LegacyBuildCreativeMultiPayload, LegacyBuildCreativeVariantPayload, LegacyPreviewCreativePayload, SyncCreativesPayload, SyncCreativesSuccessPayload, SyncCreativesErrorPayload, } from './server/index.mjs';
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -165,7 +165,7 @@ export { BrandJsonSchema, AdagentsJsonSchema } from './types/wellknown-schemas.g
|
|
|
165
165
|
export type { PlacementPresentationDocument, PlacementPresentationReference } from './types/core.generated';
|
|
166
166
|
export { PlacementPresentationDocumentSchema, PlacementPresentationReferenceSchema } from './types/schemas.generated';
|
|
167
167
|
export type { Error as TaskErrorDetail } from './types/core.generated';
|
|
168
|
-
export { STANDARD_ERROR_CODES, isStandardErrorCode, getErrorRecovery } from './types/error-codes';
|
|
168
|
+
export { STANDARD_ERROR_CODES, isStandardErrorCode, getErrorRecovery, DEFAULT_UNKNOWN_ERROR_RECOVERY, } from './types/error-codes';
|
|
169
169
|
export type { StandardErrorCode, ErrorRecovery } from './types/error-codes';
|
|
170
170
|
export { adcpError, legacyCapabilitiesResponse, legacyProductsResponse, legacyMediaBuyResponse, legacyDeliveryResponse, legacyListAccountsResponse, legacyListCreativeFormatsResponse, legacyUpdateMediaBuyResponse, legacyGetMediaBuysResponse, legacyPerformanceFeedbackResponse, legacyBuildCreativeResponse, legacyBuildCreativeMultiResponse, legacyPreviewCreativeResponse, legacyCreativeDeliveryResponse, legacyListCreativesResponse, legacyListPropertyListsResponse, legacyListCollectionListsResponse, legacyListContentStandardsResponse, legacyGetPlanAuditLogsResponse, legacySyncCreativesResponse, legacyGetSignalsResponse, legacyActivateSignalResponse, legacyCancelMediaBuyResponse, legacyAcquireRightsResponse, legacyAcquireRightsAcquired, legacyAcquireRightsPendingApproval, legacyAcquireRightsRejected, legacySyncAccountsResponse, legacySyncGovernanceResponse, legacyReportUsageResponse, validActionsForStatus, MEDIA_BUY_TRANSITIONS, CREATIVE_ASSET_TRANSITIONS, isLegalMediaBuyTransition, isLegalCreativeTransition, assertMediaBuyTransition, assertCreativeTransition, getAccountMode, isSandboxOrMockAccount, assertSandboxAccount, taskToolResponse, registerAdcpTaskTool, createTaskCapableServer, InMemoryTaskStore, isTerminal, serve, taskScopeFromPrincipal, UnknownHostError, hostname, resolveHost, verifyIntrospection, registerTestController, handleTestControllerRequest, TestControllerError, toMcpResponse, TOOL_INPUT_SHAPE, CONTROLLER_SCENARIOS, DISCOVERY_ARM_SCENARIOS, SEED_SCENARIOS, SESSION_ENTRY_CAP, enforceMapCap, createSeedFixtureCache, PostgresTaskStore, cleanupExpiredTasks, getMcpTasksMigration, MCP_TASKS_MIGRATION, ADCP_PRE_TRANSPORT, checkGovernance, governanceDeniedError, DEFAULT_REPORTING_CAPABILITIES, InMemoryStateStore, PostgresStateStore, getAdcpStateMigration, ADCP_STATE_MIGRATION, StateError, PatchConflictError, SESSION_KEY_FIELD, createSessionedStore, scopedStore, patchWithRetry, isPutIfMatchConflict, requireSessionKey, structuredSerialize, structuredDeserialize, createIdempotencyStore, memoryBackend, pgBackend, getIdempotencyMigration, IDEMPOTENCY_MIGRATION, cleanupExpiredIdempotency, redisBackend, createLazyBackend, hashPayload, IdempotencyClaimOwnershipError, getServeRequestContext, ADCP_SERVE_REQUEST_CONTEXT, createA2AAdapter, A2AInvocationError, MCP_APP_RESOURCE_MIME_TYPE, ADCP_MIRRORED_STRUCTURED_CONTENT_META_KEY, } from './server';
|
|
171
171
|
export type { AdcpErrorOptions, AdcpErrorResponse, McpToolResponse, ValidAction, CancelMediaBuyInput, AdcpTaskToolConfig, TaskStore, TaskMessageQueue, CreateTaskOptions, ToolTaskHandler, CreateTaskRequestHandlerExtra, TaskRequestHandlerExtra, CreateTaskResult, GetTaskResult, Task, ServeContext, ServeOptions, PgQueryable, PostgresTaskStoreOptions, TestControllerStore, TestControllerStoreFactory, TestControllerStoreOrFactory, ControllerScenario, SeedScenario, SeedFixtureCache, SessionContext, OnInstructionsError, MaybePromise, LegacyAdcpServerConfig, LegacyAdcpToolMap, AdcpServerToolName, AdcpCapabilitiesConfig, LegacyAdcpCustomToolConfig, LegacyAdcpCustomToolHandler, LegacyAdcpCustomToolHandlerExtra, McpAppUiMeta, McpAppMeta, AdcpMcpResourceDefinition, McpAppResourceCsp, McpAppResourcePermissions, McpAppResourceUiMeta, McpAppResourceMeta, McpAppResourceReadContext, AdcpLogger, LegacyHandlerContext, LegacyMediaBuyHandlers, LegacySignalsHandlers, LegacyCreativeHandlers, LegacyGovernanceHandlers, LegacyAccountHandlers, LegacyEventTrackingHandlers, LegacySponsoredIntelligenceHandlers, SignedRequestsConfig, AdcpPreTransport, AdcpServer, AdcpServerTransport, AdcpTestRequest, AdcpTestToolsCallRequest, AdcpTestResponse, AdcpInvokeOptions, StructuredContentFallbackTransport, StructuredContentTextFallback, StructuredContentTextFallbackContext, CheckGovernanceOptions, GovernanceCallResult, GovernanceApproved, GovernanceDenied, GovernanceConditions, AdcpStateStore, ListOptions as StateListOptions, ListResult as StateListResult, PostgresStateStoreOptions, InMemoryStateStoreOptions, VersionedDocument, PutIfMatchResult, PatchWithRetryOptions, StateErrorCode, SessionKeyContext, IdempotencyStore, IdempotencyStoreConfig, IdempotencyBackend, IdempotencyCacheEntry, IdempotencyCheckResult, MemoryBackendOptions, PgBackendOptions, RedisBackendOptions, RedisBackendClient, RedisLikeClient, LazyBackendFactory, LazyBackendOptions, A2AAdapter, A2AAdapterOptions, A2AAgentCardOverrides, A2AAgentCapabilitiesOverride, A2AAgentSkillOverride, A2AMountOptions, ExpressAppLike, LegacyHttpSecurityScheme, LegacySecurityScheme, AccountMode, RequireCacheScopeWhenProducts, ServerPayload, GetProductsPayload, CreateMediaBuyPayload, UpdateMediaBuyPayload, GetMediaBuysPayload, GetMediaBuyDeliveryPayload, ListCreativesPayload, GetCreativeDeliveryPayload, CanonicalPreviewCreativePayload, PreviewCreativePayload, LegacyGetProductsPayload, LegacyCreateMediaBuyPayload, LegacyUpdateMediaBuyPayload, LegacyGetMediaBuysPayload, LegacyGetMediaBuyDeliveryPayload, LegacyListCreativesPayload, LegacyGetCreativeDeliveryPayload, LegacyListCreativeFormatsPayload, LegacyListCreativeFormatsResponsePayload, LegacyListCreativeFormatsServerPayload, LegacyBuildCreativePayload, LegacyBuildCreativeMultiPayload, LegacyBuildCreativeVariantPayload, LegacyPreviewCreativePayload, SyncCreativesPayload, SyncCreativesSuccessPayload, SyncCreativesErrorPayload, } from './server';
|
package/dist/lib/index.js
CHANGED
|
@@ -79,6 +79,7 @@ __export(index_exports, {
|
|
|
79
79
|
DEFAULT_MAX_SSE_FRAME_BYTES: () => import_registry2.DEFAULT_MAX_SSE_FRAME_BYTES,
|
|
80
80
|
DEFAULT_REPORTING_CAPABILITIES: () => import_server.DEFAULT_REPORTING_CAPABILITIES,
|
|
81
81
|
DEFAULT_SSRF_POLICY: () => import_substitution.DEFAULT_SSRF_POLICY,
|
|
82
|
+
DEFAULT_UNKNOWN_ERROR_RECOVERY: () => import_error_codes.DEFAULT_UNKNOWN_ERROR_RECOVERY,
|
|
82
83
|
DISCOVERY_ARM_SCENARIOS: () => import_server.DISCOVERY_ARM_SCENARIOS,
|
|
83
84
|
DeferredSettlementOwnershipError: () => import_TaskExecutor.DeferredSettlementOwnershipError,
|
|
84
85
|
DeferredTaskError: () => import_errors.DeferredTaskError,
|
|
@@ -928,6 +929,7 @@ function createAdCPClientFromEnv() {
|
|
|
928
929
|
DEFAULT_MAX_SSE_FRAME_BYTES,
|
|
929
930
|
DEFAULT_REPORTING_CAPABILITIES,
|
|
930
931
|
DEFAULT_SSRF_POLICY,
|
|
932
|
+
DEFAULT_UNKNOWN_ERROR_RECOVERY,
|
|
931
933
|
DISCOVERY_ARM_SCENARIOS,
|
|
932
934
|
DeferredSettlementOwnershipError,
|
|
933
935
|
DeferredTaskError,
|
package/dist/lib/index.mjs
CHANGED
|
@@ -295,7 +295,12 @@ export * from "./reporting/index.mjs";
|
|
|
295
295
|
export * from "./types/index.mjs";
|
|
296
296
|
import { BrandJsonSchema, AdagentsJsonSchema } from "./types/wellknown-schemas.generated.mjs";
|
|
297
297
|
import { PlacementPresentationDocumentSchema, PlacementPresentationReferenceSchema } from "./types/schemas.generated.mjs";
|
|
298
|
-
import {
|
|
298
|
+
import {
|
|
299
|
+
STANDARD_ERROR_CODES,
|
|
300
|
+
isStandardErrorCode,
|
|
301
|
+
getErrorRecovery,
|
|
302
|
+
DEFAULT_UNKNOWN_ERROR_RECOVERY
|
|
303
|
+
} from "./types/error-codes.mjs";
|
|
299
304
|
import {
|
|
300
305
|
adcpError,
|
|
301
306
|
legacyCapabilitiesResponse,
|
|
@@ -886,6 +891,7 @@ export {
|
|
|
886
891
|
DEFAULT_MAX_SSE_FRAME_BYTES,
|
|
887
892
|
DEFAULT_REPORTING_CAPABILITIES,
|
|
888
893
|
DEFAULT_SSRF_POLICY,
|
|
894
|
+
DEFAULT_UNKNOWN_ERROR_RECOVERY,
|
|
889
895
|
DISCOVERY_ARM_SCENARIOS,
|
|
890
896
|
DeferredSettlementOwnershipError,
|
|
891
897
|
DeferredTaskError,
|
|
@@ -23,6 +23,7 @@ __export(consumer_runtime_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(consumer_runtime_exports);
|
|
25
25
|
var import_jcs = require('../utils/jcs.js');
|
|
26
|
+
var import_pagination = require('./pagination.js');
|
|
26
27
|
var import_reconciliation = require('./reconciliation.js');
|
|
27
28
|
const DEFAULT_POLL_INTERVAL_MS = 6e4;
|
|
28
29
|
const DEFAULT_LEASE_MS = 3e4;
|
|
@@ -59,7 +60,7 @@ async function drainReportingChanges(options, stopAfterChangeDetected) {
|
|
|
59
60
|
...options.request,
|
|
60
61
|
view: "periods",
|
|
61
62
|
changes_after: options.changesAfter,
|
|
62
|
-
...cursor ? {
|
|
63
|
+
pagination: { max_results: (0, import_pagination.reportingMaxPageSize)(), ...cursor ? { cursor } : {} }
|
|
63
64
|
},
|
|
64
65
|
{ signal }
|
|
65
66
|
),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { canonicalJsonSha256 } from "../utils/jcs.mjs";
|
|
2
|
+
import { reportingMaxPageSize } from "./pagination.mjs";
|
|
2
3
|
import {
|
|
3
4
|
ReportingReconciliationError,
|
|
4
5
|
reconcileReporting
|
|
@@ -38,7 +39,7 @@ async function drainReportingChanges(options, stopAfterChangeDetected) {
|
|
|
38
39
|
...options.request,
|
|
39
40
|
view: "periods",
|
|
40
41
|
changes_after: options.changesAfter,
|
|
41
|
-
...cursor ? {
|
|
42
|
+
pagination: { max_results: reportingMaxPageSize(), ...cursor ? { cursor } : {} }
|
|
42
43
|
},
|
|
43
44
|
{ signal }
|
|
44
45
|
),
|
|
@@ -31,12 +31,13 @@ module.exports = __toCommonJS(handler_exports);
|
|
|
31
31
|
var import_node_crypto = require("node:crypto");
|
|
32
32
|
var import_version = require('../../version.js');
|
|
33
33
|
var import_async_outcome = require('../../server/decisioning/async-outcome.js');
|
|
34
|
+
var import_schema_loader = require('../../validation/schema-loader.js');
|
|
34
35
|
var import_source = require('../source/index.js');
|
|
35
36
|
var import_coverage = require('./coverage.js');
|
|
36
37
|
var import_health = require('./health.js');
|
|
37
38
|
var import_instant = require('./instant.js');
|
|
38
39
|
var import_revision_metadata = require('./revision-metadata.js');
|
|
39
|
-
var
|
|
40
|
+
var import_row_storage_errors = require('./row-storage-errors.js');
|
|
40
41
|
var import_schedule = require('./schedule.js');
|
|
41
42
|
var import_types = require('./types.js');
|
|
42
43
|
function createReportingStatusHandler(store, options) {
|
|
@@ -48,6 +49,7 @@ function createReportingStatusHandler(store, options) {
|
|
|
48
49
|
)
|
|
49
50
|
);
|
|
50
51
|
const activeReadsByAccount = /* @__PURE__ */ new Map();
|
|
52
|
+
reportingPageBounds();
|
|
51
53
|
return async (request, context) => {
|
|
52
54
|
const raw = request;
|
|
53
55
|
const resolvedAccount = isRecord(context.account) ? context.account : {};
|
|
@@ -81,9 +83,7 @@ function createReportingStatusHandler(store, options) {
|
|
|
81
83
|
...typeof raw.changes_after === "string" ? { changes_after: raw.changes_after } : {},
|
|
82
84
|
...isRecord(raw.period) ? { period: raw.period } : {}
|
|
83
85
|
};
|
|
84
|
-
const pagination =
|
|
85
|
-
const limitValue = pagination.max_results ?? pagination.limit ?? 100;
|
|
86
|
-
const limit = typeof limitValue === "number" && Number.isFinite(limitValue) ? Math.max(1, Math.min(500, Math.trunc(limitValue))) : 100;
|
|
86
|
+
const { pageSize: limit, pagination } = reportingPagination(raw.pagination);
|
|
87
87
|
const cursor = typeof pagination.cursor === "string" ? pagination.cursor : void 0;
|
|
88
88
|
let snapshotId;
|
|
89
89
|
if (cursor) {
|
|
@@ -99,7 +99,7 @@ function createReportingStatusHandler(store, options) {
|
|
|
99
99
|
try {
|
|
100
100
|
snapshot = await store.createSnapshot(query);
|
|
101
101
|
} catch (error) {
|
|
102
|
-
if (
|
|
102
|
+
if ((0, import_types.isReportingLedgerErrorNamed)(error, "ReportingLedgerSnapshotUnavailableError") || error instanceof ReportingReadCapacityError) {
|
|
103
103
|
return lookupUnavailable(view);
|
|
104
104
|
}
|
|
105
105
|
if (isContinuityError(error)) return operationalUnavailable(view);
|
|
@@ -111,7 +111,7 @@ function createReportingStatusHandler(store, options) {
|
|
|
111
111
|
try {
|
|
112
112
|
page = await store.readSnapshotPage(snapshotId ?? snapshot.snapshotId, accountId, cursor, limit);
|
|
113
113
|
} catch (error) {
|
|
114
|
-
if (
|
|
114
|
+
if ((0, import_types.isReportingLedgerErrorNamed)(error, "ReportingLedgerSnapshotUnavailableError") || error instanceof ReportingReadCapacityError) {
|
|
115
115
|
return lookupUnavailable(view);
|
|
116
116
|
}
|
|
117
117
|
if (isContinuityError(error)) return operationalUnavailable(view);
|
|
@@ -275,7 +275,7 @@ function createReportingStatusHandler(store, options) {
|
|
|
275
275
|
else revisionRows = page2.rows;
|
|
276
276
|
}
|
|
277
277
|
} catch (error) {
|
|
278
|
-
if (error instanceof ReportingReadCapacityError || (0,
|
|
278
|
+
if (error instanceof ReportingReadCapacityError || (0, import_row_storage_errors.isReportingRowStoreError)(error)) {
|
|
279
279
|
return lookupUnavailable(view);
|
|
280
280
|
}
|
|
281
281
|
throw error;
|
|
@@ -412,7 +412,7 @@ function createReportingStatusHandler(store, options) {
|
|
|
412
412
|
issues: issues.map(wireIssue)
|
|
413
413
|
};
|
|
414
414
|
} catch (error) {
|
|
415
|
-
if (error
|
|
415
|
+
if ((0, import_types.isReportingLedgerErrorNamed)(error, "ReportingLedgerIssueIntegrityError")) return operationalUnavailable(view);
|
|
416
416
|
throw error;
|
|
417
417
|
} finally {
|
|
418
418
|
releaseReadSlot();
|
|
@@ -420,6 +420,45 @@ function createReportingStatusHandler(store, options) {
|
|
|
420
420
|
};
|
|
421
421
|
}
|
|
422
422
|
const REPORTING_STATUS_REVISION_VIEW_MAX_ROWS = 1e4;
|
|
423
|
+
let pageBounds;
|
|
424
|
+
function reportingPageBounds() {
|
|
425
|
+
if (pageBounds) return pageBounds;
|
|
426
|
+
const document = (0, import_schema_loader.getSchemaDocumentByRef)("core/pagination-request.json");
|
|
427
|
+
const field = document?.schema.properties?.max_results;
|
|
428
|
+
const { minimum, maximum, default: initial } = field ?? {};
|
|
429
|
+
if (!Number.isSafeInteger(minimum) || !Number.isSafeInteger(maximum) || !Number.isSafeInteger(initial) || minimum < 1 || maximum < minimum || initial < minimum || initial > maximum) {
|
|
430
|
+
throw new Error("The AdCP pagination-request schema does not define bounds for max_results");
|
|
431
|
+
}
|
|
432
|
+
pageBounds = Object.freeze({
|
|
433
|
+
minimum,
|
|
434
|
+
maximum,
|
|
435
|
+
default: initial
|
|
436
|
+
});
|
|
437
|
+
return pageBounds;
|
|
438
|
+
}
|
|
439
|
+
function reportingPagination(value) {
|
|
440
|
+
const bounds = reportingPageBounds();
|
|
441
|
+
if (value !== void 0 && !isRecord(value)) {
|
|
442
|
+
throw new import_async_outcome.AdcpError("VALIDATION_ERROR", { message: "pagination must be an object", field: "pagination" });
|
|
443
|
+
}
|
|
444
|
+
const pagination = value ?? {};
|
|
445
|
+
if (pagination.cursor !== void 0 && typeof pagination.cursor !== "string") {
|
|
446
|
+
throw new import_async_outcome.AdcpError("VALIDATION_ERROR", {
|
|
447
|
+
message: "pagination.cursor must be a string",
|
|
448
|
+
field: "pagination.cursor"
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
const size = pagination.max_results;
|
|
452
|
+
if (size === void 0) return { pageSize: bounds.default, pagination };
|
|
453
|
+
if (typeof size !== "number" || !Number.isInteger(size) || size < bounds.minimum || size > bounds.maximum) {
|
|
454
|
+
throw new import_async_outcome.AdcpError("VALIDATION_ERROR", {
|
|
455
|
+
message: `pagination.max_results must be an integer from ${bounds.minimum} to ${bounds.maximum}`,
|
|
456
|
+
field: "pagination.max_results",
|
|
457
|
+
suggestion: `Send an integer from ${bounds.minimum} to ${bounds.maximum}, or omit it for the default of ${bounds.default}.`
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
return { pageSize: size, pagination };
|
|
461
|
+
}
|
|
423
462
|
function reportingRevisionNotFound() {
|
|
424
463
|
return new import_async_outcome.AdcpError("REFERENCE_NOT_FOUND", {
|
|
425
464
|
message: "Reporting revision is unavailable",
|
|
@@ -432,6 +471,7 @@ function createReportingDeliveryHandler(store, options = {}) {
|
|
|
432
471
|
if (legacyRevisionReader !== void 0 && typeof legacyRevisionReader !== "function") {
|
|
433
472
|
throw new TypeError("legacyRevisionReader must be a function");
|
|
434
473
|
}
|
|
474
|
+
reportingPageBounds();
|
|
435
475
|
const activeReadsByAccount = /* @__PURE__ */ new Map();
|
|
436
476
|
const readFromSdkLedger = async (request, context) => {
|
|
437
477
|
const accountId = resolvedAccountId(context.account);
|
|
@@ -454,12 +494,11 @@ function createReportingDeliveryHandler(store, options = {}) {
|
|
|
454
494
|
field: "reporting_revision_id"
|
|
455
495
|
});
|
|
456
496
|
}
|
|
497
|
+
const { pageSize: maxResults, pagination } = reportingPagination(raw.pagination);
|
|
457
498
|
const revision = await (0, import_revision_metadata.getRevisionMetadataFromStore)(store, raw.reporting_revision_id, accountId);
|
|
458
499
|
if (!revision) return SDK_REVISION_NOT_OWNED;
|
|
459
500
|
const obligation = await store.getObligation(revision.reporting_obligation_id);
|
|
460
501
|
if (!obligation || obligation.account.account_id !== accountId) return SDK_REVISION_NOT_OWNED;
|
|
461
|
-
const pagination = isRecord(raw.pagination) ? raw.pagination : {};
|
|
462
|
-
const maxResults = typeof pagination.max_results === "number" && Number.isFinite(pagination.max_results) ? Math.max(1, Math.min(500, Math.trunc(pagination.max_results))) : 100;
|
|
463
502
|
const totalCount = revision.binding.rowCount;
|
|
464
503
|
let offset = 0;
|
|
465
504
|
if (typeof pagination.cursor === "string") {
|
|
@@ -485,7 +524,7 @@ function createReportingDeliveryHandler(store, options = {}) {
|
|
|
485
524
|
...context.signal ? { signal: context.signal } : {}
|
|
486
525
|
});
|
|
487
526
|
} catch (error) {
|
|
488
|
-
if ((0,
|
|
527
|
+
if ((0, import_row_storage_errors.isReportingRowStoreError)(error)) {
|
|
489
528
|
if (error.code === "ROWS_EXPIRED") throw reportingRevisionNotFound();
|
|
490
529
|
throw new import_async_outcome.AdcpError("SERVICE_UNAVAILABLE", {
|
|
491
530
|
message: "Reporting revision rows are temporarily unavailable"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { ADCP_MAJOR_VERSION, ADCP_VERSION, toReleasePrecisionVersion } from "../../version.mjs";
|
|
3
3
|
import { AdcpError } from "../../server/decisioning/async-outcome.mjs";
|
|
4
|
+
import { getSchemaDocumentByRef } from "../../validation/schema-loader.mjs";
|
|
4
5
|
import { canonicalJsonV1 } from "../source/index.mjs";
|
|
5
6
|
import {
|
|
6
7
|
evaluateReportingLedgerCoverageV1,
|
|
@@ -16,14 +17,13 @@ import {
|
|
|
16
17
|
reportingEffectiveConsumerMismatchEscalationV1,
|
|
17
18
|
projectReportingConsumerStatusMismatchV1,
|
|
18
19
|
projectReportingObligationHealthV1,
|
|
19
|
-
projectReportingUnreadableRevisionHealthV1
|
|
20
|
-
ReportingLedgerIssueIntegrityError
|
|
20
|
+
projectReportingUnreadableRevisionHealthV1
|
|
21
21
|
} from "./health.mjs";
|
|
22
22
|
import { compareReportingInstants } from "./instant.mjs";
|
|
23
23
|
import { getRevisionMetadataFromStore, readRevisionRowsFromStore } from "./revision-metadata.mjs";
|
|
24
|
-
import { isReportingRowStoreError } from "./row-storage.mjs";
|
|
24
|
+
import { isReportingRowStoreError } from "./row-storage-errors.mjs";
|
|
25
25
|
import { reportingPeriodSchedule } from "./schedule.mjs";
|
|
26
|
-
import {
|
|
26
|
+
import { isReportingLedgerErrorNamed } from "./types.mjs";
|
|
27
27
|
function createReportingStatusHandler(store, options) {
|
|
28
28
|
const consumerMismatchEscalation = assertReportingConsumerMismatchEscalation(
|
|
29
29
|
reportingEffectiveConsumerMismatchEscalationV1(
|
|
@@ -33,6 +33,7 @@ function createReportingStatusHandler(store, options) {
|
|
|
33
33
|
)
|
|
34
34
|
);
|
|
35
35
|
const activeReadsByAccount = /* @__PURE__ */ new Map();
|
|
36
|
+
reportingPageBounds();
|
|
36
37
|
return async (request, context) => {
|
|
37
38
|
const raw = request;
|
|
38
39
|
const resolvedAccount = isRecord(context.account) ? context.account : {};
|
|
@@ -66,9 +67,7 @@ function createReportingStatusHandler(store, options) {
|
|
|
66
67
|
...typeof raw.changes_after === "string" ? { changes_after: raw.changes_after } : {},
|
|
67
68
|
...isRecord(raw.period) ? { period: raw.period } : {}
|
|
68
69
|
};
|
|
69
|
-
const pagination =
|
|
70
|
-
const limitValue = pagination.max_results ?? pagination.limit ?? 100;
|
|
71
|
-
const limit = typeof limitValue === "number" && Number.isFinite(limitValue) ? Math.max(1, Math.min(500, Math.trunc(limitValue))) : 100;
|
|
70
|
+
const { pageSize: limit, pagination } = reportingPagination(raw.pagination);
|
|
72
71
|
const cursor = typeof pagination.cursor === "string" ? pagination.cursor : void 0;
|
|
73
72
|
let snapshotId;
|
|
74
73
|
if (cursor) {
|
|
@@ -84,7 +83,7 @@ function createReportingStatusHandler(store, options) {
|
|
|
84
83
|
try {
|
|
85
84
|
snapshot = await store.createSnapshot(query);
|
|
86
85
|
} catch (error) {
|
|
87
|
-
if (error
|
|
86
|
+
if (isReportingLedgerErrorNamed(error, "ReportingLedgerSnapshotUnavailableError") || error instanceof ReportingReadCapacityError) {
|
|
88
87
|
return lookupUnavailable(view);
|
|
89
88
|
}
|
|
90
89
|
if (isContinuityError(error)) return operationalUnavailable(view);
|
|
@@ -96,7 +95,7 @@ function createReportingStatusHandler(store, options) {
|
|
|
96
95
|
try {
|
|
97
96
|
page = await store.readSnapshotPage(snapshotId ?? snapshot.snapshotId, accountId, cursor, limit);
|
|
98
97
|
} catch (error) {
|
|
99
|
-
if (error
|
|
98
|
+
if (isReportingLedgerErrorNamed(error, "ReportingLedgerSnapshotUnavailableError") || error instanceof ReportingReadCapacityError) {
|
|
100
99
|
return lookupUnavailable(view);
|
|
101
100
|
}
|
|
102
101
|
if (isContinuityError(error)) return operationalUnavailable(view);
|
|
@@ -397,7 +396,7 @@ function createReportingStatusHandler(store, options) {
|
|
|
397
396
|
issues: issues.map(wireIssue)
|
|
398
397
|
};
|
|
399
398
|
} catch (error) {
|
|
400
|
-
if (error
|
|
399
|
+
if (isReportingLedgerErrorNamed(error, "ReportingLedgerIssueIntegrityError")) return operationalUnavailable(view);
|
|
401
400
|
throw error;
|
|
402
401
|
} finally {
|
|
403
402
|
releaseReadSlot();
|
|
@@ -405,6 +404,45 @@ function createReportingStatusHandler(store, options) {
|
|
|
405
404
|
};
|
|
406
405
|
}
|
|
407
406
|
const REPORTING_STATUS_REVISION_VIEW_MAX_ROWS = 1e4;
|
|
407
|
+
let pageBounds;
|
|
408
|
+
function reportingPageBounds() {
|
|
409
|
+
if (pageBounds) return pageBounds;
|
|
410
|
+
const document = getSchemaDocumentByRef("core/pagination-request.json");
|
|
411
|
+
const field = document?.schema.properties?.max_results;
|
|
412
|
+
const { minimum, maximum, default: initial } = field ?? {};
|
|
413
|
+
if (!Number.isSafeInteger(minimum) || !Number.isSafeInteger(maximum) || !Number.isSafeInteger(initial) || minimum < 1 || maximum < minimum || initial < minimum || initial > maximum) {
|
|
414
|
+
throw new Error("The AdCP pagination-request schema does not define bounds for max_results");
|
|
415
|
+
}
|
|
416
|
+
pageBounds = Object.freeze({
|
|
417
|
+
minimum,
|
|
418
|
+
maximum,
|
|
419
|
+
default: initial
|
|
420
|
+
});
|
|
421
|
+
return pageBounds;
|
|
422
|
+
}
|
|
423
|
+
function reportingPagination(value) {
|
|
424
|
+
const bounds = reportingPageBounds();
|
|
425
|
+
if (value !== void 0 && !isRecord(value)) {
|
|
426
|
+
throw new AdcpError("VALIDATION_ERROR", { message: "pagination must be an object", field: "pagination" });
|
|
427
|
+
}
|
|
428
|
+
const pagination = value ?? {};
|
|
429
|
+
if (pagination.cursor !== void 0 && typeof pagination.cursor !== "string") {
|
|
430
|
+
throw new AdcpError("VALIDATION_ERROR", {
|
|
431
|
+
message: "pagination.cursor must be a string",
|
|
432
|
+
field: "pagination.cursor"
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
const size = pagination.max_results;
|
|
436
|
+
if (size === void 0) return { pageSize: bounds.default, pagination };
|
|
437
|
+
if (typeof size !== "number" || !Number.isInteger(size) || size < bounds.minimum || size > bounds.maximum) {
|
|
438
|
+
throw new AdcpError("VALIDATION_ERROR", {
|
|
439
|
+
message: `pagination.max_results must be an integer from ${bounds.minimum} to ${bounds.maximum}`,
|
|
440
|
+
field: "pagination.max_results",
|
|
441
|
+
suggestion: `Send an integer from ${bounds.minimum} to ${bounds.maximum}, or omit it for the default of ${bounds.default}.`
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
return { pageSize: size, pagination };
|
|
445
|
+
}
|
|
408
446
|
function reportingRevisionNotFound() {
|
|
409
447
|
return new AdcpError("REFERENCE_NOT_FOUND", {
|
|
410
448
|
message: "Reporting revision is unavailable",
|
|
@@ -417,6 +455,7 @@ function createReportingDeliveryHandler(store, options = {}) {
|
|
|
417
455
|
if (legacyRevisionReader !== void 0 && typeof legacyRevisionReader !== "function") {
|
|
418
456
|
throw new TypeError("legacyRevisionReader must be a function");
|
|
419
457
|
}
|
|
458
|
+
reportingPageBounds();
|
|
420
459
|
const activeReadsByAccount = /* @__PURE__ */ new Map();
|
|
421
460
|
const readFromSdkLedger = async (request, context) => {
|
|
422
461
|
const accountId = resolvedAccountId(context.account);
|
|
@@ -439,12 +478,11 @@ function createReportingDeliveryHandler(store, options = {}) {
|
|
|
439
478
|
field: "reporting_revision_id"
|
|
440
479
|
});
|
|
441
480
|
}
|
|
481
|
+
const { pageSize: maxResults, pagination } = reportingPagination(raw.pagination);
|
|
442
482
|
const revision = await getRevisionMetadataFromStore(store, raw.reporting_revision_id, accountId);
|
|
443
483
|
if (!revision) return SDK_REVISION_NOT_OWNED;
|
|
444
484
|
const obligation = await store.getObligation(revision.reporting_obligation_id);
|
|
445
485
|
if (!obligation || obligation.account.account_id !== accountId) return SDK_REVISION_NOT_OWNED;
|
|
446
|
-
const pagination = isRecord(raw.pagination) ? raw.pagination : {};
|
|
447
|
-
const maxResults = typeof pagination.max_results === "number" && Number.isFinite(pagination.max_results) ? Math.max(1, Math.min(500, Math.trunc(pagination.max_results))) : 100;
|
|
448
486
|
const totalCount = revision.binding.rowCount;
|
|
449
487
|
let offset = 0;
|
|
450
488
|
if (typeof pagination.cursor === "string") {
|