@mcp-abap-adt/auth-broker 0.1.5 → 0.1.7
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 +244 -0
- package/README.md +181 -16
- package/bin/generate-env-from-service-key.ts +128 -0
- package/dist/AuthBroker.d.ts +47 -31
- package/dist/AuthBroker.d.ts.map +1 -1
- package/dist/AuthBroker.js +182 -134
- package/dist/__tests__/helpers/configHelpers.d.ts +49 -0
- package/dist/__tests__/helpers/configHelpers.d.ts.map +1 -0
- package/dist/__tests__/helpers/configHelpers.js +169 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -8
- package/dist/providers/ITokenProvider.d.ts +49 -0
- package/dist/providers/ITokenProvider.d.ts.map +1 -0
- package/dist/providers/ITokenProvider.js +10 -0
- package/dist/providers/index.d.ts +8 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +8 -0
- package/dist/stores/index.d.ts +5 -5
- package/dist/stores/index.d.ts.map +1 -1
- package/dist/stores/index.js +4 -8
- package/dist/stores/interfaces.d.ts +88 -22
- package/dist/stores/interfaces.d.ts.map +1 -1
- package/dist/stores/interfaces.js +1 -2
- package/dist/types.d.ts +7 -31
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -0
- package/package.json +13 -6
- package/dist/__tests__/testHelpers.d.ts +0 -44
- package/dist/__tests__/testHelpers.d.ts.map +0 -1
- package/dist/__tests__/testHelpers.js +0 -136
- package/dist/browserAuth.d.ts +0 -17
- package/dist/browserAuth.d.ts.map +0 -1
- package/dist/browserAuth.js +0 -305
- package/dist/cache.d.ts +0 -20
- package/dist/cache.d.ts.map +0 -1
- package/dist/cache.js +0 -46
- package/dist/envLoader.d.ts +0 -12
- package/dist/envLoader.d.ts.map +0 -1
- package/dist/envLoader.js +0 -90
- package/dist/getToken.d.ts +0 -14
- package/dist/getToken.d.ts.map +0 -1
- package/dist/getToken.js +0 -62
- package/dist/logger.d.ts +0 -40
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -186
- package/dist/pathResolver.d.ts +0 -21
- package/dist/pathResolver.d.ts.map +0 -1
- package/dist/pathResolver.js +0 -105
- package/dist/refreshToken.d.ts +0 -14
- package/dist/refreshToken.d.ts.map +0 -1
- package/dist/refreshToken.js +0 -71
- package/dist/serviceKeyLoader.d.ts +0 -12
- package/dist/serviceKeyLoader.d.ts.map +0 -1
- package/dist/serviceKeyLoader.js +0 -72
- package/dist/stores/FileServiceKeyStore.d.ts +0 -38
- package/dist/stores/FileServiceKeyStore.d.ts.map +0 -1
- package/dist/stores/FileServiceKeyStore.js +0 -47
- package/dist/stores/FileSessionStore.d.ts +0 -50
- package/dist/stores/FileSessionStore.d.ts.map +0 -1
- package/dist/stores/FileSessionStore.js +0 -116
- package/dist/stores/SafeSessionStore.d.ts +0 -35
- package/dist/stores/SafeSessionStore.d.ts.map +0 -1
- package/dist/stores/SafeSessionStore.js +0 -42
- package/dist/tokenRefresher.d.ts +0 -17
- package/dist/tokenRefresher.d.ts.map +0 -1
- package/dist/tokenRefresher.js +0 -53
- package/dist/tokenStorage.d.ts +0 -15
- package/dist/tokenStorage.d.ts.map +0 -1
- package/dist/tokenStorage.js +0 -107
- package/dist/tokenValidator.d.ts +0 -11
- package/dist/tokenValidator.d.ts.map +0 -1
- package/dist/tokenValidator.js +0 -108
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration helpers for auth-broker tests
|
|
4
|
+
* Loads test configuration from test-config.yaml
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.loadTestConfig = loadTestConfig;
|
|
41
|
+
exports.hasRealConfig = hasRealConfig;
|
|
42
|
+
exports.getAbapDestination = getAbapDestination;
|
|
43
|
+
exports.getXsuaaDestinations = getXsuaaDestinations;
|
|
44
|
+
exports.getServiceKeysDir = getServiceKeysDir;
|
|
45
|
+
exports.getSessionsDir = getSessionsDir;
|
|
46
|
+
const fs = __importStar(require("fs"));
|
|
47
|
+
const path = __importStar(require("path"));
|
|
48
|
+
const yaml = __importStar(require("js-yaml"));
|
|
49
|
+
let cachedConfig = null;
|
|
50
|
+
/**
|
|
51
|
+
* Find project root directory by looking for package.json
|
|
52
|
+
*/
|
|
53
|
+
function findProjectRoot() {
|
|
54
|
+
let currentDir = __dirname;
|
|
55
|
+
while (currentDir !== path.dirname(currentDir)) {
|
|
56
|
+
const packageJsonPath = path.join(currentDir, 'package.json');
|
|
57
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
58
|
+
return currentDir;
|
|
59
|
+
}
|
|
60
|
+
currentDir = path.dirname(currentDir);
|
|
61
|
+
}
|
|
62
|
+
// Fallback to process.cwd() if package.json not found
|
|
63
|
+
return process.cwd();
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Load test configuration from YAML
|
|
67
|
+
* Uses test-config.yaml from tests/ directory
|
|
68
|
+
*/
|
|
69
|
+
function loadTestConfig() {
|
|
70
|
+
if (cachedConfig) {
|
|
71
|
+
return cachedConfig;
|
|
72
|
+
}
|
|
73
|
+
// Find project root and load from tests/test-config.yaml
|
|
74
|
+
const projectRoot = findProjectRoot();
|
|
75
|
+
const configPath = path.resolve(projectRoot, 'tests', 'test-config.yaml');
|
|
76
|
+
const templatePath = path.resolve(projectRoot, 'tests', 'test-config.yaml.template');
|
|
77
|
+
if (process.env.TEST_VERBOSE) {
|
|
78
|
+
console.log(`[configHelpers] Project root: ${projectRoot}`);
|
|
79
|
+
console.log(`[configHelpers] Config path: ${configPath}`);
|
|
80
|
+
console.log(`[configHelpers] Config exists: ${fs.existsSync(configPath)}`);
|
|
81
|
+
}
|
|
82
|
+
if (fs.existsSync(configPath)) {
|
|
83
|
+
try {
|
|
84
|
+
const configContent = fs.readFileSync(configPath, 'utf8');
|
|
85
|
+
cachedConfig = yaml.load(configContent) || {};
|
|
86
|
+
if (process.env.TEST_VERBOSE) {
|
|
87
|
+
console.log(`[configHelpers] Loaded config:`, JSON.stringify(cachedConfig, null, 2));
|
|
88
|
+
}
|
|
89
|
+
return cachedConfig;
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
console.warn(`Failed to load test config from ${configPath}:`, error);
|
|
93
|
+
return {};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (fs.existsSync(templatePath)) {
|
|
97
|
+
console.warn('⚠️ tests/test-config.yaml not found. Using template (all integration tests will be disabled).');
|
|
98
|
+
try {
|
|
99
|
+
const templateContent = fs.readFileSync(templatePath, 'utf8');
|
|
100
|
+
cachedConfig = yaml.load(templateContent) || {};
|
|
101
|
+
return cachedConfig;
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
console.warn(`Failed to load test config template from ${templatePath}:`, error);
|
|
105
|
+
return {};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
console.warn('⚠️ Test configuration files not found.');
|
|
109
|
+
console.warn('Please create tests/test-config.yaml with test parameters.');
|
|
110
|
+
return {};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Check if test config has real values (not placeholders)
|
|
114
|
+
*/
|
|
115
|
+
function hasRealConfig(config, section) {
|
|
116
|
+
if (!config.auth_broker) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
if (section === 'abap') {
|
|
120
|
+
const abap = config.auth_broker.abap;
|
|
121
|
+
if (!abap?.destination) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
// Check if destination is not a placeholder
|
|
125
|
+
return !abap.destination.includes('<') && !abap.destination.includes('>');
|
|
126
|
+
}
|
|
127
|
+
if (section === 'xsuaa') {
|
|
128
|
+
const xsuaa = config.auth_broker.xsuaa;
|
|
129
|
+
if (!xsuaa?.btp_destination || !xsuaa?.mcp_url) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
// Check if values are not placeholders
|
|
133
|
+
return (!xsuaa.btp_destination.includes('<') &&
|
|
134
|
+
!xsuaa.mcp_url.includes('<'));
|
|
135
|
+
}
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Get ABAP destination from config
|
|
140
|
+
*/
|
|
141
|
+
function getAbapDestination(config) {
|
|
142
|
+
const cfg = config || loadTestConfig();
|
|
143
|
+
return cfg.auth_broker?.abap?.destination || null;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Get XSUAA destinations from config
|
|
147
|
+
*/
|
|
148
|
+
function getXsuaaDestinations(config) {
|
|
149
|
+
const cfg = config || loadTestConfig();
|
|
150
|
+
const xsuaa = cfg.auth_broker?.xsuaa;
|
|
151
|
+
return {
|
|
152
|
+
btp_destination: xsuaa?.btp_destination || null,
|
|
153
|
+
mcp_url: xsuaa?.mcp_url || null,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Get service keys directory from config
|
|
158
|
+
*/
|
|
159
|
+
function getServiceKeysDir(config) {
|
|
160
|
+
const cfg = config || loadTestConfig();
|
|
161
|
+
return cfg.auth_broker?.paths?.service_keys_dir || null;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Get sessions directory from config
|
|
165
|
+
*/
|
|
166
|
+
function getSessionsDir(config) {
|
|
167
|
+
const cfg = config || loadTestConfig();
|
|
168
|
+
return cfg.auth_broker?.paths?.sessions_dir || null;
|
|
169
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* JWT authentication broker for MCP ABAP ADT server
|
|
4
4
|
*/
|
|
5
5
|
export { AuthBroker } from './AuthBroker';
|
|
6
|
-
export type {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
6
|
+
export type { IAuthorizationConfig, IConnectionConfig, IServiceKeyStore, ISessionStore } from './stores/interfaces';
|
|
7
|
+
export type { IConfig } from './types';
|
|
8
|
+
export type { ITokenProvider, TokenProviderOptions, TokenProviderResult } from './providers';
|
|
9
|
+
export type { Logger } from '@mcp-abap-adt/logger';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
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,MAAM,cAAc,CAAC;AAG1C,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,MAAM,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,13 +4,10 @@
|
|
|
4
4
|
* JWT authentication broker for MCP ABAP ADT server
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.AuthBroker = void 0;
|
|
8
8
|
var AuthBroker_1 = require("./AuthBroker");
|
|
9
9
|
Object.defineProperty(exports, "AuthBroker", { enumerable: true, get: function () { return AuthBroker_1.AuthBroker; } });
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Object.defineProperty(exports, "FileServiceKeyStore", { enumerable: true, get: function () { return stores_1.FileServiceKeyStore; } });
|
|
15
|
-
Object.defineProperty(exports, "FileSessionStore", { enumerable: true, get: function () { return stores_1.FileSessionStore; } });
|
|
16
|
-
Object.defineProperty(exports, "SafeSessionStore", { enumerable: true, get: function () { return stores_1.SafeSessionStore; } });
|
|
10
|
+
// Store and provider implementations are in separate packages:
|
|
11
|
+
// - @mcp-abap-adt/auth-stores-btp - BTP and ABAP stores
|
|
12
|
+
// - @mcp-abap-adt/auth-stores-xsuaa - XSUAA stores
|
|
13
|
+
// - @mcp-abap-adt/auth-providers - XSUAA and BTP token providers
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token Provider interface
|
|
3
|
+
*
|
|
4
|
+
* Converts IAuthorizationConfig to IConnectionConfig by obtaining tokens.
|
|
5
|
+
* Different implementations handle different authentication flows:
|
|
6
|
+
* - XSUAA: client_credentials grant type (no browser)
|
|
7
|
+
* - BTP/ABAP: browser-based OAuth2 or refresh token
|
|
8
|
+
*/
|
|
9
|
+
import { IAuthorizationConfig, IConnectionConfig } from '../stores/interfaces';
|
|
10
|
+
/**
|
|
11
|
+
* Result from token provider
|
|
12
|
+
*/
|
|
13
|
+
export interface TokenProviderResult {
|
|
14
|
+
/** Connection configuration with authorization token */
|
|
15
|
+
connectionConfig: IConnectionConfig;
|
|
16
|
+
/** Refresh token (optional, for BTP/ABAP) */
|
|
17
|
+
refreshToken?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Interface for token providers
|
|
21
|
+
*
|
|
22
|
+
* Takes authorization configuration and returns connection configuration with token.
|
|
23
|
+
*/
|
|
24
|
+
export interface ITokenProvider {
|
|
25
|
+
/**
|
|
26
|
+
* Get connection configuration with token from authorization configuration
|
|
27
|
+
* @param authConfig Authorization configuration (UAA credentials, optional refresh token)
|
|
28
|
+
* @param options Optional provider-specific options (e.g., browser type for BTP)
|
|
29
|
+
* @returns Promise that resolves to connection configuration with authorization token and optional refresh token
|
|
30
|
+
*/
|
|
31
|
+
getConnectionConfig(authConfig: IAuthorizationConfig, options?: TokenProviderOptions): Promise<TokenProviderResult>;
|
|
32
|
+
/**
|
|
33
|
+
* Validate JWT token by testing connection to service
|
|
34
|
+
* @param token JWT token to validate
|
|
35
|
+
* @param serviceUrl Service URL (optional, for services that require URL validation)
|
|
36
|
+
* @returns Promise that resolves to true if token is valid, false otherwise
|
|
37
|
+
*/
|
|
38
|
+
validateToken?(token: string, serviceUrl?: string): Promise<boolean>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Options for token providers
|
|
42
|
+
*/
|
|
43
|
+
export interface TokenProviderOptions {
|
|
44
|
+
/** Browser type for browser-based authentication (chrome, edge, firefox, system, none) */
|
|
45
|
+
browser?: string;
|
|
46
|
+
/** Logger instance for logging */
|
|
47
|
+
logger?: import('@mcp-abap-adt/logger').Logger;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=ITokenProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ITokenProvider.d.ts","sourceRoot":"","sources":["../../src/providers/ITokenProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE/E;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,wDAAwD;IACxD,gBAAgB,EAAE,iBAAiB,CAAC;IACpC,6CAA6C;IAC7C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,mBAAmB,CACjB,UAAU,EAAE,oBAAoB,EAChC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAEhC;;;;;OAKG;IACH,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACtE;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,0FAA0F;IAC1F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,MAAM,CAAC,EAAE,OAAO,sBAAsB,EAAE,MAAM,CAAC;CAChD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Token Provider interface
|
|
4
|
+
*
|
|
5
|
+
* Converts IAuthorizationConfig to IConnectionConfig by obtaining tokens.
|
|
6
|
+
* Different implementations handle different authentication flows:
|
|
7
|
+
* - XSUAA: client_credentials grant type (no browser)
|
|
8
|
+
* - BTP/ABAP: browser-based OAuth2 or refresh token
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token provider interface
|
|
3
|
+
*
|
|
4
|
+
* Provider implementations are in separate packages:
|
|
5
|
+
* - @mcp-abap-adt/auth-providers - XSUAA and BTP providers
|
|
6
|
+
*/
|
|
7
|
+
export type { ITokenProvider, TokenProviderOptions, TokenProviderResult } from './ITokenProvider';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/stores/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Storage
|
|
2
|
+
* Storage interfaces for AuthBroker
|
|
3
|
+
*
|
|
4
|
+
* Store implementations are in separate packages:
|
|
5
|
+
* - @mcp-abap-adt/auth-stores-btp - BTP and ABAP stores
|
|
3
6
|
*/
|
|
4
|
-
export { IServiceKeyStore, ISessionStore,
|
|
5
|
-
export { FileServiceKeyStore } from './FileServiceKeyStore';
|
|
6
|
-
export { FileSessionStore } from './FileSessionStore';
|
|
7
|
-
export { SafeSessionStore } from './SafeSessionStore';
|
|
7
|
+
export type { IServiceKeyStore, ISessionStore, IAuthorizationConfig, IConnectionConfig } from './interfaces';
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stores/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stores/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/stores/index.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Storage
|
|
3
|
+
* Storage interfaces for AuthBroker
|
|
4
|
+
*
|
|
5
|
+
* Store implementations are in separate packages:
|
|
6
|
+
* - @mcp-abap-adt/auth-stores-btp - BTP and ABAP stores
|
|
4
7
|
*/
|
|
5
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SafeSessionStore = exports.FileSessionStore = exports.FileServiceKeyStore = void 0;
|
|
7
|
-
var FileServiceKeyStore_1 = require("./FileServiceKeyStore");
|
|
8
|
-
Object.defineProperty(exports, "FileServiceKeyStore", { enumerable: true, get: function () { return FileServiceKeyStore_1.FileServiceKeyStore; } });
|
|
9
|
-
var FileSessionStore_1 = require("./FileSessionStore");
|
|
10
|
-
Object.defineProperty(exports, "FileSessionStore", { enumerable: true, get: function () { return FileSessionStore_1.FileSessionStore; } });
|
|
11
|
-
var SafeSessionStore_1 = require("./SafeSessionStore");
|
|
12
|
-
Object.defineProperty(exports, "SafeSessionStore", { enumerable: true, get: function () { return SafeSessionStore_1.SafeSessionStore; } });
|
|
@@ -1,51 +1,117 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Storage interfaces for AuthBroker
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* for service keys and session data (tokens, configuration).
|
|
4
|
+
* All interfaces are defined here. Types (type aliases) are in types.ts.
|
|
6
5
|
*/
|
|
7
|
-
import {
|
|
6
|
+
import type { IConfig } from '../types';
|
|
7
|
+
/**
|
|
8
|
+
* Authorization configuration - values needed for obtaining and refreshing tokens
|
|
9
|
+
* Returned by stores with actual values (not file paths)
|
|
10
|
+
*/
|
|
11
|
+
export interface IAuthorizationConfig {
|
|
12
|
+
/** UAA URL for token refresh */
|
|
13
|
+
uaaUrl: string;
|
|
14
|
+
/** UAA client ID */
|
|
15
|
+
uaaClientId: string;
|
|
16
|
+
/** UAA client secret */
|
|
17
|
+
uaaClientSecret: string;
|
|
18
|
+
/** Refresh token for token renewal (optional) */
|
|
19
|
+
refreshToken?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Connection configuration - values needed for connecting to services
|
|
23
|
+
* Returned by stores with actual values (not file paths)
|
|
24
|
+
*/
|
|
25
|
+
export interface IConnectionConfig {
|
|
26
|
+
/** Service URL (SAP/ABAP/MCP URL) - undefined for XSUAA if not provided */
|
|
27
|
+
serviceUrl?: string;
|
|
28
|
+
/** Authorization token (JWT token) */
|
|
29
|
+
authorizationToken: string;
|
|
30
|
+
/** SAP client number (optional, for ABAP/BTP) */
|
|
31
|
+
sapClient?: string;
|
|
32
|
+
/** Language (optional, for ABAP/BTP) */
|
|
33
|
+
language?: string;
|
|
34
|
+
}
|
|
8
35
|
/**
|
|
9
36
|
* Interface for storing and retrieving service keys
|
|
10
37
|
*
|
|
11
|
-
* Service keys contain UAA credentials and
|
|
12
|
-
* Default implementation: FileServiceKeyStore (reads from {destination}.json files)
|
|
38
|
+
* Service keys contain UAA credentials and connection URLs.
|
|
13
39
|
*/
|
|
14
40
|
export interface IServiceKeyStore {
|
|
15
41
|
/**
|
|
16
|
-
* Get service key for destination
|
|
42
|
+
* Get raw service key for destination
|
|
43
|
+
* @param destination Destination name (e.g., "TRIAL")
|
|
44
|
+
* @returns Service key object (implementation-specific) or null if not found
|
|
45
|
+
*/
|
|
46
|
+
getServiceKey(destination: string): Promise<IConfig | null>;
|
|
47
|
+
/**
|
|
48
|
+
* Get authorization configuration from service key
|
|
49
|
+
* Returns values needed for obtaining and refreshing tokens
|
|
50
|
+
* @param destination Destination name (e.g., "TRIAL")
|
|
51
|
+
* @returns IAuthorizationConfig with actual values or null if not found
|
|
52
|
+
*/
|
|
53
|
+
getAuthorizationConfig(destination: string): Promise<IAuthorizationConfig | null>;
|
|
54
|
+
/**
|
|
55
|
+
* Get connection configuration from service key
|
|
56
|
+
* Returns values needed for connecting to services
|
|
17
57
|
* @param destination Destination name (e.g., "TRIAL")
|
|
18
|
-
* @returns
|
|
58
|
+
* @returns IConnectionConfig with actual values or null if not found
|
|
19
59
|
*/
|
|
20
|
-
|
|
60
|
+
getConnectionConfig(destination: string): Promise<IConnectionConfig | null>;
|
|
21
61
|
}
|
|
22
62
|
/**
|
|
23
|
-
* Interface for
|
|
63
|
+
* Interface for session stores - stores and retrieves session data
|
|
24
64
|
*
|
|
25
|
-
* Session
|
|
26
|
-
* Default implementation: FileSessionStore (reads/writes {destination}.env files)
|
|
65
|
+
* Session stores handle loading, saving, and managing session data (tokens, configuration).
|
|
27
66
|
*/
|
|
28
67
|
export interface ISessionStore {
|
|
29
68
|
/**
|
|
30
69
|
* Load session configuration for destination
|
|
31
|
-
*
|
|
32
|
-
*
|
|
70
|
+
* Returns optional composition of IAuthorizationConfig and IConnectionConfig
|
|
71
|
+
* Can contain either authorization config, or connection config, or both
|
|
72
|
+
* @param destination Destination name (e.g., "TRIAL" or "mcp")
|
|
73
|
+
* @returns IConfig with actual values or null if not found
|
|
33
74
|
*/
|
|
34
|
-
loadSession(destination: string): Promise<
|
|
75
|
+
loadSession(destination: string): Promise<IConfig | null>;
|
|
35
76
|
/**
|
|
36
77
|
* Save session configuration for destination
|
|
37
|
-
*
|
|
38
|
-
* @param
|
|
78
|
+
* Accepts IConfig (optional composition) or internal representation (for backward compatibility)
|
|
79
|
+
* @param destination Destination name (e.g., "TRIAL" or "mcp")
|
|
80
|
+
* @param config IConfig or internal session configuration to save
|
|
39
81
|
*/
|
|
40
|
-
saveSession(destination: string, config:
|
|
82
|
+
saveSession(destination: string, config: IConfig | unknown): Promise<void>;
|
|
41
83
|
/**
|
|
42
84
|
* Delete session for destination (optional)
|
|
43
|
-
* @param destination Destination name (e.g., "TRIAL")
|
|
85
|
+
* @param destination Destination name (e.g., "TRIAL" or "mcp")
|
|
44
86
|
*/
|
|
45
87
|
deleteSession?(destination: string): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Get authorization configuration with actual values (not file paths)
|
|
90
|
+
* Returns values needed for obtaining and refreshing tokens
|
|
91
|
+
* @param destination Destination name (e.g., "TRIAL" or "mcp")
|
|
92
|
+
* @returns IAuthorizationConfig with actual values or null if not found
|
|
93
|
+
*/
|
|
94
|
+
getAuthorizationConfig(destination: string): Promise<IAuthorizationConfig | null>;
|
|
95
|
+
/**
|
|
96
|
+
* Get connection configuration with actual values (not file paths)
|
|
97
|
+
* Returns values needed for connecting to services
|
|
98
|
+
* @param destination Destination name (e.g., "TRIAL" or "mcp")
|
|
99
|
+
* @returns IConnectionConfig with actual values or null if not found
|
|
100
|
+
*/
|
|
101
|
+
getConnectionConfig(destination: string): Promise<IConnectionConfig | null>;
|
|
102
|
+
/**
|
|
103
|
+
* Set authorization configuration
|
|
104
|
+
* Updates values needed for obtaining and refreshing tokens
|
|
105
|
+
* @param destination Destination name (e.g., "TRIAL" or "mcp")
|
|
106
|
+
* @param config IAuthorizationConfig with values to set
|
|
107
|
+
*/
|
|
108
|
+
setAuthorizationConfig(destination: string, config: IAuthorizationConfig): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Set connection configuration
|
|
111
|
+
* Updates values needed for connecting to services
|
|
112
|
+
* @param destination Destination name (e.g., "TRIAL" or "mcp")
|
|
113
|
+
* @param config IConnectionConfig with values to set
|
|
114
|
+
*/
|
|
115
|
+
setConnectionConfig(destination: string, config: IConnectionConfig): Promise<void>;
|
|
46
116
|
}
|
|
47
|
-
/** @deprecated Use IServiceKeyStore instead */
|
|
48
|
-
export type ServiceKeyStore = IServiceKeyStore;
|
|
49
|
-
/** @deprecated Use ISessionStore instead */
|
|
50
|
-
export type SessionStore = ISessionStore;
|
|
51
117
|
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/stores/interfaces.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/stores/interfaces.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,wBAAwB;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,iDAAiD;IACjD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAE5D;;;;;OAKG;IACH,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAElF;;;;;OAKG;IACH,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;CAC7E;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;OAMG;IACH,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAE1D;;;;;OAKG;IACH,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3E;;;OAGG;IACH,aAAa,CAAC,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnD;;;;;OAKG;IACH,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAElF;;;;;OAKG;IACH,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IAE5E;;;;;OAKG;IACH,sBAAsB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzF;;;;;OAKG;IACH,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpF"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Storage interfaces for AuthBroker
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* for service keys and session data (tokens, configuration).
|
|
5
|
+
* All interfaces are defined here. Types (type aliases) are in types.ts.
|
|
7
6
|
*/
|
|
8
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/types.d.ts
CHANGED
|
@@ -1,37 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type definitions for auth-broker package
|
|
3
|
+
*
|
|
4
|
+
* Type aliases (type) are defined here. Interfaces are in stores/interfaces.ts.
|
|
3
5
|
*/
|
|
6
|
+
import type { IAuthorizationConfig, IConnectionConfig } from './stores/interfaces';
|
|
4
7
|
/**
|
|
5
|
-
*
|
|
8
|
+
* Configuration - optional composition of authorization and connection configuration
|
|
9
|
+
* Can contain either authorization config, or connection config, or both
|
|
6
10
|
*/
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
sapClient?: string;
|
|
10
|
-
jwtToken: string;
|
|
11
|
-
refreshToken?: string;
|
|
12
|
-
uaaUrl?: string;
|
|
13
|
-
uaaClientId?: string;
|
|
14
|
-
uaaClientSecret?: string;
|
|
15
|
-
language?: string;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Service key structure from JSON file
|
|
19
|
-
*/
|
|
20
|
-
export interface ServiceKey {
|
|
21
|
-
url?: string;
|
|
22
|
-
abap?: {
|
|
23
|
-
url?: string;
|
|
24
|
-
client?: string;
|
|
25
|
-
language?: string;
|
|
26
|
-
};
|
|
27
|
-
sap_url?: string;
|
|
28
|
-
client?: string;
|
|
29
|
-
sap_client?: string;
|
|
30
|
-
language?: string;
|
|
31
|
-
uaa: {
|
|
32
|
-
url: string;
|
|
33
|
-
clientid: string;
|
|
34
|
-
clientsecret: string;
|
|
35
|
-
};
|
|
36
|
-
}
|
|
11
|
+
export type IConfig = Partial<IAuthorizationConfig> & Partial<IConnectionConfig>;
|
|
12
|
+
export type { IAuthorizationConfig, IConnectionConfig, IServiceKeyStore, ISessionStore, } from './stores/interfaces';
|
|
37
13
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEnF;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAGjF,YAAY,EACV,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,GACd,MAAM,qBAAqB,CAAC"}
|
package/dist/types.js
CHANGED
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.1.7",
|
|
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",
|
|
@@ -41,24 +41,31 @@
|
|
|
41
41
|
"build:fast": "npx tsc -p tsconfig.json",
|
|
42
42
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
|
|
43
43
|
"test:check": "npx tsc --noEmit",
|
|
44
|
-
"prepublishOnly": "npm run build"
|
|
44
|
+
"prepublishOnly": "npm run build",
|
|
45
|
+
"generate-env": "tsx bin/generate-env-from-service-key.ts"
|
|
46
|
+
},
|
|
47
|
+
"bin": {
|
|
48
|
+
"generate-env-from-service-key": "./bin/generate-env-from-service-key.ts"
|
|
45
49
|
},
|
|
46
50
|
"engines": {
|
|
47
51
|
"node": ">=18.0.0"
|
|
48
52
|
},
|
|
49
53
|
"dependencies": {
|
|
50
54
|
"@mcp-abap-adt/connection": "^0.1.13",
|
|
51
|
-
"
|
|
52
|
-
"dotenv": "^17.2.1",
|
|
53
|
-
"express": "^5.1.0",
|
|
54
|
-
"open": "^11.0.0"
|
|
55
|
+
"@mcp-abap-adt/logger": "^0.1.0"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
58
|
+
"@mcp-abap-adt/auth-providers": "^0.1.0",
|
|
59
|
+
"@mcp-abap-adt/auth-stores-btp": "^0.1.0",
|
|
60
|
+
"@mcp-abap-adt/auth-stores-xsuaa": "^0.1.0",
|
|
57
61
|
"@types/express": "^5.0.5",
|
|
58
62
|
"@types/jest": "^30.0.0",
|
|
63
|
+
"@types/js-yaml": "^4.0.9",
|
|
59
64
|
"@types/node": "^24.2.1",
|
|
60
65
|
"jest": "^30.2.0",
|
|
66
|
+
"js-yaml": "^4.1.1",
|
|
61
67
|
"ts-jest": "^29.2.5",
|
|
68
|
+
"tsx": "^4.21.0",
|
|
62
69
|
"typescript": "^5.9.2"
|
|
63
70
|
}
|
|
64
71
|
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Common test helpers for AuthBroker tests
|
|
3
|
-
*/
|
|
4
|
-
import { AuthBroker } from '../AuthBroker';
|
|
5
|
-
export declare const TEST_DESTINATIONS_PATH: string;
|
|
6
|
-
export interface TestBrokers {
|
|
7
|
-
tempDir: string;
|
|
8
|
-
broker: AuthBroker;
|
|
9
|
-
testDestinationsBroker: AuthBroker;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Setup test brokers for a test suite
|
|
13
|
-
*/
|
|
14
|
-
export declare function setupTestBrokers(testName: string): TestBrokers;
|
|
15
|
-
/**
|
|
16
|
-
* Cleanup test brokers
|
|
17
|
-
*/
|
|
18
|
-
export declare function cleanupTestBrokers(brokers: TestBrokers): void;
|
|
19
|
-
/**
|
|
20
|
-
* Check if NO_EXISTS.json exists and skip test if it does
|
|
21
|
-
*/
|
|
22
|
-
export declare function checkNoExistsFile(): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Prepare Test 2: Remove TRIAL.env if exists, check for TRIAL.json
|
|
25
|
-
*/
|
|
26
|
-
export declare function prepareTest2(): {
|
|
27
|
-
envFile: string;
|
|
28
|
-
serviceKeyPath: string;
|
|
29
|
-
shouldSkip: boolean;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Prepare Test 3: Check for TRIAL.json and TRIAL.env
|
|
33
|
-
*/
|
|
34
|
-
export declare function prepareTest3(): {
|
|
35
|
-
envFile: string;
|
|
36
|
-
serviceKeyPath: string;
|
|
37
|
-
sapUrl: string;
|
|
38
|
-
shouldSkip: boolean;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Verify .env file contains required tokens
|
|
42
|
-
*/
|
|
43
|
-
export declare function verifyEnvFile(envFile: string, requireRefreshToken?: boolean): void;
|
|
44
|
-
//# sourceMappingURL=testHelpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testHelpers.d.ts","sourceRoot":"","sources":["../../src/__tests__/testHelpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,eAAO,MAAM,sBAAsB,QAAsF,CAAC;AAE1H,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,CAAC;IACnB,sBAAsB,EAAE,UAAU,CAAC;CACpC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CAY9D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAM7D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAM3C;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAe/F;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAsB/G;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,mBAAmB,GAAE,OAAe,GAAG,IAAI,CAOzF"}
|