@nevermined-io/payments 1.11.2 → 1.13.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 (66) hide show
  1. package/README.md +33 -0
  2. package/dist/a2a/clientRegistry.d.ts +10 -1
  3. package/dist/a2a/clientRegistry.d.ts.map +1 -1
  4. package/dist/a2a/clientRegistry.js +13 -4
  5. package/dist/a2a/clientRegistry.js.map +1 -1
  6. package/dist/a2a/paymentsClient.d.ts +60 -3
  7. package/dist/a2a/paymentsClient.d.ts.map +1 -1
  8. package/dist/a2a/paymentsClient.js +129 -8
  9. package/dist/a2a/paymentsClient.js.map +1 -1
  10. package/dist/a2a/types.d.ts +5 -0
  11. package/dist/a2a/types.d.ts.map +1 -1
  12. package/dist/a2a/types.js.map +1 -1
  13. package/dist/api/nvm-api.d.ts +2 -0
  14. package/dist/api/nvm-api.d.ts.map +1 -1
  15. package/dist/api/nvm-api.js +4 -0
  16. package/dist/api/nvm-api.js.map +1 -1
  17. package/dist/api/orders-api.d.ts +146 -0
  18. package/dist/api/orders-api.d.ts.map +1 -0
  19. package/dist/api/orders-api.js +107 -0
  20. package/dist/api/orders-api.js.map +1 -0
  21. package/dist/common/types.d.ts +87 -0
  22. package/dist/common/types.d.ts.map +1 -1
  23. package/dist/common/types.js.map +1 -1
  24. package/dist/index.d.ts +4 -1
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +2 -0
  27. package/dist/index.js.map +1 -1
  28. package/dist/mcp/core/paywall.d.ts.map +1 -1
  29. package/dist/mcp/core/paywall.js +10 -0
  30. package/dist/mcp/core/paywall.js.map +1 -1
  31. package/dist/mpp/fetch.d.ts +8 -3
  32. package/dist/mpp/fetch.d.ts.map +1 -1
  33. package/dist/mpp/fetch.js +6 -0
  34. package/dist/mpp/fetch.js.map +1 -1
  35. package/dist/mpp/mpp-api.d.ts +11 -5
  36. package/dist/mpp/mpp-api.d.ts.map +1 -1
  37. package/dist/mpp/mpp-api.js +10 -3
  38. package/dist/mpp/mpp-api.js.map +1 -1
  39. package/dist/payments.d.ts +3 -0
  40. package/dist/payments.d.ts.map +1 -1
  41. package/dist/payments.js +4 -0
  42. package/dist/payments.js.map +1 -1
  43. package/dist/x402/express/middleware.d.ts.map +1 -1
  44. package/dist/x402/express/middleware.js +98 -1
  45. package/dist/x402/express/middleware.js.map +1 -1
  46. package/dist/x402/facilitator-api.d.ts +90 -7
  47. package/dist/x402/facilitator-api.d.ts.map +1 -1
  48. package/dist/x402/facilitator-api.js +64 -3
  49. package/dist/x402/facilitator-api.js.map +1 -1
  50. package/dist/x402/index.d.ts +3 -2
  51. package/dist/x402/index.d.ts.map +1 -1
  52. package/dist/x402/index.js +1 -0
  53. package/dist/x402/index.js.map +1 -1
  54. package/dist/x402/token-request.d.ts +8 -0
  55. package/dist/x402/token-request.d.ts.map +1 -1
  56. package/dist/x402/token-request.js +101 -1
  57. package/dist/x402/token-request.js.map +1 -1
  58. package/dist/x402/token-version.d.ts +97 -0
  59. package/dist/x402/token-version.d.ts.map +1 -0
  60. package/dist/x402/token-version.js +127 -0
  61. package/dist/x402/token-version.js.map +1 -0
  62. package/dist/x402/token.d.ts +33 -2
  63. package/dist/x402/token.d.ts.map +1 -1
  64. package/dist/x402/token.js +47 -2
  65. package/dist/x402/token.js.map +1 -1
  66. package/package.json +1 -1
