@1mcp/agent 0.12.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/README.md +22 -37
  2. package/build/auth/sdkOAuthClientProvider.d.ts +93 -0
  3. package/build/auth/sdkOAuthClientProvider.d.ts.map +1 -0
  4. package/build/auth/sdkOAuthClientProvider.js +204 -0
  5. package/build/auth/sdkOAuthClientProvider.js.map +1 -0
  6. package/build/auth/sdkOAuthServerProvider.d.ts +64 -0
  7. package/build/auth/sdkOAuthServerProvider.d.ts.map +1 -0
  8. package/build/auth/sdkOAuthServerProvider.js +359 -0
  9. package/build/auth/sdkOAuthServerProvider.js.map +1 -0
  10. package/build/auth/sessionTypes.d.ts +38 -0
  11. package/build/auth/sessionTypes.d.ts.map +1 -0
  12. package/build/auth/sessionTypes.js +3 -0
  13. package/build/auth/sessionTypes.js.map +1 -0
  14. package/build/auth/storage/authCodeRepository.d.ts +25 -0
  15. package/build/auth/storage/authCodeRepository.d.ts.map +1 -0
  16. package/build/auth/storage/authCodeRepository.js +50 -0
  17. package/build/auth/storage/authCodeRepository.js.map +1 -0
  18. package/build/auth/storage/authRequestRepository.d.ts +25 -0
  19. package/build/auth/storage/authRequestRepository.d.ts.map +1 -0
  20. package/build/auth/storage/authRequestRepository.js +51 -0
  21. package/build/auth/storage/authRequestRepository.js.map +1 -0
  22. package/build/auth/storage/clientDataRepository.d.ts +25 -0
  23. package/build/auth/storage/clientDataRepository.d.ts.map +1 -0
  24. package/build/auth/storage/clientDataRepository.js +45 -0
  25. package/build/auth/storage/clientDataRepository.js.map +1 -0
  26. package/build/auth/storage/clientSessionRepository.d.ts +77 -0
  27. package/build/auth/storage/clientSessionRepository.d.ts.map +1 -0
  28. package/build/auth/storage/clientSessionRepository.js +120 -0
  29. package/build/auth/storage/clientSessionRepository.js.map +1 -0
  30. package/build/auth/storage/fileStorageService.d.ts +68 -0
  31. package/build/auth/storage/fileStorageService.d.ts.map +1 -0
  32. package/build/auth/storage/fileStorageService.js +262 -0
  33. package/build/auth/storage/fileStorageService.js.map +1 -0
  34. package/build/auth/storage/oauthStorageService.d.ts +57 -0
  35. package/build/auth/storage/oauthStorageService.d.ts.map +1 -0
  36. package/build/auth/storage/oauthStorageService.js +131 -0
  37. package/build/auth/storage/oauthStorageService.js.map +1 -0
  38. package/build/auth/storage/sessionRepository.d.ts +29 -0
  39. package/build/auth/storage/sessionRepository.d.ts.map +1 -0
  40. package/build/auth/storage/sessionRepository.js +64 -0
  41. package/build/auth/storage/sessionRepository.js.map +1 -0
  42. package/build/capabilities/capabilityManager.d.ts +2 -2
  43. package/build/capabilities/capabilityManager.d.ts.map +1 -1
  44. package/build/capabilities/capabilityManager.js +1 -1
  45. package/build/capabilities/capabilityManager.js.map +1 -1
  46. package/build/config/{configManager.d.ts → mcpConfigManager.d.ts} +11 -6
  47. package/build/config/mcpConfigManager.d.ts.map +1 -0
  48. package/build/config/{configManager.js → mcpConfigManager.js} +26 -8
  49. package/build/config/mcpConfigManager.js.map +1 -0
  50. package/build/constants.d.ts +51 -14
  51. package/build/constants.d.ts.map +1 -1
  52. package/build/constants.js +61 -17
  53. package/build/constants.js.map +1 -1
  54. package/build/core/client/clientManager.d.ts +14 -6
  55. package/build/core/client/clientManager.d.ts.map +1 -1
  56. package/build/core/client/clientManager.js +90 -28
  57. package/build/core/client/clientManager.js.map +1 -1
  58. package/build/core/server/{serverConfig.d.ts → agentConfig.d.ts} +50 -15
  59. package/build/core/server/agentConfig.d.ts.map +1 -0
  60. package/build/core/server/agentConfig.js +166 -0
  61. package/build/core/server/agentConfig.js.map +1 -0
  62. package/build/core/server/serverManager.d.ts +12 -5
  63. package/build/core/server/serverManager.d.ts.map +1 -1
  64. package/build/core/server/serverManager.js +12 -2
  65. package/build/core/server/serverManager.js.map +1 -1
  66. package/build/core/types/client.d.ts +22 -9
  67. package/build/core/types/client.d.ts.map +1 -1
  68. package/build/core/types/client.js +2 -0
  69. package/build/core/types/client.js.map +1 -1
  70. package/build/core/types/server.d.ts +3 -3
  71. package/build/core/types/server.d.ts.map +1 -1
  72. package/build/core/types/transport.d.ts +58 -0
  73. package/build/core/types/transport.d.ts.map +1 -1
  74. package/build/core/types/transport.js +10 -0
  75. package/build/core/types/transport.js.map +1 -1
  76. package/build/handlers/notificationHandlers.d.ts +3 -3
  77. package/build/handlers/notificationHandlers.d.ts.map +1 -1
  78. package/build/handlers/notificationHandlers.js +2 -2
  79. package/build/handlers/notificationHandlers.js.map +1 -1
  80. package/build/handlers/requestHandlers.d.ts +2 -2
  81. package/build/handlers/requestHandlers.d.ts.map +1 -1
  82. package/build/handlers/requestHandlers.js +4 -3
  83. package/build/handlers/requestHandlers.js.map +1 -1
  84. package/build/index.js +47 -7
  85. package/build/index.js.map +1 -1
  86. package/build/{transport/http/middleware/loggingMiddleware.d.ts → logger/mcpLoggingEnhancer.d.ts} +1 -1
  87. package/build/logger/mcpLoggingEnhancer.d.ts.map +1 -0
  88. package/build/{transport/http/middleware/loggingMiddleware.js → logger/mcpLoggingEnhancer.js} +2 -2
  89. package/build/logger/mcpLoggingEnhancer.js.map +1 -0
  90. package/build/server.js +4 -4
  91. package/build/server.js.map +1 -1
  92. package/build/services/configReloadService.d.ts +2 -2
  93. package/build/services/configReloadService.d.ts.map +1 -1
  94. package/build/services/configReloadService.js +4 -4
  95. package/build/services/configReloadService.js.map +1 -1
  96. package/build/transport/http/middlewares/errorHandler.d.ts.map +1 -0
  97. package/build/transport/http/{errorHandler.js → middlewares/errorHandler.js} +1 -1
  98. package/build/transport/http/middlewares/errorHandler.js.map +1 -0
  99. package/build/transport/http/middlewares/scopeAuthMiddleware.d.ts +39 -0
  100. package/build/transport/http/middlewares/scopeAuthMiddleware.d.ts.map +1 -0
  101. package/build/transport/http/middlewares/scopeAuthMiddleware.js +129 -0
  102. package/build/transport/http/middlewares/scopeAuthMiddleware.js.map +1 -0
  103. package/build/transport/http/middlewares/securityMiddleware.d.ts +30 -0
  104. package/build/transport/http/middlewares/securityMiddleware.d.ts.map +1 -0
  105. package/build/transport/http/middlewares/securityMiddleware.js +201 -0
  106. package/build/transport/http/middlewares/securityMiddleware.js.map +1 -0
  107. package/build/transport/http/middlewares/tagsExtractor.d.ts.map +1 -0
  108. package/build/transport/http/middlewares/tagsExtractor.js.map +1 -0
  109. package/build/transport/http/routes/oauthRoutes.d.ts +5 -11
  110. package/build/transport/http/routes/oauthRoutes.d.ts.map +1 -1
  111. package/build/transport/http/routes/oauthRoutes.js +460 -122
  112. package/build/transport/http/routes/oauthRoutes.js.map +1 -1
  113. package/build/transport/http/routes/sseRoutes.d.ts +3 -2
  114. package/build/transport/http/routes/sseRoutes.d.ts.map +1 -1
  115. package/build/transport/http/routes/sseRoutes.js +10 -7
  116. package/build/transport/http/routes/sseRoutes.js.map +1 -1
  117. package/build/transport/http/routes/streamableHttpRoutes.d.ts +3 -2
  118. package/build/transport/http/routes/streamableHttpRoutes.d.ts.map +1 -1
  119. package/build/transport/http/routes/streamableHttpRoutes.js +17 -10
  120. package/build/transport/http/routes/streamableHttpRoutes.js.map +1 -1
  121. package/build/transport/http/server.d.ts +3 -2
  122. package/build/transport/http/server.d.ts.map +1 -1
  123. package/build/transport/http/server.js +58 -21
  124. package/build/transport/http/server.js.map +1 -1
  125. package/build/transport/transportFactory.d.ts +9 -0
  126. package/build/transport/transportFactory.d.ts.map +1 -0
  127. package/build/transport/transportFactory.js +148 -0
  128. package/build/transport/transportFactory.js.map +1 -0
  129. package/build/utils/clientFiltering.d.ts +4 -4
  130. package/build/utils/clientFiltering.d.ts.map +1 -1
  131. package/build/utils/clientFiltering.js +54 -19
  132. package/build/utils/clientFiltering.js.map +1 -1
  133. package/build/utils/errorHandling.d.ts +0 -12
  134. package/build/utils/errorHandling.d.ts.map +1 -1
  135. package/build/utils/errorHandling.js +1 -42
  136. package/build/utils/errorHandling.js.map +1 -1
  137. package/build/utils/pagination.d.ts +2 -2
  138. package/build/utils/pagination.d.ts.map +1 -1
  139. package/build/utils/pagination.js +4 -4
  140. package/build/utils/pagination.js.map +1 -1
  141. package/build/utils/parsing.d.ts +13 -0
  142. package/build/utils/parsing.d.ts.map +1 -0
  143. package/build/utils/parsing.js +32 -0
  144. package/build/utils/parsing.js.map +1 -0
  145. package/build/utils/sanitization.d.ts +60 -0
  146. package/build/utils/sanitization.d.ts.map +1 -0
  147. package/build/utils/sanitization.js +149 -0
  148. package/build/utils/sanitization.js.map +1 -0
  149. package/build/utils/scopeValidation.d.ts +102 -0
  150. package/build/utils/scopeValidation.d.ts.map +1 -0
  151. package/build/utils/scopeValidation.js +244 -0
  152. package/build/utils/scopeValidation.js.map +1 -0
  153. package/package.json +20 -11
  154. package/build/auth/authManager.d.ts +0 -109
  155. package/build/auth/authManager.d.ts.map +0 -1
  156. package/build/auth/authManager.js +0 -173
  157. package/build/auth/authManager.js.map +0 -1
  158. package/build/auth/authMiddleware.d.ts +0 -16
  159. package/build/auth/authMiddleware.d.ts.map +0 -1
  160. package/build/auth/authMiddleware.js +0 -45
  161. package/build/auth/authMiddleware.js.map +0 -1
  162. package/build/auth/sessionManager.d.ts +0 -197
  163. package/build/auth/sessionManager.d.ts.map +0 -1
  164. package/build/auth/sessionManager.js +0 -408
  165. package/build/auth/sessionManager.js.map +0 -1
  166. package/build/config/configManager.d.ts.map +0 -1
  167. package/build/config/configManager.js.map +0 -1
  168. package/build/core/server/serverConfig.d.ts.map +0 -1
  169. package/build/core/server/serverConfig.js +0 -117
  170. package/build/core/server/serverConfig.js.map +0 -1
  171. package/build/transport/config.d.ts +0 -7
  172. package/build/transport/config.d.ts.map +0 -1
  173. package/build/transport/config.js +0 -90
  174. package/build/transport/config.js.map +0 -1
  175. package/build/transport/http/errorHandler.d.ts.map +0 -1
  176. package/build/transport/http/errorHandler.js.map +0 -1
  177. package/build/transport/http/middleware/loggingMiddleware.d.ts.map +0 -1
  178. package/build/transport/http/middleware/loggingMiddleware.js.map +0 -1
  179. package/build/utils/tagsExtractor.d.ts.map +0 -1
  180. package/build/utils/tagsExtractor.js.map +0 -1
  181. /package/build/transport/http/{errorHandler.d.ts → middlewares/errorHandler.d.ts} +0 -0
  182. /package/build/{utils → transport/http/middlewares}/tagsExtractor.d.ts +0 -0
  183. /package/build/{utils → transport/http/middlewares}/tagsExtractor.js +0 -0
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Security constants for scope validation
3
+ */
4
+ export declare const SCOPE_VALIDATION_CONFIG: {
5
+ /** Maximum allowed length for a single scope */
6
+ readonly MAX_SCOPE_LENGTH: 100;
7
+ /** Maximum number of scopes per request */
8
+ readonly MAX_SCOPES_COUNT: 50;
9
+ /** Valid tag name pattern: alphanumeric, underscore, hyphen only */
10
+ readonly TAG_NAME_PATTERN: RegExp;
11
+ /** Valid tag scope pattern: tag: prefix followed by valid tag name */
12
+ readonly TAG_SCOPE_PATTERN: RegExp;
13
+ /** Minimum tag name length */
14
+ readonly MIN_TAG_LENGTH: 1;
15
+ /** Maximum tag name length */
16
+ readonly MAX_TAG_LENGTH: 50;
17
+ };
18
+ /**
19
+ * Parsed scope structure
20
+ */
21
+ export interface ParsedScope {
22
+ type: 'tag';
23
+ value: string;
24
+ }
25
+ /**
26
+ * Scope validation result
27
+ */
28
+ export interface ScopeValidationResult {
29
+ isValid: boolean;
30
+ errors: string[];
31
+ validScopes: string[];
32
+ invalidScopes: string[];
33
+ }
34
+ /**
35
+ * Validates if a string is a valid tag name
36
+ * @param tagName - The tag name to validate
37
+ * @returns True if valid, false otherwise
38
+ */
39
+ export declare function isValidTagName(tagName: string): boolean;
40
+ /**
41
+ * Validates if a string is a valid tag scope
42
+ * @param scope - The scope to validate
43
+ * @returns True if valid, false otherwise
44
+ */
45
+ export declare function isValidTagScope(scope: string): boolean;
46
+ /**
47
+ * Safely extracts tag name from a tag scope
48
+ * @param scope - The scope string (e.g., "tag:web")
49
+ * @returns The tag name if valid, null otherwise
50
+ */
51
+ export declare function extractTagFromScope(scope: string): string | null;
52
+ /**
53
+ * Parses a scope string into its components
54
+ * @param scope - The scope string to parse
55
+ * @returns Parsed scope object or null if invalid
56
+ */
57
+ export declare function parseScope(scope: string): ParsedScope | null;
58
+ /**
59
+ * Validates an array of scopes for format and security
60
+ * @param scopes - Array of scope strings to validate
61
+ * @returns Validation result with details
62
+ */
63
+ export declare function validateScopes(scopes: string[]): ScopeValidationResult;
64
+ /**
65
+ * Validates that requested scopes are available (allowlist approach)
66
+ * @param requestedScopes - Scopes requested by client
67
+ * @param availableTags - Tags available on the server
68
+ * @returns Validation result
69
+ */
70
+ export declare function validateScopesAgainstAvailableTags(requestedScopes: string[], availableTags: string[]): ScopeValidationResult;
71
+ /**
72
+ * Checks if granted scopes satisfy the requirements for requested tags
73
+ * @param grantedScopes - Scopes granted during OAuth flow
74
+ * @param requestedTags - Tags requested for current operation
75
+ * @returns True if all requested tags are covered by granted scopes
76
+ */
77
+ export declare function hasRequiredScopes(grantedScopes: string[], requestedTags: string[]): boolean;
78
+ /**
79
+ * Converts tags to their corresponding scopes
80
+ * @param tags - Array of tag names
81
+ * @returns Array of tag scopes
82
+ */
83
+ export declare function tagsToScopes(tags: string[]): string[];
84
+ /**
85
+ * Converts scopes to their corresponding tags
86
+ * @param scopes - Array of scope strings
87
+ * @returns Array of tag names
88
+ */
89
+ export declare function scopesToTags(scopes: string[]): string[];
90
+ /**
91
+ * Security utility to audit scope operations
92
+ * @param operation - The operation being performed
93
+ * @param context - Additional context for logging
94
+ */
95
+ export declare function auditScopeOperation(operation: string, context: {
96
+ clientId?: string;
97
+ requestedScopes?: string[];
98
+ grantedScopes?: string[];
99
+ success?: boolean;
100
+ error?: string;
101
+ }): void;
102
+ //# sourceMappingURL=scopeValidation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scopeValidation.d.ts","sourceRoot":"","sources":["../../src/utils/scopeValidation.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,uBAAuB;IAClC,gDAAgD;;IAEhD,2CAA2C;;IAE3C,oEAAoE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AAS,EAAE,MAAM,EACjB,OAAO,EAAE;IACP,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GACA,IAAI,CAUN"}
@@ -0,0 +1,244 @@
1
+ import logger from '../logger/logger.js';
2
+ /**
3
+ * Security constants for scope validation
4
+ */
5
+ export const SCOPE_VALIDATION_CONFIG = {
6
+ /** Maximum allowed length for a single scope */
7
+ MAX_SCOPE_LENGTH: 100,
8
+ /** Maximum number of scopes per request */
9
+ MAX_SCOPES_COUNT: 50,
10
+ /** Valid tag name pattern: alphanumeric, underscore, hyphen only */
11
+ TAG_NAME_PATTERN: /^[a-zA-Z0-9_-]+$/,
12
+ /** Valid tag scope pattern: tag: prefix followed by valid tag name */
13
+ TAG_SCOPE_PATTERN: /^tag:[a-zA-Z0-9_-]+$/,
14
+ /** Minimum tag name length */
15
+ MIN_TAG_LENGTH: 1,
16
+ /** Maximum tag name length */
17
+ MAX_TAG_LENGTH: 50,
18
+ };
19
+ /**
20
+ * Validates if a string is a valid tag name
21
+ * @param tagName - The tag name to validate
22
+ * @returns True if valid, false otherwise
23
+ */
24
+ export function isValidTagName(tagName) {
25
+ if (!tagName || typeof tagName !== 'string') {
26
+ return false;
27
+ }
28
+ // Check length constraints
29
+ if (tagName.length < SCOPE_VALIDATION_CONFIG.MIN_TAG_LENGTH ||
30
+ tagName.length > SCOPE_VALIDATION_CONFIG.MAX_TAG_LENGTH) {
31
+ return false;
32
+ }
33
+ // Check pattern
34
+ return SCOPE_VALIDATION_CONFIG.TAG_NAME_PATTERN.test(tagName);
35
+ }
36
+ /**
37
+ * Validates if a string is a valid tag scope
38
+ * @param scope - The scope to validate
39
+ * @returns True if valid, false otherwise
40
+ */
41
+ export function isValidTagScope(scope) {
42
+ if (!scope || typeof scope !== 'string') {
43
+ return false;
44
+ }
45
+ // Check length constraints
46
+ if (scope.length > SCOPE_VALIDATION_CONFIG.MAX_SCOPE_LENGTH) {
47
+ return false;
48
+ }
49
+ // Check pattern
50
+ if (!SCOPE_VALIDATION_CONFIG.TAG_SCOPE_PATTERN.test(scope)) {
51
+ return false;
52
+ }
53
+ // Extract and validate tag name
54
+ const tagName = scope.slice(4); // Remove "tag:" prefix
55
+ return isValidTagName(tagName);
56
+ }
57
+ /**
58
+ * Safely extracts tag name from a tag scope
59
+ * @param scope - The scope string (e.g., "tag:web")
60
+ * @returns The tag name if valid, null otherwise
61
+ */
62
+ export function extractTagFromScope(scope) {
63
+ if (!isValidTagScope(scope)) {
64
+ logger.warn(`Invalid tag scope format: ${scope}`);
65
+ return null;
66
+ }
67
+ return scope.slice(4); // Remove "tag:" prefix
68
+ }
69
+ /**
70
+ * Parses a scope string into its components
71
+ * @param scope - The scope string to parse
72
+ * @returns Parsed scope object or null if invalid
73
+ */
74
+ export function parseScope(scope) {
75
+ if (!scope || typeof scope !== 'string') {
76
+ return null;
77
+ }
78
+ // Currently only supporting tag scopes
79
+ if (scope.startsWith('tag:')) {
80
+ const tagName = extractTagFromScope(scope);
81
+ if (!tagName) {
82
+ return null;
83
+ }
84
+ return { type: 'tag', value: tagName };
85
+ }
86
+ // Future: Add support for other scope types (capability:, resource:, etc.)
87
+ return null;
88
+ }
89
+ /**
90
+ * Validates an array of scopes for format and security
91
+ * @param scopes - Array of scope strings to validate
92
+ * @returns Validation result with details
93
+ */
94
+ export function validateScopes(scopes) {
95
+ const result = {
96
+ isValid: true,
97
+ errors: [],
98
+ validScopes: [],
99
+ invalidScopes: [],
100
+ };
101
+ // Check for null/undefined input
102
+ if (!scopes || !Array.isArray(scopes)) {
103
+ result.isValid = false;
104
+ result.errors.push('Scopes must be an array');
105
+ return result;
106
+ }
107
+ // Check count limits
108
+ if (scopes.length > SCOPE_VALIDATION_CONFIG.MAX_SCOPES_COUNT) {
109
+ result.isValid = false;
110
+ result.errors.push(`Too many scopes: ${scopes.length} > ${SCOPE_VALIDATION_CONFIG.MAX_SCOPES_COUNT}`);
111
+ return result;
112
+ }
113
+ // Validate each scope
114
+ const seenScopes = new Set();
115
+ for (const scope of scopes) {
116
+ // Check for duplicates
117
+ if (seenScopes.has(scope)) {
118
+ result.errors.push(`Duplicate scope: ${scope}`);
119
+ result.invalidScopes.push(scope);
120
+ continue;
121
+ }
122
+ seenScopes.add(scope);
123
+ // Validate scope format
124
+ if (isValidTagScope(scope)) {
125
+ result.validScopes.push(scope);
126
+ }
127
+ else {
128
+ result.errors.push(`Invalid scope format: ${scope}`);
129
+ result.invalidScopes.push(scope);
130
+ }
131
+ }
132
+ // Set overall validity
133
+ result.isValid = result.errors.length === 0;
134
+ return result;
135
+ }
136
+ /**
137
+ * Validates that requested scopes are available (allowlist approach)
138
+ * @param requestedScopes - Scopes requested by client
139
+ * @param availableTags - Tags available on the server
140
+ * @returns Validation result
141
+ */
142
+ export function validateScopesAgainstAvailableTags(requestedScopes, availableTags) {
143
+ const result = {
144
+ isValid: true,
145
+ errors: [],
146
+ validScopes: [],
147
+ invalidScopes: [],
148
+ };
149
+ // First validate scope formats
150
+ const formatValidation = validateScopes(requestedScopes);
151
+ if (!formatValidation.isValid) {
152
+ return formatValidation;
153
+ }
154
+ // Create set of available tags for fast lookup
155
+ const availableTagSet = new Set(availableTags);
156
+ // Check each scope against available tags
157
+ for (const scope of requestedScopes) {
158
+ const tagName = extractTagFromScope(scope);
159
+ if (!tagName) {
160
+ result.errors.push(`Invalid scope format: ${scope}`);
161
+ result.invalidScopes.push(scope);
162
+ continue;
163
+ }
164
+ if (availableTagSet.has(tagName)) {
165
+ result.validScopes.push(scope);
166
+ }
167
+ else {
168
+ result.errors.push(`Scope not available: ${scope} (tag: ${tagName})`);
169
+ result.invalidScopes.push(scope);
170
+ }
171
+ }
172
+ result.isValid = result.errors.length === 0;
173
+ return result;
174
+ }
175
+ /**
176
+ * Checks if granted scopes satisfy the requirements for requested tags
177
+ * @param grantedScopes - Scopes granted during OAuth flow
178
+ * @param requestedTags - Tags requested for current operation
179
+ * @returns True if all requested tags are covered by granted scopes
180
+ */
181
+ export function hasRequiredScopes(grantedScopes, requestedTags) {
182
+ // Fail-secure: deny if inputs are invalid
183
+ if (!grantedScopes || !Array.isArray(grantedScopes) || !requestedTags || !Array.isArray(requestedTags)) {
184
+ logger.warn('Invalid input to hasRequiredScopes', { grantedScopes, requestedTags });
185
+ return false;
186
+ }
187
+ // No tags requested means access is allowed
188
+ if (requestedTags.length === 0) {
189
+ return true;
190
+ }
191
+ // Extract tags from granted scopes
192
+ const grantedTags = grantedScopes
193
+ .map((scope) => extractTagFromScope(scope))
194
+ .filter((tag) => tag !== null);
195
+ // Check if all requested tags are in granted tags
196
+ const hasAllTags = requestedTags.every((tag) => grantedTags.includes(tag));
197
+ if (!hasAllTags) {
198
+ logger.warn('Insufficient scopes for requested tags', {
199
+ grantedTags,
200
+ requestedTags,
201
+ missing: requestedTags.filter((tag) => !grantedTags.includes(tag)),
202
+ });
203
+ }
204
+ return hasAllTags;
205
+ }
206
+ /**
207
+ * Converts tags to their corresponding scopes
208
+ * @param tags - Array of tag names
209
+ * @returns Array of tag scopes
210
+ */
211
+ export function tagsToScopes(tags) {
212
+ if (!tags || !Array.isArray(tags)) {
213
+ return [];
214
+ }
215
+ return tags.filter((tag) => isValidTagName(tag)).map((tag) => `tag:${tag}`);
216
+ }
217
+ /**
218
+ * Converts scopes to their corresponding tags
219
+ * @param scopes - Array of scope strings
220
+ * @returns Array of tag names
221
+ */
222
+ export function scopesToTags(scopes) {
223
+ if (!scopes || !Array.isArray(scopes)) {
224
+ return [];
225
+ }
226
+ return scopes.map((scope) => extractTagFromScope(scope)).filter((tag) => tag !== null);
227
+ }
228
+ /**
229
+ * Security utility to audit scope operations
230
+ * @param operation - The operation being performed
231
+ * @param context - Additional context for logging
232
+ */
233
+ export function auditScopeOperation(operation, context) {
234
+ logger.info(`Scope operation: ${operation}`, {
235
+ operation,
236
+ clientId: context.clientId,
237
+ requestedScopes: context.requestedScopes,
238
+ grantedScopes: context.grantedScopes,
239
+ success: context.success,
240
+ error: context.error,
241
+ timestamp: new Date().toISOString(),
242
+ });
243
+ }
244
+ //# sourceMappingURL=scopeValidation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scopeValidation.js","sourceRoot":"","sources":["../../src/utils/scopeValidation.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,gDAAgD;IAChD,gBAAgB,EAAE,GAAG;IACrB,2CAA2C;IAC3C,gBAAgB,EAAE,EAAE;IACpB,oEAAoE;IACpE,gBAAgB,EAAE,kBAAkB;IACpC,sEAAsE;IACtE,iBAAiB,EAAE,sBAAsB;IACzC,8BAA8B;IAC9B,cAAc,EAAE,CAAC;IACjB,8BAA8B;IAC9B,cAAc,EAAE,EAAE;CACV,CAAC;AAoBX;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,2BAA2B;IAC3B,IACE,OAAO,CAAC,MAAM,GAAG,uBAAuB,CAAC,cAAc;QACvD,OAAO,CAAC,MAAM,GAAG,uBAAuB,CAAC,cAAc,EACvD,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,gBAAgB;IAChB,OAAO,uBAAuB,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAChE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,2BAA2B;IAC3B,IAAI,KA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
4
4
  "description": "One MCP server to aggregate them all - A unified Model Context Protocol server implementation",
