@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.
- package/README.md +22 -37
- package/build/auth/sdkOAuthClientProvider.d.ts +93 -0
- package/build/auth/sdkOAuthClientProvider.d.ts.map +1 -0
- package/build/auth/sdkOAuthClientProvider.js +204 -0
- package/build/auth/sdkOAuthClientProvider.js.map +1 -0
- package/build/auth/sdkOAuthServerProvider.d.ts +64 -0
- package/build/auth/sdkOAuthServerProvider.d.ts.map +1 -0
- package/build/auth/sdkOAuthServerProvider.js +359 -0
- package/build/auth/sdkOAuthServerProvider.js.map +1 -0
- package/build/auth/sessionTypes.d.ts +38 -0
- package/build/auth/sessionTypes.d.ts.map +1 -0
- package/build/auth/sessionTypes.js +3 -0
- package/build/auth/sessionTypes.js.map +1 -0
- 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/capabilities/capabilityManager.d.ts +2 -2
- package/build/capabilities/capabilityManager.d.ts.map +1 -1
- package/build/capabilities/capabilityManager.js +1 -1
- package/build/capabilities/capabilityManager.js.map +1 -1
- package/build/config/{configManager.d.ts → mcpConfigManager.d.ts} +11 -6
- package/build/config/mcpConfigManager.d.ts.map +1 -0
- package/build/config/{configManager.js → mcpConfigManager.js} +26 -8
- package/build/config/mcpConfigManager.js.map +1 -0
- package/build/constants.d.ts +51 -14
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +61 -17
- package/build/constants.js.map +1 -1
- package/build/core/client/clientManager.d.ts +14 -6
- package/build/core/client/clientManager.d.ts.map +1 -1
- package/build/core/client/clientManager.js +90 -28
- package/build/core/client/clientManager.js.map +1 -1
- package/build/core/server/{serverConfig.d.ts → agentConfig.d.ts} +50 -15
- package/build/core/server/agentConfig.d.ts.map +1 -0
- package/build/core/server/agentConfig.js +166 -0
- package/build/core/server/agentConfig.js.map +1 -0
- package/build/core/server/serverManager.d.ts +12 -5
- package/build/core/server/serverManager.d.ts.map +1 -1
- package/build/core/server/serverManager.js +12 -2
- package/build/core/server/serverManager.js.map +1 -1
- package/build/core/types/client.d.ts +22 -9
- package/build/core/types/client.d.ts.map +1 -1
- package/build/core/types/client.js +2 -0
- package/build/core/types/client.js.map +1 -1
- package/build/core/types/server.d.ts +3 -3
- package/build/core/types/server.d.ts.map +1 -1
- package/build/core/types/transport.d.ts +58 -0
- package/build/core/types/transport.d.ts.map +1 -1
- package/build/core/types/transport.js +10 -0
- package/build/core/types/transport.js.map +1 -1
- package/build/handlers/notificationHandlers.d.ts +3 -3
- package/build/handlers/notificationHandlers.d.ts.map +1 -1
- package/build/handlers/notificationHandlers.js +2 -2
- package/build/handlers/notificationHandlers.js.map +1 -1
- package/build/handlers/requestHandlers.d.ts +2 -2
- package/build/handlers/requestHandlers.d.ts.map +1 -1
- package/build/handlers/requestHandlers.js +4 -3
- package/build/handlers/requestHandlers.js.map +1 -1
- package/build/index.js +47 -7
- package/build/index.js.map +1 -1
- package/build/{transport/http/middleware/loggingMiddleware.d.ts → logger/mcpLoggingEnhancer.d.ts} +1 -1
- package/build/logger/mcpLoggingEnhancer.d.ts.map +1 -0
- package/build/{transport/http/middleware/loggingMiddleware.js → logger/mcpLoggingEnhancer.js} +2 -2
- package/build/logger/mcpLoggingEnhancer.js.map +1 -0
- package/build/server.js +4 -4
- package/build/server.js.map +1 -1
- package/build/services/configReloadService.d.ts +2 -2
- package/build/services/configReloadService.d.ts.map +1 -1
- package/build/services/configReloadService.js +4 -4
- package/build/services/configReloadService.js.map +1 -1
- package/build/transport/http/middlewares/errorHandler.d.ts.map +1 -0
- package/build/transport/http/{errorHandler.js → middlewares/errorHandler.js} +1 -1
- package/build/transport/http/middlewares/errorHandler.js.map +1 -0
- package/build/transport/http/middlewares/scopeAuthMiddleware.d.ts +39 -0
- package/build/transport/http/middlewares/scopeAuthMiddleware.d.ts.map +1 -0
- package/build/transport/http/middlewares/scopeAuthMiddleware.js +129 -0
- package/build/transport/http/middlewares/scopeAuthMiddleware.js.map +1 -0
- package/build/transport/http/middlewares/securityMiddleware.d.ts +30 -0
- package/build/transport/http/middlewares/securityMiddleware.d.ts.map +1 -0
- package/build/transport/http/middlewares/securityMiddleware.js +201 -0
- package/build/transport/http/middlewares/securityMiddleware.js.map +1 -0
- package/build/transport/http/middlewares/tagsExtractor.d.ts.map +1 -0
- package/build/transport/http/middlewares/tagsExtractor.js.map +1 -0
- package/build/transport/http/routes/oauthRoutes.d.ts +5 -11
- package/build/transport/http/routes/oauthRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/oauthRoutes.js +460 -122
- package/build/transport/http/routes/oauthRoutes.js.map +1 -1
- package/build/transport/http/routes/sseRoutes.d.ts +3 -2
- package/build/transport/http/routes/sseRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/sseRoutes.js +10 -7
- package/build/transport/http/routes/sseRoutes.js.map +1 -1
- package/build/transport/http/routes/streamableHttpRoutes.d.ts +3 -2
- package/build/transport/http/routes/streamableHttpRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/streamableHttpRoutes.js +17 -10
- package/build/transport/http/routes/streamableHttpRoutes.js.map +1 -1
- package/build/transport/http/server.d.ts +3 -2
- package/build/transport/http/server.d.ts.map +1 -1
- package/build/transport/http/server.js +58 -21
- package/build/transport/http/server.js.map +1 -1
- package/build/transport/transportFactory.d.ts +9 -0
- package/build/transport/transportFactory.d.ts.map +1 -0
- package/build/transport/transportFactory.js +148 -0
- package/build/transport/transportFactory.js.map +1 -0
- package/build/utils/clientFiltering.d.ts +4 -4
- package/build/utils/clientFiltering.d.ts.map +1 -1
- package/build/utils/clientFiltering.js +54 -19
- package/build/utils/clientFiltering.js.map +1 -1
- package/build/utils/errorHandling.d.ts +0 -12
- package/build/utils/errorHandling.d.ts.map +1 -1
- package/build/utils/errorHandling.js +1 -42
- package/build/utils/errorHandling.js.map +1 -1
- package/build/utils/pagination.d.ts +2 -2
- package/build/utils/pagination.d.ts.map +1 -1
- package/build/utils/pagination.js +4 -4
- package/build/utils/pagination.js.map +1 -1
- package/build/utils/parsing.d.ts +13 -0
- package/build/utils/parsing.d.ts.map +1 -0
- package/build/utils/parsing.js +32 -0
- package/build/utils/parsing.js.map +1 -0
- package/build/utils/sanitization.d.ts +60 -0
- package/build/utils/sanitization.d.ts.map +1 -0
- package/build/utils/sanitization.js +149 -0
- package/build/utils/sanitization.js.map +1 -0
- package/build/utils/scopeValidation.d.ts +102 -0
- package/build/utils/scopeValidation.d.ts.map +1 -0
- package/build/utils/scopeValidation.js +244 -0
- package/build/utils/scopeValidation.js.map +1 -0
- package/package.json +20 -11
- package/build/auth/authManager.d.ts +0 -109
- package/build/auth/authManager.d.ts.map +0 -1
- package/build/auth/authManager.js +0 -173
- package/build/auth/authManager.js.map +0 -1
- package/build/auth/authMiddleware.d.ts +0 -16
- package/build/auth/authMiddleware.d.ts.map +0 -1
- package/build/auth/authMiddleware.js +0 -45
- package/build/auth/authMiddleware.js.map +0 -1
- package/build/auth/sessionManager.d.ts +0 -197
- package/build/auth/sessionManager.d.ts.map +0 -1
- package/build/auth/sessionManager.js +0 -408
- package/build/auth/sessionManager.js.map +0 -1
- package/build/config/configManager.d.ts.map +0 -1
- package/build/config/configManager.js.map +0 -1
- package/build/core/server/serverConfig.d.ts.map +0 -1
- package/build/core/server/serverConfig.js +0 -117
- package/build/core/server/serverConfig.js.map +0 -1
- package/build/transport/config.d.ts +0 -7
- package/build/transport/config.d.ts.map +0 -1
- package/build/transport/config.js +0 -90
- package/build/transport/config.js.map +0 -1
- package/build/transport/http/errorHandler.d.ts.map +0 -1
- package/build/transport/http/errorHandler.js.map +0 -1
- package/build/transport/http/middleware/loggingMiddleware.d.ts.map +0 -1
- package/build/transport/http/middleware/loggingMiddleware.js.map +0 -1
- package/build/utils/tagsExtractor.d.ts.map +0 -1
- package/build/utils/tagsExtractor.js.map +0 -1
- /package/build/transport/http/{errorHandler.d.ts → middlewares/errorHandler.d.ts} +0 -0
- /package/build/{utils → transport/http/middlewares}/tagsExtractor.d.ts +0 -0
- /package/build/{utils → transport/http/middlewares}/tagsExtractor.js +0 -0
package/build/server.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { MCP_SERVER_CAPABILITIES, MCP_SERVER_NAME, MCP_SERVER_VERSION } from './constants.js';
|
|
2
2
|
import logger from './logger/logger.js';
|
|
3
|
-
import { createTransports } from './transport/
|
|
3
|
+
import { createTransports } from './transport/transportFactory.js';
|
|
4
4
|
import { createClients } from './core/client/clientManager.js';
|
|
5
5
|
import { ServerManager } from './core/server/serverManager.js';
|
|
6
|
-
import {
|
|
6
|
+
import { McpConfigManager } from './config/mcpConfigManager.js';
|
|
7
7
|
import configReloadService from './services/configReloadService.js';
|
|
8
8
|
/**
|
|
9
9
|
* Main function to set up the MCP server
|
|
10
10
|
*/
|
|
11
11
|
async function setupServer() {
|
|
12
12
|
try {
|
|
13
|
-
const mcpConfig =
|
|
13
|
+
const mcpConfig = McpConfigManager.getInstance().getTransportConfig();
|
|
14
14
|
// Create transports from configuration
|
|
15
15
|
const transports = createTransports(mcpConfig);
|
|
16
16
|
logger.info(`Created ${Object.keys(transports).length} transports`);
|
|
17
17
|
// Create clients for each transport
|
|
18
18
|
const clients = await createClients(transports);
|
|
19
|
-
logger.info(`Created ${
|
|
19
|
+
logger.info(`Created ${clients.size} clients`);
|
|
20
20
|
const serverManager = ServerManager.getOrCreateInstance({ name: MCP_SERVER_NAME, version: MCP_SERVER_VERSION }, { capabilities: MCP_SERVER_CAPABILITIES }, clients, transports);
|
|
21
21
|
// Initialize config reload service at server startup
|
|
22
22
|
configReloadService.initialize(transports);
|
package/build/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC9F,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC9F,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAA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to handle dynamic configuration reloading
|
|
4
4
|
*/
|
|
@@ -31,7 +31,7 @@ export declare class ConfigReloadService {
|
|
|
31
31
|
* @param sessionId The session ID for this server instance
|
|
32
32
|
* @param serverInfo The MCP server instance
|
|
33
33
|
*/
|
|
34
|
-
updateServerInfo(sessionId: string, serverInfo:
|
|
34
|
+
updateServerInfo(sessionId: string, serverInfo: InboundConnection): void;
|
|
35
35
|
/**
|
|
36
36
|
* Remove server info when a client disconnects
|
|
37
37
|
* @param sessionId The session ID to remove
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configReloadService.d.ts","sourceRoot":"","sources":["../../src/services/configReloadService.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,
|
|
1
|
+
{"version":3,"file":"configReloadService.d.ts","sourceRoot":"","sources":["../../src/services/configReloadService.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAM/F;;GAEG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAsB;IAC7C,OAAO,CAAC,eAAe,CAA6C;IACpE,OAAO,CAAC,iBAAiB,CAAyC;IAClE,OAAO,CAAC,WAAW,CAAS;IAE5B;;OAEG;IACH,OAAO;IAEP;;;OAGG;WACW,WAAW,IAAI,mBAAmB;IAOhD;;;OAGG;IACI,UAAU,CAAC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,IAAI;IAoB7E;;;OAGG;YACW,kBAAkB;IAgDhC;;;;OAIG;IACI,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,iBAAiB,GAAG,IAAI;IAK/E;;;OAGG;IACI,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAKhD;;OAEG;IACI,IAAI,IAAI,IAAI;CAMpB;;AAED,wBAAiD"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import logger from '../logger/logger.js';
|
|
2
|
-
import { ConfigChangeEvent,
|
|
2
|
+
import { ConfigChangeEvent, McpConfigManager } from '../config/mcpConfigManager.js';
|
|
3
3
|
import { createClients } from '../core/client/clientManager.js';
|
|
4
4
|
import { setupCapabilities } from '../capabilities/capabilityManager.js';
|
|
5
|
-
import { createTransports } from '../transport/
|
|
5
|
+
import { createTransports } from '../transport/transportFactory.js';
|
|
6
6
|
import { ServerManager } from '../core/server/serverManager.js';
|
|
7
7
|
/**
|
|
8
8
|
* Service to handle dynamic configuration reloading
|
|
@@ -32,7 +32,7 @@ export class ConfigReloadService {
|
|
|
32
32
|
*/
|
|
33
33
|
initialize(initialTransports) {
|
|
34
34
|
this.currentTransports = initialTransports;
|
|
35
|
-
const configManager =
|
|
35
|
+
const configManager = McpConfigManager.getInstance();
|
|
36
36
|
// Remove any existing listeners to prevent duplicates
|
|
37
37
|
configManager.removeAllListeners(ConfigChangeEvent.TRANSPORT_CONFIG_CHANGED);
|
|
38
38
|
// Increase max listeners limit to prevent warnings
|
|
@@ -109,7 +109,7 @@ export class ConfigReloadService {
|
|
|
109
109
|
* Stop the service and clean up resources
|
|
110
110
|
*/
|
|
111
111
|
stop() {
|
|
112
|
-
const configManager =
|
|
112
|
+
const configManager = McpConfigManager.getInstance();
|
|
113
113
|
configManager.stopWatching();
|
|
114
114
|
configManager.removeAllListeners(ConfigChangeEvent.TRANSPORT_CONFIG_CHANGED);
|
|
115
115
|
logger.info('Config reload service stopped');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configReloadService.js","sourceRoot":"","sources":["../../src/services/configReloadService.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"configReloadService.js","sourceRoot":"","sources":["../../src/services/configReloadService.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,iB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
|
|
|
1
1
|
import { ErrorCode } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
-
import logger from '
|
|
2
|
+
import logger from '../../../logger/logger.js';
|
|
3
3
|
export default function errorHandler(err, req, res, _next) {
|
|
4
4
|
logger.error('Express error:', err);
|
|
5
5
|
res.status(500).json({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorHandler.js","sourceRoot":"","sources":["../../../../src/transport/http/middlewares/errorHandler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAE/C,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,GAAU,EAAE,GAAY,EAAE,GAAa,EAAE,KAAmB;IAC/F,MAAM,CAAC,KAAK,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;IACpC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;QACnB,KAAK,EAAE;YACL,IAAI,EAAE,SAAS,CAAC,aAAa;YAC7B,OAAO,EAAE,uBAAuB;SACjC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Request, Response, NextFunction } from 'express';
|
|
2
|
+
import { SDKOAuthServerProvider } from '../../../auth/sdkOAuthServerProvider.js';
|
|
3
|
+
/**
|
|
4
|
+
* Authentication information structure
|
|
5
|
+
*/
|
|
6
|
+
export interface AuthInfo {
|
|
7
|
+
token: string;
|
|
8
|
+
clientId: string;
|
|
9
|
+
grantedScopes: string[];
|
|
10
|
+
grantedTags: string[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Creates a scope validation middleware that uses the SDK's bearer auth middleware
|
|
14
|
+
*
|
|
15
|
+
* This middleware:
|
|
16
|
+
* 1. Uses SDK's requireBearerAuth to verify tokens (when auth enabled)
|
|
17
|
+
* 2. Validates that requested tags are covered by granted scopes
|
|
18
|
+
* 3. Provides authentication context to downstream handlers
|
|
19
|
+
*
|
|
20
|
+
* When scope validation is disabled, all tags are allowed.
|
|
21
|
+
* When scope validation is enabled:
|
|
22
|
+
* - If auth is also enabled, validates tokens and scopes
|
|
23
|
+
* - If auth is disabled, allows all tags (useful for development/testing)
|
|
24
|
+
*/
|
|
25
|
+
export declare function createScopeAuthMiddleware(oauthProvider?: SDKOAuthServerProvider): (_req: Request, res: Response, next: NextFunction) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Utility function to get validated tags from response locals
|
|
28
|
+
*
|
|
29
|
+
* This should be used by downstream handlers instead of directly accessing res.locals.tags
|
|
30
|
+
* to ensure they get scope-validated tags.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getValidatedTags(res: Response): string[];
|
|
33
|
+
/**
|
|
34
|
+
* Utility function to get authentication information from response locals
|
|
35
|
+
*/
|
|
36
|
+
export declare function getAuthInfo(res: Response): AuthInfo | undefined;
|
|
37
|
+
declare const _default: (_req: Request, res: Response, next: NextFunction) => void;
|
|
38
|
+
export default _default;
|
|
39
|
+
//# sourceMappingURL=scopeAuthMiddleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scopeAuthMiddleware.d.ts","sourceRoot":"","sources":["../../../../src/transport/http/middlewares/scopeAuthMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAI1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAGjF;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CAAC,aAAa,CAAC,EAAE,sBAAsB,UAK9D,OAAO,OAAO,QAAQ,QAAQ,YAAY,KAAG,IAAI,CAuFlE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,QAAQ,GAAG,MAAM,EAAE,CAWxD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAM/D;+BArHiB,OAAO,OAAO,QAAQ,QAAQ,YAAY,KAAG,IAAI;AAwHnE,wBAA2C"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { requireBearerAuth } from '@modelcontextprotocol/sdk/server/auth/middleware/bearerAuth.js';
|
|
2
|
+
import logger from '../../../logger/logger.js';
|
|
3
|
+
import { AgentConfigManager } from '../../../core/server/agentConfig.js';
|
|
4
|
+
import { SDKOAuthServerProvider } from '../../../auth/sdkOAuthServerProvider.js';
|
|
5
|
+
import { hasRequiredScopes, scopesToTags, auditScopeOperation } from '../../../utils/scopeValidation.js';
|
|
6
|
+
/**
|
|
7
|
+
* Creates a scope validation middleware that uses the SDK's bearer auth middleware
|
|
8
|
+
*
|
|
9
|
+
* This middleware:
|
|
10
|
+
* 1. Uses SDK's requireBearerAuth to verify tokens (when auth enabled)
|
|
11
|
+
* 2. Validates that requested tags are covered by granted scopes
|
|
12
|
+
* 3. Provides authentication context to downstream handlers
|
|
13
|
+
*
|
|
14
|
+
* When scope validation is disabled, all tags are allowed.
|
|
15
|
+
* When scope validation is enabled:
|
|
16
|
+
* - If auth is also enabled, validates tokens and scopes
|
|
17
|
+
* - If auth is disabled, allows all tags (useful for development/testing)
|
|
18
|
+
*/
|
|
19
|
+
export function createScopeAuthMiddleware(oauthProvider) {
|
|
20
|
+
const serverConfig = AgentConfigManager.getInstance();
|
|
21
|
+
// If scope validation is disabled, return a pass-through middleware
|
|
22
|
+
if (!serverConfig.isScopeValidationEnabled()) {
|
|
23
|
+
return (_req, res, next) => {
|
|
24
|
+
const requestedTags = res.locals.tags || [];
|
|
25
|
+
res.locals.validatedTags = requestedTags;
|
|
26
|
+
next();
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
// If scope validation is enabled but auth is disabled, allow all tags
|
|
30
|
+
if (!serverConfig.isAuthEnabled()) {
|
|
31
|
+
return (_req, res, next) => {
|
|
32
|
+
const requestedTags = res.locals.tags || [];
|
|
33
|
+
res.locals.validatedTags = requestedTags;
|
|
34
|
+
next();
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const provider = oauthProvider || new SDKOAuthServerProvider();
|
|
38
|
+
// Create the SDK's bearer auth middleware
|
|
39
|
+
const bearerAuthMiddleware = requireBearerAuth({
|
|
40
|
+
verifier: provider,
|
|
41
|
+
});
|
|
42
|
+
// Return a combined middleware that does both auth and scope validation
|
|
43
|
+
return async (req, res, next) => {
|
|
44
|
+
try {
|
|
45
|
+
// First run the SDK's bearer auth middleware
|
|
46
|
+
await new Promise((resolve, reject) => {
|
|
47
|
+
bearerAuthMiddleware(req, res, (err) => {
|
|
48
|
+
if (err)
|
|
49
|
+
reject(err);
|
|
50
|
+
else
|
|
51
|
+
resolve();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
// If we get here, auth succeeded and req.auth is populated
|
|
55
|
+
const authInfo = req.auth;
|
|
56
|
+
const grantedScopes = authInfo.scopes || [];
|
|
57
|
+
const grantedTags = scopesToTags(grantedScopes);
|
|
58
|
+
// Get requested tags from previous middleware (tagsExtractor)
|
|
59
|
+
const requestedTags = res.locals.tags || [];
|
|
60
|
+
// Validate that all requested tags are covered by granted scopes
|
|
61
|
+
if (!hasRequiredScopes(grantedScopes, requestedTags)) {
|
|
62
|
+
auditScopeOperation('insufficient_scopes', {
|
|
63
|
+
clientId: authInfo.clientId,
|
|
64
|
+
requestedScopes: requestedTags.map((tag) => `tag:${tag}`),
|
|
65
|
+
grantedScopes,
|
|
66
|
+
success: false,
|
|
67
|
+
error: 'Insufficient scopes for requested tags',
|
|
68
|
+
});
|
|
69
|
+
res.status(403).json({
|
|
70
|
+
error: 'insufficient_scope',
|
|
71
|
+
error_description: `Insufficient scopes. Required: ${requestedTags.join(', ')}, Granted: ${grantedTags.join(', ')}`,
|
|
72
|
+
});
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// Provide authentication context to downstream handlers via res.locals
|
|
76
|
+
res.locals.auth = {
|
|
77
|
+
token: req.headers.authorization?.slice(7) || '', // Remove 'Bearer ' prefix
|
|
78
|
+
clientId: authInfo.clientId,
|
|
79
|
+
grantedScopes,
|
|
80
|
+
grantedTags,
|
|
81
|
+
};
|
|
82
|
+
// Provide validated tags to downstream handlers
|
|
83
|
+
// If no specific tags requested, use all granted tags
|
|
84
|
+
res.locals.validatedTags = requestedTags.length > 0 ? requestedTags : grantedTags;
|
|
85
|
+
auditScopeOperation('scope_validation_success', {
|
|
86
|
+
clientId: authInfo.clientId,
|
|
87
|
+
requestedScopes: requestedTags.map((tag) => `tag:${tag}`),
|
|
88
|
+
grantedScopes,
|
|
89
|
+
success: true,
|
|
90
|
+
});
|
|
91
|
+
next();
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
logger.error('Scope auth middleware error:', error);
|
|
95
|
+
res.status(500).json({
|
|
96
|
+
error: 'server_error',
|
|
97
|
+
error_description: 'Internal server error',
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Utility function to get validated tags from response locals
|
|
104
|
+
*
|
|
105
|
+
* This should be used by downstream handlers instead of directly accessing res.locals.tags
|
|
106
|
+
* to ensure they get scope-validated tags.
|
|
107
|
+
*/
|
|
108
|
+
export function getValidatedTags(res) {
|
|
109
|
+
if (!res?.locals?.validatedTags) {
|
|
110
|
+
return [];
|
|
111
|
+
}
|
|
112
|
+
// Ensure it's an array
|
|
113
|
+
if (!Array.isArray(res.locals.validatedTags)) {
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
116
|
+
return res.locals.validatedTags;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Utility function to get authentication information from response locals
|
|
120
|
+
*/
|
|
121
|
+
export function getAuthInfo(res) {
|
|
122
|
+
if (!res?.locals?.auth) {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
return res.locals.auth;
|
|
126
|
+
}
|
|
127
|
+
// Default export for backward compatibility (creates a new provider instance)
|
|
128
|
+
export default createScopeAuthMiddleware();
|
|
129
|
+
//# sourceMappingURL=scopeAuthMiddleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scopeAuthMiddleware.js","sourceRoot":"","sources":["../../../../src/transport/http/middlewares/scopeAuthMiddleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gEAAgE,CAAC;AACnG,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAYzG;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,yBAAyB,CAAC,aAAsC;IAC9E,MAAM,YAAY,GAAG,kBAAkB,CAAC,WAAW,EAAE,CAAC;IAEtD,oEAAoE;IACpE,IAAI,CAAC,YAAY,CAAC,wBAAwB,EAAE,EAAE,CAAC;QAC7C,OAAO,CAAC,IAAa,EAAE,GAAa,EAAE,IAAkB,EAAQ,EAAE;YAChE,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;YAC5C,GAAG,CAAC,MAAM,CAAC,aAAa,GAAG,aAAa,CAAC;YACzC,IAAI,EAAE,CAAC;QACT,CAAC,CAAC;IACJ,CAAC;IAED,sEAAsE;IACtE,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,EAAE,CAAC;QAClC,OAAO,CA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AAK,EAAE,cAAc;gBACrB,iBAAiB,EAAE,uBAAuB;aAC3C,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAa;IAC5C,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;QAChC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,uBAAuB;IACvB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;QAC7C,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,GAAa;IACvC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;AACzB,CAAC;AAED,8EAA8E;AAC9E,eAAe,yBAAyB,EAAE,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Request, Response, NextFunction } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* Security headers middleware to protect against common attacks
|
|
4
|
+
*/
|
|
5
|
+
export declare function securityHeaders(req: Request, res: Response, next: NextFunction): void;
|
|
6
|
+
/**
|
|
7
|
+
* Rate limiter for sensitive operations (stricter than general OAuth)
|
|
8
|
+
*/
|
|
9
|
+
export declare const sensitiveOperationLimiter: import("express-rate-limit").RateLimitRequestHandler;
|
|
10
|
+
/**
|
|
11
|
+
* Enhanced input validation middleware
|
|
12
|
+
*/
|
|
13
|
+
export declare function inputValidation(req: Request, res: Response, next: NextFunction): void;
|
|
14
|
+
/**
|
|
15
|
+
* Session security middleware
|
|
16
|
+
*/
|
|
17
|
+
export declare function sessionSecurity(req: Request, res: Response, next: NextFunction): void;
|
|
18
|
+
/**
|
|
19
|
+
* Request logging middleware for security audit trail
|
|
20
|
+
*/
|
|
21
|
+
export declare function securityAuditLogger(req: Request, res: Response, next: NextFunction): void;
|
|
22
|
+
/**
|
|
23
|
+
* Prevent common timing attacks
|
|
24
|
+
*/
|
|
25
|
+
export declare function timingAttackPrevention(req: Request, res: Response, next: NextFunction): void;
|
|
26
|
+
/**
|
|
27
|
+
* Comprehensive security middleware stack
|
|
28
|
+
*/
|
|
29
|
+
export declare function setupSecurityMiddleware(): (typeof securityHeaders)[];
|
|
30
|
+
//# sourceMappingURL=securityMiddleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"securityMiddleware.d.ts","sourceRoot":"","sources":["../../../../src/transport/http/middlewares/securityMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAI1D;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CAyBrF;AAED;;GAEG;AACH,eAAO,MAAM,yBAAyB,sDA2BpC,CAAC;AAEH;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CAiErF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CAarF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CA4CzF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CAwB5F;AAED;;GAEG;AACH,wBAAgB,uBAAuB,+BAEtC"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import rateLimit from 'express-rate-limit';
|
|
2
|
+
import logger from '../../../logger/logger.js';
|
|
3
|
+
/**
|
|
4
|
+
* Security headers middleware to protect against common attacks
|
|
5
|
+
*/
|
|
6
|
+
export function securityHeaders(req, res, next) {
|
|
7
|
+
// Prevent clickjacking
|
|
8
|
+
res.setHeader('X-Frame-Options', 'DENY');
|
|
9
|
+
// Prevent MIME type sniffing
|
|
10
|
+
res.setHeader('X-Content-Type-Options', 'nosniff');
|
|
11
|
+
// Enable XSS protection
|
|
12
|
+
res.setHeader('X-XSS-Protection', '1; mode=block');
|
|
13
|
+
// Prevent referrer leakage
|
|
14
|
+
res.setHeader('Referrer-Policy', 'strict-origin-when-cross-origin');
|
|
15
|
+
// Content Security Policy for HTML responses (disabled for OAuth/auth paths)
|
|
16
|
+
if (req.accepts('html') && !req.path.includes('/oauth/') && !req.path.includes('/auth/')) {
|
|
17
|
+
res.setHeader('Content-Security-Policy', "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; form-action 'self'; frame-ancestors 'none';");
|
|
18
|
+
}
|
|
19
|
+
// Remove server information
|
|
20
|
+
res.removeHeader('X-Powered-By');
|
|
21
|
+
next();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Rate limiter for sensitive operations (stricter than general OAuth)
|
|
25
|
+
*/
|
|
26
|
+
export const sensitiveOperationLimiter = rateLimit({
|
|
27
|
+
windowMs: 15 * 60 * 1000, // 15 minutes
|
|
28
|
+
max: 10, // 10 attempts per window
|
|
29
|
+
standardHeaders: true,
|
|
30
|
+
legacyHeaders: false,
|
|
31
|
+
message: {
|
|
32
|
+
error: 'rate_limit_exceeded',
|
|
33
|
+
error_description: 'Too many sensitive operations. Please try again later.',
|
|
34
|
+
},
|
|
35
|
+
skip: (req) => {
|
|
36
|
+
// Skip rate limiting for health checks or non-sensitive endpoints
|
|
37
|
+
return req.path === '/health' || req.path === '/';
|
|
38
|
+
},
|
|
39
|
+
handler: (req, res) => {
|
|
40
|
+
logger.warn(`Rate limit exceeded for sensitive operation`, {
|
|
41
|
+
ip: req.ip,
|
|
42
|
+
userAgent: req.get('User-Agent'),
|
|
43
|
+
path: req.path,
|
|
44
|
+
method: req.method,
|
|
45
|
+
timestamp: new Date().toISOString(),
|
|
46
|
+
});
|
|
47
|
+
res.status(429).json({
|
|
48
|
+
error: 'rate_limit_exceeded',
|
|
49
|
+
error_description: 'Too many sensitive operations. Please try again later.',
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
/**
|
|
54
|
+
* Enhanced input validation middleware
|
|
55
|
+
*/
|
|
56
|
+
export function inputValidation(req, res, next) {
|
|
57
|
+
// Check for common injection patterns in headers
|
|
58
|
+
const suspiciousPatterns = [
|
|
59
|
+
/\$\(.*\)/, // Command injection
|
|
60
|
+
/<script[\s\S]*?>/i, // XSS - matches across newlines
|
|
61
|
+
/javascript:/i, // JavaScript protocol
|
|
62
|
+
/\.\./, // Path traversal
|
|
63
|
+
/\0/, // Null byte injection
|
|
64
|
+
/union.*select/i, // SQL injection
|
|
65
|
+
/exec\s*\(/i, // Code execution
|
|
66
|
+
];
|
|
67
|
+
const checkForMaliciousContent = (value, location) => {
|
|
68
|
+
return suspiciousPatterns.some((pattern) => {
|
|
69
|
+
if (pattern.test(value)) {
|
|
70
|
+
logger.warn(`Suspicious content detected in ${location}`, {
|
|
71
|
+
value: value.substring(0, 100), // Log only first 100 chars
|
|
72
|
+
pattern: pattern.toString(),
|
|
73
|
+
ip: req.ip,
|
|
74
|
+
userAgent: req.get('User-Agent'),
|
|
75
|
+
path: req.path,
|
|
76
|
+
timestamp: new Date().toISOString(),
|
|
77
|
+
});
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
// Check headers
|
|
84
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
85
|
+
if (typeof value === 'string' && checkForMaliciousContent(value, `header:${key}`)) {
|
|
86
|
+
res.status(400).json({
|
|
87
|
+
error: 'invalid_request',
|
|
88
|
+
error_description: 'Request contains suspicious content',
|
|
89
|
+
});
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Check query parameters
|
|
94
|
+
for (const [key, value] of Object.entries(req.query)) {
|
|
95
|
+
if (typeof value === 'string' && checkForMaliciousContent(value, `query:${key}`)) {
|
|
96
|
+
res.status(400).json({
|
|
97
|
+
error: 'invalid_request',
|
|
98
|
+
error_description: 'Request contains suspicious content',
|
|
99
|
+
});
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// Check body for POST requests
|
|
104
|
+
if (req.body && typeof req.body === 'object') {
|
|
105
|
+
for (const [key, value] of Object.entries(req.body)) {
|
|
106
|
+
if (typeof value === 'string' && checkForMaliciousContent(value, `body:${key}`)) {
|
|
107
|
+
res.status(400).json({
|
|
108
|
+
error: 'invalid_request',
|
|
109
|
+
error_description: 'Request contains suspicious content',
|
|
110
|
+
});
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
next();
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Session security middleware
|
|
119
|
+
*/
|
|
120
|
+
export function sessionSecurity(req, res, next) {
|
|
121
|
+
// Add security-related headers for session management
|
|
122
|
+
res.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate');
|
|
123
|
+
res.setHeader('Pragma', 'no-cache');
|
|
124
|
+
res.setHeader('Expires', '0');
|
|
125
|
+
res.setHeader('Surrogate-Control', 'no-store');
|
|
126
|
+
// For OAuth endpoints, add additional security
|
|
127
|
+
if (req.path.includes('/oauth/')) {
|
|
128
|
+
res.setHeader('X-Robots-Tag', 'noindex, nofollow, nosnippet, noarchive');
|
|
129
|
+
}
|
|
130
|
+
next();
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Request logging middleware for security audit trail
|
|
134
|
+
*/
|
|
135
|
+
export function securityAuditLogger(req, res, next) {
|
|
136
|
+
const startTime = Date.now();
|
|
137
|
+
// Log high-value security events
|
|
138
|
+
const isSecurityRelevant = req.path.includes('/oauth/') ||
|
|
139
|
+
req.path.includes('/auth/') ||
|
|
140
|
+
req.method === 'POST' ||
|
|
141
|
+
req.method === 'PUT' ||
|
|
142
|
+
req.method === 'DELETE';
|
|
143
|
+
if (isSecurityRelevant) {
|
|
144
|
+
logger.info('Security-relevant request', {
|
|
145
|
+
method: req.method,
|
|
146
|
+
path: req.path,
|
|
147
|
+
ip: req.ip,
|
|
148
|
+
userAgent: req.get('User-Agent'),
|
|
149
|
+
contentType: req.get('Content-Type'),
|
|
150
|
+
timestamp: new Date().toISOString(),
|
|
151
|
+
sessionId: req.headers['mcp-session-id'],
|
|
152
|
+
authorization: req.headers.authorization ? 'Bearer [REDACTED]' : undefined,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
// Capture response details
|
|
156
|
+
const originalSend = res.send;
|
|
157
|
+
res.send = function (body) {
|
|
158
|
+
const duration = Date.now() - startTime;
|
|
159
|
+
if (isSecurityRelevant) {
|
|
160
|
+
logger.info('Security-relevant response', {
|
|
161
|
+
method: req.method,
|
|
162
|
+
path: req.path,
|
|
163
|
+
statusCode: res.statusCode,
|
|
164
|
+
duration,
|
|
165
|
+
ip: req.ip,
|
|
166
|
+
timestamp: new Date().toISOString(),
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
return originalSend.call(this, body);
|
|
170
|
+
};
|
|
171
|
+
next();
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Prevent common timing attacks
|
|
175
|
+
*/
|
|
176
|
+
export function timingAttackPrevention(req, res, next) {
|
|
177
|
+
const startTime = Date.now();
|
|
178
|
+
// Add random delay for authentication-related endpoints to prevent timing attacks
|
|
179
|
+
const isAuthEndpoint = req.path.includes('/oauth/') || req.path.includes('/auth/');
|
|
180
|
+
if (isAuthEndpoint) {
|
|
181
|
+
// Add random delay between 10-50ms to make timing attacks harder
|
|
182
|
+
const randomDelay = Math.floor(Math.random() * 40) + 10;
|
|
183
|
+
const originalSend = res.send;
|
|
184
|
+
res.send = function (body) {
|
|
185
|
+
const elapsed = Date.now() - startTime;
|
|
186
|
+
const remainingDelay = Math.max(0, randomDelay - elapsed);
|
|
187
|
+
setTimeout(() => {
|
|
188
|
+
return originalSend.call(this, body);
|
|
189
|
+
}, remainingDelay);
|
|
190
|
+
return this;
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
next();
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Comprehensive security middleware stack
|
|
197
|
+
*/
|
|
198
|
+
export function setupSecurityMiddleware() {
|
|
199
|
+
return [securityHeaders, sessionSecurity, inputValidation, securityAuditLogger, timingAttackPrevention];
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=securityMiddleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"securityMiddleware.js","sourceRoot":"","sources":["../../../../src/transport/http/middlewares/securityMiddleware.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAE/C;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB;IAC7E,uBAAuB;IACvB,GAAG,CAAC,SAAS,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;IAEzC,6BAA6B;IAC7B,GAAG,CAAC,SAAS,CAAC,wBAAwB,EAAE,SAAS,CAAC,CAAC;IAEnD,wBAAwB;IACxB,GAAG,CAAC,SAAS,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAC;IAEnD,2BAA2B;IAC3B,GAAG,CAAC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,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC;QAExD,MAAM,YAAY,GAAG,GAAG,CAAC,IAAI,CAAC;QAC9B,GAAG,CAAC,IAAI,GAAG,UAAU,IAAS;YAC5B,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;YACvC,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC;YAE1D,UAAU,CAAC,GAAG,EAAE;gBACd,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACvC,CAAC,EAAE,cAAc,CAAC,CAAC;YAEnB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,EAAE,CAAC;AACT,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,CAAC,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAAE,sBAAsB,CAAC,CAAC;AAC1G,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tagsExtractor.d.ts","sourceRoot":"","sources":["../../../../src/transport/http/middlewares/tagsExtractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG1D;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,QAkBpF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tagsExtractor.js","sourceRoot":"","sources":["../../../../src/transport/http/middlewares/tagsExtractor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAE/D;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB;IACnF,IAAI,IAA0B,CAAC;IAC/B,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,MAAM,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,IAAc,CAAC;QACzC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACnB,KAAK,EAAE;oBACL,IAAI,EAAE,SAAS,CAAC,aAAa;oBAC7B,OAAO,EAAE,uCAAuC;iBACjD;aACF,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QACD,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACnE,CAAC;IACD,oDAAoD;IACpD,GAAG,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;IACvB,IAAI,EAAE,CAAC;AACT,CAAC"}
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
import { SDKOAuthServerProvider } from '../../../auth/sdkOAuthServerProvider.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* This function registers all OAuth 2.1 endpoints (authorization, token, metadata, registration)
|
|
7
|
-
* and MCP resource metadata endpoints on the provided Express application. It uses the provided
|
|
8
|
-
* AuthManager for all authentication and token operations.
|
|
9
|
-
*
|
|
10
|
-
* @param app - The Express application instance
|
|
11
|
-
* @param authManager - The AuthManager instance for OAuth/session logic
|
|
4
|
+
* Creates OAuth routes with the provided OAuth provider
|
|
12
5
|
*/
|
|
13
|
-
export declare function
|
|
6
|
+
export declare function createOAuthRoutes(oauthProvider: SDKOAuthServerProvider): Router;
|
|
7
|
+
export default createOAuthRoutes;
|
|
14
8
|
//# sourceMappingURL=oauthRoutes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauthRoutes.d.ts","sourceRoot":"","sources":["../../../../src/transport/http/routes/oauthRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"oauthRoutes.d.ts","sourceRoot":"","sources":["../../../../src/transport/http/routes/oauthRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqC,MAAM,SAAS,CAAC;AAgBpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAGjF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,sBAAsB,GAAG,MAAM,CAsf/E;AAGD,eAAe,iBAAiB,CAAC"}
|