@mcp-abap-adt/auth-stores 0.2.10 → 0.3.0
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.
|
@@ -5,11 +5,13 @@ import type { IAuthorizationConfig, IConfig, IConnectionConfig, ILogger, IServic
|
|
|
5
5
|
/**
|
|
6
6
|
* XSUAA Service key store implementation
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* Reads XSUAA service keys from JSON files. Supports:
|
|
9
|
+
* - Flat format: { clientid, clientsecret, url }
|
|
10
|
+
* - With credentials wrapper: { credentials: { clientid, clientsecret, url } }
|
|
11
|
+
* - Nested uaa format: { uaa: { clientid, clientsecret, url } }
|
|
9
12
|
*/
|
|
10
13
|
export declare class XsuaaServiceKeyStore implements IServiceKeyStore {
|
|
11
14
|
private directory;
|
|
12
|
-
private parser;
|
|
13
15
|
private log?;
|
|
14
16
|
/**
|
|
15
17
|
* Create a new XsuaaServiceKeyStore instance
|
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.XsuaaServiceKeyStore = void 0;
|
|
7
|
-
const StoreErrors_1 = require("../../errors/StoreErrors");
|
|
8
|
-
const XsuaaServiceKeyParser_1 = require("../../parsers/xsuaa/XsuaaServiceKeyParser");
|
|
9
7
|
const JsonFileHandler_1 = require("../../utils/JsonFileHandler");
|
|
10
8
|
/**
|
|
11
9
|
* XSUAA Service key store implementation
|
|
12
10
|
*
|
|
13
|
-
*
|
|
11
|
+
* Reads XSUAA service keys from JSON files. Supports:
|
|
12
|
+
* - Flat format: { clientid, clientsecret, url }
|
|
13
|
+
* - With credentials wrapper: { credentials: { clientid, clientsecret, url } }
|
|
14
|
+
* - Nested uaa format: { uaa: { clientid, clientsecret, url } }
|
|
14
15
|
*/
|
|
15
16
|
class XsuaaServiceKeyStore {
|
|
16
17
|
directory;
|
|
17
|
-
parser;
|
|
18
18
|
log;
|
|
19
19
|
/**
|
|
20
20
|
* Create a new XsuaaServiceKeyStore instance
|
|
@@ -23,7 +23,6 @@ class XsuaaServiceKeyStore {
|
|
|
23
23
|
*/
|
|
24
24
|
constructor(directory, log) {
|
|
25
25
|
this.directory = directory;
|
|
26
|
-
this.parser = new XsuaaServiceKeyParser_1.XsuaaServiceKeyParser(log);
|
|
27
26
|
this.log = log;
|
|
28
27
|
}
|
|
29
28
|
/**
|
|
@@ -54,31 +53,33 @@ class XsuaaServiceKeyStore {
|
|
|
54
53
|
this.log?.debug(`Service key file not found: ${destination}.json`);
|
|
55
54
|
return null;
|
|
56
55
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
!key.uaa.clientid ||
|
|
67
|
-
!key.uaa.clientsecret) {
|
|
68
|
-
this.log?.warn(`Service key for ${destination} missing required UAA fields`);
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
this.log?.info(`Authorization config loaded for ${destination}: uaaUrl(${key.uaa.url.substring(0, 30)}...)`);
|
|
72
|
-
return {
|
|
73
|
-
uaaUrl: key.uaa.url,
|
|
74
|
-
uaaClientId: key.uaa.clientid,
|
|
75
|
-
uaaClientSecret: key.uaa.clientsecret,
|
|
76
|
-
};
|
|
56
|
+
if (!rawData || typeof rawData !== 'object') {
|
|
57
|
+
this.log?.warn(`Failed to parse service key for ${destination}: invalid format`);
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
let data = rawData;
|
|
61
|
+
// Unwrap credentials wrapper if present
|
|
62
|
+
// Format: { credentials: { clientid, clientsecret, url, ... } }
|
|
63
|
+
if (data.credentials && typeof data.credentials === 'object') {
|
|
64
|
+
data = data.credentials;
|
|
77
65
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
66
|
+
// Support both flat XSUAA format and nested uaa format
|
|
67
|
+
// Flat: { clientid, clientsecret, url }
|
|
68
|
+
// Nested: { uaa: { clientid, clientsecret, url } }
|
|
69
|
+
const uaa = data.uaa || data;
|
|
70
|
+
const uaaUrl = uaa.url;
|
|
71
|
+
const uaaClientId = uaa.clientid;
|
|
72
|
+
const uaaClientSecret = uaa.clientsecret;
|
|
73
|
+
if (!uaaUrl || !uaaClientId || !uaaClientSecret) {
|
|
74
|
+
this.log?.warn(`Service key for ${destination} missing required fields (url, clientid, clientsecret)`);
|
|
75
|
+
return null;
|
|
81
76
|
}
|
|
77
|
+
this.log?.info(`Authorization config loaded for ${destination}: uaaUrl(${uaaUrl.substring(0, 30)}...)`);
|
|
78
|
+
return {
|
|
79
|
+
uaaUrl,
|
|
80
|
+
uaaClientId,
|
|
81
|
+
uaaClientSecret,
|
|
82
|
+
};
|
|
82
83
|
}
|
|
83
84
|
/**
|
|
84
85
|
* Get connection configuration from service key
|
|
@@ -92,29 +93,29 @@ class XsuaaServiceKeyStore {
|
|
|
92
93
|
this.log?.debug(`Service key file not found: ${destination}.json`);
|
|
93
94
|
return null;
|
|
94
95
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
this.log?.warn(`Failed to parse service key for ${destination}: invalid format`);
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
const key = parsed;
|
|
102
|
-
// Service key doesn't have tokens - only URLs and client info
|
|
103
|
-
const serviceUrl = key.abap?.url ||
|
|
104
|
-
key.sap_url ||
|
|
105
|
-
(key.url && !key.url.includes('authentication') ? key.url : undefined);
|
|
106
|
-
this.log?.info(`Connection config loaded for ${destination}: serviceUrl(${serviceUrl ? `${serviceUrl.substring(0, 40)}...` : 'none'}), client(${key.abap?.client || key.sap_client || key.client || 'none'})`);
|
|
107
|
-
return {
|
|
108
|
-
serviceUrl,
|
|
109
|
-
authorizationToken: '', // Service key doesn't contain tokens
|
|
110
|
-
sapClient: key.abap?.client || key.sap_client || key.client,
|
|
111
|
-
language: key.abap?.language || key.language,
|
|
112
|
-
};
|
|
96
|
+
if (!rawData || typeof rawData !== 'object') {
|
|
97
|
+
this.log?.warn(`Failed to parse service key for ${destination}: invalid format`);
|
|
98
|
+
return null;
|
|
113
99
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
100
|
+
let data = rawData;
|
|
101
|
+
// Unwrap credentials wrapper if present
|
|
102
|
+
if (data.credentials && typeof data.credentials === 'object') {
|
|
103
|
+
data = data.credentials;
|
|
117
104
|
}
|
|
105
|
+
const abap = data.abap;
|
|
106
|
+
// Service key doesn't have tokens - only URLs and client info
|
|
107
|
+
// serviceUrl is optional for XSUAA (only needed for ABAP)
|
|
108
|
+
const url = data.url;
|
|
109
|
+
const serviceUrl = abap?.url ||
|
|
110
|
+
data.sap_url ||
|
|
111
|
+
(url && !url.includes('authentication') ? url : undefined);
|
|
112
|
+
this.log?.info(`Connection config loaded for ${destination}: serviceUrl(${serviceUrl ? `${serviceUrl.substring(0, 40)}...` : 'none'}), client(${abap?.client || data.sap_client || data.client || 'none'})`);
|
|
113
|
+
return {
|
|
114
|
+
serviceUrl,
|
|
115
|
+
authorizationToken: '', // Service key doesn't contain tokens
|
|
116
|
+
sapClient: (abap?.client || data.sap_client || data.client),
|
|
117
|
+
language: (abap?.language || data.language),
|
|
118
|
+
};
|
|
118
119
|
}
|
|
119
120
|
}
|
|
120
121
|
exports.XsuaaServiceKeyStore = XsuaaServiceKeyStore;
|