@@ -0,0 +1,107 @@
1
+ import { safeParseJson } from '../common/helper.js';
2
+ import { PaymentsError } from '../common/payments.error.js';
3
+ import { BasePaymentsAPI } from './base-payments.js';
4
+ import { API_URL_CREATE_ORDER, API_URL_GET_ORDER } from './nvm-api.js';
5
+ /**
6
+ * The OrdersAPI class wraps the browser-fiat Orders endpoints. An Order is a
7
+ * merchant-initiated, off-plan charge for an arbitrary amount (the Stripe
8
+ * PaymentIntent analog) that the buyer's browser confirms client-side — no
9
+ * plan, no buyer Nevermined account, no delegation.
10
+ *
11
+ * @remarks
12
+ * `createOrder` requires an **organization-scoped** NVM API key: the API reads
13
+ * the merchant organization from the key's own org tag, so a personal key is
14
+ * refused with `BCK.ORDER.0003`. `Payments.setOrganizationId` (the
15
+ * `X-Current-Org-Id` header) does not substitute for an org-scoped key.
16
+ *
17
+ * This client is the merchant's: a `Payments` instance is always constructed
18
+ * with an NVM API key. The buyer never needs one — the buyer's browser confirms
19
+ * the `clientSecret` with Stripe.js and can poll `GET /api/v1/orders/:id`
20
+ * directly, which is why {@link OrdersAPI.getOrder} sends no key on that call.
21
+ *
22
+ * @see nvm-monorepo `apps/api/src/orders/README.md` (epic #3238)
23
+ */
24
+ export class OrdersAPI extends BasePaymentsAPI {
25
+ static getInstance(options) {
26
+ return new OrdersAPI(options);
27
+ }
28
+ /**
29
+ * Creates an Order and its PaymentIntent, returning the `clientSecret` a
30
+ * browser confirms against (`POST /api/v1/orders`).
31
+ *
32
+ * @remarks
33
+ * This method is oriented to merchants. The NVM API Key must be scoped to an
34
+ * active organization whose Stripe Connect account can receive card payments.
35
+ *
36
+ * @param options - @see {@link CreateOrderOptions}. `currency` defaults to `'usd'`.
37
+ * @returns The new Order id, its status and — while payable — the `clientSecret`.
38
+ * @throws PaymentsError carrying the backend catalogue code: `BCK.ORDER.0001`
39
+ * (invalid request), `BCK.ORDER.0003` (not an active organization / over the
40
+ * per-order cap), `BCK.ORDER.0007` (idempotency-key conflict),
41
+ * `BCK.ORDER.0010` (velocity cap — retryable), `BCK.ORDER.0004`/`0005`
42
+ * (Connect account / PaymentIntent failure, no money moved). A refusal
43
+ * without a catalogue code (e.g. a gateway or throttle response) carries
44
+ * `http_<status>` instead.
45
+ * @example
46
+ * ```
47
+ * const { orderId, clientSecret } = await payments.orders.createOrder({
48
+ * amountMinor: 3437, // $34.37
49
+ * description: 'Cart checkout — 3 items',
50
+ * idempotencyKey: 'merchant-order-4821',
51
+ * })
52
+ * ```
53
+ */
54
+ async createOrder(options) {
55
+ const body = { ...options, currency: options.currency ?? 'usd' };
56
+ const url = new URL(API_URL_CREATE_ORDER, this.environment.backend);
57
+ const response = await fetch(url, this.getBackendHTTPOptions('POST', body));
58
+ if (!response.ok) {
59
+ throw PaymentsError.fromBackend('Unable to create order', await backendError(response));
60
+ }
61
+ return response.json();
62
+ }
63
+ /**
64
+ * Reads the buyer-safe view of an Order by id (`GET /api/v1/orders/:id`).
65
+ *
66
+ * @remarks
67
+ * The endpoint is anonymous — the unguessable id is the sole access control —
68
+ * so this call sends no API key (the `Payments` instance still needs one to
69
+ * be constructed). The response never includes the merchant identity or the
70
+ * fee, and carries `clientSecret` only while the Order is payable.
71
+ *
72
+ * @param orderId - The unguessable Order id returned by {@link createOrder}.
73
+ * @returns @see {@link Order}
74
+ * @throws PaymentsError with code `BCK.ORDER.0002` when no Order has this id.
75
+ * The read endpoint is rate-limited — all anonymous callers behind one IP
76
+ * share a bucket of 60 requests per minute — and a throttled call carries
77
+ * no catalogue code, so it surfaces as code `http_429`. That is distinct
78
+ * from the create-side velocity cap `BCK.ORDER.0010`; poll sparingly and
79
+ * back off on `http_429`.
80
+ * @example
81
+ * ```
82
+ * const order = await payments.orders.getOrder(orderId)
83
+ * if (order.status === 'paid') fulfil(order)
84
+ * ```
85
+ */
86
+ async getOrder(orderId) {
87
+ const query = API_URL_GET_ORDER.replace(':orderId', encodeURIComponent(orderId));
88
+ const url = new URL(query, this.environment.backend);
89
+ const response = await fetch(url, this.getPublicHTTPOptions('GET'));
90
+ if (!response.ok) {
91
+ throw PaymentsError.fromBackend('Unable to get order', await backendError(response));
92
+ }
93
+ return response.json();
94
+ }
95
+ }
96
+ /**
97
+ * Backend error envelope with an `http_<status>` fallback `code`, so a refusal
98
+ * that is not an `NVMException` (the read endpoint's throttle is a Nest
99
+ * `ThrottlerException` with no `code`) is still branchable by callers instead
100
+ * of collapsing to the generic `payments_error`. A catalogue `code` in the body
101
+ * always wins. Same convention as the Python SDK's `PaymentsError.from_response`.
102
+ */
103
+ async function backendError(response) {
104
+ const body = (await safeParseJson(response));
105
+ return { code: `http_${response.status}`, ...body };
106
+ }
107
+ //# s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UAAU,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAA;QAChF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QACpD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAA;QACnE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,aAAa,CAAC,WAAW,CAAC,qBAAqB,EAAE,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAA;QACtF,CAAC;QACD,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;IACxB,CAAC;CACF;AAED;;;;;;GAMG;AACH,KAAK,UAAU,YAAY,CAAC,QAAkB;IAC5C,MAAM,IAAI,GAAG,CAAC,MAAM,aAAa,CAAC,QAAQ,CAAC,CAA4B,CAAA;IACvE,OAAO,EAAE,IAAI,EAAE,QAAQ,QAAQ,CAAC,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE,CAAA;AACrD,CAAC","sourcesContent":["import { safeParseJson } from '../common/helper.js'\nimport { PaymentsError } from '../common/payments.error.js'\nimport { PaymentOptions } from '../common/types.js'\nimport { BasePaymentsAPI } from './base-payments.js'\nimport { API_URL_CREATE_ORDER, API_URL_GET_ORDER } from './nvm-api.js'\n\n/**\n * Buyer-facing lifecycle status of an Order, as published on the wire by the\n * Nevermined API (`WireOrderStatus` in nvm-monorepo\n * `apps/api/src/orders/order-status.ts`).\n */\nexport type OrderStatus =\n | 'requires_payment'\n | 'paid'\n | 'refunded'\n | 'partially_refunded'\n | 'disputed'\n | 'failed'\n\n/**\n * Body of `POST /api/v1/orders` (`RegisterOrderDto`). The authenticated\n * merchant key sets the price; the seller's Stripe Connect account is\n * resolved server-side and is deliberately NOT part of this contract.\n */\nexport interface CreateOrderOptions {\n /**\n * Charge amount in USD cents (at least `100`, i.e. $1.00). The API validates\n * the upper bound (`BCK.ORDER.0001`); a deployment may enforce a lower\n * per-order cap (`BCK.ORDER.0003`).\n */\n amountMinor: number\n /** ISO currency, lower-cased. Phase 1 is USD-only; defaults to `'usd'`. */\n currency?: 'usd'\n /** Human-readable description of the charge (max 1024 chars). */\n description?: string\n /** Opaque merchant-supplied buyer reference, e.g. the merchant's own order id (max 255 chars). */\n buyerRef?: string\n /**\n * Idempotency key (max 255 chars). A retry with the same key returns the\n * original Order unchanged (and its `clientSecret` while the Order is still\n * payable); the other fields of the retry are ignored, not merged. A retry\n * with a different `amountMinor` or `currency` is refused with `BCK.ORDER.0007`.\n */\n idempotencyKey?: string\n /** Cart line items — merchant-defined structure, recorded verbatim (keys are not transformed), opaque to the API. */\n lineItems?: Array<Record<string, unknown>>\n /** Merchant-defined metadata, recorded verbatim (keys are not transformed), opaque to the API. */\n metadata?: Record<string, unknown>\n /** Stripe capture mode. Phase 1 supports `'automatic'` only (the default). */\n captureMode?: 'automatic'\n /** Payment Service Provider that settles the Order. Phase 1 implements `'stripe'` only (the default). */\n paymentProvider?: 'stripe'\n}\n\n/** Response of `POST /api/v1/orders` (`CreateOrderResponseDto`). */\nexport interface CreateOrderResult {\n /** Unguessable Order id — the buyer-facing access control for {@link OrdersAPI.getOrder}. */\n orderId: string\n status: OrderStatus\n /** Stripe PaymentIntent client secret the browser confirms against. Present only while the Order is payable. */\n clientSecret?: string\n}\n\n/**\n * Buyer-safe view of an Order (`OrderResponseDto`). It never carries the\n * merchant identity, the Connect account or the fee breakdown.\n */\nexport interface Order {\n /** Unguessable Order id. */\n id: string\n /** Charge amount in USD cents. */\n amountMinor: number\n currency: string\n status: OrderStatus\n /** Total refunded so far, in cents. */\n amountRefundedMinor: number\n description: string | null\n buyerRef: string | null\n /** The Stripe PaymentIntent backing this Order; `null` until it is created. */\n paymentIntentId: string | null\n /** ISO-8601 instant when the Order stops being payable; `null` if it never expires. */\n expiresAt: string | null\n /** Present only while the Order is payable. */\n clientSecret?: string\n}\n\n/**\n * The OrdersAPI class wraps the browser-fiat Orders endpoints. An Order is a\n * merchant-initiated, off-plan charge for an arbitrary amount (the Stripe\n * PaymentIntent analog) that the buyer's browser confirms client-side — no\n * plan, no buyer Nevermined account, no delegation.\n *\n * @remarks\n * `createOrder` requires an **organization-scoped** NVM API key: the API reads\n * the merchant organization from the key's own org tag, so a personal key is\n * refused with `BCK.ORDER.0003`. `Payments.setOrganizationId` (the\n * `X-Current-Org-Id` header) does not substitute for an org-scoped key.\n *\n * This client is the merchant's: a `Payments` instance is always constructed\n * with an NVM API key. The buyer never needs one — the buyer's browser confirms\n * the `clientSecret` with Stripe.js and can poll `GET /api/v1/orders/:id`\n * directly, which is why {@link OrdersAPI.getOrder} sends no key on that call.\n *\n * @see nvm-monorepo `apps/api/src/orders/README.md` (epic #3238)\n */\nexport class OrdersAPI extends BasePaymentsAPI {\n static getInstance(options: PaymentOptions): OrdersAPI {\n return new OrdersAPI(options)\n }\n\n /**\n * Creates an Order and its PaymentIntent, returning the `clientSecret` a\n * browser confirms against (`POST /api/v1/orders`).\n *\n * @remarks\n * This method is oriented to merchants. The NVM API Key must be scoped to an\n * active organization whose Stripe Connect account can receive card payments.\n *\n * @param options - @see {@link CreateOrderOptions}. `currency` defaults to `'usd'`.\n * @returns The new Order id, its status and — while payable — the `clientSecret`.\n * @throws PaymentsError carrying the backend catalogue code: `BCK.ORDER.0001`\n * (invalid request), `BCK.ORDER.0003` (not an active organization / over the\n * per-order cap), `BCK.ORDER.0007` (idempotency-key conflict),\n * `BCK.ORDER.0010` (velocity cap — retryable), `BCK.ORDER.0004`/`0005`\n * (Connect account / PaymentIntent failure, no money moved). A refusal\n * without a catalogue code (e.g. a gateway or throttle response) carries\n * `http_<status>` instead.\n * @example\n * ```\n * const { orderId, clientSecret } = await payments.orders.createOrder({\n * amountMinor: 3437, // $34.37\n * description: 'Cart checkout — 3 items',\n * idempotencyKey: 'merchant-order-4821',\n * })\n * ```\n */\n public async createOrder(options: CreateOrderOptions): Promise<CreateOrderResult> {\n const body = { ...options, currency: options.currency ?? 'usd' }\n const url = new URL(API_URL_CREATE_ORDER, this.environment.backend)\n const response = await fetch(url, this.getBackendHTTPOptions('POST', body))\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to create order', await backendError(response))\n }\n return response.json()\n }\n\n /**\n * Reads the buyer-safe view of an Order by id (`GET /api/v1/orders/:id`).\n *\n * @remarks\n * The endpoint is anonymous — the unguessable id is the sole access control —\n * so this call sends no API key (the `Payments` instance still needs one to\n * be constructed). The response never includes the merchant identity or the\n * fee, and carries `clientSecret` only while the Order is payable.\n *\n * @param orderId - The unguessable Order id returned by {@link createOrder}.\n * @returns @see {@link Order}\n * @throws PaymentsError with code `BCK.ORDER.0002` when no Order has this id.\n * The read endpoint is rate-limited — all anonymous callers behind one IP\n * share a bucket of 60 requests per minute — and a throttled call carries\n * no catalogue code, so it surfaces as code `http_429`. That is distinct\n * from the create-side velocity cap `BCK.ORDER.0010`; poll sparingly and\n * back off on `http_429`.\n * @example\n * ```\n * const order = await payments.orders.getOrder(orderId)\n * if (order.status === 'paid') fulfil(order)\n * ```\n */\n public async getOrder(orderId: string): Promise<Order> {\n const query = API_URL_GET_ORDER.replace(':orderId', encodeURIComponent(orderId))\n const url = new URL(query, this.environment.backend)\n const response = await fetch(url, this.getPublicHTTPOptions('GET'))\n if (!response.ok) {\n throw PaymentsError.fromBackend('Unable to get order', await backendError(response))\n }\n return response.json()\n }\n}\n\n/**\n * Backend error envelope with an `http_<status>` fallback `code`, so a refusal\n * that is not an `NVMException` (the read endpoint's throttle is a Nest\n * `ThrottlerException` with no `code`) is still branchable by callers instead\n * of collapsing to the generic `payments_error`. A catalogue `code` in the body\n * always wins. Same convention as the Python SDK's `PaymentsError.from_response`.\n */\nasync function backendError(response: Response): Promise<Record<string, unknown>> {\n const body = (await safeParseJson(response)) as Record<string, unknown>\n return { code: `http_${response.status}`, ...body }\n}\n"]}
@@ -570,6 +570,65 @@ export interface CreateDelegationResponse {
570
570
  /** Delegation UUID */
571
571
  delegationId: string;
572
572
  }