5
5
  "keywords": [
6
6
  "mcp",
@@ -42,6 +42,9 @@
42
42
  }
43
43
  },
44
44
  "lint-staged": {
45
+ "*.ts": [
46
+ "bash -c 'tsc --noEmit --project tsconfig.test.json'"
47
+ ],
45
48
  "*.{js,ts}": [
46
49
  "eslint --fix",
47
50
  "prettier --write"
@@ -51,7 +54,7 @@
51
54
  ]
52
55
  },
53
56
  "dependencies": {
54
- "@modelcontextprotocol/sdk": "^1.13.0",
57
+ "@modelcontextprotocol/sdk": "^1.15.0",
55
58
  "body-parser": "^2.2.0",
56
59
  "cors": "^2.8.5",
57
60
  "express": "^5.1.0",
@@ -76,6 +79,7 @@
76
79
  "@typescript-eslint/eslint-plugin": "^8.27.0",
77
80
  "@typescript-eslint/parser": "^8.27.0",
78
81
  "@vitest/coverage-v8": "^1.4.0",
82
+ "axios": "^1.10.0",
79
83
  "eslint": "^9.22.0",
80
84
  "eslint-config-prettier": "^10.1.1",
81
85
  "eslint-plugin-prettier": "^5.2.3",
@@ -85,21 +89,26 @@
85
89
  "lint-staged": "^16.1.2",
86
90
  "prettier": "^3.5.3",
87
91
  "ts-node": "^10.9.2",
88
- "tsc-watch": "^6.2.1",
92
+ "tsc-watch": "^7.1.1",
89
93
  "typescript": "^5.3.3",
94
+ "vite-tsconfig-paths": "^5.1.4",
90
95
  "vitest": "^1.4.0"
91
96
  },
