@nevermined-io/payments 1.3.2 → 1.4.1

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 (67) hide show
  1. package/README.md +5 -3
  2. package/dist/api/agents-api.d.ts +4 -3
  3. package/dist/api/agents-api.d.ts.map +1 -1
  4. package/dist/api/agents-api.js +5 -5
  5. package/dist/api/agents-api.js.map +1 -1
  6. package/dist/api/base-payments.d.ts +49 -1
  7. package/dist/api/base-payments.d.ts.map +1 -1
  8. package/dist/api/base-payments.js +82 -16
  9. package/dist/api/base-payments.js.map +1 -1
  10. package/dist/api/nvm-api.d.ts +2 -1
  11. package/dist/api/nvm-api.d.ts.map +1 -1
  12. package/dist/api/nvm-api.js +2 -1
  13. package/dist/api/nvm-api.js.map +1 -1
  14. package/dist/api/organizations-api/organizations-api.d.ts +42 -1
  15. package/dist/api/organizations-api/organizations-api.d.ts.map +1 -1
  16. package/dist/api/organizations-api/organizations-api.js +91 -3
  17. package/dist/api/organizations-api/organizations-api.js.map +1 -1
  18. package/dist/api/organizations-api/types.d.ts +134 -0
  19. package/dist/api/organizations-api/types.d.ts.map +1 -1
  20. package/dist/api/organizations-api/types.js +52 -0
  21. package/dist/api/organizations-api/types.js.map +1 -1
  22. package/dist/api/plans-api.d.ts +15 -36
  23. package/dist/api/plans-api.d.ts.map +1 -1
  24. package/dist/api/plans-api.js +22 -57
  25. package/dist/api/plans-api.js.map +1 -1
  26. package/dist/common/types.d.ts +38 -15
  27. package/dist/common/types.d.ts.map +1 -1
  28. package/dist/common/types.js.map +1 -1
  29. package/dist/environments.d.ts +0 -7
  30. package/dist/environments.d.ts.map +1 -1
  31. package/dist/environments.js +0 -13
  32. package/dist/environments.js.map +1 -1
  33. package/dist/index.d.ts +5 -3
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +3 -2
  36. package/dist/index.js.map +1 -1
  37. package/dist/mcp/http/session-manager.d.ts.map +1 -1
  38. package/dist/mcp/http/session-manager.js +15 -1
  39. package/dist/mcp/http/session-manager.js.map +1 -1
  40. package/dist/payments.d.ts +26 -1
  41. package/dist/payments.d.ts.map +1 -1
  42. package/dist/payments.js +43 -11
  43. package/dist/payments.js.map +1 -1
  44. package/dist/plans.d.ts +1 -1
  45. package/dist/plans.js +6 -6
  46. package/dist/plans.js.map +1 -1
  47. package/dist/x402/delegation-api.d.ts +34 -7
  48. package/dist/x402/delegation-api.d.ts.map +1 -1
  49. package/dist/x402/delegation-api.js +15 -3
  50. package/dist/x402/delegation-api.js.map +1 -1
  51. package/dist/x402/facilitator-api.d.ts +5 -6
  52. package/dist/x402/facilitator-api.d.ts.map +1 -1
  53. package/dist/x402/facilitator-api.js +17 -5
  54. package/dist/x402/facilitator-api.js.map +1 -1
  55. package/dist/x402/index.d.ts +2 -6
  56. package/dist/x402/index.d.ts.map +1 -1
  57. package/dist/x402/index.js +1 -4
  58. package/dist/x402/index.js.map +1 -1
  59. package/package.json +23 -21
  60. package/dist/x402/visa-facilitator-api.d.ts +0 -150
  61. package/dist/x402/visa-facilitator-api.d.ts.map +0 -1
  62. package/dist/x402/visa-facilitator-api.js +0 -206
  63. package/dist/x402/visa-facilitator-api.js.map +0 -1
  64. package/dist/x402/visa-token-api.d.ts +0 -60
  65. package/dist/x402/visa-token-api.d.ts.map +0 -1
  66. package/dist/x402/visa-token-api.js +0 -99
  67. package/dist/x402/visa-token-api.js.map +0 -1
@@ -2,19 +2,6 @@ export const ZeroAddress = '0x0000000000000000000000000000000000000000';
2
2
  /**
3
3
  * Represents the different environments and their corresponding URLs.
4
4
  */
