@agent-score/commerce 2.7.3 → 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 +15 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -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 +16 -2
- package/dist/payment/index.js.map +1 -1
- package/dist/payment/index.mjs +15 -2
- package/dist/payment/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/payment/index.d.mts
CHANGED
|
@@ -402,6 +402,28 @@ declare function classifyX402SettleResult(result: ProcessX402SettleResult): Clas
|
|
|
402
402
|
* `classifyX402SettleResult`.
|
|
403
403
|
*/
|
|
404
404
|
declare function classifyOrchestrationError(err: unknown): ClassifiedX402Error | null;
|
|
405
|
+
/**
|
|
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;
|
|
405
427
|
declare function processX402Settle({ x402Server, payload, resourceConfig, resourceMeta, extension, transportContext, }: {
|
|
406
428
|
/** The x402 server instance from `createX402Server`. */
|
|
407
429
|
x402Server: X402Server;
|
|
@@ -901,4 +923,4 @@ declare function lazyMppxServer(opts: {
|
|
|
901
923
|
secretKey: string;
|
|
902
924
|
}): () => Promise<unknown>;
|
|
903
925
|
|
|
904
|
-
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, validateX402NetworkConfig, verifyX402Request, wrapSolanaChargeWithFinalizedBlockhash, zeroAmountCarveOut };
|
|
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
|
@@ -402,6 +402,28 @@ declare function classifyX402SettleResult(result: ProcessX402SettleResult): Clas
|
|
|
402
402
|
* `classifyX402SettleResult`.
|
|
403
403
|
*/
|
|
404
404
|
declare function classifyOrchestrationError(err: unknown): ClassifiedX402Error | null;
|
|
405
|
+
/**
|
|
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;
|
|
405
427
|
declare function processX402Settle({ x402Server, payload, resourceConfig, resourceMeta, extension, transportContext, }: {
|
|
406
428
|
/** The x402 server instance from `createX402Server`. */
|
|
407
429
|
x402Server: X402Server;
|
|
@@ -901,4 +923,4 @@ declare function lazyMppxServer(opts: {
|
|
|
901
923
|
secretKey: string;
|
|
902
924
|
}): () => Promise<unknown>;
|
|
903
925
|
|
|
904
|
-
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, validateX402NetworkConfig, verifyX402Request, wrapSolanaChargeWithFinalizedBlockhash, zeroAmountCarveOut };
|
|
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,6 +68,7 @@ __export(payment_exports, {
|
|
|
68
68
|
resolveRecipient: () => resolveRecipient,
|
|
69
69
|
runWithMppxFailureCapture: () => runWithMppxFailureCapture,
|
|
70
70
|
settlementOverrideHeader: () => settlementOverrideHeader,
|
|
71
|
+
stripUnsignedX402PayloadFields: () => stripUnsignedX402PayloadFields,
|
|
71
72
|
usdToAtomic: () => usdToAtomic,
|
|
72
73
|
validateX402NetworkConfig: () => validateX402NetworkConfig,
|
|
73
74
|
verifyX402Request: () => verifyX402Request,
|
|
@@ -519,6 +520,17 @@ function classifyOrchestrationError(err) {
|
|
|
519
520
|
}
|
|
520
521
|
return null;
|
|
521
522
|
}
|
|
523
|
+
function stripUnsignedX402PayloadFields(payload) {
|
|
524
|
+
if (typeof payload !== "object" || payload === null) return payload;
|
|
525
|
+
const p = payload;
|
|
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;
|
|
533
|
+
}
|
|
522
534
|
async function processX402Settle({
|
|
523
535
|
x402Server,
|
|
524
536
|
payload,
|
|
@@ -539,6 +551,7 @@ async function processX402Settle({
|
|
|
539
551
|
if (!matchedRequirement) {
|
|
540
552
|
return { success: false, phase: "no_requirements", reason: "x402Server.buildPaymentRequirements returned empty" };
|
|
541
553
|
}
|
|
554
|
+
const facilitatorPayload = stripUnsignedX402PayloadFields(payload);
|
|
542
555
|
const resolvedTransportContext = transportContext ?? (() => {
|
|
543
556
|
const path = new URL(resourceMeta.url).pathname;
|
|
544
557
|
return { method: "POST", adapter: { getPath: () => path }, routePattern: path };
|
|
@@ -553,7 +566,7 @@ async function processX402Settle({
|
|
|
553
566
|
let verifyResult;
|
|
554
567
|
try {
|
|
555
568
|
verifyResult = await server.verifyPayment(
|
|
556
|
-
|
|
569
|
+
facilitatorPayload,
|
|
557
570
|
matchedRequirement,
|
|
558
571
|
enrichedExt,
|
|
559
572
|
resolvedTransportContext
|
|
@@ -568,7 +581,7 @@ async function processX402Settle({
|
|
|
568
581
|
}
|
|
569
582
|
try {
|
|
570
583
|
const settleResult = await server.settlePayment(
|
|
571
|
-
|
|
584
|
+
facilitatorPayload,
|
|
572
585
|
matchedRequirement,
|
|
573
586
|
enrichedExt,
|
|
574
587
|
resolvedTransportContext
|
|
@@ -1542,6 +1555,7 @@ function isSolanaNetwork(input) {
|
|
|
1542
1555
|
resolveRecipient,
|
|
1543
1556
|
runWithMppxFailureCapture,
|
|
1544
1557
|
settlementOverrideHeader,
|
|
1558
|
+
stripUnsignedX402PayloadFields,
|
|
1545
1559
|
usdToAtomic,
|
|
1546
1560
|
validateX402NetworkConfig,
|
|
1547
1561
|
verifyX402Request,
|