mppx 0.19.0 → 0.20.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 (47) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/Errors.d.ts +29 -0
  3. package/dist/Errors.js +27 -2
  4. package/dist/cli/cli.js +96 -96
  5. package/dist/cli/plugins/index.js +12 -12
  6. package/dist/extensions/identity/erc8004/Constants.d.ts +20 -0
  7. package/dist/extensions/identity/erc8004/Constants.js +20 -0
  8. package/dist/extensions/identity/erc8004/Types.d.ts +11 -0
  9. package/dist/extensions/identity/erc8004/Types.js +2 -0
  10. package/dist/extensions/identity/erc8004/client/index.d.ts +33 -0
  11. package/dist/extensions/identity/erc8004/client/index.js +33 -0
  12. package/dist/extensions/identity/erc8004/index.d.ts +5 -0
  13. package/dist/extensions/identity/erc8004/index.js +4 -0
  14. package/dist/extensions/identity/erc8004/internal/Agent.d.ts +21 -0
  15. package/dist/extensions/identity/erc8004/internal/Agent.js +24 -0
  16. package/dist/extensions/identity/erc8004/server/index.d.ts +44 -0
  17. package/dist/extensions/identity/erc8004/server/index.js +178 -0
  18. package/dist/extensions/identity/index.d.ts +2 -0
  19. package/dist/extensions/identity/index.js +2 -0
  20. package/dist/extensions/identity/poppy/Constants.d.ts +26 -0
  21. package/dist/extensions/identity/poppy/Constants.js +26 -0
  22. package/dist/extensions/identity/poppy/Types.d.ts +19 -0
  23. package/dist/extensions/identity/poppy/Types.js +2 -0
  24. package/dist/extensions/identity/poppy/client/index.d.ts +69 -0
  25. package/dist/extensions/identity/poppy/client/index.js +81 -0
  26. package/dist/extensions/identity/poppy/index.d.ts +7 -0
  27. package/dist/extensions/identity/poppy/index.js +7 -0
  28. package/dist/extensions/identity/poppy/internal/Jws.d.ts +12 -0
  29. package/dist/extensions/identity/poppy/internal/Jws.js +78 -0
  30. package/dist/extensions/identity/poppy/server/index.d.ts +40 -0
  31. package/dist/extensions/identity/poppy/server/index.js +181 -0
  32. package/dist/identity/Headers.d.ts +1 -1
  33. package/dist/identity/Headers.js +3 -0
  34. package/dist/internal/version.d.ts +2 -2
  35. package/dist/internal/version.js +1 -1
  36. package/dist/proxy/Proxy.js +47 -9
  37. package/dist/tempo/client/Charge.js +7 -4
  38. package/dist/tempo/internal/simulation.d.ts +33 -0
  39. package/dist/tempo/internal/simulation.js +80 -0
  40. package/dist/tempo/server/internal/html.gen.js +1 -1
  41. package/dist/tempo/session/client/ChannelOps.js +5 -2
  42. package/dist/tempo/session/server/CredentialVerification.d.ts +2 -0
  43. package/dist/tempo/session/server/CredentialVerification.js +44 -0
  44. package/dist/tempo/session/server/MeteredStream.d.ts +2 -0
  45. package/dist/tempo/session/server/MeteredStream.js +11 -0
  46. package/dist/tempo/session/server/Sse.js +9 -4
  47. package/package.json +9 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # mppx
2
2
 
3
+ ## 0.20.0
4
+
5
+ ### Minor Changes
6
+
7
+ - e2d81d0: Required manual charges before billable per-item stream generation; billable automatic SSE proxy sessions now require request pricing. Session replay retains payment verification, and opening credentials bind their source to the signed transaction payer.
8
+
9
+ ### Patch Changes
10
+
11
+ - d8292be: Added `mppx/extensions/identity/erc8004`: an ERC-8004 agent identity provider. The client prover signs each request with the agent's wallet, and the server's verifier and payment check require that the wallet the Identity Registry names (on Tempo mainnet by default) signed the request or signed the transaction or proof of a `tempo` charge (transaction hashes, sessions, Zones and other methods need the signature). The proxy and cross-origin redirects drop its `Agent-Id` and `Agent-Signature` headers.
12
+
13
+ ## 0.19.1
14
+
15
+ ### Patch Changes
16
+
17
+ - 03bd18d: Hardened `Poppy.Server.verifier`: it rejects invalid `clients` and `maxAge` config, returns `unavailable` instead of throwing on a malformed key set and `invalid` on a non-object `cnf.jwk`, caches a failed key load for 30 seconds, reloads keys once for an unknown `kid` after 30 seconds, only verifies delegations with signing keys that match their `kid` and `alg`, and rejects `Authorization` values that combine an access token with other credentials. `Poppy-Session` is now an `Identity.Headers.request` header, so the proxy no longer forwards it upstream.
18
+ - 9405660: Added `mppx/extensions/identity/poppy`, an identity provider for Poppy (Personal Agent Protocol 1.0) Sessions: `Poppy.Client.prover` signs a fresh `Poppy-Session` JWT for each request, including the paid retry, and `Poppy.Server.verifier` verifies it, with its delegation and the agent's published keys, before any payment Challenge, returning the agent's `client_id`, the pseudonymous User ID, the Session ID and the optional Agent ID.
19
+ - 4e51d05: Fixed `Poppy.Server.verifier` so a failed key reload keeps the agent's previously loaded keys for up to an hour after they loaded, instead of answering `unavailable` until the next reload. The Poppy prover and verifier now bind any single `Bearer` or `DPoP` token, ignore scheme names inside quoted `Authorization` parameters, and the prover throws instead of signing a Session for an `Authorization` value the verifier would reject.
20
+ - 5e21a2e: Added `Errors.SpendingLimitExceededError`. The Tempo charge client and session open and top-up now throw it, or `Errors.InsufficientBalanceError`, when the pre-signing gas estimate reverts with the access key's `SpendingLimitExceeded` or the token's `InsufficientBalance`, instead of signing a transaction that would revert on chain at the fee payer's cost.
21
+
3
22
  ## 0.19.0
