@mcp-abap-adt/proxy 0.1.5 → 0.1.9

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 (39) hide show
  1. package/CHANGELOG.md +77 -2
  2. package/README.md +83 -66
  3. package/bin/mcp-abap-adt-proxy.js +15 -42
  4. package/dist/index.d.ts +3 -12
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +414 -277
  7. package/dist/lib/config.d.ts +13 -4
  8. package/dist/lib/config.d.ts.map +1 -1
  9. package/dist/lib/config.js +110 -93
  10. package/dist/lib/errorHandler.d.ts +3 -3
  11. package/dist/lib/errorHandler.d.ts.map +1 -1
  12. package/dist/lib/errorHandler.js +31 -28
  13. package/dist/lib/logger.d.ts.map +1 -1
  14. package/dist/lib/logger.js +12 -9
  15. package/dist/lib/stores.d.ts +7 -7
  16. package/dist/lib/stores.d.ts.map +1 -1
  17. package/dist/lib/stores.js +54 -80
  18. package/dist/lib/transportConfig.d.ts +1 -1
  19. package/dist/lib/transportConfig.d.ts.map +1 -1
  20. package/dist/lib/transportConfig.js +58 -38
  21. package/dist/proxy/btpProxy.d.ts +102 -0
  22. package/dist/proxy/btpProxy.d.ts.map +1 -0
  23. package/dist/proxy/btpProxy.js +833 -0
  24. package/dist/proxy/cloudLlmHubProxy.d.ts +1 -65
  25. package/dist/proxy/cloudLlmHubProxy.d.ts.map +1 -1
  26. package/dist/proxy/cloudLlmHubProxy.js +1 -441
  27. package/dist/router/headerAnalyzer.d.ts +9 -18
  28. package/dist/router/headerAnalyzer.d.ts.map +1 -1
  29. package/dist/router/headerAnalyzer.js +35 -63
  30. package/dist/router/requestInterceptor.d.ts +5 -11
  31. package/dist/router/requestInterceptor.d.ts.map +1 -1
  32. package/dist/router/requestInterceptor.js +33 -30
  33. package/package.json +38 -20
  34. package/dist/router/directCloudRouter.d.ts +0 -32
  35. package/dist/router/directCloudRouter.d.ts.map +0 -1
  36. package/dist/router/directCloudRouter.js +0 -146
  37. package/dist/router/localBasicRouter.d.ts +0 -23
  38. package/dist/router/localBasicRouter.d.ts.map +0 -1
  39. package/dist/router/localBasicRouter.js +0 -118
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /**
3
3
  * Platform-specific stores for proxy
4
- * Uses AbapServiceKeyStore/XsuaaServiceKeyStore and either AbapSessionStore or SafeAbapSessionStore
4
+ * Uses XsuaaServiceKeyStore and either XsuaaSessionStore or SafeXsuaaSessionStore
5
5
  * depending on the unsafe configuration parameter
6
6
  */
7
7
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
@@ -39,17 +39,17 @@ var __importStar = (this && this.__importStar) || (function () {
39
39
  })();
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.getPlatformStores = getPlatformStores;
42
+ const os = __importStar(require("node:os"));
43
+ const path = __importStar(require("node:path"));
42
44
  const auth_stores_1 = require("@mcp-abap-adt/auth-stores");
