@shin1ohno/sage 0.3.0 → 0.5.5
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/dist/cli/http-server-with-config.d.ts +38 -0
- package/dist/cli/http-server-with-config.d.ts.map +1 -0
- package/dist/cli/http-server-with-config.js +477 -0
- package/dist/cli/http-server-with-config.js.map +1 -0
- package/dist/cli/http-server.d.ts +74 -0
- package/dist/cli/http-server.d.ts.map +1 -0
- package/dist/cli/http-server.js +407 -0
- package/dist/cli/http-server.js.map +1 -0
- package/dist/cli/jwt-middleware.d.ts +36 -0
- package/dist/cli/jwt-middleware.d.ts.map +1 -0
- package/dist/cli/jwt-middleware.js +99 -0
- package/dist/cli/jwt-middleware.js.map +1 -0
- package/dist/cli/main-entry.d.ts +45 -0
- package/dist/cli/main-entry.d.ts.map +1 -0
- package/dist/cli/main-entry.js +192 -0
- package/dist/cli/main-entry.js.map +1 -0
- package/dist/cli/mcp-handler.d.ts +56 -0
- package/dist/cli/mcp-handler.d.ts.map +1 -0
- package/dist/cli/mcp-handler.js +2189 -0
- package/dist/cli/mcp-handler.js.map +1 -0
- package/dist/cli/parser.d.ts +45 -0
- package/dist/cli/parser.d.ts.map +1 -0
- package/dist/cli/parser.js +172 -0
- package/dist/cli/parser.js.map +1 -0
- package/dist/cli/remote-config-loader.d.ts +89 -0
- package/dist/cli/remote-config-loader.d.ts.map +1 -0
- package/dist/cli/remote-config-loader.js +129 -0
- package/dist/cli/remote-config-loader.js.map +1 -0
- package/dist/cli/secret-auth.d.ts +47 -0
- package/dist/cli/secret-auth.d.ts.map +1 -0
- package/dist/cli/secret-auth.js +165 -0
- package/dist/cli/secret-auth.js.map +1 -0
- package/dist/cli/sse-stream-handler.d.ts +45 -0
- package/dist/cli/sse-stream-handler.d.ts.map +1 -0
- package/dist/cli/sse-stream-handler.js +125 -0
- package/dist/cli/sse-stream-handler.js.map +1 -0
- package/dist/index.js +897 -209
- package/dist/index.js.map +1 -1
- package/dist/integrations/calendar-event-creator.d.ts +152 -0
- package/dist/integrations/calendar-event-creator.d.ts.map +1 -0
- package/dist/integrations/calendar-event-creator.js +507 -0
- package/dist/integrations/calendar-event-creator.js.map +1 -0
- package/dist/integrations/calendar-event-deleter.d.ts +137 -0
- package/dist/integrations/calendar-event-deleter.d.ts.map +1 -0
- package/dist/integrations/calendar-event-deleter.js +378 -0
- package/dist/integrations/calendar-event-deleter.js.map +1 -0
- package/dist/integrations/calendar-event-response.d.ts +213 -0
- package/dist/integrations/calendar-event-response.d.ts.map +1 -0
- package/dist/integrations/calendar-event-response.js +560 -0
- package/dist/integrations/calendar-event-response.js.map +1 -0
- package/dist/integrations/calendar-service.d.ts +66 -1
- package/dist/integrations/calendar-service.d.ts.map +1 -1
- package/dist/integrations/calendar-service.js +223 -0
- package/dist/integrations/calendar-service.js.map +1 -1
- package/dist/oauth/client-store.d.ts +36 -0
- package/dist/oauth/client-store.d.ts.map +1 -0
- package/dist/oauth/client-store.js +119 -0
- package/dist/oauth/client-store.js.map +1 -0
- package/dist/oauth/code-store.d.ts +48 -0
- package/dist/oauth/code-store.d.ts.map +1 -0
- package/dist/oauth/code-store.js +89 -0
- package/dist/oauth/code-store.js.map +1 -0
- package/dist/oauth/index.d.ts +13 -0
- package/dist/oauth/index.d.ts.map +1 -0
- package/dist/oauth/index.js +21 -0
- package/dist/oauth/index.js.map +1 -0
- package/dist/oauth/oauth-handler.d.ts +101 -0
- package/dist/oauth/oauth-handler.d.ts.map +1 -0
- package/dist/oauth/oauth-handler.js +577 -0
- package/dist/oauth/oauth-handler.js.map +1 -0
- package/dist/oauth/oauth-server.d.ts +165 -0
- package/dist/oauth/oauth-server.d.ts.map +1 -0
- package/dist/oauth/oauth-server.js +489 -0
- package/dist/oauth/oauth-server.js.map +1 -0
- package/dist/oauth/pkce.d.ts +48 -0
- package/dist/oauth/pkce.d.ts.map +1 -0
- package/dist/oauth/pkce.js +106 -0
- package/dist/oauth/pkce.js.map +1 -0
- package/dist/oauth/refresh-token-store.d.ts +45 -0
- package/dist/oauth/refresh-token-store.d.ts.map +1 -0
- package/dist/oauth/refresh-token-store.js +98 -0
- package/dist/oauth/refresh-token-store.js.map +1 -0
- package/dist/oauth/token-service.d.ts +46 -0
- package/dist/oauth/token-service.d.ts.map +1 -0
- package/dist/oauth/token-service.js +199 -0
- package/dist/oauth/token-service.js.map +1 -0
- package/dist/oauth/types.d.ts +269 -0
- package/dist/oauth/types.d.ts.map +1 -0
- package/dist/oauth/types.js +53 -0
- package/dist/oauth/types.js.map +1 -0
- package/dist/version.d.ts +9 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +11 -0
- package/dist/version.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP Server with Remote Config Integration
|
|
3
|
+
* Requirements: 15.1, 15.4, 15.5, 15.6, 15.7, 15.8, 15.9, 21-31 (OAuth)
|
|
4
|
+
*
|
|
5
|
+
* Creates an HTTP server with configuration loaded from remote-config.json
|
|
6
|
+
* and integrates JWT-based authentication and OAuth 2.1.
|
|
7
|
+
*/
|
|
8
|
+
import { RemoteConfig } from './remote-config-loader.js';
|
|
9
|
+
/**
|
|
10
|
+
* Options for creating the server
|
|
11
|
+
*/
|
|
12
|
+
export interface HTTPServerWithConfigOptions {
|
|
13
|
+
/** Path to remote config file (default: ~/.sage/remote-config.json) */
|
|
14
|
+
configPath?: string;
|
|
15
|
+
/** Override port from CLI */
|
|
16
|
+
port?: number;
|
|
17
|
+
/** Override host from CLI */
|
|
18
|
+
host?: string;
|
|
19
|
+
/** Override auth secret from environment */
|
|
20
|
+
authSecret?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* HTTP Server with Config interface
|
|
24
|
+
*/
|
|
25
|
+
export interface HTTPServerWithConfig {
|
|
26
|
+
start(): Promise<void>;
|
|
27
|
+
stop(): Promise<void>;
|
|
28
|
+
isRunning(): boolean;
|
|
29
|
+
getPort(): number;
|
|
30
|
+
getHost(): string;
|
|
31
|
+
isAuthEnabled(): boolean;
|
|
32
|
+
getConfig(): RemoteConfig;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Create HTTP server with configuration from file
|
|
36
|
+
*/
|
|
37
|
+
export declare function createHTTPServerWithConfig(options?: HTTPServerWithConfigOptions): Promise<HTTPServerWithConfig>;
|
|
38
|
+
//# sourceMappingURL=http-server-with-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-server-with-config.d.ts","sourceRoot":"","sources":["../../src/cli/http-server-with-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAEL,YAAY,EAGb,MAAM,2BAA2B,CAAC;AAMnC;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,SAAS,IAAI,OAAO,CAAC;IACrB,OAAO,IAAI,MAAM,CAAC;IAClB,OAAO,IAAI,MAAM,CAAC;IAClB,aAAa,IAAI,OAAO,CAAC;IACzB,SAAS,IAAI,YAAY,CAAC;CAC3B;AAyhBD;;GAEG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,oBAAoB,CAAC,CAU/B"}
|
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP Server with Remote Config Integration
|
|
3
|
+
* Requirements: 15.1, 15.4, 15.5, 15.6, 15.7, 15.8, 15.9, 21-31 (OAuth)
|
|
4
|
+
*
|
|
5
|
+
* Creates an HTTP server with configuration loaded from remote-config.json
|
|
6
|
+
* and integrates JWT-based authentication and OAuth 2.1.
|
|
7
|
+
*/
|
|
8
|
+
import { createServer } from 'http';
|
|
9
|
+
import { VERSION } from '../version.js';
|
|
10
|
+
import { loadRemoteConfig, DEFAULT_REMOTE_CONFIG_PATH, } from './remote-config-loader.js';
|
|
11
|
+
import { createSecretAuthenticator } from './secret-auth.js';
|
|
12
|
+
import { createMCPHandler } from './mcp-handler.js';
|
|
13
|
+
import { createSSEStreamHandler } from './sse-stream-handler.js';
|
|
14
|
+
import { OAuthServer, OAuthHandler } from '../oauth/index.js';
|
|
15
|
+
/**
|
|
16
|
+
* HTTP Server with Config Implementation
|
|
17
|
+
*/
|
|
18
|
+
class HTTPServerWithConfigImpl {
|
|
19
|
+
server = null;
|
|
20
|
+
running = false;
|
|
21
|
+
startTime = null;
|
|
22
|
+
config;
|
|
23
|
+
effectivePort;
|
|
24
|
+
effectiveHost;
|
|
25
|
+
authenticator = null;
|
|
26
|
+
mcpHandler = null;
|
|
27
|
+
sseHandler = null;
|
|
28
|
+
oauthServer = null;
|
|
29
|
+
oauthHandler = null;
|
|
30
|
+
constructor(config, options) {
|
|
31
|
+
this.config = config;
|
|
32
|
+
// Apply priority: CLI > Environment > Config > Default
|
|
33
|
+
this.effectivePort = options.port ?? config.remote.port;
|
|
34
|
+
this.effectiveHost = options.host ?? config.remote.host;
|
|
35
|
+
// Setup authentication based on type
|
|
36
|
+
if (config.remote.auth.type === 'oauth2') {
|
|
37
|
+
// OAuth will be initialized in start()
|
|
38
|
+
// Also setup static token authenticator if enabled
|
|
39
|
+
const oauthConfig = config.remote.auth;
|
|
40
|
+
if (oauthConfig.allowStaticTokens && oauthConfig.staticTokenSecret) {
|
|
41
|
+
this.authenticator = createSecretAuthenticator({
|
|
42
|
+
secret: oauthConfig.staticTokenSecret,
|
|
43
|
+
expiresIn: oauthConfig.accessTokenExpiry ?? '1h',
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else if (config.remote.auth.type === 'jwt') {
|
|
48
|
+
// Setup JWT authenticator from config
|
|
49
|
+
const jwtConfig = config.remote.auth;
|
|
50
|
+
const secret = options.authSecret ?? jwtConfig.secret;
|
|
51
|
+
if (secret) {
|
|
52
|
+
this.authenticator = createSecretAuthenticator({
|
|
53
|
+
secret,
|
|
54
|
+
expiresIn: jwtConfig.expiresIn ?? '24h',
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if (options.authSecret) {
|
|
59
|
+
// Setup JWT authenticator from CLI option (overrides 'none' type)
|
|
60
|
+
this.authenticator = createSecretAuthenticator({
|
|
61
|
+
secret: options.authSecret,
|
|
62
|
+
expiresIn: '24h',
|
|
63
|
+
});
|
|
64
|
+
// Update auth type to reflect that auth is now enabled
|
|
65
|
+
this.config.remote.auth = {
|
|
66
|
+
type: 'jwt',
|
|
67
|
+
secret: options.authSecret,
|
|
68
|
+
expiresIn: '24h',
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async start() {
|
|
73
|
+
if (this.running) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
// Initialize MCP handler
|
|
77
|
+
this.mcpHandler = await createMCPHandler();
|
|
78
|
+
// Initialize SSE handler for Streamable HTTP Transport (Requirement 20)
|
|
79
|
+
this.sseHandler = createSSEStreamHandler();
|
|
80
|
+
// Initialize OAuth if configured (Requirements 21-31)
|
|
81
|
+
if (this.config.remote.auth.type === 'oauth2') {
|
|
82
|
+
const oauthConfig = this.config.remote.auth;
|
|
83
|
+
const issuer = oauthConfig.issuer || `http://${this.effectiveHost}:${this.effectivePort}`;
|
|
84
|
+
// Convert user config to OAuth users
|
|
85
|
+
const users = oauthConfig.users.map((u, i) => ({
|
|
86
|
+
id: `user_${i}`,
|
|
87
|
+
username: u.username,
|
|
88
|
+
passwordHash: u.passwordHash,
|
|
89
|
+
createdAt: Date.now(),
|
|
90
|
+
}));
|
|
91
|
+
this.oauthServer = new OAuthServer({
|
|
92
|
+
issuer,
|
|
93
|
+
accessTokenExpiry: oauthConfig.accessTokenExpiry || '1h',
|
|
94
|
+
refreshTokenExpiry: oauthConfig.refreshTokenExpiry || '30d',
|
|
95
|
+
authorizationCodeExpiry: '10m',
|
|
96
|
+
allowedRedirectUris: oauthConfig.allowedRedirectUris || [],
|
|
97
|
+
users,
|
|
98
|
+
});
|
|
99
|
+
await this.oauthServer.initialize();
|
|
100
|
+
this.oauthHandler = new OAuthHandler(this.oauthServer, {
|
|
101
|
+
issuer,
|
|
102
|
+
accessTokenExpiry: oauthConfig.accessTokenExpiry || '1h',
|
|
103
|
+
refreshTokenExpiry: oauthConfig.refreshTokenExpiry || '30d',
|
|
104
|
+
allowedRedirectUris: oauthConfig.allowedRedirectUris || [],
|
|
105
|
+
users,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return new Promise((resolve, reject) => {
|
|
109
|
+
try {
|
|
110
|
+
this.server = createServer(this.handleRequest.bind(this));
|
|
111
|
+
this.server.listen(this.effectivePort, this.effectiveHost, () => {
|
|
112
|
+
this.running = true;
|
|
113
|
+
this.startTime = new Date();
|
|
114
|
+
resolve();
|
|
115
|
+
});
|
|
116
|
+
this.server.on('error', reject);
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
reject(error);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
async stop() {
|
|
124
|
+
if (!this.running || !this.server) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
// Cleanup SSE connections
|
|
128
|
+
if (this.sseHandler) {
|
|
129
|
+
this.sseHandler.cleanup();
|
|
130
|
+
}
|
|
131
|
+
return new Promise((resolve) => {
|
|
132
|
+
this.server.close(() => {
|
|
133
|
+
this.running = false;
|
|
134
|
+
this.startTime = null;
|
|
135
|
+
resolve();
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
isRunning() {
|
|
140
|
+
return this.running;
|
|
141
|
+
}
|
|
142
|
+
getPort() {
|
|
143
|
+
return this.effectivePort;
|
|
144
|
+
}
|
|
145
|
+
getHost() {
|
|
146
|
+
return this.effectiveHost;
|
|
147
|
+
}
|
|
148
|
+
isAuthEnabled() {
|
|
149
|
+
return ((this.config.remote.auth.type === 'jwt' && this.authenticator !== null) ||
|
|
150
|
+
(this.config.remote.auth.type === 'oauth2' && this.oauthServer !== null));
|
|
151
|
+
}
|
|
152
|
+
isOAuthEnabled() {
|
|
153
|
+
return this.config.remote.auth.type === 'oauth2' && this.oauthServer !== null;
|
|
154
|
+
}
|
|
155
|
+
getConfig() {
|
|
156
|
+
return this.config;
|
|
157
|
+
}
|
|
158
|
+
handleRequest(req, res) {
|
|
159
|
+
const url = req.url || '/';
|
|
160
|
+
const method = req.method || 'GET';
|
|
161
|
+
const origin = req.headers.origin;
|
|
162
|
+
// Add CORS headers
|
|
163
|
+
const corsHeaders = this.getCORSHeaders(origin);
|
|
164
|
+
for (const [key, value] of Object.entries(corsHeaders)) {
|
|
165
|
+
res.setHeader(key, value);
|
|
166
|
+
}
|
|
167
|
+
// Handle preflight
|
|
168
|
+
if (method === 'OPTIONS') {
|
|
169
|
+
res.writeHead(204);
|
|
170
|
+
res.end();
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
// Health check endpoint (no auth required)
|
|
174
|
+
if (url === '/health' && method === 'GET') {
|
|
175
|
+
this.handleHealthCheck(res);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
// OAuth endpoints (Requirements 21-31)
|
|
179
|
+
if (this.oauthHandler) {
|
|
180
|
+
const path = url.split('?')[0];
|
|
181
|
+
const oauthPaths = [
|
|
182
|
+
'/.well-known/oauth-protected-resource',
|
|
183
|
+
'/.well-known/oauth-authorization-server',
|
|
184
|
+
'/oauth/register',
|
|
185
|
+
'/oauth/authorize',
|
|
186
|
+
'/oauth/login',
|
|
187
|
+
'/oauth/token',
|
|
188
|
+
];
|
|
189
|
+
if (oauthPaths.includes(path)) {
|
|
190
|
+
this.oauthHandler.handleRequest(req, res).catch(() => {
|
|
191
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
192
|
+
res.end(JSON.stringify({ error: 'Internal server error' }));
|
|
193
|
+
});
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// Auth token endpoint (for JWT mode)
|
|
198
|
+
if (url === '/auth/token' && method === 'POST' && !this.isOAuthEnabled()) {
|
|
199
|
+
this.handleAuthToken(req, res);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
// MCP SSE endpoint for Streamable HTTP Transport (Requirement 20.1)
|
|
203
|
+
// GET /mcp establishes SSE stream for server->client notifications
|
|
204
|
+
if (url === '/mcp' && method === 'GET') {
|
|
205
|
+
this.handleMCPSSERequest(req, res);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
// MCP endpoint (auth required if enabled)
|
|
209
|
+
if (url === '/mcp' && method === 'POST') {
|
|
210
|
+
this.handleMCPRequest(req, res);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
// Root path - show server info
|
|
214
|
+
if ((url === '/' || url === '') && method === 'GET') {
|
|
215
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
216
|
+
res.end(JSON.stringify({
|
|
217
|
+
name: 'sage',
|
|
218
|
+
version: VERSION,
|
|
219
|
+
status: 'running',
|
|
220
|
+
endpoints: {
|
|
221
|
+
mcp: '/mcp',
|
|
222
|
+
health: '/health',
|
|
223
|
+
oauth: this.isOAuthEnabled() ? {
|
|
224
|
+
metadata: '/.well-known/oauth-authorization-server',
|
|
225
|
+
authorize: '/oauth/authorize',
|
|
226
|
+
token: '/oauth/token',
|
|
227
|
+
register: '/oauth/register',
|
|
228
|
+
} : undefined,
|
|
229
|
+
},
|
|
230
|
+
}));
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
// 404 for unknown routes
|
|
234
|
+
res.writeHead(404, { 'Content-Type': 'application/json' });
|
|
235
|
+
res.end(JSON.stringify({ error: 'Not found' }));
|
|
236
|
+
}
|
|
237
|
+
getCORSHeaders(origin) {
|
|
238
|
+
const allowedOrigins = this.config.remote.cors.allowedOrigins;
|
|
239
|
+
let allowOrigin = '*';
|
|
240
|
+
if (allowedOrigins.includes('*')) {
|
|
241
|
+
allowOrigin = '*';
|
|
242
|
+
}
|
|
243
|
+
else if (origin && allowedOrigins.includes(origin)) {
|
|
244
|
+
allowOrigin = origin;
|
|
245
|
+
}
|
|
246
|
+
else if (allowedOrigins.length === 1) {
|
|
247
|
+
allowOrigin = allowedOrigins[0];
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
'Access-Control-Allow-Origin': allowOrigin,
|
|
251
|
+
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
|
|
252
|
+
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
|
|
253
|
+
'Access-Control-Max-Age': '86400',
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
handleHealthCheck(res) {
|
|
257
|
+
const uptime = this.startTime ? Date.now() - this.startTime.getTime() : 0;
|
|
258
|
+
const health = {
|
|
259
|
+
status: this.running ? 'ok' : 'error',
|
|
260
|
+
uptime,
|
|
261
|
+
version: VERSION,
|
|
262
|
+
timestamp: new Date().toISOString(),
|
|
263
|
+
authEnabled: this.isAuthEnabled(),
|
|
264
|
+
};
|
|
265
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
266
|
+
res.end(JSON.stringify(health));
|
|
267
|
+
}
|
|
268
|
+
handleAuthToken(req, res) {
|
|
269
|
+
// Check if auth is enabled
|
|
270
|
+
if (!this.isAuthEnabled() || !this.authenticator) {
|
|
271
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
272
|
+
res.end(JSON.stringify({ error: 'Authentication is disabled' }));
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
// Read request body
|
|
276
|
+
let body = '';
|
|
277
|
+
req.on('data', (chunk) => {
|
|
278
|
+
body += chunk.toString();
|
|
279
|
+
});
|
|
280
|
+
req.on('end', async () => {
|
|
281
|
+
try {
|
|
282
|
+
const parsed = JSON.parse(body);
|
|
283
|
+
const secret = parsed.secret;
|
|
284
|
+
if (!secret) {
|
|
285
|
+
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
286
|
+
res.end(JSON.stringify({ error: 'Secret is required' }));
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const result = await this.authenticator.authenticate(secret);
|
|
290
|
+
if (result.success) {
|
|
291
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
292
|
+
res.end(JSON.stringify({
|
|
293
|
+
token: result.token,
|
|
294
|
+
expiresIn: result.expiresIn,
|
|
295
|
+
}));
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
299
|
+
res.end(JSON.stringify({ error: result.error || 'Invalid secret' }));
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
catch {
|
|
303
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
304
|
+
res.end(JSON.stringify({ error: 'Invalid request body' }));
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Verify Bearer token (supports both JWT and OAuth, tries both if configured)
|
|
310
|
+
*/
|
|
311
|
+
async verifyBearerToken(authHeader) {
|
|
312
|
+
if (!authHeader) {
|
|
313
|
+
return { valid: false, error: 'Authentication required' };
|
|
314
|
+
}
|
|
315
|
+
const parts = authHeader.split(' ');
|
|
316
|
+
if (parts.length !== 2 || parts[0].toLowerCase() !== 'bearer') {
|
|
317
|
+
return { valid: false, error: 'Invalid Authorization header' };
|
|
318
|
+
}
|
|
319
|
+
const token = parts[1];
|
|
320
|
+
// Try OAuth verification first if OAuth is enabled
|
|
321
|
+
if (this.isOAuthEnabled() && this.oauthServer) {
|
|
322
|
+
const result = await this.oauthServer.verifyAccessToken(token);
|
|
323
|
+
if (result.valid) {
|
|
324
|
+
return { valid: true };
|
|
325
|
+
}
|
|
326
|
+
// If OAuth fails and static tokens are enabled, try static token verification
|
|
327
|
+
if (this.authenticator) {
|
|
328
|
+
const staticResult = await this.authenticator.verifyToken(token);
|
|
329
|
+
if (staticResult.valid) {
|
|
330
|
+
return { valid: true };
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
// Return the OAuth error if both failed
|
|
334
|
+
return { valid: false, error: result.error };
|
|
335
|
+
}
|
|
336
|
+
// Fall back to JWT verification only
|
|
337
|
+
if (this.authenticator) {
|
|
338
|
+
const result = await this.authenticator.verifyToken(token);
|
|
339
|
+
return { valid: result.valid, error: result.error };
|
|
340
|
+
}
|
|
341
|
+
return { valid: false, error: 'No authentication configured' };
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Handle GET /mcp request for SSE stream (Streamable HTTP Transport)
|
|
345
|
+
* Requirement 20.1, 20.10, 31.5 (OAuth Bearer auth for SSE)
|
|
346
|
+
*/
|
|
347
|
+
handleMCPSSERequest(req, res) {
|
|
348
|
+
// Requirement 20.10, 31.5: Check authentication if enabled
|
|
349
|
+
if (this.isAuthEnabled()) {
|
|
350
|
+
// Add WWW-Authenticate header for OAuth (Requirement 22.4)
|
|
351
|
+
if (this.isOAuthEnabled() && this.oauthServer) {
|
|
352
|
+
res.setHeader('WWW-Authenticate', this.oauthServer.getWWWAuthenticateHeader());
|
|
353
|
+
}
|
|
354
|
+
this.verifyBearerToken(req.headers.authorization).then((result) => {
|
|
355
|
+
if (!result.valid) {
|
|
356
|
+
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
357
|
+
res.end(JSON.stringify({ error: result.error || 'Invalid token' }));
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
this.establishSSEConnection(req, res);
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
// Requirement 20.10: authEnabled: false allows access without auth
|
|
365
|
+
this.establishSSEConnection(req, res);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Establish SSE connection
|
|
370
|
+
*/
|
|
371
|
+
establishSSEConnection(req, res) {
|
|
372
|
+
if (!this.sseHandler) {
|
|
373
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
374
|
+
res.end(JSON.stringify({ error: 'SSE handler not initialized' }));
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
this.sseHandler.handleSSERequest(req, res);
|
|
378
|
+
}
|
|
379
|
+
handleMCPRequest(req, res) {
|
|
380
|
+
// Check authentication if enabled
|
|
381
|
+
if (this.isAuthEnabled()) {
|
|
382
|
+
// Add WWW-Authenticate header for OAuth (Requirement 22.4)
|
|
383
|
+
if (this.isOAuthEnabled() && this.oauthServer) {
|
|
384
|
+
res.setHeader('WWW-Authenticate', this.oauthServer.getWWWAuthenticateHeader());
|
|
385
|
+
}
|
|
386
|
+
this.verifyBearerToken(req.headers.authorization).then((result) => {
|
|
387
|
+
if (!result.valid) {
|
|
388
|
+
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
389
|
+
res.end(JSON.stringify({
|
|
390
|
+
jsonrpc: '2.0',
|
|
391
|
+
id: null,
|
|
392
|
+
error: {
|
|
393
|
+
code: -32002,
|
|
394
|
+
message: result.error || 'Invalid token',
|
|
395
|
+
},
|
|
396
|
+
}));
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
this.processMCPRequest(req, res);
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
this.processMCPRequest(req, res);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
processMCPRequest(req, res) {
|
|
407
|
+
let body = '';
|
|
408
|
+
req.on('data', (chunk) => {
|
|
409
|
+
body += chunk.toString();
|
|
410
|
+
});
|
|
411
|
+
req.on('end', async () => {
|
|
412
|
+
try {
|
|
413
|
+
const request = this.parseJSONRPCRequest(body);
|
|
414
|
+
// Process request through MCP handler
|
|
415
|
+
if (!this.mcpHandler) {
|
|
416
|
+
throw new Error('MCP handler not initialized');
|
|
417
|
+
}
|
|
418
|
+
const mcpRequest = {
|
|
419
|
+
jsonrpc: '2.0',
|
|
420
|
+
id: request.id,
|
|
421
|
+
method: request.method,
|
|
422
|
+
params: request.params,
|
|
423
|
+
};
|
|
424
|
+
const response = await this.mcpHandler.handleRequest(mcpRequest);
|
|
425
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
426
|
+
res.end(JSON.stringify(response));
|
|
427
|
+
}
|
|
428
|
+
catch (error) {
|
|
429
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
430
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
431
|
+
res.end(JSON.stringify({
|
|
432
|
+
jsonrpc: '2.0',
|
|
433
|
+
id: null,
|
|
434
|
+
error: {
|
|
435
|
+
code: -32700,
|
|
436
|
+
message: errorMessage,
|
|
437
|
+
},
|
|
438
|
+
}));
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
parseJSONRPCRequest(body) {
|
|
443
|
+
let parsed;
|
|
444
|
+
try {
|
|
445
|
+
parsed = JSON.parse(body);
|
|
446
|
+
}
|
|
447
|
+
catch {
|
|
448
|
+
throw new Error('Invalid JSON');
|
|
449
|
+
}
|
|
450
|
+
const request = parsed;
|
|
451
|
+
if (!request.jsonrpc || request.jsonrpc !== '2.0') {
|
|
452
|
+
throw new Error('Invalid JSON-RPC request');
|
|
453
|
+
}
|
|
454
|
+
if (request.method === undefined) {
|
|
455
|
+
throw new Error('Invalid JSON-RPC request: missing method');
|
|
456
|
+
}
|
|
457
|
+
return {
|
|
458
|
+
jsonrpc: '2.0',
|
|
459
|
+
id: request.id ?? null,
|
|
460
|
+
method: request.method,
|
|
461
|
+
params: request.params,
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Create HTTP server with configuration from file
|
|
467
|
+
*/
|
|
468
|
+
export async function createHTTPServerWithConfig(options = {}) {
|
|
469
|
+
// Load configuration
|
|
470
|
+
const configPath = options.configPath ?? DEFAULT_REMOTE_CONFIG_PATH;
|
|
471
|
+
const config = await loadRemoteConfig(configPath);
|
|
472
|
+
// Create and start server
|
|
473
|
+
const server = new HTTPServerWithConfigImpl(config, options);
|
|
474
|
+
await server.start();
|
|
475
|
+
return server;
|
|
476
|
+
}
|
|
477
|
+
//# sourceMappingURL=http-server-with-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-server-with-config.js","sourceRoot":"","sources":["../../src/cli/http-server-with-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAA2C,MAAM,MAAM,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EACL,gBAAgB,EAEhB,0BAA0B,GAE3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,yBAAyB,EAAuB,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAA0B,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAoB,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAwC9D;;GAEG;AACH,MAAM,wBAAwB;IACpB,MAAM,GAAkB,IAAI,CAAC;IAC7B,OAAO,GAAY,KAAK,CAAC;IACzB,SAAS,GAAgB,IAAI,CAAC;IAC9B,MAAM,CAAe;IACrB,aAAa,CAAS;IACtB,aAAa,CAAS;IACtB,aAAa,GAA+B,IAAI,CAAC;IACjD,UAAU,GAAsB,IAAI,CAAC;IACrC,UAAU,GAA4B,IAAI,CAAC;IAC3C,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1, 14.9, 14.10, 13.1
|
|
4
|
+
*
|
|
5
|
+
* Provides HTTP server functionality for Remote MCP access.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* HTTP Server Configuration
|
|
9
|
+
*/
|
|
10
|
+
export interface HTTPServerConfig {
|
|
11
|
+
/** HTTP server port */
|
|
12
|
+
port: number;
|
|
13
|
+
/** HTTP server host address */
|
|
14
|
+
host: string;
|
|
15
|
+
/** Path to configuration file */
|
|
16
|
+
configPath?: string;
|
|
17
|
+
/** SSL configuration for HTTPS */
|
|
18
|
+
ssl?: {
|
|
19
|
+
cert: string;
|
|
20
|
+
key: string;
|
|
21
|
+
ca?: string;
|
|
22
|
+
};
|
|
23
|
+
/** Authentication configuration */
|
|
24
|
+
auth?: {
|
|
25
|
+
enabled: boolean;
|
|
26
|
+
jwtSecret?: string;
|
|
27
|
+
apiKeys?: string[];
|
|
28
|
+
ipWhitelist?: string[];
|
|
29
|
+
tokenExpiry?: number;
|
|
30
|
+
};
|
|
31
|
+
/** CORS configuration */
|
|
32
|
+
cors?: {
|
|
33
|
+
allowedOrigins?: string[];
|
|
34
|
+
allowedMethods?: string[];
|
|
35
|
+
allowedHeaders?: string[];
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Server information
|
|
40
|
+
*/
|
|
41
|
+
export interface ServerInfo {
|
|
42
|
+
port: number;
|
|
43
|
+
host: string;
|
|
44
|
+
ssl: boolean;
|
|
45
|
+
authEnabled: boolean;
|
|
46
|
+
startTime?: Date;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Health check response
|
|
50
|
+
*/
|
|
51
|
+
export interface HealthCheckResponse {
|
|
52
|
+
status: 'ok' | 'error';
|
|
53
|
+
uptime: number;
|
|
54
|
+
version: string;
|
|
55
|
+
timestamp: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* HTTP Server Instance interface
|
|
59
|
+
*/
|
|
60
|
+
export interface HTTPServerInstance {
|
|
61
|
+
start(): Promise<void>;
|
|
62
|
+
stop(): Promise<void>;
|
|
63
|
+
isRunning(): boolean;
|
|
64
|
+
getPort(): number;
|
|
65
|
+
getHost(): string;
|
|
66
|
+
getServerInfo(): ServerInfo;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Create and start an HTTP server
|
|
70
|
+
* @param config - Server configuration
|
|
71
|
+
* @returns Running HTTP server instance
|
|
72
|
+
*/
|
|
73
|
+
export declare function createHTTPServer(config: HTTPServerConfig): Promise<HTTPServerInstance>;
|
|
74
|
+
//# sourceMappingURL=http-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-server.d.ts","sourceRoot":"","sources":["../../src/cli/http-server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,GAAG,CAAC,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,MAAM,CAAC;QACZ,EAAE,CAAC,EAAE,MAAM,CAAC;KACb,CAAC;IACF,mCAAmC;IACnC,IAAI,CAAC,EAAE;QACL,OAAO,EAAE,OAAO,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,yBAAyB;IACzB,IAAI,CAAC,EAAE;QACL,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;QAC1B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;QAC1B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;KAC3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