573
+ /**
574
+ * The protected resource a token is minted for.
575
+ *
576
+ * Load-bearing from token v3 on: `url` is inside the EIP-712 signature, so a
577
+ * v3 token only settles against the seller endpoint it names.
578
+ *
579
+ * Outside the v1/v2 signature, which covers `from` / `sessionKeysProvider` /
580
+ * `sessionKeys` / `planId` only — but **not** inert there: the backend compares
581
+ * this URL against the one the seller advertises in its `paymentRequired`
582
+ * (origin + path; an exact string comparison when either side is not a
583
+ * parseable URL) for **any** token that carries a resource. Binding a token to
584
+ * a URL the seller does not advertise verbatim therefore fails verification
585
+ * with `BCK.X402.0013`. Sellers built on this SDK's `paymentMiddleware`
586
+ * advertise `req.originalUrl` — a **relative** path — so for such a seller bind
587
+ * to that string, not to the absolute URL you fetch. See {@link
588
+ * X402TokenResource.url} for a seller that advertises the absolute form, which
589
+ * this SDK's own A2A server does.
590
+ */
591
+ export interface X402TokenResource {
592
+ /**
593
+ * The protected resource URL, **as the seller advertises it** — e.g.
594
+ * `/api/v1/tasks` from a `paymentMiddleware` seller, or the absolute
595
+ * `https://seller.example/api/v1/tasks` from one that advertises it that way
596
+ * (this SDK's A2A server does).
597
+ */
598
+ url: string;
599
+ /** Human-readable description. */
600
+ description?: string;
601
+ /** Expected response MIME type (e.g. `application/json`). */
602
+ mimeType?: string;
603
+ }
604
+ /**
605
+ * EIP-712 struct version the backend signs the access token under.
606
+ *
607
+ * - `2` — today's default: reusable bearer token, signature covers
608
+ * `[from, sessionKeysProvider, sessionKeys, planId]`.
609
+ * - `3` — appends `agentId`, `resourceUrl`, `httpVerb` and a one-time `nonce`
610
+ * to the signed struct, making the token seller/resource-bound and
611
+ * **single-use**: it is consumed on the first `POST /x402/settle`.
612
+ *
613
+ * Opt-in. Never assume the token you got back is the version you asked for —
614
+ * a backend that predates the v3 struct silently drops the field (its
615
+ * `ValidationPipe` whitelists without `forbidNonWhitelisted`) and mints v2.
616
+ * Read the version off the token with {@link detectAccessTokenVersion}.
617
+ */
618
+ export type X402TokenVersion = 2 | 3;
619
+ /**
620
+ * Options accepted by the MPP token mint: everything {@link X402TokenOptions}
621
+ * takes except `tokenVersion`.
622
+ *
623
+ * MPP and x402 stopped sharing a token version ladder (nvm-monorepo#3266). MPP
624
+ * signs one struct and names no version for it, because its single-use unit is
625
+ * the **challenge**, not the token — one MPP access token is presented across
626
+ * many challenges by design, so an x402 v3 per-token nonce would reject every
627
+ * buyer's second challenge. The backend refuses ANY `tokenVersion` on an MPP
628
+ * mint with `BCK.MPP.0007`, `2` included, so the field is omitted from the type
629
+ * rather than accepted and ignored.
630
+ */
631
+ export type MppTokenOptions = Omit<X402TokenOptions, 'tokenVersion'>;
573
632
  /**
574
633
  * Options for x402 token generation that control scheme and delegation behavior.
575
634
  */
