@shroud-fi/mcp-server 0.1.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.
- package/LICENSE +21 -0
- package/README.md +130 -0
- package/dist/cjs/auth.d.ts +41 -0
- package/dist/cjs/auth.d.ts.map +1 -0
- package/dist/cjs/auth.js +103 -0
- package/dist/cjs/auth.js.map +1 -0
- package/dist/cjs/bin/http.d.ts +7 -0
- package/dist/cjs/bin/http.d.ts.map +1 -0
- package/dist/cjs/bin/http.js +24 -0
- package/dist/cjs/bin/http.js.map +1 -0
- package/dist/cjs/bin/stdio.d.ts +9 -0
- package/dist/cjs/bin/stdio.d.ts.map +1 -0
- package/dist/cjs/bin/stdio.js +15 -0
- package/dist/cjs/bin/stdio.js.map +1 -0
- package/dist/cjs/config.d.ts +22 -0
- package/dist/cjs/config.d.ts.map +1 -0
- package/dist/cjs/config.js +180 -0
- package/dist/cjs/config.js.map +1 -0
- package/dist/cjs/constants.d.ts +29 -0
- package/dist/cjs/constants.d.ts.map +1 -0
- package/dist/cjs/constants.js +35 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/errors.d.ts +43 -0
- package/dist/cjs/errors.d.ts.map +1 -0
- package/dist/cjs/errors.js +72 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/http.d.ts +32 -0
- package/dist/cjs/http.d.ts.map +1 -0
- package/dist/cjs/http.js +180 -0
- package/dist/cjs/http.js.map +1 -0
- package/dist/cjs/index.d.ts +19 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +40 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/server.d.ts +14 -0
- package/dist/cjs/server.d.ts.map +1 -0
- package/dist/cjs/server.js +92 -0
- package/dist/cjs/server.js.map +1 -0
- package/dist/cjs/stdio.d.ts +9 -0
- package/dist/cjs/stdio.d.ts.map +1 -0
- package/dist/cjs/stdio.js +21 -0
- package/dist/cjs/stdio.js.map +1 -0
- package/dist/cjs/tools/balance.d.ts +9 -0
- package/dist/cjs/tools/balance.d.ts.map +1 -0
- package/dist/cjs/tools/balance.js +61 -0
- package/dist/cjs/tools/balance.js.map +1 -0
- package/dist/cjs/tools/index.d.ts +17 -0
- package/dist/cjs/tools/index.d.ts.map +1 -0
- package/dist/cjs/tools/index.js +40 -0
- package/dist/cjs/tools/index.js.map +1 -0
- package/dist/cjs/tools/receive.d.ts +13 -0
- package/dist/cjs/tools/receive.d.ts.map +1 -0
- package/dist/cjs/tools/receive.js +100 -0
- package/dist/cjs/tools/receive.js.map +1 -0
- package/dist/cjs/tools/register.d.ts +9 -0
- package/dist/cjs/tools/register.d.ts.map +1 -0
- package/dist/cjs/tools/register.js +36 -0
- package/dist/cjs/tools/register.js.map +1 -0
- package/dist/cjs/tools/schema.d.ts +18 -0
- package/dist/cjs/tools/schema.d.ts.map +1 -0
- package/dist/cjs/tools/schema.js +25 -0
- package/dist/cjs/tools/schema.js.map +1 -0
- package/dist/cjs/tools/send-to-wallet.d.ts +9 -0
- package/dist/cjs/tools/send-to-wallet.d.ts.map +1 -0
- package/dist/cjs/tools/send-to-wallet.js +60 -0
- package/dist/cjs/tools/send-to-wallet.js.map +1 -0
- package/dist/cjs/tools/send.d.ts +9 -0
- package/dist/cjs/tools/send.d.ts.map +1 -0
- package/dist/cjs/tools/send.js +68 -0
- package/dist/cjs/tools/send.js.map +1 -0
- package/dist/cjs/tools/status.d.ts +6 -0
- package/dist/cjs/tools/status.d.ts.map +1 -0
- package/dist/cjs/tools/status.js +39 -0
- package/dist/cjs/tools/status.js.map +1 -0
- package/dist/cjs/tools/sweep.d.ts +14 -0
- package/dist/cjs/tools/sweep.d.ts.map +1 -0
- package/dist/cjs/tools/sweep.js +119 -0
- package/dist/cjs/tools/sweep.js.map +1 -0
- package/dist/cjs/tools/x402-pay.d.ts +14 -0
- package/dist/cjs/tools/x402-pay.d.ts.map +1 -0
- package/dist/cjs/tools/x402-pay.js +78 -0
- package/dist/cjs/tools/x402-pay.js.map +1 -0
- package/dist/cjs/tools/x402-serve.d.ts +17 -0
- package/dist/cjs/tools/x402-serve.d.ts.map +1 -0
- package/dist/cjs/tools/x402-serve.js +133 -0
- package/dist/cjs/tools/x402-serve.js.map +1 -0
- package/dist/cjs/types.d.ts +66 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +6 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/auth.d.ts +41 -0
- package/dist/esm/auth.d.ts.map +1 -0
- package/dist/esm/auth.js +99 -0
- package/dist/esm/auth.js.map +1 -0
- package/dist/esm/bin/http.d.ts +7 -0
- package/dist/esm/bin/http.d.ts.map +1 -0
- package/dist/esm/bin/http.js +22 -0
- package/dist/esm/bin/http.js.map +1 -0
- package/dist/esm/bin/stdio.d.ts +9 -0
- package/dist/esm/bin/stdio.d.ts.map +1 -0
- package/dist/esm/bin/stdio.js +13 -0
- package/dist/esm/bin/stdio.js.map +1 -0
- package/dist/esm/config.d.ts +22 -0
- package/dist/esm/config.d.ts.map +1 -0
- package/dist/esm/config.js +175 -0
- package/dist/esm/config.js.map +1 -0
- package/dist/esm/constants.d.ts +29 -0
- package/dist/esm/constants.d.ts.map +1 -0
- package/dist/esm/constants.js +32 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/errors.d.ts +43 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/errors.js +61 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/http.d.ts +32 -0
- package/dist/esm/http.d.ts.map +1 -0
- package/dist/esm/http.js +177 -0
- package/dist/esm/http.js.map +1 -0
- package/dist/esm/index.d.ts +19 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +18 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/server.d.ts +14 -0
- package/dist/esm/server.d.ts.map +1 -0
- package/dist/esm/server.js +89 -0
- package/dist/esm/server.js.map +1 -0
- package/dist/esm/stdio.d.ts +9 -0
- package/dist/esm/stdio.d.ts.map +1 -0
- package/dist/esm/stdio.js +18 -0
- package/dist/esm/stdio.js.map +1 -0
- package/dist/esm/tools/balance.d.ts +9 -0
- package/dist/esm/tools/balance.d.ts.map +1 -0
- package/dist/esm/tools/balance.js +58 -0
- package/dist/esm/tools/balance.js.map +1 -0
- package/dist/esm/tools/index.d.ts +17 -0
- package/dist/esm/tools/index.d.ts.map +1 -0
- package/dist/esm/tools/index.js +28 -0
- package/dist/esm/tools/index.js.map +1 -0
- package/dist/esm/tools/receive.d.ts +13 -0
- package/dist/esm/tools/receive.d.ts.map +1 -0
- package/dist/esm/tools/receive.js +97 -0
- package/dist/esm/tools/receive.js.map +1 -0
- package/dist/esm/tools/register.d.ts +9 -0
- package/dist/esm/tools/register.d.ts.map +1 -0
- package/dist/esm/tools/register.js +33 -0
- package/dist/esm/tools/register.js.map +1 -0
- package/dist/esm/tools/schema.d.ts +18 -0
- package/dist/esm/tools/schema.d.ts.map +1 -0
- package/dist/esm/tools/schema.js +21 -0
- package/dist/esm/tools/schema.js.map +1 -0
- package/dist/esm/tools/send-to-wallet.d.ts +9 -0
- package/dist/esm/tools/send-to-wallet.d.ts.map +1 -0
- package/dist/esm/tools/send-to-wallet.js +57 -0
- package/dist/esm/tools/send-to-wallet.js.map +1 -0
- package/dist/esm/tools/send.d.ts +9 -0
- package/dist/esm/tools/send.d.ts.map +1 -0
- package/dist/esm/tools/send.js +65 -0
- package/dist/esm/tools/send.js.map +1 -0
- package/dist/esm/tools/status.d.ts +6 -0
- package/dist/esm/tools/status.d.ts.map +1 -0
- package/dist/esm/tools/status.js +36 -0
- package/dist/esm/tools/status.js.map +1 -0
- package/dist/esm/tools/sweep.d.ts +14 -0
- package/dist/esm/tools/sweep.d.ts.map +1 -0
- package/dist/esm/tools/sweep.js +116 -0
- package/dist/esm/tools/sweep.js.map +1 -0
- package/dist/esm/tools/x402-pay.d.ts +14 -0
- package/dist/esm/tools/x402-pay.d.ts.map +1 -0
- package/dist/esm/tools/x402-pay.js +75 -0
- package/dist/esm/tools/x402-pay.js.map +1 -0
- package/dist/esm/tools/x402-serve.d.ts +17 -0
- package/dist/esm/tools/x402-serve.d.ts.map +1 -0
- package/dist/esm/tools/x402-serve.js +130 -0
- package/dist/esm/tools/x402-serve.js.map +1 -0
- package/dist/esm/types.d.ts +66 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +5 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +81 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* shroud_sweep — sweep a previously-detected stealth address to a destination.
|
|
4
|
+
*
|
|
5
|
+
* Caller passes the detection bundle returned by shroud_receive (stealth
|
|
6
|
+
* address + stealth private key + ephemeral pub key + tx coords). We
|
|
7
|
+
* reconstruct a minimal DetectedPayment and dispatch to agent.sweep.
|
|
8
|
+
*
|
|
9
|
+
* Optional flags:
|
|
10
|
+
* - viaRelayer + token → Gelato ERC-20 gasless sweep
|
|
11
|
+
* - viaRelayer (ETH) → EIP-7702 ETH gasless sweep (requires selfHostEndpoint)
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.shroudSweepTool = void 0;
|
|
15
|
+
const zod_1 = require("zod");
|
|
16
|
+
const errors_js_1 = require("../errors.js");
|
|
17
|
+
const schema_js_1 = require("./schema.js");
|
|
18
|
+
const HexSchema = zod_1.z.string().regex(/^0x[0-9a-fA-F]+$/);
|
|
19
|
+
const Hex32Schema = zod_1.z.string().regex(/^0x[0-9a-fA-F]{64}$/);
|
|
20
|
+
const ArgsSchema = zod_1.z
|
|
21
|
+
.object({
|
|
22
|
+
detection: zod_1.z.object({
|
|
23
|
+
stealthAddress: schema_js_1.AddressSchema,
|
|
24
|
+
ephemeralPubKey: HexSchema,
|
|
25
|
+
stealthPrivateKey: Hex32Schema,
|
|
26
|
+
txHash: Hex32Schema,
|
|
27
|
+
blockNumber: schema_js_1.Uint256StringSchema,
|
|
28
|
+
blockHash: Hex32Schema,
|
|
29
|
+
logIndex: zod_1.z.number().int().nonnegative(),
|
|
30
|
+
finality: zod_1.z.enum(['safe', 'finalized']).optional(),
|
|
31
|
+
}),
|
|
32
|
+
destination: schema_js_1.AddressSchema,
|
|
33
|
+
token: schema_js_1.AddressSchema.optional(),
|
|
34
|
+
viaRelayer: zod_1.z.boolean().optional(),
|
|
35
|
+
ethRelayerEndpoint: zod_1.z.string().url().optional(),
|
|
36
|
+
})
|
|
37
|
+
.strict();
|
|
38
|
+
exports.shroudSweepTool = {
|
|
39
|
+
name: 'shroud_sweep',
|
|
40
|
+
description: 'Sweep a detected stealth address to a destination wallet. Pass the detection object returned by shroud_receive. Omit `token` for ETH; pass `token` for an ERC-20. Set `viaRelayer: true` for gasless sweep (ERC-20 → Gelato; ETH → requires `ethRelayerEndpoint` to a self-host relayer).',
|
|
41
|
+
inputSchema: {
|
|
42
|
+
type: 'object',
|
|
43
|
+
additionalProperties: false,
|
|
44
|
+
properties: {
|
|
45
|
+
detection: {
|
|
46
|
+
type: 'object',
|
|
47
|
+
additionalProperties: false,
|
|
48
|
+
properties: {
|
|
49
|
+
stealthAddress: { type: 'string', pattern: '^0x[0-9a-fA-F]{40}$' },
|
|
50
|
+
ephemeralPubKey: { type: 'string', pattern: '^0x[0-9a-fA-F]+$' },
|
|
51
|
+
stealthPrivateKey: { type: 'string', pattern: '^0x[0-9a-fA-F]{64}$' },
|
|
52
|
+
txHash: { type: 'string', pattern: '^0x[0-9a-fA-F]{64}$' },
|
|
53
|
+
blockNumber: { type: 'string', pattern: '^\\d+$' },
|
|
54
|
+
blockHash: { type: 'string', pattern: '^0x[0-9a-fA-F]{64}$' },
|
|
55
|
+
logIndex: { type: 'integer', minimum: 0 },
|
|
56
|
+
finality: { type: 'string', enum: ['safe', 'finalized'] },
|
|
57
|
+
},
|
|
58
|
+
required: [
|
|
59
|
+
'stealthAddress',
|
|
60
|
+
'ephemeralPubKey',
|
|
61
|
+
'stealthPrivateKey',
|
|
62
|
+
'txHash',
|
|
63
|
+
'blockNumber',
|
|
64
|
+
'blockHash',
|
|
65
|
+
'logIndex',
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
destination: { type: 'string', pattern: '^0x[0-9a-fA-F]{40}$' },
|
|
69
|
+
token: { type: 'string', pattern: '^0x[0-9a-fA-F]{40}$' },
|
|
70
|
+
viaRelayer: { type: 'boolean' },
|
|
71
|
+
ethRelayerEndpoint: { type: 'string' },
|
|
72
|
+
},
|
|
73
|
+
required: ['detection', 'destination'],
|
|
74
|
+
},
|
|
75
|
+
async handler(ctx, raw) {
|
|
76
|
+
const parsed = ArgsSchema.safeParse(raw);
|
|
77
|
+
if (!parsed.success) {
|
|
78
|
+
throw new errors_js_1.McpInvalidArgsError();
|
|
79
|
+
}
|
|
80
|
+
const { detection, destination, token, viaRelayer, ethRelayerEndpoint } = parsed.data;
|
|
81
|
+
const dp = {
|
|
82
|
+
stealthAddress: detection.stealthAddress,
|
|
83
|
+
ephemeralPubKey: detection.ephemeralPubKey,
|
|
84
|
+
stealthPrivateKey: detection.stealthPrivateKey,
|
|
85
|
+
txHash: detection.txHash,
|
|
86
|
+
blockNumber: (0, schema_js_1.toBigInt)(detection.blockNumber),
|
|
87
|
+
blockHash: detection.blockHash,
|
|
88
|
+
logIndex: detection.logIndex,
|
|
89
|
+
finality: detection.finality ?? 'safe',
|
|
90
|
+
};
|
|
91
|
+
const sweepOpts = {};
|
|
92
|
+
if (token !== undefined)
|
|
93
|
+
sweepOpts.token = token;
|
|
94
|
+
if (viaRelayer === true) {
|
|
95
|
+
sweepOpts.viaRelayer = true;
|
|
96
|
+
if (ethRelayerEndpoint !== undefined) {
|
|
97
|
+
sweepOpts.ethRelayerOptions = { selfHostEndpoint: ethRelayerEndpoint };
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const result = await ctx.agent.sweep(dp, destination, sweepOpts);
|
|
101
|
+
const swept = result.swept;
|
|
102
|
+
const out = {
|
|
103
|
+
ok: true,
|
|
104
|
+
txHash: swept.txHash,
|
|
105
|
+
destination: swept.destination,
|
|
106
|
+
};
|
|
107
|
+
if (swept.token !== undefined)
|
|
108
|
+
out.token = swept.token;
|
|
109
|
+
if (swept.blockNumber !== undefined) {
|
|
110
|
+
out.blockNumber = swept.blockNumber.toString();
|
|
111
|
+
}
|
|
112
|
+
if (swept.taskId !== undefined)
|
|
113
|
+
out.taskId = swept.taskId;
|
|
114
|
+
if (swept.status !== undefined)
|
|
115
|
+
out.status = swept.status;
|
|
116
|
+
return out;
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=sweep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sweep.js","sourceRoot":"","sources":["../../../src/tools/sweep.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEH,6BAAwB;AAGxB,4CAAmD;AACnD,2CAA2E;AAE3E,MAAM,SAAS,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;AACvD,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;AAE5D,MAAM,UAAU,GAAG,OAAC;KACjB,MAAM,CAAC;IACN,SAAS,EAAE,OAAC,CAAC,MAAM,CAAC;QAClB,cAAc,EAAE,yBAAa;QAC7B,eAAe,EAAE,SAAS;QAC1B,iBAAiB,EAAE,WAAW;QAC9B,MAAM,EAAE,WAAW;QACnB,WAAW,EAAE,+BAAmB;QAChC,SAAS,EAAE,WAAW;QACtB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;QACx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SAAS;YAAE,SAAS,CAAC,KAAK,GAAG,KAAsB,CAAC;QAClE,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;YACxB,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC;YAC5B,IAAI,kBAAkB,KAAK,SAAS,EAAE,CAAC;gBACrC,SAAS,CAAC,iBAAiB,GAAG,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,CAAC;YACzE,CAAC;QACH,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,KAAK,CAClC,EAAE,EACF,WAA4B,EAC5B,SAAS,CACV,CAAC;QACF,MAAM,KAAK,GAAG,MAAM,CAAC,KAAgC,CAAC;QACtD,MAAM,GAAG,GAA4B;YACnC,EAAE,EAAE,IAAI;YACR,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,WAAW,EAAE,KAAK,CAAC,WAAW;SAC/B,CAAC;QACF,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS;YAAE,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QACvD,IAAI,KAAK,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YACpC,GAAG,CAAC,WAAW,GAAI,KAAK,CAAC,WAAsB,CAAC,QAAQ,EAAE,CAAC;QAC7D,CAAC;QACD,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS;YAAE,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC1D,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS;YAAE,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC1D,OAAO,GAAoB,CAAC;IAC9B,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* shroud_x402_pay — one-shot HTTP 402 client.
|
|
3
|
+
*
|
|
4
|
+
* Fetches a URL; if the server responds 402, the SDK signs an EIP-3009
|
|
5
|
+
* USDC transferWithAuthorization and retries automatically. Returns the
|
|
6
|
+
* server's final status, the body (if JSON-decodable), and the settled
|
|
7
|
+
* tx hash exposed via X-PAYMENT-RESPONSE when present.
|
|
8
|
+
*
|
|
9
|
+
* `maxPriceUsdcAtomic` is a hard safety cap. If the server demands more,
|
|
10
|
+
* the SDK throws X402AmountMismatchError without signing.
|
|
11
|
+
*/
|
|
12
|
+
import type { McpTool } from '../types.js';
|
|
13
|
+
export declare const shroudX402PayTool: McpTool;
|
|
14
|
+
//# sourceMappingURL=x402-pay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x402-pay.d.ts","sourceRoot":"","sources":["../../../src/tools/x402-pay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAiB,MAAM,aAAa,CAAC;AAc1D,eAAO,MAAM,iBAAiB,EAAE,OAiD/B,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* shroud_x402_pay — one-shot HTTP 402 client.
|
|
4
|
+
*
|
|
5
|
+
* Fetches a URL; if the server responds 402, the SDK signs an EIP-3009
|
|
6
|
+
* USDC transferWithAuthorization and retries automatically. Returns the
|
|
7
|
+
* server's final status, the body (if JSON-decodable), and the settled
|
|
8
|
+
* tx hash exposed via X-PAYMENT-RESPONSE when present.
|
|
9
|
+
*
|
|
10
|
+
* `maxPriceUsdcAtomic` is a hard safety cap. If the server demands more,
|
|
11
|
+
* the SDK throws X402AmountMismatchError without signing.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.shroudX402PayTool = void 0;
|
|
15
|
+
const zod_1 = require("zod");
|
|
16
|
+
const x402_1 = require("@shroud-fi/x402");
|
|
17
|
+
const errors_js_1 = require("../errors.js");
|
|
18
|
+
const schema_js_1 = require("./schema.js");
|
|
19
|
+
const ArgsSchema = zod_1.z
|
|
20
|
+
.object({
|
|
21
|
+
url: zod_1.z.string().url(),
|
|
22
|
+
method: zod_1.z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']).optional(),
|
|
23
|
+
body: zod_1.z.string().optional(),
|
|
24
|
+
headers: zod_1.z.record(zod_1.z.string()).optional(),
|
|
25
|
+
maxPriceUsdcAtomic: schema_js_1.Uint256StringSchema.optional(),
|
|
26
|
+
})
|
|
27
|
+
.strict();
|
|
28
|
+
exports.shroudX402PayTool = {
|
|
29
|
+
name: 'shroud_x402_pay',
|
|
30
|
+
description: 'Fetch an HTTP URL. If the server responds 402, the SDK auto-signs EIP-3009 USDC payment using the agent operator wallet and retries. Returns final status, response body (if any), and settled tx hash (if X-PAYMENT-RESPONSE was returned). `maxPriceUsdcAtomic` caps how much the client will pay (base units, 6 decimals).',
|
|
31
|
+
inputSchema: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
additionalProperties: false,
|
|
34
|
+
properties: {
|
|
35
|
+
url: { type: 'string' },
|
|
36
|
+
method: { type: 'string', enum: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'] },
|
|
37
|
+
body: { type: 'string' },
|
|
38
|
+
headers: { type: 'object', additionalProperties: { type: 'string' } },
|
|
39
|
+
maxPriceUsdcAtomic: { type: 'string', pattern: '^\\d+$' },
|
|
40
|
+
},
|
|
41
|
+
required: ['url'],
|
|
42
|
+
},
|
|
43
|
+
async handler(ctx, raw) {
|
|
44
|
+
const parsed = ArgsSchema.safeParse(raw);
|
|
45
|
+
if (!parsed.success) {
|
|
46
|
+
throw new errors_js_1.McpInvalidArgsError();
|
|
47
|
+
}
|
|
48
|
+
const { url, method, body, headers, maxPriceUsdcAtomic } = parsed.data;
|
|
49
|
+
const client = (0, x402_1.createX402Client)({ transport: ctx.transport });
|
|
50
|
+
const init = {
|
|
51
|
+
method: method ?? 'GET',
|
|
52
|
+
...(headers !== undefined ? { headers } : {}),
|
|
53
|
+
...(body !== undefined ? { body } : {}),
|
|
54
|
+
...(maxPriceUsdcAtomic !== undefined
|
|
55
|
+
? { maxPriceAtomic: (0, schema_js_1.toBigInt)(maxPriceUsdcAtomic) }
|
|
56
|
+
: {}),
|
|
57
|
+
};
|
|
58
|
+
const response = await client.fetch(url, init);
|
|
59
|
+
const text = await response.text();
|
|
60
|
+
let json;
|
|
61
|
+
try {
|
|
62
|
+
json = JSON.parse(text);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
json = null;
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
ok: response.ok,
|
|
69
|
+
status: response.status,
|
|
70
|
+
bodyText: text.length > 4096 ? text.slice(0, 4096) : text,
|
|
71
|
+
bodyJson: json,
|
|
72
|
+
...(response.x402Settlement !== undefined
|
|
73
|
+
? { settledTxHash: response.x402Settlement.txHash }
|
|
74
|
+
: {}),
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=x402-pay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x402-pay.js","sourceRoot":"","sources":["../../../src/tools/x402-pay.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEH,6BAAwB;AACxB,0CAAmD;AAEnD,4CAAmD;AACnD,2CAA4D;AAE5D,MAAM,UAAU,GAAG,OAAC;KACjB,MAAM,CAAC;IACN,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IACrB,MAAM,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE;IACpE,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACxC,kBAAkB,EAAE,+BAAmB,CAAC,QAAQ,EAAE;CACnD,CAAC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C;YAC7C,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACvC,GAAG,CAAC,kBAAkB,KAAK,SAAS;gBAClC,CAAC,CAAC,EAAE,cAAc,EAAE,IAAA,oBAAQ,EAAC,kBAAkB,CAAC,EAAE;gBAClD,CAAC,CAAC,EAAE,CAAC;SACR,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC/C,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,IAAI,IAAa,CAAC;QAClB,IAAI,CAAC;YACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,GAAG,IAAI,CAAC;QACd,CAAC;QACD,OAAO;YACL,EAAE,EAAE,QAAQ,CAAC,EAAE;YACf,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,QAAQ,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI;YACzD,QAAQ,EAAE,IAAI;YACd,GAAG,CAAC,QAAQ,CAAC,cAAc,KAAK,SAAS;gBACvC,CAAC,CAAC,EAAE,aAAa,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAE;gBACnD,CAAC,CAAC,EAAE,CAAC;SACR,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* shroud_x402_serve — server-side x402 primitives.
|
|
3
|
+
*
|
|
4
|
+
* One tool, two ops:
|
|
5
|
+
* - op: 'challenge' → mint a 402 challenge bundle (headers + body) the
|
|
6
|
+
* caller serves from their own HTTP framework. Each challenge derives a
|
|
7
|
+
* FRESH stealth payTo address.
|
|
8
|
+
* - op: 'verify' → verify a client's signed X-PAYMENT payload against a
|
|
9
|
+
* prior challenge. Skip-facilitator mode by default — caller settles
|
|
10
|
+
* the EIP-3009 authorization on-chain themselves.
|
|
11
|
+
*
|
|
12
|
+
* Caller is responsible for transport (Express/Fastify/Next/etc) — this
|
|
13
|
+
* stays framework-agnostic.
|
|
14
|
+
*/
|
|
15
|
+
import type { McpTool } from '../types.js';
|
|
16
|
+
export declare const shroudX402ServeTool: McpTool;
|
|
17
|
+
//# sourceMappingURL=x402-serve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x402-serve.d.ts","sourceRoot":"","sources":["../../../src/tools/x402-serve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAiB,MAAM,aAAa,CAAC;AA+B1D,eAAO,MAAM,mBAAmB,EAAE,OA4FjC,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* shroud_x402_serve — server-side x402 primitives.
|
|
4
|
+
*
|
|
5
|
+
* One tool, two ops:
|
|
6
|
+
* - op: 'challenge' → mint a 402 challenge bundle (headers + body) the
|
|
7
|
+
* caller serves from their own HTTP framework. Each challenge derives a
|
|
8
|
+
* FRESH stealth payTo address.
|
|
9
|
+
* - op: 'verify' → verify a client's signed X-PAYMENT payload against a
|
|
10
|
+
* prior challenge. Skip-facilitator mode by default — caller settles
|
|
11
|
+
* the EIP-3009 authorization on-chain themselves.
|
|
12
|
+
*
|
|
13
|
+
* Caller is responsible for transport (Express/Fastify/Next/etc) — this
|
|
14
|
+
* stays framework-agnostic.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.shroudX402ServeTool = void 0;
|
|
18
|
+
const zod_1 = require("zod");
|
|
19
|
+
const x402_1 = require("@shroud-fi/x402");
|
|
20
|
+
const transport_1 = require("@shroud-fi/transport");
|
|
21
|
+
const errors_js_1 = require("../errors.js");
|
|
22
|
+
const schema_js_1 = require("./schema.js");
|
|
23
|
+
const ChallengeArgs = zod_1.z
|
|
24
|
+
.object({
|
|
25
|
+
op: zod_1.z.literal('challenge'),
|
|
26
|
+
resource: zod_1.z.string().min(1),
|
|
27
|
+
description: zod_1.z.string().optional(),
|
|
28
|
+
priceUsdcAtomic: schema_js_1.Uint256StringSchema.optional(),
|
|
29
|
+
})
|
|
30
|
+
.strict();
|
|
31
|
+
const VerifyArgs = zod_1.z
|
|
32
|
+
.object({
|
|
33
|
+
op: zod_1.z.literal('verify'),
|
|
34
|
+
signedPayloadBase64: zod_1.z.string().min(1),
|
|
35
|
+
challenge: zod_1.z.object({
|
|
36
|
+
body: zod_1.z.object({
|
|
37
|
+
x402Version: zod_1.z.literal(2),
|
|
38
|
+
error: zod_1.z.string(),
|
|
39
|
+
accepts: zod_1.z.array(zod_1.z.any()),
|
|
40
|
+
}),
|
|
41
|
+
headers: zod_1.z.record(zod_1.z.string()),
|
|
42
|
+
}),
|
|
43
|
+
skipFacilitator: zod_1.z.boolean().optional(),
|
|
44
|
+
})
|
|
45
|
+
.strict();
|
|
46
|
+
const ArgsSchema = zod_1.z.discriminatedUnion('op', [ChallengeArgs, VerifyArgs]);
|
|
47
|
+
exports.shroudX402ServeTool = {
|
|
48
|
+
name: 'shroud_x402_serve',
|
|
49
|
+
description: 'Server-side x402 primitives. `op: "challenge"` mints a fresh 402 challenge (headers + body + per-call stealth payTo); caller attaches to their HTTP response. `op: "verify"` verifies a client X-PAYMENT payload against a prior challenge. Defaults to skip-facilitator mode (caller settles on-chain themselves).',
|
|
50
|
+
inputSchema: {
|
|
51
|
+
type: 'object',
|
|
52
|
+
oneOf: [
|
|
53
|
+
{
|
|
54
|
+
properties: {
|
|
55
|
+
op: { const: 'challenge' },
|
|
56
|
+
resource: { type: 'string' },
|
|
57
|
+
description: { type: 'string' },
|
|
58
|
+
priceUsdcAtomic: { type: 'string', pattern: '^\\d+$' },
|
|
59
|
+
},
|
|
60
|
+
required: ['op', 'resource'],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
properties: {
|
|
64
|
+
op: { const: 'verify' },
|
|
65
|
+
signedPayloadBase64: { type: 'string' },
|
|
66
|
+
challenge: { type: 'object' },
|
|
67
|
+
skipFacilitator: { type: 'boolean' },
|
|
68
|
+
},
|
|
69
|
+
required: ['op', 'signedPayloadBase64', 'challenge'],
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
async handler(ctx, raw) {
|
|
74
|
+
const parsed = ArgsSchema.safeParse(raw);
|
|
75
|
+
if (!parsed.success) {
|
|
76
|
+
throw new errors_js_1.McpInvalidArgsError();
|
|
77
|
+
}
|
|
78
|
+
const usdc = (0, transport_1.getUSDC)(ctx.chainId);
|
|
79
|
+
if (usdc === undefined) {
|
|
80
|
+
throw new errors_js_1.McpInvalidArgsError();
|
|
81
|
+
}
|
|
82
|
+
const server = (0, x402_1.createX402Server)({
|
|
83
|
+
transport: ctx.transport,
|
|
84
|
+
chainId: ctx.chainId,
|
|
85
|
+
recipientMetaAddress: ctx.agent.metaAddressEncoded,
|
|
86
|
+
asset: usdc,
|
|
87
|
+
defaultPriceAtomic: parsed.data.op === 'challenge' && parsed.data.priceUsdcAtomic !== undefined
|
|
88
|
+
? BigInt(parsed.data.priceUsdcAtomic)
|
|
89
|
+
: 10000n,
|
|
90
|
+
});
|
|
91
|
+
if (parsed.data.op === 'challenge') {
|
|
92
|
+
const args = {
|
|
93
|
+
resource: parsed.data.resource,
|
|
94
|
+
};
|
|
95
|
+
if (parsed.data.description !== undefined)
|
|
96
|
+
args.description = parsed.data.description;
|
|
97
|
+
if (parsed.data.priceUsdcAtomic !== undefined) {
|
|
98
|
+
args.priceAtomic = BigInt(parsed.data.priceUsdcAtomic);
|
|
99
|
+
}
|
|
100
|
+
const ch = await server.challenge(args);
|
|
101
|
+
return {
|
|
102
|
+
ok: true,
|
|
103
|
+
status: ch.status,
|
|
104
|
+
headers: ch.headers,
|
|
105
|
+
body: ch.body,
|
|
106
|
+
announcement: ch.announcement,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
// op === 'verify' — caller round-trips the same shape they received from
|
|
110
|
+
// the challenge op. Cast through unknown so the schema declaration stays
|
|
111
|
+
// permissive (zod already ran structural checks).
|
|
112
|
+
const verifyResult = await server.verify({
|
|
113
|
+
signedPayload: parsed.data.signedPayloadBase64,
|
|
114
|
+
challenge: parsed.data.challenge,
|
|
115
|
+
skipFacilitator: parsed.data.skipFacilitator ?? true,
|
|
116
|
+
});
|
|
117
|
+
if (verifyResult.valid) {
|
|
118
|
+
return {
|
|
119
|
+
ok: true,
|
|
120
|
+
valid: true,
|
|
121
|
+
...(verifyResult.settledTxHash !== undefined
|
|
122
|
+
? { settledTxHash: verifyResult.settledTxHash }
|
|
123
|
+
: {}),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
ok: true,
|
|
128
|
+
valid: false,
|
|
129
|
+
error: verifyResult.error,
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
//# sourceMappingURL=x402-serve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x402-serve.js","sourceRoot":"","sources":["../../../src/tools/x402-serve.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAEH,6BAAwB;AACxB,0CAAmD;AACnD,oDAA+C;AAE/C,4CAAmD;AACnD,2CAAkD;AAElD,MAAM,aAAa,GAAG,OAAC;KACpB,MAAM,CAAC;IACN,EAAE,EAAE,OAAC,CAAC,OAAO,CAAC,WAAW,CAAC;IAC1B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ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YACZ,KAAK,EAAE,YAAY,CAAC,KAAK;SAC1B,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public types for @shroud-fi/mcp-server.
|
|
3
|
+
*/
|
|
4
|
+
import type { Hex } from 'viem';
|
|
5
|
+
import type { ShroudAgent } from '@shroud-fi/agent-runtime';
|
|
6
|
+
import type { ShroudFiTransport } from '@shroud-fi/transport';
|
|
7
|
+
/**
|
|
8
|
+
* Resolved server context — what every tool handler receives.
|
|
9
|
+
*
|
|
10
|
+
* Built once by createMcpServer/bootstrap and reused for every tool call.
|
|
11
|
+
* No mutable state lives here; the scanner cursor is owned by the agent.
|
|
12
|
+
*/
|
|
13
|
+
export interface McpServerContext {
|
|
14
|
+
readonly agent: ShroudAgent;
|
|
15
|
+
readonly transport: ShroudFiTransport;
|
|
16
|
+
readonly chainId: number;
|
|
17
|
+
/** Resolution of the operator's signing wallet, when present. */
|
|
18
|
+
readonly walletAddress: `0x${string}` | undefined;
|
|
19
|
+
}
|
|
20
|
+
/** JSON-safe tool result shape. MCP wraps this in a `content` array. */
|
|
21
|
+
export interface McpToolResult {
|
|
22
|
+
readonly ok: boolean;
|
|
23
|
+
readonly [k: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Minimal tool descriptor. We mirror the MCP SDK shape but stay decoupled so
|
|
27
|
+
* tests can exercise tools without spinning up the full MCP server.
|
|
28
|
+
*/
|
|
29
|
+
export interface McpTool {
|
|
30
|
+
readonly name: string;
|
|
31
|
+
readonly description: string;
|
|
32
|
+
readonly inputSchema: object;
|
|
33
|
+
readonly handler: (ctx: McpServerContext, args: unknown) => Promise<McpToolResult>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* EIP-191 challenge record. The HTTP transport caches outstanding challenges
|
|
37
|
+
* keyed by client wallet address until they expire or are consumed.
|
|
38
|
+
*/
|
|
39
|
+
export interface Eip191Challenge {
|
|
40
|
+
readonly wallet: `0x${string}`;
|
|
41
|
+
readonly nonce: Hex;
|
|
42
|
+
readonly issuedAtMs: number;
|
|
43
|
+
readonly expiresAtMs: number;
|
|
44
|
+
readonly message: string;
|
|
45
|
+
}
|
|
46
|
+
/** Resolved server bootstrap config. */
|
|
47
|
+
export interface McpServerBootstrapConfig {
|
|
48
|
+
readonly chainId: number;
|
|
49
|
+
readonly rpcUrl: string;
|
|
50
|
+
readonly privateKey: Hex | undefined;
|
|
51
|
+
readonly startBlock: bigint;
|
|
52
|
+
/**
|
|
53
|
+
* Optional 32-byte deterministic master seed. When supplied, the
|
|
54
|
+
* ShroudAgent's stealth meta-address derivation is identical across every
|
|
55
|
+
* process that loads this config — required for multi-surface deployments
|
|
56
|
+
* (MCP + REST + UI) to agree on the operator's recipient identity. When
|
|
57
|
+
* undefined, ShroudAgent generates a random seed per boot.
|
|
58
|
+
*/
|
|
59
|
+
readonly masterSeed: Uint8Array | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* If non-empty, the HTTP transport rejects every authenticated request
|
|
62
|
+
* whose recovered wallet is not in this set. Stdio transport ignores it.
|
|
63
|
+
*/
|
|
64
|
+
readonly httpAllowedWallets: ReadonlySet<`0x${string}`>;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;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;CACzD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EIP-191 challenge-response auth for the HTTP transport.
|
|
3
|
+
*
|
|
4
|
+
* Flow:
|
|
5
|
+
* 1. Client POSTs /auth/challenge with their wallet address.
|
|
6
|
+
* 2. Server returns a fresh nonce + a canonical message string.
|
|
7
|
+
* 3. Client signs message with personal_sign / signMessage (EIP-191).
|
|
8
|
+
* 4. Client sends every subsequent request with:
|
|
9
|
+
* X-Shroudfi-Wallet: <0x… EOA>
|
|
10
|
+
* X-Shroudfi-Nonce: <nonce returned at step 2>
|
|
11
|
+
* X-Shroudfi-Signature: <0x… hex sig>
|
|
12
|
+
* 5. Server recovers, checks address match + expiry + allow-list.
|
|
13
|
+
*
|
|
14
|
+
* The signature is single-shot — once verifyAndConsume returns true for a
|
|
15
|
+
* nonce, the cache entry is deleted, so the same signed challenge cannot be
|
|
16
|
+
* replayed.
|
|
17
|
+
*
|
|
18
|
+
* Privacy: signature bytes never appear in logs, error messages, or response
|
|
19
|
+
* bodies. Errors are short tags only.
|
|
20
|
+
*/
|
|
21
|
+
import type { Hex } from 'viem';
|
|
22
|
+
import type { Eip191Challenge } from './types.js';
|
|
23
|
+
export interface AuthCache {
|
|
24
|
+
issue(wallet: `0x${string}`): Eip191Challenge;
|
|
25
|
+
verifyAndConsume(args: {
|
|
26
|
+
wallet: `0x${string}`;
|
|
27
|
+
nonce: Hex;
|
|
28
|
+
signature: Hex;
|
|
29
|
+
}): Promise<void>;
|
|
30
|
+
/** Test seam — drop expired entries. Called automatically on every op. */
|
|
31
|
+
prune(now?: number): void;
|
|
32
|
+
/** Returns the current size — test seam. */
|
|
33
|
+
size(): number;
|
|
34
|
+
}
|
|
35
|
+
declare function buildMessage(wallet: `0x${string}`, nonce: Hex, issuedAtMs: number): string;
|
|
36
|
+
export declare function createAuthCache(ttlMs?: number): AuthCache;
|
|
37
|
+
export declare const __auth_test__: {
|
|
38
|
+
buildMessage: typeof buildMessage;
|
|
39
|
+
};
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAOhC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,WAAW,SAAS;IACxB,KAAK,CAAC,MAAM,EAAE,KAAK,MAAM,EAAE,GAAG,eAAe,CAAC;IAC9C,gBAAgB,CAAC,IAAI,EAAE;QACrB,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC;QACtB,KAAK,EAAE,GAAG,CAAC;QACX,SAAS,EAAE,GAAG,CAAC;KAChB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClB,0EAA0E;IAC1E,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,4CAA4C;IAC5C,IAAI,IAAI,MAAM,CAAC;CAChB;AAID,iBAAS,YAAY,CAAC,MAAM,EAAE,KAAK,MAAM,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAWnF;AAED,wBAAgB,eAAe,CAC7B,KAAK,GAAE,MAAgC,GACtC,SAAS,CAgEX;AAED,eAAO,MAAM,aAAa;;CAAmB,CAAC"}
|
package/dist/esm/auth.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EIP-191 challenge-response auth for the HTTP transport.
|
|
3
|
+
*
|
|
4
|
+
* Flow:
|
|
5
|
+
* 1. Client POSTs /auth/challenge with their wallet address.
|
|
6
|
+
* 2. Server returns a fresh nonce + a canonical message string.
|
|
7
|
+
* 3. Client signs message with personal_sign / signMessage (EIP-191).
|
|
8
|
+
* 4. Client sends every subsequent request with:
|
|
9
|
+
* X-Shroudfi-Wallet: <0x… EOA>
|
|
10
|
+
* X-Shroudfi-Nonce: <nonce returned at step 2>
|
|
11
|
+
* X-Shroudfi-Signature: <0x… hex sig>
|
|
12
|
+
* 5. Server recovers, checks address match + expiry + allow-list.
|
|
13
|
+
*
|
|
14
|
+
* The signature is single-shot — once verifyAndConsume returns true for a
|
|
15
|
+
* nonce, the cache entry is deleted, so the same signed challenge cannot be
|
|
16
|
+
* replayed.
|
|
17
|
+
*
|
|
18
|
+
* Privacy: signature bytes never appear in logs, error messages, or response
|
|
19
|
+
* bodies. Errors are short tags only.
|
|
20
|
+
*/
|
|
21
|
+
import { randomBytes } from 'node:crypto';
|
|
22
|
+
import { recoverMessageAddress } from 'viem';
|
|
23
|
+
import { EIP191_CHALLENGE_TTL_MS } from './constants.js';
|
|
24
|
+
import { McpEip191ChallengeExpiredError, McpEip191SignatureInvalidError, McpUnauthorizedError, } from './errors.js';
|
|
25
|
+
const SHROUDFI_DOMAIN_MARK = 'ShroudFi MCP HTTP authentication';
|
|
26
|
+
function buildMessage(wallet, nonce, issuedAtMs) {
|
|
27
|
+
// The message is deliberately self-describing so a wallet UI shows the
|
|
28
|
+
// user the exact intent before signing. The nonce is the only random
|
|
29
|
+
// piece — it ties the signature to a single server-issued challenge.
|
|
30
|
+
return [
|
|
31
|
+
SHROUDFI_DOMAIN_MARK,
|
|
32
|
+
`Wallet: ${wallet}`,
|
|
33
|
+
`Nonce: ${nonce}`,
|
|
34
|
+
`Issued: ${new Date(issuedAtMs).toISOString()}`,
|
|
35
|
+
'Sign to prove control of this wallet.',
|
|
36
|
+
].join('\n');
|
|
37
|
+
}
|
|
38
|
+
export function createAuthCache(ttlMs = EIP191_CHALLENGE_TTL_MS) {
|
|
39
|
+
const store = new Map();
|
|
40
|
+
function makeKey(wallet, nonce) {
|
|
41
|
+
return `${wallet.toLowerCase()}|${nonce.toLowerCase()}`;
|
|
42
|
+
}
|
|
43
|
+
function prune(now = Date.now()) {
|
|
44
|
+
for (const [k, v] of store) {
|
|
45
|
+
if (v.expiresAtMs <= now)
|
|
46
|
+
store.delete(k);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
issue(wallet) {
|
|
51
|
+
prune();
|
|
52
|
+
const nonceBytes = randomBytes(16);
|
|
53
|
+
const nonce = `0x${nonceBytes.toString('hex')}`;
|
|
54
|
+
const now = Date.now();
|
|
55
|
+
const ch = {
|
|
56
|
+
wallet: wallet.toLowerCase(),
|
|
57
|
+
nonce,
|
|
58
|
+
issuedAtMs: now,
|
|
59
|
+
expiresAtMs: now + ttlMs,
|
|
60
|
+
message: buildMessage(wallet.toLowerCase(), nonce, now),
|
|
61
|
+
};
|
|
62
|
+
store.set(makeKey(ch.wallet, ch.nonce), ch);
|
|
63
|
+
return ch;
|
|
64
|
+
},
|
|
65
|
+
async verifyAndConsume({ wallet, nonce, signature }) {
|
|
66
|
+
// Don't prune before lookup — we want callers to see the explicit
|
|
67
|
+
// `auth_challenge_expired` code when their nonce has timed out, instead
|
|
68
|
+
// of an indistinguishable `unauthorized`.
|
|
69
|
+
const key = makeKey(wallet, nonce);
|
|
70
|
+
const ch = store.get(key);
|
|
71
|
+
if (ch === undefined) {
|
|
72
|
+
throw new McpUnauthorizedError();
|
|
73
|
+
}
|
|
74
|
+
if (ch.expiresAtMs <= Date.now()) {
|
|
75
|
+
store.delete(key);
|
|
76
|
+
throw new McpEip191ChallengeExpiredError();
|
|
77
|
+
}
|
|
78
|
+
let recovered;
|
|
79
|
+
try {
|
|
80
|
+
recovered = await recoverMessageAddress({
|
|
81
|
+
message: ch.message,
|
|
82
|
+
signature,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
throw new McpEip191SignatureInvalidError();
|
|
87
|
+
}
|
|
88
|
+
if (recovered.toLowerCase() !== ch.wallet.toLowerCase()) {
|
|
89
|
+
throw new McpEip191SignatureInvalidError();
|
|
90
|
+
}
|
|
91
|
+
// Single-use: consume the nonce so the signed challenge can't be replayed.
|
|
92
|
+
store.delete(key);
|
|
93
|
+
},
|
|
94
|
+
prune,
|
|
95
|
+
size: () => store.size,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export const __auth_test__ = { buildMessage };
|
|
99
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,MAAM,CAAC;AAE7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EACL,8BAA8B,EAC9B,8BAA8B,EAC9B,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAgBrB,MAAM,oBAAoB,GAAG,kCAAkC,CAAC;AAEhE,SAAS,YAAY,CAAC,MAAqB,EAAE,KAAU,EAAE,UAAkB;IACzE,uEAAuE;IACvE,qEAAqE;IACrE,qEAAqE;IACrE,OAAO;QACL,oBAAoB;QACpB,WAAW,MAAM,EAAE;QACnB,UAAU,KAAK,EAAE;QACjB,WAAW,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,EAAE;QAC/C,uCAAuC;KACxC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,QAAgB,uBAAuB;IAEvC,MAAM,KAAK,GAAG,IAAI,GAAG,EAA2B,CAAC;IAEjD,SAAS,OAAO,CAAC,MAAqB,EAAE,KAAU;QAChD,OAAO,GAAG,MAAM,CAAC,WAAW,EAAE,IAAI,KAAK,CAAC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