43
- const path = __importStar(require("path"));
44
- const os = __importStar(require("os"));
45
45
  /**
46
46
  * Get platform-specific default paths for service keys and sessions
47
47
  *
48
- * Priority:
48
+ * Priority (matching mcp-abap-adt logic):
49
49
  * 1. AUTH_BROKER_PATH environment variable
50
- * 2. Platform-specific standard paths:
51
- * - Unix: ~/.config/mcp-abap-adt/service-keys
52
- * - Windows: %USERPROFILE%\Documents\mcp-abap-adt\service-keys
50
+ * 2. Platform-specific standard paths (only if no env paths were found):
51
+ * - Unix: ~/.config/mcp-abap-adt/{subfolder}
52
+ * - Windows: %USERPROFILE%\Documents\mcp-abap-adt\{subfolder}
53
53
  * 3. Current working directory (process.cwd())
54
54
  *
55
55
  * @param subfolder Subfolder name ('service-keys' or 'sessions')
@@ -59,33 +59,46 @@ function getPlatformPaths(subfolder) {
59
59
  const paths = [];
60
60
  const isWindows = process.platform === 'win32';
61
61
  // Priority 1: AUTH_BROKER_PATH environment variable
62
+ // AUTH_BROKER_PATH is treated as a base path; append subfolder when requested
62
63
  const envPath = process.env.AUTH_BROKER_PATH;
63
64
  if (envPath) {
64
65
  // Support both colon (Unix) and semicolon (Windows) separators
65
- const envPaths = envPath.split(/[:;]/).map(p => p.trim()).filter(p => p.length > 0);
66
- paths.push(...envPaths.map(p => path.resolve(p)));
66
+ const envPaths = envPath
67
+ .split(/[:;]/)
68
+ .map((p) => p.trim())
69
+ .filter((p) => p.length > 0);
70
+ paths.push(...envPaths.map((p) => {
71
+ let resolved = path.resolve(p);
72
+ // If path already ends with subfolder, use parent as base path
73
+ if (subfolder && path.basename(resolved) === subfolder) {
74
+ resolved = path.dirname(resolved);
75
+ }
76
+ return subfolder ? path.join(resolved, subfolder) : resolved;
77
+ }));
67
78
  }
68
- // Priority 2: Platform-specific standard paths (always added, unless AUTH_BROKER_PATH is set)
69
- // If AUTH_BROKER_PATH is set, platform paths are still added but with lower priority
70
- const homeDir = os.homedir();
71
- if (isWindows) {
72
- // Windows: %USERPROFILE%\Documents\mcp-abap-adt\{subfolder}
73
- const basePath = path.join(homeDir, 'Documents', 'mcp-abap-adt');
74
- if (subfolder) {
75
- paths.push(path.join(basePath, subfolder));
79
+ // Priority 2: Platform-specific standard paths
80
+ // Only add platform-specific paths if no custom paths were provided (matching mcp-abap-adt logic)
81
+ if (paths.length === 0) {
82
+ const homeDir = os.homedir();
83
+ if (isWindows) {
84
+ // Windows: %USERPROFILE%\Documents\mcp-abap-adt\{subfolder}
85
+ const basePath = path.join(homeDir, 'Documents', 'mcp-abap-adt');
86
+ if (subfolder) {
87
+ paths.push(path.join(basePath, subfolder));
88
+ }
89
+ else {
90
+ paths.push(basePath);
91
+ }
76
92
  }
77
93
  else {
78
- paths.push(basePath);
79
- }
80
- }
81
- else {
82
- // Unix (Linux/macOS): ~/.config/mcp-abap-adt/{subfolder}
83
- const basePath = path.join(homeDir, '.config', 'mcp-abap-adt');
84
- if (subfolder) {
85
- paths.push(path.join(basePath, subfolder));
86
- }
87
- else {
88
- paths.push(basePath);
94
+ // Unix (Linux/macOS): ~/.config/mcp-abap-adt/{subfolder}
95
+ const basePath = path.join(homeDir, '.config', 'mcp-abap-adt');
96
+ if (subfolder) {
97
+ paths.push(path.join(basePath, subfolder));
98
+ }
99
+ else {
100
+ paths.push(basePath);
101
+ }
89
102
  }
90
103
  }
91
104
  // Priority 3: Current working directory (always added as fallback)
@@ -102,56 +115,13 @@ function getPlatformPaths(subfolder) {
102
115
  }
103
116
  return uniquePaths;
104
117
  }
105
- /**
106
- * Combined service key store that tries both standard and XSUAA loaders
107
- * Tries standard ABAP service key loader first, then XSUAA loader if not found
108
- *
109
- * Note: Stores only support a single directory, so we use the first path from the array
110
- */
111
- class CombinedServiceKeyStore {
112
- abapStore;
113
- xsuaaStore;
114
- constructor(searchPaths) {
115
- // Stores only support a single directory, use the first path
116
- const firstPath = searchPaths[0] || process.cwd();
117
- this.abapStore = new auth_stores_1.AbapServiceKeyStore(firstPath);
118
- this.xsuaaStore = new auth_stores_1.XsuaaServiceKeyStore(firstPath);
119
- }
120
- async getServiceKey(destination) {
121
- // Try ABAP service key store first
122
- const abapKey = await this.abapStore.getServiceKey(destination);
123
- if (abapKey) {
124
- return abapKey;
125
- }
126
- // If not found, try XSUAA store (for BTP XSUAA service keys)
127
- return await this.xsuaaStore.getServiceKey(destination);
128
- }
129
- async getAuthorizationConfig(destination) {
130
- // Try ABAP service key store first
131
- const abapConfig = await this.abapStore.getAuthorizationConfig(destination);
132
- if (abapConfig) {
133
- return abapConfig;
134
- }
135
- // If not found, try XSUAA store (for BTP XSUAA service keys)
136
- return await this.xsuaaStore.getAuthorizationConfig(destination);
137
- }
138
- async getConnectionConfig(destination) {
139
- // Try ABAP service key store first
140
- const abapConfig = await this.abapStore.getConnectionConfig(destination);
141
- if (abapConfig) {
142
- return abapConfig;
143
- }
144
- // If not found, try XSUAA store (for BTP XSUAA service keys)
145
- return await this.xsuaaStore.getConnectionConfig(destination);
146
- }
147
- }
148
118
  /**
149
119
  * Get platform-specific stores
150
- * Returns stores based on configuration:
151
- * - If unsafe=true: uses AbapSessionStore (persists to disk)
152
- * - If unsafe=false: uses SafeAbapSessionStore (in-memory, secure)
153
- * - Service key store: Combined store that tries both standard and XSUAA loaders
154
- * @param unsafe If true, use AbapSessionStore. If false, use SafeAbapSessionStore (default).
120
+ * Returns XSUAA stores for BTP authentication:
121
+ * - If unsafe=true: uses XsuaaSessionStore (persists to disk)
122
+ * - If unsafe=false: uses SafeXsuaaSessionStore (in-memory, secure)
123
+ * - Service key store: XsuaaServiceKeyStore
124
+ * @param unsafe If true, use XsuaaSessionStore. If false, use SafeXsuaaSessionStore (default).
155
125
  */