@@ -580,5 +639,33 @@ export interface X402TokenOptions {
580
639
  network?: string;
581
640
  /** Delegation configuration for both erc4337 and card-delegation schemes */
582
641
  delegationConfig?: DelegationConfig;
642
+ /**
643
+ * The protected resource the token is minted for. Signed into a v3 token,
644
+ * which then only settles against this URL. Without it the backend has
645
+ * nothing to bind to and skips endpoint validation, so `tokenVersion: 3`
646
+ * alone yields a single-use token bound to nothing — a supported mode, but
647
+ * not the seller binding.
648
+ *
649
+ * Must be the **exact string the seller advertises**; see
650
+ * {@link X402TokenResource}. Supplying it without `tokenVersion: 3` is
651
+ * **refused**: only a v3 signature covers the binding, while the resource
652
+ * still arms the backend's endpoint allowlist and is compared against what
653
+ * the seller advertises — so it can only cost you a `BCK.PROTOCOL.0031` or a
654
+ * `BCK.X402.0013`.
655
+ */
656
+ resource?: X402TokenResource;
657
+ /**
658
+ * HTTP verb of the protected resource (e.g. `POST`). Signed into a v3 token
659
+ * alongside {@link X402TokenOptions.resource}, and compared against the verb
660
+ * the seller advertises. Upper-cased by the SDK before it is sent, so
661
+ * `'post'` and `'POST'` are equivalent.
662
+ */
663
+ httpVerb?: string;
664
+ /**
665
+ * Request a specific EIP-712 token version. Omitted means the backend
666
+ * default (currently `2`). Requesting `3` is a request, not a guarantee —
667
+ * always read the version back off the minted token.
668
+ */
669
+ tokenVersion?: X402TokenVersion;
583
670
  }
