mppx 0.21.1 → 0.21.2

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 (130) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/Errors.d.ts +55 -0
  3. package/dist/Errors.js +48 -0
  4. package/dist/Html.d.ts +1 -1
  5. package/dist/Html.js +2 -2
  6. package/dist/Method.d.ts +1 -1
  7. package/dist/cli/cli.js +138 -138
  8. package/dist/cli/internal.js +1 -1
  9. package/dist/cli/plugins/evm.js +1 -1
  10. package/dist/cli/plugins/index.js +13 -13
  11. package/dist/cli/plugins/x402.js +1 -1
  12. package/dist/cli/utils.d.ts +2 -45
  13. package/dist/cli/utils.js +2 -79
  14. package/dist/cli/validate/index.js +5 -2
  15. package/dist/cli/validate/payment.d.ts +1 -1
  16. package/dist/cli/validate/payment.js +3 -3
  17. package/dist/cli/validate/print.d.ts +12 -0
  18. package/dist/cli/validate/print.js +35 -0
  19. package/dist/client/core.d.ts +6 -0
  20. package/dist/client/core.js +6 -0
  21. package/dist/client/index.d.ts +2 -8
  22. package/dist/client/index.js +2 -6
  23. package/dist/client/internal/protocols/Shared.js +1 -1
  24. package/dist/client/internal/protocols/X402.js +3 -3
  25. package/dist/evm/client/Charge.js +1 -1
  26. package/dist/evm/index.d.ts +1 -1
  27. package/dist/evm/server/Charge.js +1 -1
  28. package/dist/integrations/x402/Evm.js +1 -1
  29. package/dist/integrations/x402/Negotiator.js +1 -1
  30. package/dist/internal/AcceptPayment.js +1 -1
  31. package/dist/internal/CredentialExpiry.js +1 -1
  32. package/dist/{mcp/internal/Credential.d.ts → internal/McpCredential.d.ts} +2 -2
  33. package/dist/{mcp/internal/Credential.js → internal/McpCredential.js} +2 -2
  34. package/dist/{server/internal → internal}/challengeMeta.js +1 -1
  35. package/dist/{server/internal → internal}/html/config.d.ts +2 -2
  36. package/dist/internal/pc.d.ts +46 -0
  37. package/dist/internal/pc.js +80 -0
  38. package/dist/internal/version.d.ts +2 -2
  39. package/dist/internal/version.js +1 -1
  40. package/dist/{x402 → internal/x402}/Header.js +1 -1
  41. package/dist/{x402 → internal/x402}/Siwx.d.ts +2 -2
  42. package/dist/{x402 → internal/x402}/Siwx.js +2 -2
  43. package/dist/{x402 → internal/x402}/Types.d.ts +1 -1
  44. package/dist/{x402 → internal/x402}/Types.js +1 -1
  45. package/dist/mcp/server/index.d.ts +1 -1
  46. package/dist/mcp/server/index.js +1 -1
  47. package/dist/server/Mppx.d.ts +1 -1
  48. package/dist/server/Mppx.js +6 -6
  49. package/dist/server/Transport.d.ts +2 -2
  50. package/dist/server/Transport.js +4 -4
  51. package/dist/server/index.d.ts +1 -8
  52. package/dist/server/index.js +1 -8
  53. package/dist/{mcp/server/Transport.d.ts → server/internal/mcpSdk.d.ts} +2 -2
  54. package/dist/{mcp/server/Transport.js → server/internal/mcpSdk.js} +3 -3
  55. package/dist/stripe/server/Charge.d.ts +1 -1
  56. package/dist/stripe/server/internal/html.gen.js +1 -1
  57. package/dist/tempo/Methods.d.ts +3 -0
  58. package/dist/tempo/Methods.js +3 -1
  59. package/dist/tempo/client/Charge.js +1 -1
  60. package/dist/tempo/client/Methods.d.ts +3 -0
  61. package/dist/tempo/client/index.d.ts +3 -0
  62. package/dist/tempo/client/index.js +1 -0
  63. package/dist/tempo/internal/configurable-account.d.ts +26 -0
  64. package/dist/tempo/internal/configurable-account.js +77 -0
  65. package/dist/tempo/internal/signature.d.ts +15 -0
  66. package/dist/tempo/internal/signature.js +43 -0
  67. package/dist/tempo/server/Charge.d.ts +1 -1
  68. package/dist/tempo/server/Charge.js +1 -1
  69. package/dist/tempo/server/Methods.d.ts +139 -4
  70. package/dist/tempo/server/internal/html.gen.js +1 -1
  71. package/dist/tempo/session/client/ChannelOps.d.ts +29 -0
  72. package/dist/tempo/session/client/ChannelOps.js +108 -3
  73. package/dist/tempo/session/client/CredentialState.d.ts +6 -0
  74. package/dist/tempo/session/client/CredentialState.js +29 -4
  75. package/dist/tempo/session/client/Session.d.ts +3 -0
  76. package/dist/tempo/session/client/SessionManager.js +4 -0
  77. package/dist/tempo/session/precompile/Chain.d.ts +35 -1
  78. package/dist/tempo/session/precompile/Chain.js +52 -0
  79. package/dist/tempo/session/precompile/Voucher.d.ts +46 -5
  80. package/dist/tempo/session/precompile/Voucher.js +78 -29
  81. package/dist/tempo/session/precompile/escrow.abi.d.ts +79 -0
  82. package/dist/tempo/session/precompile/escrow.abi.js +38 -0
  83. package/dist/tempo/session/server/ChannelStore.d.ts +27 -0
  84. package/dist/tempo/session/server/ChannelStore.js +24 -3
  85. package/dist/tempo/session/server/CredentialVerification.d.ts +7 -1
  86. package/dist/tempo/session/server/CredentialVerification.js +91 -12
  87. package/dist/tempo/session/server/RequestState.d.ts +2 -0
  88. package/dist/tempo/session/server/RequestState.js +1 -0
  89. package/dist/tempo/session/server/Session.d.ts +11 -0
  90. package/dist/tempo/session/server/Session.js +10 -2
  91. package/dist/tempo/session/server/SponsorshipLimit.d.ts +11 -3
  92. package/dist/tempo/session/server/SponsorshipLimit.js +36 -4
  93. package/dist/tempo/subscription/KeyAuthorization.js +6 -2
  94. package/dist/{cli/validate → validation}/challenge.d.ts +1 -1
  95. package/dist/{cli/validate → validation}/challenge.js +4 -4
  96. package/dist/validation/core.d.ts +29 -2
  97. package/dist/validation/core.js +41 -10
  98. package/dist/{cli/validate → validation}/helpers.d.ts +0 -10
  99. package/dist/{cli/validate → validation}/helpers.js +1 -35
  100. package/dist/validation/index.d.ts +2 -2
  101. package/dist/validation/index.js +1 -1
  102. package/dist/x402/Assets.d.ts +1 -1
  103. package/dist/x402/client/Exact.d.ts +1 -1
  104. package/dist/x402/client/Exact.js +2 -2
  105. package/dist/x402/index.d.ts +4 -4
  106. package/dist/x402/index.js +4 -4
  107. package/dist/x402/internal/RouteBinding.d.ts +1 -1
  108. package/dist/x402/mcp.js +2 -2
  109. package/dist/x402/server/EvmCharge.d.ts +2 -2
  110. package/dist/x402/server/EvmCharge.js +4 -4
  111. package/dist/x402/server/Facilitator.d.ts +1 -1
  112. package/dist/x402/server/Facilitator.js +1 -1
  113. package/package.json +13 -1
  114. /package/dist/{server/internal → internal}/challengeMeta.d.ts +0 -0
  115. /package/dist/{server/internal → internal}/html/compose.main.gen.d.ts +0 -0
  116. /package/dist/{server/internal → internal}/html/compose.main.gen.js +0 -0
  117. /package/dist/{server/internal → internal}/html/config.js +0 -0
  118. /package/dist/{server/internal → internal}/html/constants.d.ts +0 -0
  119. /package/dist/{server/internal → internal}/html/constants.js +0 -0
  120. /package/dist/{server/internal → internal}/html/serviceWorker.client.d.ts +0 -0
  121. /package/dist/{server/internal → internal}/html/serviceWorker.client.js +0 -0
  122. /package/dist/{server/internal → internal}/html/serviceWorker.gen.d.ts +0 -0
  123. /package/dist/{server/internal → internal}/html/serviceWorker.gen.js +0 -0
  124. /package/dist/{x402/internal → internal/x402}/ChallengeBrand.d.ts +0 -0
  125. /package/dist/{x402/internal → internal/x402}/ChallengeBrand.js +0 -0
  126. /package/dist/{x402 → internal/x402}/Header.d.ts +0 -0
  127. /package/dist/{cli/validate → validation}/discovery.d.ts +0 -0
  128. /package/dist/{cli/validate → validation}/discovery.js +0 -0
  129. /package/dist/{cli/validate → validation}/messages.d.ts +0 -0
  130. /package/dist/{cli/validate → validation}/messages.js +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # mppx