156
126
  async function getPlatformStores(unsafe = false) {
157
127
  // Get platform-specific paths for service keys and sessions
@@ -160,10 +130,14 @@ async function getPlatformStores(unsafe = false) {
160
130
  // Stores only support a single directory, use the first path
161
131
  const firstServiceKeyPath = serviceKeyPaths[0] || process.cwd();
162
132
  const firstSessionPath = sessionPaths[0] || process.cwd();
133
+ const serviceKeyStore = new auth_stores_1.XsuaaServiceKeyStore(firstServiceKeyPath);
134
+ // Note: XSUAA stores require defaultServiceUrl (cannot be obtained from service key)
135
+ // For now, we use empty string as placeholder - it will be set when session is created
136
+ const sessionStore = unsafe
137
+ ? new auth_stores_1.XsuaaSessionStore(firstSessionPath, '')
138
+ : new auth_stores_1.SafeXsuaaSessionStore('');
163
139
  return {
164
- serviceKeyStore: new CombinedServiceKeyStore(serviceKeyPaths),
165
- sessionStore: unsafe
166
- ? new auth_stores_1.AbapSessionStore(firstSessionPath)
167
- : new auth_stores_1.SafeAbapSessionStore(),
140
+ serviceKeyStore,
141
+ sessionStore,
168
142
  };
169
143
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Transport Configuration - Parse and manage transport settings
3
3
  */
4
- export type TransportType = "stdio" | "streamable-http" | "sse";
4
+ export type TransportType = 'stdio' | 'streamable-http' | 'sse';
5
5
  export interface TransportConfig {
6
6
  type: TransportType;
7
7
  host?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"transportConfig.d.ts","sourceRoot":"","sources":["../../src/lib/transportConfig.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,iBAAiB,GAAG,KAAK,CAAC;AAEhE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,4BAA4B,CAAC,EAAE,OAAO,CAAC;CACxC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,eAAe,CAgGtD"}
1
+ {"version":3,"file":"transportConfig.d.ts","sourceRoot":"","sources":["../../src/lib/transportConfig.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,iBAAiB,GAAG,KAAK,CAAC;AAEhE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,4BAA4B,CAAC,EAAE,OAAO,CAAC;CACxC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,eAAe,CAkItD"}
@@ -13,70 +13,84 @@ function parseTransportConfig() {
13
13
  let transportType = null;
14
14
  for (let i = 0; i < args.length; i++) {
15
15
  const arg = args[i];
16
- if (arg.startsWith("--transport=")) {
17
- const value = arg.split("=")[1].toLowerCase();
18
- if (value === "stdio" || value === "streamable-http" || value === "http" || value === "sse") {
19
- transportType = value === "http" ? "streamable-http" : value;
16
+ if (arg.startsWith('--transport=')) {
17
+ const value = arg.split('=')[1].toLowerCase();
18
+ if (value === 'stdio' ||
19
+ value === 'streamable-http' ||
20
+ value === 'http' ||
21
+ value === 'sse') {
22
+ transportType =
23
+ value === 'http' ? 'streamable-http' : value;
20
24
  }
21
25
  }
22
- if (arg === "--transport" && i + 1 < args.length) {
26
+ if (arg === '--transport' && i + 1 < args.length) {
23
27
  const value = args[i + 1].toLowerCase();
24
- if (value === "stdio" || value === "streamable-http" || value === "http" || value === "sse") {
25
- transportType = value === "http" ? "streamable-http" : value;
28
+ if (value === 'stdio' ||
29
+ value === 'streamable-http' ||
30
+ value === 'http' ||
31
+ value === 'sse') {
32
+ transportType =
33
+ value === 'http' ? 'streamable-http' : value;
26
34
  }
27
35
  }
28
- if (arg === "--http")
29
- transportType = "streamable-http";
30
- if (arg === "--stdio")
31
- transportType = "stdio";
32
- if (arg === "--sse")
33
- transportType = "sse";
36
+ if (arg === '--http')
37
+ transportType = 'streamable-http';
38
+ if (arg === '--stdio')
39
+ transportType = 'stdio';
40
+ if (arg === '--sse')
41
+ transportType = 'sse';
34
42
  }
35
43
  // Check environment variable
36
44
  if (!transportType && process.env.MCP_TRANSPORT) {
37
45
  const envTransport = process.env.MCP_TRANSPORT.toLowerCase();
38
- if (envTransport === "stdio" || envTransport === "streamable-http" || envTransport === "http" || envTransport === "sse") {
39
- transportType = envTransport === "http" ? "streamable-http" : envTransport;
46
+ if (envTransport === 'stdio' ||
47
+ envTransport === 'streamable-http' ||
48
+ envTransport === 'http' ||
49
+ envTransport === 'sse') {
50
+ transportType =
51
+ envTransport === 'http'
52
+ ? 'streamable-http'
53
+ : envTransport;
40
54
  }
41
55
  }
42
56
  // Auto-detect stdio mode: if stdin is not a TTY, we're likely in stdio mode
43
57
  if (!transportType && !process.stdin.isTTY) {
44
- transportType = "stdio";
58
+ transportType = 'stdio';
45
59
  }
46
60
  // Default to streamable-http if not specified
47
61
  if (!transportType) {
48
- transportType = "streamable-http";
62
+ transportType = 'streamable-http';
49
63
  }
50
64
  // Parse SSE config
51
- if (transportType === "sse") {
52
- const port = parseInt(getArgValue("--sse-port") || process.env.MCP_SSE_PORT || "3002", 10);
53
- const host = getArgValue("--sse-host") || process.env.MCP_SSE_HOST || "0.0.0.0";
65
+ if (transportType === 'sse') {
66
+ const port = parseInt(getArgValue('--sse-port') || process.env.MCP_SSE_PORT || '3002', 10);
67
+ const host = getArgValue('--sse-host') || process.env.MCP_SSE_HOST || '0.0.0.0';
54
68
  return {
55
- type: "sse",
69
+ type: 'sse',
56
70
  host,
57
71
  port,
58
- allowedOrigins: parseListOption("--sse-allowed-origins", "MCP_SSE_ALLOWED_ORIGINS"),
59
- allowedHosts: parseListOption("--sse-allowed-hosts", "MCP_SSE_ALLOWED_HOSTS"),
60
- enableDnsRebindingProtection: parseBooleanOption("--sse-enable-dns-protection", "MCP_SSE_ENABLE_DNS_PROTECTION", false),
72
+ allowedOrigins: parseListOption('--sse-allowed-origins', 'MCP_SSE_ALLOWED_ORIGINS'),
73
+ allowedHosts: parseListOption('--sse-allowed-hosts', 'MCP_SSE_ALLOWED_HOSTS'),
74
+ enableDnsRebindingProtection: parseBooleanOption('--sse-enable-dns-protection', 'MCP_SSE_ENABLE_DNS_PROTECTION', false),
61
75
  };
62
76
  }
63
77
  // Parse HTTP/streamable-http config
64
- if (transportType === "streamable-http") {
65
- const port = parseInt(getArgValue("--http-port") || process.env.MCP_HTTP_PORT || "3001", 10);
66
- const host = getArgValue("--http-host") || process.env.MCP_HTTP_HOST || "0.0.0.0";
78
+ if (transportType === 'streamable-http') {
79
+ const port = parseInt(getArgValue('--http-port') || process.env.MCP_HTTP_PORT || '3001', 10);
80
+ const host = getArgValue('--http-host') || process.env.MCP_HTTP_HOST || '0.0.0.0';
67
81
  return {
68
- type: "streamable-http",
82
+ type: 'streamable-http',
69
83
  host,
70
84
  port,
71
- enableJsonResponse: parseBooleanOption("--http-json-response", "MCP_HTTP_ENABLE_JSON_RESPONSE", false),
72
- allowedOrigins: parseListOption("--http-allowed-origins", "MCP_HTTP_ALLOWED_ORIGINS"),
73
- allowedHosts: parseListOption("--http-allowed-hosts", "MCP_HTTP_ALLOWED_HOSTS"),
74
- enableDnsRebindingProtection: parseBooleanOption("--http-enable-dns-protection", "MCP_HTTP_ENABLE_DNS_PROTECTION", false),
85
+ enableJsonResponse: parseBooleanOption('--http-json-response', 'MCP_HTTP_ENABLE_JSON_RESPONSE', false),
86
+ allowedOrigins: parseListOption('--http-allowed-origins', 'MCP_HTTP_ALLOWED_ORIGINS'),
87
+ allowedHosts: parseListOption('--http-allowed-hosts', 'MCP_HTTP_ALLOWED_HOSTS'),
88
+ enableDnsRebindingProtection: parseBooleanOption('--http-enable-dns-protection', 'MCP_HTTP_ENABLE_DNS_PROTECTION', false),
75
89
  };
76
90
  }
77
91
  // Stdio config (no additional options)
78
92
  return {
79
- type: "stdio",
93
+ type: 'stdio',
80
94
  };
81
95
  }
82
96
  /**
@@ -89,7 +103,7 @@ function getArgValue(argName) {
89
103
  return args[i + 1];
90
104
  }
91
105
  if (args[i].startsWith(`${argName}=`)) {
92
- return args[i].split("=")[1];
106
+ return args[i].split('=')[1];
93
107
  }
94
108
  }
95
109
  return undefined;
@@ -100,11 +114,11 @@ function getArgValue(argName) {
100
114
  function parseBooleanOption(argName, envName, defaultValue) {
101
115
  const argValue = getArgValue(argName);
102
116
  if (argValue !== undefined) {
103
- return argValue.toLowerCase() === "true" || argValue === "1";
117
+ return argValue.toLowerCase() === 'true' || argValue === '1';
104
118
  }
105
119
  const envValue = process.env[envName];
106
120
  if (envValue !== undefined) {
107
- return envValue.toLowerCase() === "true" || envValue === "1";
121
+ return envValue.toLowerCase() === 'true' || envValue === '1';
108
122
  }
109
123
  return defaultValue;
110
124
  }
@@ -114,11 +128,17 @@ function parseBooleanOption(argName, envName, defaultValue) {
114
128
  function parseListOption(argName, envName) {
115
129
  const argValue = getArgValue(argName);
116
130
  if (argValue) {
117
- return argValue.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
131
+ return argValue
132
+ .split(',')
133
+ .map((s) => s.trim())
134
+ .filter((s) => s.length > 0);
118
135
  }
119
136
  const envValue = process.env[envName];
120
137
  if (envValue) {
121
- return envValue.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
138
+ return envValue
139
+ .split(',')
140
+ .map((s) => s.trim())
141
+ .filter((s) => s.length > 0);
122
142
  }
123
143
  return undefined;
124
144
  }
@@ -0,0 +1,102 @@
1
+ /**
2
+ * BTP Proxy - Proxies requests to MCP servers with JWT authentication
3
+ *
4
+ * For requests with x-btp-destination, proxies to target MCP server
5
+ * with JWT token from auth-broker (XSUAA/BTP)
6
+ */
7
+ import { AuthBroker } from '@mcp-abap-adt/auth-broker';
8
+ import { type ProxyConfig } from '../lib/config.js';
9
+ import type { RoutingDecision } from '../router/headerAnalyzer.js';
10
+ /**
11
+ * Check if error messages should be written to stderr
12
+ * Only output in verbose mode and not in test environment
13
+ */
14
+ export declare function shouldWriteStderr(): boolean;
15
+ export interface GenericProxyRequest {
16
+ method: string;
17
+ url?: string;
18
+ data?: unknown;
19
+ id?: string | number | null;
20
+ [key: string]: unknown;
21
+ }
22
+ export type ProxyRequest = GenericProxyRequest;
23
+ export interface ProxyResponse {
24
+ jsonrpc: string;
25
+ id?: string | number | null;
26
+ result?: unknown;
27
+ error?: {
28
+ code: number;
29
+ message: string;
30
+ data?: unknown;
31
+ };
32
+ }
33
+ /**
34
+ * BTP Proxy Client
35
+ */
36
+ export declare class BtpProxy {
37
+ private axiosInstance;
38
+ private defaultBtpAuthBroker;
39
+ private btpAuthBrokers;
40
+ private tokenCache;
41
+ private readonly TOKEN_CACHE_TTL;
42
+ private circuitBreaker;
43
+ private config;
44
+ private unsafe;
45
+ constructor(defaultBtpAuthBroker: AuthBroker, config?: Partial<ProxyConfig>);
46
+ /**
47
+ * Initialize authentication for destination (eager auth)
48
+ * This triggers the browser authentication flow immediately if needed.
49
+ */
50
+ initialize(destination: string): Promise<void>;
51
+ /**
52
+ * Get or create BTP auth broker for specific destination
53
+ * If destination is not provided, returns default broker
54
+ * If broker doesn't exist in map, creates new one and stores it
55
+ */
56
+ private getOrCreateBtpAuthBroker;
57
+ /**
58
+ * Helper to ensure valid serviceUrl in session if override provided
59
+ */
60
+ private ensureSessionServiceUrl;
61
+ /**
62
+ * Get JWT token for BTP destination from auth-broker with retry and token refresh
63
+ * @param destination Destination name
64
+ * @param forceRefresh Force token refresh
65
+ */
66
+ private getJwtToken;
67
+ /**
68
+ * Helper function to extract string value from header (handles arrays)
69
+ */
70
+ private getHeaderValue;
71
+ /**
72
+ * Build proxy request with JWT token (BTP authentication only)
73
+ *
74
+ * Process flow:
75
+ *
76
+ * 1. BTP Authentication (XSUAA):
77
+ * 1.1 If x-btp-destination header exists:
78
+ * - Check map for broker with key = destination, get or create, save to map
79
+ * - Get token from xsuaa broker
80
+ * - Add/replace Authorization: Bearer <token> header
81
+ * 1.2 If header doesn't exist but --btp parameter exists:
82
+ * - Use destination from parameter, get or create broker, save to map
83
+ * - Get token from xsuaa broker
84
+ * - Add/replace Authorization: Bearer <token> header
85
+ * 1.3 If neither header nor parameter:
86
+ * - Do nothing, pass request further
87
+ */
88
+ private buildProxyRequest;
89
+ /**
90
+ * Proxy MCP request to target server with retry, circuit breaker, and error handling
91
+ */
92
+ proxyRequest(originalRequest: ProxyRequest, routingDecision: RoutingDecision, originalHeaders: Record<string, string | string[] | undefined>): Promise<ProxyResponse>;
93
+ /**
94
+ * Create a new BtpProxy instance
95
+ */
96
+ static create(config?: Partial<ProxyConfig>): Promise<BtpProxy>;
97
+ }
98
+ /**
99
+ * Factory function to create BtpProxy
100
+ */
101
+ export declare function createBtpProxy(config?: Partial<ProxyConfig>): Promise<BtpProxy>;
102
+ //# sourceMappingURL=btpProxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"btpProxy.d.ts","sourceRoot":"","sources":["../../src/proxy/btpProxy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU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