mppx 0.17.0 → 0.17.3

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 (83) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/BodyDigest.js +13 -1
  3. package/dist/Method.d.ts +5 -0
  4. package/dist/Store.d.ts +225 -0
  5. package/dist/Store.js +358 -0
  6. package/dist/cli/cli.js +136 -135
  7. package/dist/cli/plugins/index.js +12 -11
  8. package/dist/cli/sessions/Manager.js +12 -1
  9. package/dist/cli/sessions/store.js +7 -1
  10. package/dist/cli/utils.d.ts +2 -0
  11. package/dist/cli/utils.js +6 -0
  12. package/dist/cli/validate/helpers.d.ts +1 -1
  13. package/dist/cli/validate/helpers.js +14 -2
  14. package/dist/client/Mppx.d.ts +1 -1
  15. package/dist/client/Mppx.js +18 -6
  16. package/dist/client/internal/Fetch.d.ts +3 -1
  17. package/dist/client/internal/Fetch.js +68 -3
  18. package/dist/client/internal/MethodResponse.d.ts +8 -0
  19. package/dist/client/internal/MethodResponse.js +9 -0
  20. package/dist/client/internal/ProofRealm.d.ts +3 -3
  21. package/dist/client/internal/ProofRealm.js +4 -4
  22. package/dist/client/internal/protocols/Mcp.d.ts +4 -0
  23. package/dist/client/internal/protocols/Mcp.js +27 -14
  24. package/dist/identity/Client.js +7 -1
  25. package/dist/internal/AcceptPayment.d.ts +12 -2
  26. package/dist/internal/AcceptPayment.js +12 -3
  27. package/dist/internal/sse.d.ts +21 -0
  28. package/dist/internal/sse.js +65 -0
  29. package/dist/internal/version.d.ts +2 -2
  30. package/dist/internal/version.js +1 -1
  31. package/dist/mcp/client/McpClient.d.ts +2 -2
  32. package/dist/mcp/client/McpClient.js +6 -3
  33. package/dist/proxy/Proxy.d.ts +17 -0
  34. package/dist/proxy/Proxy.js +116 -3
  35. package/dist/proxy/internal/Replay.d.ts +105 -0
  36. package/dist/proxy/internal/Replay.js +257 -0
  37. package/dist/server/Mppx.d.ts +2 -0
  38. package/dist/server/Mppx.js +7 -5
  39. package/dist/server/Transport.js +1 -1
  40. package/dist/server/internal/html/config.d.ts +7 -1
  41. package/dist/server/internal/html/config.js +4 -0
  42. package/dist/stripe/internal/types.d.ts +82 -6
  43. package/dist/stripe/server/Charge.js +1 -2
  44. package/dist/stripe/server/internal/html.gen.js +1 -1
  45. package/dist/tempo/client/Charge.d.ts +9 -0
  46. package/dist/tempo/client/Charge.js +13 -9
  47. package/dist/tempo/client/Methods.d.ts +2 -0
  48. package/dist/tempo/internal/fee-payer.d.ts +85 -10
  49. package/dist/tempo/internal/fee-payer.js +183 -19
  50. package/dist/tempo/legacy/session/Chain.js +2 -0
  51. package/dist/tempo/server/Charge.js +6 -3
  52. package/dist/tempo/server/Subscription.js +1 -0
  53. package/dist/tempo/server/internal/html.gen.js +1 -1
  54. package/dist/tempo/server/internal/transport.d.ts +6 -0
  55. package/dist/tempo/server/internal/transport.js +21 -21
  56. package/dist/tempo/session/client/ChannelOps.d.ts +2 -0
  57. package/dist/tempo/session/client/ChannelStore.d.ts +2 -0
  58. package/dist/tempo/session/client/ChannelStore.js +5 -0
  59. package/dist/tempo/session/client/CredentialState.js +2 -0
  60. package/dist/tempo/session/client/Session.d.ts +37 -2
  61. package/dist/tempo/session/client/Session.js +111 -7
  62. package/dist/tempo/session/client/SessionManager.d.ts +2 -1
  63. package/dist/tempo/session/client/SessionManager.js +60 -9
  64. package/dist/tempo/session/client/Transports.d.ts +4 -0
  65. package/dist/tempo/session/client/Transports.js +35 -3
  66. package/dist/tempo/session/precompile/Chain.js +1 -0
  67. package/dist/tempo/session/precompile/Voucher.js +20 -7
  68. package/dist/tempo/session/server/ChannelStore.d.ts +9 -0
  69. package/dist/tempo/session/server/ChannelStore.js +8 -1
  70. package/dist/tempo/session/server/MeteredStream.d.ts +4 -0
  71. package/dist/tempo/session/server/MeteredStream.js +6 -1
  72. package/dist/tempo/session/server/Session.d.ts +2 -1
  73. package/dist/tempo/session/server/Session.js +2 -1
  74. package/dist/tempo/session/server/Settlement.d.ts +4 -2
  75. package/dist/tempo/session/server/Settlement.js +2 -2
  76. package/dist/tempo/session/server/Sse.d.ts +59 -0
  77. package/dist/tempo/session/server/Sse.js +175 -10
  78. package/dist/tempo/session/server/Ws.js +29 -12
  79. package/dist/zod.d.ts +2 -1
  80. package/dist/zod.js +1 -1
  81. package/package.json +1 -3
  82. package/dist/stripe/server/internal/html/types.d.ts +0 -2
  83. package/dist/stripe/server/internal/html/types.js +0 -2