2
2
 
3
+ ## 0.21.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 60f265c: Fixed `mppx/validation` so it no longer imports the CLI, which pulled in the CLI's bundled `incur` dependency and failed to load from npm. `validate()` and `validateStream()` now take an optional `payment` validator; without one, payment checks are reported as skipped. `mppx validate` passes its own.
8
+
9
+ Moved shared modules so lower layers no longer import higher ones: the HTML payment-page infrastructure and x402 wire helpers now live under `src/internal`, and the MCP SDK server transport lives under `src/server`. Public entry points are unchanged.
10
+
11
+ - 6056a5b: Added `mppx/client/core`, `mppx/tempo/client` and `mppx/tempo/server` entrypoints, so apps can load the client primitives or only the Tempo method without the other payment methods. `mppx/client` and `mppx/server` export the same API as before.
12
+ - db173d9: Fixed Tempo session voucher, close authorization and subscription key authorization verification to reject secp256k1 signatures with a high `s` value, which Tempo does not accept onchain. Voucher and close authorization signing now normalize a signer's high-`s` signature to its low-`s` equivalent.
13
+ - 98d110b: Added TIP-1166 configurable account voucher signers to `tempo/session`. Servers accept configurable account (`0x05`) vouchers and close authorizations when `configurableVouchers` is set (default `false`), advertise it in the challenge, and check each voucher against the signer config commitment recorded at open (`OpeningCommitmentRecorded`). Configurable account clients open channels with their config commitment as the salt, sign vouchers with configurable account signatures, refuse to open against servers that do not advertise `configurableVouchers` (`ConfigurableVouchersUnsupportedError`), and surface top-ups that revert because the signer config changed as `SignerConfigChangedError`. `Voucher.verifyVoucher` and `Voucher.verifyCloseAuthorization` take optional `{ configurable, openingCommitment }` options; without them they accept only primitive signatures, as before.
14
+ - bd9dac5: Fixed `validateStream` to pass its synthesized `Payment: failed` check to `onPaymentResults`, and fixed `validate()` to promise automatic Tempo wallet provisioning only when a payment validator is configured.
15
+
3
16
  ## 0.21.1
