@agent-score/commerce 2.7.4 → 2.7.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/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 +12 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -16
- package/dist/index.mjs.map +1 -1
- package/dist/payment/index.d.mts +22 -22
- package/dist/payment/index.d.ts +22 -22
- package/dist/payment/index.js +13 -17
- package/dist/payment/index.js.map +1 -1
- package/dist/payment/index.mjs +12 -16
- package/dist/payment/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/payment/index.d.mts
CHANGED
|
@@ -403,27 +403,27 @@ declare function classifyX402SettleResult(result: ProcessX402SettleResult): Clas
|
|
|
403
403
|
*/
|
|
404
404
|
declare function classifyOrchestrationError(err: unknown): ClassifiedX402Error | null;
|
|
405
405
|
/**
|
|
406
|
-
*
|
|
407
|
-
* facilitator's verify/settle endpoints
|
|
408
|
-
*
|
|
409
|
-
* agentscore-pay (and other x402 clients)
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
* it
|
|
418
|
-
*
|
|
419
|
-
*
|
|
420
|
-
*
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
*
|
|
424
|
-
*
|
|
425
|
-
*/
|
|
426
|
-
declare function
|
|
406
|
+
* Strip the non-signed `extensions` + `resource` blocks from a decoded X-Payment payload
|
|
407
|
+
* before it is forwarded to the facilitator's verify/settle endpoints.
|
|
408
|
+
*
|
|
409
|
+
* agentscore-pay (and other x402 clients) echo the 402 challenge's `extensions` (Bazaar
|
|
410
|
+
* input schema) and `resource` blocks into the payload alongside the signed `payload` +
|
|
411
|
+
* `accepted`. Neither is part of the EIP-3009 signature (which covers only
|
|
412
|
+
* `payload.authorization`). CDP's `/x402/verify` validates the paymentPayload against its
|
|
413
|
+
* `x402V2PaymentPayload` schema, which is `{ x402Version, payload, accepted }` and admits
|
|
414
|
+
* neither `extensions` nor `resource`: their presence makes the payload match no union
|
|
415
|
+
* branch and CDP rejects it ("must match one of [x402V2PaymentPayload, x402V1PaymentPayload]").
|
|
416
|
+
* Endpoints whose echoed Bazaar schema is large fail while small ones happen to slip through,
|
|
417
|
+
* so it presents as "works on some routes, fails on others" but is one shape bug.
|
|
418
|
+
*
|
|
419
|
+
* Confirmed against the live CDP facilitator: accepted-nested WITHOUT extensions/resource
|
|
420
|
+
* passes schema and reaches signature verify; a flat `{ x402Version, scheme, network, payload }`
|
|
421
|
+
* is rejected with "x402V2PaymentPayload requires 'accepted'". So `accepted` (which
|
|
422
|
+
* `verifyX402Request` reads for network/payTo) and every other field stay intact; only the
|
|
423
|
+
* two echoed challenge blocks are dropped, and only here at the facilitator boundary.
|
|
424
|
+
* Non-object payloads, and payloads carrying neither field, pass through untouched.
|
|
425
|
+
*/
|
|
426
|
+
declare function stripUnsignedX402PayloadFields(payload: unknown): unknown;
|
|
427
427
|
declare function processX402Settle({ x402Server, payload, resourceConfig, resourceMeta, extension, transportContext, }: {
|
|
428
428
|
/** The x402 server instance from `createX402Server`. */
|
|
429
429
|
x402Server: X402Server;
|
|
@@ -923,4 +923,4 @@ declare function lazyMppxServer(opts: {
|
|
|
923
923
|
secretKey: string;
|
|
924
924
|
}): () => Promise<unknown>;
|
|
925
925
|
|
|
926
|
-
export { type ClassifiedX402Error, type MppxComposeResult, type MppxRailSpec, type NetworkFamily, type PaymentHeadersRail, type PaymentHeadersResult, type ProcessX402SettleFailure, type ProcessX402SettleResult, type ProcessX402SettleSuccess, type RailDefinition, type RailName, SETTLEMENT_OVERRIDES_HEADER, type SettlementHandlers, type SettlementOverrides, type SettlementPayloadLike, SignerNetwork, SolanaMppRailSpec, StripeRailSpec, TempoRailSpec, TempoSessionRailSpec, USDC, type VerifyX402RequestResult, X402BaseRailSpec, X402Server, type X402ServerLike, X402_SUPPORTED_BASE_NETWORKS, type ZeroSettleRail, type ZeroSettleResult, buildIdempotencyKey, buildPaymentDirective, buildPaymentHeaders, buildPaymentRequestBlob, classifyOrchestrationError, classifyX402SettleResult, composeMppxRequest, createMppxServer, detectRailFromHeaders, dispatchSettlementByNetwork, lazyMppxServer, lazyX402Server, lookupRail, mppCredentialPayloadType, mppxChallengeHeaders, networkFamily, networks, paymentDirective, processX402Settle, rails, registerX402SchemesV1V2, runWithMppxFailureCapture, settlementOverrideHeader,
|
|
926
|
+
export { type ClassifiedX402Error, type MppxComposeResult, type MppxRailSpec, type NetworkFamily, type PaymentHeadersRail, type PaymentHeadersResult, type ProcessX402SettleFailure, type ProcessX402SettleResult, type ProcessX402SettleSuccess, type RailDefinition, type RailName, SETTLEMENT_OVERRIDES_HEADER, type SettlementHandlers, type SettlementOverrides, type SettlementPayloadLike, SignerNetwork, SolanaMppRailSpec, StripeRailSpec, TempoRailSpec, TempoSessionRailSpec, USDC, type VerifyX402RequestResult, X402BaseRailSpec, X402Server, type X402ServerLike, X402_SUPPORTED_BASE_NETWORKS, type ZeroSettleRail, type ZeroSettleResult, buildIdempotencyKey, buildPaymentDirective, buildPaymentHeaders, buildPaymentRequestBlob, classifyOrchestrationError, classifyX402SettleResult, composeMppxRequest, createMppxServer, detectRailFromHeaders, dispatchSettlementByNetwork, lazyMppxServer, lazyX402Server, lookupRail, mppCredentialPayloadType, mppxChallengeHeaders, networkFamily, networks, paymentDirective, processX402Settle, rails, registerX402SchemesV1V2, runWithMppxFailureCapture, settlementOverrideHeader, stripUnsignedX402PayloadFields, validateX402NetworkConfig, verifyX402Request, wrapSolanaChargeWithFinalizedBlockhash, zeroAmountCarveOut };
|
package/dist/payment/index.d.ts
CHANGED
|
@@ -403,27 +403,27 @@ declare function classifyX402SettleResult(result: ProcessX402SettleResult): Clas
|
|
|
403
403
|
*/
|
|
404
404
|
declare function classifyOrchestrationError(err: unknown): ClassifiedX402Error | null;
|
|
405
405
|
/**
|
|
406
|
-
*
|
|
407
|
-
* facilitator's verify/settle endpoints
|
|
408
|
-
*
|
|
409
|
-
* agentscore-pay (and other x402 clients)
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
* it
|
|
418
|
-
*
|
|
419
|
-
*
|
|
420
|
-
*
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
*
|
|
424
|
-
*
|
|
425
|
-
*/
|
|
426
|
-
declare function
|
|
406
|
+
* Strip the non-signed `extensions` + `resource` blocks from a decoded X-Payment payload
|
|
407
|
+
* before it is forwarded to the facilitator's verify/settle endpoints.
|
|
408
|
+
*
|
|
409
|
+
* agentscore-pay (and other x402 clients) echo the 402 challenge's `extensions` (Bazaar
|
|
410
|
+
* input schema) and `resource` blocks into the payload alongside the signed `payload` +
|
|
411
|
+
* `accepted`. Neither is part of the EIP-3009 signature (which covers only
|
|
412
|
+
* `payload.authorization`). CDP's `/x402/verify` validates the paymentPayload against its
|
|
413
|
+
* `x402V2PaymentPayload` schema, which is `{ x402Version, payload, accepted }` and admits
|
|
414
|
+
* neither `extensions` nor `resource`: their presence makes the payload match no union
|
|
415
|
+
* branch and CDP rejects it ("must match one of [x402V2PaymentPayload, x402V1PaymentPayload]").
|
|
416
|
+
* Endpoints whose echoed Bazaar schema is large fail while small ones happen to slip through,
|
|
417
|
+
* so it presents as "works on some routes, fails on others" but is one shape bug.
|
|
418
|
+
*
|
|
419
|
+
* Confirmed against the live CDP facilitator: accepted-nested WITHOUT extensions/resource
|
|
420
|
+
* passes schema and reaches signature verify; a flat `{ x402Version, scheme, network, payload }`
|
|
421
|
+
* is rejected with "x402V2PaymentPayload requires 'accepted'". So `accepted` (which
|
|
422
|
+
* `verifyX402Request` reads for network/payTo) and every other field stay intact; only the
|
|
423
|
+
* two echoed challenge blocks are dropped, and only here at the facilitator boundary.
|
|
424
|
+
* Non-object payloads, and payloads carrying neither field, pass through untouched.
|
|
425
|
+
*/
|
|
426
|
+
declare function stripUnsignedX402PayloadFields(payload: unknown): unknown;
|
|
427
427
|
declare function processX402Settle({ x402Server, payload, resourceConfig, resourceMeta, extension, transportContext, }: {
|
|
428
428
|
/** The x402 server instance from `createX402Server`. */
|
|
429
429
|
x402Server: X402Server;
|
|
@@ -923,4 +923,4 @@ declare function lazyMppxServer(opts: {
|
|
|
923
923
|
secretKey: string;
|
|
924
924
|
}): () => Promise<unknown>;
|
|
925
925
|
|
|
926
|
-
export { type ClassifiedX402Error, type MppxComposeResult, type MppxRailSpec, type NetworkFamily, type PaymentHeadersRail, type PaymentHeadersResult, type ProcessX402SettleFailure, type ProcessX402SettleResult, type ProcessX402SettleSuccess, type RailDefinition, type RailName, SETTLEMENT_OVERRIDES_HEADER, type SettlementHandlers, type SettlementOverrides, type SettlementPayloadLike, SignerNetwork, SolanaMppRailSpec, StripeRailSpec, TempoRailSpec, TempoSessionRailSpec, USDC, type VerifyX402RequestResult, X402BaseRailSpec, X402Server, type X402ServerLike, X402_SUPPORTED_BASE_NETWORKS, type ZeroSettleRail, type ZeroSettleResult, buildIdempotencyKey, buildPaymentDirective, buildPaymentHeaders, buildPaymentRequestBlob, classifyOrchestrationError, classifyX402SettleResult, composeMppxRequest, createMppxServer, detectRailFromHeaders, dispatchSettlementByNetwork, lazyMppxServer, lazyX402Server, lookupRail, mppCredentialPayloadType, mppxChallengeHeaders, networkFamily, networks, paymentDirective, processX402Settle, rails, registerX402SchemesV1V2, runWithMppxFailureCapture, settlementOverrideHeader,
|
|
926
|
+
export { type ClassifiedX402Error, type MppxComposeResult, type MppxRailSpec, type NetworkFamily, type PaymentHeadersRail, type PaymentHeadersResult, type ProcessX402SettleFailure, type ProcessX402SettleResult, type ProcessX402SettleSuccess, type RailDefinition, type RailName, SETTLEMENT_OVERRIDES_HEADER, type SettlementHandlers, type SettlementOverrides, type SettlementPayloadLike, SignerNetwork, SolanaMppRailSpec, StripeRailSpec, TempoRailSpec, TempoSessionRailSpec, USDC, type VerifyX402RequestResult, X402BaseRailSpec, X402Server, type X402ServerLike, X402_SUPPORTED_BASE_NETWORKS, type ZeroSettleRail, type ZeroSettleResult, buildIdempotencyKey, buildPaymentDirective, buildPaymentHeaders, buildPaymentRequestBlob, classifyOrchestrationError, classifyX402SettleResult, composeMppxRequest, createMppxServer, detectRailFromHeaders, dispatchSettlementByNetwork, lazyMppxServer, lazyX402Server, lookupRail, mppCredentialPayloadType, mppxChallengeHeaders, networkFamily, networks, paymentDirective, processX402Settle, rails, registerX402SchemesV1V2, runWithMppxFailureCapture, settlementOverrideHeader, stripUnsignedX402PayloadFields, validateX402NetworkConfig, verifyX402Request, wrapSolanaChargeWithFinalizedBlockhash, zeroAmountCarveOut };
|
package/dist/payment/index.js
CHANGED
|
@@ -68,7 +68,7 @@ __export(payment_exports, {
|
|
|
68
68
|
resolveRecipient: () => resolveRecipient,
|
|
69
69
|
runWithMppxFailureCapture: () => runWithMppxFailureCapture,
|
|
70
70
|
settlementOverrideHeader: () => settlementOverrideHeader,
|
|
71
|
-
|
|
71
|
+
stripUnsignedX402PayloadFields: () => stripUnsignedX402PayloadFields,
|
|
72
72
|
usdToAtomic: () => usdToAtomic,
|
|
73
73
|
validateX402NetworkConfig: () => validateX402NetworkConfig,
|
|
74
74
|
verifyX402Request: () => verifyX402Request,
|
|
@@ -520,20 +520,16 @@ function classifyOrchestrationError(err) {
|
|
|
520
520
|
}
|
|
521
521
|
return null;
|
|
522
522
|
}
|
|
523
|
-
function
|
|
523
|
+
function stripUnsignedX402PayloadFields(payload) {
|
|
524
524
|
if (typeof payload !== "object" || payload === null) return payload;
|
|
525
525
|
const p = payload;
|
|
526
|
-
|
|
527
|
-
const
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
scheme,
|
|
534
|
-
network,
|
|
535
|
-
payload: inner
|
|
536
|
-
};
|
|
526
|
+
if (!("extensions" in p) && !("resource" in p)) return payload;
|
|
527
|
+
const rest = {};
|
|
528
|
+
for (const [k, v] of Object.entries(p)) {
|
|
529
|
+
if (k === "extensions" || k === "resource") continue;
|
|
530
|
+
rest[k] = v;
|
|
531
|
+
}
|
|
532
|
+
return rest;
|
|
537
533
|
}
|
|
538
534
|
async function processX402Settle({
|
|
539
535
|
x402Server,
|
|
@@ -555,7 +551,7 @@ async function processX402Settle({
|
|
|
555
551
|
if (!matchedRequirement) {
|
|
556
552
|
return { success: false, phase: "no_requirements", reason: "x402Server.buildPaymentRequirements returned empty" };
|
|
557
553
|
}
|
|
558
|
-
const
|
|
554
|
+
const facilitatorPayload = stripUnsignedX402PayloadFields(payload);
|
|
559
555
|
const resolvedTransportContext = transportContext ?? (() => {
|
|
560
556
|
const path = new URL(resourceMeta.url).pathname;
|
|
561
557
|
return { method: "POST", adapter: { getPath: () => path }, routePattern: path };
|
|
@@ -570,7 +566,7 @@ async function processX402Settle({
|
|
|
570
566
|
let verifyResult;
|
|
571
567
|
try {
|
|
572
568
|
verifyResult = await server.verifyPayment(
|
|
573
|
-
|
|
569
|
+
facilitatorPayload,
|
|
574
570
|
matchedRequirement,
|
|
575
571
|
enrichedExt,
|
|
576
572
|
resolvedTransportContext
|
|
@@ -585,7 +581,7 @@ async function processX402Settle({
|
|
|
585
581
|
}
|
|
586
582
|
try {
|
|
587
583
|
const settleResult = await server.settlePayment(
|
|
588
|
-
|
|
584
|
+
facilitatorPayload,
|
|
589
585
|
matchedRequirement,
|
|
590
586
|
enrichedExt,
|
|
591
587
|
resolvedTransportContext
|
|
@@ -1559,7 +1555,7 @@ function isSolanaNetwork(input) {
|
|
|
1559
1555
|
resolveRecipient,
|
|
1560
1556
|
runWithMppxFailureCapture,
|
|
1561
1557
|
settlementOverrideHeader,
|
|
1562
|
-
|
|
1558
|
+
stripUnsignedX402PayloadFields,
|
|
1563
1559
|
usdToAtomic,
|
|
1564
1560
|
validateX402NetworkConfig,
|
|
1565
1561
|
verifyX402Request,
|