92
97
  "scripts": {
93
- "dev": "tsc-watch --onSuccess \"node build/index.js --config ./mcp.json --port 3051 --auth\"",
94
- "build": "tsc && node -e \"require('fs').chmodSync('build/index.js', '755')\"",
95
- "typecheck": "tsc --noEmit --project tsconfig.test.json",
96
- "watch": "tsc --watch",
98
+ "dev": "LOG_LEVEL=debug tsc-watch --project tsconfig.build.json --onSuccess \"node build/index.js --config ./mcp.json --port 3051 --enable-auth\"",
99
+ "build": "tsc --project tsconfig.build.json && node -e \"require('fs').chmodSync('build/index.js', '755')\"",
100
+ "watch": "tsc --watch --project tsconfig.build.json",
97
101
  "inspector": "npx -y @modelcontextprotocol/inspector",
98
102
  "lint": "eslint . --ext .ts",
99
103
  "lint:fix": "eslint . --ext .ts --fix",
100
- "format": "prettier --write \"src/**/*.{js,ts}\"",
101
- "test": "vitest run",
102
- "test:watch": "vitest",
103
- "test:coverage": "vitest run --coverage"
104
+ "format": "prettier --write \"src/**/*.{js,ts}\" \"test/**/*.{js,ts}\"",
105
+ "typecheck": "tsc --noEmit --project tsconfig.test.json",
106
+ "test": "pnpm test:unit && pnpm test:e2e",
107
+ "test:unit": "vitest run",
108
+ "test:unit:watch": "vitest",
109
+ "test:unit:coverage": "vitest run --coverage",
110
+ "test:e2e": "vitest run --config vitest.e2e.config.ts",
111
+ "test:e2e:watch": "vitest --config vitest.e2e.config.ts",
112
+ "test:e2e:coverage": "vitest run --config vitest.e2e.config.ts --coverage"
104
113
  }
