mppx 0.21.4 → 0.22.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 (59) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/BodyDigest.d.ts +3 -3
  3. package/dist/BodyDigest.js +5 -3
  4. package/dist/Challenge.js +12 -2
  5. package/dist/Credential.js +9 -1
  6. package/dist/Errors.d.ts +62 -8
  7. package/dist/Errors.js +57 -6
  8. package/dist/Store.d.ts +7 -4
  9. package/dist/Store.js +18 -8
  10. package/dist/cli/cli.js +135 -135
  11. package/dist/cli/internal.js +1 -1
  12. package/dist/cli/plugins/index.js +12 -12
  13. package/dist/client/Budget.d.ts +49 -0
  14. package/dist/client/Budget.js +101 -0
  15. package/dist/client/Mppx.d.ts +8 -3
  16. package/dist/client/Mppx.js +55 -13
  17. package/dist/client/Spend.d.ts +134 -0
  18. package/dist/client/Spend.js +58 -0
  19. package/dist/client/core.d.ts +2 -0
  20. package/dist/client/core.js +2 -0
  21. package/dist/client/internal/Fetch.d.ts +23 -3
  22. package/dist/client/internal/Fetch.js +155 -37
  23. package/dist/client/internal/FundsMoved.d.ts +9 -0
  24. package/dist/client/internal/FundsMoved.js +18 -0
  25. package/dist/client/internal/SpendGate.d.ts +136 -0
  26. package/dist/client/internal/SpendGate.js +608 -0
  27. package/dist/client/internal/SpendHooks.d.ts +42 -0
  28. package/dist/client/internal/SpendHooks.js +36 -0
  29. package/dist/client/internal/protocols/Mcp.d.ts +9 -0
  30. package/dist/client/internal/protocols/Mcp.js +27 -0
  31. package/dist/client/internal/protocols/Mpp.js +20 -3
  32. package/dist/client/internal/protocols/Shared.js +29 -3
  33. package/dist/evm/client/Charge.js +20 -8
  34. package/dist/extensions/identity/erc8004/server/index.d.ts +7 -1
  35. package/dist/extensions/identity/erc8004/server/index.js +13 -1
  36. package/dist/extensions/identity/link/client/index.js +57 -5
  37. package/dist/identity/Client.d.ts +7 -3
  38. package/dist/identity/Client.js +178 -13
  39. package/dist/identity/Types.d.ts +2 -1
  40. package/dist/integrations/x402/Negotiator.js +4 -1
  41. package/dist/integrations/x402/Solana.d.ts +75 -0
  42. package/dist/integrations/x402/Solana.js +143 -0
  43. package/dist/internal/challengeMeta.d.ts +17 -2
  44. package/dist/internal/challengeMeta.js +35 -7
  45. package/dist/internal/version.d.ts +2 -2
  46. package/dist/internal/version.js +1 -1
  47. package/dist/mcp/client/McpClient.d.ts +6 -1
  48. package/dist/mcp/client/McpClient.js +48 -10
  49. package/dist/server/Mppx.d.ts +12 -1
  50. package/dist/server/Mppx.js +58 -6
  51. package/dist/server/Transport.js +46 -2
  52. package/dist/stripe/server/internal/html.gen.js +1 -1
  53. package/dist/tempo/client/Charge.js +81 -17
  54. package/dist/tempo/server/Charge.d.ts +7 -1
  55. package/dist/tempo/server/Charge.js +98 -12
  56. package/dist/tempo/server/internal/html.gen.js +1 -1
  57. package/dist/tempo/session/client/SessionManager.js +3 -0
  58. package/dist/x402/server/EvmCharge.js +3 -0
  59. package/package.json +1 -1
@@ -110,6 +110,9 @@ export function sessionManager(parameters) {
110
110
  sessionOrigin = origin;
111
111
  return origin;
112
112
  }
113
+ // Spending options accept only charges, so a fetch that sets them cannot pay for sessions.
114
+ if (Fetch.spendConfigOf(config.fetch))
115
+ throw new TypeError('SessionManager: the fetch sets spending options (maxPayment, authorize, funders or tokens), which accept only charges. Pass a fetch without them.');
113
116
  const inheritedIdentity = Fetch.identityOf(config.fetch);
114
117
  const rawFetch = Fetch.unwrapFetch(config.fetch);
115
118
  config.fetch = async (input, init) => {
@@ -163,6 +163,9 @@ export function createPath(config) {
163
163
  respondChallenge(options, response) {
164
164
  if (!response)
165
165
  throw new Error('x402 path requires a base challenge response.');
166
+ // A rejection without a Challenge (403, or 400 for more than one credential) gets no offer.
167
+ if (!response.headers.has('WWW-Authenticate'))
168
+ return response;
166
169
  const headers = new Headers(response.headers);
167
170
  const request = options.challenge.request;
168
171
  headers.set(x402_Types.paymentRequiredHeader, x402_Header.encodePaymentRequired({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mppx",
3
3
  "type": "module",
4
- "version": "0.21.4",
4
+ "version": "0.22.0",
5
5
  "main": "./dist/index.js",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/wevm/mppx#readme",