mppx 0.13.5 → 0.13.6
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 +27 -0
- package/dist/Credential.d.ts +3 -0
- package/dist/Credential.js +9 -0
- package/dist/cli/cli.js +131 -131
- package/dist/cli/plugins/evm.js +2 -2
- package/dist/cli/plugins/index.js +11 -11
- package/dist/client/internal/MethodChallenge.d.ts +2 -0
- package/dist/client/internal/MethodChallenge.js +4 -0
- package/dist/internal/version.d.ts +2 -2
- package/dist/internal/version.js +1 -1
- package/dist/server/Mppx.js +31 -5
- package/dist/stripe/server/Methods.js +4 -1
- package/dist/tempo/client/Charge.js +1 -0
- package/dist/tempo/internal/auto-swap.d.ts +10 -0
- package/dist/tempo/internal/auto-swap.js +35 -8
- package/dist/tempo/internal/fee-payer.d.ts +8 -0
- package/dist/tempo/internal/fee-payer.js +20 -12
- package/dist/tempo/legacy/session/Chain.js +8 -2
- package/dist/tempo/server/Methods.js +12 -1
- package/dist/tempo/server/Relay.js +6 -22
- package/dist/tempo/server/Subscription.js +3 -0
- package/dist/tempo/server/internal/html.gen.js +1 -1
- package/dist/tempo/server/internal/transport.d.ts +3 -0
- package/dist/tempo/server/internal/transport.js +5 -1
- package/dist/tempo/session/client/ChannelOps.d.ts +2 -0
- package/dist/tempo/session/client/ChannelStore.d.ts +12 -1
- package/dist/tempo/session/client/ChannelStore.js +47 -0
- package/dist/tempo/session/client/CredentialState.js +8 -3
- package/dist/tempo/session/client/Session.js +50 -33
- package/dist/tempo/session/client/SessionManager.js +186 -65
- package/dist/tempo/session/client/Transports.d.ts +6 -0
- package/dist/tempo/session/client/Transports.js +52 -7
- package/dist/tempo/session/precompile/Chain.js +5 -2
- package/dist/tempo/session/server/ChannelStore.d.ts +34 -0
- package/dist/tempo/session/server/ChannelStore.js +69 -9
- package/dist/tempo/session/server/CredentialVerification.d.ts +7 -1
- package/dist/tempo/session/server/CredentialVerification.js +220 -48
- package/dist/tempo/session/server/MeteredStream.d.ts +6 -5
- package/dist/tempo/session/server/MeteredStream.js +10 -26
- package/dist/tempo/session/server/Session.d.ts +29 -2
- package/dist/tempo/session/server/Session.js +114 -33
- package/dist/tempo/session/server/Settlement.d.ts +9 -0
- package/dist/tempo/session/server/Settlement.js +12 -0
- package/dist/tempo/session/server/Sse.d.ts +4 -3
- package/dist/tempo/session/server/Sse.js +3 -3
- package/dist/tempo/session/server/Ws.d.ts +9 -1
- package/dist/tempo/session/server/Ws.js +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# mppx
|
|
2
2
|
|
|
3
|
+
## 0.13.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 82810df: Added `autoSwap.fallback` to Tempo charges. Setting `fallback: false` swaps only from `tokenIn`, as an allowlist, instead of also trying pathUSD and USDC afterwards.
|
|
8
|
+
- 82810df: Added OUSD to the default Tempo auto-swap currencies, after pathUSD and USDC.
|
|
9
|
+
- 0acc2bc: Fixed Tempo charge auto-swap finding no route for an access key whose authorization was not yet published. Balance and DEX quote reads no longer carry the client's account, which the node rejected with `KeyNotFound`.
|
|
10
|
+
- 7827823: Bounded session management POSTs to 30 seconds so stalled endpoints cannot hold funding waiters indefinitely. Timed-out payments report an unknown outcome and ignore late responses.
|
|
11
|
+
|
|
12
|
+
Persisted uncertain top-up state in the channel store after dispatched management requests timed out, failed, or were cancelled and blocked new deposits, including from replacement managers. Callers must reconcile the pending transaction against trusted chain state before clearing that state.
|
|
13
|
+
|
|
14
|
+
- 4de6876: Bounded payment authorization values to 64 KiB before scheme extraction and decoding.
|
|
15
|
+
- 80f9a76: Rechecked sponsored subscription and session transaction deadlines before signing and submission. Aligned validity-window rounding and rejected maximum windows below the required 15 seconds.
|
|
16
|
+
- 051510d: Fixed `compose()` dispatch for handlers without a static `scope`. Their challenges are scoped to the request's route, so dispatch now compares the credential's metadata with that scope merged in, instead of falling back to the first handler with the same method and intent.
|
|
17
|
+
- 626afc6: Fixed `compose()` dispatching every `tempo/session` credential to the first session handler. Dispatch compared the credential with each handler's route request, which lacks the `chainId` and `sessionProtocol` the session request hook adds, so no handler matched; sessions offered in several currencies rejected all but the first with a currency mismatch.
|
|
18
|
+
- f82decc: Sessions now read on-chain channel state concurrently with the stored channel when accepting a voucher, instead of after it. The forced on-chain refresh and error precedence are unchanged.
|
|
19
|
+
- 7055666: Fixed manual streaming charges to commit before stream.charge() resolved, retaining charges when subsequent work was canceled or failed.
|
|
20
|
+
- 3f95f89: Fixed the EVM CLI plugin to use the selected account when signing payments.
|
|
21
|
+
- 3b18cd0: Paid session requests make fewer store round trips. Validating a voucher credential right before broadcasting it no longer reads the stored channel, since broadcasting checks it again. With `voucherStateMaxAge`, a voucher is checked against the stored channel inside the store update that accepts it, without a separate read. The new `chargeOnAcceptance` option charges request-priced content in that same update instead of a second update when the response is delivered.
|
|
22
|
+
- 97eb961: Added `reusableChallenges` to `tempo.session()`. A session challenge then stays valid for later requests to the same route until it expires: it is bound to its route, currency, recipient and channel terms but not to the amount it quoted, and every request is charged its own price from the channel's accepted balance. Clients can send a voucher with a request instead of waiting for a `402`. Composed handlers with a stable binding are now also dispatched by the fields their route request defines, and with reusable challenges session SSE responses charge the verified route request's amount.
|
|
23
|
+
- 22e5b42: Limited automatic swaps to the missing balance and bounded spending independently of DEX quotes. Added an explicit maxAmountIn budget for non-parity token pairs; defaults assumed 1:1 token units plus slippage. Sponsored charge validation accepted partial acquisition up to the payment amount.
|
|
24
|
+
- 132a793: Stopped reusing cached relay receipts as new payment authorizations. Relay broadcasts now omit idempotency keys so reused credentials are rejected; applications should recover uncertain outcomes separately from executing protected operations.
|
|
25
|
+
- 78d0a04: Serialized session-manager top-ups and refreshed the active deposit before subsequent funding decisions, preventing concurrent automatic requests from exceeding the configured deposit limit.
|
|
26
|
+
- 9ad515a: Fixed Stripe-backed session offers to enforce the one-cent recording minimum before application offer policies.
|
|
27
|
+
- d4dddfc: Checked on-chain escrow during managed SSE and WebSocket streams and stopped delivery when escrow closed or checks failed.
|
|
28
|
+
- 13a9035: Added `voucherStateMaxAge` to `tempo.session()`. Vouchers within the deposit of on-chain state verified that recently are accepted without waiting for a fresh on-chain read, which finishes in the background and records a pending close for later vouchers. The verification time is persisted on the stored channel so every server instance can use it. The default `0` keeps reading on-chain state before every acceptance.
|
|
29
|
+
|
|
3
30
|
## 0.13.5
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/dist/Credential.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export declare class InvalidCredentialEncodingError extends Error {
|
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Deserializes a Payment credential header value to a credential.
|
|
27
|
+
* Rejects values longer than 64 KiB before decoding.
|
|
27
28
|
* Accepts the spec-compliant base64url `opaque` string shape and the legacy
|
|
28
29
|
* object-shaped `opaque` form emitted by older mppx versions.
|
|
29
30
|
*
|
|
@@ -106,6 +107,8 @@ export declare function serialize(credential: Credential): string;
|
|
|
106
107
|
* Extracts the `Payment` scheme from an Authorization header value
|
|
107
108
|
* that may contain multiple schemes (comma-separated per RFC 9110).
|
|
108
109
|
*
|
|
110
|
+
* Values longer than 64 KiB are rejected before splitting.
|
|
111
|
+
*
|
|
109
112
|
* @param header - The raw Authorization header value.
|
|
110
113
|
* @returns The `Payment ...` scheme string, or `null` if not found.
|
|
111
114
|
*/
|
package/dist/Credential.js
CHANGED
|
@@ -2,6 +2,8 @@ import { Base64 } from 'ox';
|
|
|
2
2
|
import * as Challenge from './Challenge.js';
|
|
3
3
|
import * as Constants from './Constants.js';
|
|
4
4
|
import * as PaymentRequest from './PaymentRequest.js';
|
|
5
|
+
// Allow the echoed challenge and payment payload to expand during JSON/base64 encoding.
|
|
6
|
+
const maxAuthorizationLength = 64 * 1024;
|
|
5
7
|
export class MissingAuthorizationHeaderError extends Error {
|
|
6
8
|
name = 'MissingAuthorizationHeaderError';
|
|
7
9
|
constructor(header = Constants.Headers.authorization) {
|
|
@@ -22,6 +24,7 @@ export class InvalidCredentialEncodingError extends Error {
|
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
24
26
|
* Deserializes a Payment credential header value to a credential.
|
|
27
|
+
* Rejects values longer than 64 KiB before decoding.
|
|
25
28
|
* Accepts the spec-compliant base64url `opaque` string shape and the legacy
|
|
26
29
|
* object-shaped `opaque` form emitted by older mppx versions.
|
|
27
30
|
*
|
|
@@ -36,6 +39,8 @@ export class InvalidCredentialEncodingError extends Error {
|
|
|
36
39
|
* ```
|
|
37
40
|
*/
|
|
38
41
|
export function deserialize(value) {
|
|
42
|
+
if (value.length > maxAuthorizationLength)
|
|
43
|
+
throw new InvalidCredentialEncodingError();
|
|
39
44
|
const prefixMatch = value.match(new RegExp(`^${Constants.Schemes.payment}\\s+(.+)$`, 'i'));
|
|
40
45
|
if (!prefixMatch?.[1])
|
|
41
46
|
throw new MissingPaymentSchemeError();
|
|
@@ -162,10 +167,14 @@ export function serialize(credential) {
|
|
|
162
167
|
* Extracts the `Payment` scheme from an Authorization header value
|
|
163
168
|
* that may contain multiple schemes (comma-separated per RFC 9110).
|
|
164
169
|
*
|
|
170
|
+
* Values longer than 64 KiB are rejected before splitting.
|
|
171
|
+
*
|
|
165
172
|
* @param header - The raw Authorization header value.
|
|
166
173
|
* @returns The `Payment ...` scheme string, or `null` if not found.
|
|
167
174
|
*/
|
|
168
175
|
export function extractPaymentScheme(header) {
|
|
176
|
+
if (header.length > maxAuthorizationLength)
|
|
177
|
+
return null;
|
|
169
178
|
const schemes = header.split(',').map((s) => s.trim());
|
|
170
179
|
return schemes.find((s) => new RegExp(`^${Constants.Schemes.payment}\\s+`, 'i').test(s)) ?? null;
|
|
171
180
|
}
|