5
- /**
6
- * Visa backend URLs mapped by environment name.
7
- * When scheme is 'visa', the facilitator and token APIs use these URLs
8
- * for verify, settle, and access-token operations while the main NVM
9
- * backend (from Environments) is still used for plans, agents, etc.
10
- */
11
- export const VisaBackendUrls = {
12
- staging_sandbox: process.env.VISA_STAGING_SANDBOX_URL || 'https://visa.nevermined.dev/api/',
13
- staging_live: process.env.VISA_STAGING_LIVE_URL || 'https://visa.nevermined.dev/api/',
14
- sandbox: process.env.VISA_SANDBOX_URL || 'https://visa.nevermined.dev/api/',
15
- live: process.env.VISA_LIVE_URL || 'https://visa.nevermined.dev/api/',
16
- custom: process.env.VISA_BACKEND_URL || 'http://localhost:3000/api/',
17
- };
18
5
  export const Environments = {
19
6
  /**
20
7
  * The staging environment URLs.
@@ -1 +1 @@
1
- {"version":3,"file":"environments.js","sourceRoot":"","sources":["../src/environments.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,WAAW,GAAG,4CAA4C,CAAA;AAIvE;;GAEG;AACH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAoC;IAC9D,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,kCAAkC;IAC3F,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,kCAAkC;IACrF,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,kCAAkC;IAC3E,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,kCAAkC;IACrE,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,4BAA4B;CACrE,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAA6C;IACpE;;OAEG;IACH,eAAe,EAAE;QACf,QAAQ,EAAE,wBAAwB;QAClC,OAAO,EAAE,qCAAqC;QAC9C,KAAK,EAAE,sCAAsC;QAC7C,WAAW,EAAE,iCAAiC;KAC/C;IACD,YAAY,EAAE;QACZ,QAAQ,EAAE,wBAAwB;QAClC,OAAO,EAAE,kCAAkC;QAC3C,KAAK,EAAE,mCAAmC;QAC1C,WAAW,EAAE,iCAAiC;KAC/C;IACD;;OAEG;IACH,OAAO,EAAE;QACP,QAAQ,EAAE,wBAAwB;QAClC,OAAO,EAAE,qCAAqC;QAC9C,KAAK,EAAE,sCAAsC;QAC7C,WAAW,EAAE,iCAAiC;KAC/C;IACD;;OAEG;IACH,IAAI,EAAE;QACJ,QAAQ,EAAE,wBAAwB;QAClC,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,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 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 */\n/**\n * Visa backend URLs mapped by environment name.\n * When scheme is 'visa', the facilitator and token APIs use these URLs\n * for verify, settle, and access-token operations while the main NVM\n * backend (from Environments) is still used for plans, agents, etc.\n */\nexport const VisaBackendUrls: Record<EnvironmentName, string> = {\n staging_sandbox: process.env.VISA_STAGING_SANDBOX_URL || 'https://visa.nevermined.dev/api/',\n staging_live: process.env.VISA_STAGING_LIVE_URL || 'https://visa.nevermined.dev/api/',\n sandbox: process.env.VISA_SANDBOX_URL || 'https://visa.nevermined.dev/api/',\n live: process.env.VISA_LIVE_URL || 'https://visa.nevermined.dev/api/',\n custom: process.env.VISA_BACKEND_URL || 'http://localhost:3000/api/',\n}\n\nexport const Environments: Record<EnvironmentName, EnvironmentInfo> = {\n /**\n * The staging environment URLs.\n */\n staging_sandbox: {\n frontend: 'https://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 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 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 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 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":"AAOA,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,OAAO,EAAE,qCAAqC;QAC9C,KAAK,EAAE,sCAAsC;QAC7C,WAAW,EAAE,iCAAiC;KAC/C;IACD,YAAY,EAAE;QACZ,QAAQ,EAAE,wBAAwB;QAClC,OAAO,EAAE,kCAAkC;QAC3C,KAAK,EAAE,mCAAmC;QAC1C,WAAW,EAAE,iCAAiC;KAC/C;IACD;;OAEG;IACH,OAAO,EAAE;QACP,QAAQ,EAAE,wBAAwB;QAClC,OAAO,EAAE,qCAAqC;QAC9C,KAAK,EAAE,sCAAsC;QAC7C,WAAW,EAAE,iCAAiC;KAC/C;IACD;;OAEG;IACH,IAAI,EAAE;QACJ,QAAQ,EAAE,wBAAwB;QAClC,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,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 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 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 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 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 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 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
@@ -8,13 +8,15 @@ export * from './api/query-api.js';
8
8
  export * from './api/observability-api/observability-api.js';
9
9
  export type { BackendApiOptions } from './api/nvm-api.js';
10
10
  export { ContractsAPI } from './api/contracts-api.js';
11
+ export { CURRENT_ORG_ID_HEADER } from './api/base-payments.js';
12
+ export type { PublicationOptions } from './api/base-payments.js';
13
+ export { OrganizationsAPI } from './api/organizations-api/organizations-api.js';
14
+ export { OrganizationMemberRole, OrganizationType, OrganizationActivityEventType, } from './api/organizations-api/types.js';
15
+ export type { MyMembership, OrganizationActivityEvent, OrganizationActivityFilters, OrganizationActivityPage, } from './api/organizations-api/types.js';
11
16
  export { buildPaymentRequired, resolveNetwork, resolveScheme } from './x402/facilitator-api.js';
12
17
  export { DelegationAPI } from './x402/delegation-api.js';
13
18
  export type { PaymentMethodSummary, UpdatePaymentMethodDto, DelegationSummary, DelegationListResponse, PurchasingPower, ListOptions, } from './x402/delegation-api.js';
14
19
  export type { X402PaymentRequired, X402PaymentAccepted, X402Resource, X402Scheme, X402SchemeExtra, VerifyPermissionsParams, VerifyPermissionsResult, SettlePermissionsParams, SettlePermissionsResult, } from './x402/facilitator-api.js';
15
- export { buildVisaPaymentRequired, VISA_X402_HEADERS } from './x402/visa-facilitator-api.js';
16
- export type { VisaPaymentExtra, VisaPaymentRequirements, VisaPaymentRequired, VisaVerifyResponse, VisaSettlementResponse, } from './x402/visa-facilitator-api.js';
17
- export type { VisaPaymentPayloadResponse } from './x402/visa-token-api.js';
18
20
  export type { CreditsContext, CreditsOption, PaywallOptions, McpConfig, PaywallContext, AuthResult, } from './mcp/types/paywall.types.js';
19
21
  export type { OAuthUrls, OAuthConfig, HttpRouterConfig, HttpServerConfig, HttpServerResult, } from './mcp/types/http.types.js';
20
22
  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,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;AAGrD,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC/F,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,YAAY,EACV,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,EACf,WAAW,GACZ,MAAM,0BAA0B,CAAA;AACjC,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAC5F,YAAY,EACV,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,gCAAgC,CAAA;AACvC,YAAY,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAA;AAE1E,YAAY,EACV,cAAc,EACd,aAAa,EACb,cAAc,EACd,SAAS,EACT,cAAc,EACd,UAAU,GACX,MA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Ac,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC/F,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,YAAY,EACV,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,EACf,WAAW,GACZ,MAAM,0BAA0B,CAAA;AACjC,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,2BAA2B,CAAA;AAElC,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"}
package/dist/index.js CHANGED
@@ -7,11 +7,12 @@ export * from './common/helper.js';
7
7
  export * from './api/query-api.js';
8
8
  export * from './api/observability-api/observability-api.js';
9
9
  export { ContractsAPI } from './api/contracts-api.js';
10
+ export { CURRENT_ORG_ID_HEADER } from './api/base-payments.js';
11
+ export { OrganizationsAPI } from './api/organizations-api/organizations-api.js';
12
+ export { OrganizationMemberRole, OrganizationType, OrganizationActivityEventType, } from './api/organizations-api/types.js';
10
13
  // x402 utilities and types
11
14
  export { buildPaymentRequired, resolveNetwork, resolveScheme } from './x402/facilitator-api.js';
12
15
  export { DelegationAPI } from './x402/delegation-api.js';
13
- // Visa x402 utilities and types
14
- export { buildVisaPaymentRequired, VISA_X402_HEADERS } from './x402/visa-facilitator-api.js';
15
16
  // MCP HTTP utilities
16
17
  export { createRequireAuthMiddleware } from './mcp/http/oauth-router.js';
17
18
  //# sourceMappingURL=index.js.map
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,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;AAErD,2BAA2B;AAC3B,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC/F,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAoBxD,gCAAgC;AAChC,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AA+B5F,qBAAqB;AACrB,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA","sourcesContent":["export * from './environments.js'\nexport * from './payments.js'\nexport * from './utils.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'\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// Visa x402 utilities and types\nexport { buildVisaPaymentRequired, VISA_X402_HEADERS } from './x402/visa-facilitator-api.js'\nexport type {\n VisaPaymentExtra,\n VisaPaymentRequirements,\n VisaPaymentRequired,\n VisaVerifyResponse,\n VisaSettlementResponse,\n} from './x402/visa-facilitator-api.js'\nexport type { VisaPaymentPayloadResponse } from './x402/visa-token-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"]}
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,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","sourcesContent":["export * from './environments.js'\nexport * from './payments.js'\nexport * from './utils.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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"session-manager.d.ts","sourceRoot":"","sources":["../../../src/mcp/http/session-manager.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAA;IACtD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,EAAE,CAAC,EAAE,MAAM,CAAA;CACZ;AAmBD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,yCAAyC;IACzC,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9C,2CAA2C;IAC3C,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,GAAG,OAAO;IAsB1C;;OAEG;IACH,iBAAiB,IAAI,MAAM,EAAE;IAI7B;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACH,kBAAkB,IAAI,IAAI;IAQ1B;;OAEG;IACH,OAAO,CAAC,GAAG;CAGZ;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,GAAE,oBAAyB,GAAG,cAAc,CAEtF"}
@@ -82,6 +82,17 @@ export class SessionManager {
82
82
  if (!this.mcpServer) {
83
83
  throw new Error('MCP server not set. Call setMcpServer() first.');
84
84
  }
85
+ // In stateless mode (sessionIdGenerator: undefined), each request gets a new transport
86
+ // but McpServer can only have one transport at a time. Close the existing connection
87
+ // before connecting the new transport so Protocol._transport is reset to undefined.
88
+ // The StreamableHTTPServerTransport with enableJsonResponse does not auto-close after
89
+ // sending a JSON response, so we must close it explicitly before each new connection.
90
+ try {
91
+ await this.mcpServer.close();
92
+ }
93
+ catch (_e) {
94
+ // Ignore close errors — server may not have been connected yet
95
+ }
85
96
  const TransportClass = await getTransportClass();
86
97
  // Use stateless mode (sessionIdGenerator: undefined) to avoid requiring
87
98
  // Mcp-Session-Id header on every request. This allows clients to make
@@ -90,10 +101,13 @@ export class SessionManager {
90
101
  sessionIdGenerator: undefined,
91
102
  enableJsonResponse: true,
92
103
  });
104
+ // Set onclose BEFORE connect() so the SDK chains it with its own handler.
105
+ // When the transport closes, both our cleanup and the SDK's cleanup run.
93
106
  transport.onclose = () => {
94
- this.log?.(`Transport closed for session ${sessionId}`);
95
107
  this.sessions.delete(sessionId);
108
+ this.requestContexts.delete(sessionId);
96
109
  this.config.onSessionDestroyed?.(sessionId);
110
+ this.log?.(`Transport closed for session ${sessionId}`);
97
111
  };
98
112
  await this.mcpServer.connect(transport);
99
113
  // Force _initialized to true to allow requests without requiring initialize first.
@@ -1 +1 @@
1
- {"version":3,"file":"session-manager.js","sourceRoot":"","sources":["../../../src/mcp/http/session-manager.ts"],"names":[],"mappings":"AAAA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,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;QAC3C,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAA;QAChC,CAAC;QACD,IAAI,CAAC,GAAG,EAAE,CAAC,iBAAiB,UAAU,CAAC,MAAM,WAAW,CAAC,CAAA;IAC3D,CAAC;IAED;;OAEG;IACK,GAAG,CAAC,OAAe;QACzB,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,CAAA;IAC5B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAA+B,EAAE;IACpE,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAA;AACnC,CAAC","sourcesContent":["/**\n * Session manager for MCP transports.\n * Handles creation, retrieval, and cleanup of StreamableHTTPServerTransport instances.\n * Also stores request context (headers) per session for authentication.\n */\nimport { randomUUID } from 'crypto'\n\n// We'll dynamically import the SDK to avoid hard dependency issues\nlet StreamableHTTPServerTransport: any = null\n\n/**\n * Request context stored per session.\n * Contains HTTP headers and other request info needed for authentication.\n */\nexport interface RequestContext {\n headers: Record<string, string | string[] | undefined>\n method?: string\n url?: string\n ip?: string\n}\n\n/**\n * Lazily load the MCP SDK transport.\n */\nasync function getTransportClass(): Promise<any> {\n if (!StreamableHTTPServerTransport) {\n try {\n const module = await import('@modelcontextprotocol/sdk/server/streamableHttp.js')\n StreamableHTTPServerTransport = module.StreamableHTTPServerTransport\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 StreamableHTTPServerTransport\n}\n\n/**\n * Configuration for session manager.\n */\nexport interface SessionManagerConfig {\n /** Callback when a session is created */\n onSessionCreated?: (sessionId: string) => void\n /** Callback when a session is destroyed */\n onSessionDestroyed?: (sessionId: string) => void\n /** Logger function */\n log?: (message: string) => void\n}\n\n/**\n * Manages MCP transport sessions.\n */\nexport class SessionManager {\n private sessions: Map<string, any> = new Map()\n private requestContexts: Map<string, RequestContext> = new Map()\n private mcpServer: any = null\n private config: SessionManagerConfig\n\n constructor(config: SessionManagerConfig = {}) {\n this.config = config\n }\n\n /**\n * Set the MCP server that transports will connect to.\n */\n setMcpServer(server: any): void {\n this.mcpServer = server\n }\n\n /**\n * Generate a new session ID.\n */\n generateSessionId(): string {\n return randomUUID()\n }\n\n /**\n * Check if a session exists.\n */\n hasSession(sessionId: string): boolean {\n return this.sessions.has(sessionId)\n }\n\n /**\n * Get an existing session's transport.\n */\n getSession(sessionId: string): any | undefined {\n return this.sessions.get(sessionId)\n }\n\n /**\n * Store request context (headers, etc.) for a session.\n * This is called when an HTTP request arrives, before dispatching to MCP.\n */\n setRequestContext(sessionId: string, context: RequestContext): void {\n this.requestContexts.set(sessionId, context)\n }\n\n /**\n * Get the stored request context for a session.\n * Returns undefined if no context is stored.\n */\n getRequestContext(sessionId: string): RequestContext | undefined {\n return this.requestContexts.get(sessionId)\n }\n\n /**\n * Get or create a transport for a session.\n */\n async getOrCreateSession(sessionId: string): Promise<any> {\n if (this.sessions.has(sessionId)) {\n const existingSession = this.sessions.get(sessionId)\n if (existingSession) {\n return existingSession\n }\n }\n\n if (!this.mcpServer) {\n throw new Error('MCP server not set. Call setMcpServer() first.')\n }\n\n const TransportClass = await getTransportClass()\n\n // Use stateless mode (sessionIdGenerator: undefined) to avoid requiring\n // Mcp-Session-Id header on every request. This allows clients to make\n // direct JSON-RPC calls without the full MCP initialization handshake.\n const transport = new TransportClass({\n sessionIdGenerator: undefined,\n enableJsonResponse: true,\n })\n\n transport.onclose = () => {\n this.log?.(`Transport closed for session ${sessionId}`)\n this.sessions.delete(sessionId)\n this.config.onSessionDestroyed?.(sessionId)\n }\n\n await this.mcpServer.connect(transport)\n\n // Force _initialized to true to allow requests without requiring initialize first.\n // This maintains backward compatibility with clients that don't send initialize.\n // The SDK sets _initialized = true only after processing an initialize request,\n // but we want to accept tool/resource/prompt calls directly.\n if (transport._initialized === false) {\n transport._initialized = true\n }\n\n this.sessions.set(sessionId, transport)\n\n this.log?.(`Created new transport for session ${sessionId}`)\n this.config.onSessionCreated?.(sessionId)\n\n return transport\n }\n\n /**\n * Destroy a session.\n */\n destroySession(sessionId: string): boolean {\n if (this.sessions.has(sessionId)) {\n const transport = this.sessions.get(sessionId)\n this.sessions.delete(sessionId)\n this.requestContexts.delete(sessionId) // Clean up request context\n this.log?.(`Destroyed session ${sessionId}`)\n this.config.onSessionDestroyed?.(sessionId)\n\n // Try to close the transport if it has a close method\n if (transport && typeof transport.close === 'function') {\n try {\n transport.close()\n } catch {\n // Ignore close errors\n }\n }\n\n return true\n }\n return false\n }\n\n /**\n * Get all active session IDs.\n */\n getActiveSessions(): string[] {\n return Array.from(this.sessions.keys())\n }\n\n /**\n * Get the number of active sessions.\n */\n getSessionCount(): number {\n return this.sessions.size\n }\n\n /**\n * Destroy all sessions.\n */\n destroyAllSessions(): void {\n const sessionIds = this.getActiveSessions()\n for (const sessionId of sessionIds) {\n this.destroySession(sessionId)\n }\n this.log?.(`Destroyed all ${sessionIds.length} sessions`)\n }\n\n /**\n * Internal logging helper (no-op if log not provided).\n */\n private log(message: string): void {\n this.config.log?.(message)\n }\n}\n\n/**\n * Create a new session manager.\n */\nexport function createSessionManager(config: SessionManagerConfig = {}): SessionManager {\n return new SessionManager(config)\n}\n"]}
1
+ {"version":3,"file":"session-manager.js","sourceRoot":"","sources":["../../../src/mcp/http/session-manager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAEnC,mEAAmE;AACnE,IAAI,6BAA6B,GAAQ,IAAI,CAAA;AAa7C;;GAEG;AACH,KAAK,UAAU,iBAAiB;IAC9B,IAAI,CAAC,6BAA6B,EAAE,CAAC;QACnC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,oDAAoD,CAAC,CAAA;YAC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,kBAAkB;QAChB,MAAM,UAAU,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;QAC3C,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAA;QAChC,CAAC;QACD,IAAI,CAAC,GAAG,EAAE,CAAC,iBAAiB,UAAU,CAAC,MAAM,WAAW,CAAC,CAAA;IAC3D,CAAC;IAED;;OAEG;IACK,GAAG,CAAC,OAAe;QACzB,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,CAAA;IAC5B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAA+B,EAAE;IACpE,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAA;AACnC,CAAC","sourcesContent":["/**\n * Session manager for MCP transports.\n * Handles creation, retrieval, and cleanup of StreamableHTTPServerTransport instances.\n * Also stores request context (headers) per session for authentication.\n */\nimport { randomUUID } from 'crypto'\n\n// We'll dynamically import the SDK to avoid hard dependency issues\nlet StreamableHTTPServerTransport: any = null\n\n/**\n * Request context stored per session.\n * Contains HTTP headers and other request info needed for authentication.\n */\nexport interface RequestContext {\n headers: Record<string, string | string[] | undefined>\n method?: string\n url?: string\n ip?: string\n}\n\n/**\n * Lazily load the MCP SDK transport.\n */\nasync function getTransportClass(): Promise<any> {\n if (!StreamableHTTPServerTransport) {\n try {\n const module = await import('@modelcontextprotocol/sdk/server/streamableHttp.js')\n StreamableHTTPServerTransport = module.StreamableHTTPServerTransport\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 StreamableHTTPServerTransport\n}\n\n/**\n * Configuration for session manager.\n */\nexport interface SessionManagerConfig {\n /** Callback when a session is created */\n onSessionCreated?: (sessionId: string) => void\n /** Callback when a session is destroyed */\n onSessionDestroyed?: (sessionId: string) => void\n /** Logger function */\n log?: (message: string) => void\n}\n\n/**\n * Manages MCP transport sessions.\n */\nexport class SessionManager {\n private sessions: Map<string, any> = new Map()\n private requestContexts: Map<string, RequestContext> = new Map()\n private mcpServer: any = null\n private config: SessionManagerConfig\n\n constructor(config: SessionManagerConfig = {}) {\n this.config = config\n }\n\n /**\n * Set the MCP server that transports will connect to.\n */\n setMcpServer(server: any): void {\n this.mcpServer = server\n }\n\n /**\n * Generate a new session ID.\n */\n generateSessionId(): string {\n return randomUUID()\n }\n\n /**\n * Check if a session exists.\n */\n hasSession(sessionId: string): boolean {\n return this.sessions.has(sessionId)\n }\n\n /**\n * Get an existing session's transport.\n */\n getSession(sessionId: string): any | undefined {\n return this.sessions.get(sessionId)\n }\n\n /**\n * Store request context (headers, etc.) for a session.\n * This is called when an HTTP request arrives, before dispatching to MCP.\n */\n setRequestContext(sessionId: string, context: RequestContext): void {\n this.requestContexts.set(sessionId, context)\n }\n\n /**\n * Get the stored request context for a session.\n * Returns undefined if no context is stored.\n */\n getRequestContext(sessionId: string): RequestContext | undefined {\n return this.requestContexts.get(sessionId)\n }\n\n /**\n * Get or create a transport for a session.\n */\n async getOrCreateSession(sessionId: string): Promise<any> {\n if (this.sessions.has(sessionId)) {\n const existingSession = this.sessions.get(sessionId)\n if (existingSession) {\n return existingSession\n }\n }\n\n if (!this.mcpServer) {\n throw new Error('MCP server not set. Call setMcpServer() first.')\n }\n\n // In stateless mode (sessionIdGenerator: undefined), each request gets a new transport\n // but McpServer can only have one transport at a time. Close the existing connection\n // before connecting the new transport so Protocol._transport is reset to undefined.\n // The StreamableHTTPServerTransport with enableJsonResponse does not auto-close after\n // sending a JSON response, so we must close it explicitly before each new connection.\n try {\n await this.mcpServer.close()\n } catch (_e) {\n // Ignore close errors — server may not have been connected yet\n }\n\n const TransportClass = await getTransportClass()\n\n // Use stateless mode (sessionIdGenerator: undefined) to avoid requiring\n // Mcp-Session-Id header on every request. This allows clients to make\n // direct JSON-RPC calls without the full MCP initialization handshake.\n const transport = new TransportClass({\n sessionIdGenerator: undefined,\n enableJsonResponse: true,\n })\n\n // Set onclose BEFORE connect() so the SDK chains it with its own handler.\n // When the transport closes, both our cleanup and the SDK's cleanup run.\n transport.onclose = () => {\n this.sessions.delete(sessionId)\n this.requestContexts.delete(sessionId)\n this.config.onSessionDestroyed?.(sessionId)\n this.log?.(`Transport closed for session ${sessionId}`)\n }\n\n await this.mcpServer.connect(transport)\n\n // Force _initialized to true to allow requests without requiring initialize first.\n // This maintains backward compatibility with clients that don't send initialize.\n // The SDK sets _initialized = true only after processing an initialize request,\n // but we want to accept tool/resource/prompt calls directly.\n if (transport._initialized === false) {\n transport._initialized = true\n }\n\n this.sessions.set(sessionId, transport)\n\n this.log?.(`Created new transport for session ${sessionId}`)\n this.config.onSessionCreated?.(sessionId)\n\n return transport\n }\n\n /**\n * Destroy a session.\n */\n destroySession(sessionId: string): boolean {\n if (this.sessions.has(sessionId)) {\n const transport = this.sessions.get(sessionId)\n this.sessions.delete(sessionId)\n this.requestContexts.delete(sessionId) // Clean up request context\n this.log?.(`Destroyed session ${sessionId}`)\n this.config.onSessionDestroyed?.(sessionId)\n\n // Try to close the transport if it has a close method\n if (transport && typeof transport.close === 'function') {\n try {\n transport.close()\n } catch {\n // Ignore close errors\n }\n }\n\n return true\n }\n return false\n }\n\n /**\n * Get all active session IDs.\n */\n getActiveSessions(): string[] {\n return Array.from(this.sessions.keys())\n }\n\n /**\n * Get the number of active sessions.\n */\n getSessionCount(): number {\n return this.sessions.size\n }\n\n /**\n * Destroy all sessions.\n */\n destroyAllSessions(): void {\n const sessionIds = this.getActiveSessions()\n for (const sessionId of sessionIds) {\n this.destroySession(sessionId)\n }\n this.log?.(`Destroyed all ${sessionIds.length} sessions`)\n }\n\n /**\n * Internal logging helper (no-op if log not provided).\n */\n private log(message: string): void {\n this.config.log?.(message)\n }\n}\n\n/**\n * Create a new session manager.\n */\nexport function createSessionManager(config: SessionManagerConfig = {}): SessionManager {\n return new SessionManager(config)\n}\n"]}
@@ -98,7 +98,10 @@ export declare class Payments extends BasePaymentsAPI {
98
98
  };
99
99
  /**
100
100
  * Returns the Delegation API for listing enrolled payment methods.
101
- * The instance is lazily initialized on first access.
101
+ * The instance is lazily initialized on first access — the current
102
+ * organization pin (set via `setOrganizationId` or the constructor
103
+ * option) is forwarded so the first call carries the right
104
+ * `X-Current-Org-Id` header.
102
105
  */
103
106
  get delegation(): DelegationAPI;
104
107
  /**
@@ -177,6 +180,28 @@ export declare class Payments extends BasePaymentsAPI {
177
180
  * ```
178
181
  */
179
182
  logout(): void;
183
+ /**
184
+ * Pins (or clears) the active organization workspace used by every
185
+ * subsequent authenticated request. The SDK forwards the choice as the
186
+ * `X-Current-Org-Id` header so the backend scopes publications and
187
+ * other org-aware queries to the requested organization.
188
+ *
189
+ * Pass `null` to clear the pin and let the backend fall back to the
190
+ * API key's org tag or the caller's most-recent active membership.
191
+ *
192
+ * For one-off targeting (e.g. publish a single agent into Org B without
193
+ * leaving Org B as the active workspace) prefer the per-call
194
+ * `{ organizationId }` option on `agents.registerAgent` /
195
+ * `plans.registerPlan` / similar.
196
+ *
197
+ * @param organizationId - Org ID to pin (e.g. `org-…`) or `null` to clear.
198
+ * @example
199
+ * ```ts
200
+ * payments.setOrganizationId('org-abc123')
201
+ * await payments.agents.registerAgent(metadata, api, [planId]) // lands in org-abc123
202
+ * ```
203
+ */
204
+ setOrganizationId(organizationId: string | null): void;
180
205
  /**
181
206
  * Checks if a user is logged in.
182
207
  * @example
@@ -1 +1 @@
1
- {"version":3,"file":"payments.d.ts","sourceRoot":"","sources":["../src/payments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAA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;;;;;OAMG;IACH,IAAW,UAAU,IAAI,aAAa,CASrC;IAED;;;OAGG;IACH,MAAM,CAAC,GAAG;;MAA4B;IAEtC;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,cAAc;IAO1C;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,kBAAkB,CAAC,OAAO,EAAE,cAAc;IAoBjD;;;;;OAKG;IACH,OAAO;IAOP;;OAEG;IACH,OAAO,CAAC,aAAa;IAYrB;;;;;;;;;;OAUG;IACI,OAAO;IAMd;;;;;;;;;OASG;IACI,MAAM;IAIb;;;;;;;;;;;;;;;;;;;;OAoBG;IACa,iBAAiB,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAgBtE;;;;;;;OAOG;IACH,IAAI,UAAU,IAAI,OAAO,CAExB;CACF"}
package/dist/payments.js CHANGED
@@ -14,8 +14,6 @@ import { OrganizationsAPI } from './api/organizations-api/organizations-api.js';
14
14
  import { FacilitatorAPI } from './x402/facilitator-api.js';
15
15
  import { X402TokenAPI } from './x402/token.js';
16
16
  import { DelegationAPI } from './x402/delegation-api.js';
17
- import { VisaFacilitatorAPI } from './x402/visa-facilitator-api.js';
18
- import { VisaTokenAPI } from './x402/visa-token-api.js';
19
17
  /**
20
18
  * Main class that interacts with the Nevermined payments API.
21
19
  * Use `Payments.getInstance` for server-side usage or `Payments.getBrowserInstance` for browser usage.
@@ -66,13 +64,17 @@ export class Payments extends BasePaymentsAPI {
66
64
  }
67
65
  /**
68
66
  * Returns the Delegation API for listing enrolled payment methods.
69
- * The instance is lazily initialized on first access.
67
+ * The instance is lazily initialized on first access — the current
68
+ * organization pin (set via `setOrganizationId` or the constructor
69
+ * option) is forwarded so the first call carries the right
70
+ * `X-Current-Org-Id` header.
70
71
  */
71
72
  get delegation() {
72
73
  if (!this._delegation) {
73
74
  this._delegation = DelegationAPI.getInstance({
74
75
  nvmApiKey: this.nvmApiKey,
75
76
  environment: this.environmentName,
77
+ organizationId: this.currentOrganizationId ?? undefined,
76
78
  });
77
79
  }
78
80
  return this._delegation;
@@ -154,14 +156,8 @@ export class Payments extends BasePaymentsAPI {
154
156
  this.organizations = OrganizationsAPI.getInstance(options);
155
157
  this.query = AIQueryApi.getInstance();
156
158
  this.contracts = new ContractsAPI(options);
157
- if (options.scheme === 'visa') {
158
- this.facilitator = VisaFacilitatorAPI.getInstance(options);
159
- this.x402 = VisaTokenAPI.getInstance(options);
160
- }
161
- else {
162
- this.facilitator = FacilitatorAPI.getInstance(options);
163
- this.x402 = X402TokenAPI.getInstance(options);
164
- }
159
+ this.facilitator = FacilitatorAPI.getInstance(options);
160
+ this.x402 = X402TokenAPI.getInstance(options);
165
161
  }
166
162
  /**
167
163
  * Initiates the connect flow. The user's browser will be redirected to
@@ -193,6 +189,42 @@ export class Payments extends BasePaymentsAPI {
193
189
  logout() {
194
190
  this.nvmApiKey = '';
195
191
  }
192
+ /**
193
+ * Pins (or clears) the active organization workspace used by every
194
+ * subsequent authenticated request. The SDK forwards the choice as the
195
+ * `X-Current-Org-Id` header so the backend scopes publications and
196
+ * other org-aware queries to the requested organization.
197
+ *
198
+ * Pass `null` to clear the pin and let the backend fall back to the
199
+ * API key's org tag or the caller's most-recent active membership.
200
+ *
201
+ * For one-off targeting (e.g. publish a single agent into Org B without
202
+ * leaving Org B as the active workspace) prefer the per-call
203
+ * `{ organizationId }` option on `agents.registerAgent` /
204
+ * `plans.registerPlan` / similar.
205
+ *
206
+ * @param organizationId - Org ID to pin (e.g. `org-…`) or `null` to clear.
207
+ * @example
208
+ * ```ts
209
+ * payments.setOrganizationId('org-abc123')
210
+ * await payments.agents.registerAgent(metadata, api, [planId]) // lands in org-abc123
211
+ * ```
212
+ */
213
+ setOrganizationId(organizationId) {
214
+ super.setOrganizationId(organizationId);
215
+ this.plans?.setOrganizationId(organizationId);
216
+ this.agents?.setOrganizationId(organizationId);
217
+ this.requests?.setOrganizationId(organizationId);
218
+ this.observability?.setOrganizationId(organizationId);
219
+ this.organizations?.setOrganizationId(organizationId);
220
+ this.contracts?.setOrganizationId(organizationId);
221
+ this.facilitator?.setOrganizationId(organizationId);
222
+ this.x402?.setOrganizationId(organizationId);
223
+ // `_delegation` is lazy — the getter forwards `currentOrganizationId`
224
+ // on first access, so only propagate to an already-built instance.
225
+ // (Eagerly constructing it here would change the lazy contract.)
226
+ this._delegation?.setOrganizationId(organizationId);
227
+ }
196
228
  /**
197
229
  * Checks if a user is logged in.
198
230
  * @example
@@ -1 +1 @@
1
- {"version":3,"file":"payments.js","sourceRoot":"","sources":["../src/payments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAA;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAA;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO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AAG,EAAE,CAAA;IACrB,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAA;IAClC,CAAC;;AA5ID;;;GAGG;AACI,YAAG,GAAG,EAAE,qBAAqB,EAAE,CAAA","sourcesContent":["import { AIQueryApi } from './api/query-api.js'\nimport { PaymentsError } from './common/payments.error.js'\nimport { PaymentOptions } from './common/types.js'\nimport { BasePaymentsAPI } from './api/base-payments.js'\nimport { PlansAPI } from './api/plans-api.js'\nimport { ContractsAPI } from './api/contracts-api.js'\nimport { AgentsAPI } from './api/agents-api.js'\nimport { AgentRequestsAPI } from './api/requests-api.js'\nimport { ObservabilityAPI } from './api/observability-api/observability-api.js'\nimport { ClientRegistry } from './a2a/clientRegistry.js'\nimport type { PaymentsA2AServerOptions, PaymentsA2AServerResult } from './a2a/server.js'\nimport { PaymentsA2AServer } from './a2a/server.js'\nimport { buildPaymentAgentCard } from './a2a/agent-card.js'\nimport * as mcpModule from './mcp/index.js'\nimport { OrganizationsAPI } from './api/organizations-api/organizations-api.js'\nimport { FacilitatorAPI } from './x402/facilitator-api.js'\nimport { X402TokenAPI } from './x402/token.js'\nimport { DelegationAPI } from './x402/delegation-api.js'\nimport { VisaFacilitatorAPI } from './x402/visa-facilitator-api.js'\nimport { VisaTokenAPI } from './x402/visa-token-api.js'\n\n/**\n * Main class that interacts with the Nevermined payments API.\n * Use `Payments.getInstance` for server-side usage or `Payments.getBrowserInstance` for browser usage.\n * @remarks This API requires a Nevermined API Key, which can be obtained by logging in to the Nevermined App.\n *\n * The library provides methods to manage AI Agents, Plans & process AI Agent Requests.\n *\n * Each of these functionalities is encapsulated in its own API class:\n * - `plans`: Manages AI Plans, including registration and ordering and retrieving plan details.\n * - `agents`: Handles AI Agents, including registration of AI Agents and access token generation.\n * - `requests`: Manages requests received by AI Agents, including validation and tracking.\n * - `observability`: Provides observability and logging utilities for AI Agents with Helicone integration\n */\nexport class Payments extends BasePaymentsAPI {\n public query!: AIQueryApi\n public plans!: PlansAPI\n public agents!: AgentsAPI\n public requests!: AgentRequestsAPI\n public observability!: ObservabilityAPI\n public organizations!: OrganizationsAPI\n public contracts!: ContractsAPI\n public facilitator!: FacilitatorAPI\n public x402!: X402TokenAPI\n private _a2aRegistry?: ClientRegistry\n private _delegation?: DelegationAPI\n\n /**\n * Cached MCP integration to preserve configuration (e.g., agentId, serverName)\n * across multiple getter accesses. This ensures callers do not need to retain\n * a reference to a previously configured instance.\n */\n private _mcpIntegration?: ReturnType<typeof mcpModule.buildMcpIntegration>\n\n /**\n * Exposes A2A server and client registry methods.\n * The client registry is initialized only if getClient is called.\n */\n public get a2a() {\n return {\n /**\n * Starts the A2A server with payment integration.\n * @param options - Server options.\n */\n start: (\n options: Omit<PaymentsA2AServerOptions, 'paymentsService'>,\n ): PaymentsA2AServerResult => PaymentsA2AServer.start({ ...options, paymentsService: this }),\n\n /**\n * Gets (or creates) a RegisteredPaymentsClient for the given alias.\n * The registry is initialized only on first use.\n * @param options - ClientRegistryOptions.\n */\n getClient: async (options: any) => {\n if (!this._a2aRegistry) {\n this._a2aRegistry = new ClientRegistry(this)\n }\n return await this._a2aRegistry.getClient(options)\n },\n }\n }\n\n /**\n * Returns the MCP integration API. The instance is memoized so that configuration\n * set via `configure({ agentId, serverName })` persists across calls.\n */\n public get mcp() {\n if (!this._mcpIntegration) {\n this._mcpIntegration = mcpModule.buildMcpIntegration(this)\n }\n return this._mcpIntegration\n }\n\n /**\n * Returns the Delegation API for listing enrolled payment methods.\n * The instance is lazily initialized on first access.\n */\n public get delegation(): DelegationAPI {\n if (!this._delegation) {\n this._delegation = DelegationAPI.getInstance({\n nvmApiKey: this.nvmApiKey,\n environment: this.environmentName,\n })\n }\n return this._delegation\n }\n\n /**\n * Static A2A helpers and utilities.\n * Example: Payments.a2a.buildPaymentAgentCard(...)\n */\n static a2a = { buildPaymentAgentCard }\n\n /**\n * Get an instance of the Payments class for server-side usage.\n *\n * @param options - The options to initialize the payments class.\n * @example\n * ```\n * const payments = Payments.getInstance({\n * nvmApiKey: 'your-nvm-api-key',\n * environment: 'sandbox'\n * })\n * ```\n * @returns An instance of {@link Payments}\n * @throws PaymentsError if nvmApiKey is missing.\n */\n static getInstance(options: PaymentOptions) {\n if (!options.nvmApiKey) {\n throw new PaymentsError('Nevermined API Key is required')\n }\n return new Payments(options, false)\n }\n\n /**\n * Get an instance of the Payments class for browser usage.\n *\n * @remarks\n * This is a browser-only function.\n *\n * @param options - The options to initialize the payments class.\n * @example\n * ```\n * const payments = Payments.getBrowserInstance({\n * returnUrl: 'https://mysite.example',\n * environment: 'sandbox',\n * appId: 'my-app-id',\n * version: '1.0.0'\n * })\n * ```\n * @returns An instance of {@link Payments}\n * @throws PaymentsError if returnUrl is missing.\n */\n static getBrowserInstance(options: PaymentOptions) {\n if (!options.returnUrl) {\n throw new PaymentsError('returnUrl is required')\n }\n const url = new URL(window.location.href)\n const urlNvmApiKey = url.searchParams.get('nvmApiKey') as string\n if (urlNvmApiKey) {\n url.searchParams.delete('nvmApiKey')\n }\n\n const urlAccountAddress = url.searchParams.get('accountAddress') as string\n if (urlAccountAddress) {\n url.searchParams.delete('accountAddress')\n }\n\n history.replaceState(history.state, '', url.toString())\n\n return new Payments(options, true)\n }\n\n /**\n * Initializes the Payments class.\n *\n * @param options - The options to initialize the payments class.\n * @param isBrowserInstance - Whether this instance is for browser usage.\n */\n private constructor(options: PaymentOptions, isBrowserInstance = true) {\n super(options)\n\n this.isBrowserInstance = isBrowserInstance\n this.initializeApi(options)\n }\n\n /**\n * Initializes the AI Query Protocol API.\n */\n private initializeApi(options: PaymentOptions) {\n this.plans = PlansAPI.getInstance(options)\n this.agents = AgentsAPI.getInstance(options)\n this.requests = AgentRequestsAPI.getInstance(options)\n this.observability = ObservabilityAPI.getInstance(options)\n this.organizations = OrganizationsAPI.getInstance(options)\n this.query = AIQueryApi.getInstance()\n this.contracts = new ContractsAPI(options)\n if (options.scheme === 'visa') {\n this.facilitator = VisaFacilitatorAPI.getInstance(options)\n this.x402 = VisaTokenAPI.getInstance(options)\n } else {\n this.facilitator = FacilitatorAPI.getInstance(options)\n this.x402 = X402TokenAPI.getInstance(options)\n }\n }\n\n /**\n * Initiates the connect flow. The user's browser will be redirected to\n * the Nevermined App login page.\n *\n * @remarks\n * This is a browser-only function.\n * @example\n * ```\n * payments.connect()\n * ```\n */\n public connect() {\n if (!this.isBrowserInstance) return\n const url = new URL(`/login?returnUrl=${this.returnUrl}`, this.environment.frontend)\n window.location.href = url.toString()\n }\n\n /**\n * Logs out the user by removing the NVM API key.\n *\n * @remarks\n * This is a browser-only function.\n * @example\n * ```\n * payments.logout()\n * ```\n */\n public logout() {\n this.nvmApiKey = ''\n }\n\n /**\n * Checks if a user is logged in.\n * @example\n * ```\n * payments.isLoggedIn\n * ```\n * @returns True if the user is logged in.\n */\n get isLoggedIn(): boolean {\n return this.nvmApiKey.length > 0\n }\n}\n"]}
1
+ {"version":3,"file":"payments.js","sourceRoot":"","sources":["../src/payments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAA;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,C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IACrB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACa,iBAAiB,CAAC,cAA6B;QAC7D,KAAK,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAA;QACvC,IAAI,CAAC,KAAK,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAA;QAC7C,IAAI,CAAC,MAAM,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAA;QAC9C,IAAI,CAAC,QAAQ,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAA;QAChD,IAAI,CAAC,aAAa,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAA;QACrD,IAAI,CAAC,aAAa,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAA;QACrD,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAA;QACjD,IAAI,CAAC,WAAW,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAA;QACnD,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAA;QAC5C,sEAAsE;QACtE,mEAAmE;QACnE,iEAAiE;QACjE,IAAI,CAAC,WAAW,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAA;IACrD,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAA;IAClC,CAAC;;AA5KD;;;GAGG;AACI,YAAG,GAAG,EAAE,qBAAqB,EAAE,CAAA","sourcesContent":["import { AIQueryApi } from './api/query-api.js'\nimport { PaymentsError } from './common/payments.error.js'\nimport { PaymentOptions } from './common/types.js'\nimport { BasePaymentsAPI } from './api/base-payments.js'\nimport { PlansAPI } from './api/plans-api.js'\nimport { ContractsAPI } from './api/contracts-api.js'\nimport { AgentsAPI } from './api/agents-api.js'\nimport { AgentRequestsAPI } from './api/requests-api.js'\nimport { ObservabilityAPI } from './api/observability-api/observability-api.js'\nimport { ClientRegistry } from './a2a/clientRegistry.js'\nimport type { PaymentsA2AServerOptions, PaymentsA2AServerResult } from './a2a/server.js'\nimport { PaymentsA2AServer } from './a2a/server.js'\nimport { buildPaymentAgentCard } from './a2a/agent-card.js'\nimport * as mcpModule from './mcp/index.js'\nimport { OrganizationsAPI } from './api/organizations-api/organizations-api.js'\nimport { FacilitatorAPI } from './x402/facilitator-api.js'\nimport { X402TokenAPI } from './x402/token.js'\nimport { DelegationAPI } from './x402/delegation-api.js'\n\n/**\n * Main class that interacts with the Nevermined payments API.\n * Use `Payments.getInstance` for server-side usage or `Payments.getBrowserInstance` for browser usage.\n * @remarks This API requires a Nevermined API Key, which can be obtained by logging in to the Nevermined App.\n *\n * The library provides methods to manage AI Agents, Plans & process AI Agent Requests.\n *\n * Each of these functionalities is encapsulated in its own API class:\n * - `plans`: Manages AI Plans, including registration and ordering and retrieving plan details.\n * - `agents`: Handles AI Agents, including registration of AI Agents and access token generation.\n * - `requests`: Manages requests received by AI Agents, including validation and tracking.\n * - `observability`: Provides observability and logging utilities for AI Agents with Helicone integration\n */\nexport class Payments extends BasePaymentsAPI {\n public query!: AIQueryApi\n public plans!: PlansAPI\n public agents!: AgentsAPI\n public requests!: AgentRequestsAPI\n public observability!: ObservabilityAPI\n public organizations!: OrganizationsAPI\n public contracts!: ContractsAPI\n public facilitator!: FacilitatorAPI\n public x402!: X402TokenAPI\n private _a2aRegistry?: ClientRegistry\n private _delegation?: DelegationAPI\n\n /**\n * Cached MCP integration to preserve configuration (e.g., agentId, serverName)\n * across multiple getter accesses. This ensures callers do not need to retain\n * a reference to a previously configured instance.\n */\n private _mcpIntegration?: ReturnType<typeof mcpModule.buildMcpIntegration>\n\n /**\n * Exposes A2A server and client registry methods.\n * The client registry is initialized only if getClient is called.\n */\n public get a2a() {\n return {\n /**\n * Starts the A2A server with payment integration.\n * @param options - Server options.\n */\n start: (\n options: Omit<PaymentsA2AServerOptions, 'paymentsService'>,\n ): PaymentsA2AServerResult => PaymentsA2AServer.start({ ...options, paymentsService: this }),\n\n /**\n * Gets (or creates) a RegisteredPaymentsClient for the given alias.\n * The registry is initialized only on first use.\n * @param options - ClientRegistryOptions.\n */\n getClient: async (options: any) => {\n if (!this._a2aRegistry) {\n this._a2aRegistry = new ClientRegistry(this)\n }\n return await this._a2aRegistry.getClient(options)\n },\n }\n }\n\n /**\n * Returns the MCP integration API. The instance is memoized so that configuration\n * set via `configure({ agentId, serverName })` persists across calls.\n */\n public get mcp() {\n if (!this._mcpIntegration) {\n this._mcpIntegration = mcpModule.buildMcpIntegration(this)\n }\n return this._mcpIntegration\n }\n\n /**\n * Returns the Delegation API for listing enrolled payment methods.\n * The instance is lazily initialized on first access — the current\n * organization pin (set via `setOrganizationId` or the constructor\n * option) is forwarded so the first call carries the right\n * `X-Current-Org-Id` header.\n */\n public get delegation(): DelegationAPI {\n if (!this._delegation) {\n this._delegation = DelegationAPI.getInstance({\n nvmApiKey: this.nvmApiKey,\n environment: this.environmentName,\n organizationId: this.currentOrganizationId ?? undefined,\n })\n }\n return this._delegation\n }\n\n /**\n * Static A2A helpers and utilities.\n * Example: Payments.a2a.buildPaymentAgentCard(...)\n */\n static a2a = { buildPaymentAgentCard }\n\n /**\n * Get an instance of the Payments class for server-side usage.\n *\n * @param options - The options to initialize the payments class.\n * @example\n * ```\n * const payments = Payments.getInstance({\n * nvmApiKey: 'your-nvm-api-key',\n * environment: 'sandbox'\n * })\n * ```\n * @returns An instance of {@link Payments}\n * @throws PaymentsError if nvmApiKey is missing.\n */\n static getInstance(options: PaymentOptions) {\n if (!options.nvmApiKey) {\n throw new PaymentsError('Nevermined API Key is required')\n }\n return new Payments(options, false)\n }\n\n /**\n * Get an instance of the Payments class for browser usage.\n *\n * @remarks\n * This is a browser-only function.\n *\n * @param options - The options to initialize the payments class.\n * @example\n * ```\n * const payments = Payments.getBrowserInstance({\n * returnUrl: 'https://mysite.example',\n * environment: 'sandbox',\n * appId: 'my-app-id',\n * version: '1.0.0'\n * })\n * ```\n * @returns An instance of {@link Payments}\n * @throws PaymentsError if returnUrl is missing.\n */\n static getBrowserInstance(options: PaymentOptions) {\n if (!options.returnUrl) {\n throw new PaymentsError('returnUrl is required')\n }\n const url = new URL(window.location.href)\n const urlNvmApiKey = url.searchParams.get('nvmApiKey') as string\n if (urlNvmApiKey) {\n url.searchParams.delete('nvmApiKey')\n }\n\n const urlAccountAddress = url.searchParams.get('accountAddress') as string\n if (urlAccountAddress) {\n url.searchParams.delete('accountAddress')\n }\n\n history.replaceState(history.state, '', url.toString())\n\n return new Payments(options, true)\n }\n\n /**\n * Initializes the Payments class.\n *\n * @param options - The options to initialize the payments class.\n * @param isBrowserInstance - Whether this instance is for browser usage.\n */\n private constructor(options: PaymentOptions, isBrowserInstance = true) {\n super(options)\n\n this.isBrowserInstance = isBrowserInstance\n this.initializeApi(options)\n }\n\n /**\n * Initializes the AI Query Protocol API.\n */\n private initializeApi(options: PaymentOptions) {\n this.plans = PlansAPI.getInstance(options)\n this.agents = AgentsAPI.getInstance(options)\n this.requests = AgentRequestsAPI.getInstance(options)\n this.observability = ObservabilityAPI.getInstance(options)\n this.organizations = OrganizationsAPI.getInstance(options)\n this.query = AIQueryApi.getInstance()\n this.contracts = new ContractsAPI(options)\n this.facilitator = FacilitatorAPI.getInstance(options)\n this.x402 = X402TokenAPI.getInstance(options)\n }\n\n /**\n * Initiates the connect flow. The user's browser will be redirected to\n * the Nevermined App login page.\n *\n * @remarks\n * This is a browser-only function.\n * @example\n * ```\n * payments.connect()\n * ```\n */\n public connect() {\n if (!this.isBrowserInstance) return\n const url = new URL(`/login?returnUrl=${this.returnUrl}`, this.environment.frontend)\n window.location.href = url.toString()\n }\n\n /**\n * Logs out the user by removing the NVM API key.\n *\n * @remarks\n * This is a browser-only function.\n * @example\n * ```\n * payments.logout()\n * ```\n */\n public logout() {\n this.nvmApiKey = ''\n }\n\n /**\n * Pins (or clears) the active organization workspace used by every\n * subsequent authenticated request. The SDK forwards the choice as the\n * `X-Current-Org-Id` header so the backend scopes publications and\n * other org-aware queries to the requested organization.\n *\n * Pass `null` to clear the pin and let the backend fall back to the\n * API key's org tag or the caller's most-recent active membership.\n *\n * For one-off targeting (e.g. publish a single agent into Org B without\n * leaving Org B as the active workspace) prefer the per-call\n * `{ organizationId }` option on `agents.registerAgent` /\n * `plans.registerPlan` / similar.\n *\n * @param organizationId - Org ID to pin (e.g. `org-…`) or `null` to clear.\n * @example\n * ```ts\n * payments.setOrganizationId('org-abc123')\n * await payments.agents.registerAgent(metadata, api, [planId]) // lands in org-abc123\n * ```\n */\n public override setOrganizationId(organizationId: string | null): void {\n super.setOrganizationId(organizationId)\n this.plans?.setOrganizationId(organizationId)\n this.agents?.setOrganizationId(organizationId)\n this.requests?.setOrganizationId(organizationId)\n this.observability?.setOrganizationId(organizationId)\n this.organizations?.setOrganizationId(organizationId)\n this.contracts?.setOrganizationId(organizationId)\n this.facilitator?.setOrganizationId(organizationId)\n this.x402?.setOrganizationId(organizationId)\n // `_delegation` is lazy — the getter forwards `currentOrganizationId`\n // on first access, so only propagate to an already-built instance.\n // (Eagerly constructing it here would change the lazy contract.)\n this._delegation?.setOrganizationId(organizationId)\n }\n\n /**\n * Checks if a user is logged in.\n * @example\n * ```\n * payments.isLoggedIn\n * ```\n * @returns True if the user is logged in.\n */\n get isLoggedIn(): boolean {\n return this.nvmApiKey.length > 0\n }\n}\n"]}
package/dist/plans.d.ts CHANGED
@@ -24,7 +24,7 @@ export declare const getNonExpirableDurationConfig: () => PlanCreditsConfig;
24
24
  export declare const getFixedCreditsConfig: (creditsGranted: bigint, creditsPerRequest?: bigint) => PlanCreditsConfig;
25
25
  export declare const getDynamicCreditsConfig: (creditsGranted: bigint, minCreditsPerRequest?: bigint, maxCreditsPerRequest?: bigint) => PlanCreditsConfig;
26
26
  export declare const setRedemptionType: (creditsConfig: PlanCreditsConfig, redemptionType: PlanRedemptionType) => PlanCreditsConfig;
27
- export declare const setProofRequired: (creditsConfig: PlanCreditsConfig, proofRequired?: boolean) => PlanCreditsConfig;
27
+ export declare const setOnchainMirror: (creditsConfig: PlanCreditsConfig, onchainMirror?: boolean) => PlanCreditsConfig;
28
28
  /**
29
29
  * Build a pay-as-you-go price configuration.
30
30
  *
package/dist/plans.js CHANGED
@@ -72,7 +72,7 @@ export const getExpirableDurationConfig = (durationOfPlan) => {
72
72
  return {
73
73
  isRedemptionAmountFixed: false,
74
74
  redemptionType: PlanRedemptionType.ONLY_SUBSCRIBER,
75
- proofRequired: false,
75
+ onchainMirror: false,
76
76
  durationSecs: durationOfPlan,
77
77
  amount: 1n,
78
78
  minAmount: 1n,
@@ -86,7 +86,7 @@ export const getFixedCreditsConfig = (creditsGranted, creditsPerRequest = 1n) =>
86
86
  return {
87
87
  isRedemptionAmountFixed: true,
88
88
  redemptionType: PlanRedemptionType.ONLY_SUBSCRIBER,
89
- proofRequired: false,
89
+ onchainMirror: false,
90
90
  durationSecs: 0n,
91
91
  amount: creditsGranted,
92
92
  minAmount: creditsPerRequest,
@@ -97,7 +97,7 @@ export const getDynamicCreditsConfig = (creditsGranted, minCreditsPerRequest = 1
97
97
  return {
98
98
  isRedemptionAmountFixed: false,
99
99
  redemptionType: PlanRedemptionType.ONLY_SUBSCRIBER,
100
- proofRequired: false,
100
+ onchainMirror: false,
101
101
  durationSecs: 0n,
102
102
  amount: creditsGranted,
103
103
  minAmount: minCreditsPerRequest,
@@ -110,10 +110,10 @@ export const setRedemptionType = (creditsConfig, redemptionType) => {
110
110
  redemptionType,
111
111
  };
112
112
  };
113
- export const setProofRequired = (creditsConfig, proofRequired = true) => {
113
+ export const setOnchainMirror = (creditsConfig, onchainMirror = true) => {
114
114
  return {
115
115
  ...creditsConfig,
116
- proofRequired,
116
+ onchainMirror,
117
117
  };
118
118
  };
119
119
  /**
@@ -147,7 +147,7 @@ export const getPayAsYouGoCreditsConfig = () => {
147
147
  return {
148
148
  isRedemptionAmountFixed: false,
149
149
  redemptionType: PlanRedemptionType.ONLY_SUBSCRIBER,
150
- proofRequired: false,
150
+ onchainMirror: false,
151
151
  durationSecs: 0n,
152
152
  amount: 1n,
153
153
  minAmount: 1n,
package/dist/plans.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"plans.js","sourceRoot":"","sources":["../src/plans.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EACR,kBAAkB,EAGlB,kBAAkB,GACnB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAE9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAO,CAAA,CAAC,uBAAuB;AAC/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAQ,CAAA,CAAC,2BAA2B;AACrE,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAU,CAAA,CAAC,yEAAyE;AACtH,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAW,CAAA,CAAC,gCAAgC;AAE7E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,MAAc,EACd,QAAiB,EACjB,WAA8B,QAAQ,CAAC,GAAG,EACzB,EAAE;IACnB,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,oBAAoB,QAAQ,kCAAkC,CAAC,CAAA;IACjF,OAAO;QACL,YAAY,EAAE,WAAW;QACzB,OAAO,EAAE,CAAC,MAAM,CAAC;QACjB,SAAS,EAAE,CAAC,QAAQ,CAAC;QACrB,eAAe,EAAE,WAAW;QAC5B,aAAa,EAAE,WAAW;QAC1B,oBAAoB,EAAE,WAAW;QACjC,eAAe,EAAE,WAAW;QAC5B,QAAQ,EAAE,KAAK;QACf,QAAQ;KACT,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,MAAc,EACd,QAAiB,EACjB,eAAwB,WAAW,EAClB,EAAE;IACnB,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC;QAC9B,MAAM,I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GAAG,IAAI,EACD,EAAE;IACrB,OAAO;QACL,GAAG,aAAa;QAChB,aAAa;KACd,CAAA;AACH,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,MAAc,EACd,QAAiB,EACjB,eAAwB,WAAW,EACnC,eAAyB,EACR,EAAE;IACnB,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,oBAAoB,QAAQ,kCAAkC,CAAC,CAAA;IAEjF,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CACb,2HAA2H,CAC5H,CAAA;IACH,CAAC;IAED,OAAO;QACL,YAAY;QACZ,OAAO,EAAE,CAAC,MAAM,CAAC;QACjB,SAAS,EAAE,CAAC,QAAQ,CAAC;QACrB,eAAe,EAAE,WAAW;QAC5B,aAAa,EAAE,WAAW;QAC1B,oBAAoB,EAAE,WAAW;QACjC,eAAe;QACf,QAAQ,EAAE,IAAI;KACf,CAAA;AACH,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAsB,EAAE;IAChE,OAAO;QACL,uBAAuB,EAAE,KAAK;QAC9B,cAAc,EAAE,kBAAkB,CAAC,eAAe;QAClD,aAAa,EAAE,KAAK;QACpB,YAAY,EAAE,EAAE;QAChB,MAAM,EAAE,EAAE;QACV,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,EAAE;KACd,CAAA;AACH,CAAC,CAAA","sourcesContent":["import {\n Address,\n Currency,\n EURC_TOKEN_ADDRESS,\n PlanCreditsConfig,\n PlanPriceConfig,\n PlanRedemptionType,\n} from './common/types.js'\nimport { ZeroAddress } from './environments.js'\nimport { isEthereumAddress } from './utils.js'\n\nexport const ONE_DAY_DURATION = 86_400n // 24 * 60 * 60 seconds\nexport const ONE_WEEK_DURATION = 604_800n // 7 * 24 * 60 * 60 seconds\nexport const ONE_MONTH_DURATION = 2_629_746n // (365.25 days/year ÷ 12 months/year) × 24 × 60 × 60 ≈ 2,629,746 seconds\nexport const ONE_YEAR_DURATION = 31_557_600n // 365.25 * 24 * 60 * 60 seconds\n\nexport const getFiatPriceConfig = (\n amount: bigint,\n receiver: Address,\n currency: Currency | string = Currency.USD,\n): PlanPriceConfig => {\n if (!isEthereumAddress(receiver))\n throw new Error(`Receiver address ${receiver} is not a valid Ethereum address`)\n return {\n tokenAddress: ZeroAddress,\n amounts: [amount],\n receivers: [receiver],\n contractAddress: ZeroAddress,\n feeController: ZeroAddress,\n externalPriceAddress: ZeroAddress,\n templateAddress: ZeroAddress,\n isCrypto: false,\n currency,\n }\n}\n\nexport const getCryptoPriceConfig = (\n amount: bigint,\n receiver: Address,\n tokenAddress: Address = ZeroAddress,\n): PlanPriceConfig => {\n if (!isEthereumAddress(receiver))\n throw new Error(`Receiver address ${receiver} is not a valid Ethereum address`)\n return {\n tokenAddress,\n amounts: [amount],\n receivers: [receiver],\n contractAddress: ZeroAddress,\n feeController: ZeroAddress,\n externalPriceAddress: ZeroAddress,\n templateAddress: ZeroAddress,\n isCrypto: true,\n }\n}\n\nexport const getERC20PriceConfig = (\n amount: bigint,\n tokenAddress: Address,\n receiver: Address,\n): PlanPriceConfig => {\n return getCryptoPriceConfig(amount, receiver, tokenAddress)\n}\n\n/**\n * Builds a price configuration for EURC (Euro stablecoin) payments.\n *\n * EURC uses 6 decimal places. To charge €29.00, pass `29_000_000n`.\n *\n * @param amount - Amount in the token's smallest unit (6 decimals for EURC).\n * @param receiver - Wallet address that will receive the payment.\n * @param eurcAddress - Optional EURC token address. Defaults to Base Mainnet EURC.\n * @returns The PlanPriceConfig representing an EURC price.\n */\nexport const getEURCPriceConfig = (\n amount: bigint,\n receiver: Address,\n eurcAddress: Address = EURC_TOKEN_ADDRESS,\n): PlanPriceConfig => {\n return {\n ...getERC20PriceConfig(amount, eurcAddress, receiver),\n currency: Currency.EURC,\n }\n}\n\nexport const getFreePriceConfig = (): PlanPriceConfig => {\n return {\n tokenAddress: ZeroAddress,\n amounts: [],\n receivers: [],\n contractAddress: ZeroAddress,\n feeController: ZeroAddress,\n externalPriceAddress: ZeroAddress,\n templateAddress: ZeroAddress,\n isCrypto: true,\n }\n}\n\nexport const getNativeTokenPriceConfig = (amount: bigint, receiver: Address): PlanPriceConfig => {\n return getCryptoPriceConfig(amount, receiver, ZeroAddress)\n}\n\nexport const getExpirableDurationConfig = (durationOfPlan: bigint): PlanCreditsConfig => {\n return {\n isRedemptionAmountFixed: false,\n redemptionType: PlanRedemptionType.ONLY_SUBSCRIBER,\n proofRequired: false,\n durationSecs: durationOfPlan,\n amount: 1n,\n minAmount: 1n,\n maxAmount: 1n,\n }\n}\n\nexport const getNonExpirableDurationConfig = (): PlanCreditsConfig => {\n return getExpirableDurationConfig(0n)\n}\n\nexport const getFixedCreditsConfig = (\n creditsGranted: bigint,\n creditsPerRequest = 1n,\n): PlanCreditsConfig => {\n return {\n isRedemptionAmountFixed: true,\n redemptionType: PlanRedemptionType.ONLY_SUBSCRIBER,\n proofRequired: false,\n durationSecs: 0n,\n amount: creditsGranted,\n minAmount: creditsPerRequest,\n maxAmount: creditsPerRequest,\n }\n}\n\nexport const getDynamicCreditsConfig = (\n creditsGranted: bigint,\n minCreditsPerRequest = 1n,\n maxCreditsPerRequest = 1n,\n): PlanCreditsConfig => {\n return {\n isRedemptionAmountFixed: false,\n redemptionType: PlanRedemptionType.ONLY_SUBSCRIBER,\n proofRequired: false,\n durationSecs: 0n,\n amount: creditsGranted,\n minAmount: minCreditsPerRequest,\n maxAmount: maxCreditsPerRequest,\n }\n}\n\nexport const setRedemptionType = (\n creditsConfig: PlanCreditsConfig,\n redemptionType: PlanRedemptionType,\n): PlanCreditsConfig => {\n return {\n ...creditsConfig,\n redemptionType,\n }\n}\n\nexport const setProofRequired = (\n creditsConfig: PlanCreditsConfig,\n proofRequired = true,\n): PlanCreditsConfig => {\n return {\n ...creditsConfig,\n proofRequired,\n }\n}\n\n/**\n * Build a pay-as-you-go price configuration.\n *\n * For pay-as-you-go plans, the template address must come from the API deployment info.\n */\nexport const getPayAsYouGoPriceConfig = (\n amount: bigint,\n receiver: Address,\n tokenAddress: Address = ZeroAddress,\n templateAddress?: Address,\n): PlanPriceConfig => {\n if (!isEthereumAddress(receiver))\n throw new Error(`Receiver address ${receiver} is not a valid Ethereum address`)\n\n if (!templateAddress) {\n throw new Error(\n 'templateAddress is required. Use ContractsAPI.getPayAsYouGoTemplateAddress() or Payments.plans.getPayAsYouGoPriceConfig()',\n )\n }\n\n return {\n tokenAddress,\n amounts: [amount],\n receivers: [receiver],\n contractAddress: ZeroAddress,\n feeController: ZeroAddress,\n externalPriceAddress: ZeroAddress,\n templateAddress,\n isCrypto: true,\n }\n}\n\n/**\n * Build a pay-as-you-go credits configuration.\n *\n * Credits are not minted upfront; these values are required for validation only.\n */\nexport const getPayAsYouGoCreditsConfig = (): PlanCreditsConfig => {\n return {\n isRedemptionAmountFixed: false,\n redemptionType: PlanRedemptionType.ONLY_SUBSCRIBER,\n proofRequired: false,\n durationSecs: 0n,\n amount: 1n,\n minAmount: 1n,\n maxAmount: 1n,\n }\n}\n"]}
1
+ {"version":3,"file":"plans.js","sourceRoot":"","sources":["../src/plans.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EACR,kBAAkB,EAGlB,kBAAkB,GACnB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAE9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAO,CAAA,CAAC,uBAAuB;AAC/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAQ,CAAA,CAAC,2BAA2B;AACrE,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAU,CAAA,CAAC,yEAAyE;AACtH,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAW,CAAA,CAAC,gCAAgC;AAE7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,WAAW;QACjC,eAAe;QACf,QAAQ,EAAE,IAAI;KACf,CAAA;AACH,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAsB,EAAE;IAChE,OAAO;QACL,uBAAuB,EAAE,KAAK;QAC9B,cAAc,EAAE,kBAAkB,CAAC,eAAe;QAClD,aAAa,EAAE,KAAK;QACpB,YAAY,EAAE,EAAE;QAChB,MAAM,EAAE,EAAE;QACV,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,EAAE;KACd,CAAA;AACH,CAAC,CAAA","sourcesContent":["import {\n Address,\n Currency,\n EURC_TOKEN_ADDRESS,\n PlanCreditsConfig,\n PlanPriceConfig,\n PlanRedemptionType,\n} from './common/types.js'\nimport { ZeroAddress } from './environments.js'\nimport { isEthereumAddress } from './utils.js'\n\nexport const ONE_DAY_DURATION = 86_400n // 24 * 60 * 60 seconds\nexport const ONE_WEEK_DURATION = 604_800n // 7 * 24 * 60 * 60 seconds\nexport const ONE_MONTH_DURATION = 2_629_746n // (365.25 days/year ÷ 12 months/year) × 24 × 60 × 60 ≈ 2,629,746 seconds\nexport const ONE_YEAR_DURATION = 31_557_600n // 365.25 * 24 * 60 * 60 seconds\n\nexport const getFiatPriceConfig = (\n amount: bigint,\n receiver: Address,\n currency: Currency | string = Currency.USD,\n): PlanPriceConfig => {\n if (!isEthereumAddress(receiver))\n throw new Error(`Receiver address ${receiver} is not a valid Ethereum address`)\n return {\n tokenAddress: ZeroAddress,\n amounts: [amount],\n receivers: [receiver],\n contractAddress: ZeroAddress,\n feeController: ZeroAddress,\n externalPriceAddress: ZeroAddress,\n templateAddress: ZeroAddress,\n isCrypto: false,\n currency,\n }\n}\n\nexport const getCryptoPriceConfig = (\n amount: bigint,\n receiver: Address,\n tokenAddress: Address = ZeroAddress,\n): PlanPriceConfig => {\n if (!isEthereumAddress(receiver))\n throw new Error(`Receiver address ${receiver} is not a valid Ethereum address`)\n return {\n tokenAddress,\n amounts: [amount],\n receivers: [receiver],\n contractAddress: ZeroAddress,\n feeController: ZeroAddress,\n externalPriceAddress: ZeroAddress,\n templateAddress: ZeroAddress,\n isCrypto: true,\n }\n}\n\nexport const getERC20PriceConfig = (\n amount: bigint,\n tokenAddress: Address,\n receiver: Address,\n): PlanPriceConfig => {\n return getCryptoPriceConfig(amount, receiver, tokenAddress)\n}\n\n/**\n * Builds a price configuration for EURC (Euro stablecoin) payments.\n *\n * EURC uses 6 decimal places. To charge €29.00, pass `29_000_000n`.\n *\n * @param amount - Amount in the token's smallest unit (6 decimals for EURC).\n * @param receiver - Wallet address that will receive the payment.\n * @param eurcAddress - Optional EURC token address. Defaults to Base Mainnet EURC.\n * @returns The PlanPriceConfig representing an EURC price.\n */\nexport const getEURCPriceConfig = (\n amount: bigint,\n receiver: Address,\n eurcAddress: Address = EURC_TOKEN_ADDRESS,\n): PlanPriceConfig => {\n return {\n ...getERC20PriceConfig(amount, eurcAddress, receiver),\n currency: Currency.EURC,\n }\n}\n\nexport const getFreePriceConfig = (): PlanPriceConfig => {\n return {\n tokenAddress: ZeroAddress,\n amounts: [],\n receivers: [],\n contractAddress: ZeroAddress,\n feeController: ZeroAddress,\n externalPriceAddress: ZeroAddress,\n templateAddress: ZeroAddress,\n isCrypto: true,\n }\n}\n\nexport const getNativeTokenPriceConfig = (amount: bigint, receiver: Address): PlanPriceConfig => {\n return getCryptoPriceConfig(amount, receiver, ZeroAddress)\n}\n\nexport const getExpirableDurationConfig = (durationOfPlan: bigint): PlanCreditsConfig => {\n return {\n isRedemptionAmountFixed: false,\n redemptionType: PlanRedemptionType.ONLY_SUBSCRIBER,\n onchainMirror: false,\n durationSecs: durationOfPlan,\n amount: 1n,\n minAmount: 1n,\n maxAmount: 1n,\n }\n}\n\nexport const getNonExpirableDurationConfig = (): PlanCreditsConfig => {\n return getExpirableDurationConfig(0n)\n}\n\nexport const getFixedCreditsConfig = (\n creditsGranted: bigint,\n creditsPerRequest = 1n,\n): PlanCreditsConfig => {\n return {\n isRedemptionAmountFixed: true,\n redemptionType: PlanRedemptionType.ONLY_SUBSCRIBER,\n onchainMirror: false,\n durationSecs: 0n,\n amount: creditsGranted,\n minAmount: creditsPerRequest,\n maxAmount: creditsPerRequest,\n }\n}\n\nexport const getDynamicCreditsConfig = (\n creditsGranted: bigint,\n minCreditsPerRequest = 1n,\n maxCreditsPerRequest = 1n,\n): PlanCreditsConfig => {\n return {\n isRedemptionAmountFixed: false,\n redemptionType: PlanRedemptionType.ONLY_SUBSCRIBER,\n onchainMirror: false,\n durationSecs: 0n,\n amount: creditsGranted,\n minAmount: minCreditsPerRequest,\n maxAmount: maxCreditsPerRequest,\n }\n}\n\nexport const setRedemptionType = (\n creditsConfig: PlanCreditsConfig,\n redemptionType: PlanRedemptionType,\n): PlanCreditsConfig => {\n return {\n ...creditsConfig,\n redemptionType,\n }\n}\n\nexport const setOnchainMirror = (\n creditsConfig: PlanCreditsConfig,\n onchainMirror = true,\n): PlanCreditsConfig => {\n return {\n ...creditsConfig,\n onchainMirror,\n }\n}\n\n/**\n * Build a pay-as-you-go price configuration.\n *\n * For pay-as-you-go plans, the template address must come from the API deployment info.\n */\nexport const getPayAsYouGoPriceConfig = (\n amount: bigint,\n receiver: Address,\n tokenAddress: Address = ZeroAddress,\n templateAddress?: Address,\n): PlanPriceConfig => {\n if (!isEthereumAddress(receiver))\n throw new Error(`Receiver address ${receiver} is not a valid Ethereum address`)\n\n if (!templateAddress) {\n throw new Error(\n 'templateAddress is required. Use ContractsAPI.getPayAsYouGoTemplateAddress() or Payments.plans.getPayAsYouGoPriceConfig()',\n )\n }\n\n return {\n tokenAddress,\n amounts: [amount],\n receivers: [receiver],\n contractAddress: ZeroAddress,\n feeController: ZeroAddress,\n externalPriceAddress: ZeroAddress,\n templateAddress,\n isCrypto: true,\n }\n}\n\n/**\n * Build a pay-as-you-go credits configuration.\n *\n * Credits are not minted upfront; these values are required for validation only.\n */\nexport const getPayAsYouGoCreditsConfig = (): PlanCreditsConfig => {\n return {\n isRedemptionAmountFixed: false,\n redemptionType: PlanRedemptionType.ONLY_SUBSCRIBER,\n onchainMirror: false,\n durationSecs: 0n,\n amount: 1n,\n minAmount: 1n,\n maxAmount: 1n,\n }\n}\n"]}
@@ -6,17 +6,38 @@
6
6
  */
7
7
  import { BasePaymentsAPI } from '../api/base-payments.js';
8
8
  import { CreateDelegationPayload, CreateDelegationResponse, PaymentOptions } from '../common/types.js';
9
+ /**
10
+ * Card-delegation providers exposed by the SDK. Use this when you want to
11
+ * restrict to card-shape entries only (e.g., filtering the heterogeneous
12
+ * list returned by {@link DelegationAPI.listPaymentMethods}).
13
+ */
14
+ export type CardProvider = 'stripe' | 'braintree' | 'visa';
15
+ /**
16
+ * All delegation providers, including the crypto path. Matches the
17
+ * server-side union and aligns with {@link CreateDelegationPayload.provider}.
18
+ */
19
+ export type DelegationProvider = CardProvider | 'erc4337';
9
20
  /**
10
21
  * Summary of a user's enrolled payment method.
22
+ *
23
+ * The list returned by {@link DelegationAPI.listPaymentMethods} is
24
+ * heterogeneous: it includes enrolled cards (`provider` in
25
+ * `stripe` / `braintree` / `visa`) AND, when the user has a smart account
26
+ * configured, an entry for the user's ERC-4337 wallet
27
+ * (`provider: 'erc4337'`, `type: 'crypto_wallet'`, `brand: 'ethereum'`).
28
+ * Filter on `provider` when callers only want one shape.
11
29
  */
12
30
  export interface PaymentMethodSummary {
13
- /** Payment method ID (Stripe 'pm_...' or Braintree vault token) */
31
+ /** Payment method ID (Stripe 'pm_...', Braintree vault token, Visa Agentic
32
+ * token id, or — for the erc4337 entry — the smart-account address) */
14
33
  id: string;
15
- /** Payment method type (e.g., 'card', 'paypal') */
34
+ /** Payment method type ('card' | 'crypto_wallet' | 'paypal' | …) */
16
35
  type: string;
17
- /** Card brand (e.g., 'visa', 'mastercard') or payment method type ('paypal', 'venmo') */
36
+ /** Card brand (e.g., 'visa', 'mastercard'), 'ethereum' for the erc4337
37
+ * entry, or payment method type ('paypal', 'venmo') */
18
38
  brand: string;
19
- /** Last 4 digits (cards) or email/username (PayPal/Venmo) */
39
+ /** Last 4 digits (cards), trailing 4 chars of the wallet address
40
+ * (erc4337), or email/username (PayPal/Venmo) */
20
41
  last4: string;
21
42
  /** Expiration month (0 for non-card methods) */
22
43
  expMonth: number;
@@ -24,8 +45,8 @@ export interface PaymentMethodSummary {
24
45
  expYear: number;
25
46
  /** Human-readable alias, if set */
26
47
  alias?: string | null;
27
- /** Payment provider: 'stripe' or 'braintree' */
28
- provider?: string;
48
+ /** One of 'stripe' | 'braintree' | 'visa' | 'erc4337' */
49
+ provider?: DelegationProvider;
29
50
  /** Current status ('Active' or 'Revoked') */
30
51
  status?: string;
31
52
  /** NVM API Key IDs allowed to use this payment method, or null if unrestricted */
@@ -101,7 +122,13 @@ export declare class DelegationAPI extends BasePaymentsAPI {
101
122
  */
102
123
  getPurchasingPower(): Promise<PurchasingPower>;
103
124
  /**
104
- * Create a new delegation for either stripe or erc4337 provider.
125
+ * Create a new delegation for any supported provider (stripe, braintree,
126
+ * visa, or erc4337).
127
+ *
128
+ * Note: Visa delegations require a per-delegation device-binding ceremony
129
+ * (FIDO/passkey + assuranceData) that must be performed in the browser
130
+ * via the Nevermined webapp. The SDK can list and consume an already-
131
+ * created Visa delegation but cannot create one programmatically.
105
132
  *
106
133
  * @param payload - The delegation creation parameters
107
134
  * @returns The created delegation ID (and token for card delegations)
@@ -1 +1 @@
1
- {"version":3,"file":"delegation-api.d.ts","sourceRoot":"","sources":["../../src/x402/delegation-api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAEzD,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAEtG;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,mEAAmE;IACnE,EAAE,EAAE,MAAM,CAAA;IACV,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAA;IACZ,yFAAyF;IACzF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