@opentiny/next 0.0.1 → 0.1.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/package.json CHANGED
@@ -1,20 +1,29 @@
1
1
  {
2
2
  "name": "@opentiny/next",
3
- "version": "0.0.1",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Chunhui Mo",
7
7
  "files": [
8
8
  "client.js",
9
- "server.js"
9
+ "client.d.ts",
10
+ "server.js",
11
+ "server.d.ts"
10
12
  ],
11
13
  "main": "client.js",
12
14
  "module": "client.js",
13
15
  "description": "OpenTiny NEXT",
14
16
  "dependencies": {
15
- "@modelcontextprotocol/sdk": "^1.10.2",
17
+ "@modelcontextprotocol/sdk": "^1.11.0",
16
18
  "jsonwebtoken": "^9.0.2",
17
- "zod": "^3.24.2"
19
+ "zod": "^3.24.4"
20
+ },
21
+ "peerDependencies": {
22
+ "express": "^4.21.2"
23
+ },
24
+ "devDependencies": {
25
+ "@types/express": "^5.0.1",
26
+ "@types/jsonwebtoken": "^9.0.9"
18
27
  },
19
28
  "engines": {
20
29
  "node": "^18.0.0 || >=20.0.0"
package/server.d.ts ADDED
@@ -0,0 +1,91 @@
1
+ import jwt, { JwtPayload } from 'jsonwebtoken';
2
+ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
3
+ import { Request, Response, NextFunction } from 'express';
4
+
5
+ /**
6
+ * 客户端连接的信息,包括客户端实例、用户信息和 Transport 类型
7
+ */
8
+ interface ClientInfo {
9
+ /**
10
+ * MCP 客户端实例
11
+ */
12
+ client: Client;
13
+ /**
14
+ * 连接的用户信息
15
+ */
16
+ user?: JwtPayload | string;
17
+ /**
18
+ * 用于识别不同连接的信息
19
+ */
20
+ device: {
21
+ /**
22
+ * 连接的来源 IP 地址,可能是 IPv4 或 IPv6 地址
23
+ */
24
+ ip: string | string[];
25
+ /**
26
+ * 识别浏览器类型和版本 User-Agent 字符串
27
+ */
28
+ userAgent: string;
29
+ /**
30
+ * 连接的语言设置,通常是浏览器的 Accept-Language 字段
31
+ */
32
+ acceptLanguage: string;
33
+ /**
34
+ * 连接的来源 URL,通常是 HTTP Referer 字段
35
+ */
36
+ referer: string;
37
+ };
38
+ /**
39
+ * 客户端连接的 Transport 类型
40
+ */
41
+ type: 'SSE' | 'StreamableHTTP';
42
+ }
43
+ /**
44
+ * Express 请求对象的扩展,添加了可选的用户信息属性
45
+ */
46
+ declare module 'express' {
47
+ interface Request {
48
+ user?: JwtPayload | string;
49
+ }
50
+ }
51
+ /**
52
+ * 认证中间件,用于校验 JWT Token。
53
+ *
54
+ * 检查请求头中的 Authorization 字段,提取并校验 Bearer Token。
55
+ * 校验通过后,将解码后的用户信息挂载到 req.user。
56
+ * 校验失败或缺失 token 时,返回 401 或 403 错误。
57
+ */
58
+ declare const auth: ({ secret }: {
59
+ secret: string;
60
+ }) => (req: Request, res: Response, next: NextFunction) => void;
61
+ /**
62
+ * 根据签名的密钥生成 JWT Token
63
+ *
64
+ * @param payload - JWT Token 的载荷,包含用户信息等
65
+ * @param secret - 用于签名的密钥
66
+ * @param signOption - 签名选项,默认过期时间 30 天,默认算法 HS256
67
+ * @returns - 生成的 JWT Token
68
+ */
69
+ declare const signToken: (payload: object, secret: string, signOption?: jwt.SignOptions) => string;
70
+ /**
71
+ * 验证 JWT Token,如果验证失败,比如 Token 过期、签名不匹配等,将抛出错误异常。
72
+ *
73
+ * @param token - 要验证的 JWT Token
74
+ * @param secret - 用于验证的密钥
75
+ * @returns - 解码后的 JWT Token 载荷,包含用户信息等
76
+ */
77
+ declare const verifyToken: (token: string, secret: string) => any;
78
+ /**
79
+ * SSE 与 Streamable HTTP 连接的处理函数,同时返回所有客户端代理实例
80
+ */
81
+ declare const useProxyHandles: () => {
82
+ handleSseProxy: (req: Request, res: Response, endpoint: string) => Promise<void>;
83
+ handleSseInspector: (req: Request, res: Response, endpoint: string) => Promise<void>;
84
+ handleSseMessage: (req: Request, res: Response) => Promise<void>;
85
+ handleStreamRequest: (req: Request, res: Response) => Promise<void>;
86
+ handleStreamInspector: (req: Request, res: Response) => Promise<void>;
87
+ clients: Record<string, ClientInfo>;
88
+ };
89
+
90
+ export { auth, signToken, useProxyHandles, verifyToken };
91
+ export type { ClientInfo };
package/server.js CHANGED
@@ -1,219 +1,273 @@
1
- import k from "jsonwebtoken";
2
- import { McpServer as E } from "@modelcontextprotocol/sdk/server/mcp.js";
3
- import { Client as T } from "@modelcontextprotocol/sdk/client/index.js";
4
- import { SSEServerTransport as V } from "@modelcontextprotocol/sdk/server/sse.js";
5
- import { StreamableHTTPServerTransport as J } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
6
- import { isInitializeRequest as P } from "@modelcontextprotocol/sdk/types.js";
7
- function v() {
8
- const e = ["40ghLnek", "7980140dDASYG", "JvVNa", "DvCDG", "kfWRb", "prompts/get", "onmessage", "completion/complete", "send", "callTool", "setLoggingLevel", "resources/unsubscribe", "222hqihXy", "1678XyeuGi", "listPrompts", "tools/list", "logging/setLevel", "listTools", "8XxqwZi", "3051684ntcRnK", "NeBcV", "11716310OyJSdP", "resources/list", "RUQsw", "complete", "RqvEE", "43413BNLEOk", "call", "tools/call", "422886BXoftZ", "listResourceTemplates", "listResources", "332gnQqOU", "readResource", "LpDjz", "resources/read", "unsubscribeResource", "gbwvY", "resources/templates/list", "ping", "pvsVK", "lnGdZ", "20769705ecWcKi", "_client"];
9
- return v = function() {
10
- return e;
11
- }, v();
12
- }
13
- function w(e, s) {
14
- const x = v();
15
- return w = function(t, a) {
16
- return t = t - (-17 * -497 + 7 * 1387 + -17724), x[t];
17
- }, w(e, s);
18
- }
19
- (function(e, s) {
20
- const x = w, t = e();
1
+ import R from "jsonwebtoken";
2
+ import { McpServer as P } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { Client as G } from "@modelcontextprotocol/sdk/client/index.js";
4
+ import { SSEServerTransport as E } from "@modelcontextprotocol/sdk/server/sse.js";
5
+ import { StreamableHTTPServerTransport as C } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
6
+ import { isInitializeRequest as D } from "@modelcontextprotocol/sdk/types.js";
7
+ (function(e, a) {
8
+ const x = _, s = e();
21
9
  for (; ; )
22
10
  try {
23
- if (parseInt(x(450)) / 1 * (parseInt(x(449)) / 2) + -parseInt(x(463)) / 3 * (parseInt(x(469)) / 4) + parseInt(x(437)) / 5 * (-parseInt(x(466)) / 6) + parseInt(x(438)) / 7 * (parseInt(x(455)) / 8) + parseInt(x(456)) / 9 + -parseInt(x(458)) / 10 + parseInt(x(435)) / 11 === s) break;
24
- t.push(t.shift());
11
+ if (-parseInt(x(214)) / 1 + -parseInt(x(218)) / 2 + -parseInt(x(209)) / 3 * (-parseInt(x(215)) / 4) + -parseInt(x(180)) / 5 * (-parseInt(x(206)) / 6) + -parseInt(x(202)) / 7 * (-parseInt(x(216)) / 8) + -parseInt(x(178)) / 9 + -parseInt(x(187)) / 10 * (-parseInt(x(196)) / 11) === a) break;
12
+ s.push(s.shift());
25
13
  } catch {
26
- t.push(t.shift());
14
+ s.push(s.shift());
15
+ }
16
+ })(v, 21221 + 415033 * -3 + 1911515 * 1);
17
+ const J = async (e, a) => {
18
+ const x = _, s = { LHerf: x(190), emwBK: x(201), HohQv: "resources/read", WQgCS: x(195), Xzrrt: x(179), cXnlb: "ping", RFwiY: x(198), Ahdht: "logging/setLevel", gQXkS: x(182) };
19
+ let r;
20
+ const { id: o, method: l, params: u } = a;
21
+ if (l) {
22
+ switch (l) {
23
+ case s[x(217)]:
24
+ r = await e._client[x(207)](u);
25
+ break;
26
+ case x(175):
27
+ r = await e[x(186)][x(189)](u);
28
+ break;
29
+ case "resources/list":
30
+ r = await e._client[x(181)](u);
31
+ break;
32
+ case s[x(191)]:
33
+ r = await e[x(186)].listResourceTemplates(u);
34
+ break;
35
+ case s[x(177)]:
36
+ r = await e._client[x(193)](u);
37
+ break;
38
+ case x(212):
39
+ r = await e._client.subscribeResource(u);
40
+ break;
41
+ case s[x(184)]:
42
+ r = await e[x(186)][x(176)](u);
43
+ break;
44
+ case s[x(185)]:
45
+ r = await e[x(186)][x(208)](u);
46
+ break;
47
+ case x(210):
48
+ r = await e[x(186)][x(199)](u);
49
+ break;
50
+ case s[x(211)]:
51
+ r = await e._client.ping();
52
+ break;
53
+ case s[x(183)]:
54
+ r = await e[x(186)][x(200)](u);
55
+ break;
56
+ case s[x(192)]:
57
+ r = await e[x(186)][x(203)](u);
58
+ break;
27
59
  }
28
- })(v, 206 * -3206 + 572580 + 3 * 234931);
29
- const j = async (e, s) => {
30
- const x = w, t = { JLGsi: x(465), gbwvY: x(459), kfWRb: x(475), woBkd: x(472), JvVNa: x(442), NeBcV: "prompts/list", lnGdZ: x(476), RUQsw: x(444), DvCDG: x(453), pvsVK: "2.0" };
31
- let a;
32
- const { id: i, method: l, params: b } = s;
33
- switch (l) {
34
- case x(452):
35
- a = await e[x(436)][x(454)](b);
36
- break;
37
- case t.JLGsi:
38
- a = await e[x(436)][x(446)](b);
39
- break;
40
- case t[x(474)]:
41
- a = await e[x(436)][x(468)](b);
42
- break;
43
- case t[x(441)]:
44
- a = await e[x(436)][x(467)](b);
45
- break;
46
- case t.woBkd:
47
- a = await e._client[x(470)](b);
48
- break;
49
- case "resources/subscribe":
50
- a = await e[x(436)].subscribeResource(b);
51
- break;
52
- case x(448):
53
- a = await e[x(436)][x(473)](b);
54
- break;
55
- case t[x(439)]:
56
- a = await e[x(436)].getPrompt(b);
57
- break;
58
- case t[x(457)]:
59
- a = await e[x(436)][x(451)](b);
60
- break;
61
- case t[x(434)]:
62
- a = await e[x(436)][x(476)]();
63
- break;
64
- case t[x(460)]:
65
- a = await e._client[x(461)](b);
66
- break;
67
- case t[x(440)]:
68
- a = await e._client[x(447)](b);
69
- break;
60
+ return r && await e[x(188)]({ result: r, jsonrpc: s[x(205)], id: o }), r;
70
61
  }
71
- return a && await e[x(445)]({ result: a, jsonrpc: t[x(477)], id: i }), a;
72
- }, G = (e) => {
73
- const s = w, x = { LpDjz: function(a, i, l) {
74
- return a(i, l);
75
- }, RqvEE: function(a, i) {
76
- return a === i;
77
- } }, t = e[s(443)];
78
- e[s(443)] = async (a) => {
79
- const i = s;
80
- if (e[i(436)]) {
81
- const l = await x[i(471)](j, e, a);
82
- x[i(462)](l, void 0) && t && t[i(464)](e, a);
62
+ };
63
+ function _(e, a) {
64
+ const x = v();
65
+ return _ = function(s, r) {
66
+ return s = s - (1 * -9967 + -4408 + 150 * 97), x[s];
67
+ }, _(e, a);
68
+ }
69
+ const V = (e) => {
70
+ const a = _, x = { ZSjeW: function(r, o, l) {
71
+ return r(o, l);
72
+ }, SdJQA: function(r, o) {
73
+ return r === o;
74
+ } }, s = e[a(197)];
75
+ e[a(197)] = async (r) => {
76
+ const o = a;
77
+ if (e._client) {
78
+ let l;
79
+ try {
80
+ l = await x[o(204)](J, e, r);
81
+ } catch {
82
+ }
83
+ if (x[o(213)](l, void 0) && s) try {
84
+ s[o(194)](e, r);
85
+ } catch {
86
+ }
83
87
  }
84
88
  };
85
89
  };
86
- var D = I;
87
- (function(e, s) {
88
- for (var x = I, t = e(); ; )
90
+ function v() {
91
+ const e = ["tools/call", "unsubscribeResource", "HohQv", "2695725XEZTcm", "prompts/get", "15CDBgfz", "listResources", "2.0", "RFwiY", "WQgCS", "Xzrrt", "_client", "10ztjwvo", "send", "callTool", "tools/list", "emwBK", "Ahdht", "readResource", "call", "resources/unsubscribe", "13116598RDpWam", "onmessage", "completion/complete", "listPrompts", "complete", "resources/templates/list", "70658JIuKys", "setLoggingLevel", "ZSjeW", "gQXkS", "378336OAexTi", "listTools", "getPrompt", "34179buwJLm", "prompts/list", "cXnlb", "resources/subscribe", "SdJQA", "613434GgqIlU", "24KfGjls", "352PgssEG", "LHerf", "586968oouJmA"];
92
+ return v = function() {
93
+ return e;
94
+ }, v();
95
+ }
96
+ function w(e, a) {
97
+ var x = y();
98
+ return w = function(s, r) {
99
+ s = s - (-43 * 217 + 7655 + -113 * -19);
100
+ var o = x[s];
101
+ return o;
102
+ }, w(e, a);
103
+ }
104
+ (function(e, a) {
105
+ for (var x = w, s = e(); ; )
89
106
  try {
90
- var a = -parseInt(x(436)) / 1 + -parseInt(x(442)) / 2 + -parseInt(x(437)) / 3 + -parseInt(x(439)) / 4 * (-parseInt(x(433)) / 5) + -parseInt(x(438)) / 6 * (-parseInt(x(444)) / 7) + parseInt(x(435)) / 8 * (parseInt(x(432)) / 9) + parseInt(x(440)) / 10 * (parseInt(x(441)) / 11);
91
- if (a === s) break;
92
- t.push(t.shift());
107
+ var r = parseInt(x(471)) / 1 + parseInt(x(481)) / 2 * (parseInt(x(475)) / 3) + parseInt(x(473)) / 4 * (-parseInt(x(472)) / 5) + -parseInt(x(482)) / 6 + parseInt(x(476)) / 7 + -parseInt(x(478)) / 8 + -parseInt(x(480)) / 9 * (-parseInt(x(477)) / 10);
108
+ if (r === a) break;
109
+ s.push(s.shift());
93
110
  } catch {
94
- t.push(t.shift());
111
+ s.push(s.shift());
95
112
  }
96
- })(_, 1 * 180938 + -164677 + 122845 * 1);
97
- function _() {
98
- var e = ["JbWIK", "7PvIdfa", "handleMessage", "7452kBaxsX", "5hAcjWQ", "_client", "264kiyxhA", "274715KWZWnr", "90723qFebmp", "1444614sGuODB", "42628QIsDgS", "1538770EIZnHd", "22iTKJpK", "284884YIVAfn"];
99
- return _ = function() {
113
+ })(y, -300663 * 1 + -46 * 3722 + -4 * -157219);
114
+ function y() {
115
+ var e = ["736940YvXfNU", "_client", "351VaYOnl", "2054339FKDeBh", "10iDnLyM", "1006992tpTscA", "handleMessage", "96147EaQlKd", "3764PZZCEc", "360384sMoAEh", "2820IAqjWz", "5sHGHIA"];
116
+ return y = function() {
100
117
  return e;
101
- }, _();
118
+ }, y();
102
119
  }
103
- function I(e, s) {
104
- var x = _();
105
- return I = function(t, a) {
106
- t = t - (-35 * -213 + -98 * -17 + -8689);
107
- var i = x[t];
108
- return i;
109
- }, I(e, s);
120
+ class Y extends E {
121
+ constructor(a, x, s) {
122
+ var r = w;
123
+ super(a, x), this[r(474)] = s;
124
+ }
125
+ async handleMessage(a) {
126
+ var x = w;
127
+ V(this), await super[x(479)](a);
128
+ }
110
129
  }
111
- class Q extends V {
112
- constructor(s, x, t) {
113
- var a = I;
114
- super(s, x), this[a(434)] = t;
130
+ var H = g;
131
+ function g(e, a) {
132
+ var x = S();
133
+ return g = function(s, r) {
134
+ s = s - (175 * 44 + 5283 + -12719);
135
+ var o = x[s];
136
+ return o;
137
+ }, g(e, a);
138
+ }
139
+ (function(e, a) {
140
+ for (var x = g, s = e(); ; )
141
+ try {
142
+ var r = -parseInt(x(269)) / 1 * (parseInt(x(275)) / 2) + -parseInt(x(278)) / 3 * (parseInt(x(264)) / 4) + -parseInt(x(272)) / 5 * (-parseInt(x(277)) / 6) + parseInt(x(276)) / 7 * (-parseInt(x(265)) / 8) + -parseInt(x(274)) / 9 * (-parseInt(x(267)) / 10) + parseInt(x(270)) / 11 * (parseInt(x(271)) / 12) + parseInt(x(268)) / 13;
143
+ if (r === a) break;
144
+ s.push(s.shift());
145
+ } catch {
146
+ s.push(s.shift());
147
+ }
148
+ })(S, 338708 + 8830 * 52 + -113446);
149
+ class j extends C {
150
+ constructor(a, x) {
151
+ var s = g;
152
+ super(a), this[s(279)] = x;
115
153
  }
116
- async [D(445)](s) {
117
- var x = D, t = { JbWIK: function(a, i) {
118
- return a(i);
154
+ async [H(266)](a, x, s) {
155
+ var r = H, o = { iVowj: function(l, u) {
156
+ return l(u);
119
157
  } };
120
- t[x(443)](G, this), await super[x(445)](s);
158
+ o[r(273)](V, this), await super[r(266)](a, x, s);
121
159
  }
122
160
  }
123
- const y = h;
124
- function g() {
125
- const e = ["VvQjC", "_notificationHandlers", "vVdrj", "close", "Invalid or missing session ID", "No transport found", "body", "initialize", "hXAGK", "verify", "user", "MoeVJ", "2.0", "17790IVaKVa", "1206zSexRs", "mcp-session-id", "ejUhf", "notifications/initialized", "MLcwn", "client", "JnLxl", "writeHead", "1167984bKmTXI", "params", "Method not allowed.", "capabilities", "30 days", "json", "split", "fgOBA", "TsvGH", "1441gQHOjh", "rmhSH", "end", "headers", "APLQY", "4784eQEDDO", "send", "953496ufBuiH", "QDlIF", "protocolVersion", "POST", "OEuFV", "iODQK", "stringify", "Invalid token", "Bad Request: No valid session ID provided", "mcp-client", "DELETE", "GET", "authorization", "1.0.0", "TiFXP", "JJRrj", "method", "9674iCllrc", "connect", "LdDvS", "Missing token", "No client found", "status", "_requestHandlers", "sessionId", "kiuPw", "sse", "1600614QKtxUt", "streamable-session-id", "message", "handleRequest", "1394aZMmXF", "mcp-server", "streamable", "kxjBS", "4rwcmPk", "2091730pvfidK", "HS256", "yzXtw", "set"];
126
- return g = function() {
161
+ function S() {
162
+ var e = ["_client", "6428lqivWx", "29288CzqRmW", "handlePostRequest", "690RHSMrO", "26362180eTNHMT", "2hDVhMr", "9099937trIaXV", "12VhPJUq", "95tarehR", "iVowj", "71433IELkru", "1122424QxeVeD", "2513qtRRon", "48588ccGIEj", "813iFSbuL"];
163
+ return S = function() {
127
164
  return e;
128
- }, g();
165
+ }, S();
129
166
  }
130
- (function(e, s) {
131
- const x = h, t = e();
167
+ const h = m;
168
+ (function(e, a) {
169
+ const x = m, s = e();
132
170
  for (; ; )
133
171
  try {
134
- if (parseInt(x(501)) / 1 * (parseInt(x(556)) / 2) + -parseInt(x(552)) / 3 + parseInt(x(560)) / 4 * (-parseInt(x(561)) / 5) + parseInt(x(509)) / 6 + parseInt(x(542)) / 7 * (parseInt(x(523)) / 8) + -parseInt(x(525)) / 9 + parseInt(x(500)) / 10 * (-parseInt(x(518)) / 11) === s) break;
135
- t.push(t.shift());
172
+ if (parseInt(x(459)) / 1 * (parseInt(x(458)) / 2) + parseInt(x(445)) / 3 + -parseInt(x(431)) / 4 * (parseInt(x(429)) / 5) + parseInt(x(472)) / 6 + -parseInt(x(440)) / 7 * (parseInt(x(434)) / 8) + parseInt(x(442)) / 9 + -parseInt(x(411)) / 10 * (parseInt(x(420)) / 11) === a) break;
173
+ s.push(s.shift());
136
174
  } catch {
137
- t.push(t.shift());
175
+ s.push(s.shift());
138
176
  }
139
- })(g, 570805);
140
- function h(e, s) {
141
- const x = g();
142
- return h = function(t, a) {
143
- return t = t - (7451 + 1739 * -4), x[t];
144
- }, h(e, s);
177
+ })(T, 428917);
178
+ function T() {
179
+ const e = ["742479MVxrxP", "GET", "query", "Missing bearer token", "set", "sessionId", "initialize", "RCaLJ", "JrMYw", "HS256", "end", "client", "OVFyq", "38rqoYCF", "28631UjGtnn", "zJmYG", "LUYAp", "body", "accept-language", "GET, POST, DELETE", "uGodP", "1.0.0", "StreamableHTTP", "close", "mcp-session-id", "wqTCu", "DELETE", "2229096JGmqCd", "Method not allowed.", "user", "verify", "notifications/initialized", "connect", "Invalid bearer token", "POST", "stringify", "No transport found", "writeHead", "1041010qkMaha", "zylKo", "mcp-proxy-client", "PaIlR", "handleRequest", "capabilities", "method", "ocgfq", "x-forwarded-for", "88BGFsTF", "WlTKY", "SSE", "protocolVersion", "OtdPb", "mcp-proxy-server", "_requestHandlers", "xoTOd", "json", "10HeuyKH", "uMAyY", "791068KxqRiz", "DLIhP", "No client found", "196712oeSOuj", "headers", "VmBCX", "params", "authorization", "Bad Request: No valid session ID provided", "28pbCSNl", "status", "5333553Iaseks", "cemcS", "send"];
180
+ return T = function() {
181
+ return e;
182
+ }, T();
145
183
  }
146
- const N = ({ secret: e }) => (s, x, t) => {
147
- var b;
148
- const a = h, i = { yzXtw: a(545), MLcwn: function(p) {
149
- return p();
150
- }, iODQK: a(532) }, l = (b = s.headers[a(537)]) == null ? void 0 : b[a(515)](" ")[16 * -223 + -8468 + 12037];
151
- if (!l) return x[a(547)](-3780 + 37 * 113)[a(524)](i[a(563)]);
184
+ function m(e, a) {
185
+ const x = T();
186
+ return m = function(s, r) {
187
+ return s = s - (-9661 * 1 + 857 + 9214), x[s];
188
+ }, m(e, a);
189
+ }
190
+ const N = ({ secret: e }) => (a, x, s) => {
191
+ var u;
192
+ const r = m, o = { LUYAp: r(478) }, l = (u = a[r(435)][r(438)]) == null ? void 0 : u.split(" ")[1];
193
+ if (!l) {
194
+ x[r(441)](5745 + -167 * 32).send(r(448));
195
+ return;
196
+ }
152
197
  try {
153
- s[a(497)] = k[a(496)](l, e), i[a(505)](t);
154
- } catch (p) {
155
- x[a(547)](-2235 + -1 * -6541 + -1301 * 3)[a(514)]({ error: i[a(530)], details: p[a(554)] });
198
+ a[r(474)] = R[r(475)](l, e), s();
199
+ } catch (q) {
200
+ x.status(-4735 * -1 + 5095 + 857 * -11)[r(428)]({ error: o[r(461)], details: q.message });
156
201
  }
157
- }, z = (e, s, x = { expiresIn: y(513), algorithm: y(562) }) => k.sign(e, s, x), U = (e, s) => k.verify(e, s), F = () => {
158
- const e = y, s = { LdDvS: e(568), MoeVJ: e(534), APLQY: "1.0.0", JXIlP: e(551), wiIii: e(557), rmhSH: function(r, c) {
159
- return r === c;
160
- }, vVdrj: e(528), OEuFV: function(r, c, n) {
161
- return r(c, n);
162
- }, VvQjC: function(r, c) {
163
- return r === c;
164
- }, QDlIF: "GET, POST, DELETE", kxjBS: e(499), UwKNl: e(502), JJRrj: function(r, c) {
165
- return r === c;
166
- }, JnLxl: e(535), VySIR: e(569), hXAGK: e(553), fgOBA: function(r, c) {
167
- return r(c);
168
- }, TsvGH: e(504), kiuPw: e(572), ejUhf: e(558), TiFXP: e(533) }, x = {}, t = {}, a = async (r, c, n) => {
169
- const o = e, f = new V(n, c), d = f[o(549)];
170
- x[d] = f, r.on(s[o(544)], () => {
171
- f.close(), delete x[d], delete t[d];
202
+ }, U = (e, a, x = { expiresIn: "30 days", algorithm: h(454) }) => R.sign(e, a, x), Z = (e, a) => R[h(475)](e, a), M = (e) => ({ ip: e.headers[h(419)] || e.ip || "", userAgent: e[h(435)]["user-agent"] || "", acceptLanguage: e[h(435)][h(463)] || "", referer: e[h(435)].referer || "" }), $ = () => {
203
+ const e = h, a = { DLIhP: e(468), ocgfq: e(413), OtdPb: e(466), RCaLJ: function(n, c) {
204
+ return n(c);
205
+ }, uGodP: e(422), VmBCX: e(433), zylKo: e(425), cemcS: function(n, c) {
206
+ return n === c;
207
+ }, pFHDd: e(479), OVFyq: function(n, c, t) {
208
+ return n(c, t);
209
+ }, zJmYG: e(471), PaIlR: e(464), WlTKY: "2.0", JrMYw: e(473), wqTCu: "Invalid or missing session ID", kiVuv: "stream-session-id", BLfLq: e(451), xoTOd: function(n, c) {
210
+ return n(c);
211
+ }, uMAyY: e(467) }, x = {}, s = {}, r = async (n, c, t) => {
212
+ const i = e, d = new E(t, c), b = d.sessionId;
213
+ x[b] = d, n.on(a.DLIhP, () => {
214
+ d[m(468)](), delete x[b], delete s[b];
172
215
  });
173
- const u = new T({ name: s[o(498)], version: s.APLQY });
174
- t[d] = { client: u, user: r[o(497)], type: s.JXIlP }, await u[o(543)](f);
175
- }, i = async (r, c, n) => {
176
- var S, R;
177
- const o = e, f = (R = t[(S = r.query) == null ? void 0 : S[o(549)]]) == null ? void 0 : R[o(506)];
178
- if (!f) {
179
- c[o(547)](7124 + 1 * 4002 + -10726)[o(524)](o(546));
216
+ const f = { prompts: {}, resources: {}, tools: {}, logging: {} }, p = new G({ name: a[i(418)], version: a.OtdPb }, { capabilities: f });
217
+ s[b] = { client: p, user: n.user, device: a[i(452)](M, n), type: a[i(465)] }, await p[i(477)](d);
218
+ }, o = async (n, c, t) => {
219
+ var L;
220
+ const i = e, d = n.query[i(450)], b = (L = s[d]) == null ? void 0 : L[i(456)];
221
+ if (!b) {
222
+ c[i(441)](-106 * 43 + 9187 + -4229).send(a.VmBCX);
180
223
  return;
181
224
  }
182
- const d = new Q(n, c, f), u = d.sessionId;
183
- x[u] = d, r.on(s[o(544)], () => {
184
- d.close(), delete x[u];
225
+ const f = new Y(t, c, b), p = f.sessionId;
226
+ x[p] = f, n.on(a[i(432)], () => {
227
+ f.close(), delete x[p];
185
228
  });
186
- const m = { prompts: {}, resources: {}, tools: {}, logging: {} };
187
- await new E({ name: s.wiIii, version: s[o(522)] }, { capabilities: m })[o(543)](d);
188
- }, l = async (r, c) => {
189
- const n = e, o = r.query[n(549)], f = x[o];
190
- f ? await f.handlePostMessage(r, c) : c.status(1 * 1388 + 19 * 314 + -6954).send(n(570));
191
- }, b = async (r, c) => {
192
- const n = e;
193
- s[n(519)](r[n(541)], s[n(567)]) ? await s[n(529)](L, r, c) : r[n(541)] === n(536) || s[n(565)](r.method, n(535)) ? await s[n(529)](K, r, c) : await p(c);
194
- }, p = async (r) => {
229
+ const I = { prompts: {}, resources: {}, tools: {}, logging: {} };
230
+ await new P({ name: a[i(412)], version: a[i(424)] }, { capabilities: I })[i(477)](f);
231
+ }, l = async (n, c) => {
232
+ const t = e, i = n.query[t(450)], d = x[i];
233
+ d ? await d.handlePostMessage(n, c) : c.status(2771 + 694 * -2 + 1 * -983).send(t(481));
234
+ }, u = async (n, c) => {
235
+ const t = e;
236
+ a[t(443)](n[t(417)], a.pFHDd) ? await a[t(457)](A, n, c) : a[t(443)](n.method, t(446)) || a.cemcS(n[t(417)], a[t(460)]) ? await a[t(457)](z, n, c) : await a[t(452)](q, c);
237
+ }, q = async (n) => {
195
238
  const c = e;
196
- r[c(508)](1 * 1354 + -3672 + -2723 * -1, { Allow: s[c(526)] })[c(520)](JSON[c(531)]({ jsonrpc: s[c(559)], error: { code: -32e3, message: c(511) }, id: null }));
197
- }, K = async (r, c) => {
198
- const n = e, o = r[n(521)][s.UwKNl], f = x[o];
199
- f ? (await f.handleRequest(r, c), s[n(540)](r[n(541)], s[n(507)]) && f.validateSession(r, c) && (delete x[o], delete t[o])) : c[n(547)](400)[n(524)](s.VySIR);
200
- }, L = async (r, c) => {
201
- const n = e, o = r[n(521)][s.UwKNl], f = r[n(521)][s[n(495)]];
202
- let d = x[o];
203
- if (d) await d.handleRequest(r, c, r[n(571)]);
204
- else if (!o && s[n(516)](P, r[n(571)])) {
205
- d = new J({ sessionIdGenerator: () => f });
206
- const u = new T({ name: s[n(498)], version: s[n(522)] });
207
- u[n(566)].set(s[n(517)], () => {
208
- }), u[n(548)][n(564)](s[n(550)], (m) => ({ protocolVersion: m[n(510)][n(527)], capabilities: m.params[n(512)], serverInfo: { name: n(557), version: n(538) } })), t[f] = { client: u, user: r[n(497)], type: s[n(503)] }, x[f] = d, d[n(549)] = f, await u.connect(d), await d[n(555)](r, c, r[n(571)]);
209
- } else c[n(547)](400)[n(514)]({ jsonrpc: s[n(559)], error: { code: -32e3, message: s[n(539)] }, id: null });
239
+ n[c(410)](-80 + -7 * 593 + 4636, { Allow: a[c(414)] })[c(455)](JSON[c(480)]({ jsonrpc: a[c(421)], error: { code: -32e3, message: a[c(453)] }, id: null }));
240
+ }, z = async (n, c) => {
241
+ const t = e, i = n[t(435)][t(469)], d = x[i];
242
+ d ? (await d[t(415)](n, c), n[t(417)] === a.zJmYG && (delete x[i], delete s[i])) : c[t(441)](-25 * -155 + 97 * 49 + 121 * -68)[t(444)](a[t(470)]);
243
+ }, A = async (n, c) => {
244
+ const t = e, i = n.headers[t(469)], d = n[t(435)][a.kiVuv];
245
+ let b = x[i];
246
+ if (b) await b[t(415)](n, c, n[t(462)]);
247
+ else if (!i && a.RCaLJ(D, n[t(462)])) {
248
+ b = new C({ sessionIdGenerator: () => d });
249
+ const f = { prompts: {}, resources: {}, tools: {}, logging: {} }, p = new G({ name: a[t(418)], version: a[t(424)] }, { capabilities: f });
250
+ p._notificationHandlers.set(t(476), () => {
251
+ }), p[t(426)][t(449)](a.BLfLq, (I) => ({ protocolVersion: I[t(437)][t(423)], capabilities: I[t(437)][t(416)], serverInfo: { name: "mcp-server", version: t(466) } })), s[d] = { client: p, user: n[t(474)], device: a[t(427)](M, n), type: a[t(430)] }, x[d] = b, b.sessionId = d, await p[t(477)](b), await b.handleRequest(n, c, n[t(462)]);
252
+ } else c.status(1604 * 4 + 8837 + 1 * -14853)[t(428)]({ jsonrpc: a[t(421)], error: { code: -32e3, message: t(439) }, id: null });
210
253
  };
211
- return { handleProxy: a, handleInspector: i, handleMessage: l, handleRequest: b, clients: t };
254
+ return { handleSseProxy: r, handleSseInspector: o, handleSseMessage: l, handleStreamRequest: u, handleStreamInspector: async (n, c) => {
255
+ var I;
256
+ const t = e, i = n[t(447)].sessionId, d = (I = s[i]) == null ? void 0 : I[t(456)];
257
+ if (!d) {
258
+ c[t(441)](-8 * -500 + -4 * -599 + -5996)[t(444)](a[t(436)]);
259
+ return;
260
+ }
261
+ const b = new j({ sessionIdGenerator: void 0 }, d), f = { prompts: {}, resources: {}, tools: {}, logging: {} }, p = new P({ name: "mcp-proxy-server", version: a[t(424)] }, { capabilities: f });
262
+ await p[t(477)](b), await b[t(415)](n, c, n[t(462)]), c.on(t(468), () => {
263
+ const k = t;
264
+ b[k(468)](), p[k(468)]();
265
+ });
266
+ }, clients: s };
212
267
  };
213
268
  export {
214
- Q as GatewaySSEServerTransport,
215
269
  N as auth,
216
- z as signToken,
217
- F as useHandles,
218
- U as verifyToken
270
+ U as signToken,
271
+ $ as useProxyHandles,
272
+ Z as verifyToken
219
273
  };