mppx 0.16.0 → 0.17.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 +36 -0
- package/dist/BodyDigest.js +13 -1
- package/dist/Challenge.d.ts +6 -0
- package/dist/Challenge.js +12 -0
- package/dist/Method.d.ts +7 -0
- package/dist/cli/cli.js +140 -134
- package/dist/cli/plugins/index.js +11 -11
- package/dist/cli/sessions/store.js +7 -1
- package/dist/cli/validate/helpers.d.ts +1 -1
- package/dist/cli/validate/helpers.js +14 -2
- package/dist/cli/validate/payment.js +39 -15
- package/dist/client/Mppx.js +11 -3
- package/dist/client/internal/Fetch.d.ts +2 -0
- package/dist/client/internal/Fetch.js +59 -3
- package/dist/client/internal/protocols/Mpp.js +4 -1
- package/dist/identity/Client.js +3 -3
- package/dist/identity/Server.d.ts +13 -0
- package/dist/identity/Server.js +50 -1
- package/dist/identity/Types.d.ts +32 -10
- package/dist/internal/AcceptPayment.d.ts +12 -2
- package/dist/internal/AcceptPayment.js +12 -3
- package/dist/internal/version.d.ts +2 -2
- package/dist/internal/version.js +1 -1
- package/dist/mcp/client/McpClient.js +1 -1
- package/dist/proxy/Proxy.d.ts +15 -0
- package/dist/proxy/Proxy.js +89 -1
- package/dist/proxy/internal/Replay.d.ts +105 -0
- package/dist/proxy/internal/Replay.js +257 -0
- package/dist/server/Mppx.d.ts +4 -2
- package/dist/server/Mppx.js +50 -24
- package/dist/server/internal/challengeMeta.d.ts +6 -0
- package/dist/server/internal/challengeMeta.js +17 -1
- package/dist/tempo/client/Charge.d.ts +20 -0
- package/dist/tempo/client/Charge.js +43 -10
- package/dist/tempo/client/Methods.d.ts +2 -0
- package/dist/tempo/internal/defaults.d.ts +9 -0
- package/dist/tempo/internal/defaults.js +9 -0
- package/dist/tempo/internal/fee-payer.js +2 -2
- package/dist/tempo/server/Charge.js +16 -2
- package/dist/tempo/server/internal/html.gen.js +1 -1
- package/dist/tempo/session/client/ChannelOps.d.ts +2 -0
- package/dist/tempo/session/client/ChannelStore.js +5 -0
- package/dist/tempo/session/client/Session.d.ts +26 -1
- package/dist/tempo/session/client/Session.js +72 -1
- package/dist/tempo/session/client/SessionManager.d.ts +1 -0
- package/dist/tempo/session/client/SessionManager.js +54 -7
- package/dist/tempo/session/client/Transports.d.ts +2 -0
- package/dist/tempo/session/client/Transports.js +31 -2
- package/dist/tempo/session/precompile/Voucher.js +20 -7
- package/dist/tempo/session/server/Session.d.ts +2 -1
- package/dist/tempo/session/server/Session.js +2 -1
- package/dist/tempo/session/server/Settlement.d.ts +4 -2
- package/dist/tempo/session/server/Settlement.js +2 -2
- package/dist/tempo/session/server/Ws.js +29 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# mppx
|
|
2
2
|
|
|
3
|
+
## 0.17.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 95dd056: Fixed closing a Tempo session paid with a Viem Tempo access key account. `signCloseAuthorization` now signs the close authorization hash raw with the access key, as vouchers already do, instead of returning a keychain signature that TIP-1034 rejects.
|
|
8
|
+
- ed76e8e: Accepted the RFC 9530 byte-sequence form (`sha-256=:base64:`) in `BodyDigest.verify`, alongside the existing bare form. `BodyDigest.compute` still emits the bare form.
|
|
9
|
+
- 20eca32: Added `feeToken` to the Tempo charge client, so an access key whose spending limits exclude the default fee token can pay an unsponsored charge's fee in a token it may spend.
|
|
10
|
+
- 2b747bf: Fixed Tempo charge settlement returning a fresh 402 after a paid transaction was mined: a broadcast rejected with `ExpiringNonceReplay` (for example, a retried send) now recovers the transaction's receipt instead of failing.
|
|
11
|
+
- cd6a2a7: Fixed payment retries losing Request-carried HTTP methods and bodies, including valid body overrides. Rejected automatic payment after redirects with ambiguous method rewriting before creating credentials.
|
|
12
|
+
- 807376f: Fixed cooperative HTTP session close inheriting the resource Request's body and abort signal while preserving its transport settings and the same resource URL.
|
|
13
|
+
- 2ca12d1: Charged request-priced SSE-enabled content before invoking application handlers, including POST requests that return plain responses. Marked the receipt prepaid to avoid charging the first stream unit twice. Per-item pricing remained stream-driven. Applications must refund request charges when they cannot serve the accepted request.
|
|
14
|
+
- 3fca0d6: Added an opt-in `replay` option to `Proxy.create`, so a payer who loses the connection during a long paid request can collect the response. The paid upstream request runs detached from the client, and a retry with the same credential and request gets the stored response, `202` while it runs, or a new upstream attempt after a failed delivery, without paying again.
|
|
15
|
+
- afb9924: Fixed rejected WebSocket payments leaving sockets open when detailed error messages exceeded the close-frame reason limit.
|
|
16
|
+
- 3c2bc84: Bound each session manager to its first HTTP origin and persisted that binding with reusable channels. Rejected cross-origin HTTP, SSE, and WebSocket reuse before disclosing channel hints or payment credentials, and prevented redirects from forwarding session requests. Existing unbound channel entries acquired an origin on their next validated reuse.
|
|
17
|
+
- 9957b10: Applied the `currencies`, `maxAmount`, `maxAtomicAmount` and `expectedRecipients` client options to Tempo session payments. `tempo()` passed them only to its charge method; its session method, and `tempo.session()` given them directly, now skip offers in other currencies, to other recipients or above the cap during selection and reject them before signing or topping up a channel. An explicit close passed to `Mppx.createCredential`, `fetch` or the MCP client stays available for any offer: `canHandleChallenge` now receives the caller's credential context when it is known before selection.
|
|
18
|
+
- 5d353bb: Prevented validation probes from authorizing payments through an installed global Mppx fetch wrapper.
|
|
19
|
+
|
|
20
|
+
## 0.17.0
|
|
21
|
+
|
|
22
|
+
### Minor Changes
|
|
23
|
+
|
|
24
|
+
- 25c8468: Simplified payment-stage identity. Breaking changes to `mppx/identity`:
|
|
25
|
+
|
|
26
|
+
- Every payment offer in one 402 now carries the same HMAC-bound identity nonce, passed to verifiers as `context.nonce`. Bind payment-stage proofs to it instead of the challenge id. Routes may combine several offers with payment-stage identity (for example `tempo()`'s default currencies, or Tempo and Stripe), as long as they require the same verifiers; previously a route allowed only one such offer.
|
|
27
|
+
- Verifiers issue their 402 challenge headers through a new optional `challenge(request, { nonce })` hook, which runs once per 402, instead of returning them from `verify` as `missing`. `verify` only checks proofs.
|
|
28
|
+
- `Prover.retry` is split: `prepare(response, { challenge })` runs on a 402 before the payment retry, and `retry(response)` runs on other rejections and returns whether to resend.
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- b149237: Raised the @hono/node-server override to 2.1.5 to resolve a dependency audit advisory.
|
|
33
|
+
- faa4735: Fixed the client throwing `No Payment schemes found.` on a `402` whose `WWW-Authenticate` has no Payment challenge, so other protocols such as x402 now handle it.
|
|
34
|
+
- 73b464f: Fixed the Tempo charge client signing a sponsored transaction whose `validBefore` had fewer than 15 seconds left after slow preparation: the pre-sign check now measures `validBefore` as well as the challenge expiry.
|
|
35
|
+
- a0d54fd: Enforced the fee payer's 15-second remaining-validity minimum for Tempo charges: clients refused to sign a sponsored pull transaction for a challenge expiring in under 15 seconds, checking again right before signing, and servers refused to issue a sponsored challenge with a paid amount and pull mode that expires that soon. Push and zero-amount challenges were exempt. Request hooks received the expiry echoed by the credential when verifying it.
|
|
36
|
+
- 7a68c55: Fixed focused tests failing in a clean checkout by generating the HTML modules on demand, and the package check's cleanup reinstalling dependencies with the publish manifest.
|
|
37
|
+
- 443ad6d: Improved `mppx validate` SSE receipt scanning to search only newly received text for event boundaries, so long events no longer cost quadratic time.
|
|
38
|
+
|
|
3
39
|
## 0.16.0
|
|
4
40
|
|
|
5
41
|
### Minor Changes
|
package/dist/BodyDigest.js
CHANGED
|
@@ -36,6 +36,18 @@ export function compute(body) {
|
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
38
|
export function verify(digest, body) {
|
|
39
|
-
return constantTimeEqual(compute(body), digest);
|
|
39
|
+
return constantTimeEqual(compute(body), normalize(digest));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Accepts the RFC 9530 byte-sequence form `sha-256=:base64hash:` (the form the
|
|
43
|
+
* Payment spec shows) by stripping its colons and restoring any padding it
|
|
44
|
+
* omits (RFC 8941 `4.2.7). Other text is left unchanged.
|
|
45
|
+
*/
|
|
46
|
+
function normalize(digest) {
|
|
47
|
+
const match = /^sha-256=:([A-Za-z0-9+/]+)=*:$/.exec(digest);
|
|
48
|
+
if (!match)
|
|
49
|
+
return digest;
|
|
50
|
+
const hash = match[1];
|
|
51
|
+
return `sha-256=${hash}${'='.repeat((4 - (hash.length % 4)) % 4)}`;
|
|
40
52
|
}
|
|
41
53
|
//# sourceMappingURL=BodyDigest.js.map
|
package/dist/Challenge.d.ts
CHANGED
|
@@ -215,6 +215,12 @@ export declare function serialize(challenge: Challenge): string;
|
|
|
215
215
|
* @returns The deserialized challenge.
|
|
216
216
|
*/
|
|
217
217
|
export declare function deserialize<const methods extends readonly Method.Method[] | undefined = undefined>(value: string, options?: from.Options<methods>): from.ReturnType<from.Parameters, methods>;
|
|
218
|
+
/**
|
|
219
|
+
* Returns whether a `WWW-Authenticate` value contains a Payment challenge.
|
|
220
|
+
*
|
|
221
|
+
* @internal
|
|
222
|
+
*/
|
|
223
|
+
export declare function hasPaymentScheme(value: string): boolean;
|
|
218
224
|
/**
|
|
219
225
|
* Extracts the challenge from a Headers object.
|
|
220
226
|
*
|
package/dist/Challenge.js
CHANGED
|
@@ -335,6 +335,18 @@ function startsWithSchemeToken(value, index, token) {
|
|
|
335
335
|
const next = value[index + token.length];
|
|
336
336
|
return Boolean(next && /\s/.test(next));
|
|
337
337
|
}
|
|
338
|
+
/**
|
|
339
|
+
* Returns whether a `WWW-Authenticate` value contains a Payment challenge.
|
|
340
|
+
*
|
|
341
|
+
* @internal
|
|
342
|
+
*/
|
|
343
|
+
export function hasPaymentScheme(value) {
|
|
344
|
+
// A bare `Payment` scheme with no parameters is still a (malformed) Payment challenge.
|
|
345
|
+
return (findSchemeStarts(value, Constants.Schemes.payment).length > 0 ||
|
|
346
|
+
value
|
|
347
|
+
.split(',')
|
|
348
|
+
.some((part) => part.trim().toLowerCase() === Constants.Schemes.payment.toLowerCase()));
|
|
349
|
+
}
|
|
338
350
|
/** @internal Finds auth scheme boundaries while ignoring quoted-string contents. */
|
|
339
351
|
function findSchemeStarts(value, token) {
|
|
340
352
|
const starts = [];
|
package/dist/Method.d.ts
CHANGED
|
@@ -75,6 +75,8 @@ export type VerifiedChallengeEnvelope<request extends Record<string, unknown> =
|
|
|
75
75
|
export type RequestContext<method extends Method> = {
|
|
76
76
|
capturedRequest?: CapturedRequest;
|
|
77
77
|
credential?: Credential.Credential | null;
|
|
78
|
+
/** Expiry (ISO 8601) of the challenge being issued, or echoed by `credential`. */
|
|
79
|
+
expires?: string | undefined;
|
|
78
80
|
request: z.input<method['schema']['request']>;
|
|
79
81
|
};
|
|
80
82
|
/** Verification hook parameters for a single method. */
|
|
@@ -224,8 +226,13 @@ export type CreateCredentialFn<method extends Method, context = unknown> = (para
|
|
|
224
226
|
context: context;
|
|
225
227
|
})) => Promise<string>;
|
|
226
228
|
/** Predicate used when multiple client implementations share a wire method/intent. */
|
|
229
|
+
/**
|
|
230
|
+
* Returns whether a client method can sign a challenge. `context` is the caller's credential
|
|
231
|
+
* context when the caller supplied it before selection, such as an explicit session close.
|
|
232
|
+
*/
|
|
227
233
|
export type CanHandleChallengeFn = (parameters: {
|
|
228
234
|
challenge: Challenge.Challenge;
|
|
235
|
+
context?: unknown;
|
|
229
236
|
}) => boolean;
|
|
230
237
|
/** Request transform function for a single method. */
|
|
231
238
|
export type RequestFn<method extends Method> = (options: RequestContext<method>) => MaybePromise<z.input<method['schema']['request']>>;
|