4
23
 
5
24
  ### Minor Changes
package/dist/Errors.d.ts CHANGED
@@ -272,6 +272,33 @@ export declare namespace PaymentSimulationError {
272
272
  sender?: `0x${string}` | undefined;
273
273
  };
274
274
  }
275
+ /**
276
+ * The access key that signs a Tempo payment has less spending limit left than the payment needs,
277
+ * so the client did not sign it.
278
+ *
279
+ * The client simulates a payment before it signs. On chain the transaction would revert with the
280
+ * account keychain's `SpendingLimitExceeded()` error, and a fee payer would still pay for it.
281
+ * Raise the key's limit, wait for its period to reset, or pay with another key. The simulation
282
+ * error is the `cause`.
283
+ */
284
+ export declare class SpendingLimitExceededError extends Error {
285
+ readonly name = "SpendingLimitExceededError";
286
+ /** Access key that signs the payment, when the account is an access key. */
287
+ readonly accessKey: `0x${string}` | undefined;
288
+ /** Account that pays. */
289
+ readonly account: `0x${string}`;
290
+ constructor(options: SpendingLimitExceededError.Options);
291
+ }
292
+ export declare namespace SpendingLimitExceededError {
293
+ type Options = {
294
+ /** Access key that signs the payment. */
295
+ accessKey?: `0x${string}` | undefined;
296
+ /** Account that pays. */
297
+ account: `0x${string}`;
298
+ /** The simulation error. */
299
+ cause?: unknown;
300
+ };
301
+ }
275
302
  /**
276
303
  * A client withdrew from a Zone to pay a challenge, but the withdrawal did not settle on Tempo
277
304
  * before the client stopped waiting. The withdrawal cannot be undone and may still settle.
@@ -399,6 +426,8 @@ export declare class InsufficientBalanceError extends PaymentError {
399
426
  }
400
427
  export declare namespace InsufficientBalanceError {
401
428
  type Options = {
429
+ /** Underlying error, such as the failed simulation. Never serialized into Problem Details. */
430
+ cause?: unknown;
402
431
  /** Page where the payer can get the funds, such as the MACH onramp. */
403
432
  fundingUrl?: string | undefined;
404
433
  /** Reason for insufficient balance. */
package/dist/Errors.js CHANGED
@@ -226,6 +226,31 @@ export class PaymentSimulationError extends Error {
226
226
  Object.defineProperty(this, 'cause', { configurable: true, value: cause, writable: true });
227
227
  }
228
228
  }
229
+ /**
230
+ * The access key that signs a Tempo payment has less spending limit left than the payment needs,
231
+ * so the client did not sign it.
232
+ *
233
+ * The client simulates a payment before it signs. On chain the transaction would revert with the
234
+ * account keychain's `SpendingLimitExceeded()` error, and a fee payer would still pay for it.
235
+ * Raise the key's limit, wait for its period to reset, or pay with another key. The simulation
236
+ * error is the `cause`.
237
+ */
238
+ export class SpendingLimitExceededError extends Error {
239
+ name = 'SpendingLimitExceededError';
240
+ /** Access key that signs the payment, when the account is an access key. */
241
+ accessKey;
242
+ /** Account that pays. */
243
+ account;
244
+ constructor(options) {
245
+ const { accessKey, account, cause } = options;
246
+ super(`Access key spending limit exceeded: ${accessKey ? `key ${accessKey} of ` : ''}account ${account} cannot pay this amount, so the payment was not signed.`);
247
+ this.accessKey = accessKey;
248
+ this.account = account;
249
+ // Defined manually (non-enumerable, like native `cause`) so consumers on pre-ES2022 libs still typecheck.
250
+ if (cause !== undefined)
251
+ Object.defineProperty(this, 'cause', { configurable: true, value: cause, writable: true });
252
+ }
253
+ }
229
254
  /**
230
255
  * A client withdrew from a Zone to pay a challenge, but the withdrawal did not settle on Tempo
231
256
  * before the client stopped waiting. The withdrawal cannot be undone and may still settle.
@@ -337,8 +362,8 @@ export class InsufficientBalanceError extends PaymentError {
337
362
  status = 402;
338
363
  type = 'https://paymentauth.org/problems/session/insufficient-balance';
339
364
  constructor(options = {}) {
340
- const { fundingUrl, reason } = options;
341
- super(withFundingUrl(reason ? `Insufficient balance: ${reason}.` : 'Insufficient balance.', fundingUrl), { fundingUrl });
365
+ const { cause, fundingUrl, reason } = options;
366
+ super(withFundingUrl(reason ? `Insufficient balance: ${reason}.` : 'Insufficient balance.', fundingUrl), { cause, fundingUrl });
342
367
  }
343
368
  }
344
369
  /**