@1mcp/agent 0.10.3 → 0.12.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.
Files changed (147) hide show
  1. package/README.md +41 -17
  2. package/build/auth/authManager.d.ts +109 -0
  3. package/build/auth/authManager.d.ts.map +1 -0
  4. package/build/auth/authManager.js +173 -0
  5. package/build/auth/authManager.js.map +1 -0
  6. package/build/auth/authMiddleware.d.ts +16 -0
  7. package/build/auth/authMiddleware.d.ts.map +1 -0
  8. package/build/auth/authMiddleware.js +45 -0
  9. package/build/auth/authMiddleware.js.map +1 -0
  10. package/build/auth/sessionManager.d.ts +197 -0
  11. package/build/auth/sessionManager.d.ts.map +1 -0
  12. package/build/auth/sessionManager.js +408 -0
  13. package/build/auth/sessionManager.js.map +1 -0
  14. package/build/capabilities/capabilityManager.d.ts +1 -1
  15. package/build/capabilities/capabilityManager.d.ts.map +1 -1
  16. package/build/capabilities/capabilityManager.js +39 -6
  17. package/build/capabilities/capabilityManager.js.map +1 -1
  18. package/build/config/configManager.d.ts +7 -1
  19. package/build/config/configManager.d.ts.map +1 -1
  20. package/build/config/configManager.js +24 -2
  21. package/build/config/configManager.js.map +1 -1
  22. package/build/constants.d.ts +25 -1
  23. package/build/constants.d.ts.map +1 -1
  24. package/build/constants.js +31 -2
  25. package/build/constants.js.map +1 -1
  26. package/build/{client.d.ts → core/client/clientFactory.d.ts} +1 -1
  27. package/build/core/client/clientFactory.d.ts.map +1 -0
  28. package/build/{client.js → core/client/clientFactory.js} +2 -2
  29. package/build/core/client/clientFactory.js.map +1 -0
  30. package/build/{clients → core/client}/clientManager.d.ts +3 -2
  31. package/build/core/client/clientManager.d.ts.map +1 -0
  32. package/build/{clients → core/client}/clientManager.js +10 -6
  33. package/build/core/client/clientManager.js.map +1 -0
  34. package/build/core/server/serverConfig.d.ts +100 -0
  35. package/build/core/server/serverConfig.d.ts.map +1 -0
  36. package/build/core/server/serverConfig.js +117 -0
  37. package/build/core/server/serverConfig.js.map +1 -0
  38. package/build/{serverManager.d.ts → core/server/serverManager.d.ts} +7 -2
  39. package/build/core/server/serverManager.d.ts.map +1 -0
  40. package/build/core/server/serverManager.js +159 -0
  41. package/build/core/server/serverManager.js.map +1 -0
  42. package/build/core/types/client.d.ts +38 -0
  43. package/build/core/types/client.d.ts.map +1 -0
  44. package/build/core/types/client.js +13 -0
  45. package/build/core/types/client.js.map +1 -0
  46. package/build/core/types/index.d.ts +4 -0
  47. package/build/core/types/index.d.ts.map +1 -0
  48. package/build/core/types/index.js +5 -0
  49. package/build/core/types/index.js.map +1 -0
  50. package/build/core/types/server.d.ts +14 -0
  51. package/build/core/types/server.d.ts.map +1 -0
  52. package/build/core/types/server.js +2 -0
  53. package/build/core/types/server.js.map +1 -0
  54. package/build/{types.d.ts → core/types/transport.d.ts} +1 -48
  55. package/build/core/types/transport.d.ts.map +1 -0
  56. package/build/{types.js → core/types/transport.js} +1 -13
  57. package/build/core/types/transport.js.map +1 -0
  58. package/build/handlers/notificationHandlers.d.ts +1 -1
  59. package/build/handlers/notificationHandlers.d.ts.map +1 -1
  60. package/build/handlers/notificationHandlers.js +41 -15
  61. package/build/handlers/notificationHandlers.js.map +1 -1
  62. package/build/handlers/requestHandlers.d.ts +1 -1
  63. package/build/handlers/requestHandlers.d.ts.map +1 -1
  64. package/build/handlers/requestHandlers.js +65 -2
  65. package/build/handlers/requestHandlers.js.map +1 -1
  66. package/build/index.d.ts +1 -1
  67. package/build/index.d.ts.map +1 -1
  68. package/build/index.js +44 -5
  69. package/build/index.js.map +1 -1
  70. package/build/logger/logger.js +1 -1
  71. package/build/logger/logger.js.map +1 -1
  72. package/build/server.d.ts +1 -1
  73. package/build/server.d.ts.map +1 -1
  74. package/build/server.js +6 -3
  75. package/build/server.js.map +1 -1
  76. package/build/services/configReloadService.d.ts +15 -5
  77. package/build/services/configReloadService.d.ts.map +1 -1
  78. package/build/services/configReloadService.js +28 -11
  79. package/build/services/configReloadService.js.map +1 -1
  80. package/build/{config/transportConfig.d.ts → transport/config.d.ts} +2 -2
  81. package/build/transport/config.d.ts.map +1 -0
  82. package/build/{config/transportConfig.js → transport/config.js} +2 -2
  83. package/build/transport/config.js.map +1 -0
  84. package/build/transport/http/errorHandler.d.ts.map +1 -0
  85. package/build/{server → transport/http}/errorHandler.js +1 -1
  86. package/build/transport/http/errorHandler.js.map +1 -0
  87. package/build/transport/http/middleware/loggingMiddleware.d.ts.map +1 -0
  88. package/build/{middleware → transport/http/middleware}/loggingMiddleware.js +11 -7
  89. package/build/transport/http/middleware/loggingMiddleware.js.map +1 -0
  90. package/build/transport/http/routes/oauthRoutes.d.ts +14 -0
  91. package/build/transport/http/routes/oauthRoutes.d.ts.map +1 -0
  92. package/build/transport/http/routes/oauthRoutes.js +132 -0
  93. package/build/transport/http/routes/oauthRoutes.js.map +1 -0
  94. package/build/transport/http/routes/sseRoutes.d.ts +4 -0
  95. package/build/transport/http/routes/sseRoutes.d.ts.map +1 -0
  96. package/build/transport/http/routes/sseRoutes.js +64 -0
  97. package/build/transport/http/routes/sseRoutes.js.map +1 -0
  98. package/build/transport/http/routes/streamableHttpRoutes.d.ts +4 -0
  99. package/build/transport/http/routes/streamableHttpRoutes.d.ts.map +1 -0
  100. package/build/transport/http/routes/streamableHttpRoutes.js +121 -0
  101. package/build/transport/http/routes/streamableHttpRoutes.js.map +1 -0
  102. package/build/transport/http/server.d.ts +69 -0
  103. package/build/transport/http/server.d.ts.map +1 -0
  104. package/build/transport/http/server.js +115 -0
  105. package/build/transport/http/server.js.map +1 -0
  106. package/build/utils/clientFiltering.d.ts +1 -1
  107. package/build/utils/clientFiltering.d.ts.map +1 -1
  108. package/build/utils/errorHandling.d.ts +1 -0
  109. package/build/utils/errorHandling.d.ts.map +1 -1
  110. package/build/utils/errorHandling.js +29 -5
  111. package/build/utils/errorHandling.js.map +1 -1
  112. package/build/utils/errorTypes.d.ts +4 -1
  113. package/build/utils/errorTypes.d.ts.map +1 -1
  114. package/build/utils/errorTypes.js +12 -4
  115. package/build/utils/errorTypes.js.map +1 -1
  116. package/build/utils/pagination.d.ts +1 -1
  117. package/build/utils/pagination.d.ts.map +1 -1
  118. package/build/utils/pagination.js +84 -5
  119. package/build/utils/pagination.js.map +1 -1
  120. package/build/utils/tagsExtractor.d.ts.map +1 -0
  121. package/build/utils/tagsExtractor.js.map +1 -0
  122. package/package.json +14 -5
  123. package/build/client.d.ts.map +0 -1
  124. package/build/client.js.map +0 -1
  125. package/build/clients/clientManager.d.ts.map +0 -1
  126. package/build/clients/clientManager.js.map +0 -1
  127. package/build/config/transportConfig.d.ts.map +0 -1
  128. package/build/config/transportConfig.js.map +0 -1
  129. package/build/middleware/loggingMiddleware.d.ts.map +0 -1
  130. package/build/middleware/loggingMiddleware.js.map +0 -1
  131. package/build/server/errorHandler.d.ts.map +0 -1
  132. package/build/server/errorHandler.js.map +0 -1
  133. package/build/server/expressServer.d.ts +0 -11
  134. package/build/server/expressServer.d.ts.map +0 -1
  135. package/build/server/expressServer.js +0 -177
  136. package/build/server/expressServer.js.map +0 -1
  137. package/build/server/tagsExtractor.d.ts.map +0 -1
  138. package/build/server/tagsExtractor.js.map +0 -1
  139. package/build/serverManager.d.ts.map +0 -1
  140. package/build/serverManager.js +0 -87
  141. package/build/serverManager.js.map +0 -1
  142. package/build/types.d.ts.map +0 -1
  143. package/build/types.js.map +0 -1
  144. /package/build/{server → transport/http}/errorHandler.d.ts +0 -0
  145. /package/build/{middleware → transport/http/middleware}/loggingMiddleware.d.ts +0 -0
  146. /package/build/{server → utils}/tagsExtractor.d.ts +0 -0
  147. /package/build/{server → utils}/tagsExtractor.js +0 -0
