@agent-score/commerce 2.7.3 → 2.7.4
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/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/identity/express.js +1 -1
- package/dist/identity/express.mjs +1 -1
- package/dist/identity/fastify.js +1 -1
- package/dist/identity/fastify.mjs +1 -1
- package/dist/identity/hono.js +1 -1
- package/dist/identity/hono.mjs +1 -1
- package/dist/identity/nextjs.js +1 -1
- package/dist/identity/nextjs.mjs +1 -1
- package/dist/identity/web.js +1 -1
- package/dist/identity/web.mjs +1 -1
- package/dist/index.js +19 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -3
- package/dist/index.mjs.map +1 -1
- package/dist/payment/index.d.mts +23 -1
- package/dist/payment/index.d.ts +23 -1
- package/dist/payment/index.js +20 -2
- package/dist/payment/index.js.map +1 -1
- package/dist/payment/index.mjs +19 -2
- package/dist/payment/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/payment/index.mjs
CHANGED
|
@@ -440,6 +440,21 @@ function classifyOrchestrationError(err) {
|
|
|
440
440
|
}
|
|
441
441
|
return null;
|
|
442
442
|
}
|
|
443
|
+
function toCanonicalX402PaymentPayload(payload) {
|
|
444
|
+
if (typeof payload !== "object" || payload === null) return payload;
|
|
445
|
+
const p = payload;
|
|
446
|
+
const accepted = typeof p.accepted === "object" && p.accepted !== null ? p.accepted : void 0;
|
|
447
|
+
const scheme = p.scheme ?? accepted?.scheme;
|
|
448
|
+
const network = p.network ?? accepted?.network;
|
|
449
|
+
const inner = p.payload;
|
|
450
|
+
if (scheme === void 0 || network === void 0 || inner === void 0) return payload;
|
|
451
|
+
return {
|
|
452
|
+
x402Version: p.x402Version ?? 2,
|
|
453
|
+
scheme,
|
|
454
|
+
network,
|
|
455
|
+
payload: inner
|
|
456
|
+
};
|
|
457
|
+
}
|
|
443
458
|
async function processX402Settle({
|
|
444
459
|
x402Server,
|
|
445
460
|
payload,
|
|
@@ -460,6 +475,7 @@ async function processX402Settle({
|
|
|
460
475
|
if (!matchedRequirement) {
|
|
461
476
|
return { success: false, phase: "no_requirements", reason: "x402Server.buildPaymentRequirements returned empty" };
|
|
462
477
|
}
|
|
478
|
+
const canonicalPayload = toCanonicalX402PaymentPayload(payload);
|
|
463
479
|
const resolvedTransportContext = transportContext ?? (() => {
|
|
464
480
|
const path = new URL(resourceMeta.url).pathname;
|
|
465
481
|
return { method: "POST", adapter: { getPath: () => path }, routePattern: path };
|
|
@@ -474,7 +490,7 @@ async function processX402Settle({
|
|
|
474
490
|
let verifyResult;
|
|
475
491
|
try {
|
|
476
492
|
verifyResult = await server.verifyPayment(
|
|
477
|
-
|
|
493
|
+
canonicalPayload,
|
|
478
494
|
matchedRequirement,
|
|
479
495
|
enrichedExt,
|
|
480
496
|
resolvedTransportContext
|
|
@@ -489,7 +505,7 @@ async function processX402Settle({
|
|
|
489
505
|
}
|
|
490
506
|
try {
|
|
491
507
|
const settleResult = await server.settlePayment(
|
|
492
|
-
|
|
508
|
+
canonicalPayload,
|
|
493
509
|
matchedRequirement,
|
|
494
510
|
enrichedExt,
|
|
495
511
|
resolvedTransportContext
|
|
@@ -1462,6 +1478,7 @@ export {
|
|
|
1462
1478
|
resolveRecipient,
|
|
1463
1479
|
runWithMppxFailureCapture,
|
|
1464
1480
|
settlementOverrideHeader,
|
|
1481
|
+
toCanonicalX402PaymentPayload,
|
|
1465
1482
|
usdToAtomic,
|
|
1466
1483
|
validateX402NetworkConfig,
|
|
1467
1484
|
verifyX402Request,
|