@mcp-abap-adt/auth-broker 0.1.11 → 0.2.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/CHANGELOG.md +158 -0
- package/README.md +189 -52
- package/dist/AuthBroker.d.ts +57 -35
- package/dist/AuthBroker.d.ts.map +1 -1
- package/dist/AuthBroker.js +502 -142
- package/dist/__tests__/helpers/configHelpers.d.ts.map +1 -1
- package/dist/__tests__/helpers/configHelpers.js +24 -2
- package/dist/__tests__/helpers/testLogger.d.ts +6 -0
- package/dist/__tests__/helpers/testLogger.d.ts.map +1 -0
- package/dist/__tests__/helpers/testLogger.js +81 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +6 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configHelpers.d.ts","sourceRoot":"","sources":["../../../src/__tests__/helpers/configHelpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,MAAM,WAAW,UAAU;IACzB,WAAW,CAAC,EAAE;QACZ,KAAK,CAAC,EAAE;YACN,gBAAgB,CAAC,EAAE,MAAM,CAAC;YAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;SACvB,CAAC;QACF,IAAI,CAAC,EAAE;YACL,WAAW,CAAC,EAAE,MAAM,CAAC;SACtB,CAAC;QACF,KAAK,CAAC,EAAE;YACN,eAAe,CAAC,EAAE,MAAM,CAAC;YACzB,eAAe,CAAC,EAAE,MAAM,CAAC;YACzB,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC;KACH,CAAC;CACH;AAkBD;;;GAGG;AACH,wBAAgB,cAAc,IAAI,UAAU,CA6C3C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CA2BpF;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAGrE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG;IACzD,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,CAOA;
|
|
1
|
+
{"version":3,"file":"configHelpers.d.ts","sourceRoot":"","sources":["../../../src/__tests__/helpers/configHelpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,MAAM,WAAW,UAAU;IACzB,WAAW,CAAC,EAAE;QACZ,KAAK,CAAC,EAAE;YACN,gBAAgB,CAAC,EAAE,MAAM,CAAC;YAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;SACvB,CAAC;QACF,IAAI,CAAC,EAAE;YACL,WAAW,CAAC,EAAE,MAAM,CAAC;SACtB,CAAC;QACF,KAAK,CAAC,EAAE;YACN,eAAe,CAAC,EAAE,MAAM,CAAC;YACzB,eAAe,CAAC,EAAE,MAAM,CAAC;YACzB,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC;KACH,CAAC;CACH;AAkBD;;;GAGG;AACH,wBAAgB,cAAc,IAAI,UAAU,CA6C3C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CA2BpF;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAGrE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG;IACzD,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,CAOA;AAaD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CASpE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CASjE"}
|
|
@@ -153,17 +153,39 @@ function getXsuaaDestinations(config) {
|
|
|
153
153
|
mcp_url: xsuaa?.mcp_url || null,
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Expand tilde (~) to home directory
|
|
158
|
+
*/
|
|
159
|
+
function expandTilde(filePath) {
|
|
160
|
+
if (filePath.startsWith('~')) {
|
|
161
|
+
const os = require('os');
|
|
162
|
+
return path.join(os.homedir(), filePath.slice(1));
|
|
163
|
+
}
|
|
164
|
+
return filePath;
|
|
165
|
+
}
|
|
156
166
|
/**
|
|
157
167
|
* Get service keys directory from config
|
|
158
168
|
*/
|
|
159
169
|
function getServiceKeysDir(config) {
|
|
160
170
|
const cfg = config || loadTestConfig();
|
|
161
|
-
|
|
171
|
+
const dir = cfg.auth_broker?.paths?.service_keys_dir;
|
|
172
|
+
if (!dir) {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
// Expand ~ and normalize path
|
|
176
|
+
const expanded = expandTilde(dir);
|
|
177
|
+
return path.resolve(expanded);
|
|
162
178
|
}
|
|
163
179
|
/**
|
|
164
180
|
* Get sessions directory from config
|
|
165
181
|
*/
|
|
166
182
|
function getSessionsDir(config) {
|
|
167
183
|
const cfg = config || loadTestConfig();
|
|
168
|
-
|
|
184
|
+
const dir = cfg.auth_broker?.paths?.sessions_dir;
|
|
185
|
+
if (!dir) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
// Expand ~ and normalize path
|
|
189
|
+
const expanded = expandTilde(dir);
|
|
190
|
+
return path.resolve(expanded);
|
|
169
191
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testLogger.d.ts","sourceRoot":"","sources":["../../../src/__tests__/helpers/testLogger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAgBxD,wBAAgB,gBAAgB,CAAC,MAAM,GAAE,MAAe,GAAG,OAAO,CAgEjE"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Test logger with environment variable control
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createTestLogger = createTestLogger;
|
|
7
|
+
function getLogLevel() {
|
|
8
|
+
const level = process.env.LOG_LEVEL?.toLowerCase() || 'info';
|
|
9
|
+
const levels = ['debug', 'info', 'warn', 'error'];
|
|
10
|
+
return levels.includes(level) ? level : 'info';
|
|
11
|
+
}
|
|
12
|
+
function shouldLog(level) {
|
|
13
|
+
const currentLevel = getLogLevel();
|
|
14
|
+
const levels = ['debug', 'info', 'warn', 'error'];
|
|
15
|
+
return levels.indexOf(level) >= levels.indexOf(currentLevel);
|
|
16
|
+
}
|
|
17
|
+
function createTestLogger(prefix = 'TEST') {
|
|
18
|
+
// Check if logging is enabled - requires explicit enable
|
|
19
|
+
const isEnabled = () => {
|
|
20
|
+
// Explicitly disabled
|
|
21
|
+
if (process.env.DEBUG_AUTH_BROKER === 'false') {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
// Explicitly enabled
|
|
25
|
+
if (process.env.DEBUG_AUTH_BROKER === 'true' ||
|
|
26
|
+
process.env.DEBUG === 'true' ||
|
|
27
|
+
process.env.DEBUG?.includes('auth-broker') === true) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
// Do not enable by default - require explicit enable
|
|
31
|
+
return false;
|
|
32
|
+
};
|
|
33
|
+
// Format message and meta into single line
|
|
34
|
+
const formatMessage = (message, meta) => {
|
|
35
|
+
if (!meta || meta === '') {
|
|
36
|
+
return message;
|
|
37
|
+
}
|
|
38
|
+
// If meta is an object, format it concisely
|
|
39
|
+
if (typeof meta === 'object' && !Array.isArray(meta)) {
|
|
40
|
+
const parts = [];
|
|
41
|
+
for (const [key, value] of Object.entries(meta)) {
|
|
42
|
+
if (value !== undefined && value !== null) {
|
|
43
|
+
if (typeof value === 'string' && value.length > 50) {
|
|
44
|
+
parts.push(`${key}(${value.substring(0, 50)}...)`);
|
|
45
|
+
}
|
|
46
|
+
else if (typeof value === 'boolean') {
|
|
47
|
+
parts.push(`${key}(${value})`);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
parts.push(`${key}(${value})`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return parts.length > 0 ? `${message} ${parts.join(', ')}` : message;
|
|
55
|
+
}
|
|
56
|
+
// If meta is a string or other type, append it
|
|
57
|
+
return `${message} ${String(meta)}`;
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
debug: (message, meta) => {
|
|
61
|
+
if (isEnabled() && shouldLog('debug')) {
|
|
62
|
+
console.debug(`[${prefix}] [DEBUG] ${formatMessage(message, meta)}`);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
info: (message, meta) => {
|
|
66
|
+
if (isEnabled() && shouldLog('info')) {
|
|
67
|
+
console.info(`[${prefix}] ${formatMessage(message, meta)}`);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
warn: (message, meta) => {
|
|
71
|
+
if (isEnabled() && shouldLog('warn')) {
|
|
72
|
+
console.warn(`[${prefix}] [WARN] ${formatMessage(message, meta)}`);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
error: (message, meta) => {
|
|
76
|
+
if (isEnabled() && shouldLog('error')) {
|
|
77
|
+
console.error(`[${prefix}] [ERROR] ${formatMessage(message, meta)}`);
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @mcp-abap-adt/auth-broker
|
|
3
3
|
* JWT authentication broker for MCP ABAP ADT server
|
|
4
4
|
*/
|
|
5
|
-
export { AuthBroker } from './AuthBroker';
|
|
5
|
+
export { AuthBroker, type AuthBrokerConfig } from './AuthBroker';
|
|
6
6
|
export type { IAuthorizationConfig, IConnectionConfig, IServiceKeyStore, ISessionStore } from './stores/interfaces';
|
|
7
7
|
export type { IConfig } from './types';
|
|
8
8
|
export type { ITokenProvider, TokenProviderOptions, TokenProviderResult } from './providers';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGjE,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpH,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE7F,YAAY,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAExD,YAAY,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-abap-adt/auth-broker",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "JWT authentication broker for MCP ABAP ADT - manages tokens based on destination headers",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"build": "npm run clean --silent && npx tsc -p tsconfig.json",
|
|
41
41
|
"build:fast": "npx tsc -p tsconfig.json",
|
|
42
42
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
|
|
43
|
-
"test:check": "npx tsc --noEmit",
|
|
43
|
+
"test:check": "npx tsc --noEmit && npx tsc --noEmit -p tsconfig.test.json",
|
|
44
44
|
"prepublishOnly": "npm run build",
|
|
45
45
|
"generate-env": "tsx bin/generate-env-from-service-key.ts"
|
|
46
46
|
},
|
|
@@ -51,11 +51,12 @@
|
|
|
51
51
|
"node": ">=18.0.0"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@mcp-abap-adt/interfaces": "^0.1.
|
|
54
|
+
"@mcp-abap-adt/interfaces": "^0.1.15",
|
|
55
|
+
"axios": "^1.13.2"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
|
-
"@mcp-abap-adt/auth-providers": "^0.1.
|
|
58
|
-
"@mcp-abap-adt/auth-stores": "^0.1
|
|
58
|
+
"@mcp-abap-adt/auth-providers": "^0.1.4",
|
|
59
|
+
"@mcp-abap-adt/auth-stores": "^0.2.1",
|
|
59
60
|
"@types/express": "^5.0.5",
|
|
60
61
|
"@types/jest": "^30.0.0",
|
|
61
62
|
"@types/js-yaml": "^4.0.9",
|