@devlab.group/agent-commerce 2.0.0 → 2.2.0
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/README.md +137 -56
- package/dist/ap2.d.ts +2 -2
- package/dist/ap2.js +4 -3
- package/dist/ap2.js.map +1 -1
- package/dist/{authorization-BpbWGGrf.d.ts → authorization-CMkIuAkO.d.ts} +1 -1
- package/dist/chunk-2CJNA7MS.js +8 -0
- package/dist/chunk-2CJNA7MS.js.map +1 -0
- package/dist/{chunk-CKJRITWY.js → chunk-5ZYXBCDX.js} +3 -3
- package/dist/{chunk-CKJRITWY.js.map → chunk-5ZYXBCDX.js.map} +1 -1
- package/dist/{chunk-3LUJHVKX.js → chunk-6Z2H53CG.js} +5 -4
- package/dist/chunk-6Z2H53CG.js.map +1 -0
- package/dist/{chunk-53WXXIPR.js → chunk-7ZMMXZ4G.js} +6 -10
- package/dist/chunk-7ZMMXZ4G.js.map +1 -0
- package/dist/{chunk-HOZA3IWP.js → chunk-ES3V6ECS.js} +16 -6
- package/dist/chunk-ES3V6ECS.js.map +1 -0
- package/dist/chunk-HNRDZLSN.js +1398 -0
- package/dist/chunk-HNRDZLSN.js.map +1 -0
- package/dist/{chunk-SYEGCNJZ.js → chunk-IEW7NSP2.js} +23 -5
- package/dist/chunk-IEW7NSP2.js.map +1 -0
- package/dist/chunk-KA2AX5FH.js +44 -0
- package/dist/chunk-KA2AX5FH.js.map +1 -0
- package/dist/chunk-Y4RE3XYF.js +581 -0
- package/dist/chunk-Y4RE3XYF.js.map +1 -0
- package/dist/cli/ap2-MBMQHFX4.js +678 -0
- package/dist/cli/ap2-MBMQHFX4.js.map +1 -0
- package/dist/cli/chunk-2ZZOGI5I.js +1352 -0
- package/dist/cli/chunk-2ZZOGI5I.js.map +1 -0
- package/dist/cli/chunk-3EQBCFZY.js +53 -0
- package/dist/cli/chunk-3EQBCFZY.js.map +1 -0
- package/dist/cli/chunk-3M6U7ILB.js +8 -0
- package/dist/cli/chunk-3M6U7ILB.js.map +1 -0
- package/dist/cli/chunk-3MGAJ5FX.js +70 -0
- package/dist/cli/chunk-3MGAJ5FX.js.map +1 -0
- package/dist/cli/chunk-5K4XEAZV.js +113 -0
- package/dist/cli/chunk-5K4XEAZV.js.map +1 -0
- package/dist/cli/chunk-7JNYFUT3.js +256 -0
- package/dist/cli/chunk-7JNYFUT3.js.map +1 -0
- package/dist/cli/chunk-AA3FIEAR.js +27 -0
- package/dist/cli/chunk-AA3FIEAR.js.map +1 -0
- package/dist/cli/chunk-FHCFR2GS.js +17 -0
- package/dist/cli/chunk-FHCFR2GS.js.map +1 -0
- package/dist/cli/chunk-FRMLWGSS.js +8 -0
- package/dist/cli/chunk-FRMLWGSS.js.map +1 -0
- package/dist/cli/chunk-KLX2YZDG.js +1400 -0
- package/dist/cli/chunk-KLX2YZDG.js.map +1 -0
- package/dist/cli/chunk-NSPPEF5M.js +334 -0
- package/dist/cli/chunk-NSPPEF5M.js.map +1 -0
- package/dist/cli/chunk-OSTCU6ZK.js +44 -0
- package/dist/cli/chunk-OSTCU6ZK.js.map +1 -0
- package/dist/cli/chunk-QQ3WY5L3.js +271 -0
- package/dist/cli/chunk-QQ3WY5L3.js.map +1 -0
- package/dist/cli/chunk-RWVPYAKC.js +1742 -0
- package/dist/cli/chunk-RWVPYAKC.js.map +1 -0
- package/dist/cli/chunk-SPAYKVUP.js +118 -0
- package/dist/cli/chunk-SPAYKVUP.js.map +1 -0
- package/dist/cli/chunk-SS3QFF5N.js +614 -0
- package/dist/cli/chunk-SS3QFF5N.js.map +1 -0
- package/dist/cli/chunk-TPC4EJLT.js +11 -0
- package/dist/cli/chunk-TPC4EJLT.js.map +1 -0
- package/dist/cli/config-4IBGVFSP.js +11 -0
- package/dist/cli/config-4IBGVFSP.js.map +1 -0
- package/dist/cli/index.js +822 -3392
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/mcp-CNWQ2MOE.js +559 -0
- package/dist/cli/mcp-CNWQ2MOE.js.map +1 -0
- package/dist/cli/near-5AY3HWYF.js +58 -0
- package/dist/cli/near-5AY3HWYF.js.map +1 -0
- package/dist/cli/provider-4BQDH56Y.js +396 -0
- package/dist/cli/provider-4BQDH56Y.js.map +1 -0
- package/dist/cli/run-5MB2D45X.js +7286 -0
- package/dist/cli/run-5MB2D45X.js.map +1 -0
- package/dist/cli/svm-3MMYFPC7.js +33 -0
- package/dist/cli/svm-3MMYFPC7.js.map +1 -0
- package/dist/cli/x402-NKR3WQDQ.js +96 -0
- package/dist/cli/x402-NKR3WQDQ.js.map +1 -0
- package/dist/{constants-BSBRlKRR.d.ts → constants-nackLItD.d.ts} +2 -1
- package/dist/index.d.ts +61 -40
- package/dist/index.js +2642 -2205
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.ts +3 -3
- package/dist/mcp.js +15 -20
- package/dist/mcp.js.map +1 -1
- package/dist/mpp.d.ts +12 -5
- package/dist/mpp.js +69 -65
- package/dist/mpp.js.map +1 -1
- package/dist/near-D6C42VPE.js +58 -0
- package/dist/near-D6C42VPE.js.map +1 -0
- package/dist/networks-olfflCI_.d.ts +38 -0
- package/dist/{protocol-adapter-DonxfAwa.d.ts → protocol-adapter-CfxU8Z2T.d.ts} +2 -2
- package/dist/{runtime-CiYbgGpi.d.ts → runtime-7vLNYvmU.d.ts} +25 -3
- package/dist/svm-QEUAUNPQ.js +33 -0
- package/dist/svm-QEUAUNPQ.js.map +1 -0
- package/dist/x402.d.ts +76 -64
- package/dist/x402.js +13 -4
- package/dist/x402.js.map +1 -1
- package/package.json +22 -2
- package/dist/chunk-3LUJHVKX.js.map +0 -1
- package/dist/chunk-53WXXIPR.js.map +0 -1
- package/dist/chunk-HOZA3IWP.js.map +0 -1
- package/dist/chunk-RKBGCPCK.js +0 -733
- package/dist/chunk-RKBGCPCK.js.map +0 -1
- package/dist/chunk-SYEGCNJZ.js.map +0 -1
- package/dist/chunk-TWRUNWDR.js +0 -265
- package/dist/chunk-TWRUNWDR.js.map +0 -1
- package/dist/{payment-flow-DCS882tR.d.ts → guardrails-CX_jYXvZ.d.ts} +8 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/protocols/mcp/descriptor.ts","../../src/protocols/mcp/tool-mapping.ts","../../src/protocols/mcp/result-mapping.ts","../../src/protocols/mcp/adapter.ts"],"names":[],"mappings":";;;;;;;;AAUA,IAAM,kBAAA,GAAqB,CAAA,EAAG,4BAA4B,CAAA,EAAA,EAAK,uBAAuB,CAAA,CAAA;AAGtF,IAAM,gBAAA,GAAsC,CAAC,YAAA,EAAc,YAAY,CAAA;AAUhE,IAAM,eAAA,GAAqC;AAAA,EAChD,WAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,aAAA;AAAA,EACA,aAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,kCAAA;AAAA,EACA,OAAA;AAAA,EACA,0BAAA;AAAA,EACA,eAAA;AAAA,EACA,UAAA;AAAA,EACA,eAAA;AAAA,EACA,YAAA;AAAA,EACA,oBAAA;AAAA;AAAA,EAEA,+CAAA;AAAA,EACA;AACF,CAAA;AAEO,SAAS,gBAAgB,qBAAA,EAAkD;AAChF,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,KAAA;AAAA,IACN,IAAA,EAAM,UAAA;AAAA,IACN,qBAAA;AAAA,IACA,aAAA,EAAe,kBAAA;AAAA,IACf,YAAA,EAAc,gBAAA;AAAA,IACd,MAAA,EAAQ,QAAA;AAAA,IACR,WAAA,EAAa;AAAA,GACf;AACF;;;ACnCO,SAAS,gBAAgB,EAAA,EAAqB;AACnD,EAAA,OAAO,qBAAA,CAAsB,KAAK,EAAE,CAAA;AACtC;AAEA,SAAS,eAAe,QAAA,EAAqC;AAC3D,EAAA,OAAO,QAAA,CAAS,QAAQ,IAAA,KAAS,MAAA;AACnC;AAIA,SAAS,qBAAqB,QAAA,EAA2D;AACvF,EAAA,OAAO,QAAA,CAAS,eAAe,CAAC,CAAA;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OAAO,CAAC,CAAA;AACnE,EAAA,IAAI,QAAA,CAAS,SAAS,IAAA,EAAM;AAC1B,IAAA,WAAA,MAAiB,KAAA,IAAS,SAAS,IAAA,EAAM;AACvC,MAAA,IAAI,IAAI,SAAA,EAAW;AACnB,MAAA,GAAA,CAAI,MAAM,KAAK,CAAA;AAAA,IACjB;AAAA,EACF;AACA,EAAA,GAAA,CAAI,GAAA,EAAI;AACV;AAGA,SAAS,eAAA,CACP,MACA,QAAA,EAC+B;AAC/B,EAAA,MAAM,MAAA,GAAS,QAAA,CAAS,cAAA,CAAe,CAAC,CAAA;AACxC,EAAA,IAAI,WAAW,MAAA,EAAQ;AACrB,IAAA,MAAM,OAAA,GAAU,wBAAA,CAAyB,IAAA,GAAO,yBAAyB,CAAC,CAAA;AAC1E,IAAA,IAAI,OAAA,KAAY,MAAA,EAAW,OAAO,EAAE,QAAQ,OAAA,EAAQ;AAAA,EACtD;AACA,EAAA,MAAM,UAAA,GAAa,OAAO,2BAA2B,CAAA;AACrD,EAAA,IAAI,MAAA,KAAW,KAAA,IAAS,QAAA,CAAS,UAAU,CAAA,EAAG;AAE5C,IAAA,OAAO,EAAE,MAAA,EAAQ,OAAA,EAAS,IAAA,CAAK,SAAA,CAAU,UAAU,CAAA,EAAE;AAAA,EACvD;AACA,EAAA,OAAO,MAAA;AACT;AAEO,SAAS,iBAAiB,OAAA,EAAkD;AACjF,EAAA,OAAO,IAAI,mBAAmB,OAAO,CAAA;AACvC","file":"mcp-CNWQ2MOE.js","sourcesContent":["/**\n * Adapter self-description. `supportedSpec` lists the modern revision and\n * the newest 2025-era revision. The SDK's legacy fallback also accepts older\n * 2025-era revisions.\n */\nimport { LATEST_PROTOCOL_VERSION } from '@modelcontextprotocol/server';\nimport type { AdapterDescriptor } from '../../core';\nimport { MCP_MODERN_PROTOCOL_REVISION } from './constants';\n\n// List the modern revision followed by the SDK's latest legacy revision\nconst MCP_SUPPORTED_SPEC = `${MCP_MODERN_PROTOCOL_REVISION}, ${LATEST_PROTOCOL_VERSION}`;\n\n// Tool-oriented capabilities this adapter implements\nconst MCP_CAPABILITIES: readonly string[] = ['tools/list', 'tools/call'];\n\n/**\n * MCP surfaces this adapter does not implement, listed so its descriptor never\n * implies blanket protocol compatibility.\n *\n * `dns-rebinding-protection` is delegated rather than missing: the gateway's\n * `onRequest` hook validates Host and Origin for `/mcp` (see adapter.ts), and\n * the adapter provides none on its own.\n */\nexport const MCP_UNSUPPORTED: readonly string[] = [\n 'resources',\n 'prompts',\n 'sampling',\n 'completions',\n 'elicitation',\n 'roots',\n 'logging',\n 'notifications/tools/list_changed',\n 'tasks',\n 'dns-rebinding-protection',\n 'authorization',\n 'sessions',\n 'subscriptions',\n 'pagination',\n 'HTTP+SSE transport',\n // mppx reads challenges and refusals from tool-result `_meta`.\n 'MPP payment-required as JSON-RPC error -32042',\n 'MPP verification failure as JSON-RPC error -32043',\n];\n\nexport function buildDescriptor(implementationVersion: string): AdapterDescriptor {\n return {\n name: 'mcp',\n kind: 'protocol',\n implementationVersion,\n supportedSpec: MCP_SUPPORTED_SPEC,\n capabilities: MCP_CAPABILITIES,\n status: 'stable',\n unsupported: MCP_UNSUPPORTED,\n };\n}\n","/**\n * Maps a canonical `CommerceResource` to an MCP `Tool`: the tool name is the\n * resource id, the description carries a price notice for a paid resource,\n * and the input schema is the canonical JSON Schema plus the reserved\n * `_payment` and `_authorization` properties the resource accepts\n */\n\nimport type { JSONObject, Tool } from '@modelcontextprotocol/server';\nimport {\n AUTHORIZATION_INPUT_FIELD,\n type CommerceResource,\n PAYMENT_INPUT_FIELD,\n type PaymentMethodName,\n} from '../../core';\nimport { isRecord } from '../../core/is-record';\nimport { MPP_MCP_CREDENTIAL_META_KEY } from '../../payments/mpp/transport';\nimport { X402_MCP_PAYMENT_META_KEY } from '../../payments/x402/transport';\nimport { MCP_TOOL_NAME_PATTERN } from './constants';\n\nexport function isValidToolName(id: string): boolean {\n return MCP_TOOL_NAME_PATTERN.test(id);\n}\n\nfunction isPaidResource(resource: CommerceResource): boolean {\n return resource.pricing.type !== 'free';\n}\n\n// The rail a `_payment` proof is labeled with (see `extractReservedInputFields`),\n// `undefined` when the resource lists none\nfunction primaryPaymentMethod(resource: CommerceResource): PaymentMethodName | undefined {\n return resource.paymentMethods[0];\n}\n\n/** Describe the selected rail's `_meta` proof and `_payment` fallback */\nexport function proofCarriers(method: PaymentMethodName | undefined): string {\n const field = `the \"${PAYMENT_INPUT_FIELD}\" argument`;\n if (method === 'x402') return `_meta[\"${X402_MCP_PAYMENT_META_KEY}\"] or ${field}`;\n if (method === 'mpp') return `_meta[\"${MPP_MCP_CREDENTIAL_META_KEY}\"] or ${field}`;\n return field;\n}\n\n// How to supply a proof, generic when the resource names no rail\nfunction paymentProofNote(resource: CommerceResource): string {\n const method = primaryPaymentMethod(resource);\n const rail = method !== undefined ? `an ${method}` : 'a';\n return `Requires ${rail} payment proof in ${proofCarriers(method)}, built from the payment-required response.`;\n}\n\n// Tell callers to omit `_payment` when a wrapper supplies `_meta`\nconst OMIT_NOTE = 'Omit it when the client sends the proof in _meta.';\n\n/**\n * Description for the reserved `_payment` input property, in the proof\n * encoding of the resource's own rail\n */\nfunction paymentInputFieldDescription(resource: CommerceResource): string {\n const method = primaryPaymentMethod(resource);\n if (method === 'x402') {\n return `x402 payment proof (base64 PAYMENT-SIGNATURE value) for a previous payment-required response. ${OMIT_NOTE}`;\n }\n if (method === 'mpp') {\n return `MPP credential (the full \"Authorization: Payment ...\" value) for the challenge in a previous payment-required response. ${OMIT_NOTE}`;\n }\n if (method !== undefined) {\n return `${method} payment proof (base64-encoded) returned from a previous payment-required response.`;\n }\n return 'Payment proof returned from a previous payment-required response.';\n}\n\n// The authorization methods the resource requires, empty when it requires none\nfunction requiredAuthorization(resource: CommerceResource): readonly string[] {\n return resource.authorization?.required ?? [];\n}\n\nfunction authorizationNote(resource: CommerceResource): string {\n const methods = requiredAuthorization(resource);\n return methods.length > 0\n ? ` Also requires ${methods.join(' and ')} authorization in the \"${AUTHORIZATION_INPUT_FIELD}\" input field.`\n : '';\n}\n\n/**\n * Tool description. A paid resource gets a price notice appended, so an agent\n * sees the cost before calling, not only in the input schema.\n */\nexport function buildToolDescription(resource: CommerceResource): string {\n const base = resource.description ?? resource.name;\n switch (resource.pricing.type) {\n case 'free':\n return base;\n case 'fixed': {\n const { amount, currency } = resource.pricing;\n return `${base} Costs ${amount} ${currency} per call. ${paymentProofNote(resource)}${authorizationNote(resource)}`;\n }\n case 'dynamic':\n return `${base} Requires payment (amount determined at request time). ${paymentProofNote(resource)}${authorizationNote(resource)}`;\n }\n}\n\n/**\n * Builds the MCP `Tool.inputSchema` from the canonical `CommerceResource.inputSchema`.\n *\n * Every keyword is carried through except that `type` is forced to the\n * `'object'` MCP requires, `properties` keeps only object-valued entries and\n * `required` only strings. A paid resource gains the optional `_payment`\n * string property, and a resource requiring authorization the optional\n * `_authorization` object. Both are declared because a resource's input schema\n * is closed by default, and a client that validates arguments against it\n * would otherwise refuse to send them.\n */\nexport function buildInputSchema(resource: CommerceResource): Tool['inputSchema'] {\n const base = resource.inputSchema;\n const baseIsObject = isRecord(base);\n\n // Keep object-valued property schemas from the resource's config JSON\n const basePropertyEntries: readonly [string, JSONObject][] =\n baseIsObject && isRecord(base.properties)\n ? Object.entries(base.properties).filter((entry): entry is [string, JSONObject] =>\n isRecord(entry[1]),\n )\n : [];\n const properties: Record<string, JSONObject> = Object.fromEntries(basePropertyEntries);\n\n // Both overwrite a resource-declared property of the same name; config\n // rejects that collision at load time\n if (isPaidResource(resource)) {\n properties[PAYMENT_INPUT_FIELD] = {\n type: 'string',\n description: paymentInputFieldDescription(resource),\n };\n }\n const methods = requiredAuthorization(resource);\n if (methods.length > 0) {\n properties[AUTHORIZATION_INPUT_FIELD] = {\n type: 'object',\n description:\n 'Authorization this resource requires in addition to payment: the method and its serialized proof.',\n properties: {\n method: { type: 'string', enum: [...methods] },\n payload: { type: 'string', minLength: 1 },\n },\n required: ['method', 'payload'],\n };\n }\n\n const required =\n baseIsObject && Array.isArray(base.required)\n ? base.required.filter((v): v is string => typeof v === 'string')\n : [];\n\n const extra = baseIsObject\n ? Object.fromEntries(\n Object.entries(base).filter(\n ([key]) => key !== 'type' && key !== 'properties' && key !== 'required',\n ),\n )\n : {};\n\n return {\n ...extra,\n type: 'object',\n properties,\n ...(required.length > 0 ? { required } : {}),\n };\n}\n","/**\n * Maps pipeline outcomes and errors to MCP tool results through the core wire\n * helpers (`toErrorEnvelope`, `toPaymentRequiredEnvelope`,\n * `toDeliverySummary`). The A2A adapter uses all three and the HTTP route the\n * two envelopes, so each shape is defined once.\n */\n\nimport type { CallToolResult } from '@modelcontextprotocol/server';\nimport {\n type CommerceError,\n DELIVERY_SUMMARY_META_KEY,\n type DeliveredOutcome,\n type ExecutionOutcome,\n type PaymentMethodName,\n type PaymentRequiredOutcome,\n toDeliverySummary,\n toErrorEnvelope,\n toPaymentRequiredEnvelope,\n} from '../../core';\nimport { isRecord } from '../../core/is-record';\nimport {\n MPP_MCP_PAYMENT_REQUIRED_META_KEY,\n MPP_MCP_RECEIPT_META_KEY,\n mcpPaymentRequired,\n receiptObject,\n} from '../../payments/mpp/transport';\nimport {\n settlementFailure,\n settlementResponse,\n settlementResponseFromDetails,\n X402_MCP_ERROR_META_KEY,\n X402_MCP_PAYMENT_RESPONSE_META_KEY,\n x402ErrorCode,\n} from '../../payments/x402/transport';\nimport { proofCarriers } from './tool-mapping';\n\nfunction toRecord(value: object): Record<string, unknown> {\n return value as Record<string, unknown>;\n}\n\nfunction deliveredResult(outcome: DeliveredOutcome): CallToolResult {\n const body = outcome.body;\n const text = typeof body === 'string' ? body : JSON.stringify(body ?? null);\n const payment = outcome.payment;\n const receipt =\n payment?.provider === 'mpp' ? receiptObject(payment.metadata?.['receipt']) : undefined;\n return {\n content: [{ type: 'text', text }],\n ...(isRecord(body) ? { structuredContent: body } : {}),\n _meta: {\n [DELIVERY_SUMMARY_META_KEY]: toRecord(toDeliverySummary(outcome)),\n ...(payment?.provider === 'x402'\n ? { [X402_MCP_PAYMENT_RESPONSE_META_KEY]: settlementResponse(payment) }\n : {}),\n ...(receipt !== undefined ? { [MPP_MCP_RECEIPT_META_KEY]: receipt } : {}),\n },\n };\n}\n\n// The x402 MCP transport requires the first text block to repeat\n// `structuredContent` as JSON; the second gives readers a short explanation\nfunction structuredError(\n structured: Record<string, unknown>,\n sentence: string,\n meta?: Record<string, unknown>,\n): CallToolResult {\n return {\n isError: true,\n content: [\n { type: 'text', text: JSON.stringify(structured) },\n { type: 'text', text: sentence },\n ],\n structuredContent: structured,\n ...(meta !== undefined ? { _meta: meta } : {}),\n };\n}\n\n// Put x402's PaymentRequired fields beside the gateway error envelope so\n// x402 clients can read the challenge from `structuredContent`\nfunction withX402Challenge(\n envelope: Record<string, unknown>,\n challenge: Record<string, unknown>,\n): Record<string, unknown> {\n return { ...challenge, ...envelope };\n}\n\nfunction paymentRequiredResult(outcome: PaymentRequiredOutcome): CallToolResult {\n const envelope = toPaymentRequiredEnvelope(outcome);\n const p = envelope.payment;\n const x402Required = p.provider === 'x402' ? p.envelope : undefined;\n const structured =\n x402Required !== undefined\n ? withX402Challenge(toRecord(envelope), x402Required)\n : toRecord(envelope);\n const mppRequired = p.provider === 'mpp' ? mcpPaymentRequired(p.envelope) : undefined;\n let meta: Record<string, unknown> | undefined;\n if (x402Required !== undefined) meta = { [X402_MCP_ERROR_META_KEY]: x402Required };\n else if (mppRequired !== undefined) meta = { [MPP_MCP_PAYMENT_REQUIRED_META_KEY]: mppRequired };\n return structuredError(\n structured,\n // A challenge with several offers names no single destination\n `Payment required: ${p.amount} ${p.currency}${p.destination !== undefined ? ` to ${p.destination}` : ''} for resource \"${outcome.resourceId}\". Retry with an ${p.provider} payment proof in ${proofCarriers(p.provider)}.`,\n meta,\n );\n}\n\n/** A tool result for an error; `rail` is the payment method the call used, if any */\nexport function errorResult(error: CommerceError, rail?: PaymentMethodName): CallToolResult {\n const envelope = toErrorEnvelope(error);\n const details = error.details;\n const challenge = details?.['challenge'];\n // Include the rail's new challenge when a 402 refusal supplies one\n const refused = error.httpStatus === 402 && isRecord(challenge);\n const x402Required =\n rail === 'x402' && refused\n ? {\n ...challenge,\n error: x402ErrorCode(error.code, details?.['reason'], details?.['network']),\n }\n : undefined;\n const structured =\n x402Required !== undefined\n ? withX402Challenge(toRecord(envelope), x402Required)\n : toRecord(envelope);\n let meta: Record<string, unknown> | undefined;\n if (rail === 'x402') {\n const settlement =\n error.code === 'PAYMENT_SETTLEMENT_FAILED'\n ? settlementFailure(details)\n : settlementResponseFromDetails(details);\n if (settlement !== undefined || x402Required !== undefined) {\n meta = {\n ...(x402Required !== undefined ? { [X402_MCP_ERROR_META_KEY]: x402Required } : {}),\n ...(settlement !== undefined ? { [X402_MCP_PAYMENT_RESPONSE_META_KEY]: settlement } : {}),\n };\n }\n } else if (rail === 'mpp' && refused) {\n // MPP error results carry a challenge but no receipt\n const required = mcpPaymentRequired(challenge, {\n code: error.code,\n reason: details?.['reason'],\n detail: error.message,\n });\n if (required !== undefined) meta = { [MPP_MCP_PAYMENT_REQUIRED_META_KEY]: required };\n }\n return structuredError(structured, `${envelope.code}: ${envelope.message}`, meta);\n}\n\nexport function mapOutcome(outcome: ExecutionOutcome): CallToolResult {\n return outcome.kind === 'delivered' ? deliveredResult(outcome) : paymentRequiredResult(outcome);\n}\n","/**\n * MCP protocol adapter.\n *\n * One MCP tool per mcp-exposed canonical resource. Every `tools/call` builds a\n * `CanonicalRequest` and goes through `context.pipeline.execute()`. This\n * adapter reads payment carriers but leaves verification, settlement and\n * merchant calls to the pipeline.\n *\n * The SDK's `createMcpHandler` serves `2026-07-28` over Streamable HTTP and\n * routes 2025-era requests through its stateless fallback. It creates a\n * low-level `Server` for each request. This adapter converts the gateway's\n * Node request and response to the web types the handler uses, without adding\n * `@modelcontextprotocol/node` as a peer.\n *\n * Tools are registered on the low-level `Server`, not through\n * `McpServer.registerTool`, whose `inputSchema` accepts only a Zod schema or\n * shape. `CommerceResource.inputSchema` and the MCP wire `Tool.inputSchema`\n * are both JSON Schema, so building `Tool` objects directly carries the schema\n * through with no lossy conversion. The SDK marks `Server` `@deprecated` but\n * still documents it for advanced cases such as this one.\n *\n * The gateway's `onRequest` hook validates Host and Origin for every route,\n * including `/mcp`. This adapter has no separate allowlist. When mounted\n * outside the gateway, it provides no Host or Origin checks; its descriptor\n * therefore lists `dns-rebinding-protection` as unsupported.\n */\nimport type { IncomingMessage, ServerResponse } from 'node:http';\nimport {\n type CallToolResult,\n createMcpHandler,\n type McpHttpHandler,\n ProtocolError,\n ProtocolErrorCode,\n Server,\n type Tool,\n} from '@modelcontextprotocol/server';\nimport {\n type AdapterDescriptor,\n type AdapterHealth,\n type CanonicalRequest,\n CommerceError,\n type CommerceResource,\n extractReservedInputFields,\n type HttpProtocolAdapter,\n type PaymentSubmission,\n type ProtocolAdapterContext,\n toCommerceError,\n} from '../../core';\nimport { toLogInfo } from '../../core/errors';\nimport { isRecord } from '../../core/is-record';\nimport { MPP_MCP_CREDENTIAL_META_KEY } from '../../payments/mpp/transport';\nimport { X402_MCP_PAYMENT_META_KEY, x402McpPaymentSubmission } from '../../payments/x402/transport';\nimport { PACKAGE_VERSION } from '../../version';\nimport { readCappedBody } from '../http';\nimport { MCP_MODERN_PROTOCOL_REVISION, MCP_TOOL_NAME_PATTERN } from './constants';\nimport { buildDescriptor } from './descriptor';\nimport { errorResult, mapOutcome } from './result-mapping';\nimport { buildInputSchema, buildToolDescription, isValidToolName } from './tool-mapping';\n\nexport interface McpAdapterOptions {\n /** Path prefix the gateway mounts this adapter at. Default '/mcp' */\n readonly mountPath?: string;\n /** MCP `Implementation.name` reported during initialize */\n readonly serverName?: string;\n /** MCP `Implementation.version` reported during initialize. Default: this package's version */\n readonly serverVersion?: string;\n}\n\ninterface RegisteredTool {\n readonly resource: CommerceResource;\n readonly tool: Tool;\n}\n\ninterface SkippedResource {\n readonly id: string;\n readonly reason: string;\n}\n\nconst DEFAULT_MOUNT_PATH = '/mcp';\nconst DEFAULT_SERVER_NAME = 'agent-commerce';\n\n/**\n * The SDK can dispatch several `tools/call` requests in one JSON-RPC batch\n * before earlier calls settle. One POST can therefore start concurrent\n * `pipeline.execute()` calls. Limit active calls to 8 per adapter instance.\n */\nconst MAX_CONCURRENT_TOOL_CALLS = 8;\n\n// A second line behind the gateway mount's cap, bounding what this adapter\n// buffers if it is mounted without that guard\nconst MAX_REQUEST_BODY_BYTES = 256 * 1024;\n\n/**\n * Bounds the queue behind the semaphore, per adapter instance. Without it an\n * oversized batch would queue in full and then run in full. 64 is 8x\n * MAX_CONCURRENT_TOOL_CALLS, room for a legitimate burst; calls beyond it fail\n * fast with GATEWAY_BUSY and reach no backend.\n */\nconst MAX_QUEUED_TOOL_CALLS = 64;\n\n// Batch revision used by the SDK when no protocol-version header is sent\nconst MCP_BATCH_PROTOCOL_REVISION = '2025-03-26';\n\n// The tool list is public and stable until restart; cache it for a minute\nconst TOOLS_LIST_CACHE_HINT = { ttlMs: 60_000, cacheScope: 'public' } as const;\n\nclass McpProtocolAdapter implements HttpProtocolAdapter {\n readonly name = 'mcp' as const;\n readonly mountPath: string;\n readonly descriptor: AdapterDescriptor;\n\n private readonly serverName: string;\n private readonly serverVersion: string;\n\n private context: ProtocolAdapterContext | undefined;\n private started = false;\n private tools: readonly RegisteredTool[] = [];\n private toolsByResourceId: ReadonlyMap<string, CommerceResource> = new Map();\n private skipped: readonly SkippedResource[] = [];\n private handler: McpHttpHandler | undefined;\n\n // Counting semaphore on `pipeline.execute()`. It lives on the adapter, not\n // the request, so the cap holds across concurrent `/mcp` requests as well\n // as within one batch.\n private inFlightToolCalls = 0;\n private readonly toolCallWaiters: Array<() => void> = [];\n\n constructor(options: McpAdapterOptions = {}) {\n this.mountPath = options.mountPath ?? DEFAULT_MOUNT_PATH;\n this.serverName = options.serverName ?? DEFAULT_SERVER_NAME;\n this.serverVersion = options.serverVersion ?? PACKAGE_VERSION;\n this.descriptor = buildDescriptor(PACKAGE_VERSION);\n }\n\n async start(context: ProtocolAdapterContext): Promise<void> {\n this.context = context;\n this.started = false;\n\n let resources: readonly CommerceResource[] = [];\n try {\n resources = context.resources.listExposedVia('mcp');\n } catch (err) {\n context.logger.error(\n { err: toLogInfo(err) },\n 'mcp adapter: failed to list mcp-exposed resources',\n );\n resources = [];\n }\n\n const tools: RegisteredTool[] = [];\n const toolsByResourceId = new Map<string, CommerceResource>();\n const skipped: SkippedResource[] = [];\n\n for (const resource of resources) {\n try {\n if (!isValidToolName(resource.id)) {\n skipped.push({\n id: resource.id,\n reason: `resource id is not a legal MCP tool name (must match ${MCP_TOOL_NAME_PATTERN.source})`,\n });\n continue;\n }\n if (toolsByResourceId.has(resource.id)) {\n skipped.push({ id: resource.id, reason: 'duplicate tool name' });\n continue;\n }\n const tool: Tool = {\n name: resource.id,\n description: buildToolDescription(resource),\n inputSchema: buildInputSchema(resource),\n };\n tools.push({ resource, tool });\n toolsByResourceId.set(resource.id, resource);\n } catch (err) {\n skipped.push({\n id: resource.id,\n reason: `failed to build MCP tool: ${toCommerceError(err).message}`,\n });\n }\n }\n\n for (const s of skipped) {\n context.logger.warn({ resourceId: s.id, reason: s.reason }, 'mcp adapter: resource skipped');\n }\n\n this.tools = tools;\n this.toolsByResourceId = toolsByResourceId;\n this.skipped = skipped;\n // Route 2025-era requests through the SDK's stateless fallback\n this.handler = createMcpHandler(\n (ctx) => this.buildServer(ctx.requestInfo?.signal ?? new AbortController().signal),\n {\n legacy: 'stateless',\n // Reporting only: a request the SDK rejects is already answered\n onerror: (err) => context.logger.debug({ err: toLogInfo(err) }, 'mcp adapter: SDK error'),\n },\n );\n this.started = true;\n\n context.logger.info(\n {\n mountPath: this.mountPath,\n toolCount: tools.length,\n skippedCount: skipped.length,\n },\n 'mcp adapter started',\n );\n }\n\n async handleHttp(req: IncomingMessage, res: ServerResponse): Promise<void> {\n try {\n if (!this.started || !this.context || !this.handler) {\n this.writeJsonRpcError(res, 503, 'MCP adapter is not running.');\n return;\n }\n if (req.method !== 'POST') {\n this.writeJsonRpcError(res, 405, 'Method not allowed. This endpoint only accepts POST.');\n return;\n }\n\n // Aborted when the response closes. `handleToolCall` checks it only\n // before `pipeline.execute()`: a call that may already have settled\n // must finish, or the buyer is charged for nothing.\n const abortController = new AbortController();\n res.once('close', () => abortController.abort());\n const read = await readCappedBody(req, MAX_REQUEST_BODY_BYTES);\n if (read.kind === 'too-large') {\n this.writeJsonRpcError(\n res,\n 413,\n `Request body exceeds the ${MAX_REQUEST_BODY_BYTES}-byte limit.`,\n );\n return;\n }\n if (read.kind !== 'ok') {\n this.writeJsonRpcError(res, 400, 'Could not read the request body.');\n return;\n }\n const body = parseJson(read.text);\n const version = req.headers['mcp-protocol-version'];\n if (Array.isArray(body) && version !== undefined && version !== MCP_BATCH_PROTOCOL_REVISION) {\n this.writeJsonRpcError(\n res,\n 400,\n `Invalid Request: JSON-RPC batches are supported only in MCP ${MCP_BATCH_PROTOCOL_REVISION}.`,\n );\n return;\n }\n const malformed = isModernRequest(req) ? undefined : malformedToolCall(body);\n if (malformed !== undefined) {\n this.writeJsonRpcError(res, 200, malformed.message, -32602, malformed.id);\n return;\n }\n const response = await this.handler.fetch(\n toWebRequest(req, read.text, abortController.signal),\n );\n await writeWebResponse(response, res);\n } catch (err) {\n this.context?.logger.error({ err: toLogInfo(err) }, 'mcp adapter: request handling failed');\n this.writeJsonRpcError(res, 500, 'Internal server error.');\n }\n }\n\n async health(): Promise<AdapterHealth> {\n const checkedAt = this.context?.clock.nowIso() ?? new Date().toISOString();\n if (!this.started || !this.context) {\n return { status: 'fail', detail: 'MCP adapter has not been started.', checkedAt };\n }\n const toolCount = this.tools.length;\n if (this.skipped.length > 0) {\n const detail = `${toolCount} tool(s) registered; ${this.skipped.length} resource(s) skipped: ${this.skipped\n .map((s) => `${s.id} (${s.reason})`)\n .join('; ')}`;\n return { status: 'warn', detail, checkedAt };\n }\n return { status: 'pass', detail: `${toolCount} tool(s) registered.`, checkedAt };\n }\n\n async stop(): Promise<void> {\n this.started = false;\n const handler = this.handler;\n this.handler = undefined;\n try {\n await handler?.close();\n } catch {\n // Best effort: stop() must be idempotent and never throw\n }\n this.context = undefined;\n }\n\n // Use general JSON-RPC codes for transport errors\n private writeJsonRpcError(\n res: ServerResponse,\n status: number,\n message: string,\n code = status >= 500 ? -32603 : -32600,\n id: string | number | null = null,\n ): void {\n if (res.headersSent) return;\n res.writeHead(status, {\n 'content-type': 'application/json',\n // RFC 9110 requires Allow on a 405, and this endpoint takes only POST\n ...(status === 405 ? { allow: 'POST' } : {}),\n });\n res.end(JSON.stringify({ jsonrpc: '2.0', error: { code, message }, id }));\n }\n\n private buildServer(signal: AbortSignal): Server {\n const server = new Server(\n { name: this.serverName, version: this.serverVersion },\n { capabilities: { tools: {} }, cacheHints: { 'tools/list': TOOLS_LIST_CACHE_HINT } },\n );\n server.setRequestHandler('tools/list', async (request) => {\n // A cursor is invalid because this list is not paginated\n if (request.params?.cursor !== undefined) {\n throw new ProtocolError(ProtocolErrorCode.InvalidParams, 'Invalid cursor.');\n }\n return { tools: this.tools.map((t) => t.tool) };\n });\n server.setRequestHandler('tools/call', async (request) =>\n this.handleToolCall(\n request.params.name,\n request.params.arguments ?? {},\n request.params._meta,\n signal,\n ),\n );\n return server;\n }\n\n private async handleToolCall(\n resourceId: string,\n rawArgs: Record<string, unknown>,\n meta: Record<string, unknown> | undefined,\n signal: AbortSignal,\n ): Promise<CallToolResult> {\n const context = this.context;\n if (!context) {\n return errorResult(new CommerceError('INTERNAL_ERROR', 'MCP adapter is not running.'));\n }\n // Clients can call names absent from `tools/list`. Return the same MCP\n // error for unknown and non-MCP resources without revealing the latter\n const resource = this.toolsByResourceId.get(resourceId);\n if (!resource) {\n throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Unknown tool \"${resourceId}\".`);\n }\n try {\n const requestId = context.ids.next('mcp');\n const fields = extractReservedInputFields(rawArgs, resource, requestId);\n const { input, authorization } = fields;\n // Client wrappers attach proofs in `_meta`; that proof takes priority\n // over a possible `_payment` placeholder in the arguments\n const payment = paymentFromMeta(meta, resource) ?? fields.payment;\n const request: CanonicalRequest = {\n requestId,\n resourceId,\n input,\n protocol: 'mcp',\n receivedAt: context.clock.nowIso(),\n ...(payment !== undefined ? { payment } : {}),\n ...(authorization !== undefined ? { authorization } : {}),\n };\n await this.acquireToolCallSlot(signal);\n try {\n // The last cancellation point: a queued call whose caller has left\n // must not start a pipeline run, while a started one may reach\n // settle() and must finish\n if (signal.aborted) {\n // No error code names \"the caller left\". PROTOCOL_UNSUPPORTED is the\n // closest non-retryable one; GATEWAY_BUSY would invite a retry\n // nobody is left to make.\n return errorResult(\n new CommerceError(\n 'PROTOCOL_UNSUPPORTED',\n 'Client disconnected before this call started.',\n ),\n );\n }\n const outcome = await context.pipeline.execute(request);\n return mapOutcome(outcome);\n } finally {\n // Always released: a stranded permit shrinks the cap for good and\n // eventually deadlocks the adapter\n this.releaseToolCallSlot();\n }\n } catch (err) {\n const error = toCommerceError(err);\n context.logger.warn({ resourceId, err: toLogInfo(error) }, 'mcp adapter: execution failed');\n return errorResult(error, resource.paymentMethods[0]);\n }\n }\n\n /**\n * Takes a permit, or queues for one when MAX_CONCURRENT_TOOL_CALLS are in\n * flight. Throws when the queue is full or the caller disconnected while\n * queued; a throw never leaks a permit.\n */\n private async acquireToolCallSlot(signal: AbortSignal): Promise<void> {\n if (this.inFlightToolCalls < MAX_CONCURRENT_TOOL_CALLS) {\n this.inFlightToolCalls++;\n return;\n }\n if (this.toolCallWaiters.length >= MAX_QUEUED_TOOL_CALLS) {\n // Load shedding is transient, so GATEWAY_BUSY tells the caller to back\n // off and retry\n throw new CommerceError(\n 'GATEWAY_BUSY',\n 'Too many tool calls already queued on this adapter; retry later.',\n );\n }\n // Resolved by releaseToolCallSlot, which hands its permit straight to the\n // oldest waiter, so a call arriving later cannot take it first\n await new Promise<void>((resolve) => this.toolCallWaiters.push(resolve));\n if (signal.aborted) {\n // This waiter now holds a permit it will not use; pass it on\n this.releaseToolCallSlot();\n // Non-retryable, for the same reason as the check in handleToolCall\n throw new CommerceError('PROTOCOL_UNSUPPORTED', 'Client disconnected while queued.');\n }\n }\n\n private releaseToolCallSlot(): void {\n const next = this.toolCallWaiters.shift();\n // Handing the permit over leaves the in-flight count unchanged\n if (next !== undefined) next();\n else this.inFlightToolCalls--;\n }\n}\n\n// Pass the Node request body to the SDK as a stream. The gateway's socket\n// byte limit still applies, and the signal reports client disconnects.\nfunction toWebRequest(req: IncomingMessage, body: string, signal: AbortSignal): Request {\n const headers = new Headers();\n for (const [name, value] of Object.entries(req.headers)) {\n if (value !== undefined) headers.set(name, Array.isArray(value) ? value.join(', ') : value);\n }\n return new Request(new URL(req.url ?? '/', 'http://localhost'), {\n method: req.method ?? 'POST',\n headers,\n body,\n signal,\n });\n}\n\n/**\n * Let the SDK validate requests with `Mcp-Method` or a modern version header;\n * malformed headers and `_meta` may require an HTTP 400 response\n */\nfunction isModernRequest(req: IncomingMessage): boolean {\n if (req.headers['mcp-method'] !== undefined) return true;\n const version = req.headers['mcp-protocol-version'];\n // ISO revision dates sort lexically.\n return typeof version === 'string' && version >= MCP_MODERN_PROTOCOL_REVISION;\n}\n\n// Undefined for a body that is not JSON; the SDK answers that with -32700\nfunction parseJson(body: string): unknown {\n try {\n return JSON.parse(body);\n } catch {\n return undefined;\n }\n}\n\n// Give malformed tool calls without modern headers a short -32602 response\nfunction malformedToolCall(message: unknown): { id: string | number; message: string } | undefined {\n if (!isRecord(message) || message['method'] !== 'tools/call') return undefined;\n const id = message['id'];\n if (typeof id !== 'string' && typeof id !== 'number') return undefined;\n const params = message['params'];\n let problem: string | undefined;\n if (!isRecord(params)) problem = 'params must be an object';\n else if (typeof params['name'] !== 'string') problem = '\"name\" must be a string';\n else if (params['arguments'] !== undefined && !isRecord(params['arguments'])) {\n problem = '\"arguments\" must be an object';\n } else if (params['_meta'] !== undefined && !isRecord(params['_meta'])) {\n problem = '\"_meta\" must be an object';\n }\n return problem === undefined\n ? undefined\n : { id, message: `Invalid tools/call params: ${problem}.` };\n}\n\n// Stream the SDK's response body, including SSE, to the Node response\nasync function writeWebResponse(response: Response, res: ServerResponse): Promise<void> {\n res.writeHead(response.status, Object.fromEntries(response.headers));\n if (response.body !== null) {\n for await (const chunk of response.body) {\n if (res.destroyed) break;\n res.write(chunk);\n }\n }\n res.end();\n}\n\n// Read a proof from the selected rail's MCP `_meta` carrier\nfunction paymentFromMeta(\n meta: Record<string, unknown> | undefined,\n resource: CommerceResource,\n): PaymentSubmission | undefined {\n const method = resource.paymentMethods[0];\n if (method === 'x402') {\n const payload = x402McpPaymentSubmission(meta?.[X402_MCP_PAYMENT_META_KEY]);\n if (payload !== undefined) return { method, payload };\n }\n const credential = meta?.[MPP_MCP_CREDENTIAL_META_KEY];\n if (method === 'mpp' && isRecord(credential)) {\n // The MPP provider converts this object to an Authorization value\n return { method, payload: JSON.stringify(credential) };\n }\n return undefined;\n}\n\nexport function createMcpAdapter(options?: McpAdapterOptions): HttpProtocolAdapter {\n return new McpProtocolAdapter(options);\n}\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { computeNearReplayKey } from './chunk-OSTCU6ZK.js';
|
|
2
|
+
import { isRecord } from './chunk-3M6U7ILB.js';
|
|
3
|
+
import { decodeSignedDelegateB64, parseFtTransferArgs } from '@x402/near';
|
|
4
|
+
|
|
5
|
+
var MAX_SIGNED_DELEGATE_BASE64 = 4096;
|
|
6
|
+
var ONE_YOCTO = 1n;
|
|
7
|
+
function inspectNearPayload(payload, terms) {
|
|
8
|
+
const encoded = isRecord(payload) ? payload["signedDelegateAction"] : void 0;
|
|
9
|
+
if (typeof encoded !== "string" || encoded.length > MAX_SIGNED_DELEGATE_BASE64) {
|
|
10
|
+
return "invalid_exact_near_payload_shape";
|
|
11
|
+
}
|
|
12
|
+
let delegate;
|
|
13
|
+
try {
|
|
14
|
+
delegate = decodeSignedDelegateB64(encoded).delegate;
|
|
15
|
+
} catch {
|
|
16
|
+
return "invalid_exact_near_payload_signed_delegate_action";
|
|
17
|
+
}
|
|
18
|
+
if (!isCanonical(encoded)) return "invalid_exact_near_payload_signed_delegate_action";
|
|
19
|
+
if (delegate.actionCount !== 1) return "invalid_exact_near_payload_action_count";
|
|
20
|
+
const call = delegate.functionCall;
|
|
21
|
+
if (!call) return "invalid_exact_near_payload_action_kind";
|
|
22
|
+
if (call.methodName !== "ft_transfer") return "invalid_exact_near_payload_method_name";
|
|
23
|
+
if (delegate.receiverId !== terms.asset) {
|
|
24
|
+
return "invalid_exact_near_payload_token_contract_mismatch";
|
|
25
|
+
}
|
|
26
|
+
let args;
|
|
27
|
+
try {
|
|
28
|
+
args = parseFtTransferArgs(call.args);
|
|
29
|
+
} catch {
|
|
30
|
+
return "invalid_exact_near_payload_ft_transfer_args";
|
|
31
|
+
}
|
|
32
|
+
if (args.receiver_id !== terms.payTo) return "invalid_exact_near_payload_recipient_mismatch";
|
|
33
|
+
if (args.amount !== terms.amount) return "invalid_exact_near_payload_amount_mismatch";
|
|
34
|
+
if (call.deposit !== ONE_YOCTO) return "invalid_exact_near_payload_attached_deposit";
|
|
35
|
+
return {
|
|
36
|
+
payer: delegate.senderId,
|
|
37
|
+
replayKey: computeNearReplayKey({
|
|
38
|
+
network: terms.network,
|
|
39
|
+
senderId: delegate.senderId,
|
|
40
|
+
publicKey: delegate.publicKey,
|
|
41
|
+
nonce: delegate.nonce
|
|
42
|
+
})
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function isCanonical(encoded) {
|
|
46
|
+
const bytes = Buffer.from(encoded, "base64");
|
|
47
|
+
if (bytes.toString("base64") !== encoded) return false;
|
|
48
|
+
try {
|
|
49
|
+
decodeSignedDelegateB64(bytes.subarray(0, bytes.length - 1).toString("base64"));
|
|
50
|
+
return false;
|
|
51
|
+
} catch {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { inspectNearPayload };
|
|
57
|
+
//# sourceMappingURL=near-5AY3HWYF.js.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EAAO,OAAO,+CAAA;AAC7C,EAAA,IAAI,IAAA,CAAK,MAAA,KAAW,KAAA,CAAM,MAAA,EAAQ,OAAO,4CAAA;AACzC,EAAA,IAAI,IAAA,CAAK,OAAA,KAAY,SAAA,EAAW,OAAO,6CAAA;AACvC,EAAA,OAAO;AAAA,IACL,OAAO,QAAA,CAAS,QAAA;AAAA,IAChB,WAAW,oBAAA,CAAqB;AAAA,MAC9B,SAAS,KAAA,CAAM,OAAA;AAAA,MACf,UAAU,QAAA,CAAS,QAAA;AAAA,MACnB,WAAW,QAAA,CAAS,SAAA;AAAA,MACpB,OAAO,QAAA,CAAS;AAAA,KACjB;AAAA,GACH;AACF;AAOA,SAAS,YAAY,OAAA,EAA0B;AAC7C,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,IAAA,CAAK,OAAA,EAAS,QAAQ,CAAA;AAC3C,EAAA,IAAI,KAAA,CAAM,QAAA,CAAS,QAAQ,CAAA,KAAM,SAAS,OAAO,KAAA;AACjD,EAAA,IAAI;AACF,IAAA,uBAAA,CAAwB,KAAA,CAAM,SAAS,CAAA,EAAG,KAAA,CAAM,SAAS,CAAC,CAAA,CAAE,QAAA,CAAS,QAAQ,CAAC,CAAA;AAC9E,IAAA,OAAO,KAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF","file":"near-5AY3HWYF.js","sourcesContent":["/**\n * NEAR `exact` payload inspection: bounded decoding of the NEP-366 signed\n * delegate action, the transfer it authorizes and its replay identity. The\n * provider loads this module only for a NEAR offer, so other deployments never\n * import `@x402/near`.\n *\n * The facilitator checks the signature, the access key and its nonce, the\n * delegate window and chain state. The gateway checks the transfer the buyer\n * signed against the offer, so a proof for other terms never reaches it.\n */\nimport { decodeSignedDelegateB64, parseFtTransferArgs } from '@x402/near';\nimport { isRecord } from '../../core/is-record';\nimport { computeNearReplayKey } from './replay-key';\n\n// One `ft_transfer` delegate is a few hundred bytes; this bounds the decoder\nconst MAX_SIGNED_DELEGATE_BASE64 = 4096;\n// NEP-141 requires exactly one yoctoNEAR on `ft_transfer`\nconst ONE_YOCTO = 1n;\n\nexport interface NearTransferTerms {\n readonly network: string;\n /** The NEP-141 token contract the delegate must call */\n readonly asset: string;\n readonly payTo: string;\n /** Atomic units, as the offer states them */\n readonly amount: string;\n}\n\n/**\n * Returns the payer and replay key if the NEAR `exact` payload matches the\n * offer, or a refusal reason using the SDK facilitator's codes.\n */\nexport function inspectNearPayload(\n payload: unknown,\n terms: NearTransferTerms,\n): { readonly payer: string; readonly replayKey: string } | string {\n const encoded = isRecord(payload) ? payload['signedDelegateAction'] : undefined;\n if (typeof encoded !== 'string' || encoded.length > MAX_SIGNED_DELEGATE_BASE64) {\n return 'invalid_exact_near_payload_shape';\n }\n let delegate: ReturnType<typeof decodeSignedDelegateB64>['delegate'];\n try {\n delegate = decodeSignedDelegateB64(encoded).delegate;\n } catch {\n return 'invalid_exact_near_payload_signed_delegate_action';\n }\n if (!isCanonical(encoded)) return 'invalid_exact_near_payload_signed_delegate_action';\n if (delegate.actionCount !== 1) return 'invalid_exact_near_payload_action_count';\n const call = delegate.functionCall;\n if (!call) return 'invalid_exact_near_payload_action_kind';\n if (call.methodName !== 'ft_transfer') return 'invalid_exact_near_payload_method_name';\n if (delegate.receiverId !== terms.asset) {\n return 'invalid_exact_near_payload_token_contract_mismatch';\n }\n let args: ReturnType<typeof parseFtTransferArgs>;\n try {\n args = parseFtTransferArgs(call.args);\n } catch {\n return 'invalid_exact_near_payload_ft_transfer_args';\n }\n if (args.receiver_id !== terms.payTo) return 'invalid_exact_near_payload_recipient_mismatch';\n if (args.amount !== terms.amount) return 'invalid_exact_near_payload_amount_mismatch';\n if (call.deposit !== ONE_YOCTO) return 'invalid_exact_near_payload_attached_deposit';\n return {\n payer: delegate.senderId,\n replayKey: computeNearReplayKey({\n network: terms.network,\n senderId: delegate.senderId,\n publicKey: delegate.publicKey,\n nonce: delegate.nonce,\n }),\n };\n}\n\n/**\n * One delegate, one encoding: canonical base64, and no bytes after the signed\n * delegate. The SDK decoder ignores such bytes, so the check decodes the\n * payload without its last byte: a canonical encoding then runs short.\n */\nfunction isCanonical(encoded: string): boolean {\n const bytes = Buffer.from(encoded, 'base64');\n if (bytes.toString('base64') !== encoded) return false;\n try {\n decodeSignedDelegateB64(bytes.subarray(0, bytes.length - 1).toString('base64'));\n return false;\n } catch {\n return true;\n }\n}\n"]}
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
import { MPP_PROFILE, MPP_NETWORKS, MPP_DEFAULT_NETWORK, MPP_SUPPORTED_SPEC, MPP_DEFAULT_PAYMENT_FLOW, MPP_SPEC_DRAFTS, MPP_MIN_CHALLENGE_SECRET_LENGTH, isMppNetwork } from './chunk-AA3FIEAR.js';
|
|
2
|
+
import { createX402PaymentProvider, DEFAULT_IDS, parseCanonicalAmount } from './chunk-KLX2YZDG.js';
|
|
3
|
+
import './chunk-NSPPEF5M.js';
|
|
4
|
+
import { SETTLE_AFTER_BACKEND_METADATA_KEY } from './chunk-7JNYFUT3.js';
|
|
5
|
+
import { computeReplayKey } from './chunk-OSTCU6ZK.js';
|
|
6
|
+
import { CONTENT_DIGEST_METADATA_KEY } from './chunk-5K4XEAZV.js';
|
|
7
|
+
import { PACKAGE_VERSION } from './chunk-FRMLWGSS.js';
|
|
8
|
+
import { systemClock, CommerceError } from './chunk-QQ3WY5L3.js';
|
|
9
|
+
import './chunk-3M6U7ILB.js';
|
|
10
|
+
import { Challenge, Method, Receipt, Credential, PaymentRequest, Errors } from 'mppx';
|
|
11
|
+
import { Methods } from 'mppx/evm';
|
|
12
|
+
import { charge } from 'mppx/evm/server';
|
|
13
|
+
import { parseAbi, createPublicClient, http, getAddress, isAddress } from 'viem';
|
|
14
|
+
|
|
15
|
+
var VERIFICATION_REASONS = [
|
|
16
|
+
["EVM authorization challenge hash mismatch", "wrong_nonce"],
|
|
17
|
+
["EVM authorization signature mismatch", "invalid_signature"],
|
|
18
|
+
["EVM authorization is not valid yet", "authorization_not_yet_valid"],
|
|
19
|
+
["EVM authorization has expired", "authorization_expired"],
|
|
20
|
+
["EVM authorization source mismatch", "source_mismatch"],
|
|
21
|
+
["EVM authorization amount mismatch", "wrong_amount"],
|
|
22
|
+
["EVM authorization recipient mismatch", "wrong_recipient"]
|
|
23
|
+
];
|
|
24
|
+
function verificationReason(error) {
|
|
25
|
+
if (error instanceof Errors.PaymentExpiredError) return "challenge_expired";
|
|
26
|
+
if (error instanceof Errors.InvalidPayloadError) return "invalid_payload";
|
|
27
|
+
if (error instanceof Errors.InvalidChallengeError) return "invalid_challenge";
|
|
28
|
+
if (error instanceof Errors.VerificationFailedError) {
|
|
29
|
+
const match = VERIFICATION_REASONS.find(([text]) => error.message.includes(text));
|
|
30
|
+
if (match) return match[1];
|
|
31
|
+
}
|
|
32
|
+
return "authorization_invalid";
|
|
33
|
+
}
|
|
34
|
+
function decodeCredential(payload) {
|
|
35
|
+
const serialized = payload.trimStart().startsWith("{") ? Credential.serialize(JSON.parse(payload)) : payload;
|
|
36
|
+
return Credential.deserialize(serialized);
|
|
37
|
+
}
|
|
38
|
+
function bindingMismatch(echoed, issued, resourceId) {
|
|
39
|
+
if (echoed.realm !== issued.realm) return "wrong_realm";
|
|
40
|
+
if (echoed.method !== issued.method || echoed.intent !== issued.intent) {
|
|
41
|
+
return "unsupported_method";
|
|
42
|
+
}
|
|
43
|
+
if (echoed.opaque !== PaymentRequest.serialize({ resource: resourceId })) {
|
|
44
|
+
return "wrong_resource";
|
|
45
|
+
}
|
|
46
|
+
if (echoed.digest !== void 0 && echoed.digest !== issued.digest) {
|
|
47
|
+
return "body_digest_mismatch";
|
|
48
|
+
}
|
|
49
|
+
const got = echoed.request;
|
|
50
|
+
const want = issued.request;
|
|
51
|
+
if (got.amount !== want.amount) return "wrong_amount";
|
|
52
|
+
if (!sameAddress(got.recipient, want.recipient)) return "wrong_recipient";
|
|
53
|
+
if (got.methodDetails?.chainId !== want.methodDetails?.chainId) return "wrong_network";
|
|
54
|
+
if (!sameAddress(got.currency, want.currency)) return "wrong_asset";
|
|
55
|
+
if (canonical(got.methodDetails) !== canonical(want.methodDetails)) {
|
|
56
|
+
return "unsupported_credential";
|
|
57
|
+
}
|
|
58
|
+
if (canonical(got) !== canonical(want)) return "wrong_terms";
|
|
59
|
+
return void 0;
|
|
60
|
+
}
|
|
61
|
+
function toX402Submission(x402Requirement, authorization) {
|
|
62
|
+
const { signature, from, to, value, validAfter, validBefore, nonce } = authorization;
|
|
63
|
+
const payment = {
|
|
64
|
+
x402Version: 2,
|
|
65
|
+
accepted: x402Requirement.challenge.accepts[0],
|
|
66
|
+
payload: { signature, authorization: { from, to, value, validAfter, validBefore, nonce } }
|
|
67
|
+
};
|
|
68
|
+
return { method: "x402", payload: Buffer.from(JSON.stringify(payment)).toString("base64") };
|
|
69
|
+
}
|
|
70
|
+
function canonical(value) {
|
|
71
|
+
return value === void 0 ? "" : PaymentRequest.serialize(value);
|
|
72
|
+
}
|
|
73
|
+
function sameAddress(a, b) {
|
|
74
|
+
return a !== void 0 && b !== void 0 && isAddress(a) && isAddress(b) ? getAddress(a) === getAddress(b) : false;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// src/payments/mpp/descriptor.ts
|
|
78
|
+
var MPP_DESCRIPTOR = {
|
|
79
|
+
name: "mpp",
|
|
80
|
+
kind: "payment",
|
|
81
|
+
implementationVersion: PACKAGE_VERSION,
|
|
82
|
+
supportedSpec: MPP_SUPPORTED_SPEC,
|
|
83
|
+
capabilities: [
|
|
84
|
+
`intent=${MPP_PROFILE.intent}`,
|
|
85
|
+
`method=${MPP_PROFILE.method}`,
|
|
86
|
+
`credential=${MPP_PROFILE.credentialType}`,
|
|
87
|
+
"eip-3009",
|
|
88
|
+
...MPP_NETWORKS.map((network) => `network=${network}`),
|
|
89
|
+
`asset=${MPP_PROFILE.assetSymbol}`,
|
|
90
|
+
"verify-before-settle",
|
|
91
|
+
"authorization-flow",
|
|
92
|
+
"upfront-flow",
|
|
93
|
+
"payment-receipt",
|
|
94
|
+
// HTTP request bodies only; MCP and A2A carry the proof in the body
|
|
95
|
+
"challenge-digest-binding"
|
|
96
|
+
],
|
|
97
|
+
// The pinned specs are drafts and mppx is pre-1.0; the wire format may change
|
|
98
|
+
status: "experimental",
|
|
99
|
+
unsupported: [
|
|
100
|
+
// Name other methods as a class instead of maintaining a second list
|
|
101
|
+
"methods other than evm",
|
|
102
|
+
// This profile supports only the EIP-3009 `authorization` credential
|
|
103
|
+
"credential=permit2",
|
|
104
|
+
"credential=transaction",
|
|
105
|
+
"credential=hash",
|
|
106
|
+
// The draft allows splits only with permit2 credentials
|
|
107
|
+
"splits",
|
|
108
|
+
"intent=subscription",
|
|
109
|
+
// A separate EVM draft, not an option of charge
|
|
110
|
+
"evm sessions",
|
|
111
|
+
"discovery extension"
|
|
112
|
+
]
|
|
113
|
+
};
|
|
114
|
+
function configInvalid(message) {
|
|
115
|
+
return new CommerceError("CONFIG_INVALID", message);
|
|
116
|
+
}
|
|
117
|
+
function validateOptions(options) {
|
|
118
|
+
if (!isAddress(options.recipient)) throw configInvalid("MPP recipient is not an EVM address");
|
|
119
|
+
if (!isAddress(options.asset)) throw configInvalid("MPP asset is not an EVM address");
|
|
120
|
+
if (options.assetName.length === 0 || options.assetVersion.length === 0) {
|
|
121
|
+
throw configInvalid("MPP asset needs its EIP-712 domain name and version");
|
|
122
|
+
}
|
|
123
|
+
if (options.realm.length === 0 || /[\r\n]/.test(options.realm)) {
|
|
124
|
+
throw configInvalid("MPP realm must be a non-empty single-line string");
|
|
125
|
+
}
|
|
126
|
+
if (options.challengeSecret.length < MPP_MIN_CHALLENGE_SECRET_LENGTH) {
|
|
127
|
+
throw configInvalid(
|
|
128
|
+
`MPP challenge secret must have length at least ${MPP_MIN_CHALLENGE_SECRET_LENGTH}`
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
const ttl = options.challengeTtlSeconds;
|
|
132
|
+
if (ttl !== void 0 && (!Number.isInteger(ttl) || ttl <= 0)) {
|
|
133
|
+
throw configInvalid("MPP challenge TTL must be a positive whole number of seconds");
|
|
134
|
+
}
|
|
135
|
+
if (options.network !== void 0 && !isMppNetwork(options.network)) {
|
|
136
|
+
throw configInvalid(`MPP network must be one of ${MPP_NETWORKS.join(", ")}`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// src/payments/mpp/provider.ts
|
|
141
|
+
var DEFAULT_CHALLENGE_TTL_SECONDS = 300;
|
|
142
|
+
var NONCE_ALREADY_USED = "invalid_exact_evm_nonce_already_used";
|
|
143
|
+
var AUTHORIZATION_STATE_ABI = parseAbi([
|
|
144
|
+
"function authorizationState(address authorizer, bytes32 nonce) view returns (bool)"
|
|
145
|
+
]);
|
|
146
|
+
var NONCE_READ_TIMEOUT_MS = 5e3;
|
|
147
|
+
function createMppPaymentProvider(options) {
|
|
148
|
+
const { rpcUrl, facilitator, allowMainnet, allowUnauthenticatedFacilitator, logger, ...rest } = options;
|
|
149
|
+
validateOptions(rest);
|
|
150
|
+
const settlement = createX402PaymentProvider({
|
|
151
|
+
network: options.network ?? MPP_DEFAULT_NETWORK,
|
|
152
|
+
rpcUrl,
|
|
153
|
+
asset: options.asset,
|
|
154
|
+
assetName: options.assetName,
|
|
155
|
+
assetVersion: options.assetVersion,
|
|
156
|
+
assetDecimals: MPP_PROFILE.assetDecimals,
|
|
157
|
+
payTo: options.recipient,
|
|
158
|
+
facilitator,
|
|
159
|
+
...allowMainnet !== void 0 ? { allowMainnet } : {},
|
|
160
|
+
...allowUnauthenticatedFacilitator !== void 0 ? { allowUnauthenticatedFacilitator } : {},
|
|
161
|
+
...logger !== void 0 ? { logger } : {},
|
|
162
|
+
...options.clock !== void 0 ? { clock: options.clock } : {}
|
|
163
|
+
});
|
|
164
|
+
const chain = createPublicClient({
|
|
165
|
+
transport: http(rpcUrl, { timeout: NONCE_READ_TIMEOUT_MS, retryCount: 0 })
|
|
166
|
+
});
|
|
167
|
+
const nonceUsed = (payer, nonce) => chain.readContract({
|
|
168
|
+
address: options.asset,
|
|
169
|
+
abi: AUTHORIZATION_STATE_ABI,
|
|
170
|
+
functionName: "authorizationState",
|
|
171
|
+
args: [payer, nonce]
|
|
172
|
+
});
|
|
173
|
+
return createMppProviderWithSettlement(rest, settlement, nonceUsed);
|
|
174
|
+
}
|
|
175
|
+
function createMppProviderWithSettlement(options, settlement, nonceUsed) {
|
|
176
|
+
validateOptions(options);
|
|
177
|
+
if (settlement.name !== "x402") {
|
|
178
|
+
throw configInvalid("MPP settlement must be an x402 payment provider");
|
|
179
|
+
}
|
|
180
|
+
const network = options.network ?? MPP_DEFAULT_NETWORK;
|
|
181
|
+
const chainId = Number(network.split(":")[1]);
|
|
182
|
+
const clock = options.clock ?? systemClock;
|
|
183
|
+
const ttlSeconds = options.challengeTtlSeconds ?? DEFAULT_CHALLENGE_TTL_SECONDS;
|
|
184
|
+
const recipient = getAddress(options.recipient);
|
|
185
|
+
const asset = getAddress(options.asset);
|
|
186
|
+
const ids = options.ids ?? DEFAULT_IDS;
|
|
187
|
+
let settlementTermsChecked = false;
|
|
188
|
+
const method = charge({
|
|
189
|
+
currency: asset,
|
|
190
|
+
recipient,
|
|
191
|
+
chainId,
|
|
192
|
+
decimals: MPP_PROFILE.assetDecimals,
|
|
193
|
+
authorization: { name: options.assetName, version: options.assetVersion },
|
|
194
|
+
settle: async () => {
|
|
195
|
+
throw new CommerceError("INTERNAL_ERROR", "MPP direct broadcast is disabled");
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
function rejected(requirement, reason) {
|
|
199
|
+
return {
|
|
200
|
+
status: "rejected",
|
|
201
|
+
provider: "mpp",
|
|
202
|
+
amount: requirement.amount,
|
|
203
|
+
currency: requirement.currency,
|
|
204
|
+
network,
|
|
205
|
+
asset,
|
|
206
|
+
rejectionReason: reason
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
async function createRequirement(context) {
|
|
210
|
+
if (context.currency !== MPP_PROFILE.assetSymbol) {
|
|
211
|
+
throw configInvalid(
|
|
212
|
+
`Resource "${context.resource.id}" is priced in ${context.currency}, but MPP charges ${MPP_PROFILE.assetSymbol}`
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
if (parseCanonicalAmount(context.amount, MPP_PROFILE.assetDecimals) <= 0n) {
|
|
216
|
+
throw new CommerceError("PAYMENT_INVALID", `Amount "${context.amount}" must be above zero`, {
|
|
217
|
+
details: { amount: context.amount }
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
if (!settlementTermsChecked) {
|
|
221
|
+
await settlementRequirement(context);
|
|
222
|
+
settlementTermsChecked = true;
|
|
223
|
+
}
|
|
224
|
+
const paymentFlow = options.resourcePaymentFlows?.[context.resource.id] ?? options.paymentFlow ?? MPP_DEFAULT_PAYMENT_FLOW;
|
|
225
|
+
const expires = new Date(clock.now().getTime() + ttlSeconds * 1e3);
|
|
226
|
+
const digest = context.metadata?.[CONTENT_DIGEST_METADATA_KEY];
|
|
227
|
+
const challenge = Challenge.fromMethod(Methods.charge, {
|
|
228
|
+
secretKey: options.challengeSecret,
|
|
229
|
+
realm: options.realm,
|
|
230
|
+
expires,
|
|
231
|
+
// Present for an HTTP request with a body. MCP and A2A carry the proof
|
|
232
|
+
// in the body itself, so their challenges bind none.
|
|
233
|
+
...typeof digest === "string" ? { digest } : {},
|
|
234
|
+
// Bound by the challenge HMAC, so a challenge for one resource cannot pay
|
|
235
|
+
// for another at the same price
|
|
236
|
+
meta: { resource: context.resource.id },
|
|
237
|
+
request: {
|
|
238
|
+
amount: context.amount,
|
|
239
|
+
currency: asset,
|
|
240
|
+
recipient,
|
|
241
|
+
chainId,
|
|
242
|
+
decimals: MPP_PROFILE.assetDecimals,
|
|
243
|
+
credentialTypes: [MPP_PROFILE.credentialType]
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
return {
|
|
247
|
+
id: ids.next("payreq"),
|
|
248
|
+
requestId: context.requestId,
|
|
249
|
+
resourceId: context.resource.id,
|
|
250
|
+
provider: "mpp",
|
|
251
|
+
amount: context.amount,
|
|
252
|
+
currency: context.currency,
|
|
253
|
+
destination: recipient,
|
|
254
|
+
network,
|
|
255
|
+
asset,
|
|
256
|
+
expiresAt: expires.toISOString(),
|
|
257
|
+
challenge: {
|
|
258
|
+
provider: "mpp",
|
|
259
|
+
version: MPP_SPEC_DRAFTS.core,
|
|
260
|
+
accepts: [challenge],
|
|
261
|
+
// Build both carrier forms here because the HTTP route and MCP
|
|
262
|
+
// adapter cannot import mppx: a header value for HTTP and challenge
|
|
263
|
+
// objects for MCP
|
|
264
|
+
envelope: { wwwAuthenticate: Challenge.serialize(challenge), challenges: [challenge] }
|
|
265
|
+
},
|
|
266
|
+
metadata: { [SETTLE_AFTER_BACKEND_METADATA_KEY]: paymentFlow === "authorization" }
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
async function verify(context) {
|
|
270
|
+
const { requirement, resource, submission } = context;
|
|
271
|
+
if (requirement.provider !== "mpp" || requirement.challenge.provider !== "mpp") {
|
|
272
|
+
return rejected(requirement, "wrong_provider");
|
|
273
|
+
}
|
|
274
|
+
const issued = requirement.challenge.accepts[0];
|
|
275
|
+
if (!issued) return rejected(requirement, "missing_challenge");
|
|
276
|
+
let credential;
|
|
277
|
+
try {
|
|
278
|
+
credential = decodeCredential(submission.payload);
|
|
279
|
+
} catch {
|
|
280
|
+
return rejected(requirement, "malformed_credential");
|
|
281
|
+
}
|
|
282
|
+
const echoed = credential.challenge;
|
|
283
|
+
if (!Challenge.verify(echoed, { secretKey: options.challengeSecret })) {
|
|
284
|
+
return rejected(requirement, "challenge_not_issued");
|
|
285
|
+
}
|
|
286
|
+
const binding = bindingMismatch(echoed, issued, resource.id);
|
|
287
|
+
if (binding) return rejected(requirement, binding);
|
|
288
|
+
if (!echoed.expires || new Date(echoed.expires).getTime() <= clock.now().getTime()) {
|
|
289
|
+
return rejected(requirement, "challenge_expired");
|
|
290
|
+
}
|
|
291
|
+
if (credential.payload?.type !== MPP_PROFILE.credentialType) {
|
|
292
|
+
return rejected(requirement, "unsupported_credential");
|
|
293
|
+
}
|
|
294
|
+
let payer;
|
|
295
|
+
try {
|
|
296
|
+
const validation = await Method.validateCredential([method], credential);
|
|
297
|
+
payer = getAddress(validation.details.payer);
|
|
298
|
+
} catch (error) {
|
|
299
|
+
return rejected(requirement, verificationReason(error));
|
|
300
|
+
}
|
|
301
|
+
const nonce = credential.payload.nonce;
|
|
302
|
+
const replayKey = computeReplayKey({ chainId, asset, from: payer, nonce });
|
|
303
|
+
const x402Verification = await settlement.verify(
|
|
304
|
+
await toX402Context(context, credential.payload)
|
|
305
|
+
);
|
|
306
|
+
if (x402Verification.status !== "verified") {
|
|
307
|
+
const reason = x402Verification.rejectionReason;
|
|
308
|
+
const spent = reason === NONCE_ALREADY_USED || (await nonceUsed?.(payer, nonce).catch(() => false) ?? false);
|
|
309
|
+
return rejected(
|
|
310
|
+
requirement,
|
|
311
|
+
spent ? "challenge_already_used" : reason ?? "settlement_rejected"
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
if (x402Verification.replayKey !== replayKey) {
|
|
315
|
+
return rejected(requirement, "settlement_mismatch");
|
|
316
|
+
}
|
|
317
|
+
return {
|
|
318
|
+
status: "verified",
|
|
319
|
+
provider: "mpp",
|
|
320
|
+
payer,
|
|
321
|
+
payee: recipient,
|
|
322
|
+
amount: requirement.amount,
|
|
323
|
+
currency: requirement.currency,
|
|
324
|
+
network,
|
|
325
|
+
asset,
|
|
326
|
+
replayKey
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
async function toX402Context(context, authorization) {
|
|
330
|
+
const { requestId, requirement, resource } = context;
|
|
331
|
+
const x402Requirement = await settlementRequirement({
|
|
332
|
+
requestId,
|
|
333
|
+
resource,
|
|
334
|
+
amount: requirement.amount,
|
|
335
|
+
currency: requirement.currency,
|
|
336
|
+
requestedAt: clock.nowIso()
|
|
337
|
+
});
|
|
338
|
+
return {
|
|
339
|
+
requestId,
|
|
340
|
+
resource,
|
|
341
|
+
requirement: x402Requirement,
|
|
342
|
+
submission: toX402Submission(x402Requirement, authorization)
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
async function settlementRequirement(context) {
|
|
346
|
+
const x402 = await settlement.createRequirement(context);
|
|
347
|
+
const extra = x402.challenge.accepts[0]?.["extra"] ?? {};
|
|
348
|
+
if (x402.network !== network || !sameAddress(x402.asset, asset) || !sameAddress(x402.destination, recipient) || extra["name"] !== options.assetName || extra["version"] !== options.assetVersion) {
|
|
349
|
+
throw configInvalid(
|
|
350
|
+
"MPP settlement provider must use the same network, asset, EIP-712 domain and recipient"
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
return x402;
|
|
354
|
+
}
|
|
355
|
+
async function settle(context) {
|
|
356
|
+
const { requestId, requirement, resource, submission, verification } = context;
|
|
357
|
+
if (verification.status !== "verified" || verification.replayKey === void 0) {
|
|
358
|
+
throw new CommerceError(
|
|
359
|
+
"PAYMENT_INVALID",
|
|
360
|
+
"MPP settle() called without a successful verify()"
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
const credential = decodeCredential(submission.payload);
|
|
364
|
+
const authorization = credential.payload;
|
|
365
|
+
const settled = await settlement.settle({
|
|
366
|
+
...await toX402Context({ requestId, requirement, resource}, authorization),
|
|
367
|
+
verification: { ...verification, provider: "x402" }
|
|
368
|
+
});
|
|
369
|
+
const result = {
|
|
370
|
+
...settled,
|
|
371
|
+
provider: "mpp",
|
|
372
|
+
amount: requirement.amount,
|
|
373
|
+
currency: requirement.currency,
|
|
374
|
+
replayKey: verification.replayKey
|
|
375
|
+
};
|
|
376
|
+
if (settled.status !== "settled" || settled.externalReference === void 0) return result;
|
|
377
|
+
const fields = {
|
|
378
|
+
method: MPP_PROFILE.method,
|
|
379
|
+
reference: settled.externalReference,
|
|
380
|
+
status: "success",
|
|
381
|
+
timestamp: settled.settledAt ?? clock.nowIso(),
|
|
382
|
+
challengeId: credential.challenge.id,
|
|
383
|
+
chainId
|
|
384
|
+
};
|
|
385
|
+
const receipt = Receipt.from(fields);
|
|
386
|
+
return { ...result, metadata: { ...settled.metadata, receipt: Receipt.serialize(receipt) } };
|
|
387
|
+
}
|
|
388
|
+
function health() {
|
|
389
|
+
return settlement.health();
|
|
390
|
+
}
|
|
391
|
+
return { name: "mpp", descriptor: MPP_DESCRIPTOR, createRequirement, verify, settle, health };
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export { createMppPaymentProvider, createMppProviderWithSettlement };
|
|
395
|
+
//# sourceMappingURL=provider-4BQDH56Y.js.map
|
|
396
|
+
//# sourceMappingURL=provider-4BQDH56Y.js.map
|