@@ -0,0 +1,197 @@
1
+ /**
2
+ * Represents session data stored for access tokens.
3
+ *
4
+ * Contains all necessary information to validate and manage user sessions
5
+ * including client identification, resource access, and expiration details.
6
+ */
7
+ export interface SessionData {
8
+ /** The client ID that owns this session */
9
+ clientId: string;
10
+ /** The resource this session has access to */
11
+ resource: string;
12
+ /** Unix timestamp when this session expires */
13
+ expires: number;
14
+ /** Unix timestamp when this session was created */
15
+ createdAt: number;
16
+ }
17
+ /**
18
+ * Represents authorization code data for OAuth 2.1 flow.
19
+ *
20
+ * Contains information about authorization codes used in the OAuth
21
+ * authorization code grant flow, including client and redirect details.
22
+ */
23
+ export interface AuthCodeData {
24
+ /** The client ID that requested this authorization code */
25
+ clientId: string;
26
+ /** The redirect URI where the code should be used */
27
+ redirectUri: string;
28
+ /** The resource this code grants access to */
29
+ resource: string;
30
+ /** Unix timestamp when this code expires */
31
+ expires: number;
32
+ /** Unix timestamp when this code was created */
33
+ createdAt: number;
34
+ }
35
+ /**
36
+ * SessionManager handles file-based session storage with automatic cleanup.
37
+ *
38
+ * This class manages OAuth 2.1 sessions and authorization codes using
39
+ * the local filesystem. It provides automatic cleanup of expired sessions
40
+ * and supports configurable storage locations.
41
+ *
42
+ * Features:
43
+ * - File-based session storage with JSON format
44
+ * - Automatic cleanup of expired sessions every 5 minutes
45
+ * - Prefixed identifiers for easy debugging
46
+ * - Configurable storage directory
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const sessionManager = new SessionManager('/custom/path');
51
+ * const sessionId = sessionManager.createSession('client-123', 'resource', 3600000);
52
+ * const session = sessionManager.getSession(sessionId);
53
+ * ```
54
+ */
55
+ export declare class SessionManager {
56
+ private sessionStoragePath;
57
+ private cleanupInterval;
58
+ /**
59
+ * Creates a new SessionManager instance.
60
+ *
61
+ * Initializes the session storage directory and starts the automatic
62
+ * cleanup process for expired sessions.
63
+ *
64
+ * @param sessionStoragePath - Optional custom path for session storage
65
+ */
66
+ constructor(sessionStoragePath?: string);
67
+ /**
68
+ * Ensures the session storage directory exists.
69
+ *
70
+ * Creates the directory structure if it doesn't exist, including
71
+ * parent directories as needed.
72
+ *
73
+ * @throws Error if directory creation fails
74
+ */
75
+ private ensureSessionDirectory;
76
+ /**
77
+ * Gets the file path for a session ID.
78
+ *
79
+ * @param sessionId - The session identifier
80
+ * @returns Full file path for the session file
81
+ */
82
+ private getSessionFilePath;
83
+ /**
84
+ * Gets the file path for an authorization code.
85
+ *
86
+ * @param code - The authorization code
87
+ * @returns Full file path for the auth code file
88
+ */
89
+ private getAuthCodeFilePath;
90
+ /**
91
+ * Utility to validate session IDs and auth codes for proper format and security.
92
+ * Ensures proper format with prefix and UUID structure for security.
93
+ * @param id - The session ID or auth code to validate
94
+ * @returns true if valid, false otherwise
95
+ */
96
+ private isValidId;
97
+ /**
98
+ * Creates a new session with the specified parameters.
99
+ *
100
+ * Generates a unique session ID with prefix, stores the session data
101
+ * as a JSON file, and returns the session identifier.
102
+ *
103
+ * @param clientId - The client identifier
104
+ * @param resource - The resource this session can access
105
+ * @param ttlMs - Time-to-live in milliseconds
106
+ * @returns The generated session ID with prefix
107
+ * @throws Error if session creation fails
108
+ */
109
+ createSession(clientId: string, resource: string, ttlMs: number): string;
110
+ /**
111
+ * Retrieves session data by session ID.
112
+ *
113
+ * Reads the session file and validates expiration. If the session
114
+ * is expired, it's automatically deleted and null is returned.
115
+ *
116
+ * @param sessionId - The session identifier to retrieve
117
+ * @returns Session data if valid and not expired, null otherwise
118
+ */
119
+ getSession(sessionId: string): SessionData | null;
120
+ /**
121
+ * Deletes a session by session ID.
122
+ *
123
+ * Removes the session file from the filesystem if it exists.
124
+ *
125
+ * @param sessionId - The session identifier to delete
126
+ * @returns True if session was deleted, false if it didn't exist
127
+ */
128
+ deleteSession(sessionId: string): boolean;
129
+ /**
130
+ * Creates a new authorization code for OAuth 2.1 flow.
131
+ *
132
+ * Generates a unique authorization code with prefix, stores the code data
133
+ * as a JSON file, and returns the code identifier.
134
+ *
135
+ * @param clientId - The client identifier
136
+ * @param redirectUri - The redirect URI for this code
137
+ * @param resource - The resource this code grants access to
138
+ * @param ttlMs - Time-to-live in milliseconds
139
+ * @returns The generated authorization code with prefix
140
+ * @throws Error if code creation fails
141
+ */
142
+ createAuthCode(clientId: string, redirectUri: string, resource: string, ttlMs: number): string;
143
+ /**
144
+ * Retrieves authorization code data by code.
145
+ *
146
+ * Reads the auth code file and validates expiration. If the code
147
+ * is expired, it's automatically deleted and null is returned.
148
+ *
149
+ * @param code - The authorization code to retrieve
150
+ * @returns Auth code data if valid and not expired, null otherwise
151
+ */
152
+ getAuthCode(code: string): AuthCodeData | null;
153
+ /**
154
+ * Deletes an authorization code by code.
155
+ *
156
+ * Removes the auth code file from the filesystem if it exists.
157
+ *
158
+ * @param code - The authorization code to delete
159
+ * @returns True if code was deleted, false if it didn't exist
160
+ */
161
+ deleteAuthCode(code: string): boolean;
162
+ /**
163
+ * Starts the automatic cleanup interval for expired sessions.
164
+ *
165
+ * Runs cleanup every 5 minutes to remove expired sessions and
166
+ * authorization codes from the filesystem.
167
+ */
168
+ private startCleanupInterval;
169
+ /**
170
+ * Cleans up expired sessions and authorization codes.
171
+ *
172
+ * Scans the session storage directory and removes all expired
173
+ * session and auth code files. Also handles corrupted files
174
+ * by removing them to prevent future errors.
175
+ */
176
+ private cleanupExpiredSessions;
177
+ /**
178
+ * Performs graceful shutdown of the SessionManager.
179
+ *
180
+ * Stops the cleanup interval to prevent memory leaks and
181
+ * ensures proper resource cleanup.
182
+ */
183
+ shutdown(): void;
184
+ /**
185
+ * Creates a new session with a custom ID (no prefix).
186
+ * Used for access tokens where the token ID is generated separately.
187
+ *
188
+ * @param tokenId - The raw UUID to use for the session (no prefix)
189
+ * @param clientId - The client identifier
190
+ * @param resource - The resource this session can access
191
+ * @param ttlMs - Time-to-live in milliseconds
192
+ * @returns The generated session ID with prefix
193
+ * @throws Error if session creation fails
194
+ */
195
+ createSessionWithId(tokenId: string, clientId: string, resource: string, ttlMs: number): string;
196
+ }
197
+ //# sourceMappingURL=sessionManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessionManager.d.ts","sourceRoot":"","sources":["../../src/auth/sessionManager.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;I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AE,MAAM,GAAG,YAAY,GAAG,IAAI;IA0BrD;;;;;;;OAOG;IACI,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAmB5C;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAU5B;;;;;;OAMG;IACH,OAAO,CAAC,sBAAsB;IAqC9B;;;;;OAKG;IACI,QAAQ,IAAI,IAAI;IAOvB;;;;;;;;;;OAUG;IACI,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;CAmBvG"}
@@ -0,0 +1,408 @@
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 SessionManager {
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 = sessionStoragePath || path.join(getGlobalConfigDir(), AUTH_CONFIG.SESSION_STORAGE_DIR);
39
+ this.ensureSessionDirectory();
40
+ this.startCleanupInterval();
41
+ }
42
+ /**
43
+ * Ensures the session storage directory exists.
44
+ *
45
+ * Creates the directory structure if it doesn't exist, including
46
+ * parent directories as needed.
47
+ *
48
+ * @throws Error if directory creation fails
49
+ */
50
+ ensureSessionDirectory() {
51
+ try {
52
+ if (!fs.existsSync(this.sessionStoragePath)) {
53
+ fs.mkdirSync(this.sessionStoragePath, { recursive: true });
54
+ logger.info(`Created session storage directory: ${this.sessionStoragePath}`);
55
+ }
56
+ }
57
+ catch (error) {
58
+ logger.error(`Failed to create session directory: ${error}`);
59
+ throw error;
60
+ }
61
+ }
62
+ /**
63
+ * Gets the file path for a session ID.
64
+ *
65
+ * @param sessionId - The session identifier
66
+ * @returns Full file path for the session file
67
+ */
68
+ getSessionFilePath(sessionId) {
69
+ // Validate session ID format first
70
+ if (!this.isValidId(sessionId)) {
71
+ throw new Error('Invalid session ID format');
72
+ }
73
+ const fileName = `${AUTH_CONFIG.SESSION_FILE_PREFIX}${sessionId}${AUTH_CONFIG.SESSION_FILE_EXTENSION}`;
74
+ const filePath = path.resolve(this.sessionStoragePath, fileName);
75
+ // Additional security check: ensure resolved path is within session storage
76
+ const normalizedStoragePath = path.resolve(this.sessionStoragePath);
77
+ const normalizedFilePath = path.resolve(filePath);
78
+ if (!normalizedFilePath.startsWith(normalizedStoragePath + path.sep)) {
79
+ throw new Error('Invalid session file path: outside storage directory');
80
+ }
81
+ return filePath;
82
+ }
83
+ /**
84
+ * Gets the file path for an authorization code.
85
+ *
86
+ * @param code - The authorization code
87
+ * @returns Full file path for the auth code file
88
+ */
89
+ getAuthCodeFilePath(code) {
90
+ // Validate auth code format first
91
+ if (!this.isValidId(code)) {
92
+ throw new Error('Invalid authorization code format');
93
+ }
94
+ const fileName = `auth_code_${code}${AUTH_CONFIG.SESSION_FILE_EXTENSION}`;
95
+ const filePath = path.resolve(this.sessionStoragePath, fileName);
96
+ // Additional security check: ensure resolved path is within session storage
97
+ const normalizedStoragePath = path.resolve(this.sessionStoragePath);
98
+ const normalizedFilePath = path.resolve(filePath);
99
+ if (!normalizedFilePath.startsWith(normalizedStoragePath + path.sep)) {
100
+ throw new Error('Invalid authorization code path: outside storage directory');
101
+ }
102
+ return filePath;
103
+ }
104
+ /**
105
+ * Utility to validate session IDs and auth codes for proper format and security.
106
+ * Ensures proper format with prefix and UUID structure for security.
107
+ * @param id - The session ID or auth code to validate
108
+ * @returns true if valid, false otherwise
109
+ */
110
+ isValidId(id) {
111
+ // Check minimum length (prefix + UUID)
112
+ if (!id || id.length < 40) {
113
+ return false;
114
+ }
115
+ // Check for valid prefix
116
+ const hasValidPrefix = id.startsWith(AUTH_CONFIG.PREFIXES.SESSION_ID) || id.startsWith(AUTH_CONFIG.PREFIXES.AUTH_CODE);
117
+ if (!hasValidPrefix) {
118
+ return false;
119
+ }
120
+ // Validate the UUID portion (after prefix)
121
+ const uuidPart = id.startsWith(AUTH_CONFIG.PREFIXES.SESSION_ID)
122
+ ? id.substring(AUTH_CONFIG.PREFIXES.SESSION_ID.length)
123
+ : id.substring(AUTH_CONFIG.PREFIXES.AUTH_CODE.length);
124
+ // UUID v4 format: 8-4-4-4-12 hexadecimal digits with hyphens
125
+ 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;
126
+ return uuidRegex.test(uuidPart);
127
+ }
128
+ /**
129
+ * Creates a new session with the specified parameters.
130
+ *
131
+ * Generates a unique session ID with prefix, stores the session data
132
+ * as a JSON file, and returns the session identifier.
133
+ *
134
+ * @param clientId - The client identifier
135
+ * @param resource - The resource this session can access
136
+ * @param ttlMs - Time-to-live in milliseconds
137
+ * @returns The generated session ID with prefix
138
+ * @throws Error if session creation fails
139
+ */
140
+ createSession(clientId, resource, ttlMs) {
141
+ const sessionId = AUTH_CONFIG.PREFIXES.SESSION_ID + randomUUID();
142
+ const sessionData = {
143
+ clientId,
144
+ resource,
145
+ expires: Date.now() + ttlMs,
146
+ createdAt: Date.now(),
147
+ };
148
+ try {
149
+ const filePath = this.getSessionFilePath(sessionId);
150
+ fs.writeFileSync(filePath, JSON.stringify(sessionData, null, 2));
151
+ logger.info(`Created session: ${sessionId} for client: ${clientId}`);
152
+ return sessionId;
153
+ }
154
+ catch (error) {
155
+ logger.error(`Failed to create session: ${error}`);
156
+ throw error;
157
+ }
158
+ }
159
+ /**
160
+ * Retrieves session data by session ID.
161
+ *
162
+ * Reads the session file and validates expiration. If the session
163
+ * is expired, it's automatically deleted and null is returned.
164
+ *
165
+ * @param sessionId - The session identifier to retrieve
166
+ * @returns Session data if valid and not expired, null otherwise
167
+ */
168
+ getSession(sessionId) {
169
+ if (!this.isValidId(sessionId)) {
170
+ logger.warn(`Rejected getSession with invalid sessionId: ${sessionId}`);
171
+ return null;
172
+ }
173
+ try {
174
+ const filePath = this.getSessionFilePath(sessionId);
175
+ if (!fs.existsSync(filePath)) {
176
+ return null;
177
+ }
178
+ const data = fs.readFileSync(filePath, 'utf8');
179
+ const sessionData = JSON.parse(data);
180
+ if (sessionData.expires < Date.now()) {
181
+ this.deleteSession(sessionId);
182
+ return null;
183
+ }
184
+ return sessionData;
185
+ }
186
+ catch (error) {
187
+ logger.error(`Failed to read session ${sessionId}: ${error}`);
188
+ return null;
189
+ }
190
+ }
191
+ /**
192
+ * Deletes a session by session ID.
193
+ *
194
+ * Removes the session file from the filesystem if it exists.
195
+ *
196
+ * @param sessionId - The session identifier to delete
197
+ * @returns True if session was deleted, false if it didn't exist
198
+ */
199
+ deleteSession(sessionId) {
200
+ if (!this.isValidId(sessionId)) {
201
+ logger.warn(`Rejected deleteSession with invalid sessionId: ${sessionId}`);
202
+ return false;
203
+ }
204
+ try {
205
+ const filePath = this.getSessionFilePath(sessionId);
206
+ if (fs.existsSync(filePath)) {
207
+ fs.unlinkSync(filePath);
208
+ logger.info(`Deleted session: ${sessionId}`);
209
+ return true;
210
+ }
211
+ return false;
212
+ }
213
+ catch (error) {
214
+ logger.error(`Failed to delete session ${sessionId}: ${error}`);
215
+ return false;
216
+ }
217
+ }
218
+ /**
219
+ * Creates a new authorization code for OAuth 2.1 flow.
220
+ *
221
+ * Generates a unique authorization code with prefix, stores the code data
222
+ * as a JSON file, and returns the code identifier.
223
+ *
224
+ * @param clientId - The client identifier
225
+ * @param redirectUri - The redirect URI for this code
226
+ * @param resource - The resource this code grants access to
227
+ * @param ttlMs - Time-to-live in milliseconds
228
+ * @returns The generated authorization code with prefix
229
+ * @throws Error if code creation fails
230
+ */
231
+ createAuthCode(clientId, redirectUri, resource, ttlMs) {
232
+ const code = AUTH_CONFIG.PREFIXES.AUTH_CODE + randomUUID();
233
+ const authCodeData = {
234
+ clientId,
235
+ redirectUri,
236
+ resource,
237
+ expires: Date.now() + ttlMs,
238
+ createdAt: Date.now(),
239
+ };
240
+ try {
241
+ const filePath = this.getAuthCodeFilePath(code);
242
+ fs.writeFileSync(filePath, JSON.stringify(authCodeData, null, 2));
243
+ logger.info(`Created auth code: ${code} for client: ${clientId}`);
244
+ return code;
245
+ }
246
+ catch (error) {
247
+ logger.error(`Failed to create auth code: ${error}`);
248
+ throw error;
249
+ }
250
+ }
251
+ /**
252
+ * Retrieves authorization code data by code.
253
+ *
254
+ * Reads the auth code file and validates expiration. If the code
255
+ * is expired, it's automatically deleted and null is returned.
256
+ *
257
+ * @param code - The authorization code to retrieve
258
+ * @returns Auth code data if valid and not expired, null otherwise
259
+ */
260
+ getAuthCode(code) {
261
+ if (!this.isValidId(code)) {
262
+ logger.warn(`Rejected getAuthCode with invalid code: ${code}`);
263
+ return null;
264
+ }
265
+ try {
266
+ const filePath = this.getAuthCodeFilePath(code);
267
+ if (!fs.existsSync(filePath)) {
268
+ return null;
269
+ }
270
+ const data = fs.readFileSync(filePath, 'utf8');
271
+ const authCodeData = JSON.parse(data);
272
+ if (authCodeData.expires < Date.now()) {
273
+ this.deleteAuthCode(code);
274
+ return null;
275
+ }
276
+ return authCodeData;
277
+ }
278
+ catch (error) {
279
+ logger.error(`Failed to read auth code ${code}: ${error}`);
280
+ return null;
281
+ }
282
+ }
283
+ /**
284
+ * Deletes an authorization code by code.
285
+ *
286
+ * Removes the auth code file from the filesystem if it exists.
287
+ *
288
+ * @param code - The authorization code to delete
289
+ * @returns True if code was deleted, false if it didn't exist
290
+ */
291
+ deleteAuthCode(code) {
292
+ if (!this.isValidId(code)) {
293
+ logger.warn(`Rejected deleteAuthCode with invalid code: ${code}`);
294
+ return false;
295
+ }
296
+ try {
297
+ const filePath = this.getAuthCodeFilePath(code);
298
+ if (fs.existsSync(filePath)) {
299
+ fs.unlinkSync(filePath);
300
+ logger.info(`Deleted auth code: ${code}`);
301
+ return true;
302
+ }
303
+ return false;
304
+ }
305
+ catch (error) {
306
+ logger.error(`Failed to delete auth code ${code}: ${error}`);
307
+ return false;
308
+ }
309
+ }
310
+ /**
311
+ * Starts the automatic cleanup interval for expired sessions.
312
+ *
313
+ * Runs cleanup every 5 minutes to remove expired sessions and
314
+ * authorization codes from the filesystem.
315
+ */
316
+ startCleanupInterval() {
317
+ // Clean up expired sessions every 5 minutes
318
+ this.cleanupInterval = setInterval(() => {
319
+ this.cleanupExpiredSessions();
320
+ }, 5 * 60 * 1000);
321
+ }
322
+ /**
323
+ * Cleans up expired sessions and authorization codes.
324
+ *
325
+ * Scans the session storage directory and removes all expired
326
+ * session and auth code files. Also handles corrupted files
327
+ * by removing them to prevent future errors.
328
+ */
329
+ cleanupExpiredSessions() {
330
+ try {
331
+ const files = fs.readdirSync(this.sessionStoragePath);
332
+ let cleanedCount = 0;
333
+ for (const file of files) {
334
+ if (file.endsWith(AUTH_CONFIG.SESSION_FILE_EXTENSION)) {
335
+ const filePath = path.join(this.sessionStoragePath, file);
336
+ try {
337
+ const data = fs.readFileSync(filePath, 'utf8');
338
+ const sessionData = JSON.parse(data);
339
+ if (sessionData.expires < Date.now()) {
340
+ fs.unlinkSync(filePath);
341
+ cleanedCount++;
342
+ }
343
+ }
344
+ catch (error) {
345
+ logger.warn(`Failed to process session file ${file}: ${error}`);
346
+ // Remove corrupted files
347
+ try {
348
+ fs.unlinkSync(filePath);
349
+ cleanedCount++;
350
+ }
351
+ catch (unlinkError) {
352
+ logger.error(`Failed to remove corrupted file ${file}: ${unlinkError}`);
353
+ }
354
+ }
355
+ }
356
+ }
357
+ if (cleanedCount > 0) {
358
+ logger.info(`Cleaned up ${cleanedCount} expired sessions`);
359
+ }
360
+ }
361
+ catch (error) {
362
+ logger.error(`Failed to cleanup expired sessions: ${error}`);
363
+ }
364
+ }
365
+ /**
366
+ * Performs graceful shutdown of the SessionManager.
367
+ *
368
+ * Stops the cleanup interval to prevent memory leaks and
369
+ * ensures proper resource cleanup.
370
+ */
371
+ shutdown() {
372
+ if (this.cleanupInterval) {
373
+ clearInterval(this.cleanupInterval);
374
+ this.cleanupInterval = null;
375
+ }
376
+ }
377
+ /**
378
+ * Creates a new session with a custom ID (no prefix).
379
+ * Used for access tokens where the token ID is generated separately.
380
+ *
381
+ * @param tokenId - The raw UUID to use for the session (no prefix)
382
+ * @param clientId - The client identifier
383
+ * @param resource - The resource this session can access
384
+ * @param ttlMs - Time-to-live in milliseconds
385
+ * @returns The generated session ID with prefix
386
+ * @throws Error if session creation fails
387
+ */
388
+ createSessionWithId(tokenId, clientId, resource, ttlMs) {
389
+ const sessionId = AUTH_CONFIG.PREFIXES.SESSION_ID + tokenId;
390
+ const sessionData = {
391
+ clientId,
392
+ resource,
393
+ expires: Date.now() + ttlMs,
394
+ createdAt: Date.now(),
395
+ };
396
+ try {
397
+ const filePath = this.getSessionFilePath(sessionId);
398
+ fs.writeFileSync(filePath, JSON.stringify(sessionData, null, 2));
399
+ logger.info(`Created session: ${sessionId} for client: ${clientId}`);
400
+ return sessionId;
401
+ }
402
+ catch (error) {
403
+ logger.error(`Failed to create session: ${error}`);
404
+ throw error;
405
+ }
406
+ }
407
+ }
408
+ //# sourceMappingURL=sessionManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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,CAAC;IACH,CAAC;IAED;;;;;;;;;;OAUG;IACI,mBAAmB,CAAC,OAAe,EAAE,QAAgB,EAAE,QAAgB,EAAE,KAAa;QAC3F,MAAM,SAAS,GAAG,WAAW,CAAC,QAAQ,CAAC,UAAU,GAAG,OAAO,CAAC;QAC5D,MAAM,WAAW,GAAgB;YAC/B,QAAQ;YACR,QAAQ;YACR,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;YAC3B,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACtB,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,oBAAoB,SAAS,gBAAgB,QAAQ,EAAE,CAAC,CAAC;YACrE,OAAO,SAAS,CAAC;QACnB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,6BAA6B,KAAK,EAAE,CAAC,CAAC;YACnD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
@@ -1,4 +1,4 @@
1
- import { Clients, ServerInfo } from '../types.js';
1
+ import { Clients, ServerInfo } from '../core/types/index.js';
2
2
  /**
3
3
  * Collects capabilities from all clients and registers them with the server
4
4
  * @param clients Record of client instances
@@ -1 +1 @@
1
- {"version":3,"file":"capabilityManager.d.ts","sourceRoot":"","sources":["../../src/capabilities/capabilityManager.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;GAY/E"}
1
+ {"version":3,"file":"capabilityManager.d.ts","sourceRoot":"","sources":["../../src/capabilities/capabilityManager.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAE7D;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;GAY/E"}