mppx 0.19.0 → 0.19.1
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.
- package/CHANGELOG.md +9 -0
- package/dist/Errors.d.ts +29 -0
- package/dist/Errors.js +27 -2
- package/dist/cli/cli.js +96 -96
- package/dist/cli/plugins/index.js +12 -12
- package/dist/extensions/identity/poppy/Constants.d.ts +26 -0
- package/dist/extensions/identity/poppy/Constants.js +26 -0
- package/dist/extensions/identity/poppy/Types.d.ts +19 -0
- package/dist/extensions/identity/poppy/Types.js +2 -0
- package/dist/extensions/identity/poppy/client/index.d.ts +69 -0
- package/dist/extensions/identity/poppy/client/index.js +81 -0
- package/dist/extensions/identity/poppy/index.d.ts +7 -0
- package/dist/extensions/identity/poppy/index.js +7 -0
- package/dist/extensions/identity/poppy/internal/Jws.d.ts +12 -0
- package/dist/extensions/identity/poppy/internal/Jws.js +78 -0
- package/dist/extensions/identity/poppy/server/index.d.ts +40 -0
- package/dist/extensions/identity/poppy/server/index.js +181 -0
- package/dist/identity/Headers.d.ts +1 -1
- package/dist/identity/Headers.js +1 -0
- package/dist/internal/version.d.ts +2 -2
- package/dist/internal/version.js +1 -1
- package/dist/tempo/client/Charge.js +7 -4
- package/dist/tempo/internal/simulation.d.ts +33 -0
- package/dist/tempo/internal/simulation.js +80 -0
- package/dist/tempo/server/internal/html.gen.js +1 -1
- package/dist/tempo/session/client/ChannelOps.js +5 -2
- package/package.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# mppx
|
|
2
2
|
|
|
3
|
+
## 0.19.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 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.
|
|
8
|
+
- 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.
|
|
9
|
+
- 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.
|
|
10
|
+
- 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.
|
|
11
|
+
|
|
3
12
|
## 0.19.0
|
|
4
13
|
|
|
5
14
|
### 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
|
/**
|