mppx 0.9.0 → 0.9.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 +8 -0
- package/dist/Errors.d.ts +10 -0
- package/dist/Errors.js +12 -0
- package/dist/Mcp.d.ts +9 -1
- package/dist/Mcp.js +18 -0
- package/dist/Method.d.ts +7 -0
- package/dist/cli/cli.js +134 -134
- package/dist/cli/plugins/index.js +12 -12
- package/dist/client/internal/protocols/Mcp.js +2 -1
- package/dist/mcp/client/McpClient.js +22 -10
- package/dist/mcp/server/Transport.d.ts +2 -2
- package/dist/mcp/server/Transport.js +11 -4
- package/dist/server/Mppx.d.ts +6 -0
- package/dist/server/Mppx.js +75 -6
- package/dist/server/Transport.js +8 -15
- package/dist/stripe/Methods.d.ts +6 -0
- package/dist/stripe/Methods.js +3 -1
- package/dist/stripe/client/Charge.d.ts +6 -0
- package/dist/stripe/client/Methods.d.ts +6 -0
- package/dist/stripe/internal/payment-intent.d.ts +7 -0
- package/dist/stripe/internal/payment-intent.js +6 -0
- package/dist/stripe/server/Charge.d.ts +6 -0
- package/dist/stripe/server/Charge.js +8 -3
- package/dist/stripe/server/Methods.js +62 -7
- package/dist/stripe/server/internal/html.gen.d.ts +1 -1
- package/dist/stripe/server/internal/html.gen.js +1 -1
- package/dist/tempo/Tokens.d.ts +13 -0
- package/dist/tempo/Tokens.js +13 -0
- package/dist/tempo/client/Charge.d.ts +1 -1
- package/dist/tempo/client/Charge.js +17 -0
- package/dist/tempo/index.d.ts +1 -0
- package/dist/tempo/index.js +1 -0
- package/dist/tempo/internal/fee-payer.d.ts +1 -1
- package/dist/tempo/internal/fee-payer.js +2 -12
- package/dist/tempo/internal/fee-token.d.ts +2 -0
- package/dist/tempo/internal/fee-token.js +7 -0
- package/dist/tempo/server/internal/html.gen.d.ts +1 -1
- package/dist/tempo/server/internal/html.gen.js +1 -1
- package/dist/tempo/session/client/SessionManager.js +1 -2
- package/dist/tempo/session/server/Session.js +5 -2
- package/dist/x402/mcp.js +4 -3
- package/package.json +1 -1
|
@@ -530,11 +530,10 @@ export function sessionManager(parameters) {
|
|
|
530
530
|
trackCreates: false,
|
|
531
531
|
};
|
|
532
532
|
channelUse = use;
|
|
533
|
-
// Cold starts resume from `channelStore` after the 402 reveals the scope.
|
|
534
|
-
const liveHint = runtime.channel?.opened ? runtime.channel.channelId : undefined;
|
|
535
533
|
try {
|
|
536
534
|
await bootstrapSession(input, init);
|
|
537
535
|
use.trackCreates = true;
|
|
536
|
+
const liveHint = runtime.channel?.opened ? runtime.channel.channelId : undefined;
|
|
538
537
|
let effectiveInit = requestInitWithSessionHint(input, init, liveHint);
|
|
539
538
|
// Stored channels may be stale, so retry once after evicting the resumed entry.
|
|
540
539
|
let canRetryResumed = !previous.channel?.opened;
|
|
@@ -129,10 +129,13 @@ async function verifyBootstrapCredential(parameters) {
|
|
|
129
129
|
});
|
|
130
130
|
Expires.assert(credential.challenge.expires, credential.challenge.id);
|
|
131
131
|
assertBootstrapChallengeMatches(challenge, credential.challenge);
|
|
132
|
+
const payload = Methods.charge.schema.credential.payload.safeParse(credential.payload);
|
|
133
|
+
if (!payload.success)
|
|
134
|
+
throw new Errors.InvalidPayloadError();
|
|
132
135
|
return charge.verify({
|
|
133
136
|
credential: {
|
|
134
137
|
...credential,
|
|
135
|
-
payload:
|
|
138
|
+
payload: payload.data,
|
|
136
139
|
},
|
|
137
140
|
request: rawRequest,
|
|
138
141
|
});
|
|
@@ -159,7 +162,7 @@ async function handleBootstrapPreflight(parameters) {
|
|
|
159
162
|
});
|
|
160
163
|
}
|
|
161
164
|
catch (error) {
|
|
162
|
-
return respondBootstrapChallenge(challenge, error instanceof Errors.PaymentError ? error : new Errors.
|
|
165
|
+
return respondBootstrapChallenge(challenge, error instanceof Errors.PaymentError ? error : new Errors.InternalPaymentError());
|
|
163
166
|
}
|
|
164
167
|
const channelId = await resolveSessionChannelId({
|
|
165
168
|
capturedRequest: parameters.capturedRequest,
|
package/dist/x402/mcp.js
CHANGED
|
@@ -2,6 +2,7 @@ import { McpError } from '@modelcontextprotocol/sdk/types.js';
|
|
|
2
2
|
import { decodePaymentRequiredHeader } from '@x402/core/http';
|
|
3
3
|
import { createPaymentWrapper, MCP_PAYMENT_META_KEY, } from '@x402/mcp';
|
|
4
4
|
import * as Challenge from '../Challenge.js';
|
|
5
|
+
import * as Errors from '../Errors.js';
|
|
5
6
|
import * as Negotiator from '../integrations/x402/Negotiator.js';
|
|
6
7
|
import * as Mcp from '../Mcp.js';
|
|
7
8
|
import * as McpCredential from '../mcp/internal/Credential.js';
|
|
@@ -56,7 +57,7 @@ export function mpp(resourceServer, config) {
|
|
|
56
57
|
return x402Handler(arguments_, rawExtra);
|
|
57
58
|
if (result.status === 'handled') {
|
|
58
59
|
if (result.response.status === 402)
|
|
59
|
-
throw createCombinedChallenge(result.response);
|
|
60
|
+
throw createCombinedChallenge(result.response, credential ? new Errors.VerificationFailedError() : undefined);
|
|
60
61
|
return attachReceipt(await responseToToolResult(result.response.clone()), result.response, credential);
|
|
61
62
|
}
|
|
62
63
|
const toolResult = await handler(arguments_, {
|
|
@@ -118,11 +119,11 @@ function getErrorMessage(value) {
|
|
|
118
119
|
function isRecord(value) {
|
|
119
120
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
120
121
|
}
|
|
121
|
-
function createCombinedChallenge(response) {
|
|
122
|
+
function createCombinedChallenge(response, error) {
|
|
122
123
|
const challenges = Challenge.fromResponseList(response);
|
|
123
124
|
const encoded = response.headers.get(paymentRequiredHeader);
|
|
124
125
|
const x402 = encoded ? decodePaymentRequiredHeader(encoded) : undefined;
|
|
125
|
-
return new McpError(Mcp.
|
|
126
|
+
return new McpError(Mcp.errorCode(error), error?.title ?? 'Payment Required', {
|
|
126
127
|
challenges,
|
|
127
128
|
httpStatus: 402,
|
|
128
129
|
...(x402 ? { x402 } : {}),
|