105
114
  }
@@ -1,109 +0,0 @@
1
- import { SessionData } from './sessionManager.js';
2
- /**
3
- * AuthManager handles OAuth 2.1 authentication flow and token validation.
4
- *
5
- * This class orchestrates the OAuth 2.1 authorization code grant flow,
6
- * manages access token validation, and provides session information.
7
- * It integrates with SessionManager for persistent storage and
8
- * ServerConfigManager for configuration settings.
9
- *
10
- * Features:
11
- * - OAuth 2.1 authorization code grant flow
12
- * - Access token validation with prefix support
13
- * - Session information retrieval
14
- * - Configurable authentication settings
15
- *
16
- * @example
17
- * ```typescript
18
- * const authManager = new AuthManager('/custom/sessions');
19
- * const token = authManager.exchangeCodeForToken('code-123', 'client-456');
20
- * const session = authManager.validateAccessToken('tk-sess-789');
21
- * ```
22
- */
23
- export declare class AuthManager {
24
- private sessionManager;
25
- private configManager;
26
- /**
27
- * Creates a new AuthManager instance.
28
- *
29
- * Initializes the session manager with optional custom storage path
30
- * and retrieves the server configuration manager instance.
31
- *
32
- * @param sessionStoragePath - Optional custom path for session storage
33
- */
34
- constructor(sessionStoragePath?: string);
35
- /**
36
- * Checks if authentication is currently enabled.
37
- *
38
- * @returns True if OAuth 2.1 authentication is enabled, false otherwise
39
- */
40
- isAuthEnabled(): boolean;
41
- /**
42
- * Validates an access token and returns session data.
43
- *
44
- * If authentication is disabled, returns null (always valid).
45
- * For enabled authentication, strips the token prefix if present
46
- * and validates the underlying session.
47
- *
48
- * @param token - The access token to validate (with or without prefix)
49
- * @returns Session data if token is valid, null otherwise
50
- */
51
- validateAccessToken(token: string): SessionData | null;
52
- /**
53
- * Creates an authorization code for OAuth 2.1 flow.
54
- *
55
- * Delegates to the session manager to create a prefixed authorization
56
- * code with the configured time-to-live.
57
- *
58
- * @param clientId - The client identifier
59
- * @param redirectUri - The redirect URI for this code
60
- * @param resource - The resource this code grants access to
61
- * @returns The generated authorization code with prefix
62
- */
63
- createAuthCode(clientId: string, redirectUri: string, resource: string): string;
64
- /**
65
- * Exchanges an authorization code for an access token.
66
- *
67
- * Validates the authorization code, checks client ID and redirect URI
68
- * matches, then creates a new access token with the configured TTL.
69
- * The authorization code is deleted after successful exchange.
70
- *
71
- * @param code - The authorization code to exchange
72
- * @param clientId - The client identifier
73
- * @param redirectUri - Optional redirect URI for validation
74
- * @param resource - Optional resource for validation
75
- * @returns Access token with prefix if exchange successful, null otherwise
76
- */
77
- exchangeCodeForToken(code: string, clientId: string, redirectUri?: string, resource?: string): string | null;
78
- /**
79
- * Gets information about an access token.
80
- *
81
- * Retrieves session data for the token and returns formatted
82
- * information including client ID, resource, and time until expiration.
83
- *
84
- * @param token - The access token to get information for
85
- * @returns Token information if valid, null otherwise
86
- */
87
- getTokenInfo(token: string): {
88
- clientId: string;
89
- resource: string;
90
- expiresIn: number;
91
- } | null;
92
- /**
93
- * Revokes an access token.
94
- *
95
- * Removes the session associated with the token from storage.
96
- *
97
- * @param token - The access token to revoke
98
- * @returns True if token was revoked, false if it didn't exist
99
- */
100
- revokeToken(token: string): boolean;
101
- /**
102
- * Performs graceful shutdown of the AuthManager.
103
- *
104
- * Delegates shutdown to the session manager to ensure proper
105
- * cleanup of resources and timers.
106
- */
107
- shutdown(): void;
108
- }
109
- //# sourceMappingURL=authManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authManager.d.ts","sourceRoot":"","sources":["../../src/auth/authManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAKlE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,aAAa,CAAsB;IAE3C;;;;;;;OAOG;gBACS,kBAAkB,CAAC,EAAE,MAAM;IAKvC;;;;OAIG;IACI,aAAa,IAAI,OAAO;IAI/B;;;;;;;;;OASG;IACI,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAmB7D;;;;;;;;;;OAUG;IACI,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAKtF;;;;;;;;;;;;OAYG;IACI,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAoCnH;;;;;;;;OAQG;IACI,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAapG;;;;;;;OAOG;IACI,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAI1C;;;;;OAKG;IACI,QAAQ,IAAI,IAAI;CAGxB"}