@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../src/utils/pagination.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../src/utils/pagination.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAA2C,MAAM,wBAAwB,CAAC;AAC/F,OAAO,MAAM,MAAM,qBAAqB,CAAC;AA0BzC,MAAM,UAAU,WAAW,CAAC,MAAe;IACzC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC1C,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;IAC5B,CAAC;IAED,yBAAyB;IACzB,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3C,MAAM,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAC;QACvD,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;IAC5B,CAAC;IAED,IAAI,CAAC;QACH,2BAA2B;QAC3B,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAEhE,sEAAsE;QACtE,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,EAAE,CAAC;YACtC,0BAA0B;YAC1B,MAAM,CAAC,IAAI,CAAC,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B,EAAE,UAAU,EAAE,CAAC;AACjD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { ClientSessionData } from './sessionTypes.js';
|
|
2
|
-
/**
|
|
3
|
-
* ClientSessionManager handles file-based client session storage with automatic cleanup.
|
|
4
|
-
*
|
|
5
|
-
* This class manages OAuth 2.1 client sessions using the local filesystem.
|
|
6
|
-
* It provides automatic cleanup of expired sessions and supports configurable
|
|
7
|
-
* storage locations separate from server sessions.
|
|
8
|
-
*
|
|
9
|
-
* Features:
|
|
10
|
-
* - File-based client session storage with JSON format
|
|
11
|
-
* - Automatic cleanup of expired client sessions
|
|
12
|
-
* - Server name sanitization for safe filenames
|
|
13
|
-
* - Configurable storage directory
|
|
14
|
-
* - Unified session data per server
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const clientSessionManager = new ClientSessionManager();
|
|
19
|
-
* const sessionData = { serverName: 'test', ... };
|
|
20
|
-
* clientSessionManager.createClientSession('test', sessionData);
|
|
21
|
-
* const session = clientSessionManager.getClientSession('test');
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export declare class ClientSessionManager {
|
|
25
|
-
private clientSessionStoragePath;
|
|
26
|
-
/**
|
|
27
|
-
* Creates a new ClientSessionManager instance.
|
|
28
|
-
*
|
|
29
|
-
* Initializes the client session storage directory.
|
|
30
|
-
*
|
|
31
|
-
* @param clientSessionStoragePath - Optional custom path for client session storage
|
|
32
|
-
*/
|
|
33
|
-
constructor(clientSessionStoragePath?: string);
|
|
34
|
-
/**
|
|
35
|
-
* Gets the client session storage path.
|
|
36
|
-
*
|
|
37
|
-
* @returns The absolute path to the client session storage directory
|
|
38
|
-
*/
|
|
39
|
-
getClientSessionStoragePath(): string;
|
|
40
|
-
/**
|
|
41
|
-
* Ensures the client session storage directory exists.
|
|
42
|
-
*
|
|
43
|
-
* Creates the directory structure if it doesn't exist, including
|
|
44
|
-
* parent directories as needed.
|
|
45
|
-
*
|
|
46
|
-
* @throws Error if directory creation fails
|
|
47
|
-
*/
|
|
48
|
-
private ensureClientSessionDirectory;
|
|
49
|
-
/**
|
|
50
|
-
* Gets the file path for a client session.
|
|
51
|
-
*
|
|
52
|
-
* @param serverName - The server name for the client session
|
|
53
|
-
* @returns Full file path for the client session file
|
|
54
|
-
*/
|
|
55
|
-
private getClientSessionFilePath;
|
|
56
|
-
/**
|
|
57
|
-
* Creates or updates a client session.
|
|
58
|
-
*
|
|
59
|
-
* @param serverName - The server name for the client session
|
|
60
|
-
* @param clientSessionData - The client session data to store
|
|
61
|
-
* @returns The server name
|
|
62
|
-
* @throws Error if client session creation fails
|
|
63
|
-
*/
|
|
64
|
-
createClientSession(serverName: string, clientSessionData: ClientSessionData): string;
|
|
65
|
-
/**
|
|
66
|
-
* Retrieves client session data by server name.
|
|
67
|
-
*
|
|
68
|
-
* @param serverName - The server name to retrieve client session for
|
|
69
|
-
* @returns Client session data if valid and not expired, null otherwise
|
|
70
|
-
*/
|
|
71
|
-
getClientSession(serverName: string): ClientSessionData | null;
|
|
72
|
-
/**
|
|
73
|
-
* Deletes a client session by server name.
|
|
74
|
-
*
|
|
75
|
-
* @param serverName - The server name to delete client session for
|
|
76
|
-
* @returns True if client session was deleted, false if it didn't exist
|
|
77
|
-
*/
|
|
78
|
-
deleteClientSession(serverName: string): boolean;
|
|
79
|
-
/**
|
|
80
|
-
* Cleans up expired client sessions.
|
|
81
|
-
*
|
|
82
|
-
* Scans the client session storage directory and removes all expired
|
|
83
|
-
* client session files. Also handles corrupted files by removing them
|
|
84
|
-
* to prevent future errors.
|
|
85
|
-
*/
|
|
86
|
-
cleanupExpiredClientSessions(): void;
|
|
87
|
-
/**
|
|
88
|
-
* Lists all client session files in the storage directory.
|
|
89
|
-
*
|
|
90
|
-
* @returns Array of server names that have client sessions
|
|
91
|
-
*/
|
|
92
|
-
listClientSessions(): string[];
|
|
93
|
-
}
|
|
94
|
-
//# sourceMappingURL=clientSessionManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clientSessionManager.d.ts","sourceRoot":"","sources":["../../src/auth/clientSessionManager.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGtD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,wBAAwB,CAAS;IAEzC;;;;;;OAMG;gBACS,wBAAwB,CAAC,EAAE,MAAM;IAK7C;;;;OAIG;IACI,2BAA2B,IAAI,MAAM;IAI5C;;;;;;;OAOG;IACH,OAAO,CAAC,4BAA4B;IAYpC;;;;;OAKG;IACH,OAAO,CAAC,wBAAwB;IAgBhC;;;;;;;OAOG;IACI,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,iBAAiB,EAAE,iBAAiB,GAAG,MAAM;IAY5F;;;;;OAKG;IACI,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI;IAsBrE;;;;;OAKG;IACI,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAevD;;;;;;OAMG;IACI,4BAA4B,IAAI,IAAI;IAyC3C;;;;OAIG;IACI,kBAAkB,IAAI,MAAM,EAAE;CAetC"}
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import logger from '../logger/logger.js';
|
|
4
|
-
import { getGlobalConfigDir } from '../constants.js';
|
|
5
|
-
import { sanitizeServerName } from '../utils/sanitization.js';
|
|
6
|
-
/**
|
|
7
|
-
* ClientSessionManager handles file-based client session storage with automatic cleanup.
|
|
8
|
-
*
|
|
9
|
-
* This class manages OAuth 2.1 client sessions using the local filesystem.
|
|
10
|
-
* It provides automatic cleanup of expired sessions and supports configurable
|
|
11
|
-
* storage locations separate from server sessions.
|
|
12
|
-
*
|
|
13
|
-
* Features:
|
|
14
|
-
* - File-based client session storage with JSON format
|
|
15
|
-
* - Automatic cleanup of expired client sessions
|
|
16
|
-
* - Server name sanitization for safe filenames
|
|
17
|
-
* - Configurable storage directory
|
|
18
|
-
* - Unified session data per server
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* const clientSessionManager = new ClientSessionManager();
|
|
23
|
-
* const sessionData = { serverName: 'test', ... };
|
|
24
|
-
* clientSessionManager.createClientSession('test', sessionData);
|
|
25
|
-
* const session = clientSessionManager.getClientSession('test');
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export class ClientSessionManager {
|
|
29
|
-
clientSessionStoragePath;
|
|
30
|
-
/**
|
|
31
|
-
* Creates a new ClientSessionManager instance.
|
|
32
|
-
*
|
|
33
|
-
* Initializes the client session storage directory.
|
|
34
|
-
*
|
|
35
|
-
* @param clientSessionStoragePath - Optional custom path for client session storage
|
|
36
|
-
*/
|
|
37
|
-
constructor(clientSessionStoragePath) {
|
|
38
|
-
this.clientSessionStoragePath = clientSessionStoragePath || path.join(getGlobalConfigDir(), 'clientSessions');
|
|
39
|
-
this.ensureClientSessionDirectory();
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Gets the client session storage path.
|
|
43
|
-
*
|
|
44
|
-
* @returns The absolute path to the client session storage directory
|
|
45
|
-
*/
|
|
46
|
-
getClientSessionStoragePath() {
|
|
47
|
-
return this.clientSessionStoragePath;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Ensures the client session storage directory exists.
|
|
51
|
-
*
|
|
52
|
-
* Creates the directory structure if it doesn't exist, including
|
|
53
|
-
* parent directories as needed.
|
|
54
|
-
*
|
|
55
|
-
* @throws Error if directory creation fails
|
|
56
|
-
*/
|
|
57
|
-
ensureClientSessionDirectory() {
|
|
58
|
-
try {
|
|
59
|
-
if (!fs.existsSync(this.clientSessionStoragePath)) {
|
|
60
|
-
fs.mkdirSync(this.clientSessionStoragePath, { recursive: true });
|
|
61
|
-
logger.info(`Created client session storage directory: ${this.clientSessionStoragePath}`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
logger.error(`Failed to create client session directory: ${error}`);
|
|
66
|
-
throw error;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Gets the file path for a client session.
|
|
71
|
-
*
|
|
72
|
-
* @param serverName - The server name for the client session
|
|
73
|
-
* @returns Full file path for the client session file
|
|
74
|
-
*/
|
|
75
|
-
getClientSessionFilePath(serverName) {
|
|
76
|
-
const sanitizedServerName = sanitizeServerName(serverName);
|
|
77
|
-
const fileName = `oauth_${sanitizedServerName}.json`;
|
|
78
|
-
const filePath = path.resolve(this.clientSessionStoragePath, fileName);
|
|
79
|
-
// Additional security check: ensure resolved path is within client session storage
|
|
80
|
-
const normalizedStoragePath = path.resolve(this.clientSessionStoragePath);
|
|
81
|
-
const normalizedFilePath = path.resolve(filePath);
|
|
82
|
-
if (!normalizedFilePath.startsWith(normalizedStoragePath + path.sep)) {
|
|
83
|
-
throw new Error('Invalid client session file path: outside storage directory');
|
|
84
|
-
}
|
|
85
|
-
return filePath;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Creates or updates a client session.
|
|
89
|
-
*
|
|
90
|
-
* @param serverName - The server name for the client session
|
|
91
|
-
* @param clientSessionData - The client session data to store
|
|
92
|
-
* @returns The server name
|
|
93
|
-
* @throws Error if client session creation fails
|
|
94
|
-
*/
|
|
95
|
-
createClientSession(serverName, clientSessionData) {
|
|
96
|
-
try {
|
|
97
|
-
const filePath = this.getClientSessionFilePath(serverName);
|
|
98
|
-
fs.writeFileSync(filePath, JSON.stringify(clientSessionData, null, 2));
|
|
99
|
-
logger.info(`Created/updated client session for server: ${serverName}`);
|
|
100
|
-
return serverName;
|
|
101
|
-
}
|
|
102
|
-
catch (error) {
|
|
103
|
-
logger.error(`Failed to create client session for ${serverName}: ${error}`);
|
|
104
|
-
throw error;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Retrieves client session data by server name.
|
|
109
|
-
*
|
|
110
|
-
* @param serverName - The server name to retrieve client session for
|
|
111
|
-
* @returns Client session data if valid and not expired, null otherwise
|
|
112
|
-
*/
|
|
113
|
-
getClientSession(serverName) {
|
|
114
|
-
try {
|
|
115
|
-
const filePath = this.getClientSessionFilePath(serverName);
|
|
116
|
-
if (!fs.existsSync(filePath)) {
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
const data = fs.readFileSync(filePath, 'utf8');
|
|
120
|
-
const clientSessionData = JSON.parse(data);
|
|
121
|
-
if (clientSessionData.expires < Date.now()) {
|
|
122
|
-
this.deleteClientSession(serverName);
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
return clientSessionData;
|
|
126
|
-
}
|
|
127
|
-
catch (error) {
|
|
128
|
-
logger.error(`Failed to read client session for ${serverName}: ${error}`);
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Deletes a client session by server name.
|
|
134
|
-
*
|
|
135
|
-
* @param serverName - The server name to delete client session for
|
|
136
|
-
* @returns True if client session was deleted, false if it didn't exist
|
|
137
|
-
*/
|
|
138
|
-
deleteClientSession(serverName) {
|
|
139
|
-
try {
|
|
140
|
-
const filePath = this.getClientSessionFilePath(serverName);
|
|
141
|
-
if (fs.existsSync(filePath)) {
|
|
142
|
-
fs.unlinkSync(filePath);
|
|
143
|
-
logger.info(`Deleted client session for server: ${serverName}`);
|
|
144
|
-
return true;
|
|
145
|
-
}
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
catch (error) {
|
|
149
|
-
logger.error(`Failed to delete client session for ${serverName}: ${error}`);
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Cleans up expired client sessions.
|
|
155
|
-
*
|
|
156
|
-
* Scans the client session storage directory and removes all expired
|
|
157
|
-
* client session files. Also handles corrupted files by removing them
|
|
158
|
-
* to prevent future errors.
|
|
159
|
-
*/
|
|
160
|
-
cleanupExpiredClientSessions() {
|
|
161
|
-
try {
|
|
162
|
-
if (!fs.existsSync(this.clientSessionStoragePath)) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
const files = fs.readdirSync(this.clientSessionStoragePath);
|
|
166
|
-
let cleanedCount = 0;
|
|
167
|
-
for (const file of files) {
|
|
168
|
-
if (file.endsWith('.json') && file.startsWith('oauth_')) {
|
|
169
|
-
const filePath = path.join(this.clientSessionStoragePath, file);
|
|
170
|
-
try {
|
|
171
|
-
const data = fs.readFileSync(filePath, 'utf8');
|
|
172
|
-
const clientSessionData = JSON.parse(data);
|
|
173
|
-
if (clientSessionData.expires < Date.now()) {
|
|
174
|
-
fs.unlinkSync(filePath);
|
|
175
|
-
cleanedCount++;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
catch (error) {
|
|
179
|
-
logger.warn(`Failed to process client session file ${file}: ${error}`);
|
|
180
|
-
// Remove corrupted files
|
|
181
|
-
try {
|
|
182
|
-
fs.unlinkSync(filePath);
|
|
183
|
-
cleanedCount++;
|
|
184
|
-
}
|
|
185
|
-
catch (unlinkError) {
|
|
186
|
-
logger.error(`Failed to remove corrupted client session file ${file}: ${unlinkError}`);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
if (cleanedCount > 0) {
|
|
192
|
-
logger.info(`Cleaned up ${cleanedCount} expired client sessions`);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
catch (error) {
|
|
196
|
-
logger.error(`Failed to cleanup expired client sessions: ${error}`);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Lists all client session files in the storage directory.
|
|
201
|
-
*
|
|
202
|
-
* @returns Array of server names that have client sessions
|
|
203
|
-
*/
|
|
204
|
-
listClientSessions() {
|
|
205
|
-
try {
|
|
206
|
-
if (!fs.existsSync(this.clientSessionStoragePath)) {
|
|
207
|
-
return [];
|
|
208
|
-
}
|
|
209
|
-
const files = fs.readdirSync(this.clientSessionStoragePath);
|
|
210
|
-
return files
|
|
211
|
-
.filter((file) => file.endsWith('.json') && file.startsWith('oauth_'))
|
|
212
|
-
.map((file) => file.substring(6, file.length - 5)); // Remove 'oauth_' prefix and '.json' suffix
|
|
213
|
-
}
|
|
214
|
-
catch (error) {
|
|
215
|
-
logger.error(`Failed to list client sessions: ${error}`);
|
|
216
|
-
return [];
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
//# sourceMappingURL=clientSessionManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clientSessionManager.js","sourceRoot":"","sources":["../../src/auth/clientSessionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,oBAAoB;IACvB,wBAAwB,CAAS;IAEzC;;;;;;OAMG;IACH,YAAY,wBAAiC;QAC3C,IAAI,CAAC,wBAAwB,GAAG,wBAAwB,IAAI,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,gBAAgB,CAAC,CAAC;QAC9G,IAAI,CAAC,4BAA4B,EAAE,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACI,2BAA2B;QAChC,OAAO,IAAI,CAAC,wBAAwB,CAAC;IACvC,CAAC;IAED;;;;;;;OAOG;IACK,4BAA4B;QAClC,IAAI,CAAC;YACH,IAAI,CAAC,EAAE,CAAC,UAAU,CA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E,CAAC;QACZ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { SessionData, AuthCodeData } from './sessionTypes.js';
|
|
2
|
-
/**
|
|
3
|
-
* SessionManager handles file-based session storage with automatic cleanup.
|
|
4
|
-
*
|
|
5
|
-
* This class manages OAuth 2.1 sessions and authorization codes using
|
|
6
|
-
* the local filesystem. It provides automatic cleanup of expired sessions
|
|
7
|
-
* and supports configurable storage locations.
|
|
8
|
-
*
|
|
9
|
-
* Features:
|
|
10
|
-
* - File-based session storage with JSON format
|
|
11
|
-
* - Automatic cleanup of expired sessions every 5 minutes
|
|
12
|
-
* - Prefixed identifiers for easy debugging
|
|
13
|
-
* - Configurable storage directory
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* const sessionManager = new SessionManager('/custom/path');
|
|
18
|
-
* const sessionId = sessionManager.createSession('client-123', 'resource', 3600000);
|
|
19
|
-
* const session = sessionManager.getSession(sessionId);
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export declare class ServerSessionManager {
|
|
23
|
-
private sessionStoragePath;
|
|
24
|
-
private cleanupInterval;
|
|
25
|
-
/**
|
|
26
|
-
* Creates a new SessionManager instance.
|
|
27
|
-
*
|
|
28
|
-
* Initializes the session storage directory and starts the automatic
|
|
29
|
-
* cleanup process for expired sessions.
|
|
30
|
-
*
|
|
31
|
-
* @param sessionStoragePath - Optional custom path for session storage
|
|
32
|
-
*/
|
|
33
|
-
constructor(sessionStoragePath?: string);
|
|
34
|
-
/**
|
|
35
|
-
* Gets the session storage path.
|
|
36
|
-
*
|
|
37
|
-
* @returns The absolute path to the session storage directory
|
|
38
|
-
*/
|
|
39
|
-
getSessionStoragePath(): string;
|
|
40
|
-
/**
|
|
41
|
-
* Ensures the session storage directory exists.
|
|
42
|
-
*
|
|
43
|
-
* Creates the directory structure if it doesn't exist, including
|
|
44
|
-
* parent directories as needed.
|
|
45
|
-
*
|
|
46
|
-
* @throws Error if directory creation fails
|
|
47
|
-
*/
|
|
48
|
-
private ensureSessionDirectory;
|
|
49
|
-
/**
|
|
50
|
-
* Gets the file path for a session ID.
|
|
51
|
-
*
|
|
52
|
-
* @param sessionId - The session identifier
|
|
53
|
-
* @returns Full file path for the session file
|
|
54
|
-
*/
|
|
55
|
-
private getSessionFilePath;
|
|
56
|
-
/**
|
|
57
|
-
* Gets the file path for an authorization code.
|
|
58
|
-
*
|
|
59
|
-
* @param code - The authorization code
|
|
60
|
-
* @returns Full file path for the auth code file
|
|
61
|
-
*/
|
|
62
|
-
private getAuthCodeFilePath;
|
|
63
|
-
/**
|
|
64
|
-
* Utility to validate session IDs and auth codes for proper format and security.
|
|
65
|
-
* Ensures proper format with prefix and UUID structure for security.
|
|
66
|
-
* @param id - The session ID or auth code to validate
|
|
67
|
-
* @returns true if valid, false otherwise
|
|
68
|
-
*/
|
|
69
|
-
private isValidId;
|
|
70
|
-
/**
|
|
71
|
-
* Creates a new session with the specified parameters.
|
|
72
|
-
*
|
|
73
|
-
* Generates a unique session ID with prefix, stores the session data
|
|
74
|
-
* as a JSON file, and returns the session identifier.
|
|
75
|
-
*
|
|
76
|
-
* @param clientId - The client identifier
|
|
77
|
-
* @param resource - The resource this session can access
|
|
78
|
-
* @param ttlMs - Time-to-live in milliseconds
|
|
79
|
-
* @returns The generated session ID with prefix
|
|
80
|
-
* @throws Error if session creation fails
|
|
81
|
-
*/
|
|
82
|
-
createSession(clientId: string, resource: string, ttlMs: number): string;
|
|
83
|
-
/**
|
|
84
|
-
* Retrieves session data by session ID.
|
|
85
|
-
*
|
|
86
|
-
* Reads the session file and validates expiration. If the session
|
|
87
|
-
* is expired, it's automatically deleted and null is returned.
|
|
88
|
-
*
|
|
89
|
-
* @param sessionId - The session identifier to retrieve
|
|
90
|
-
* @returns Session data if valid and not expired, null otherwise
|
|
91
|
-
*/
|
|
92
|
-
getSession(sessionId: string): SessionData | null;
|
|
93
|
-
/**
|
|
94
|
-
* Deletes a session by session ID.
|
|
95
|
-
*
|
|
96
|
-
* Removes the session file from the filesystem if it exists.
|
|
97
|
-
*
|
|
98
|
-
* @param sessionId - The session identifier to delete
|
|
99
|
-
* @returns True if session was deleted, false if it didn't exist
|
|
100
|
-
*/
|
|
101
|
-
deleteSession(sessionId: string): boolean;
|
|
102
|
-
/**
|
|
103
|
-
* Creates a new authorization code for OAuth 2.1 flow.
|
|
104
|
-
*
|
|
105
|
-
* Generates a unique authorization code with prefix, stores the code data
|
|
106
|
-
* as a JSON file, and returns the code identifier.
|
|
107
|
-
*
|
|
108
|
-
* @param clientId - The client identifier
|
|
109
|
-
* @param redirectUri - The redirect URI for this code
|
|
110
|
-
* @param resource - The resource this code grants access to
|
|
111
|
-
* @param ttlMs - Time-to-live in milliseconds
|
|
112
|
-
* @returns The generated authorization code with prefix
|
|
113
|
-
* @throws Error if code creation fails
|
|
114
|
-
*/
|
|
115
|
-
createAuthCode(clientId: string, redirectUri: string, resource: string, ttlMs: number): string;
|
|
116
|
-
/**
|
|
117
|
-
* Retrieves authorization code data by code.
|
|
118
|
-
*
|
|
119
|
-
* Reads the auth code file and validates expiration. If the code
|
|
120
|
-
* is expired, it's automatically deleted and null is returned.
|
|
121
|
-
*
|
|
122
|
-
* @param code - The authorization code to retrieve
|
|
123
|
-
* @returns Auth code data if valid and not expired, null otherwise
|
|
124
|
-
*/
|
|
125
|
-
getAuthCode(code: string): AuthCodeData | null;
|
|
126
|
-
/**
|
|
127
|
-
* Deletes an authorization code by code.
|
|
128
|
-
*
|
|
129
|
-
* Removes the auth code file from the filesystem if it exists.
|
|
130
|
-
*
|
|
131
|
-
* @param code - The authorization code to delete
|
|
132
|
-
* @returns True if code was deleted, false if it didn't exist
|
|
133
|
-
*/
|
|
134
|
-
deleteAuthCode(code: string): boolean;
|
|
135
|
-
/**
|
|
136
|
-
* Starts the automatic cleanup interval for expired sessions.
|
|
137
|
-
*
|
|
138
|
-
* Runs cleanup every 5 minutes to remove expired sessions and
|
|
139
|
-
* authorization codes from the filesystem.
|
|
140
|
-
*/
|
|
141
|
-
private startCleanupInterval;
|
|
142
|
-
/**
|
|
143
|
-
* Cleans up expired sessions and authorization codes.
|
|
144
|
-
*
|
|
145
|
-
* Scans the session storage directory and removes all expired
|
|
146
|
-
* session and auth code files. Also handles corrupted files
|
|
147
|
-
* by removing them to prevent future errors.
|
|
148
|
-
*/
|
|
149
|
-
private cleanupExpiredSessions;
|
|
150
|
-
/**
|
|
151
|
-
* Cleans up expired server sessions and authorization codes.
|
|
152
|
-
*/
|
|
153
|
-
private cleanupExpiredServerSessions;
|
|
154
|
-
/**
|
|
155
|
-
* Performs graceful shutdown of the SessionManager.
|
|
156
|
-
*
|
|
157
|
-
* Stops the cleanup interval to prevent memory leaks and
|
|
158
|
-
* ensures proper resource cleanup.
|
|
159
|
-
*/
|
|
160
|
-
shutdown(): void;
|
|
161
|
-
/**
|
|
162
|
-
* Creates a new session with a custom ID (no prefix).
|
|
163
|
-
* Used for access tokens where the token ID is generated separately.
|
|
164
|
-
*
|
|
165
|
-
* @param tokenId - The raw UUID to use for the session (no prefix)
|
|
166
|
-
* @param clientId - The client identifier
|
|
167
|
-
* @param resource - The resource this session can access
|
|
168
|
-
* @param ttlMs - Time-to-live in milliseconds
|
|
169
|
-
* @returns The generated session ID with prefix
|
|
170
|
-
* @throws Error if session creation fails
|
|
171
|
-
*/
|
|
172
|
-
createSessionWithId(tokenId: string, clientId: string, resource: string, ttlMs: number): string;
|
|
173
|
-
/**
|
|
174
|
-
* Creates a new session with custom data.
|
|
175
|
-
* Used for OAuth client data storage where arbitrary data needs to be stored.
|
|
176
|
-
*
|
|
177
|
-
* @param sessionId - The session ID to use
|
|
178
|
-
* @param data - The custom data to store
|
|
179
|
-
* @param ttlMs - Time-to-live in milliseconds
|
|
180
|
-
* @returns The session ID
|
|
181
|
-
* @throws Error if session creation fails
|
|
182
|
-
*/
|
|
183
|
-
createSessionWithData(sessionId: string, data: string, ttlMs: number): string;
|
|
184
|
-
}
|
|
185
|
-
//# sourceMappingURL=serverSessionManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serverSessionManager.d.ts","sourceRoot":"","sources":["../../src/auth/serverSessionManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,kBAAkB,CAAS;IACnC,OAAO,CAAC,eAAe,CAA+C;IAEtE;;;;;;;OAOG;gBACS,kBAAkB,CAAC,EAAE,MAAM;IAOvC;;;;OAIG;IACI,qBAAqB,IAAI,MAAM;IAItC;;;;;;;OAOG;IACH,OAAO,CAAC,sBAAsB;IAY9B;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAoB1B;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAoB3B;;;;;OAKG;IACH,OAAO,CAAC,SAAS;IAoCjB;;;;;;;;;;;OAWG;IACI,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAoB/E;;;;;;;;OAQG;IACI,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IA0BxD;;;;;;;OAOG;IACI,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAmBhD;;;;;;;;;;;;OAYG;IACI,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAqBrG;;;;;;;;OAQG;IACI,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IA0BrD;;;;;;;OAOG;IACI,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAmB5C;;;;;OAKG;IACH,OAAO,CAAC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