@1mcp/agent 0.13.0 → 0.14.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/README.md +28 -20
- package/build/auth/sdkOAuthClientProvider.d.ts +1 -1
- package/build/auth/sdkOAuthClientProvider.d.ts.map +1 -1
- package/build/auth/sdkOAuthClientProvider.js +11 -6
- package/build/auth/sdkOAuthClientProvider.js.map +1 -1
- package/build/auth/sdkOAuthServerProvider.d.ts +4 -3
- package/build/auth/sdkOAuthServerProvider.d.ts.map +1 -1
- package/build/auth/sdkOAuthServerProvider.js +41 -110
- package/build/auth/sdkOAuthServerProvider.js.map +1 -1
- package/build/auth/sessionTypes.d.ts +24 -10
- package/build/auth/sessionTypes.d.ts.map +1 -1
- package/build/auth/storage/authCodeRepository.d.ts +25 -0
- package/build/auth/storage/authCodeRepository.d.ts.map +1 -0
- package/build/auth/storage/authCodeRepository.js +50 -0
- package/build/auth/storage/authCodeRepository.js.map +1 -0
- package/build/auth/storage/authRequestRepository.d.ts +25 -0
- package/build/auth/storage/authRequestRepository.d.ts.map +1 -0
- package/build/auth/storage/authRequestRepository.js +51 -0
- package/build/auth/storage/authRequestRepository.js.map +1 -0
- package/build/auth/storage/clientDataRepository.d.ts +25 -0
- package/build/auth/storage/clientDataRepository.d.ts.map +1 -0
- package/build/auth/storage/clientDataRepository.js +45 -0
- package/build/auth/storage/clientDataRepository.js.map +1 -0
- package/build/auth/storage/clientSessionRepository.d.ts +77 -0
- package/build/auth/storage/clientSessionRepository.d.ts.map +1 -0
- package/build/auth/storage/clientSessionRepository.js +120 -0
- package/build/auth/storage/clientSessionRepository.js.map +1 -0
- package/build/auth/storage/fileStorageService.d.ts +68 -0
- package/build/auth/storage/fileStorageService.d.ts.map +1 -0
- package/build/auth/storage/fileStorageService.js +262 -0
- package/build/auth/storage/fileStorageService.js.map +1 -0
- package/build/auth/storage/oauthStorageService.d.ts +57 -0
- package/build/auth/storage/oauthStorageService.d.ts.map +1 -0
- package/build/auth/storage/oauthStorageService.js +131 -0
- package/build/auth/storage/oauthStorageService.js.map +1 -0
- package/build/auth/storage/sessionRepository.d.ts +29 -0
- package/build/auth/storage/sessionRepository.d.ts.map +1 -0
- package/build/auth/storage/sessionRepository.js +64 -0
- package/build/auth/storage/sessionRepository.js.map +1 -0
- package/build/constants.d.ts +26 -11
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +32 -11
- package/build/constants.js.map +1 -1
- package/build/core/client/clientManager.d.ts +55 -39
- package/build/core/client/clientManager.d.ts.map +1 -1
- package/build/core/client/clientManager.js +180 -171
- package/build/core/client/clientManager.js.map +1 -1
- package/build/core/server/agentConfig.d.ts +13 -0
- package/build/core/server/agentConfig.d.ts.map +1 -1
- package/build/core/server/agentConfig.js +18 -2
- package/build/core/server/agentConfig.js.map +1 -1
- package/build/core/server/serverManager.d.ts +11 -4
- package/build/core/server/serverManager.d.ts.map +1 -1
- package/build/core/server/serverManager.js +47 -23
- package/build/core/server/serverManager.js.map +1 -1
- package/build/core/types/server.d.ts +17 -0
- package/build/core/types/server.d.ts.map +1 -1
- package/build/core/types/server.js +14 -1
- package/build/core/types/server.js.map +1 -1
- package/build/handlers/notificationHandlers.d.ts +2 -2
- package/build/handlers/notificationHandlers.d.ts.map +1 -1
- package/build/handlers/notificationHandlers.js +15 -10
- package/build/handlers/notificationHandlers.js.map +1 -1
- package/build/handlers/requestHandlers.d.ts +1 -1
- package/build/handlers/requestHandlers.d.ts.map +1 -1
- package/build/handlers/requestHandlers.js +68 -67
- package/build/handlers/requestHandlers.js.map +1 -1
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/logger/mcpLoggingEnhancer.d.ts.map +1 -1
- package/build/logger/mcpLoggingEnhancer.js +18 -1
- package/build/logger/mcpLoggingEnhancer.js.map +1 -1
- package/build/server.d.ts.map +1 -1
- package/build/server.js +3 -2
- package/build/server.js.map +1 -1
- package/build/services/configReloadService.d.ts.map +1 -1
- package/build/services/configReloadService.js +3 -2
- package/build/services/configReloadService.js.map +1 -1
- package/build/transport/http/middlewares/httpRequestLogger.d.ts +16 -0
- package/build/transport/http/middlewares/httpRequestLogger.d.ts.map +1 -0
- package/build/transport/http/middlewares/httpRequestLogger.js +41 -0
- package/build/transport/http/middlewares/httpRequestLogger.js.map +1 -0
- package/build/transport/http/middlewares/scopeAuthMiddleware.d.ts +4 -7
- package/build/transport/http/middlewares/scopeAuthMiddleware.d.ts.map +1 -1
- package/build/transport/http/middlewares/scopeAuthMiddleware.js +6 -12
- package/build/transport/http/middlewares/scopeAuthMiddleware.js.map +1 -1
- package/build/transport/http/routes/oauthRoutes.d.ts +6 -2
- package/build/transport/http/routes/oauthRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/oauthRoutes.js +333 -337
- package/build/transport/http/routes/oauthRoutes.js.map +1 -1
- package/build/transport/http/routes/sseRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/sseRoutes.js +11 -5
- package/build/transport/http/routes/sseRoutes.js.map +1 -1
- package/build/transport/http/routes/streamableHttpRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/streamableHttpRoutes.js +11 -10
- package/build/transport/http/routes/streamableHttpRoutes.js.map +1 -1
- package/build/transport/http/server.d.ts +1 -0
- package/build/transport/http/server.d.ts.map +1 -1
- package/build/transport/http/server.js +11 -5
- package/build/transport/http/server.js.map +1 -1
- package/build/transport/transportFactory.js +2 -2
- package/build/transport/transportFactory.js.map +1 -1
- package/build/utils/clientFiltering.d.ts.map +1 -1
- package/build/utils/clientFiltering.js +40 -5
- package/build/utils/clientFiltering.js.map +1 -1
- package/build/utils/operationExecution.d.ts +10 -0
- package/build/utils/operationExecution.d.ts.map +1 -0
- package/build/utils/operationExecution.js +36 -0
- package/build/utils/operationExecution.js.map +1 -0
- package/build/utils/pagination.d.ts.map +1 -1
- package/build/utils/pagination.js +22 -13
- package/build/utils/pagination.js.map +1 -1
- package/package.json +1 -1
- package/build/auth/clientSessionManager.d.ts +0 -94
- package/build/auth/clientSessionManager.d.ts.map +0 -1
- package/build/auth/clientSessionManager.js +0 -220
- package/build/auth/clientSessionManager.js.map +0 -1
- package/build/auth/serverSessionManager.d.ts +0 -185
- package/build/auth/serverSessionManager.d.ts.map +0 -1
- package/build/auth/serverSessionManager.js +0 -461
- package/build/auth/serverSessionManager.js.map +0 -1
- package/build/core/client/clientFactory.d.ts +0 -25
- package/build/core/client/clientFactory.d.ts.map +0 -1
- package/build/core/client/clientFactory.js +0 -12
- package/build/core/client/clientFactory.js.map +0 -1
|
@@ -1,461 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { randomUUID } from 'node:crypto';
|
|
4
|
-
import logger from '../logger/logger.js';
|
|
5
|
-
import { AUTH_CONFIG, getGlobalConfigDir } from '../constants.js';
|
|
6
|
-
/**
|
|
7
|
-
* SessionManager handles file-based session storage with automatic cleanup.
|
|
8
|
-
*
|
|
9
|
-
* This class manages OAuth 2.1 sessions and authorization codes using
|
|
10
|
-
* the local filesystem. It provides automatic cleanup of expired sessions
|
|
11
|
-
* and supports configurable storage locations.
|
|
12
|
-
*
|
|
13
|
-
* Features:
|
|
14
|
-
* - File-based session storage with JSON format
|
|
15
|
-
* - Automatic cleanup of expired sessions every 5 minutes
|
|
16
|
-
* - Prefixed identifiers for easy debugging
|
|
17
|
-
* - Configurable storage directory
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* const sessionManager = new SessionManager('/custom/path');
|
|
22
|
-
* const sessionId = sessionManager.createSession('client-123', 'resource', 3600000);
|
|
23
|
-
* const session = sessionManager.getSession(sessionId);
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export class ServerSessionManager {
|
|
27
|
-
sessionStoragePath;
|
|
28
|
-
cleanupInterval = null;
|
|
29
|
-
/**
|
|
30
|
-
* Creates a new SessionManager instance.
|
|
31
|
-
*
|
|
32
|
-
* Initializes the session storage directory and starts the automatic
|
|
33
|
-
* cleanup process for expired sessions.
|
|
34
|
-
*
|
|
35
|
-
* @param sessionStoragePath - Optional custom path for session storage
|
|
36
|
-
*/
|
|
37
|
-
constructor(sessionStoragePath) {
|
|
38
|
-
this.sessionStoragePath =
|
|
39
|
-
sessionStoragePath || path.join(getGlobalConfigDir(), AUTH_CONFIG.SERVER.SESSION.STORAGE_DIR);
|
|
40
|
-
this.ensureSessionDirectory();
|
|
41
|
-
this.startCleanupInterval();
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Gets the session storage path.
|
|
45
|
-
*
|
|
46
|
-
* @returns The absolute path to the session storage directory
|
|
47
|
-
*/
|
|
48
|
-
getSessionStoragePath() {
|
|
49
|
-
return this.sessionStoragePath;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Ensures the session storage directory exists.
|
|
53
|
-
*
|
|
54
|
-
* Creates the directory structure if it doesn't exist, including
|
|
55
|
-
* parent directories as needed.
|
|
56
|
-
*
|
|
57
|
-
* @throws Error if directory creation fails
|
|
58
|
-
*/
|
|
59
|
-
ensureSessionDirectory() {
|
|
60
|
-
try {
|
|
61
|
-
if (!fs.existsSync(this.sessionStoragePath)) {
|
|
62
|
-
fs.mkdirSync(this.sessionStoragePath, { recursive: true });
|
|
63
|
-
logger.info(`Created session storage directory: ${this.sessionStoragePath}`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
logger.error(`Failed to create session directory: ${error}`);
|
|
68
|
-
throw error;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Gets the file path for a session ID.
|
|
73
|
-
*
|
|
74
|
-
* @param sessionId - The session identifier
|
|
75
|
-
* @returns Full file path for the session file
|
|
76
|
-
*/
|
|
77
|
-
getSessionFilePath(sessionId) {
|
|
78
|
-
// Validate session ID format first
|
|
79
|
-
if (!this.isValidId(sessionId)) {
|
|
80
|
-
throw new Error('Invalid session ID format');
|
|
81
|
-
}
|
|
82
|
-
const fileName = `${AUTH_CONFIG.SERVER.SESSION.FILE_PREFIX}${sessionId}${AUTH_CONFIG.SERVER.SESSION.FILE_EXTENSION}`;
|
|
83
|
-
const filePath = path.resolve(this.sessionStoragePath, fileName);
|
|
84
|
-
// Additional security check: ensure resolved path is within session storage
|
|
85
|
-
const normalizedStoragePath = path.resolve(this.sessionStoragePath);
|
|
86
|
-
const normalizedFilePath = path.resolve(filePath);
|
|
87
|
-
if (!normalizedFilePath.startsWith(normalizedStoragePath + path.sep)) {
|
|
88
|
-
throw new Error('Invalid session file path: outside storage directory');
|
|
89
|
-
}
|
|
90
|
-
return filePath;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Gets the file path for an authorization code.
|
|
94
|
-
*
|
|
95
|
-
* @param code - The authorization code
|
|
96
|
-
* @returns Full file path for the auth code file
|
|
97
|
-
*/
|
|
98
|
-
getAuthCodeFilePath(code) {
|
|
99
|
-
// Validate auth code format first
|
|
100
|
-
if (!this.isValidId(code)) {
|
|
101
|
-
throw new Error('Invalid authorization code format');
|
|
102
|
-
}
|
|
103
|
-
const fileName = `auth_code_${code}${AUTH_CONFIG.SERVER.SESSION.FILE_EXTENSION}`;
|
|
104
|
-
const filePath = path.resolve(this.sessionStoragePath, fileName);
|
|
105
|
-
// Additional security check: ensure resolved path is within session storage
|
|
106
|
-
const normalizedStoragePath = path.resolve(this.sessionStoragePath);
|
|
107
|
-
const normalizedFilePath = path.resolve(filePath);
|
|
108
|
-
if (!normalizedFilePath.startsWith(normalizedStoragePath + path.sep)) {
|
|
109
|
-
throw new Error('Invalid authorization code path: outside storage directory');
|
|
110
|
-
}
|
|
111
|
-
return filePath;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Utility to validate session IDs and auth codes for proper format and security.
|
|
115
|
-
* Ensures proper format with prefix and UUID structure for security.
|
|
116
|
-
* @param id - The session ID or auth code to validate
|
|
117
|
-
* @returns true if valid, false otherwise
|
|
118
|
-
*/
|
|
119
|
-
isValidId(id) {
|
|
120
|
-
// Check minimum length (prefix + content)
|
|
121
|
-
if (!id || id.length < 8) {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
// Check for valid server-side prefix
|
|
125
|
-
const hasServerPrefix = id.startsWith(AUTH_CONFIG.SERVER.PREFIXES.SESSION_ID) || id.startsWith(AUTH_CONFIG.SERVER.PREFIXES.AUTH_CODE);
|
|
126
|
-
if (hasServerPrefix) {
|
|
127
|
-
// Validate the UUID portion (after prefix)
|
|
128
|
-
const uuidPart = id.startsWith(AUTH_CONFIG.SERVER.PREFIXES.SESSION_ID)
|
|
129
|
-
? id.substring(AUTH_CONFIG.SERVER.PREFIXES.SESSION_ID.length)
|
|
130
|
-
: id.substring(AUTH_CONFIG.SERVER.PREFIXES.AUTH_CODE.length);
|
|
131
|
-
// UUID v4 format: 8-4-4-4-12 hexadecimal digits with hyphens
|
|
132
|
-
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
133
|
-
return uuidRegex.test(uuidPart);
|
|
134
|
-
}
|
|
135
|
-
// Check for valid client-side OAuth prefix
|
|
136
|
-
const hasClientPrefix = id.startsWith(AUTH_CONFIG.CLIENT.PREFIXES.CLIENT) ||
|
|
137
|
-
id.startsWith(AUTH_CONFIG.CLIENT.PREFIXES.TOKENS) ||
|
|
138
|
-
id.startsWith(AUTH_CONFIG.CLIENT.PREFIXES.VERIFIER) ||
|
|
139
|
-
id.startsWith(AUTH_CONFIG.CLIENT.PREFIXES.STATE);
|
|
140
|
-
if (hasClientPrefix) {
|
|
141
|
-
const contentPart = id.substring(4); // All client prefixes are 4 characters
|
|
142
|
-
return contentPart.length > 0 && /^[a-zA-Z0-9_-]+$/.test(contentPart);
|
|
143
|
-
}
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Creates a new session with the specified parameters.
|
|
148
|
-
*
|
|
149
|
-
* Generates a unique session ID with prefix, stores the session data
|
|
150
|
-
* as a JSON file, and returns the session identifier.
|
|
151
|
-
*
|
|
152
|
-
* @param clientId - The client identifier
|
|
153
|
-
* @param resource - The resource this session can access
|
|
154
|
-
* @param ttlMs - Time-to-live in milliseconds
|
|
155
|
-
* @returns The generated session ID with prefix
|
|
156
|
-
* @throws Error if session creation fails
|
|
157
|
-
*/
|
|
158
|
-
createSession(clientId, resource, ttlMs) {
|
|
159
|
-
const sessionId = AUTH_CONFIG.SERVER.PREFIXES.SESSION_ID + randomUUID();
|
|
160
|
-
const sessionData = {
|
|
161
|
-
clientId,
|
|
162
|
-
resource,
|
|
163
|
-
expires: Date.now() + ttlMs,
|
|
164
|
-
createdAt: Date.now(),
|
|
165
|
-
};
|
|
166
|
-
try {
|
|
167
|
-
const filePath = this.getSessionFilePath(sessionId);
|
|
168
|
-
fs.writeFileSync(filePath, JSON.stringify(sessionData, null, 2));
|
|
169
|
-
logger.info(`Created session: ${sessionId} for client: ${clientId}`);
|
|
170
|
-
return sessionId;
|
|
171
|
-
}
|
|
172
|
-
catch (error) {
|
|
173
|
-
logger.error(`Failed to create session: ${error}`);
|
|
174
|
-
throw error;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Retrieves session data by session ID.
|
|
179
|
-
*
|
|
180
|
-
* Reads the session file and validates expiration. If the session
|
|
181
|
-
* is expired, it's automatically deleted and null is returned.
|
|
182
|
-
*
|
|
183
|
-
* @param sessionId - The session identifier to retrieve
|
|
184
|
-
* @returns Session data if valid and not expired, null otherwise
|
|
185
|
-
*/
|
|
186
|
-
getSession(sessionId) {
|
|
187
|
-
if (!this.isValidId(sessionId)) {
|
|
188
|
-
logger.warn(`Rejected getSession with invalid sessionId: ${sessionId}`);
|
|
189
|
-
return null;
|
|
190
|
-
}
|
|
191
|
-
try {
|
|
192
|
-
const filePath = this.getSessionFilePath(sessionId);
|
|
193
|
-
if (!fs.existsSync(filePath)) {
|
|
194
|
-
return null;
|
|
195
|
-
}
|
|
196
|
-
const data = fs.readFileSync(filePath, 'utf8');
|
|
197
|
-
const sessionData = JSON.parse(data);
|
|
198
|
-
if (sessionData.expires < Date.now()) {
|
|
199
|
-
this.deleteSession(sessionId);
|
|
200
|
-
return null;
|
|
201
|
-
}
|
|
202
|
-
return sessionData;
|
|
203
|
-
}
|
|
204
|
-
catch (error) {
|
|
205
|
-
logger.error(`Failed to read session ${sessionId}: ${error}`);
|
|
206
|
-
return null;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Deletes a session by session ID.
|
|
211
|
-
*
|
|
212
|
-
* Removes the session file from the filesystem if it exists.
|
|
213
|
-
*
|
|
214
|
-
* @param sessionId - The session identifier to delete
|
|
215
|
-
* @returns True if session was deleted, false if it didn't exist
|
|
216
|
-
*/
|
|
217
|
-
deleteSession(sessionId) {
|
|
218
|
-
if (!this.isValidId(sessionId)) {
|
|
219
|
-
logger.warn(`Rejected deleteSession with invalid sessionId: ${sessionId}`);
|
|
220
|
-
return false;
|
|
221
|
-
}
|
|
222
|
-
try {
|
|
223
|
-
const filePath = this.getSessionFilePath(sessionId);
|
|
224
|
-
if (fs.existsSync(filePath)) {
|
|
225
|
-
fs.unlinkSync(filePath);
|
|
226
|
-
logger.info(`Deleted session: ${sessionId}`);
|
|
227
|
-
return true;
|
|
228
|
-
}
|
|
229
|
-
return false;
|
|
230
|
-
}
|
|
231
|
-
catch (error) {
|
|
232
|
-
logger.error(`Failed to delete session ${sessionId}: ${error}`);
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Creates a new authorization code for OAuth 2.1 flow.
|
|
238
|
-
*
|
|
239
|
-
* Generates a unique authorization code with prefix, stores the code data
|
|
240
|
-
* as a JSON file, and returns the code identifier.
|
|
241
|
-
*
|
|
242
|
-
* @param clientId - The client identifier
|
|
243
|
-
* @param redirectUri - The redirect URI for this code
|
|
244
|
-
* @param resource - The resource this code grants access to
|
|
245
|
-
* @param ttlMs - Time-to-live in milliseconds
|
|
246
|
-
* @returns The generated authorization code with prefix
|
|
247
|
-
* @throws Error if code creation fails
|
|
248
|
-
*/
|
|
249
|
-
createAuthCode(clientId, redirectUri, resource, ttlMs) {
|
|
250
|
-
const code = AUTH_CONFIG.SERVER.PREFIXES.AUTH_CODE + randomUUID();
|
|
251
|
-
const authCodeData = {
|
|
252
|
-
clientId,
|
|
253
|
-
redirectUri,
|
|
254
|
-
resource,
|
|
255
|
-
expires: Date.now() + ttlMs,
|
|
256
|
-
createdAt: Date.now(),
|
|
257
|
-
};
|
|
258
|
-
try {
|
|
259
|
-
const filePath = this.getAuthCodeFilePath(code);
|
|
260
|
-
fs.writeFileSync(filePath, JSON.stringify(authCodeData, null, 2));
|
|
261
|
-
logger.info(`Created auth code: ${code} for client: ${clientId}`);
|
|
262
|
-
return code;
|
|
263
|
-
}
|
|
264
|
-
catch (error) {
|
|
265
|
-
logger.error(`Failed to create auth code: ${error}`);
|
|
266
|
-
throw error;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Retrieves authorization code data by code.
|
|
271
|
-
*
|
|
272
|
-
* Reads the auth code file and validates expiration. If the code
|
|
273
|
-
* is expired, it's automatically deleted and null is returned.
|
|
274
|
-
*
|
|
275
|
-
* @param code - The authorization code to retrieve
|
|
276
|
-
* @returns Auth code data if valid and not expired, null otherwise
|
|
277
|
-
*/
|
|
278
|
-
getAuthCode(code) {
|
|
279
|
-
if (!this.isValidId(code)) {
|
|
280
|
-
logger.warn(`Rejected getAuthCode with invalid code: ${code}`);
|
|
281
|
-
return null;
|
|
282
|
-
}
|
|
283
|
-
try {
|
|
284
|
-
const filePath = this.getAuthCodeFilePath(code);
|
|
285
|
-
if (!fs.existsSync(filePath)) {
|
|
286
|
-
return null;
|
|
287
|
-
}
|
|
288
|
-
const data = fs.readFileSync(filePath, 'utf8');
|
|
289
|
-
const authCodeData = JSON.parse(data);
|
|
290
|
-
if (authCodeData.expires < Date.now()) {
|
|
291
|
-
this.deleteAuthCode(code);
|
|
292
|
-
return null;
|
|
293
|
-
}
|
|
294
|
-
return authCodeData;
|
|
295
|
-
}
|
|
296
|
-
catch (error) {
|
|
297
|
-
logger.error(`Failed to read auth code ${code}: ${error}`);
|
|
298
|
-
return null;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* Deletes an authorization code by code.
|
|
303
|
-
*
|
|
304
|
-
* Removes the auth code file from the filesystem if it exists.
|
|
305
|
-
*
|
|
306
|
-
* @param code - The authorization code to delete
|
|
307
|
-
* @returns True if code was deleted, false if it didn't exist
|
|
308
|
-
*/
|
|
309
|
-
deleteAuthCode(code) {
|
|
310
|
-
if (!this.isValidId(code)) {
|
|
311
|
-
logger.warn(`Rejected deleteAuthCode with invalid code: ${code}`);
|
|
312
|
-
return false;
|
|
313
|
-
}
|
|
314
|
-
try {
|
|
315
|
-
const filePath = this.getAuthCodeFilePath(code);
|
|
316
|
-
if (fs.existsSync(filePath)) {
|
|
317
|
-
fs.unlinkSync(filePath);
|
|
318
|
-
logger.info(`Deleted auth code: ${code}`);
|
|
319
|
-
return true;
|
|
320
|
-
}
|
|
321
|
-
return false;
|
|
322
|
-
}
|
|
323
|
-
catch (error) {
|
|
324
|
-
logger.error(`Failed to delete auth code ${code}: ${error}`);
|
|
325
|
-
return false;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
/**
|
|
329
|
-
* Starts the automatic cleanup interval for expired sessions.
|
|
330
|
-
*
|
|
331
|
-
* Runs cleanup every 5 minutes to remove expired sessions and
|
|
332
|
-
* authorization codes from the filesystem.
|
|
333
|
-
*/
|
|
334
|
-
startCleanupInterval() {
|
|
335
|
-
// Clean up expired sessions every 5 minutes
|
|
336
|
-
this.cleanupInterval = setInterval(() => {
|
|
337
|
-
this.cleanupExpiredSessions();
|
|
338
|
-
}, 5 * 60 * 1000);
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* Cleans up expired sessions and authorization codes.
|
|
342
|
-
*
|
|
343
|
-
* Scans the session storage directory and removes all expired
|
|
344
|
-
* session and auth code files. Also handles corrupted files
|
|
345
|
-
* by removing them to prevent future errors.
|
|
346
|
-
*/
|
|
347
|
-
cleanupExpiredSessions() {
|
|
348
|
-
this.cleanupExpiredServerSessions();
|
|
349
|
-
}
|
|
350
|
-
/**
|
|
351
|
-
* Cleans up expired server sessions and authorization codes.
|
|
352
|
-
*/
|
|
353
|
-
cleanupExpiredServerSessions() {
|
|
354
|
-
try {
|
|
355
|
-
const files = fs.readdirSync(this.sessionStoragePath);
|
|
356
|
-
let cleanedCount = 0;
|
|
357
|
-
for (const file of files) {
|
|
358
|
-
if (file.endsWith(AUTH_CONFIG.SERVER.SESSION.FILE_EXTENSION)) {
|
|
359
|
-
const filePath = path.join(this.sessionStoragePath, file);
|
|
360
|
-
try {
|
|
361
|
-
const data = fs.readFileSync(filePath, 'utf8');
|
|
362
|
-
const sessionData = JSON.parse(data);
|
|
363
|
-
if (sessionData.expires < Date.now()) {
|
|
364
|
-
fs.unlinkSync(filePath);
|
|
365
|
-
cleanedCount++;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
catch (error) {
|
|
369
|
-
logger.warn(`Failed to process session file ${file}: ${error}`);
|
|
370
|
-
// Remove corrupted files
|
|
371
|
-
try {
|
|
372
|
-
fs.unlinkSync(filePath);
|
|
373
|
-
cleanedCount++;
|
|
374
|
-
}
|
|
375
|
-
catch (unlinkError) {
|
|
376
|
-
logger.error(`Failed to remove corrupted file ${file}: ${unlinkError}`);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
if (cleanedCount > 0) {
|
|
382
|
-
logger.info(`Cleaned up ${cleanedCount} expired server sessions`);
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
catch (error) {
|
|
386
|
-
logger.error(`Failed to cleanup expired server sessions: ${error}`);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
|
-
* Performs graceful shutdown of the SessionManager.
|
|
391
|
-
*
|
|
392
|
-
* Stops the cleanup interval to prevent memory leaks and
|
|
393
|
-
* ensures proper resource cleanup.
|
|
394
|
-
*/
|
|
395
|
-
shutdown() {
|
|
396
|
-
if (this.cleanupInterval) {
|
|
397
|
-
clearInterval(this.cleanupInterval);
|
|
398
|
-
this.cleanupInterval = null;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Creates a new session with a custom ID (no prefix).
|
|
403
|
-
* Used for access tokens where the token ID is generated separately.
|
|
404
|
-
*
|
|
405
|
-
* @param tokenId - The raw UUID to use for the session (no prefix)
|
|
406
|
-
* @param clientId - The client identifier
|
|
407
|
-
* @param resource - The resource this session can access
|
|
408
|
-
* @param ttlMs - Time-to-live in milliseconds
|
|
409
|
-
* @returns The generated session ID with prefix
|
|
410
|
-
* @throws Error if session creation fails
|
|
411
|
-
*/
|
|
412
|
-
createSessionWithId(tokenId, clientId, resource, ttlMs) {
|
|
413
|
-
const sessionId = AUTH_CONFIG.SERVER.PREFIXES.SESSION_ID + tokenId;
|
|
414
|
-
const sessionData = {
|
|
415
|
-
clientId,
|
|
416
|
-
resource,
|
|
417
|
-
expires: Date.now() + ttlMs,
|
|
418
|
-
createdAt: Date.now(),
|
|
419
|
-
};
|
|
420
|
-
try {
|
|
421
|
-
const filePath = this.getSessionFilePath(sessionId);
|
|
422
|
-
fs.writeFileSync(filePath, JSON.stringify(sessionData, null, 2));
|
|
423
|
-
logger.info(`Created session: ${sessionId} for client: ${clientId}`);
|
|
424
|
-
return sessionId;
|
|
425
|
-
}
|
|
426
|
-
catch (error) {
|
|
427
|
-
logger.error(`Failed to create session: ${error}`);
|
|
428
|
-
throw error;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
/**
|
|
432
|
-
* Creates a new session with custom data.
|
|
433
|
-
* Used for OAuth client data storage where arbitrary data needs to be stored.
|
|
434
|
-
*
|
|
435
|
-
* @param sessionId - The session ID to use
|
|
436
|
-
* @param data - The custom data to store
|
|
437
|
-
* @param ttlMs - Time-to-live in milliseconds
|
|
438
|
-
* @returns The session ID
|
|
439
|
-
* @throws Error if session creation fails
|
|
440
|
-
*/
|
|
441
|
-
createSessionWithData(sessionId, data, ttlMs) {
|
|
442
|
-
const sessionData = {
|
|
443
|
-
clientId: 'oauth-client-data',
|
|
444
|
-
resource: 'internal',
|
|
445
|
-
expires: Date.now() + ttlMs,
|
|
446
|
-
createdAt: Date.now(),
|
|
447
|
-
data,
|
|
448
|
-
};
|
|
449
|
-
try {
|
|
450
|
-
const filePath = this.getSessionFilePath(sessionId);
|
|
451
|
-
fs.writeFileSync(filePath, JSON.stringify(sessionData, null, 2));
|
|
452
|
-
logger.info(`Created data session: ${sessionId}`);
|
|
453
|
-
return sessionId;
|
|
454
|
-
}
|
|
455
|
-
catch (error) {
|
|
456
|
-
logger.error(`Failed to create data session: ${error}`);
|
|
457
|
-
throw error;
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
//# sourceMappingURL=serverSessionManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serverSessionManager.js","sourceRoot":"","sources":["../../src/auth/serverSessionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGlE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,oBAAoB;IACvB,kBAAkB,CAAS;IAC3B,eAAe,GAA0C,IAAI,CAAC;IAEtE;;;;;;;OAO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BAA6B,KAAK,EAAE,CAAC,CAAC;YACnD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;;;;;;;;OASG;IACI,qBAAqB,CAAC,SAAiB,EAAE,IAAY,EAAE,KAAa;QACzE,MAAM,WAAW,GAAgB;YAC/B,QAAQ,EAAE,mBAAmB;YAC7B,QAAQ,EAAE,UAAU;YACpB,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;YAC3B,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,IAAI;SACL,CAAC;QAEF,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;YACpD,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YACjE,MAAM,CAAC,IAAI,CAAC,yBAAyB,SAAS,EAAE,CAAC,CAAC;YAClD,OAAO,SAAS,CAAC;QACnB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,kCAAkC,KAAK,EAAE,CAAC,CAAC;YACxD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
|
-
export default function createClient(): Promise<Client<{
|
|
3
|
-
method: string;
|
|
4
|
-
params?: {
|
|
5
|
-
[x: string]: unknown;
|
|
6
|
-
_meta?: {
|
|
7
|
-
[x: string]: unknown;
|
|
8
|
-
progressToken?: string | number | undefined;
|
|
9
|
-
} | undefined;
|
|
10
|
-
} | undefined;
|
|
11
|
-
}, {
|
|
12
|
-
method: string;
|
|
13
|
-
params?: {
|
|
14
|
-
[x: string]: unknown;
|
|
15
|
-
_meta?: {
|
|
16
|
-
[x: string]: unknown;
|
|
17
|
-
} | undefined;
|
|
18
|
-
} | undefined;
|
|
19
|
-
}, {
|
|
20
|
-
[x: string]: unknown;
|
|
21
|
-
_meta?: {
|
|
22
|
-
[x: string]: unknown;
|
|
23
|
-
} | undefined;
|
|
24
|
-
}>>;
|
|
25
|
-
//# sourceMappingURL=clientFactory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clientFactory.d.ts","sourceRoot":"","sources":["../../../src/core/client/clientFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAGnE,wBAA8B,YAAY;;;;;;;;;;;;;;;;;;;;;;IAYzC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
|
-
import { MCP_SERVER_NAME, MCP_SERVER_VERSION, MCP_CLIENT_CAPABILITIES } from '../../constants.js';
|
|
3
|
-
export default async function createClient() {
|
|
4
|
-
const client = new Client({
|
|
5
|
-
name: MCP_SERVER_NAME,
|
|
6
|
-
version: MCP_SERVER_VERSION,
|
|
7
|
-
}, {
|
|
8
|
-
capabilities: MCP_CLIENT_CAPABILITIES,
|
|
9
|
-
});
|
|
10
|
-
return client;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=clientFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clientFactory.js","sourceRoot":"","sources":["../../../src/core/client/clientFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAElG,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,YAAY;IACxC,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB;QACE,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE,kBAAkB;KAC5B,EACD;QACE,YAAY,EAAE,uBAAuB;KACtC,CACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|