584
671
  //# sourceMappingURL=types.d.ts.map
@@ -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;;;;;;;;;OASG;IACH,WAAW,CAAC,EAAE,eAAe,CAAA;IAE7B;;;;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;CACxB;AAED,MAAM,WAAW,QAAQ;IACvB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,CAAC,CAAA;IACR,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,OAAO,GAAG,KAAK,MAAM,EAAE,CAAA;AAEnC;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB;;OAEG;IACH,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;OAG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AAC;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"]}
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,KAA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a,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 * The protected resource a token is minted for.\n *\n * Load-bearing from token v3 on: `url` is inside the EIP-712 signature, so a\n * v3 token only settles against the seller endpoint it names.\n *\n * Outside the v1/v2 signature, which covers `from` / `sessionKeysProvider` /\n * `sessionKeys` / `planId` only — but **not** inert there: the backend compares\n * this URL against the one the seller advertises in its `paymentRequired`\n * (origin + path; an exact string comparison when either side is not a\n * parseable URL) for **any** token that carries a resource. Binding a token to\n * a URL the seller does not advertise verbatim therefore fails verification\n * with `BCK.X402.0013`. Sellers built on this SDK's `paymentMiddleware`\n * advertise `req.originalUrl` — a **relative** path — so for such a seller bind\n * to that string, not to the absolute URL you fetch. See {@link\n * X402TokenResource.url} for a seller that advertises the absolute form, which\n * this SDK's own A2A server does.\n */\nexport interface X402TokenResource {\n /**\n * The protected resource URL, **as the seller advertises it** — e.g.\n * `/api/v1/tasks` from a `paymentMiddleware` seller, or the absolute\n * `https://seller.example/api/v1/tasks` from one that advertises it that way\n * (this SDK's A2A server does).\n */\n url: string\n /** Human-readable description. */\n description?: string\n /** Expected response MIME type (e.g. `application/json`). */\n mimeType?: string\n}\n\n/**\n * EIP-712 struct version the backend signs the access token under.\n *\n * - `2` — today's default: reusable bearer token, signature covers\n * `[from, sessionKeysProvider, sessionKeys, planId]`.\n * - `3` — appends `agentId`, `resourceUrl`, `httpVerb` and a one-time `nonce`\n * to the signed struct, making the token seller/resource-bound and\n * **single-use**: it is consumed on the first `POST /x402/settle`.\n *\n * Opt-in. Never assume the token you got back is the version you asked for —\n * a backend that predates the v3 struct silently drops the field (its\n * `ValidationPipe` whitelists without `forbidNonWhitelisted`) and mints v2.\n * Read the version off the token with {@link detectAccessTokenVersion}.\n */\nexport type X402TokenVersion = 2 | 3\n\n/**\n * Options accepted by the MPP token mint: everything {@link X402TokenOptions}\n * takes except `tokenVersion`.\n *\n * MPP and x402 stopped sharing a token version ladder (nvm-monorepo#3266). MPP\n * signs one struct and names no version for it, because its single-use unit is\n * the **challenge**, not the token — one MPP access token is presented across\n * many challenges by design, so an x402 v3 per-token nonce would reject every\n * buyer's second challenge. The backend refuses ANY `tokenVersion` on an MPP\n * mint with `BCK.MPP.0007`, `2` included, so the field is omitted from the type\n * rather than accepted and ignored.\n */\nexport type MppTokenOptions = Omit<X402TokenOptions, 'tokenVersion'>\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 * The protected resource the token is minted for. Signed into a v3 token,\n * which then only settles against this URL. Without it the backend has\n * nothing to bind to and skips endpoint validation, so `tokenVersion: 3`\n * alone yields a single-use token bound to nothing — a supported mode, but\n * not the seller binding.\n *\n * Must be the **exact string the seller advertises**; see\n * {@link X402TokenResource}. Supplying it without `tokenVersion: 3` is\n * **refused**: only a v3 signature covers the binding, while the resource\n * still arms the backend's endpoint allowlist and is compared against what\n * the seller advertises — so it can only cost you a `BCK.PROTOCOL.0031` or a\n * `BCK.X402.0013`.\n */\n resource?: X402TokenResource\n /**\n * HTTP verb of the protected resource (e.g. `POST`). Signed into a v3 token\n * alongside {@link X402TokenOptions.resource}, and compared against the verb\n * the seller advertises. Upper-cased by the SDK before it is sent, so\n * `'post'` and `'POST'` are equivalent.\n */\n httpVerb?: string\n /**\n * Request a specific EIP-712 token version. Omitted means the backend\n * default (currently `2`). Requesting `3` is a request, not a guarantee —\n * always read the version back off the minted token.\n */\n tokenVersion?: X402TokenVersion\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -12,12 +12,15 @@ export { ContractsAPI } from './api/contracts-api.js';
12
12
  export { CURRENT_ORG_ID_HEADER } from './api/base-payments.js';