4
17
 
5
18
  ### Patch Changes
package/dist/Errors.d.ts CHANGED
@@ -303,6 +303,61 @@ export declare namespace PaymentSimulationError {
303
303
  sender?: `0x${string}` | undefined;
304
304
  };
305
305
  }
306
+ /**
307
+ * A `tempo/session` client would open a channel whose vouchers a TIP-1166 configurable account
308
+ * signs, but the server's challenge does not advertise `configurableVouchers`, so the server
309
+ * would reject those vouchers. The client stops before it locks a deposit.
310
+ *
311
+ * Pay with a primitive account or access key, or ask the server operator to enable
312
+ * `configurableVouchers` once the chain runs T15.
313
+ */
314
+ export declare class ConfigurableVouchersUnsupportedError extends Error {
315
+ readonly name = "ConfigurableVouchersUnsupportedError";
316
+ /** Configurable account that would sign the channel's vouchers. */
317
+ readonly signer: `0x${string}`;
318
+ constructor(options: ConfigurableVouchersUnsupportedError.Options);
319
+ }
320
+ export declare namespace ConfigurableVouchersUnsupportedError {
321
+ type Options = {
322
+ /** Configurable account that would sign the channel's vouchers. */
323
+ signer: `0x${string}`;
324
+ };
325
+ }
326
+ /**
327
+ * A `tempo/session` top-up would revert because the channel signer's TIP-1166 config changed
328
+ * since the channel opened, so the client did not sign it.
329
+ *
330
+ * The escrow reverts a nonzero top-up with `SignerConfigChanged(signer)` when the config
331
+ * commitment recorded at open differs from the signer's current one, or with
332
+ * `RootKeyRetired(signer)` when the signer had no commitment at open and has one now. Vouchers
333
+ * already signed for the channel still settle, since the escrow checks them against the commitment
334
+ * recorded at open, but the channel takes no new funds: close it and open a new one. The
335
+ * simulation error is the `cause`.
336
+ */
337
+ export declare class SignerConfigChangedError extends Error {
338
+ readonly name = "SignerConfigChangedError";
339
+ /** Channel whose signer config changed. */
340
+ readonly channelId: `0x${string}`;
341
+ /** Escrow error that reverted the top-up. */
342
+ readonly reason: SignerConfigChangedError.Reason;
343
+ /** Voucher signer of the channel. */
344
+ readonly signer: `0x${string}`;
345
+ constructor(options: SignerConfigChangedError.Options);
346
+ }
347
+ export declare namespace SignerConfigChangedError {
348
+ /** `SignerConfigChanged`: the commitment recorded at open differs. `RootKeyRetired`: the signer had none at open. */
349
+ type Reason = 'SignerConfigChanged' | 'RootKeyRetired';
350
+ type Options = {
351
+ /** The simulation error. */
352
+ cause?: unknown;
353
+ /** Channel whose signer config changed. */
354
+ channelId: `0x${string}`;
355
+ /** Escrow error that reverted the top-up. */
356
+ reason: Reason;
357
+ /** Voucher signer of the channel. */
358
+ signer: `0x${string}`;
359
+ };
360
+ }
306
361
  /**
307
362
  * The access key that signs a Tempo payment has less spending limit left than the payment needs,
308
363
  * so the client did not sign it.
package/dist/Errors.js CHANGED
@@ -261,6 +261,54 @@ export class PaymentSimulationError extends Error {
261
261
  Object.defineProperty(this, 'cause', { configurable: true, value: cause, writable: true });
262
262
  }
263
263
  }
264
+ /**
265
+ * A `tempo/session` client would open a channel whose vouchers a TIP-1166 configurable account
266
+ * signs, but the server's challenge does not advertise `configurableVouchers`, so the server
267
+ * would reject those vouchers. The client stops before it locks a deposit.
268
+ *
269
+ * Pay with a primitive account or access key, or ask the server operator to enable
270
+ * `configurableVouchers` once the chain runs T15.
271
+ */
272
+ export class ConfigurableVouchersUnsupportedError extends Error {
273
+ name = 'ConfigurableVouchersUnsupportedError';
274
+ /** Configurable account that would sign the channel's vouchers. */
275
+ signer;
276
+ constructor(options) {
277
+ const { signer } = options;
278
+ super(`Configurable account ${signer} signs vouchers with TIP-1166 configurable account signatures, but the session challenge does not advertise \`configurableVouchers\`, so the channel was not opened.`);
279
+ this.signer = signer;
280
+ }
281
+ }
282
+ /**
283
+ * A `tempo/session` top-up would revert because the channel signer's TIP-1166 config changed
284
+ * since the channel opened, so the client did not sign it.
285
+ *
286
+ * The escrow reverts a nonzero top-up with `SignerConfigChanged(signer)` when the config
287
+ * commitment recorded at open differs from the signer's current one, or with
288
+ * `RootKeyRetired(signer)` when the signer had no commitment at open and has one now. Vouchers
289
+ * already signed for the channel still settle, since the escrow checks them against the commitment
290
+ * recorded at open, but the channel takes no new funds: close it and open a new one. The
291
+ * simulation error is the `cause`.
292
+ */
293
+ export class SignerConfigChangedError extends Error {
294
+ name = 'SignerConfigChangedError';
295
+ /** Channel whose signer config changed. */
296
+ channelId;
297
+ /** Escrow error that reverted the top-up. */
298
+ reason;
299
+ /** Voucher signer of the channel. */
300
+ signer;
301
+ constructor(options) {
302
+ const { cause, channelId, reason, signer } = options;
303
+ super(`Signer ${signer} of channel ${channelId} changed its account config since the channel opened, so the top-up was not signed. Close the channel and open a new one.`);
304
+ this.channelId = channelId;
305
+ this.reason = reason;
306
+ this.signer = signer;
307
+ // Defined manually (non-enumerable, like native `cause`) so consumers on pre-ES2022 libs still typecheck.
308
+ if (cause !== undefined)
309
+ Object.defineProperty(this, 'cause', { configurable: true, value: cause, writable: true });
310
+ }
311
+ }
264
312
  /**
265
313
  * The access key that signs a Tempo payment has less spending limit left than the payment needs,
266
314
  * so the client did not sign it.
package/dist/Html.d.ts CHANGED
@@ -1,5 +1,5 @@
1
+ import { type Config, type Data, type Text, type Theme, vars } from './internal/html/config.js';
1
2
  import type * as Method from './Method.js';
2
- import { type Config, type Data, type Text, type Theme, vars } from './server/internal/html/config.js';
3
3
  export declare function init<method extends Method.Method = Method.Method, config extends Record<string, unknown> = {}>(methodName: method['name']): Context<method, config>;
4
4
  export type Context<method extends Method.Method = Method.Method, config extends Record<string, unknown> = {}> = Data<method, config> & {
5
5
  error: (message?: string | null | undefined) => void;
package/dist/Html.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Json } from 'ox';
2
- import { attrs, ids, vars, } from './server/internal/html/config.js';
3
- import { submitCredential } from './server/internal/html/serviceWorker.client.js';
2
+ import { attrs, ids, vars, } from './internal/html/config.js';
3
+ import { submitCredential } from './internal/html/serviceWorker.client.js';
4
4
  export function init(methodName) {
5
5
  const element = document.getElementById(ids.data);
6
6
  const dataMap = Json.parse(element.textContent);
package/dist/Method.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import type * as Challenge from './Challenge.js';
2
2
  import * as Credential from './Credential.js';
3
+ import type * as Html from './internal/html/config.js';
3
4
  import type { DeepReadonly, ExactPartial, LooseOmit, MaybePromise } from './internal/types.js';
4
5
  import type * as Receipt from './Receipt.js';
5
- import type * as Html from './server/internal/html/config.js';
6
6
  import type * as Transport from './server/Transport.js';
7
7
  import type * as z from './zod.js';
8
8
  /**