@agent-score/commerce 2.7.2 → 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 +29 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -4
- 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.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
|
+
* Reshape a decoded X-Payment payload into the lean canonical x402 PaymentPayload the
|
|
407
|
+
* facilitator's verify/settle endpoints validate: `{ x402Version, scheme, network, payload }`.
|
|
408
|
+
*
|
|
409
|
+
* agentscore-pay (and other x402 clients) transmit a richer wire shape: the chosen
|
|
410
|
+
* requirement is nested under `accepted` (which `verifyX402Request` reads for network/payTo),
|
|
411
|
+
* and the 402 challenge's `extensions` (Bazaar input schema) + `resource` blocks are echoed
|
|
412
|
+
* alongside the signed `payload`. None of that is part of the EIP-3009 signature; the
|
|
413
|
+
* signature covers only `payload.authorization`; but CDP's `/x402/verify` validates the
|
|
414
|
+
* paymentPayload against the `x402V2PaymentPayload` union, which requires top-level
|
|
415
|
+
* `scheme` + `network`: a payload that carries them only under `accepted` matches neither
|
|
416
|
+
* branch, and the echoed `extensions.bazaar.schema` bloats the body enough that CDP rejects
|
|
417
|
+
* it on larger schemas while tolerating small ones ("must match one of [x402V2PaymentPayload,
|
|
418
|
+
* x402V1PaymentPayload]"). Forwarding the four canonical fields only fixes it regardless of size.
|
|
419
|
+
*
|
|
420
|
+
* `scheme`/`network` are lifted out of `accepted`, falling back to any top-level values a
|
|
421
|
+
* canonical client already sent. The full `accepted`/`extensions`/`resource` stay on the wire
|
|
422
|
+
* for `verifyX402Request`; they are dropped only here, at the facilitator boundary. A payload
|
|
423
|
+
* that lacks the canonical pieces (unexpected shape) passes through untouched so it reaches the
|
|
424
|
+
* facilitator unchanged rather than silently mangled.
|
|
425
|
+
*/
|
|
426
|
+
declare function toCanonicalX402PaymentPayload(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, toCanonicalX402PaymentPayload, 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
|
+
* Reshape a decoded X-Payment payload into the lean canonical x402 PaymentPayload the
|
|
407
|
+
* facilitator's verify/settle endpoints validate: `{ x402Version, scheme, network, payload }`.
|
|
408
|
+
*
|
|
409
|
+
* agentscore-pay (and other x402 clients) transmit a richer wire shape: the chosen
|
|
410
|
+
* requirement is nested under `accepted` (which `verifyX402Request` reads for network/payTo),
|
|
411
|
+
* and the 402 challenge's `extensions` (Bazaar input schema) + `resource` blocks are echoed
|
|
412
|
+
* alongside the signed `payload`. None of that is part of the EIP-3009 signature; the
|
|
413
|
+
* signature covers only `payload.authorization`; but CDP's `/x402/verify` validates the
|
|
414
|
+
* paymentPayload against the `x402V2PaymentPayload` union, which requires top-level
|
|
415
|
+
* `scheme` + `network`: a payload that carries them only under `accepted` matches neither
|
|
416
|
+
* branch, and the echoed `extensions.bazaar.schema` bloats the body enough that CDP rejects
|
|
417
|
+
* it on larger schemas while tolerating small ones ("must match one of [x402V2PaymentPayload,
|
|
418
|
+
* x402V1PaymentPayload]"). Forwarding the four canonical fields only fixes it regardless of size.
|
|
419
|
+
*
|
|
420
|
+
* `scheme`/`network` are lifted out of `accepted`, falling back to any top-level values a
|
|
421
|
+
* canonical client already sent. The full `accepted`/`extensions`/`resource` stay on the wire
|
|
422
|
+
* for `verifyX402Request`; they are dropped only here, at the facilitator boundary. A payload
|
|
423
|
+
* that lacks the canonical pieces (unexpected shape) passes through untouched so it reaches the
|
|
424
|
+
* facilitator unchanged rather than silently mangled.
|
|
425
|
+
*/
|
|
426
|
+
declare function toCanonicalX402PaymentPayload(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, toCanonicalX402PaymentPayload, 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
|
+
toCanonicalX402PaymentPayload: () => toCanonicalX402PaymentPayload,
|
|
71
72
|
usdToAtomic: () => usdToAtomic,
|
|
72
73
|
validateX402NetworkConfig: () => validateX402NetworkConfig,
|
|
73
74
|
verifyX402Request: () => verifyX402Request,
|
|
@@ -519,6 +520,21 @@ function classifyOrchestrationError(err) {
|
|
|
519
520
|
}
|
|
520
521
|
return null;
|
|
521
522
|
}
|
|
523
|
+
function toCanonicalX402PaymentPayload(payload) {
|
|
524
|
+
if (typeof payload !== "object" || payload === null) return payload;
|
|
525
|
+
const p = payload;
|
|
526
|
+
const accepted = typeof p.accepted === "object" && p.accepted !== null ? p.accepted : void 0;
|
|
527
|
+
const scheme = p.scheme ?? accepted?.scheme;
|
|
528
|
+
const network = p.network ?? accepted?.network;
|
|
529
|
+
const inner = p.payload;
|
|
530
|
+
if (scheme === void 0 || network === void 0 || inner === void 0) return payload;
|
|
531
|
+
return {
|
|
532
|
+
x402Version: p.x402Version ?? 2,
|
|
533
|
+
scheme,
|
|
534
|
+
network,
|
|
535
|
+
payload: inner
|
|
536
|
+
};
|
|
537
|
+
}
|
|
522
538
|
async function processX402Settle({
|
|
523
539
|
x402Server,
|
|
524
540
|
payload,
|
|
@@ -539,6 +555,7 @@ async function processX402Settle({
|
|
|
539
555
|
if (!matchedRequirement) {
|
|
540
556
|
return { success: false, phase: "no_requirements", reason: "x402Server.buildPaymentRequirements returned empty" };
|
|
541
557
|
}
|
|
558
|
+
const canonicalPayload = toCanonicalX402PaymentPayload(payload);
|
|
542
559
|
const resolvedTransportContext = transportContext ?? (() => {
|
|
543
560
|
const path = new URL(resourceMeta.url).pathname;
|
|
544
561
|
return { method: "POST", adapter: { getPath: () => path }, routePattern: path };
|
|
@@ -553,7 +570,7 @@ async function processX402Settle({
|
|
|
553
570
|
let verifyResult;
|
|
554
571
|
try {
|
|
555
572
|
verifyResult = await server.verifyPayment(
|
|
556
|
-
|
|
573
|
+
canonicalPayload,
|
|
557
574
|
matchedRequirement,
|
|
558
575
|
enrichedExt,
|
|
559
576
|
resolvedTransportContext
|
|
@@ -568,7 +585,7 @@ async function processX402Settle({
|
|
|
568
585
|
}
|
|
569
586
|
try {
|
|
570
587
|
const settleResult = await server.settlePayment(
|
|
571
|
-
|
|
588
|
+
canonicalPayload,
|
|
572
589
|
matchedRequirement,
|
|
573
590
|
enrichedExt,
|
|
574
591
|
resolvedTransportContext
|
|
@@ -1542,6 +1559,7 @@ function isSolanaNetwork(input) {
|
|
|
1542
1559
|
resolveRecipient,
|
|
1543
1560
|
runWithMppxFailureCapture,
|
|
1544
1561
|
settlementOverrideHeader,
|
|
1562
|
+
toCanonicalX402PaymentPayload,
|
|
1545
1563
|
usdToAtomic,
|
|
1546
1564
|
validateX402NetworkConfig,
|
|
1547
1565
|
verifyX402Request,
|