13
13
  export type { PublicationOptions } from './api/base-payments.js';
14
14
  export { OrganizationsAPI } from './api/organizations-api/organizations-api.js';
15
+ export { OrdersAPI } from './api/orders-api.js';
16
+ export type { CreateOrderOptions, CreateOrderResult, Order, OrderStatus } from './api/orders-api.js';
15
17
  export { OrganizationMemberRole, OrganizationType, OrganizationActivityEventType, } from './api/organizations-api/types.js';
16
18
  export type { MyMembership, OrganizationActivityEvent, OrganizationActivityFilters, OrganizationActivityPage, } from './api/organizations-api/types.js';
17
19
  export { buildPaymentRequired, resolveNetwork, resolveScheme } from './x402/facilitator-api.js';
20
+ export { detectAccessTokenVersion, isSingleUseAccessToken, isAccessTokenAlreadyUsed, X402_TOKEN_ALREADY_USED_CODE, } from './x402/token-version.js';
18
21
  export { DelegationAPI } from './x402/delegation-api.js';
19
22
  export type { PaymentMethodSummary, UpdatePaymentMethodDto, DelegationSummary, DelegationListResponse, PurchasingPower, ListOptions, } from './x402/delegation-api.js';
20
- export type { X402PaymentRequired, X402PaymentAccepted, X402Resource, X402Scheme, X402SchemeExtra, VerifyPermissionsParams, VerifyPermissionsResult, SettlePermissionsParams, SettlePermissionsResult, } from './x402/facilitator-api.js';
23
+ export type { X402PaymentRequired, X402PaymentAccepted, X402Resource, X402Scheme, X402SchemeExtra, VerifyPermissionsParams, VerifyPermissionsResult, SettlePermissionsParams, SettlePermissionsResult, X402BillingModel, } from './x402/facilitator-api.js';
21
24
  export * from './mpp/index.js';
