@nevermined-io/payments 1.9.0 → 1.11.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.
Files changed (98) hide show
  1. package/dist/api/base-payments.d.ts +11 -0
  2. package/dist/api/base-payments.d.ts.map +1 -1
  3. package/dist/api/base-payments.js +28 -3
  4. package/dist/api/base-payments.js.map +1 -1
  5. package/dist/api/nvm-api.d.ts +4 -0
  6. package/dist/api/nvm-api.d.ts.map +1 -1
  7. package/dist/api/nvm-api.js +7 -0
  8. package/dist/api/nvm-api.js.map +1 -1
  9. package/dist/api/organizations-api/organizations-api.d.ts +19 -1
  10. package/dist/api/organizations-api/organizations-api.d.ts.map +1 -1
  11. package/dist/api/organizations-api/organizations-api.js +49 -0
  12. package/dist/api/organizations-api/organizations-api.js.map +1 -1
  13. package/dist/api/organizations-api/types.d.ts +27 -0
  14. package/dist/api/organizations-api/types.d.ts.map +1 -1
  15. package/dist/api/organizations-api/types.js.map +1 -1
  16. package/dist/common/api-version.d.ts +1 -1
  17. package/dist/common/api-version.js +1 -1
  18. package/dist/common/api-version.js.map +1 -1
  19. package/dist/common/types.d.ts +9 -4
  20. package/dist/common/types.d.ts.map +1 -1
  21. package/dist/common/types.js.map +1 -1
  22. package/dist/environments.d.ts +12 -0
  23. package/dist/environments.d.ts.map +1 -1
  24. package/dist/environments.js +31 -0
  25. package/dist/environments.js.map +1 -1
  26. package/dist/index.d.ts +1 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +2 -0
  29. package/dist/index.js.map +1 -1
  30. package/dist/mcp/core/server-manager.d.ts.map +1 -1
  31. package/dist/mcp/core/server-manager.js +3 -0
  32. package/dist/mcp/core/server-manager.js.map +1 -1
  33. package/dist/mcp/http/mcp-handler.d.ts +7 -0
  34. package/dist/mcp/http/mcp-handler.d.ts.map +1 -1
  35. package/dist/mcp/http/mcp-handler.js +8 -1
  36. package/dist/mcp/http/mcp-handler.js.map +1 -1
  37. package/dist/mcp/http/oauth-metadata.d.ts.map +1 -1
  38. package/dist/mcp/http/oauth-metadata.js +31 -6
  39. package/dist/mcp/http/oauth-metadata.js.map +1 -1
  40. package/dist/mcp/http/oauth-router.d.ts +17 -16
  41. package/dist/mcp/http/oauth-router.d.ts.map +1 -1
  42. package/dist/mcp/http/oauth-router.js +56 -28
  43. package/dist/mcp/http/oauth-router.js.map +1 -1
  44. package/dist/mpp/codec.d.ts +92 -0
  45. package/dist/mpp/codec.d.ts.map +1 -0
  46. package/dist/mpp/codec.js +405 -0
  47. package/dist/mpp/codec.js.map +1 -0
  48. package/dist/mpp/errors.d.ts +165 -0
  49. package/dist/mpp/errors.d.ts.map +1 -0
  50. package/dist/mpp/errors.js +177 -0
  51. package/dist/mpp/errors.js.map +1 -0
  52. package/dist/mpp/fetch.d.ts +196 -0
  53. package/dist/mpp/fetch.d.ts.map +1 -0
  54. package/dist/mpp/fetch.js +493 -0
  55. package/dist/mpp/fetch.js.map +1 -0
  56. package/dist/mpp/index.d.ts +11 -0
  57. package/dist/mpp/index.d.ts.map +1 -0
  58. package/dist/mpp/index.js +20 -0
  59. package/dist/mpp/index.js.map +1 -0
  60. package/dist/mpp/mpp-api.d.ts +153 -0
  61. package/dist/mpp/mpp-api.d.ts.map +1 -0
  62. package/dist/mpp/mpp-api.js +298 -0
  63. package/dist/mpp/mpp-api.js.map +1 -0
  64. package/dist/mpp/types.d.ts +43 -0
  65. package/dist/mpp/types.d.ts.map +1 -0
  66. package/dist/mpp/types.js +9 -0
  67. package/dist/mpp/types.js.map +1 -0
  68. package/dist/payments.d.ts +13 -0
  69. package/dist/payments.d.ts.map +1 -1
  70. package/dist/payments.js +3 -0
  71. package/dist/payments.js.map +1 -1
  72. package/dist/x402/delegation-api.d.ts +3 -1
  73. package/dist/x402/delegation-api.d.ts.map +1 -1
  74. package/dist/x402/delegation-api.js.map +1 -1
  75. package/dist/x402/express/index.d.ts +2 -0
  76. package/dist/x402/express/index.d.ts.map +1 -1
  77. package/dist/x402/express/index.js +2 -0
  78. package/dist/x402/express/index.js.map +1 -1
  79. package/dist/x402/express/middleware.d.ts +33 -1
  80. package/dist/x402/express/middleware.d.ts.map +1 -1
  81. package/dist/x402/express/middleware.js +831 -1
  82. package/dist/x402/express/middleware.js.map +1 -1
  83. package/dist/x402/express/mpp-support.d.ts +58 -0
  84. package/dist/x402/express/mpp-support.d.ts.map +1 -0
  85. package/dist/x402/express/mpp-support.js +67 -0
  86. package/dist/x402/express/mpp-support.js.map +1 -0
  87. package/dist/x402/express/raw-body.d.ts +24 -0
  88. package/dist/x402/express/raw-body.d.ts.map +1 -0
  89. package/dist/x402/express/raw-body.js +34 -0
  90. package/dist/x402/express/raw-body.js.map +1 -0
  91. package/dist/x402/token-request.d.ts +15 -0
  92. package/dist/x402/token-request.d.ts.map +1 -0
  93. package/dist/x402/token-request.js +66 -0
  94. package/dist/x402/token-request.js.map +1 -0
  95. package/dist/x402/token.d.ts.map +1 -1
  96. package/dist/x402/token.js +7 -51
  97. package/dist/x402/token.js.map +1 -1
  98. package/package.json +3 -1
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEpD;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,KAAK,CAAA;AAEjC,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,WAAW,EAAE,eAAe,CAAA;IAE5B;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAA;IAEjB;;OAEG;IACH,MAAM,CAAC,EAAE,aAAa,CAAA;IAEtB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;;;;;;;;;;;;OAaG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA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AC,IAAI,cAAc,CAAA;IAC9D,CAAC;IACD,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAA;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,CAAU;IACtC,OAAO,CAAC,KAAK,aAAa,IAAI,CAAC,KAAK,qBAAqB,CAAA;AAC3D,CAAC","sourcesContent":["import { EnvironmentName } from '../environments.js'\n\n/**\n * The payment scheme to use.\n * - 'nvm' (default): Nevermined-issued x402 access tokens covering both\n * credit-based ERC-4337 payments and fiat card delegations (Stripe,\n * Braintree, Visa).\n */\nexport type PaymentScheme = 'nvm'\n\nexport interface PaymentOptions {\n /**\n * The Nevermined environment to connect to.\n * If you are developing an agent it's recommended to use the \"sandbox\" environment.\n * When deploying to live use the \"live\" environment.\n */\n environment: EnvironmentName\n\n /**\n * The Nevermined API Key. This key identify your user and is required to interact with the Nevermined API.\n * You can get your API key by logging in to the Nevermined App.\n * @see https://nevermined.ai/docs/tutorials/integration/nvm-api-keys\n */\n nvmApiKey: string\n\n /**\n * The payment scheme to use. Defaults to 'nvm'.\n */\n scheme?: PaymentScheme\n\n /**\n * The URL to return to the app after a successful login.\n */\n returnUrl?: string\n\n /**\n * The app id. This attribute is optional and helps to associate assets registered into Nevermined with a common identifier.\n */\n appId?: string\n\n /**\n * Pins the Nevermined backend API version (MAJOR.MINOR) sent with every\n * request via the `Nevermined-Version` header. Defaults to\n * {@link LOCKED_API_VERSION} — the backend contract this SDK release is\n * built and tested against. Override only to deliberately target a\n * different backend contract.\n *\n * @see https://docs.nevermined.app/api-reference/versioning\n */\n version?: string\n\n /**\n * Optional organization ID to use as the active workspace for every\n * authenticated backend request. When set, the SDK sends an\n * `X-Current-Org-Id` header so the backend scopes published agents,\n * plans, and other resources to this organization.\n *\n * If omitted the backend falls back to the API key's org tag or to the\n * caller's most-recent active membership (see `CurrentOrgContextGuard`\n * in nvm-monorepo).\n *\n * Override per-call via the `organizationId` option on create methods.\n *\n * @see Payments.setOrganizationId\n */\n organizationId?: string\n}\n\nexport interface Endpoint {\n [verb: string]: string\n}\n\nexport interface ApiResponse<T> {\n success: boolean\n data?: T\n error?: string\n}\n\nexport type Address = `0x${string}`\n\n/**\n * Definition of the price configuration for a Payment Plan\n */\nexport interface PlanPriceConfig {\n /**\n * The address of the token (ERC20 or Native if zero address) for paying the plan\n */\n tokenAddress?: Address\n /**\n * The amounts to be paid for the plan\n */\n amounts: bigint[]\n /**\n * The receivers of the payments of the plan\n */\n receivers: string[]\n /**\n * The address of the smart contract that calculates the price\n */\n contractAddress?: Address\n /**\n * The address of the fee controller contract, if any\n * @remarks if not given, the fee controller is the default one\n */\n feeController?: Address\n /**\n * The address of the external price contract, if any\n */\n externalPriceAddress?: Address\n /**\n * The address of the template contract, if any\n */\n templateAddress?: Address\n /**\n * Whether this is a crypto payment (true) or fiat payment (false)\n */\n isCrypto: boolean\n /**\n * Optional currency for the plan (e.g., 'USD', 'EUR', 'USDC', 'EURC').\n * When omitted, the backend determines the default based on the payment type.\n */\n currency?: Currency | string\n}\n\n/**\n * Definition of the credits configuration for a payment plan\n */\nexport interface PlanCreditsConfig {\n /**\n * Whether the redemption amount is fixed (true) or dynamic (false)\n */\n isRedemptionAmountFixed: boolean\n /**\n * How the credits can be redeemed\n */\n redemptionType: PlanRedemptionType\n /**\n * Whether burns of these credits are mirrored on-chain. When `false`\n * (default) the credits ledger lives in the API's Postgres and burns\n * are recorded off-chain only. When `true` an `OnchainMirrorWorker`\n * replays each off-chain burn to `NFT1155Credits` for audit.\n */\n onchainMirror: boolean\n /**\n * The duration of the credits in seconds\n * @remarks 0 means non-expirable\n */\n durationSecs: bigint\n /**\n * The amount of credits that are granted when purchasing the plan (as string for API)\n */\n amount: bigint\n /**\n * The minimum number of credits redeemed when using the plan\n */\n minAmount: bigint\n /**\n * The maximum number of credits redeemed when using the plan\n */\n maxAmount: bigint\n /**\n * The address of the NFT contract that represents the plan's credits\n */\n nftAddress?: Address\n}\n\n/**\n * Different types of prices that can be configured for a plan\n * @remarks 0 - FIXED_PRICE, 1 - FIXED_FIAT_PRICE, 2 - SMART_CONTRACT_PRICE\n * If FIXED_PRICE it means the plan can be paid in crypto by a fixed amount of a ERC20 or Native token\n * If FIXED_FIAT_PRICE it means the plan can be paid in fiat by a fixed amount (typically USD)\n * If SMART_CONTRACT_PRICE it means the plan can be paid in crypto and the amount to be paid is calculated by a smart contract\n */\nexport enum PlanPriceType {\n FIXED_PRICE,\n FIXED_FIAT_PRICE,\n SMART_CONTRACT_PRICE,\n}\n\n/**\n * Supported currencies for payment plans.\n * - Fiat: USD, EUR (processed via Stripe)\n * - Crypto: USDC, EURC (ERC20 stablecoins on Base)\n */\nexport enum Currency {\n USD = 'USD',\n EUR = 'EUR',\n USDC = 'USDC',\n EURC = 'EURC',\n}\n\n/** EURC token address on Base Mainnet (chain 8453) */\nexport const EURC_TOKEN_ADDRESS: Address = '0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42'\n/** EURC token address on Base Sepolia testnet (chain 84532) */\nexport const EURC_TOKEN_ADDRESS_TESTNET: Address = '0x808456652fdb597867f38412077A9182bf77359F'\n\n/**\n * Different types of credits that can be obtained when purchasing a plan\n * @remarks 0 - EXPIRABLE, 1 - FIXED, 2 - DYNAMIC\n * If EXPIRABLE it means the credits can be used for a fixed amount of time (calculated in seconds)\n * If FIXED it means the credits can be used for a fixed amount of times\n * If DYNAMIC it means the credits can be used but the redemption amount is dynamic\n */\nexport enum PlanCreditsType {\n EXPIRABLE,\n FIXED,\n DYNAMIC,\n}\n\n/**\n * Different types of redemptions criterias that can be used when redeeming credits\n * @remarks 0 - ONLY_GLOBAL_ROLE, 1 - ONLY_OWNER, 2 - ROLE_AND_OWNER\n * If ONLY_GLOBAL_ROLE it means the credits can be redeemed only by an account with the `CREDITS_BURNER_ROLE`\n * If ONLY_OWNER it means the credits can be redeemed only by the owner of the Plan\n * If ONLY_PLAN_ROLE it means the credits can be redeemed by an account with specifics grants for the plan\n * If ONLY_SUBSCRIBER means only the subscriber (the one who holds the credits NFT) can redeem\n */\nexport enum PlanRedemptionType {\n ONLY_GLOBAL_ROLE = 0, // NVM Proxy can burn\n ONLY_OWNER = 1, // Agent can burn\n ONLY_PLAN_ROLE = 2,\n ONLY_SUBSCRIBER = 4, // Subscriber who ordered the plan can redeem\n}\n\nexport interface PlanBalance {\n planId: string\n planName: string\n planType: string\n holderAddress: Address\n balance: bigint\n creditsContract: Address\n isSubscriber: boolean\n pricePerCredit: number\n}\n\nexport interface StartAgentRequest {\n agentRequestId: string\n agentName: string\n agentId: string\n balance: PlanBalance\n urlMatching: string\n verbMatching: string\n batch: boolean\n}\n\nexport interface ValidationAgentRequest {\n balance: PlanBalance\n urlMatching: string\n verbMatching: string\n}\n\nexport interface AgentAccessCredentials {\n accessToken: string\n proxies?: string[]\n}\n\nexport interface SubscriberRequestStatus {\n planId: string\n agentId: string\n isValid: boolean\n code: number\n message?: string\n}\n\nexport interface NvmAPIResult {\n success: boolean\n message?: string\n txHash?: string\n httpStatus?: number\n data?: APIOutputData\n when?: Date\n}\n\nexport interface APIOutputData {\n [key: string]: any\n}\n\nexport interface StripeCheckoutResult {\n stripeCheckoutSessionId: string\n checkoutLink: string\n clientReferenceId: string\n paymentStatus?: string\n linkCreatedAt: number\n linkExpiresAt: number\n}\n\n/**\n * Metadata attributes describing the AI Agent.\n */\nexport interface AgentMetadata {\n /**\n * Name of the Agent\n */\n name: string\n /**\n * Description of the Agent\n */\n description?: string\n /**\n * The author of the Agent (organization or person) that own the Agent.\n */\n author?: string\n /**\n * The author of the Agent (organization or person) that own the Agent.\n */\n license?: string\n /**\n * Tags describing the AI Agent\n */\n tags?: string[]\n /**\n * Some description or instructions about how to integrate the Agent.\n */\n integration?: string\n /**\n * A link to some same usage of the Agent.\n */\n sampleLink?: string\n /**\n * Text describing the API of the Agent.\n */\n apiDescription?: string\n /**\n * The date when the Agent was created.\n */\n dateCreated?: Date\n\n // internalAttributes?: any\n}\n\n/**\n * Metadata attributes describing the Payment Plan.\n */\nexport interface PlanMetadata extends AgentMetadata {\n /**\n * Indicates if a payment plan is a Trial plan.\n * A Trial plan is a plan that allows users to test the AI Agents associated with it typically without any cost.\n * @remarks A Trial plan only can be purchased once by a user.\n */\n isTrialPlan?: boolean\n /**\n * Indicates if a payment plan is limited by credits.\n * If 'time', the plan will be limited by time.\n * If 'credits', the plan will be limited by credits.\n */\n accessLimit?: 'credits' | 'time'\n}\n\n/**\n * It describes the API exposed by an AI Agent.\n * This information is necessary to query the AI Agent and to know which endpoints are available.\n */\nexport interface AgentAPIAttributes {\n /**\n * Optional allowlist of upstream endpoints that require a valid Payment Plan\n * subscription. When provided, the Nevermined platform enforces this list as\n * **Additional Security** (defense-in-depth) on top of any per-route gating\n * the Payments library middleware applies in your agent. When omitted, no\n * route-level allowlist is enforced — your library middleware remains the\n * sole gate.\n */\n endpoints?: Endpoint[]\n /**\n * The list of endpoints of the upstream service that publicly available. The access to these endpoints don't require subscription to the Payment Plan. They are useful to expose documentation, etc.\n */\n openEndpoints?: string[]\n /**\n * Optional URL to a discoverable agent definition (OpenAPI spec, MCP\n * Manifest, or A2A agent card). Stored as metadata for documentation /\n * discovery — not consumed at runtime by the Nevermined platform.\n */\n agentDefinitionUrl?: string\n\n /////// AUTHORIZATION ///////\n\n /**\n * The upstream agent/service authentication type ('none', 'basic', 'bearer' or 'oauth').\n */\n authType?: 'none' | 'basic' | 'oauth' | 'bearer'\n /**\n * The upstream agent/service username for authentication. Only if `authType` is 'basic'.\n */\n username?: string\n /**\n * The upstream agent/service password for authentication. Only if `authType` is 'basic'.\n */\n password?: string\n /**\n * The upstream agent/service bearer token for authentication. Only if `authType` is 'bearer' or 'oauth'.\n */\n token?: string\n}\n\n/**\n * Options for pagination in API requests to the Nevermined API.\n */\nexport class PaginationOptions {\n /**\n * The field to sort the results by.\n * If not provided, the default sorting defined by the API will be applied.\n */\n sortBy?: string\n /**\n * The order in which to sort the results.\n * Default is 'desc' (descending).\n */\n sortOrder: 'asc' | 'desc' = 'desc'\n /**\n * The page number to retrieve.\n * Default is 1.\n */\n page = 1\n /**\n * The number of items per page.\n * Default is 10.\n */\n offset = 10\n\n /**\n * Constructs a new PaginationOptions instance.\n * @param options - Optional initial values for the pagination options.\n */\n constructor(options?: Partial<PaginationOptions>) {\n if (options) {\n this.sortBy = options.sortBy\n this.sortOrder = options.sortOrder || 'desc'\n this.page = options.page || 1\n this.offset = options.offset || 10\n }\n }\n\n /**\n * It returns a string representation of the pagination options\n * @returns A string representation of the pagination options as URL query parameters.\n * This can be used to append to API requests for pagination.\n */\n asQueryParams(): string {\n const params: Record<string, string> = {}\n if (this.sortBy) {\n params.sortBy = this.sortBy\n }\n params.sortOrder = this.sortOrder\n params.page = this.page.toString()\n params.pageSize = this.offset.toString()\n\n return new URLSearchParams(params).toString()\n }\n}\n\n/**\n * Status of an agent task\n */\nexport enum AgentTaskStatus {\n SUCCESS = 'SUCCESS',\n FAILED = 'FAILED',\n PENDING = 'PENDING',\n}\n\n/**\n * Data transfer object for tracking agent sub tasks\n */\nexport interface TrackAgentSubTaskDto {\n /**\n * The unique identifier of the agent task\n */\n agentRequestId: string\n\n /**\n * The number of credits burned in this agent sub task (optional)\n * @defaultValue 0\n */\n creditsToRedeem?: number\n\n /**\n * A tag to categorize this agent sub task (optional)\n */\n tag?: string\n\n /**\n * A description of this agent sub task (optional)\n */\n description?: string\n\n /**\n * The status of the agent sub task (optional)\n */\n status?: AgentTaskStatus\n}\n\nexport type SimulationRequestOptions = {\n agentName?: string\n planName?: string\n batch?: boolean\n pricePerCredit?: number\n}\n\n/**\n * x402 payment scheme type.\n * - 'nvm:erc4337': Crypto payments via ERC-4337 smart accounts\n * - 'nvm:card-delegation': Fiat/Stripe card delegation payments\n */\nexport type X402SchemeType = 'nvm:erc4337' | 'nvm:card-delegation'\n\n/**\n * Default network for each x402 scheme (backward-compat: defaults to Base Sepolia).\n */\nexport const X402_SCHEME_NETWORKS: Record<X402SchemeType, string> = {\n 'nvm:erc4337': 'eip155:84532',\n 'nvm:card-delegation': 'stripe',\n}\n\n/**\n * Environment-specific network for the erc4337 scheme.\n */\nconst ERC4337_NETWORK_BY_ENV: Record<string, string> = {\n sandbox: 'eip155:84532', // Base Sepolia\n staging_sandbox: 'eip155:84532', // Base Sepolia\n live: 'eip155:8453', // Base Mainnet\n staging_live: 'eip155:8453', // Base Mainnet\n}\n\n/**\n * Return the default network for a scheme, accounting for the environment.\n *\n * For `nvm:erc4337`, the network depends on the environment:\n * - sandbox / staging_sandbox → `eip155:84532` (Base Sepolia)\n * - live / staging_live → `eip155:8453` (Base Mainnet)\n *\n * Falls back to `X402_SCHEME_NETWORKS` when no environment is given.\n */\nexport function getDefaultNetwork(scheme: X402SchemeType, environment?: EnvironmentName): string {\n if (scheme === 'nvm:erc4337' && environment) {\n return ERC4337_NETWORK_BY_ENV[environment] ?? 'eip155:84532'\n }\n return X402_SCHEME_NETWORKS[scheme]\n}\n\n/**\n * Type guard to check if a value is a valid x402 scheme type.\n */\nexport function isValidScheme(s: unknown): s is X402SchemeType {\n return s === 'nvm:erc4337' || s === 'nvm:card-delegation'\n}\n\n/**\n * Currency codes accepted for a delegation. Lowercase, mirroring the\n * backend's `@IsIn(['usd','eur','usdc','eurc'])` constraint on\n * `POST /api/v1/delegation/create` and the Python SDK's `DelegationCurrency`.\n * Card providers use `'usd'`/`'eur'`; erc4337 uses `'usdc'`/`'eurc'`.\n */\nexport type DelegationCurrency = 'usd' | 'eur' | 'usdc' | 'eurc'\n\n/**\n * Configuration for delegation-based payments (both crypto and card schemes).\n *\n * The supported flow is **create-first**: create a delegation with\n * {@link DelegationAPI.createDelegation}, then request the access token with\n * `delegationConfig: { delegationId }`.\n *\n * @remarks\n * The inline create-on-the-fly fields (`providerPaymentMethodId`,\n * `spendingLimitCents`, `durationSecs`, `currency`, `merchantAccountId`,\n * `maxTransactions`, `cardId`) are individually deprecated. Calling\n * {@link X402TokenAPI.getX402AccessToken} with a `delegationConfig` that lacks\n * `delegationId` but carries one of those fields emits a runtime deprecation\n * warning; create the delegation first and pass only `delegationId` (optionally\n * `apiKeyId`) here. The interface itself is NOT deprecated — the\n * `{ delegationId }` reuse path is the supported way to configure a token request.\n */\nexport interface DelegationConfig {\n /**\n * PaymentMethod entity UUID — references an enrolled card.\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n cardId?: string\n /** Existing delegation UUID to reuse instead of creating a new one. The supported (non-deprecated) path. */\n delegationId?: string\n /**\n * Stripe payment method ID (e.g., 'pm_...'). Required only for new delegations.\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n providerPaymentMethodId?: string\n /**\n * Maximum spending limit in cents. Required only for new delegations.\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n spendingLimitCents?: number\n /**\n * Duration of the delegation in seconds. Required only for new delegations.\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n durationSecs?: number\n /**\n * Currency code (e.g., 'usd' for card providers, 'usdc' for erc4337).\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n currency?: DelegationCurrency\n /**\n * Merchant account ID (Stripe Connect acct_xxx or Braintree merchantId).\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n merchantAccountId?: string\n /**\n * Maximum number of transactions allowed.\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n maxTransactions?: number\n /**\n * Plan ID to scope a newly-created delegation to. Optional and additive:\n * delegations are plan-agnostic by default; supplying `planId` opts into a\n * plan-bound delegation. (Visa delegations are always plan-specific and\n * require it server-side.)\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n planId?: string\n /** NVM API Key ID to scope the delegation to. Active (non-deprecated). */\n apiKeyId?: string\n}\n\n/**\n * Payload for creating a new delegation via POST /api/v1/delegation/create.\n */\nexport interface CreateDelegationPayload {\n /** Delegation provider: 'stripe' | 'braintree' | 'visa' for card, 'erc4337' for crypto */\n provider: 'stripe' | 'braintree' | 'visa' | 'erc4337'\n /** Payment method ID from the provider (Stripe 'pm_...', Braintree vault token, or Visa Agentic token id). Required for card providers. */\n providerPaymentMethodId?: string\n /** Maximum spending limit in cents */\n spendingLimitCents: number\n /** Duration of the delegation in seconds */\n durationSecs: number\n /** Currency code (e.g., 'usd' for card providers, 'usdc' for erc4337). Required by the backend — no silent default. */\n currency: DelegationCurrency\n /**\n * Plan ID to scope the delegation to. Optional and additive: delegations are\n * plan-agnostic by default; supplying `planId` opts into a plan-bound\n * delegation. (Visa delegations are always plan-specific and require it.)\n */\n planId?: string\n /** Merchant account ID (Stripe Connect acct_xxx or Braintree merchantId) */\n merchantAccountId?: string\n /** Maximum number of transactions allowed */\n maxTransactions?: number\n /** NVM API Key ID to scope the delegation to */\n apiKeyId?: string\n}\n\n/**\n * Response from creating a delegation.\n */\nexport interface CreateDelegationResponse {\n /** Delegation token (for card delegations) */\n delegationToken?: string\n /** Delegation UUID */\n delegationId: string\n}\n\n/**\n * Options for x402 token generation that control scheme and delegation behavior.\n */\nexport interface X402TokenOptions {\n /** The x402 scheme to use (defaults to 'nvm:erc4337') */\n scheme?: X402SchemeType\n /** Network identifier (auto-derived from scheme if omitted) */\n network?: string\n /** Delegation configuration for both erc4337 and card-delegation schemes */\n delegationConfig?: DelegationConfig\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":"AA2KA;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,+DAAW,CAAA;IACX,yEAAgB,CAAA;IAChB,iFAAoB,CAAA;AACtB,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,uBAAW,CAAA;IACX,uBAAW,CAAA;IACX,yBAAa,CAAA;IACb,yBAAa,CAAA;AACf,CAAC,EALW,QAAQ,KAAR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AAC,SAAS,CAAA;QACjC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAA;QAClC,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAA;QAExC,OAAO,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAA;IAC/C,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,sCAAmB,CAAA;IACnB,oCAAiB,CAAA;IACjB,sCAAmB,CAAA;AACrB,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B;AA+CD;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAmC;IAClE,aAAa,EAAE,cAAc;IAC7B,qBAAqB,EAAE,QAAQ;CAChC,CAAA;AAED;;GAEG;AACH,MAAM,sBAAsB,GAA2B;IACrD,OAAO,EAAE,cAAc,EAAE,eAAe;IACxC,eAAe,EAAE,cAAc,EAAE,eAAe;IAChD,IAAI,EAAE,aAAa,EAAE,eAAe;IACpC,YAAY,EAAE,aAAa,EAAE,eAAe;CAC7C,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAsB,EAAE,WAA6B;IACrF,IAAI,MAAM,KAAK,aAAa,IAAI,WAAW,EAAE,CAAC;QAC5C,OAAO,sBAAsB,CAAC,WAAW,CAAC,IAAI,cAAc,CAAA;IAC9D,CAAC;IACD,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAA;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,CAAU;IACtC,OAAO,CAAC,KAAK,aAAa,IAAI,CAAC,KAAK,qBAAqB,CAAA;AAC3D,CAAC","sourcesContent":["import { EnvironmentName } from '../environments.js'\n\n/**\n * The payment scheme to use.\n * - 'nvm' (default): Nevermined-issued x402 access tokens covering both\n * credit-based ERC-4337 payments and fiat card delegations (Stripe,\n * Braintree, Visa).\n */\nexport type PaymentScheme = 'nvm'\n\nexport interface PaymentOptions {\n /**\n * The Nevermined environment to connect to.\n *\n * @deprecated The environment is now derived from the NVM API key prefix\n * (`<prefix>:<jwt>`), so this option is no longer required. It is still\n * accepted for backward compatibility and as a fallback when the key prefix\n * is unrecognized (e.g. local/custom development), but when the prefix maps\n * to a known environment the key wins and this option is ignored (a one-time\n * deprecation warning is emitted). It will be removed in a future release.\n */\n environment?: EnvironmentName\n\n /**\n * The Nevermined API Key. This key identify your user and is required to interact with the Nevermined API.\n * You can get your API key by logging in to the Nevermined App.\n * @see https://nevermined.ai/docs/tutorials/integration/nvm-api-keys\n */\n nvmApiKey: string\n\n /**\n * The payment scheme to use. Defaults to 'nvm'.\n */\n scheme?: PaymentScheme\n\n /**\n * The URL to return to the app after a successful login.\n */\n returnUrl?: string\n\n /**\n * The app id. This attribute is optional and helps to associate assets registered into Nevermined with a common identifier.\n */\n appId?: string\n\n /**\n * Pins the Nevermined backend API version (MAJOR.MINOR) sent with every\n * request via the `Nevermined-Version` header. Defaults to\n * {@link LOCKED_API_VERSION} — the backend contract this SDK release is\n * built and tested against. Override only to deliberately target a\n * different backend contract.\n *\n * @see https://nevermined.ai/docs/development-guide/api-versioning\n */\n version?: string\n\n /**\n * Optional organization ID to use as the active workspace for every\n * authenticated backend request. When set, the SDK sends an\n * `X-Current-Org-Id` header so the backend scopes published agents,\n * plans, and other resources to this organization.\n *\n * If omitted the backend falls back to the API key's org tag or to the\n * caller's most-recent active membership (see `CurrentOrgContextGuard`\n * in nvm-monorepo).\n *\n * Override per-call via the `organizationId` option on create methods.\n *\n * @see Payments.setOrganizationId\n */\n organizationId?: string\n}\n\nexport interface Endpoint {\n [verb: string]: string\n}\n\nexport interface ApiResponse<T> {\n success: boolean\n data?: T\n error?: string\n}\n\nexport type Address = `0x${string}`\n\n/**\n * Definition of the price configuration for a Payment Plan\n */\nexport interface PlanPriceConfig {\n /**\n * The address of the token (ERC20 or Native if zero address) for paying the plan\n */\n tokenAddress?: Address\n /**\n * The amounts to be paid for the plan\n */\n amounts: bigint[]\n /**\n * The receivers of the payments of the plan\n */\n receivers: string[]\n /**\n * The address of the smart contract that calculates the price\n */\n contractAddress?: Address\n /**\n * The address of the fee controller contract, if any\n * @remarks if not given, the fee controller is the default one\n */\n feeController?: Address\n /**\n * The address of the external price contract, if any\n */\n externalPriceAddress?: Address\n /**\n * The address of the template contract, if any\n */\n templateAddress?: Address\n /**\n * Whether this is a crypto payment (true) or fiat payment (false)\n */\n isCrypto: boolean\n /**\n * Optional currency for the plan (e.g., 'USD', 'EUR', 'USDC', 'EURC').\n * When omitted, the backend determines the default based on the payment type.\n */\n currency?: Currency | string\n}\n\n/**\n * Definition of the credits configuration for a payment plan\n */\nexport interface PlanCreditsConfig {\n /**\n * Whether the redemption amount is fixed (true) or dynamic (false)\n */\n isRedemptionAmountFixed: boolean\n /**\n * How the credits can be redeemed\n */\n redemptionType: PlanRedemptionType\n /**\n * Whether burns of these credits are mirrored on-chain. When `false`\n * (default) the credits ledger lives in the API's Postgres and burns\n * are recorded off-chain only. When `true` an `OnchainMirrorWorker`\n * replays each off-chain burn to `NFT1155Credits` for audit.\n */\n onchainMirror: boolean\n /**\n * The duration of the credits in seconds\n * @remarks 0 means non-expirable\n */\n durationSecs: bigint\n /**\n * The amount of credits that are granted when purchasing the plan (as string for API)\n */\n amount: bigint\n /**\n * The minimum number of credits redeemed when using the plan\n */\n minAmount: bigint\n /**\n * The maximum number of credits redeemed when using the plan\n */\n maxAmount: bigint\n /**\n * The address of the NFT contract that represents the plan's credits\n */\n nftAddress?: Address\n}\n\n/**\n * Different types of prices that can be configured for a plan\n * @remarks 0 - FIXED_PRICE, 1 - FIXED_FIAT_PRICE, 2 - SMART_CONTRACT_PRICE\n * If FIXED_PRICE it means the plan can be paid in crypto by a fixed amount of a ERC20 or Native token\n * If FIXED_FIAT_PRICE it means the plan can be paid in fiat by a fixed amount (typically USD)\n * If SMART_CONTRACT_PRICE it means the plan can be paid in crypto and the amount to be paid is calculated by a smart contract\n */\nexport enum PlanPriceType {\n FIXED_PRICE,\n FIXED_FIAT_PRICE,\n SMART_CONTRACT_PRICE,\n}\n\n/**\n * Supported currencies for payment plans.\n * - Fiat: USD, EUR (processed via Stripe)\n * - Crypto: USDC, EURC (ERC20 stablecoins on Base)\n */\nexport enum Currency {\n USD = 'USD',\n EUR = 'EUR',\n USDC = 'USDC',\n EURC = 'EURC',\n}\n\n/** EURC token address on Base Mainnet (chain 8453) */\nexport const EURC_TOKEN_ADDRESS: Address = '0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42'\n/** EURC token address on Base Sepolia testnet (chain 84532) */\nexport const EURC_TOKEN_ADDRESS_TESTNET: Address = '0x808456652fdb597867f38412077A9182bf77359F'\n\n/**\n * Different types of credits that can be obtained when purchasing a plan\n * @remarks 0 - EXPIRABLE, 1 - FIXED, 2 - DYNAMIC\n * If EXPIRABLE it means the credits can be used for a fixed amount of time (calculated in seconds)\n * If FIXED it means the credits can be used for a fixed amount of times\n * If DYNAMIC it means the credits can be used but the redemption amount is dynamic\n */\nexport enum PlanCreditsType {\n EXPIRABLE,\n FIXED,\n DYNAMIC,\n}\n\n/**\n * Different types of redemptions criterias that can be used when redeeming credits\n * @remarks 0 - ONLY_GLOBAL_ROLE, 1 - ONLY_OWNER, 2 - ROLE_AND_OWNER\n * If ONLY_GLOBAL_ROLE it means the credits can be redeemed only by an account with the `CREDITS_BURNER_ROLE`\n * If ONLY_OWNER it means the credits can be redeemed only by the owner of the Plan\n * If ONLY_PLAN_ROLE it means the credits can be redeemed by an account with specifics grants for the plan\n * If ONLY_SUBSCRIBER means only the subscriber (the one who holds the credits NFT) can redeem\n */\nexport enum PlanRedemptionType {\n ONLY_GLOBAL_ROLE = 0, // NVM Proxy can burn\n ONLY_OWNER = 1, // Agent can burn\n ONLY_PLAN_ROLE = 2,\n ONLY_SUBSCRIBER = 4, // Subscriber who ordered the plan can redeem\n}\n\nexport interface PlanBalance {\n planId: string\n planName: string\n planType: string\n holderAddress: Address\n balance: bigint\n creditsContract: Address\n isSubscriber: boolean\n pricePerCredit: number\n}\n\nexport interface StartAgentRequest {\n agentRequestId: string\n agentName: string\n agentId: string\n balance: PlanBalance\n urlMatching: string\n verbMatching: string\n batch: boolean\n}\n\nexport interface ValidationAgentRequest {\n balance: PlanBalance\n urlMatching: string\n verbMatching: string\n}\n\nexport interface AgentAccessCredentials {\n accessToken: string\n proxies?: string[]\n}\n\nexport interface SubscriberRequestStatus {\n planId: string\n agentId: string\n isValid: boolean\n code: number\n message?: string\n}\n\nexport interface NvmAPIResult {\n success: boolean\n message?: string\n txHash?: string\n httpStatus?: number\n data?: APIOutputData\n when?: Date\n}\n\nexport interface APIOutputData {\n [key: string]: any\n}\n\nexport interface StripeCheckoutResult {\n stripeCheckoutSessionId: string\n checkoutLink: string\n clientReferenceId: string\n paymentStatus?: string\n linkCreatedAt: number\n linkExpiresAt: number\n}\n\n/**\n * Metadata attributes describing the AI Agent.\n */\nexport interface AgentMetadata {\n /**\n * Name of the Agent\n */\n name: string\n /**\n * Description of the Agent\n */\n description?: string\n /**\n * The author of the Agent (organization or person) that own the Agent.\n */\n author?: string\n /**\n * The author of the Agent (organization or person) that own the Agent.\n */\n license?: string\n /**\n * Tags describing the AI Agent\n */\n tags?: string[]\n /**\n * Some description or instructions about how to integrate the Agent.\n */\n integration?: string\n /**\n * A link to some same usage of the Agent.\n */\n sampleLink?: string\n /**\n * Text describing the API of the Agent.\n */\n apiDescription?: string\n /**\n * The date when the Agent was created.\n */\n dateCreated?: Date\n\n // internalAttributes?: any\n}\n\n/**\n * Metadata attributes describing the Payment Plan.\n */\nexport interface PlanMetadata extends AgentMetadata {\n /**\n * Indicates if a payment plan is a Trial plan.\n * A Trial plan is a plan that allows users to test the AI Agents associated with it typically without any cost.\n * @remarks A Trial plan only can be purchased once by a user.\n */\n isTrialPlan?: boolean\n /**\n * Indicates if a payment plan is limited by credits.\n * If 'time', the plan will be limited by time.\n * If 'credits', the plan will be limited by credits.\n */\n accessLimit?: 'credits' | 'time'\n}\n\n/**\n * It describes the API exposed by an AI Agent.\n * This information is necessary to query the AI Agent and to know which endpoints are available.\n */\nexport interface AgentAPIAttributes {\n /**\n * Optional allowlist of upstream endpoints that require a valid Payment Plan\n * subscription. When provided, the Nevermined platform enforces this list as\n * **Additional Security** (defense-in-depth) on top of any per-route gating\n * the Payments library middleware applies in your agent. When omitted, no\n * route-level allowlist is enforced — your library middleware remains the\n * sole gate.\n */\n endpoints?: Endpoint[]\n /**\n * The list of endpoints of the upstream service that publicly available. The access to these endpoints don't require subscription to the Payment Plan. They are useful to expose documentation, etc.\n */\n openEndpoints?: string[]\n /**\n * Optional URL to a discoverable agent definition (OpenAPI spec, MCP\n * Manifest, or A2A agent card). Stored as metadata for documentation /\n * discovery — not consumed at runtime by the Nevermined platform.\n */\n agentDefinitionUrl?: string\n\n /////// AUTHORIZATION ///////\n\n /**\n * The upstream agent/service authentication type ('none', 'basic', 'bearer' or 'oauth').\n */\n authType?: 'none' | 'basic' | 'oauth' | 'bearer'\n /**\n * The upstream agent/service username for authentication. Only if `authType` is 'basic'.\n */\n username?: string\n /**\n * The upstream agent/service password for authentication. Only if `authType` is 'basic'.\n */\n password?: string\n /**\n * The upstream agent/service bearer token for authentication. Only if `authType` is 'bearer' or 'oauth'.\n */\n token?: string\n}\n\n/**\n * Options for pagination in API requests to the Nevermined API.\n */\nexport class PaginationOptions {\n /**\n * The field to sort the results by.\n * If not provided, the default sorting defined by the API will be applied.\n */\n sortBy?: string\n /**\n * The order in which to sort the results.\n * Default is 'desc' (descending).\n */\n sortOrder: 'asc' | 'desc' = 'desc'\n /**\n * The page number to retrieve.\n * Default is 1.\n */\n page = 1\n /**\n * The number of items per page.\n * Default is 10.\n */\n offset = 10\n\n /**\n * Constructs a new PaginationOptions instance.\n * @param options - Optional initial values for the pagination options.\n */\n constructor(options?: Partial<PaginationOptions>) {\n if (options) {\n this.sortBy = options.sortBy\n this.sortOrder = options.sortOrder || 'desc'\n this.page = options.page || 1\n this.offset = options.offset || 10\n }\n }\n\n /**\n * It returns a string representation of the pagination options\n * @returns A string representation of the pagination options as URL query parameters.\n * This can be used to append to API requests for pagination.\n */\n asQueryParams(): string {\n const params: Record<string, string> = {}\n if (this.sortBy) {\n params.sortBy = this.sortBy\n }\n params.sortOrder = this.sortOrder\n params.page = this.page.toString()\n params.pageSize = this.offset.toString()\n\n return new URLSearchParams(params).toString()\n }\n}\n\n/**\n * Status of an agent task\n */\nexport enum AgentTaskStatus {\n SUCCESS = 'SUCCESS',\n FAILED = 'FAILED',\n PENDING = 'PENDING',\n}\n\n/**\n * Data transfer object for tracking agent sub tasks\n */\nexport interface TrackAgentSubTaskDto {\n /**\n * The unique identifier of the agent task\n */\n agentRequestId: string\n\n /**\n * The number of credits burned in this agent sub task (optional)\n * @defaultValue 0\n */\n creditsToRedeem?: number\n\n /**\n * A tag to categorize this agent sub task (optional)\n */\n tag?: string\n\n /**\n * A description of this agent sub task (optional)\n */\n description?: string\n\n /**\n * The status of the agent sub task (optional)\n */\n status?: AgentTaskStatus\n}\n\nexport type SimulationRequestOptions = {\n agentName?: string\n planName?: string\n batch?: boolean\n pricePerCredit?: number\n}\n\n/**\n * x402 payment scheme type.\n * - 'nvm:erc4337': Crypto payments via ERC-4337 smart accounts\n * - 'nvm:card-delegation': Fiat/Stripe card delegation payments\n */\nexport type X402SchemeType = 'nvm:erc4337' | 'nvm:card-delegation'\n\n/**\n * Default network for each x402 scheme (backward-compat: defaults to Base Sepolia).\n */\nexport const X402_SCHEME_NETWORKS: Record<X402SchemeType, string> = {\n 'nvm:erc4337': 'eip155:84532',\n 'nvm:card-delegation': 'stripe',\n}\n\n/**\n * Environment-specific network for the erc4337 scheme.\n */\nconst ERC4337_NETWORK_BY_ENV: Record<string, string> = {\n sandbox: 'eip155:84532', // Base Sepolia\n staging_sandbox: 'eip155:84532', // Base Sepolia\n live: 'eip155:8453', // Base Mainnet\n staging_live: 'eip155:8453', // Base Mainnet\n}\n\n/**\n * Return the default network for a scheme, accounting for the environment.\n *\n * For `nvm:erc4337`, the network depends on the environment:\n * - sandbox / staging_sandbox → `eip155:84532` (Base Sepolia)\n * - live / staging_live → `eip155:8453` (Base Mainnet)\n *\n * Falls back to `X402_SCHEME_NETWORKS` when no environment is given.\n */\nexport function getDefaultNetwork(scheme: X402SchemeType, environment?: EnvironmentName): string {\n if (scheme === 'nvm:erc4337' && environment) {\n return ERC4337_NETWORK_BY_ENV[environment] ?? 'eip155:84532'\n }\n return X402_SCHEME_NETWORKS[scheme]\n}\n\n/**\n * Type guard to check if a value is a valid x402 scheme type.\n */\nexport function isValidScheme(s: unknown): s is X402SchemeType {\n return s === 'nvm:erc4337' || s === 'nvm:card-delegation'\n}\n\n/**\n * Currency codes accepted for a delegation. Lowercase, mirroring the\n * backend's `@IsIn(['usd','eur','usdc','eurc'])` constraint on\n * `POST /api/v1/delegation/create` and the Python SDK's `DelegationCurrency`.\n * Card providers use `'usd'`/`'eur'`; erc4337 uses `'usdc'`/`'eurc'`.\n */\nexport type DelegationCurrency = 'usd' | 'eur' | 'usdc' | 'eurc'\n\n/**\n * Configuration for delegation-based payments (both crypto and card schemes).\n *\n * The supported flow is **create-first**: create a delegation with\n * {@link DelegationAPI.createDelegation}, then request the access token with\n * `delegationConfig: { delegationId }`.\n *\n * @remarks\n * The inline create-on-the-fly fields (`providerPaymentMethodId`,\n * `spendingLimitCents`, `durationSecs`, `currency`, `merchantAccountId`,\n * `maxTransactions`, `cardId`) are individually deprecated. Calling\n * {@link X402TokenAPI.getX402AccessToken} with a `delegationConfig` that lacks\n * `delegationId` but carries one of those fields emits a runtime deprecation\n * warning; create the delegation first and pass only `delegationId` (optionally\n * `apiKeyId`) here. The interface itself is NOT deprecated — the\n * `{ delegationId }` reuse path is the supported way to configure a token request.\n */\nexport interface DelegationConfig {\n /**\n * PaymentMethod entity UUID — references an enrolled card.\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n cardId?: string\n /** Existing delegation UUID to reuse instead of creating a new one. The supported (non-deprecated) path. */\n delegationId?: string\n /**\n * Stripe payment method ID (e.g., 'pm_...'). Required only for new delegations.\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n providerPaymentMethodId?: string\n /**\n * Maximum spending limit in cents. Required only for new delegations.\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n spendingLimitCents?: number\n /**\n * Duration of the delegation in seconds. Required only for new delegations.\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n durationSecs?: number\n /**\n * Currency code (e.g., 'usd' for card providers, 'usdc' for erc4337).\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n currency?: DelegationCurrency\n /**\n * Merchant account ID (Stripe Connect acct_xxx or Braintree merchantId).\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n merchantAccountId?: string\n /**\n * Maximum number of transactions allowed.\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n maxTransactions?: number\n /**\n * Plan ID to scope a newly-created delegation to. Optional and additive:\n * delegations are plan-agnostic by default; supplying `planId` opts into a\n * plan-bound delegation. (Visa delegations are always plan-specific and\n * require it server-side.)\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n planId?: string\n /** NVM API Key ID to scope the delegation to. Active (non-deprecated). */\n apiKeyId?: string\n}\n\n/**\n * Payload for creating a new delegation via POST /api/v1/delegation/create.\n */\nexport interface CreateDelegationPayload {\n /** Delegation provider: 'stripe' | 'braintree' | 'visa' for card, 'erc4337' for crypto */\n provider: 'stripe' | 'braintree' | 'visa' | 'erc4337'\n /** Payment method ID from the provider (Stripe 'pm_...', Braintree vault token, or Visa Agentic token id). Required for card providers. */\n providerPaymentMethodId?: string\n /** Maximum spending limit in cents */\n spendingLimitCents: number\n /** Duration of the delegation in seconds */\n durationSecs: number\n /** Currency code (e.g., 'usd' for card providers, 'usdc' for erc4337). Required by the backend — no silent default. */\n currency: DelegationCurrency\n /**\n * Plan ID to scope the delegation to. Optional and additive: delegations are\n * plan-agnostic by default; supplying `planId` opts into a plan-bound\n * delegation. (Visa delegations are always plan-specific and require it.)\n */\n planId?: string\n /** Merchant account ID (Stripe Connect acct_xxx or Braintree merchantId) */\n merchantAccountId?: string\n /** Maximum number of transactions allowed */\n maxTransactions?: number\n /** NVM API Key ID to scope the delegation to */\n apiKeyId?: string\n}\n\n/**\n * Response from creating a delegation.\n */\nexport interface CreateDelegationResponse {\n /** Delegation token (for card delegations) */\n delegationToken?: string\n /** Delegation UUID */\n delegationId: string\n}\n\n/**\n * Options for x402 token generation that control scheme and delegation behavior.\n */\nexport interface X402TokenOptions {\n /** The x402 scheme to use (defaults to 'nvm:erc4337') */\n scheme?: X402SchemeType\n /** Network identifier (auto-derived from scheme if omitted) */\n network?: string\n /** Delegation configuration for both erc4337 and card-delegation schemes */\n delegationConfig?: DelegationConfig\n}\n"]}
@@ -14,6 +14,18 @@ export interface EnvironmentInfo {
14
14
  }
15
15
  export declare const ZeroAddress = "0x0000000000000000000000000000000000000000";
16
16
  export type EnvironmentName = 'staging_sandbox' | 'staging_live' | 'sandbox' | 'live' | 'custom';
17
+ /**
18
+ * Maps the prefix of an NVM API key (`<prefix>:<jwt>`) to the environment the
19
+ * key targets. This is the inverse of the backend's `addPrefixToToken`: a key
20
+ * minted for `staging_sandbox` carries the prefix `sandbox-staging`, i.e.
21
+ * `{env}-{deployment}` on the wire maps to `{deployment}_{env}` here.
22
+ *
23
+ * @param nvmApiKey - The full NVM API key (`<prefix>:<jwt>`), or a bare JWT.
24
+ * @returns The mapped {@link EnvironmentName}, or `undefined` when the key has
25
+ * no prefix or the prefix is not recognized (caller falls back to the
26
+ * deprecated `environment` option, else `custom`).
27
+ */
28
+ export declare const getEnvironmentFromApiKey: (nvmApiKey: string) => EnvironmentName | undefined;
17
29
  /**
18
30
  * Represents the different environments and their corresponding URLs.
19
31
  */
@@ -1 +1 @@
1
- {"version":3,"file":"environments.d.ts","sourceRoot":"","sources":["../src/environments.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAA;IAChB;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,eAAO,MAAM,WAAW,+CAA+C,CAAA;AAEvE,MAAM,MAAM,eAAe,GAAG,iBAAiB,GAAG,cAAc,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAA;AAEhG;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,eAAe,EAAE,eAAe,CAqDjE,CAAA"}
1
+ {"version":3,"file":"environments.d.ts","sourceRoot":"","sources":["../src/environments.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAA;IAChB;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,eAAO,MAAM,WAAW,+CAA+C,CAAA;AAEvE,MAAM,MAAM,eAAe,GAAG,iBAAiB,GAAG,cAAc,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAA;AAEhG;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,GAAI,WAAW,MAAM,KAAG,eAAe,GAAG,SAkB9E,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,eAAe,EAAE,eAAe,CAqDjE,CAAA"}
@@ -1,4 +1,35 @@
1
1
  export const ZeroAddress = '0x0000000000000000000000000000000000000000';
2
+ /**
3
+ * Maps the prefix of an NVM API key (`<prefix>:<jwt>`) to the environment the
4
+ * key targets. This is the inverse of the backend's `addPrefixToToken`: a key
5
+ * minted for `staging_sandbox` carries the prefix `sandbox-staging`, i.e.
6
+ * `{env}-{deployment}` on the wire maps to `{deployment}_{env}` here.
7
+ *
8
+ * @param nvmApiKey - The full NVM API key (`<prefix>:<jwt>`), or a bare JWT.
9
+ * @returns The mapped {@link EnvironmentName}, or `undefined` when the key has
10
+ * no prefix or the prefix is not recognized (caller falls back to the
11
+ * deprecated `environment` option, else `custom`).
12
+ */
13
+ export const getEnvironmentFromApiKey = (nvmApiKey) => {
14
+ if (!nvmApiKey || !nvmApiKey.includes(':'))
15
+ return undefined;
16
+ // Backend-minted prefixes are always lowercase; lowercasing keeps this in
17
+ // exact parity with the payments-py sibling and tolerates a non-canonical
18
+ // uppercase prefix.
19
+ const prefix = nvmApiKey.slice(0, nvmApiKey.indexOf(':')).toLowerCase();
20
+ switch (prefix) {
21
+ case 'sandbox-staging':
22
+ return 'staging_sandbox';
23
+ case 'live-staging':
24
+ return 'staging_live';
25
+ case 'sandbox':
26
+ return 'sandbox';
27
+ case 'live':
28
+ return 'live';
29
+ default:
30
+ return undefined;
31
+ }
32
+ };
2
33
  /**
3
34
  * Represents the different environments and their corresponding URLs.
4
35
  */
@@ -1 +1 @@
1
- {"version":3,"file":"environments.js","sourceRoot":"","sources":["../src/environments.ts"],"names":[],"mappings":"AAeA,MAAM,CAAC,MAAM,WAAW,GAAG,4CAA4C,CAAA;AAIvE;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAA6C;IACpE;;OAEG;IACH,eAAe,EAAE;QACf,QAAQ,EAAE,wBAAwB;QAClC,KAAK,EAAE,8BAA8B;QACrC,OAAO,EAAE,qCAAqC;QAC9C,KAAK,EAAE,sCAAsC;QAC7C,WAAW,EAAE,iCAAiC;KAC/C;IACD,YAAY,EAAE;QACZ,QAAQ,EAAE,wBAAwB;QAClC,KAAK,EAAE,8BAA8B;QACrC,OAAO,EAAE,kCAAkC;QAC3C,KAAK,EAAE,mCAAmC;QAC1C,WAAW,EAAE,iCAAiC;KAC/C;IACD;;OAEG;IACH,OAAO,EAAE;QACP,QAAQ,EAAE,wBAAwB;QAClC,KAAK,EAAE,8BAA8B;QACrC,OAAO,EAAE,qCAAqC;QAC9C,KAAK,EAAE,sCAAsC;QAC7C,WAAW,EAAE,iCAAiC;KAC/C;IACD;;OAEG;IACH,IAAI,EAAE;QACJ,QAAQ,EAAE,wBAAwB;QAClC,KAAK,EAAE,8BAA8B;QACrC,OAAO,EAAE,kCAAkC;QAC3C,KAAK,EAAE,mCAAmC;QAC1C,WAAW,EAAE,iCAAiC;KAC/C;IACD;;OAEG;IACH,MAAM,EAAE;QACN,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,uBAAuB;QACjE,oEAAoE;QACpE,kEAAkE;QAClE,kEAAkE;QAClE,gEAAgE;QAChE,YAAY;QACZ,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,uBAAuB;QAC3D,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,uBAAuB;QAC/D,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,uBAAuB;QAC3D,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,uBAAuB;KACjE;CACF,CAAA","sourcesContent":["export interface EnvironmentInfo {\n frontend: string\n /**\n * Base URL of the standalone, Privy-free embed app (the `embed.<tier>`\n * origin that serves the chromeless `/cards/*` and `/checkout/*` pages).\n * Formed by prepending `embed.` to the webapp host. The CLI redirect-mode\n * card flows open `${embed}/cards/setup` here — the old webapp\n * `/embed/cards/*` routes were removed in the #1787 cutover.\n */\n embed: string\n backend: string\n proxy: string\n heliconeUrl: string\n}\n\nexport const ZeroAddress = '0x0000000000000000000000000000000000000000'\n\nexport type EnvironmentName = 'staging_sandbox' | 'staging_live' | 'sandbox' | 'live' | 'custom'\n\n/**\n * Represents the different environments and their corresponding URLs.\n */\nexport const Environments: Record<EnvironmentName, EnvironmentInfo> = {\n /**\n * The staging environment URLs.\n */\n staging_sandbox: {\n frontend: 'https://nevermined.dev',\n embed: 'https://embed.nevermined.dev',\n backend: 'https://api.sandbox.nevermined.dev/',\n proxy: 'https://proxy.sandbox.nevermined.dev',\n heliconeUrl: 'https://helicone.nevermined.dev',\n },\n staging_live: {\n frontend: 'https://nevermined.dev',\n embed: 'https://embed.nevermined.dev',\n backend: 'https://api.live.nevermined.dev/',\n proxy: 'https://proxy.live.nevermined.dev',\n heliconeUrl: 'https://helicone.nevermined.dev',\n },\n /**\n * The Sandbox environment URLs.\n */\n sandbox: {\n frontend: 'https://nevermined.app',\n embed: 'https://embed.nevermined.app',\n backend: 'https://api.sandbox.nevermined.app/',\n proxy: 'https://proxy.sandbox.nevermined.app',\n heliconeUrl: 'https://helicone.nevermined.dev',\n },\n /**\n * The Live environment URLs.\n */\n live: {\n frontend: 'https://nevermined.app',\n embed: 'https://embed.nevermined.app',\n backend: 'https://api.live.nevermined.app/',\n proxy: 'https://proxy.live.nevermined.app',\n heliconeUrl: 'https://helicone.nevermined.dev',\n },\n /**\n * A custom environment URLs.\n */\n custom: {\n frontend: process.env.NVM_FRONTEND_URL || 'http://localhost:4200',\n // No fallback to NVM_FRONTEND_URL: the webapp host no longer serves\n // the card pages post-#1787 cutover, so silently reusing it would\n // reintroduce a dead-route footgun. The embed app runs on its own\n // port (4250, matching nvm-monorepo#1824); set NVM_EMBED_URL to\n // override.\n embed: process.env.NVM_EMBED_URL || 'http://localhost:4250',\n backend: process.env.NVM_BACKEND_URL || 'http://localhost:3001',\n proxy: process.env.NVM_PROXY_URL || 'https://localhost:443',\n heliconeUrl: process.env.HELICONE_URL || 'http://localhost:8585',\n },\n}\n"]}
1
+ {"version":3,"file":"environments.js","sourceRoot":"","sources":["../src/environments.ts"],"names":[],"mappings":"AAeA,MAAM,CAAC,MAAM,WAAW,GAAG,4CAA4C,CAAA;AAIvE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,C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AE,mCAAmC;QAC1C,WAAW,EAAE,iCAAiC;KAC/C;IACD;;OAEG;IACH,MAAM,EAAE;QACN,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,uBAAuB;QACjE,oEAAoE;QACpE,kEAAkE;QAClE,kEAAkE;QAClE,gEAAgE;QAChE,YAAY;QACZ,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,uBAAuB;QAC3D,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,uBAAuB;QAC/D,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,uBAAuB;QAC3D,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,uBAAuB;KACjE;CACF,CAAA","sourcesContent":["export interface EnvironmentInfo {\n frontend: string\n /**\n * Base URL of the standalone, Privy-free embed app (the `embed.<tier>`\n * origin that serves the chromeless `/cards/*` and `/checkout/*` pages).\n * Formed by prepending `embed.` to the webapp host. The CLI redirect-mode\n * card flows open `${embed}/cards/setup` here — the old webapp\n * `/embed/cards/*` routes were removed in the #1787 cutover.\n */\n embed: string\n backend: string\n proxy: string\n heliconeUrl: string\n}\n\nexport const ZeroAddress = '0x0000000000000000000000000000000000000000'\n\nexport type EnvironmentName = 'staging_sandbox' | 'staging_live' | 'sandbox' | 'live' | 'custom'\n\n/**\n * Maps the prefix of an NVM API key (`<prefix>:<jwt>`) to the environment the\n * key targets. This is the inverse of the backend's `addPrefixToToken`: a key\n * minted for `staging_sandbox` carries the prefix `sandbox-staging`, i.e.\n * `{env}-{deployment}` on the wire maps to `{deployment}_{env}` here.\n *\n * @param nvmApiKey - The full NVM API key (`<prefix>:<jwt>`), or a bare JWT.\n * @returns The mapped {@link EnvironmentName}, or `undefined` when the key has\n * no prefix or the prefix is not recognized (caller falls back to the\n * deprecated `environment` option, else `custom`).\n */\nexport const getEnvironmentFromApiKey = (nvmApiKey: string): EnvironmentName | undefined => {\n if (!nvmApiKey || !nvmApiKey.includes(':')) return undefined\n // Backend-minted prefixes are always lowercase; lowercasing keeps this in\n // exact parity with the payments-py sibling and tolerates a non-canonical\n // uppercase prefix.\n const prefix = nvmApiKey.slice(0, nvmApiKey.indexOf(':')).toLowerCase()\n switch (prefix) {\n case 'sandbox-staging':\n return 'staging_sandbox'\n case 'live-staging':\n return 'staging_live'\n case 'sandbox':\n return 'sandbox'\n case 'live':\n return 'live'\n default:\n return undefined\n }\n}\n\n/**\n * Represents the different environments and their corresponding URLs.\n */\nexport const Environments: Record<EnvironmentName, EnvironmentInfo> = {\n /**\n * The staging environment URLs.\n */\n staging_sandbox: {\n frontend: 'https://nevermined.dev',\n embed: 'https://embed.nevermined.dev',\n backend: 'https://api.sandbox.nevermined.dev/',\n proxy: 'https://proxy.sandbox.nevermined.dev',\n heliconeUrl: 'https://helicone.nevermined.dev',\n },\n staging_live: {\n frontend: 'https://nevermined.dev',\n embed: 'https://embed.nevermined.dev',\n backend: 'https://api.live.nevermined.dev/',\n proxy: 'https://proxy.live.nevermined.dev',\n heliconeUrl: 'https://helicone.nevermined.dev',\n },\n /**\n * The Sandbox environment URLs.\n */\n sandbox: {\n frontend: 'https://nevermined.app',\n embed: 'https://embed.nevermined.app',\n backend: 'https://api.sandbox.nevermined.app/',\n proxy: 'https://proxy.sandbox.nevermined.app',\n heliconeUrl: 'https://helicone.nevermined.dev',\n },\n /**\n * The Live environment URLs.\n */\n live: {\n frontend: 'https://nevermined.app',\n embed: 'https://embed.nevermined.app',\n backend: 'https://api.live.nevermined.app/',\n proxy: 'https://proxy.live.nevermined.app',\n heliconeUrl: 'https://helicone.nevermined.dev',\n },\n /**\n * A custom environment URLs.\n */\n custom: {\n frontend: process.env.NVM_FRONTEND_URL || 'http://localhost:4200',\n // No fallback to NVM_FRONTEND_URL: the webapp host no longer serves\n // the card pages post-#1787 cutover, so silently reusing it would\n // reintroduce a dead-route footgun. The embed app runs on its own\n // port (4250, matching nvm-monorepo#1824); set NVM_EMBED_URL to\n // override.\n embed: process.env.NVM_EMBED_URL || 'http://localhost:4250',\n backend: process.env.NVM_BACKEND_URL || 'http://localhost:3001',\n proxy: process.env.NVM_PROXY_URL || 'https://localhost:443',\n heliconeUrl: process.env.HELICONE_URL || 'http://localhost:8585',\n },\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -18,6 +18,7 @@ export { buildPaymentRequired, resolveNetwork, resolveScheme } from './x402/faci
18
18
  export { DelegationAPI } from './x402/delegation-api.js';
19
19
  export type { PaymentMethodSummary, UpdatePaymentMethodDto, DelegationSummary, DelegationListResponse, PurchasingPower, ListOptions, } from './x402/delegation-api.js';
20
20
  export type { X402PaymentRequired, X402PaymentAccepted, X402Resource, X402Scheme, X402SchemeExtra, VerifyPermissionsParams, VerifyPermissionsResult, SettlePermissionsParams, SettlePermissionsResult, } from './x402/facilitator-api.js';
21
+ export * from './mpp/index.js';
21
22
  export type { CreditsContext, CreditsOption, PaywallOptions, McpConfig, PaywallContext, AuthResult, } from './mcp/types/paywall.types.js';
22
23
  export type { OAuthUrls, OAuthConfig, HttpRouterConfig, HttpServerConfig, HttpServerResult, } from './mcp/types/http.types.js';
23
24
  export type { ExtendedMcpConfig } from './mcp/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,8CAA8C,CAAA;AAC5D,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,YAA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BAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,2BAA2B,CAAA;AAGlC,cAAc,gBAAgB,CAAA;AAG9B,YAAY,EACV,cAAc,EACd,aAAa,EACb,cAAc,EACd,SAAS,EACT,cAAc,EACd,UAAU,GACX,MAAM,8BAA8B,CAAA;AAGrC,YAAY,EACV,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,2BAA2B,CAAA;AAGlC,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAGvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAExE,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,IAAI,EACJ,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,0BAA0B,EAC1B,qCAAqC,EACrC,YAAY,EACZ,qCAAqC,GACtC,MAAM,gBAAgB,CAAA;AAGvB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,4BAA4B,EAC5B,aAAa,IAAI,gBAAgB,GAClC,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,EAC1B,iCAAiC,GAClC,MAAM,qBAAqB,CAAA"}
package/dist/index.js CHANGED
@@ -14,6 +14,8 @@ export { OrganizationMemberRole, OrganizationType, OrganizationActivityEventType
14
14
  // x402 utilities and types
15
15
  export { buildPaymentRequired, resolveNetwork, resolveScheme } from './x402/facilitator-api.js';
16
16
  export { DelegationAPI } from './x402/delegation-api.js';
17
+ // MPP (Machine Payments Protocol) public surface
18
+ export * from './mpp/index.js';
17
19
  // MCP HTTP utilities
18
20
  export { createRequireAuthMiddleware } from './mcp/http/oauth-router.js';
19
21
  // x402 v2 A2A in-band transport utilities (mirrors the Python X402A2AUtils)
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,8CAA8C,CAAA;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAA;AAC/E,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,6BAA6B,GAC9B,MAAM,kCAAkC,CAAA;AAQzC,2BAA2B;AAC3B,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC/F,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AA0CxD,qBAAqB;AACrB,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAqBxE,4EAA4E;AAC5E,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,4BAA4B,EAC5B,aAAa,IAAI,gBAAgB,GAClC,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,EAC1B,iCAAiC,GAClC,MAAM,qBAAqB,CAAA","sourcesContent":["export * from './environments.js'\nexport * from './payments.js'\nexport * from './utils.js'\nexport * from './common/api-version.js'\nexport * from './common/types.js'\nexport * from './common/payments.error.js'\nexport * from './common/helper.js'\nexport * from './api/query-api.js'\nexport * from './api/observability-api/observability-api.js'\nexport type { BackendApiOptions } from './api/nvm-api.js'\nexport { ContractsAPI } from './api/contracts-api.js'\nexport { CURRENT_ORG_ID_HEADER } from './api/base-payments.js'\nexport type { PublicationOptions } from './api/base-payments.js'\nexport { OrganizationsAPI } from './api/organizations-api/organizations-api.js'\nexport {\n OrganizationMemberRole,\n OrganizationType,\n OrganizationActivityEventType,\n} from './api/organizations-api/types.js'\nexport type {\n MyMembership,\n OrganizationActivityEvent,\n OrganizationActivityFilters,\n OrganizationActivityPage,\n} from './api/organizations-api/types.js'\n\n// x402 utilities and types\nexport { buildPaymentRequired, resolveNetwork, resolveScheme } from './x402/facilitator-api.js'\nexport { DelegationAPI } from './x402/delegation-api.js'\nexport type {\n PaymentMethodSummary,\n UpdatePaymentMethodDto,\n DelegationSummary,\n DelegationListResponse,\n PurchasingPower,\n ListOptions,\n} from './x402/delegation-api.js'\nexport type {\n X402PaymentRequired,\n X402PaymentAccepted,\n X402Resource,\n X402Scheme,\n X402SchemeExtra,\n VerifyPermissionsParams,\n VerifyPermissionsResult,\n SettlePermissionsParams,\n SettlePermissionsResult,\n} from './x402/facilitator-api.js'\n// MCP public types\nexport type {\n CreditsContext,\n CreditsOption,\n PaywallOptions,\n McpConfig,\n PaywallContext,\n AuthResult,\n} from './mcp/types/paywall.types.js'\n\n// MCP HTTP types\nexport type {\n OAuthUrls,\n OAuthConfig,\n HttpRouterConfig,\n HttpServerConfig,\n HttpServerResult,\n} from './mcp/types/http.types.js'\n\n// MCP extended config type\nexport type { ExtendedMcpConfig } from './mcp/index.js'\n\n// MCP HTTP utilities\nexport { createRequireAuthMiddleware } from './mcp/http/oauth-router.js'\n\nexport type {\n AgentCard,\n TaskHandlerResult,\n TaskStatusUpdateEvent,\n ExecutionEventBus,\n AgentExecutor,\n RequestContext,\n PushNotificationConfig,\n Task,\n MessageSendParams,\n SendMessageResponse,\n TaskQueryParams,\n GetTaskResponse,\n TaskPushNotificationConfig,\n SetTaskPushNotificationConfigResponse,\n TaskIdParams,\n GetTaskPushNotificationConfigResponse,\n} from './a2a/types.js'\n\n// x402 v2 A2A in-band transport utilities (mirrors the Python X402A2AUtils)\nexport {\n X402A2AUtils,\n x402A2AUtils,\n X402A2AMetadata,\n X402_SETTLEMENT_DEFERRED_KEY,\n PaymentStatus as A2APaymentStatus,\n} from './a2a/x402-a2a.js'\nexport {\n A2A_X402_EXTENSION_URI,\n NVM_PAYMENT_EXTENSION_URI,\n AGENT_CARD_WELL_KNOWN_PATH,\n LEGACY_AGENT_CARD_WELL_KNOWN_PATH,\n} from './a2a/agent-card.js'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,8CAA8C,CAAA;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAA;AAC/E,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,6BAA6B,GAC9B,MAAM,kCAAkC,CAAA;AAQzC,2BAA2B;AAC3B,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC/F,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAqBxD,iDAAiD;AACjD,cAAc,gBAAgB,CAAA;AAwB9B,qBAAqB;AACrB,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAqBxE,4EAA4E;AAC5E,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,4BAA4B,EAC5B,aAAa,IAAI,gBAAgB,GAClC,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,EAC1B,iCAAiC,GAClC,MAAM,qBAAqB,CAAA","sourcesContent":["export * from './environments.js'\nexport * from './payments.js'\nexport * from './utils.js'\nexport * from './common/api-version.js'\nexport * from './common/types.js'\nexport * from './common/payments.error.js'\nexport * from './common/helper.js'\nexport * from './api/query-api.js'\nexport * from './api/observability-api/observability-api.js'\nexport type { BackendApiOptions } from './api/nvm-api.js'\nexport { ContractsAPI } from './api/contracts-api.js'\nexport { CURRENT_ORG_ID_HEADER } from './api/base-payments.js'\nexport type { PublicationOptions } from './api/base-payments.js'\nexport { OrganizationsAPI } from './api/organizations-api/organizations-api.js'\nexport {\n OrganizationMemberRole,\n OrganizationType,\n OrganizationActivityEventType,\n} from './api/organizations-api/types.js'\nexport type {\n MyMembership,\n OrganizationActivityEvent,\n OrganizationActivityFilters,\n OrganizationActivityPage,\n} from './api/organizations-api/types.js'\n\n// x402 utilities and types\nexport { buildPaymentRequired, resolveNetwork, resolveScheme } from './x402/facilitator-api.js'\nexport { DelegationAPI } from './x402/delegation-api.js'\nexport type {\n PaymentMethodSummary,\n UpdatePaymentMethodDto,\n DelegationSummary,\n DelegationListResponse,\n PurchasingPower,\n ListOptions,\n} from './x402/delegation-api.js'\nexport type {\n X402PaymentRequired,\n X402PaymentAccepted,\n X402Resource,\n X402Scheme,\n X402SchemeExtra,\n VerifyPermissionsParams,\n VerifyPermissionsResult,\n SettlePermissionsParams,\n SettlePermissionsResult,\n} from './x402/facilitator-api.js'\n\n// MPP (Machine Payments Protocol) public surface\nexport * from './mpp/index.js'\n\n// MCP public types\nexport type {\n CreditsContext,\n CreditsOption,\n PaywallOptions,\n McpConfig,\n PaywallContext,\n AuthResult,\n} from './mcp/types/paywall.types.js'\n\n// MCP HTTP types\nexport type {\n OAuthUrls,\n OAuthConfig,\n HttpRouterConfig,\n HttpServerConfig,\n HttpServerResult,\n} from './mcp/types/http.types.js'\n\n// MCP extended config type\nexport type { ExtendedMcpConfig } from './mcp/index.js'\n\n// MCP HTTP utilities\nexport { createRequireAuthMiddleware } from './mcp/http/oauth-router.js'\n\nexport type {\n AgentCard,\n TaskHandlerResult,\n TaskStatusUpdateEvent,\n ExecutionEventBus,\n AgentExecutor,\n RequestContext,\n PushNotificationConfig,\n Task,\n MessageSendParams,\n SendMessageResponse,\n TaskQueryParams,\n GetTaskResponse,\n TaskPushNotificationConfig,\n SetTaskPushNotificationConfigResponse,\n TaskIdParams,\n GetTaskPushNotificationConfigResponse,\n} from './a2a/types.js'\n\n// x402 v2 A2A in-band transport utilities (mirrors the Python X402A2AUtils)\nexport {\n X402A2AUtils,\n x402A2AUtils,\n X402A2AMetadata,\n X402_SETTLEMENT_DEFERRED_KEY,\n PaymentStatus as A2APaymentStatus,\n} from './a2a/x402-a2a.js'\nexport {\n A2A_X402_EXTENSION_URI,\n NVM_PAYMENT_EXTENSION_URI,\n AGENT_CARD_WELL_KNOWN_PATH,\n LEGACY_AGENT_CARD_WELL_KNOWN_PATH,\n} from './a2a/agent-card.js'\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"server-manager.d.ts","sourceRoot":"","sources":["../../../src/mcp/core/server-manager.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,WAAW,EACX,eAAe,EACf,aAAa,EACb,eAAe,EACf,eAAe,EAKhB,MAAM,0BAA0B,CAAA;AAkCjC;;GAEG;AACH,oBAAY,WAAW;IACrB,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,QAAQ,aAAa;CACtB;AAED;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,KAAK,CAAgC;IAC7C,OAAO,CAAC,QAA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BP;;OAEG;IACG,KAAK,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAsI9D;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA4B3B;;OAEG;YACW,2BAA2B;IAsKzC;;OAEG;IACH,OAAO,CAAC,iBAAiB;CAiB1B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,GAAG,gBAAgB,CAExE"}
@@ -185,6 +185,9 @@ export class McpServerManager {
185
185
  mountMcpHandlers(this.expressApp, {
186
186
  sessionManager: this.sessionManager,
187
187
  requireAuth: true,
188
+ // Pin the challenge's resource_metadata origin to the operator's known
189
+ // baseUrl (never client Host/X-Forwarded-* headers) — see #410 review.
190
+ baseUrl,
188
191
  log: this.log,
189
192
  });
190
193
  // Add 404 fallback
@@ -1 +1 @@
1
- {"version":3,"file":"server-manager.js","sourceRoot":"","sources":["../../../src/mcp/core/server-manager.ts"],"names":[],"mappings":"AAKA,OAAO,OAA6B,MAAM,SAAS,CAAA;AAiBnD,OAAO,EAAE,oBAAoB,EAAkB,MAAM,4BAA4B,CAAA;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAE7D,IAAI,cAAc,GAAQ,IAAI,CAAA;AAC9B,IAAI,qBAAqB,GAAQ,IAAI,CAAA;AAErC;;GAEG;AACH,KAAK,UAAU,iBAAiB;IAC9B,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,yC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CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;QACpF,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;QAE9E,IAAI,CAAC,GAAG,CAAC;kBACK,IAAI,CAAC,OAAO;kBACZ,IAAI,CAAC,OAAO;kBACZ,IAAI,CAAC,OAAO;qBACT,IAAI,CAAC,OAAO;WACtB,SAAS;eACL,aAAa;aACf,WAAW;aACX,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAiB,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IACrF,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAkB;IACpD,OAAO,IAAI,gBAAgB,CAAC,QAAQ,CAAC,CAAA;AACvC,CAAC","sourcesContent":["/**\n * Server manager for simplified MCP API.\n * Orchestrates McpServer, Express, Transport, and session management.\n */\nimport type { Server } from 'http'\nimport express, { type Application } from 'express'\nimport type { Payments } from '../../payments.js'\nimport type {\n McpToolConfig,\n McpResourceConfig,\n McpPromptConfig,\n McpRegistrationOptions,\n ToolHandler,\n ResourceHandler,\n PromptHandler,\n McpServerConfig,\n McpServerResult,\n ServerInfo,\n ToolRegistration,\n ResourceRegistration,\n PromptRegistration,\n} from '../types/server.types.js'\nimport { createSessionManager, SessionManager } from '../http/session-manager.js'\nimport { mountMcpHandlers } from '../http/mcp-handler.js'\nimport {\n createOAuthRouter,\n createCorsMiddleware,\n createJsonMiddleware,\n createHttpLoggingMiddleware,\n} from '../http/oauth-router.js'\nimport { PaywallDecorator } from './paywall.js'\nimport { PaywallAuthenticator } from './auth.js'\nimport { CreditsContextProvider } from './credits-context.js'\n\nlet McpServerClass: any = null\nlet ResourceTemplateClass: any = null\n\n/**\n * Lazily load McpServer and ResourceTemplate from the SDK.\n */\nasync function getMcpServerClass(): Promise<any> {\n if (!McpServerClass) {\n try {\n const module = await import('@modelcontextprotocol/sdk/server/mcp.js')\n McpServerClass = module.McpServer\n ResourceTemplateClass = module.ResourceTemplate\n } catch (error) {\n throw new Error(\n 'Failed to load @modelcontextprotocol/sdk. Make sure it is installed: npm install @modelcontextprotocol/sdk',\n )\n }\n }\n return McpServerClass\n}\n\n/**\n * Server manager state.\n */\nexport enum ServerState {\n Idle = 'idle',\n Starting = 'starting',\n Running = 'running',\n Stopping = 'stopping',\n}\n\n/**\n * Manages the complete MCP server lifecycle.\n */\nexport class McpServerManager {\n private state: ServerState = ServerState.Idle\n private payments: Payments\n private tools: Map<string, ToolRegistration> = new Map()\n private resources: Map<string, ResourceRegistration> = new Map()\n private prompts: Map<string, PromptRegistration> = new Map()\n private mcpServer: any = null\n private expressApp: Application | null = null\n private httpServer: Server | null = null\n private sessionManager: SessionManager | null = null\n private config: McpServerConfig | null = null\n private log: ((message: string) => void) | undefined = undefined\n private paywallDecorator: PaywallDecorator\n\n constructor(payments: Payments) {\n this.payments = payments\n // Initialize paywall decorator\n const authenticator = new PaywallAuthenticator(payments)\n const creditsContext = new CreditsContextProvider()\n this.paywallDecorator = new PaywallDecorator(payments, authenticator, creditsContext)\n }\n\n /**\n * Get current server state.\n */\n getState(): ServerState {\n return this.state\n }\n\n /**\n * Register a tool.\n * Must be called before start().\n */\n registerTool(\n name: string,\n config: McpToolConfig,\n handler: ToolHandler,\n options: McpRegistrationOptions = {},\n ): void {\n if (this.state !== ServerState.Idle) {\n throw new Error('Cannot register tools after server has started')\n }\n\n this.tools.set(name, {\n name,\n config,\n handler,\n options: {\n credits: options.credits,\n onRedeemError: options.onRedeemError ?? 'ignore',\n },\n })\n\n this.log?.(`Registered tool: ${name}`)\n }\n\n /**\n * Register a resource.\n * Must be called before start().\n */\n registerResource(\n name: string,\n uriOrTemplate: string,\n config: McpResourceConfig,\n handler: ResourceHandler,\n options: McpRegistrationOptions = {},\n ): void {\n if (this.state !== ServerState.Idle) {\n throw new Error('Cannot register resources after server has started')\n }\n\n this.resources.set(uriOrTemplate, {\n name,\n uriOrTemplate,\n config,\n handler,\n options: {\n credits: options.credits,\n onRedeemError: options.onRedeemError ?? 'ignore',\n },\n })\n\n this.log?.(`Registered resource: ${name} at ${uriOrTemplate}`)\n }\n\n /**\n * Register a prompt.\n * Must be called before start().\n */\n registerPrompt(\n name: string,\n config: McpPromptConfig,\n handler: PromptHandler,\n options: McpRegistrationOptions = {},\n ): void {\n if (this.state !== ServerState.Idle) {\n throw new Error('Cannot register prompts after server has started')\n }\n\n this.prompts.set(name, {\n name,\n config,\n handler,\n options: {\n credits: options.credits,\n onRedeemError: options.onRedeemError ?? 'ignore',\n },\n })\n\n this.log?.(`Registered prompt: ${name}`)\n }\n\n /**\n * Start the MCP server.\n */\n async start(config: McpServerConfig): Promise<McpServerResult> {\n if (this.state !== ServerState.Idle) {\n throw new Error(`Cannot start server in state: ${this.state}`)\n }\n\n this.state = ServerState.Starting\n this.config = config\n this.log = config.onLog\n\n try {\n // Validate configuration. planId is required (plan-centric); agentId is\n // optional and informational only.\n if (!config.planId) {\n throw new Error('planId is required')\n }\n if (!config.port) {\n throw new Error('port is required')\n }\n\n const baseUrl = config.baseUrl || `http://localhost:${config.port}`\n\n const McpServer = await getMcpServerClass()\n\n // Create MCP server\n this.mcpServer = new McpServer({\n name: config.serverName,\n version: config.version || '1.0.0',\n })\n\n // Register tools, resources, and prompts with paywall protection\n await this.registerHandlersWithPaywall()\n\n this.expressApp = express()\n\n // Apply global middleware\n if (this.expressApp) {\n // HTTP request logging (must be first to log all requests)\n this.expressApp.use(createHttpLoggingMiddleware(this.log))\n this.expressApp.use(createCorsMiddleware(config.corsOrigins || '*'))\n this.expressApp.use(createJsonMiddleware())\n }\n\n // Mount OAuth router\n const environment =\n config.environment || (this.payments as any).environmentName || 'staging_sandbox'\n\n const oauthRouter = createOAuthRouter({\n payments: this.payments,\n baseUrl,\n agentId: config.agentId,\n environment,\n serverName: config.serverName,\n tools: Array.from(this.tools.keys()),\n resources: Array.from(this.resources.keys()),\n prompts: Array.from(this.prompts.keys()),\n enableOAuthDiscovery: config.enableOAuthDiscovery ?? true,\n enableClientRegistration: config.enableClientRegistration ?? true,\n enableHealthCheck: config.enableHealthCheck ?? true,\n enableServerInfo: config.enableServerInfo ?? true,\n version: config.version || '1.0.0',\n description: config.description,\n })\n\n if (this.expressApp) {\n this.expressApp.use(oauthRouter)\n }\n\n // Create session manager\n this.sessionManager = createSessionManager({\n log: this.log,\n })\n this.sessionManager.setMcpServer(this.mcpServer)\n\n // Mount MCP handlers\n if (this.expressApp && this.sessionManager) {\n mountMcpHandlers(this.expressApp as any, {\n sessionManager: this.sessionManager,\n requireAuth: true,\n log: this.log,\n })\n\n // Add 404 fallback\n this.expressApp.use((req: any, res: any) => {\n this.log?.(`404 - ${req.method} ${req.path}`)\n res.status(404).json({\n error: 'not_found',\n error_description: `Endpoint not found: ${req.method} ${req.path}`,\n })\n })\n }\n\n // Start HTTP server\n if (!this.expressApp) {\n throw new Error('Express app not initialized')\n }\n const expressApp = this.expressApp\n await new Promise<void>((resolve, reject) => {\n const host = config.host || '0.0.0.0'\n const server = expressApp.listen(config.port, host, () => {\n resolve()\n })\n this.httpServer = server\n server.on('error', reject)\n })\n\n this.state = ServerState.Running\n\n const info: ServerInfo = {\n baseUrl,\n port: config.port,\n tools: Array.from(this.tools.keys()),\n resources: Array.from(this.resources.keys()),\n prompts: Array.from(this.prompts.keys()),\n }\n\n // Log startup message\n this.logStartupMessage(info, config)\n\n // Call onStart callback\n config.onStart?.(info)\n\n return {\n info,\n stop: () => this.stop(),\n }\n } catch (error) {\n this.state = ServerState.Idle\n throw error\n }\n }\n\n /**\n * Stop the server gracefully.\n */\n async stop(): Promise<void> {\n if (this.state !== ServerState.Running) {\n return\n }\n\n this.state = ServerState.Stopping\n\n // Destroy all sessions\n this.sessionManager?.destroyAllSessions()\n\n // Close HTTP server\n const server = this.httpServer\n if (server) {\n await new Promise<void>((resolve) => {\n server.close(() => resolve())\n })\n }\n\n // Reset state\n this.mcpServer = null\n this.expressApp = null\n this.httpServer = null\n this.sessionManager = null\n this.state = ServerState.Idle\n\n this.log?.('Server stopped')\n }\n\n /**\n * Register all tools, resources, and prompts with paywall protection.\n */\n private async registerHandlersWithPaywall(): Promise<void> {\n // Configure paywall with agent and server info\n if (!this.config) {\n throw new Error('Server config not set')\n }\n this.paywallDecorator.configure({\n planId: this.config.planId,\n agentId: this.config.agentId,\n serverName: this.config.serverName,\n })\n\n // Register tools\n for (const [name, registration] of this.tools) {\n const { config: toolConfig, handler, options } = registration\n\n // Wrap handler with paywall\n // Convert number to bigint if needed, but preserve functions and undefined\n const creditsOption: any =\n typeof options.credits === 'function'\n ? options.credits\n : typeof options.credits === 'number'\n ? BigInt(options.credits)\n : options.credits\n\n const protectedHandler = this.paywallDecorator.protect(\n async (args: any, extra?: any, paywallContext?: any) => {\n // Pass agentRequest directly in extra (consistent with resources)\n const handlerExtra = paywallContext\n ? {\n ...extra,\n agentRequest: paywallContext.agentRequest,\n }\n : extra\n // Call the user's handler with the converted context\n const result = await handler(args, handlerExtra)\n return result\n },\n {\n name,\n kind: 'tool',\n credits: creditsOption,\n onRedeemError: options.onRedeemError,\n },\n )\n\n // Register with MCP server\n this.mcpServer.registerTool(name, toolConfig, protectedHandler)\n }\n\n // Register resources\n for (const [uriOrTemplate, registration] of this.resources) {\n const { name, config: resourceConfig, handler, options } = registration\n\n // Wrap handler with paywall\n // Convert number to bigint if needed, but preserve functions and undefined\n const creditsOption: any =\n typeof options.credits === 'function'\n ? options.credits\n : typeof options.credits === 'number'\n ? BigInt(options.credits)\n : options.credits\n\n const protectedHandler = this.paywallDecorator.protect(\n async (uri: URL, extra?: any, paywallContext?: any) => {\n // Convert PaywallContext - pass extra directly to handler\n const handlerExtra = paywallContext\n ? {\n ...extra,\n authResult: paywallContext.authResult,\n credits: paywallContext.credits,\n agentRequest: paywallContext.agentRequest,\n }\n : extra\n // Call the user's handler with the converted context\n const result = await handler(uri, handlerExtra)\n return result\n },\n {\n name,\n kind: 'resource',\n credits: creditsOption,\n onRedeemError: options.onRedeemError,\n },\n )\n\n // Register with MCP server\n const hasTemplateVariables = /\\{[^}]+\\}/.test(uriOrTemplate)\n\n if (hasTemplateVariables) {\n const templateInstance = new ResourceTemplateClass(uriOrTemplate, {\n list: async () => ({ resources: [] }),\n })\n this.mcpServer.registerResource(name, templateInstance, resourceConfig, protectedHandler)\n } else {\n // For static resources: registerResource(name, uriString, config, handler)\n this.mcpServer.registerResource(name, uriOrTemplate, resourceConfig, protectedHandler)\n }\n }\n\n // Register prompts\n for (const [name, registration] of this.prompts) {\n const { config: promptConfig, handler, options } = registration\n\n // Wrap handler with paywall\n // Convert number to bigint if needed, but preserve functions and undefined\n const creditsOption: any =\n typeof options.credits === 'function'\n ? options.credits\n : typeof options.credits === 'number'\n ? BigInt(options.credits)\n : options.credits\n\n const protectedHandler = this.paywallDecorator.protect(\n async (args: any, extra?: any, paywallContext?: any) => {\n // Convert PaywallContext to PromptContext format\n // PromptContext has: { requestId?, credits?, extra? }\n const promptContext = paywallContext\n ? {\n requestId: paywallContext.agentRequest?.agentRequestId,\n credits: paywallContext.credits,\n extra: {\n ...extra,\n authResult: paywallContext.authResult,\n credits: paywallContext.credits,\n agentRequest: paywallContext.agentRequest,\n },\n }\n : extra\n ? {\n requestId: extra?.agentRequest?.agentRequestId,\n credits: extra?.credits,\n extra,\n }\n : undefined\n\n // Call the user's handler with the converted context\n const result = await handler(args, promptContext)\n return result\n },\n {\n name,\n kind: 'prompt',\n credits: creditsOption,\n onRedeemError: options.onRedeemError,\n },\n )\n\n // Register with MCP server\n const sdkPromptConfig: any = {\n title: promptConfig.title,\n description: promptConfig.description,\n }\n\n if (promptConfig.argsSchema) {\n const schema = promptConfig.argsSchema as any\n if (schema && typeof schema === 'object' && 'shape' in schema) {\n sdkPromptConfig.argsSchema = schema.shape\n } else {\n sdkPromptConfig.argsSchema = promptConfig.argsSchema\n }\n }\n\n this.mcpServer.registerPrompt(name, sdkPromptConfig, protectedHandler)\n }\n }\n\n /**\n * Log startup message (only if onLog callback provided).\n */\n private logStartupMessage(info: ServerInfo, config: McpServerConfig): void {\n if (!this.log) return\n\n const toolsList = info.tools.length > 0 ? info.tools.join(', ') : 'none'\n const resourcesList = info.resources.length > 0 ? info.resources.join(', ') : 'none'\n const promptsList = info.prompts.length > 0 ? info.prompts.join(', ') : 'none'\n\n this.log(`MCP Server Started!\n MCP Endpoint: ${info.baseUrl}/mcp\n Health Check: ${info.baseUrl}/health\n Server Info: ${info.baseUrl}/\n OAuth Discovery: ${info.baseUrl}/.well-known/oauth-authorization-server\n Tools: ${toolsList}\n Resources: ${resourcesList}\n Prompts: ${promptsList}\n Plan ID: ${config.planId}${config.agentId ? `\\n Agent ID: ${config.agentId}` : ''}`)\n }\n}\n\n/**\n * Create a new server manager.\n */\nexport function createServerManager(payments: Payments): McpServerManager {\n return new McpServerManager(payments)\n}\n"]}
1
+ {"version":3,"file":"server-manager.js","sourceRoot":"","sources":["../../../src/mcp/core/server-manager.ts"],"names":[],"mappings":"AAKA,OAAO,OAA6B,MAAM,SAAS,CAAA;AAiBnD,OAAO,EAAE,oBAAoB,EAAkB,MAAM,4BAA4B,CAAA;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAE7D,IAAI,cAAc,GAAQ,IAAI,CAAA;AAC9B,IAAI,qBAA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AAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;QACxE,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;QACpF,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;QAE9E,IAAI,CAAC,GAAG,CAAC;kBACK,IAAI,CAAC,OAAO;kBACZ,IAAI,CAAC,OAAO;kBACZ,IAAI,CAAC,OAAO;qBACT,IAAI,CAAC,OAAO;WACtB,SAAS;eACL,aAAa;aACf,WAAW;aACX,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAiB,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IACrF,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAkB;IACpD,OAAO,IAAI,gBAAgB,CAAC,QAAQ,CAAC,CAAA;AACvC,CAAC","sourcesContent":["/**\n * Server manager for simplified MCP API.\n * Orchestrates McpServer, Express, Transport, and session management.\n */\nimport type { Server } from 'http'\nimport express, { type Application } from 'express'\nimport type { Payments } from '../../payments.js'\nimport type {\n McpToolConfig,\n McpResourceConfig,\n McpPromptConfig,\n McpRegistrationOptions,\n ToolHandler,\n ResourceHandler,\n PromptHandler,\n McpServerConfig,\n McpServerResult,\n ServerInfo,\n ToolRegistration,\n ResourceRegistration,\n PromptRegistration,\n} from '../types/server.types.js'\nimport { createSessionManager, SessionManager } from '../http/session-manager.js'\nimport { mountMcpHandlers } from '../http/mcp-handler.js'\nimport {\n createOAuthRouter,\n createCorsMiddleware,\n createJsonMiddleware,\n createHttpLoggingMiddleware,\n} from '../http/oauth-router.js'\nimport { PaywallDecorator } from './paywall.js'\nimport { PaywallAuthenticator } from './auth.js'\nimport { CreditsContextProvider } from './credits-context.js'\n\nlet McpServerClass: any = null\nlet ResourceTemplateClass: any = null\n\n/**\n * Lazily load McpServer and ResourceTemplate from the SDK.\n */\nasync function getMcpServerClass(): Promise<any> {\n if (!McpServerClass) {\n try {\n const module = await import('@modelcontextprotocol/sdk/server/mcp.js')\n McpServerClass = module.McpServer\n ResourceTemplateClass = module.ResourceTemplate\n } catch (error) {\n throw new Error(\n 'Failed to load @modelcontextprotocol/sdk. Make sure it is installed: npm install @modelcontextprotocol/sdk',\n )\n }\n }\n return McpServerClass\n}\n\n/**\n * Server manager state.\n */\nexport enum ServerState {\n Idle = 'idle',\n Starting = 'starting',\n Running = 'running',\n Stopping = 'stopping',\n}\n\n/**\n * Manages the complete MCP server lifecycle.\n */\nexport class McpServerManager {\n private state: ServerState = ServerState.Idle\n private payments: Payments\n private tools: Map<string, ToolRegistration> = new Map()\n private resources: Map<string, ResourceRegistration> = new Map()\n private prompts: Map<string, PromptRegistration> = new Map()\n private mcpServer: any = null\n private expressApp: Application | null = null\n private httpServer: Server | null = null\n private sessionManager: SessionManager | null = null\n private config: McpServerConfig | null = null\n private log: ((message: string) => void) | undefined = undefined\n private paywallDecorator: PaywallDecorator\n\n constructor(payments: Payments) {\n this.payments = payments\n // Initialize paywall decorator\n const authenticator = new PaywallAuthenticator(payments)\n const creditsContext = new CreditsContextProvider()\n this.paywallDecorator = new PaywallDecorator(payments, authenticator, creditsContext)\n }\n\n /**\n * Get current server state.\n */\n getState(): ServerState {\n return this.state\n }\n\n /**\n * Register a tool.\n * Must be called before start().\n */\n registerTool(\n name: string,\n config: McpToolConfig,\n handler: ToolHandler,\n options: McpRegistrationOptions = {},\n ): void {\n if (this.state !== ServerState.Idle) {\n throw new Error('Cannot register tools after server has started')\n }\n\n this.tools.set(name, {\n name,\n config,\n handler,\n options: {\n credits: options.credits,\n onRedeemError: options.onRedeemError ?? 'ignore',\n },\n })\n\n this.log?.(`Registered tool: ${name}`)\n }\n\n /**\n * Register a resource.\n * Must be called before start().\n */\n registerResource(\n name: string,\n uriOrTemplate: string,\n config: McpResourceConfig,\n handler: ResourceHandler,\n options: McpRegistrationOptions = {},\n ): void {\n if (this.state !== ServerState.Idle) {\n throw new Error('Cannot register resources after server has started')\n }\n\n this.resources.set(uriOrTemplate, {\n name,\n uriOrTemplate,\n config,\n handler,\n options: {\n credits: options.credits,\n onRedeemError: options.onRedeemError ?? 'ignore',\n },\n })\n\n this.log?.(`Registered resource: ${name} at ${uriOrTemplate}`)\n }\n\n /**\n * Register a prompt.\n * Must be called before start().\n */\n registerPrompt(\n name: string,\n config: McpPromptConfig,\n handler: PromptHandler,\n options: McpRegistrationOptions = {},\n ): void {\n if (this.state !== ServerState.Idle) {\n throw new Error('Cannot register prompts after server has started')\n }\n\n this.prompts.set(name, {\n name,\n config,\n handler,\n options: {\n credits: options.credits,\n onRedeemError: options.onRedeemError ?? 'ignore',\n },\n })\n\n this.log?.(`Registered prompt: ${name}`)\n }\n\n /**\n * Start the MCP server.\n */\n async start(config: McpServerConfig): Promise<McpServerResult> {\n if (this.state !== ServerState.Idle) {\n throw new Error(`Cannot start server in state: ${this.state}`)\n }\n\n this.state = ServerState.Starting\n this.config = config\n this.log = config.onLog\n\n try {\n // Validate configuration. planId is required (plan-centric); agentId is\n // optional and informational only.\n if (!config.planId) {\n throw new Error('planId is required')\n }\n if (!config.port) {\n throw new Error('port is required')\n }\n\n const baseUrl = config.baseUrl || `http://localhost:${config.port}`\n\n const McpServer = await getMcpServerClass()\n\n // Create MCP server\n this.mcpServer = new McpServer({\n name: config.serverName,\n version: config.version || '1.0.0',\n })\n\n // Register tools, resources, and prompts with paywall protection\n await this.registerHandlersWithPaywall()\n\n this.expressApp = express()\n\n // Apply global middleware\n if (this.expressApp) {\n // HTTP request logging (must be first to log all requests)\n this.expressApp.use(createHttpLoggingMiddleware(this.log))\n this.expressApp.use(createCorsMiddleware(config.corsOrigins || '*'))\n this.expressApp.use(createJsonMiddleware())\n }\n\n // Mount OAuth router\n const environment =\n config.environment || (this.payments as any).environmentName || 'staging_sandbox'\n\n const oauthRouter = createOAuthRouter({\n payments: this.payments,\n baseUrl,\n agentId: config.agentId,\n environment,\n serverName: config.serverName,\n tools: Array.from(this.tools.keys()),\n resources: Array.from(this.resources.keys()),\n prompts: Array.from(this.prompts.keys()),\n enableOAuthDiscovery: config.enableOAuthDiscovery ?? true,\n enableClientRegistration: config.enableClientRegistration ?? true,\n enableHealthCheck: config.enableHealthCheck ?? true,\n enableServerInfo: config.enableServerInfo ?? true,\n version: config.version || '1.0.0',\n description: config.description,\n })\n\n if (this.expressApp) {\n this.expressApp.use(oauthRouter)\n }\n\n // Create session manager\n this.sessionManager = createSessionManager({\n log: this.log,\n })\n this.sessionManager.setMcpServer(this.mcpServer)\n\n // Mount MCP handlers\n if (this.expressApp && this.sessionManager) {\n mountMcpHandlers(this.expressApp as any, {\n sessionManager: this.sessionManager,\n requireAuth: true,\n // Pin the challenge's resource_metadata origin to the operator's known\n // baseUrl (never client Host/X-Forwarded-* headers) — see #410 review.\n baseUrl,\n log: this.log,\n })\n\n // Add 404 fallback\n this.expressApp.use((req: any, res: any) => {\n this.log?.(`404 - ${req.method} ${req.path}`)\n res.status(404).json({\n error: 'not_found',\n error_description: `Endpoint not found: ${req.method} ${req.path}`,\n })\n })\n }\n\n // Start HTTP server\n if (!this.expressApp) {\n throw new Error('Express app not initialized')\n }\n const expressApp = this.expressApp\n await new Promise<void>((resolve, reject) => {\n const host = config.host || '0.0.0.0'\n const server = expressApp.listen(config.port, host, () => {\n resolve()\n })\n this.httpServer = server\n server.on('error', reject)\n })\n\n this.state = ServerState.Running\n\n const info: ServerInfo = {\n baseUrl,\n port: config.port,\n tools: Array.from(this.tools.keys()),\n resources: Array.from(this.resources.keys()),\n prompts: Array.from(this.prompts.keys()),\n }\n\n // Log startup message\n this.logStartupMessage(info, config)\n\n // Call onStart callback\n config.onStart?.(info)\n\n return {\n info,\n stop: () => this.stop(),\n }\n } catch (error) {\n this.state = ServerState.Idle\n throw error\n }\n }\n\n /**\n * Stop the server gracefully.\n */\n async stop(): Promise<void> {\n if (this.state !== ServerState.Running) {\n return\n }\n\n this.state = ServerState.Stopping\n\n // Destroy all sessions\n this.sessionManager?.destroyAllSessions()\n\n // Close HTTP server\n const server = this.httpServer\n if (server) {\n await new Promise<void>((resolve) => {\n server.close(() => resolve())\n })\n }\n\n // Reset state\n this.mcpServer = null\n this.expressApp = null\n this.httpServer = null\n this.sessionManager = null\n this.state = ServerState.Idle\n\n this.log?.('Server stopped')\n }\n\n /**\n * Register all tools, resources, and prompts with paywall protection.\n */\n private async registerHandlersWithPaywall(): Promise<void> {\n // Configure paywall with agent and server info\n if (!this.config) {\n throw new Error('Server config not set')\n }\n this.paywallDecorator.configure({\n planId: this.config.planId,\n agentId: this.config.agentId,\n serverName: this.config.serverName,\n })\n\n // Register tools\n for (const [name, registration] of this.tools) {\n const { config: toolConfig, handler, options } = registration\n\n // Wrap handler with paywall\n // Convert number to bigint if needed, but preserve functions and undefined\n const creditsOption: any =\n typeof options.credits === 'function'\n ? options.credits\n : typeof options.credits === 'number'\n ? BigInt(options.credits)\n : options.credits\n\n const protectedHandler = this.paywallDecorator.protect(\n async (args: any, extra?: any, paywallContext?: any) => {\n // Pass agentRequest directly in extra (consistent with resources)\n const handlerExtra = paywallContext\n ? {\n ...extra,\n agentRequest: paywallContext.agentRequest,\n }\n : extra\n // Call the user's handler with the converted context\n const result = await handler(args, handlerExtra)\n return result\n },\n {\n name,\n kind: 'tool',\n credits: creditsOption,\n onRedeemError: options.onRedeemError,\n },\n )\n\n // Register with MCP server\n this.mcpServer.registerTool(name, toolConfig, protectedHandler)\n }\n\n // Register resources\n for (const [uriOrTemplate, registration] of this.resources) {\n const { name, config: resourceConfig, handler, options } = registration\n\n // Wrap handler with paywall\n // Convert number to bigint if needed, but preserve functions and undefined\n const creditsOption: any =\n typeof options.credits === 'function'\n ? options.credits\n : typeof options.credits === 'number'\n ? BigInt(options.credits)\n : options.credits\n\n const protectedHandler = this.paywallDecorator.protect(\n async (uri: URL, extra?: any, paywallContext?: any) => {\n // Convert PaywallContext - pass extra directly to handler\n const handlerExtra = paywallContext\n ? {\n ...extra,\n authResult: paywallContext.authResult,\n credits: paywallContext.credits,\n agentRequest: paywallContext.agentRequest,\n }\n : extra\n // Call the user's handler with the converted context\n const result = await handler(uri, handlerExtra)\n return result\n },\n {\n name,\n kind: 'resource',\n credits: creditsOption,\n onRedeemError: options.onRedeemError,\n },\n )\n\n // Register with MCP server\n const hasTemplateVariables = /\\{[^}]+\\}/.test(uriOrTemplate)\n\n if (hasTemplateVariables) {\n const templateInstance = new ResourceTemplateClass(uriOrTemplate, {\n list: async () => ({ resources: [] }),\n })\n this.mcpServer.registerResource(name, templateInstance, resourceConfig, protectedHandler)\n } else {\n // For static resources: registerResource(name, uriString, config, handler)\n this.mcpServer.registerResource(name, uriOrTemplate, resourceConfig, protectedHandler)\n }\n }\n\n // Register prompts\n for (const [name, registration] of this.prompts) {\n const { config: promptConfig, handler, options } = registration\n\n // Wrap handler with paywall\n // Convert number to bigint if needed, but preserve functions and undefined\n const creditsOption: any =\n typeof options.credits === 'function'\n ? options.credits\n : typeof options.credits === 'number'\n ? BigInt(options.credits)\n : options.credits\n\n const protectedHandler = this.paywallDecorator.protect(\n async (args: any, extra?: any, paywallContext?: any) => {\n // Convert PaywallContext to PromptContext format\n // PromptContext has: { requestId?, credits?, extra? }\n const promptContext = paywallContext\n ? {\n requestId: paywallContext.agentRequest?.agentRequestId,\n credits: paywallContext.credits,\n extra: {\n ...extra,\n authResult: paywallContext.authResult,\n credits: paywallContext.credits,\n agentRequest: paywallContext.agentRequest,\n },\n }\n : extra\n ? {\n requestId: extra?.agentRequest?.agentRequestId,\n credits: extra?.credits,\n extra,\n }\n : undefined\n\n // Call the user's handler with the converted context\n const result = await handler(args, promptContext)\n return result\n },\n {\n name,\n kind: 'prompt',\n credits: creditsOption,\n onRedeemError: options.onRedeemError,\n },\n )\n\n // Register with MCP server\n const sdkPromptConfig: any = {\n title: promptConfig.title,\n description: promptConfig.description,\n }\n\n if (promptConfig.argsSchema) {\n const schema = promptConfig.argsSchema as any\n if (schema && typeof schema === 'object' && 'shape' in schema) {\n sdkPromptConfig.argsSchema = schema.shape\n } else {\n sdkPromptConfig.argsSchema = promptConfig.argsSchema\n }\n }\n\n this.mcpServer.registerPrompt(name, sdkPromptConfig, protectedHandler)\n }\n }\n\n /**\n * Log startup message (only if onLog callback provided).\n */\n private logStartupMessage(info: ServerInfo, config: McpServerConfig): void {\n if (!this.log) return\n\n const toolsList = info.tools.length > 0 ? info.tools.join(', ') : 'none'\n const resourcesList = info.resources.length > 0 ? info.resources.join(', ') : 'none'\n const promptsList = info.prompts.length > 0 ? info.prompts.join(', ') : 'none'\n\n this.log(`MCP Server Started!\n MCP Endpoint: ${info.baseUrl}/mcp\n Health Check: ${info.baseUrl}/health\n Server Info: ${info.baseUrl}/\n OAuth Discovery: ${info.baseUrl}/.well-known/oauth-authorization-server\n Tools: ${toolsList}\n Resources: ${resourcesList}\n Prompts: ${promptsList}\n Plan ID: ${config.planId}${config.agentId ? `\\n Agent ID: ${config.agentId}` : ''}`)\n }\n}\n\n/**\n * Create a new server manager.\n */\nexport function createServerManager(payments: Payments): McpServerManager {\n return new McpServerManager(payments)\n}\n"]}
@@ -23,6 +23,13 @@ export interface McpHandlerConfig {
23
23
  sessionManager: SessionManager;
24
24
  /** Whether to require authentication (default: true) */
25
25
  requireAuth?: boolean;
26
+ /**
27
+ * Public base URL of this MCP server. When provided, the 401
28
+ * `WWW-Authenticate` challenge's `resource_metadata` pointer is built from it
29
+ * (never from client-supplied Host/X-Forwarded-* headers) — the correct,
30
+ * spoof-proof choice behind a TLS-terminating proxy.
31
+ */
32
+ baseUrl?: string;
26
33
  /** Logger function */
27
34
  log?: (message: string) => void;
28
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-handler.d.ts","sourceRoot":"","sources":["../../../src/mcp/http/mcp-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAG1E;;;GAGG;AACH,eAAO,MAAM,qBAAqB,mCAA0C,CAAA;AAE5E;;;GAGG;AACH,wBAAgB,wBAAwB,IAAI,cAAc,GAAG,SAAS,CAErE;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+BAA+B;IAC/B,cAAc,EAAE,cAAc,CAAA;IAC9B,wDAAwD;IACxD,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,sBAAsB;IACtB,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAChC;AAsCD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,IAGtB,KAAK,OAAO,EAAE,KAAK,QAAQ,KAAG,OAAO,CAAC,IAAI,CAAC,CA6DjF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,IAGtB,KAAK,OAAO,EAAE,KAAK,QAAQ,KAAG,OAAO,CAAC,IAAI,CAAC,CAkBhF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,gBAAgB,IAGtB,KAAK,OAAO,EAAE,KAAK,QAAQ,KAAG,OAAO,CAAC,IAAI,CAAC,CAYnF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAg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AwB/E"}
@@ -155,7 +155,14 @@ export function mountMcpHandlers(router, config) {
155
155
  const getHandler = createGetMcpHandler(config);
156
156
  const deleteHandler = createDeleteMcpHandler(config);
157
157
  if (requireAuth) {
158
- const authMiddleware = createRequireAuthMiddleware();
158
+ // These handlers protect the `/mcp` resource, so a 401 must advertise the
159
+ // `/mcp`-scoped PRM (resource: `<baseUrl>/mcp`), not the root document. Pin the
160
+ // origin to the operator baseUrl when known, so the challenge never depends on
161
+ // client-supplied Host/X-Forwarded-* headers.
162
+ const authMiddleware = createRequireAuthMiddleware({
163
+ baseUrl: config.baseUrl,
164
+ resourceMetadataPath: '/.well-known/oauth-protected-resource/mcp',
165
+ });
159
166
  router.post('/mcp', authMiddleware, postHandler);
160
167
  router.get('/mcp', authMiddleware, getHandler);
161
168
  router.delete('/mcp', authMiddleware, deleteHandler);
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-handler.js","sourceRoot":"","sources":["../../../src/mcp/http/mcp-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAG/C,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAA;AAE/D;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,iBAAiB,EAAkB,CAAA;AAE5E;;;GAGG;AACH,MAAM,UAAU,wBAAwB;IACtC,OAAO,qBAAqB,CAAC,QAAQ,EAAE,CAAA;AACzC,CAAC;AAcD;;GAEG;AACH,SAAS,gBAAgB,CAAC,GAAY;IACpC,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAC/C,OAAO,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,SAAgC,CAAA;AACpF,CAAC;AAED;;GAEG;AACH,SAAS,mBAAmB,CAAC,IAAS;IACpC,OAAO,IAAI,IA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I,CAAC,MAAM,EAAE,cAAc,EAAE,WAAkB,CAAC,CAAA;QACvD,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,UAAiB,CAAC,CAAA;QACrD,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,aAAoB,CAAC,CAAA;IAC7D,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,WAAkB,CAAC,CAAA;QACvC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,UAAiB,CAAC,CAAA;QACrC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,aAAoB,CAAC,CAAA;IAC7C,CAAC;AACH,CAAC","sourcesContent":["/**\n * HTTP handlers for MCP endpoints.\n * Provides POST, GET, and DELETE handlers for the /mcp endpoint.\n */\nimport { AsyncLocalStorage } from 'async_hooks'\nimport type { Request, Response, Router } from 'express'\nimport type { SessionManager, RequestContext } from './session-manager.js'\nimport { createRequireAuthMiddleware } from './oauth-router.js'\n\n/**\n * AsyncLocalStorage to store request context within the async flow.\n * This allows handlers deep in the call stack to access HTTP headers.\n */\nexport const requestContextStorage = new AsyncLocalStorage<RequestContext>()\n\n/**\n * Get the current request context from AsyncLocalStorage.\n * Returns undefined if not in a request context.\n */\nexport function getCurrentRequestContext(): RequestContext | undefined {\n return requestContextStorage.getStore()\n}\n\n/**\n * Configuration for MCP handlers.\n */\nexport interface McpHandlerConfig {\n /** Session manager instance */\n sessionManager: SessionManager\n /** Whether to require authentication (default: true) */\n requireAuth?: boolean\n /** Logger function */\n log?: (message: string) => void\n}\n\n/**\n * Extract session ID from request headers.\n */\nfunction extractSessionId(req: Request): string | undefined {\n const headerVal = req.headers['mcp-session-id']\n return Array.isArray(headerVal) ? headerVal[0] : (headerVal as string | undefined)\n}\n\n/**\n * Check if request is an initialize request.\n */\nfunction isInitializeRequest(body: any): boolean {\n return body && typeof body === 'object' && body.method === 'initialize'\n}\n\n/**\n * Ensure Accept header includes required MIME types.\n */\nfunction ensureAcceptHeader(req: Request): void {\n if (!req.headers.accept) {\n req.headers.accept = 'application/json, text/event-stream'\n } else if (\n !req.headers.accept.includes('application/json') ||\n !req.headers.accept.includes('text/event-stream')\n ) {\n const accept = req.headers.accept.split(',').map((s: string) => s.trim())\n if (!accept.includes('application/json')) {\n accept.push('application/json')\n }\n if (!accept.includes('text/event-stream')) {\n accept.push('text/event-stream')\n }\n req.headers.accept = accept.join(', ')\n }\n}\n\n/**\n * Create the POST /mcp handler.\n */\nexport function createPostMcpHandler(config: McpHandlerConfig) {\n const { sessionManager, log } = config\n\n return async function postMcpHandler(req: Request, res: Response): Promise<void> {\n try {\n log?.(`POST /mcp`)\n\n if (!req.body || typeof req.body !== 'object') {\n res.status(400).json({\n jsonrpc: '2.0',\n error: {\n code: -32700,\n message: 'Parse error: Invalid JSON-RPC request',\n },\n id: null,\n })\n return\n }\n\n const clientSessionId = extractSessionId(req)\n const isInit = isInitializeRequest(req.body)\n\n let sessionId = clientSessionId\n if (isInit || !sessionId) {\n sessionId = sessionManager.generateSessionId()\n log?.(`Created new session: ${sessionId}`)\n }\n\n res.setHeader('Mcp-Session-Id', sessionId)\n ensureAcceptHeader(req)\n\n // Create request context with HTTP headers\n const requestContext: RequestContext = {\n headers: req.headers as Record<string, string | string[] | undefined>,\n method: req.method,\n url: req.url,\n ip: req.ip,\n }\n\n // Store in session manager for later access\n sessionManager.setRequestContext(sessionId, requestContext)\n\n const transport = await sessionManager.getOrCreateSession(sessionId)\n\n // Run transport handling within AsyncLocalStorage context\n // This makes headers available to tool handlers via getCurrentRequestContext()\n await requestContextStorage.run(requestContext, async () => {\n await transport.handleRequest(req, res, req.body)\n })\n } catch (error: unknown) {\n // Silently handle errors - library should not log\n if (!res.headersSent) {\n const errorMessage = error instanceof Error ? error.message : 'Internal server error'\n res.status(500).json({\n jsonrpc: '2.0',\n error: {\n code: -32603,\n message: errorMessage,\n },\n id: (req.body as any)?.id || null,\n })\n }\n }\n }\n}\n\n/**\n * Create the GET /mcp handler (SSE stream).\n */\nexport function createGetMcpHandler(config: McpHandlerConfig) {\n const { sessionManager, log } = config\n\n return async function getMcpHandler(req: Request, res: Response): Promise<void> {\n log?.(`GET /mcp (SSE)`)\n\n const sessionId = extractSessionId(req)\n\n if (!sessionId || !sessionManager.hasSession(sessionId)) {\n res.status(400).json({ error: 'Invalid or missing session ID' })\n return\n }\n\n log?.(`Establishing SSE stream for session ${sessionId}`)\n const transport = sessionManager.getSession(sessionId)\n if (!transport) {\n res.status(400).json({ error: 'Session transport not found' })\n return\n }\n await transport.handleRequest(req, res)\n }\n}\n\n/**\n * Create the DELETE /mcp handler (session termination).\n */\nexport function createDeleteMcpHandler(config: McpHandlerConfig) {\n const { sessionManager, log } = config\n\n return async function deleteMcpHandler(req: Request, res: Response): Promise<void> {\n log?.(`DELETE /mcp`)\n\n const sessionId = extractSessionId(req)\n\n if (sessionId && sessionManager.destroySession(sessionId)) {\n log?.(`Destroyed session: ${sessionId}`)\n res.status(204).end()\n } else {\n res.status(404).json({ error: 'Session not found' })\n }\n }\n}\n\n/**\n * Mount all MCP handlers on an Express router.\n */\nexport function mountMcpHandlers(router: Router, config: McpHandlerConfig): void {\n const { requireAuth = true } = config\n\n const postHandler = createPostMcpHandler(config)\n const getHandler = createGetMcpHandler(config)\n const deleteHandler = createDeleteMcpHandler(config)\n\n if (requireAuth) {\n const authMiddleware = createRequireAuthMiddleware()\n router.post('/mcp', authMiddleware, postHandler as any)\n router.get('/mcp', authMiddleware, getHandler as any)\n router.delete('/mcp', authMiddleware, deleteHandler as any)\n } else {\n router.post('/mcp', postHandler as any)\n router.get('/mcp', getHandler as any)\n router.delete('/mcp', deleteHandler as any)\n }\n}\n"]}
1
+ {"version":3,"file":"mcp-handler.js","sourceRoot":"","sources":["../../../src/mcp/http/mcp-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAG/C,OAAO,EAAE,2BAA2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AC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC,CAAA;QACtD,CAAC;IACH,CAAC,CAAA;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAc,EAAE,MAAwB;IACvE,MAAM,EAAE,WAAW,GAAG,IAAI,EAAE,GAAG,MAAM,CAAA;IAErC,MAAM,WAAW,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAA;IAChD,MAAM,UAAU,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAA;IAC9C,MAAM,aAAa,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAA;IAEpD,IAAI,WAAW,EAAE,CAAC;QAChB,0EAA0E;QAC1E,gFAAgF;QAChF,+EAA+E;QAC/E,8CAA8C;QAC9C,MAAM,cAAc,GAAG,2BAA2B,CAAC;YACjD,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,oBAAoB,EAAE,2CAA2C;SAClE,CAAC,CAAA;QACF,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,EAAE,WAAkB,CAAC,CAAA;QACvD,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,UAAiB,CAAC,CAAA;QACrD,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,aAAoB,CAAC,CAAA;IAC7D,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,WAAkB,CAAC,CAAA;QACvC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,UAAiB,CAAC,CAAA;QACrC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,aAAoB,CAAC,CAAA;IAC7C,CAAC;AACH,CAAC","sourcesContent":["/**\n * HTTP handlers for MCP endpoints.\n * Provides POST, GET, and DELETE handlers for the /mcp endpoint.\n */\nimport { AsyncLocalStorage } from 'async_hooks'\nimport type { Request, Response, Router } from 'express'\nimport type { SessionManager, RequestContext } from './session-manager.js'\nimport { createRequireAuthMiddleware } from './oauth-router.js'\n\n/**\n * AsyncLocalStorage to store request context within the async flow.\n * This allows handlers deep in the call stack to access HTTP headers.\n */\nexport const requestContextStorage = new AsyncLocalStorage<RequestContext>()\n\n/**\n * Get the current request context from AsyncLocalStorage.\n * Returns undefined if not in a request context.\n */\nexport function getCurrentRequestContext(): RequestContext | undefined {\n return requestContextStorage.getStore()\n}\n\n/**\n * Configuration for MCP handlers.\n */\nexport interface McpHandlerConfig {\n /** Session manager instance */\n sessionManager: SessionManager\n /** Whether to require authentication (default: true) */\n requireAuth?: boolean\n /**\n * Public base URL of this MCP server. When provided, the 401\n * `WWW-Authenticate` challenge's `resource_metadata` pointer is built from it\n * (never from client-supplied Host/X-Forwarded-* headers) — the correct,\n * spoof-proof choice behind a TLS-terminating proxy.\n */\n baseUrl?: string\n /** Logger function */\n log?: (message: string) => void\n}\n\n/**\n * Extract session ID from request headers.\n */\nfunction extractSessionId(req: Request): string | undefined {\n const headerVal = req.headers['mcp-session-id']\n return Array.isArray(headerVal) ? headerVal[0] : (headerVal as string | undefined)\n}\n\n/**\n * Check if request is an initialize request.\n */\nfunction isInitializeRequest(body: any): boolean {\n return body && typeof body === 'object' && body.method === 'initialize'\n}\n\n/**\n * Ensure Accept header includes required MIME types.\n */\nfunction ensureAcceptHeader(req: Request): void {\n if (!req.headers.accept) {\n req.headers.accept = 'application/json, text/event-stream'\n } else if (\n !req.headers.accept.includes('application/json') ||\n !req.headers.accept.includes('text/event-stream')\n ) {\n const accept = req.headers.accept.split(',').map((s: string) => s.trim())\n if (!accept.includes('application/json')) {\n accept.push('application/json')\n }\n if (!accept.includes('text/event-stream')) {\n accept.push('text/event-stream')\n }\n req.headers.accept = accept.join(', ')\n }\n}\n\n/**\n * Create the POST /mcp handler.\n */\nexport function createPostMcpHandler(config: McpHandlerConfig) {\n const { sessionManager, log } = config\n\n return async function postMcpHandler(req: Request, res: Response): Promise<void> {\n try {\n log?.(`POST /mcp`)\n\n if (!req.body || typeof req.body !== 'object') {\n res.status(400).json({\n jsonrpc: '2.0',\n error: {\n code: -32700,\n message: 'Parse error: Invalid JSON-RPC request',\n },\n id: null,\n })\n return\n }\n\n const clientSessionId = extractSessionId(req)\n const isInit = isInitializeRequest(req.body)\n\n let sessionId = clientSessionId\n if (isInit || !sessionId) {\n sessionId = sessionManager.generateSessionId()\n log?.(`Created new session: ${sessionId}`)\n }\n\n res.setHeader('Mcp-Session-Id', sessionId)\n ensureAcceptHeader(req)\n\n // Create request context with HTTP headers\n const requestContext: RequestContext = {\n headers: req.headers as Record<string, string | string[] | undefined>,\n method: req.method,\n url: req.url,\n ip: req.ip,\n }\n\n // Store in session manager for later access\n sessionManager.setRequestContext(sessionId, requestContext)\n\n const transport = await sessionManager.getOrCreateSession(sessionId)\n\n // Run transport handling within AsyncLocalStorage context\n // This makes headers available to tool handlers via getCurrentRequestContext()\n await requestContextStorage.run(requestContext, async () => {\n await transport.handleRequest(req, res, req.body)\n })\n } catch (error: unknown) {\n // Silently handle errors - library should not log\n if (!res.headersSent) {\n const errorMessage = error instanceof Error ? error.message : 'Internal server error'\n res.status(500).json({\n jsonrpc: '2.0',\n error: {\n code: -32603,\n message: errorMessage,\n },\n id: (req.body as any)?.id || null,\n })\n }\n }\n }\n}\n\n/**\n * Create the GET /mcp handler (SSE stream).\n */\nexport function createGetMcpHandler(config: McpHandlerConfig) {\n const { sessionManager, log } = config\n\n return async function getMcpHandler(req: Request, res: Response): Promise<void> {\n log?.(`GET /mcp (SSE)`)\n\n const sessionId = extractSessionId(req)\n\n if (!sessionId || !sessionManager.hasSession(sessionId)) {\n res.status(400).json({ error: 'Invalid or missing session ID' })\n return\n }\n\n log?.(`Establishing SSE stream for session ${sessionId}`)\n const transport = sessionManager.getSession(sessionId)\n if (!transport) {\n res.status(400).json({ error: 'Session transport not found' })\n return\n }\n await transport.handleRequest(req, res)\n }\n}\n\n/**\n * Create the DELETE /mcp handler (session termination).\n */\nexport function createDeleteMcpHandler(config: McpHandlerConfig) {\n const { sessionManager, log } = config\n\n return async function deleteMcpHandler(req: Request, res: Response): Promise<void> {\n log?.(`DELETE /mcp`)\n\n const sessionId = extractSessionId(req)\n\n if (sessionId && sessionManager.destroySession(sessionId)) {\n log?.(`Destroyed session: ${sessionId}`)\n res.status(204).end()\n } else {\n res.status(404).json({ error: 'Session not found' })\n }\n }\n}\n\n/**\n * Mount all MCP handlers on an Express router.\n */\nexport function mountMcpHandlers(router: Router, config: McpHandlerConfig): void {\n const { requireAuth = true } = config\n\n const postHandler = createPostMcpHandler(config)\n const getHandler = createGetMcpHandler(config)\n const deleteHandler = createDeleteMcpHandler(config)\n\n if (requireAuth) {\n // These handlers protect the `/mcp` resource, so a 401 must advertise the\n // `/mcp`-scoped PRM (resource: `<baseUrl>/mcp`), not the root document. Pin the\n // origin to the operator baseUrl when known, so the challenge never depends on\n // client-supplied Host/X-Forwarded-* headers.\n const authMiddleware = createRequireAuthMiddleware({\n baseUrl: config.baseUrl,\n resourceMetadataPath: '/.well-known/oauth-protected-resource/mcp',\n })\n router.post('/mcp', authMiddleware, postHandler as any)\n router.get('/mcp', authMiddleware, getHandler as any)\n router.delete('/mcp', authMiddleware, deleteHandler as any)\n } else {\n router.post('/mcp', postHandler as any)\n router.get('/mcp', getHandler as any)\n router.delete('/mcp', deleteHandler as any)\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"oauth-metadata.d.ts","sourceRoot":"","sources":["../../../src/mcp/http/oauth-metadata.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC1E,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,yBAAyB,EACzB,4BAA4B,EAC5B,2BAA2B,EAC3B,iBAAiB,EAClB,MAAM,wBAAwB,CAAA;AAiD/B;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,WAAW,EAAE,eAAe,EAC5B,SAAS,CAAC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