@@ -40,7 +40,32 @@ export async function serve(options) {
40
40
  runtime.closed = true;
41
41
  abortController.abort();
42
42
  unsubscribe();
43
- await Promise.resolve(socket.close(code, reason));
43
+ await closeSocket(code, reason);
44
+ };
45
+ const closeSocket = async (code, reason) => {
46
+ try {
47
+ await socket.close(code, reason);
48
+ }
49
+ catch {
50
+ // Some adapters reject a close even after the session has stopped.
51
+ // Retry without application data and contain both sync and async errors.
52
+ try {
53
+ await socket.close();
54
+ }
55
+ catch { }
56
+ }
57
+ };
58
+ const rejectAndClose = (message, status, code) => {
59
+ runtime.closed = true;
60
+ abortController.abort();
61
+ unsubscribe();
62
+ // Queue the small final diagnostic synchronously before close changes socket state.
63
+ // Do not wait for an adapter's send promise: a stalled peer must still be closed.
64
+ try {
65
+ void Promise.resolve(socket.send(formatErrorMessage({ message, status }))).catch(() => { });
66
+ }
67
+ catch { }
68
+ void closeSocket(code, message);
44
69
  };
45
70
  const sendCloseReady = async () => {
46
71
  if (runtime.closeReadySent || !runtime.streamContext || runtime.closed)
@@ -129,7 +154,7 @@ export async function serve(options) {
129
154
  message: authorizationResult.message,
130
155
  status: authorizationResult.responseStatus,
131
156
  }));
132
- await close(1008, authorizationResult.message);
157
+ await close(1008, 'payment authorization rejected');
133
158
  return;
134
159
  }
135
160
  const { receipt } = authorizationResult;
@@ -169,11 +194,7 @@ export async function serve(options) {
169
194
  return;
170
195
  const messageBytes = frameByteLength(payload);
171
196
  if (messageBytes !== null && messageBytes > maxIncomingMessageBytes) {
172
- runtime.closed = true;
173
- abortController.abort();
174
- unsubscribe();
175
- void send(socket, formatErrorMessage({ message: 'payment message is too large', status: 413 })).catch(() => { });
176
- void Promise.resolve(socket.close(1009, 'payment message is too large')).catch(() => { });
197
+ rejectAndClose('payment message is too large', 413, 1009);
177
198
  return;
178
199
  }
179
200
  const raw = toText(payload);
@@ -194,11 +215,7 @@ export async function serve(options) {
194
215
  if (!work)
195
216
  return;
196
217
  if (runtime.queuedActions >= maxQueuedPaymentMessages) {
197
- void sendFrame(formatErrorMessage({
198
- message: 'too many queued payment messages',
199
- status: 429,
200
- })).catch(() => { });
201
- void close(1008, 'too many queued payment messages');
218
+ rejectAndClose('too many queued payment messages', 429, 1008);
202
219
  return;
203
220
  }
204
221
  runtime.queuedActions++;
package/dist/zod.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { type ZodMiniType, z } from 'zod/mini';
1
+ import type { ZodMiniType } from 'zod/mini';
2
+ import * as z from 'zod/mini';
2
3
  export * from 'zod/mini';
3
4
  export type DatetimeInput = string | Date;
4
5
  /** Numeric string amount (e.g., "1", "1.5", "1000000"). */
package/dist/zod.js CHANGED
@@ -1,4 +1,4 @@
1
- import { z } from 'zod/mini';
1
+ import * as z from 'zod/mini';
2
2
  export * from 'zod/mini';
3
3
  /** Numeric string amount (e.g., "1", "1.5", "1000000"). */
4
4
  export function amount() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mppx",
3
3
  "type": "module",
4
- "version": "0.17.0",
4
+ "version": "0.17.3",
5
5
  "main": "./dist/index.js",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/wevm/mppx#readme",
@@ -206,8 +206,6 @@
206
206
  }
207
207
  },
208
208
  "dependencies": {
209
- "@stripe/stripe-js": "9.17.0",
210
- "eventsource-parser": "4.1.1",
211
209
  "ox": "0.14.45",
212
210
  "structured-headers": "2.1.0",
213
211
  "zod": "^4.6.7"
@@ -1,2 +0,0 @@
1
- export type { CreatePaymentMethodFromElements, StripeElementsOptionsMode, StripePaymentElementOptions, } from '@stripe/stripe-js';
2
- //# sourceMappingURL=types.d.ts.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map