22
25
  export type { CreditsContext, CreditsOption, PaywallOptions, McpConfig, PaywallContext, AuthResult, } from './mcp/types/paywall.types.js';
23
26
  export type { OAuthUrls, OAuthConfig, HttpRouterConfig, HttpServerConfig, HttpServerResult, } from './mcp/types/http.types.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,YAAY,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAA;AAC/E,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,6BAA6B,GAC9B,MAAM,kCAAkC,CAAA;AACzC,YAAY,EACV,YAAY,EACZ,yBAAyB,EACzB,2BAA2B,EAC3B,wBAAwB,GACzB,MAAM,kCAAkC,CAAA;AAGzC,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;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"}
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,C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B,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
@@ -10,9 +10,11 @@ export * from './api/observability-api/observability-api.js';
10
10
  export { ContractsAPI } from './api/contracts-api.js';
11
11
  export { CURRENT_ORG_ID_HEADER } from './api/base-payments.js';
12
12
  export { OrganizationsAPI } from './api/organizations-api/organizations-api.js';
13
+ export { OrdersAPI } from './api/orders-api.js';
13
14
  export { OrganizationMemberRole, OrganizationType, OrganizationActivityEventType, } from './api/organizations-api/types.js';
14
15
  // x402 utilities and types
15
16
  export { buildPaymentRequired, resolveNetwork, resolveScheme } from './x402/facilitator-api.js';
17
+ export { detectAccessTokenVersion, isSingleUseAccessToken, isAccessTokenAlreadyUsed, X402_TOKEN_ALREADY_USED_CODE, } from './x402/token-version.js';
16
18
  export { DelegationAPI } from './x402/delegation-api.js';
17
19
  // MPP (Machine Payments Protocol) public surface
18
20
  export * from './mpp/index.js';
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;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
+ {"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,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAE/C,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,EACL,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAsBxD,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 { OrdersAPI } from './api/orders-api.js'\nexport type { CreateOrderOptions, CreateOrderResult, Order, OrderStatus } from './api/orders-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 {\n detectAccessTokenVersion,\n isSingleUseAccessToken,\n isAccessTokenAlreadyUsed,\n X402_TOKEN_ALREADY_USED_CODE,\n} from './x402/token-version.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 X402BillingModel,\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":"paywall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G,GAAG,EACvB,OAAO,EAAE,eAAe,GACvB,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC;IAKxF;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAmL5B;;;;OAIG;IACH,OAAO,CAAC,4BAA4B;IAYpC;;OAEG;YACW,aAAa;CAyE5B"}
@@ -133,10 +133,16 @@ export class PaywallDecorator {
133
133
  ...(creditsResult && { [X402_PAYMENT_RESPONSE_META_KEY]: creditsResult }),
134
134
  [NEVERMINED_CREDITS_META_KEY]: {
135
135
  ...(creditsResult?.transaction && { txHash: creditsResult.transaction }),
136
+ // `creditsRedeemed` is meaningless without this: a pay-as-you-go plan
137
+ // holds no balance, so it reads '0' on a settle that DID charge the
138
+ // buyer. Omitted (not '') when the settle carried no discriminator,
139
+ // so a consumer can tell "absent" from "present and empty".
140
+ ...(creditsResult?.billingModel && { billingModel: creditsResult.billingModel }),
136
141
  creditsRedeemed: creditsResult?.success
137
142
  ? (creditsResult.creditsRedeemed ?? credits.toString())
138
143
  : '0',
139
144
  remainingBalance: creditsResult?.remainingBalance,
145
+ ...(creditsResult?.orderTx && { orderTx: creditsResult.orderTx }),
140
146
  planId: authResult.planId,
141
147
  subscriberAddress: authResult.subscriberAddress,
142
148
  success: creditsResult ? creditsResult.success : true,
@@ -268,10 +274,14 @@ function wrapAsyncIterable(iterable, onFinally, planId, subscriberAddress, credi
268
274
  // Nevermined-namespaced observability (NOT part of the x402 spec).
269
275
  [NEVERMINED_CREDITS_META_KEY]: {
270
276
  ...(settlement?.transaction && { txHash: settlement.transaction }),
277
+ // See the non-streaming site: without `billingModel`, `creditsRedeemed`
278
+ // cannot be read — it is '0' on a pay-as-you-go settle that charged.
279
+ ...(settlement?.billingModel && { billingModel: settlement.billingModel }),
271
280
  creditsRedeemed: settlement?.success
272
281
  ? (settlement.creditsRedeemed ?? credits.toString())
273
282
  : '0',
274
283
  remainingBalance: settlement?.remainingBalance,
284
+ ...(settlement?.orderTx && { orderTx: settlement.orderTx }),
275
285
  planId,
276
286
  subscriberAddress,
277
287
  success: settlement ? settlement.success : true,