@mcp-abap-adt/auth-stores 0.1.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/LICENSE +22 -0
  3. package/README.md +209 -0
  4. package/dist/index.d.ts +22 -0
  5. package/dist/index.js +53 -0
  6. package/dist/loaders/abap/serviceKeyLoader.d.ts +15 -0
  7. package/dist/loaders/abap/serviceKeyLoader.js +84 -0
  8. package/dist/loaders/xsuaa/xsuaaServiceKeyLoader.d.ts +19 -0
  9. package/dist/loaders/xsuaa/xsuaaServiceKeyLoader.js +80 -0
  10. package/dist/parsers/abap/AbapServiceKeyParser.d.ts +35 -0
  11. package/dist/parsers/abap/AbapServiceKeyParser.js +50 -0
  12. package/dist/parsers/xsuaa/XsuaaServiceKeyParser.d.ts +30 -0
  13. package/dist/parsers/xsuaa/XsuaaServiceKeyParser.js +72 -0
  14. package/dist/storage/abap/envLoader.d.ts +21 -0
  15. package/dist/storage/abap/envLoader.js +94 -0
  16. package/dist/storage/abap/tokenStorage.d.ts +24 -0
  17. package/dist/storage/abap/tokenStorage.js +113 -0
  18. package/dist/storage/xsuaa/xsuaaEnvLoader.d.ts +20 -0
  19. package/dist/storage/xsuaa/xsuaaEnvLoader.js +91 -0
  20. package/dist/storage/xsuaa/xsuaaTokenStorage.d.ts +19 -0
  21. package/dist/storage/xsuaa/xsuaaTokenStorage.js +115 -0
  22. package/dist/stores/abap/AbapServiceKeyStore.d.ts +34 -0
  23. package/dist/stores/abap/AbapServiceKeyStore.js +43 -0
  24. package/dist/stores/abap/AbapSessionStore.d.ts +80 -0
  25. package/dist/stores/abap/AbapSessionStore.js +239 -0
  26. package/dist/stores/abap/SafeAbapSessionStore.d.ts +35 -0
  27. package/dist/stores/abap/SafeAbapSessionStore.js +117 -0
  28. package/dist/stores/abstract/AbstractJsonSessionStore.d.ts +67 -0
  29. package/dist/stores/abstract/AbstractJsonSessionStore.js +99 -0
  30. package/dist/stores/abstract/AbstractSafeSessionStore.d.ts +89 -0
  31. package/dist/stores/abstract/AbstractSafeSessionStore.js +76 -0
  32. package/dist/stores/abstract/AbstractServiceKeyStore.d.ts +66 -0
  33. package/dist/stores/abstract/AbstractServiceKeyStore.js +165 -0
  34. package/dist/stores/btp/BtpServiceKeyStore.d.ts +34 -0
  35. package/dist/stores/btp/BtpServiceKeyStore.js +43 -0
  36. package/dist/stores/btp/BtpSessionStore.d.ts +79 -0
  37. package/dist/stores/btp/BtpSessionStore.js +247 -0
  38. package/dist/stores/btp/SafeBtpSessionStore.d.ts +32 -0
  39. package/dist/stores/btp/SafeBtpSessionStore.js +115 -0
  40. package/dist/stores/xsuaa/SafeXsuaaSessionStore.d.ts +34 -0
  41. package/dist/stores/xsuaa/SafeXsuaaSessionStore.js +117 -0
  42. package/dist/stores/xsuaa/XsuaaServiceKeyStore.d.ts +36 -0
  43. package/dist/stores/xsuaa/XsuaaServiceKeyStore.js +49 -0
  44. package/dist/stores/xsuaa/XsuaaSessionStore.d.ts +54 -0
  45. package/dist/stores/xsuaa/XsuaaSessionStore.js +223 -0
  46. package/dist/utils/constants.d.ts +83 -0
  47. package/dist/utils/constants.js +86 -0
  48. package/dist/utils/pathResolver.d.ts +20 -0
  49. package/dist/utils/pathResolver.js +105 -0
  50. package/package.json +63 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,45 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2024-12-04
9
+
10
+ ### Added
11
+ - Initial release of unified stores package
12
+ - **BTP Stores**:
13
+ - `BtpServiceKeyStore` - Reads XSUAA service keys for base BTP connections
14
+ - `BtpSessionStore` - File-based store for base BTP sessions (uses `XSUAA_*` env vars)
15
+ - `SafeBtpSessionStore` - In-memory store for base BTP sessions
16
+ - **ABAP Stores**:
17
+ - `AbapServiceKeyStore` - Reads ABAP service keys with nested `uaa` object
18
+ - `AbapSessionStore` - File-based store for ABAP sessions (uses `SAP_*` env vars)
19
+ - `SafeAbapSessionStore` - In-memory store for ABAP sessions
20
+ - **XSUAA Stores**:
21
+ - `XsuaaServiceKeyStore` - Reads XSUAA service keys (direct format)
22
+ - `XsuaaSessionStore` - File-based store for XSUAA sessions (uses `XSUAA_*` env vars)
23
+ - `SafeXsuaaSessionStore` - In-memory store for XSUAA sessions
24
+ - **Abstract Base Classes**:
25
+ - `AbstractServiceKeyStore` - Base class for service key stores with file I/O
26
+ - `AbstractJsonSessionStore` - Base class for file-based session stores
27
+ - `AbstractSafeSessionStore` - Base class for in-memory session stores
28
+ - **Utilities**:
29
+ - `pathResolver` - Resolve search paths and find files in multiple directories
30
+ - `constants` - Environment variable name constants for ABAP, BTP, and XSUAA
31
+ - Service key loaders for ABAP and XSUAA formats
32
+ - **Testing**:
33
+ - Unit tests for parsers (AbapServiceKeyParser, XsuaaServiceKeyParser)
34
+ - Unit tests for service key stores with mocked file system
35
+ - Jest configuration with TypeScript support
36
+
37
+ ### Changed
38
+ - Merged `@mcp-abap-adt/auth-stores-btp` and `@mcp-abap-adt/auth-stores-xsuaa` into single unified package
39
+ - Eliminated code duplication in abstract classes and utility functions
40
+ - Unified constants for all store types (ABAP, BTP, XSUAA)
41
+ - Consistent API across all store implementations
42
+
43
+ ### Dependencies
44
+ - `@mcp-abap-adt/auth-broker` ^0.1.6 - Interface definitions (`IServiceKeyStore`, `ISessionStore`, `IAuthorizationConfig`, `IConnectionConfig`, `IConfig`)
45
+ - `dotenv` ^17.2.1 - Environment variable parsing for `.env` files
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Oleksii Kyslytsia
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md ADDED
@@ -0,0 +1,209 @@
1
+ # @mcp-abap-adt/auth-stores
2
+
3
+ Stores for MCP ABAP ADT auth-broker - BTP, ABAP, and XSUAA implementations.
4
+
5
+ This package provides file-based and in-memory stores for service keys and sessions used by the `@mcp-abap-adt/auth-broker` package.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @mcp-abap-adt/auth-stores
11
+ ```
12
+
13
+ ## Overview
14
+
15
+ This package implements the `IServiceKeyStore` and `ISessionStore` interfaces from `@mcp-abap-adt/auth-broker`:
16
+
17
+ - **Service Key Stores**: Read service key JSON files from configured search paths
18
+ - **Session Stores**: Read/write session data from/to `.env` files or in-memory storage
19
+ - **Abstract Classes**: Base classes for creating custom store implementations
20
+
21
+ ## Store Types
22
+
23
+ ### Service Key Stores
24
+
25
+ Service key stores read JSON files containing UAA credentials and connection information:
26
+
27
+ - **`BtpServiceKeyStore`** - Reads XSUAA service keys for base BTP (direct XSUAA format)
28
+ - **`AbapServiceKeyStore`** - Reads ABAP service keys (with nested `uaa` object)
29
+ - **`XsuaaServiceKeyStore`** - Reads XSUAA service keys (alias for BtpServiceKeyStore)
30
+
31
+ ### Session Stores
32
+
33
+ Session stores manage authentication tokens and configuration:
34
+
35
+ **File-based stores** (persist to `.env` files):
36
+ - **`BtpSessionStore`** - Stores base BTP sessions using `XSUAA_*` environment variables
37
+ - **`AbapSessionStore`** - Stores ABAP sessions using `SAP_*` environment variables
38
+ - **`XsuaaSessionStore`** - Stores XSUAA sessions using `XSUAA_*` environment variables
39
+
40
+ **In-memory stores** (non-persistent, secure):
41
+ - **`SafeBtpSessionStore`** - In-memory store for base BTP sessions
42
+ - **`SafeAbapSessionStore`** - In-memory store for ABAP sessions
43
+ - **`SafeXsuaaSessionStore`** - In-memory store for XSUAA sessions
44
+
45
+ ## Usage
46
+
47
+ ### BTP Stores (base BTP without sapUrl)
48
+
49
+ ```typescript
50
+ import { BtpServiceKeyStore, BtpSessionStore, SafeBtpSessionStore } from '@mcp-abap-adt/auth-stores';
51
+
52
+ // Service key store - reads {destination}.json files
53
+ const serviceKeyStore = new BtpServiceKeyStore(['/path/to/service-keys']);
54
+
55
+ // File-based session store - reads/writes {destination}.env files
56
+ const sessionStore = new BtpSessionStore(['/path/to/sessions']);
57
+
58
+ // In-memory session store (non-persistent)
59
+ const safeSessionStore = new SafeBtpSessionStore();
60
+ ```
61
+
62
+ ### ABAP Stores (with sapUrl)
63
+
64
+ ```typescript
65
+ import { AbapServiceKeyStore, AbapSessionStore, SafeAbapSessionStore } from '@mcp-abap-adt/auth-stores';
66
+
67
+ // Service key store - reads ABAP service keys with nested uaa object
68
+ const serviceKeyStore = new AbapServiceKeyStore(['/path/to/service-keys']);
69
+
70
+ // File-based session store - stores ABAP sessions with SAP_* env vars
71
+ const sessionStore = new AbapSessionStore(['/path/to/sessions']);
72
+
73
+ // In-memory session store
74
+ const safeSessionStore = new SafeAbapSessionStore();
75
+ ```
76
+
77
+ ### XSUAA Stores
78
+
79
+ ```typescript
80
+ import { XsuaaServiceKeyStore, XsuaaSessionStore, SafeXsuaaSessionStore } from '@mcp-abap-adt/auth-stores';
81
+
82
+ // Service key store - reads XSUAA service keys
83
+ const serviceKeyStore = new XsuaaServiceKeyStore(['/path/to/service-keys']);
84
+
85
+ // File-based session store - stores XSUAA sessions
86
+ const sessionStore = new XsuaaSessionStore(['/path/to/sessions']);
87
+
88
+ // In-memory session store
89
+ const safeSessionStore = new SafeXsuaaSessionStore();
90
+ ```
91
+
92
+ ### Search Paths
93
+
94
+ Search paths are resolved in priority order:
95
+
96
+ 1. **Constructor parameter** (highest priority)
97
+ 2. **`AUTH_BROKER_PATH` environment variable** (colon/semicolon-separated paths)
98
+ 3. **Current working directory** (lowest priority, only if no other paths specified)
99
+
100
+ ```typescript
101
+ // Single path
102
+ const store = new BtpServiceKeyStore('/path/to/keys');
103
+
104
+ // Multiple paths
105
+ const store = new BtpServiceKeyStore(['/path1', '/path2', '/path3']);
106
+
107
+ // Use environment variable
108
+ process.env.AUTH_BROKER_PATH = '/path1:/path2:/path3';
109
+ const store = new BtpServiceKeyStore(); // Uses AUTH_BROKER_PATH
110
+ ```
111
+
112
+ ### Service Key Format
113
+
114
+ **ABAP Service Key** (with nested `uaa` object):
115
+ ```json
116
+ {
117
+ "uaa": {
118
+ "url": "https://...authentication...hana.ondemand.com",
119
+ "clientid": "...",
120
+ "clientsecret": "..."
121
+ },
122
+ "abap": {
123
+ "url": "https://...abap...hana.ondemand.com",
124
+ "client": "001"
125
+ }
126
+ }
127
+ ```
128
+
129
+ **XSUAA Service Key** (direct format):
130
+ ```json
131
+ {
132
+ "url": "https://...authentication...hana.ondemand.com",
133
+ "clientid": "...",
134
+ "clientsecret": "...",
135
+ "apiurl": "https://...api...hana.ondemand.com"
136
+ }
137
+ ```
138
+
139
+ ### Abstract Classes
140
+
141
+ For creating custom store implementations:
142
+
143
+ - **`AbstractServiceKeyStore`** - Base class for service key stores
144
+ - Handles file I/O operations
145
+ - Subclasses implement format-specific parsing logic
146
+
147
+ - **`AbstractJsonSessionStore`** - Base class for file-based session stores
148
+ - Handles `.env` file read/write operations
149
+ - Subclasses implement format-specific serialization
150
+
151
+ - **`AbstractSafeSessionStore`** - Base class for in-memory session stores
152
+ - Provides secure, non-persistent storage
153
+ - Subclasses implement format-specific data structures
154
+
155
+ ## Utilities
156
+
157
+ ### Path Resolver
158
+
159
+ ```typescript
160
+ import { resolveSearchPaths, findFileInPaths } from '@mcp-abap-adt/auth-stores';
161
+
162
+ // Resolve search paths from constructor, env var, or cwd
163
+ const paths = resolveSearchPaths(['/custom/path']);
164
+
165
+ // Find file in multiple search paths
166
+ const filePath = findFileInPaths('TRIAL.json', paths);
167
+ ```
168
+
169
+ ### Constants
170
+
171
+ ```typescript
172
+ import {
173
+ ABAP_AUTHORIZATION_VARS,
174
+ ABAP_CONNECTION_VARS,
175
+ BTP_AUTHORIZATION_VARS,
176
+ BTP_CONNECTION_VARS,
177
+ XSUAA_AUTHORIZATION_VARS,
178
+ XSUAA_CONNECTION_VARS
179
+ } from '@mcp-abap-adt/auth-stores';
180
+ ```
181
+
182
+ ### Service Key Loaders
183
+
184
+ ```typescript
185
+ import { loadServiceKey, loadXSUAAServiceKey } from '@mcp-abap-adt/auth-stores';
186
+
187
+ // Load ABAP service key
188
+ const abapKey = await loadServiceKey('TRIAL', ['/path/to/keys']);
189
+
190
+ // Load XSUAA service key
191
+ const xsuaaKey = await loadXSUAAServiceKey('mcp', ['/path/to/keys']);
192
+ ```
193
+
194
+ ## Testing
195
+
196
+ Tests use Jest and include unit tests with mocked file system operations.
197
+
198
+ ```bash
199
+ npm test
200
+ ```
201
+
202
+ ## Dependencies
203
+
204
+ - `@mcp-abap-adt/auth-broker` (^0.1.6) - Interface definitions
205
+ - `dotenv` - Environment variable parsing
206
+
207
+ ## License
208
+
209
+ MIT
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @mcp-abap-adt/auth-stores
3
+ * Stores for MCP ABAP ADT auth-broker
4
+ *
5
+ * Provides BTP, ABAP, and XSUAA store implementations
6
+ */
7
+ export { BtpSessionStore } from './stores/btp/BtpSessionStore';
8
+ export { SafeBtpSessionStore } from './stores/btp/SafeBtpSessionStore';
9
+ export { BtpServiceKeyStore } from './stores/btp/BtpServiceKeyStore';
10
+ export { AbapSessionStore } from './stores/abap/AbapSessionStore';
11
+ export { SafeAbapSessionStore } from './stores/abap/SafeAbapSessionStore';
12
+ export { AbapServiceKeyStore } from './stores/abap/AbapServiceKeyStore';
13
+ export { XsuaaSessionStore } from './stores/xsuaa/XsuaaSessionStore';
14
+ export { SafeXsuaaSessionStore } from './stores/xsuaa/SafeXsuaaSessionStore';
15
+ export { XsuaaServiceKeyStore } from './stores/xsuaa/XsuaaServiceKeyStore';
16
+ export { AbstractServiceKeyStore } from './stores/abstract/AbstractServiceKeyStore';
17
+ export { AbstractJsonSessionStore } from './stores/abstract/AbstractJsonSessionStore';
18
+ export { AbstractSafeSessionStore } from './stores/abstract/AbstractSafeSessionStore';
19
+ export { resolveSearchPaths, findFileInPaths } from './utils/pathResolver';
20
+ export { ABAP_AUTHORIZATION_VARS, ABAP_CONNECTION_VARS, BTP_AUTHORIZATION_VARS, BTP_CONNECTION_VARS, XSUAA_AUTHORIZATION_VARS, XSUAA_CONNECTION_VARS } from './utils/constants';
21
+ export { loadServiceKey } from './loaders/abap/serviceKeyLoader';
22
+ export { loadXSUAAServiceKey } from './loaders/xsuaa/xsuaaServiceKeyLoader';
package/dist/index.js ADDED
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ /**
3
+ * @mcp-abap-adt/auth-stores
4
+ * Stores for MCP ABAP ADT auth-broker
5
+ *
6
+ * Provides BTP, ABAP, and XSUAA store implementations
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.loadXSUAAServiceKey = exports.loadServiceKey = exports.XSUAA_CONNECTION_VARS = exports.XSUAA_AUTHORIZATION_VARS = exports.BTP_CONNECTION_VARS = exports.BTP_AUTHORIZATION_VARS = exports.ABAP_CONNECTION_VARS = exports.ABAP_AUTHORIZATION_VARS = exports.findFileInPaths = exports.resolveSearchPaths = exports.AbstractSafeSessionStore = exports.AbstractJsonSessionStore = exports.AbstractServiceKeyStore = exports.XsuaaServiceKeyStore = exports.SafeXsuaaSessionStore = exports.XsuaaSessionStore = exports.AbapServiceKeyStore = exports.SafeAbapSessionStore = exports.AbapSessionStore = exports.BtpServiceKeyStore = exports.SafeBtpSessionStore = exports.BtpSessionStore = void 0;
10
+ // BTP stores (base BTP without sapUrl)
11
+ var BtpSessionStore_1 = require("./stores/btp/BtpSessionStore");
12
+ Object.defineProperty(exports, "BtpSessionStore", { enumerable: true, get: function () { return BtpSessionStore_1.BtpSessionStore; } });
13
+ var SafeBtpSessionStore_1 = require("./stores/btp/SafeBtpSessionStore");
14
+ Object.defineProperty(exports, "SafeBtpSessionStore", { enumerable: true, get: function () { return SafeBtpSessionStore_1.SafeBtpSessionStore; } });
15
+ var BtpServiceKeyStore_1 = require("./stores/btp/BtpServiceKeyStore");
16
+ Object.defineProperty(exports, "BtpServiceKeyStore", { enumerable: true, get: function () { return BtpServiceKeyStore_1.BtpServiceKeyStore; } });
17
+ // ABAP stores (with sapUrl, extends base BTP)
18
+ var AbapSessionStore_1 = require("./stores/abap/AbapSessionStore");
19
+ Object.defineProperty(exports, "AbapSessionStore", { enumerable: true, get: function () { return AbapSessionStore_1.AbapSessionStore; } });
20
+ var SafeAbapSessionStore_1 = require("./stores/abap/SafeAbapSessionStore");
21
+ Object.defineProperty(exports, "SafeAbapSessionStore", { enumerable: true, get: function () { return SafeAbapSessionStore_1.SafeAbapSessionStore; } });
22
+ var AbapServiceKeyStore_1 = require("./stores/abap/AbapServiceKeyStore");
23
+ Object.defineProperty(exports, "AbapServiceKeyStore", { enumerable: true, get: function () { return AbapServiceKeyStore_1.AbapServiceKeyStore; } });
24
+ // XSUAA stores
25
+ var XsuaaSessionStore_1 = require("./stores/xsuaa/XsuaaSessionStore");
26
+ Object.defineProperty(exports, "XsuaaSessionStore", { enumerable: true, get: function () { return XsuaaSessionStore_1.XsuaaSessionStore; } });
27
+ var SafeXsuaaSessionStore_1 = require("./stores/xsuaa/SafeXsuaaSessionStore");
28
+ Object.defineProperty(exports, "SafeXsuaaSessionStore", { enumerable: true, get: function () { return SafeXsuaaSessionStore_1.SafeXsuaaSessionStore; } });
29
+ var XsuaaServiceKeyStore_1 = require("./stores/xsuaa/XsuaaServiceKeyStore");
30
+ Object.defineProperty(exports, "XsuaaServiceKeyStore", { enumerable: true, get: function () { return XsuaaServiceKeyStore_1.XsuaaServiceKeyStore; } });
31
+ // Abstract classes (for extending)
32
+ var AbstractServiceKeyStore_1 = require("./stores/abstract/AbstractServiceKeyStore");
33
+ Object.defineProperty(exports, "AbstractServiceKeyStore", { enumerable: true, get: function () { return AbstractServiceKeyStore_1.AbstractServiceKeyStore; } });
34
+ var AbstractJsonSessionStore_1 = require("./stores/abstract/AbstractJsonSessionStore");
35
+ Object.defineProperty(exports, "AbstractJsonSessionStore", { enumerable: true, get: function () { return AbstractJsonSessionStore_1.AbstractJsonSessionStore; } });
36
+ var AbstractSafeSessionStore_1 = require("./stores/abstract/AbstractSafeSessionStore");
37
+ Object.defineProperty(exports, "AbstractSafeSessionStore", { enumerable: true, get: function () { return AbstractSafeSessionStore_1.AbstractSafeSessionStore; } });
38
+ // Utils
39
+ var pathResolver_1 = require("./utils/pathResolver");
40
+ Object.defineProperty(exports, "resolveSearchPaths", { enumerable: true, get: function () { return pathResolver_1.resolveSearchPaths; } });
41
+ Object.defineProperty(exports, "findFileInPaths", { enumerable: true, get: function () { return pathResolver_1.findFileInPaths; } });
42
+ var constants_1 = require("./utils/constants");
43
+ Object.defineProperty(exports, "ABAP_AUTHORIZATION_VARS", { enumerable: true, get: function () { return constants_1.ABAP_AUTHORIZATION_VARS; } });
44
+ Object.defineProperty(exports, "ABAP_CONNECTION_VARS", { enumerable: true, get: function () { return constants_1.ABAP_CONNECTION_VARS; } });
45
+ Object.defineProperty(exports, "BTP_AUTHORIZATION_VARS", { enumerable: true, get: function () { return constants_1.BTP_AUTHORIZATION_VARS; } });
46
+ Object.defineProperty(exports, "BTP_CONNECTION_VARS", { enumerable: true, get: function () { return constants_1.BTP_CONNECTION_VARS; } });
47
+ Object.defineProperty(exports, "XSUAA_AUTHORIZATION_VARS", { enumerable: true, get: function () { return constants_1.XSUAA_AUTHORIZATION_VARS; } });
48
+ Object.defineProperty(exports, "XSUAA_CONNECTION_VARS", { enumerable: true, get: function () { return constants_1.XSUAA_CONNECTION_VARS; } });
49
+ // Loaders
50
+ var serviceKeyLoader_1 = require("./loaders/abap/serviceKeyLoader");
51
+ Object.defineProperty(exports, "loadServiceKey", { enumerable: true, get: function () { return serviceKeyLoader_1.loadServiceKey; } });
52
+ var xsuaaServiceKeyLoader_1 = require("./loaders/xsuaa/xsuaaServiceKeyLoader");
53
+ Object.defineProperty(exports, "loadXSUAAServiceKey", { enumerable: true, get: function () { return xsuaaServiceKeyLoader_1.loadXSUAAServiceKey; } });
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Service key loader - loads service key JSON files by destination name for ABAP
3
+ *
4
+ * Uses parsers to handle different service key formats:
5
+ * - AbapServiceKeyParser: Standard ABAP service key format with nested uaa object
6
+ * - XsuaaServiceKeyParser: Direct XSUAA service key format from BTP
7
+ */
8
+ /**
9
+ * Load service key from {destination}.json file
10
+ * Automatically detects format and uses appropriate parser
11
+ * @param destination Destination name
12
+ * @param searchPaths Array of paths to search for the file
13
+ * @returns Service key object or null if file not found
14
+ */
15
+ export declare function loadServiceKey(destination: string, searchPaths: string[]): Promise<unknown | null>;
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ /**
3
+ * Service key loader - loads service key JSON files by destination name for ABAP
4
+ *
5
+ * Uses parsers to handle different service key formats:
6
+ * - AbapServiceKeyParser: Standard ABAP service key format with nested uaa object
7
+ * - XsuaaServiceKeyParser: Direct XSUAA service key format from BTP
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.loadServiceKey = loadServiceKey;
44
+ const fs = __importStar(require("fs"));
45
+ const pathResolver_1 = require("../../utils/pathResolver");
46
+ const AbapServiceKeyParser_1 = require("../../parsers/abap/AbapServiceKeyParser");
47
+ const XsuaaServiceKeyParser_1 = require("../../parsers/xsuaa/XsuaaServiceKeyParser");
48
+ /**
49
+ * Load service key from {destination}.json file
50
+ * Automatically detects format and uses appropriate parser
51
+ * @param destination Destination name
52
+ * @param searchPaths Array of paths to search for the file
53
+ * @returns Service key object or null if file not found
54
+ */
55
+ async function loadServiceKey(destination, searchPaths) {
56
+ const fileName = `${destination}.json`;
57
+ const serviceKeyPath = (0, pathResolver_1.findFileInPaths)(fileName, searchPaths);
58
+ if (!serviceKeyPath) {
59
+ return null;
60
+ }
61
+ try {
62
+ const fileContent = fs.readFileSync(serviceKeyPath, 'utf8');
63
+ const rawData = JSON.parse(fileContent);
64
+ // Try parsers in order: ABAP format first, then XSUAA format
65
+ const parsers = [
66
+ new AbapServiceKeyParser_1.AbapServiceKeyParser(),
67
+ new XsuaaServiceKeyParser_1.XsuaaServiceKeyParser(),
68
+ ];
69
+ for (const parser of parsers) {
70
+ if (parser.canParse(rawData)) {
71
+ return parser.parse(rawData);
72
+ }
73
+ }
74
+ // No parser could handle the data
75
+ throw new Error('Service key does not match any supported format. ' +
76
+ 'Expected either ABAP format (with nested uaa object) or XSUAA format (with url, clientid, clientsecret at root level)');
77
+ }
78
+ catch (error) {
79
+ if (error instanceof SyntaxError) {
80
+ throw new Error(`Invalid JSON in service key file for destination "${destination}": ${error.message}`);
81
+ }
82
+ throw new Error(`Failed to load service key for destination "${destination}": ${error instanceof Error ? error.message : String(error)}`);
83
+ }
84
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * XSUAA Service key loader - loads XSUAA service key JSON files by destination name
3
+ *
4
+ * Supports direct XSUAA service key format from BTP (without nested uaa object):
5
+ * {
6
+ * "url": "https://...authentication...hana.ondemand.com",
7
+ * "clientid": "...",
8
+ * "clientsecret": "...",
9
+ * ...
10
+ * }
11
+ */
12
+ /**
13
+ * Load XSUAA service key from {destination}.json file
14
+ * Normalizes direct XSUAA format to standard ServiceKey format
15
+ * @param destination Destination name
16
+ * @param searchPaths Array of paths to search for the file
17
+ * @returns Service key object or null if file not found
18
+ */
19
+ export declare function loadXSUAAServiceKey(destination: string, searchPaths: string[]): Promise<unknown | null>;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ /**
3
+ * XSUAA Service key loader - loads XSUAA service key JSON files by destination name
4
+ *
5
+ * Supports direct XSUAA service key format from BTP (without nested uaa object):
6
+ * {
7
+ * "url": "https://...authentication...hana.ondemand.com",
8
+ * "clientid": "...",
9
+ * "clientsecret": "...",
10
+ * ...
11
+ * }
12
+ */
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
46
+ Object.defineProperty(exports, "__esModule", { value: true });
47
+ exports.loadXSUAAServiceKey = loadXSUAAServiceKey;
48
+ const pathResolver_1 = require("../../utils/pathResolver");
49
+ const XsuaaServiceKeyParser_1 = require("../../parsers/xsuaa/XsuaaServiceKeyParser");
50
+ const fs = __importStar(require("fs"));
51
+ /**
52
+ * Load XSUAA service key from {destination}.json file
53
+ * Normalizes direct XSUAA format to standard ServiceKey format
54
+ * @param destination Destination name
55
+ * @param searchPaths Array of paths to search for the file
56
+ * @returns Service key object or null if file not found
57
+ */
58
+ async function loadXSUAAServiceKey(destination, searchPaths) {
59
+ const fileName = `${destination}.json`;
60
+ const serviceKeyPath = (0, pathResolver_1.findFileInPaths)(fileName, searchPaths);
61
+ if (!serviceKeyPath) {
62
+ return null;
63
+ }
64
+ try {
65
+ const fileContent = fs.readFileSync(serviceKeyPath, 'utf8');
66
+ const rawData = JSON.parse(fileContent);
67
+ // Use XSUAA parser
68
+ const parser = new XsuaaServiceKeyParser_1.XsuaaServiceKeyParser();
69
+ if (!parser.canParse(rawData)) {
70
+ return null; // Not an XSUAA format
71
+ }
72
+ return parser.parse(rawData);
73
+ }
74
+ catch (error) {
75
+ if (error instanceof SyntaxError) {
76
+ throw new Error(`Invalid JSON in XSUAA service key file for destination "${destination}": ${error.message}`);
77
+ }
78
+ throw new Error(`Failed to load XSUAA service key for destination "${destination}": ${error instanceof Error ? error.message : String(error)}`);
79
+ }
80
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * ABAP Service Key Parser
3
+ *
4
+ * Parses standard ABAP service key format with nested uaa object:
5
+ * {
6
+ * "uaa": {
7
+ * "url": "...",
8
+ * "clientid": "...",
9
+ * "clientsecret": "..."
10
+ * },
11
+ * "abap": {
12
+ * "url": "...",
13
+ * "client": "..."
14
+ * },
15
+ * ...
16
+ * }
17
+ */
18
+ /**
19
+ * Parser for standard ABAP service key format
20
+ */
21
+ export declare class AbapServiceKeyParser {
22
+ /**
23
+ * Check if this parser can handle the given raw service key data
24
+ * @param rawData Raw JSON data from service key file
25
+ * @returns true if data has nested uaa object, false otherwise
26
+ */
27
+ canParse(rawData: any): boolean;
28
+ /**
29
+ * Parse raw service key data
30
+ * @param rawData Raw JSON data from service key file
31
+ * @returns Parsed service key object
32
+ * @throws Error if data cannot be parsed or is invalid
33
+ */
34
+ parse(rawData: any): unknown;
35
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ /**
3
+ * ABAP Service Key Parser
4
+ *
5
+ * Parses standard ABAP service key format with nested uaa object:
6
+ * {
7
+ * "uaa": {
8
+ * "url": "...",
9
+ * "clientid": "...",
10
+ * "clientsecret": "..."
11
+ * },
12
+ * "abap": {
13
+ * "url": "...",
14
+ * "client": "..."
15
+ * },
16
+ * ...
17
+ * }
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.AbapServiceKeyParser = void 0;
21
+ /**
22
+ * Parser for standard ABAP service key format
23
+ */
24
+ class AbapServiceKeyParser {
25
+ /**
26
+ * Check if this parser can handle the given raw service key data
27
+ * @param rawData Raw JSON data from service key file
28
+ * @returns true if data has nested uaa object, false otherwise
29
+ */
30
+ canParse(rawData) {
31
+ return rawData && typeof rawData === 'object' && rawData.uaa && typeof rawData.uaa === 'object';
32
+ }
33
+ /**
34
+ * Parse raw service key data
35
+ * @param rawData Raw JSON data from service key file
36
+ * @returns Parsed service key object
37
+ * @throws Error if data cannot be parsed or is invalid
38
+ */
39
+ parse(rawData) {
40
+ if (!this.canParse(rawData)) {
41
+ throw new Error('Service key does not match ABAP format (missing uaa object)');
42
+ }
43
+ // Validate UAA configuration
44
+ if (!rawData.uaa.url || !rawData.uaa.clientid || !rawData.uaa.clientsecret) {
45
+ throw new Error('Service key "uaa" object missing required fields: url, clientid, clientsecret');
46
+ }
47
+ return rawData;
48
+ }
49
+ }
50
+ exports.AbapServiceKeyParser = AbapServiceKeyParser;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * XSUAA Service Key Parser
3
+ *
4
+ * Parses direct XSUAA service key format from BTP (without nested uaa object):
5
+ * {
6
+ * "url": "https://...authentication...hana.ondemand.com",
7
+ * "clientid": "...",
8
+ * "clientsecret": "...",
9
+ * "tenantmode": "shared",
10
+ * ...
11
+ * }
12
+ */
13
+ /**
14
+ * Parser for direct XSUAA service key format from BTP
15
+ */
16
+ export declare class XsuaaServiceKeyParser {
17
+ /**
18
+ * Check if this parser can handle the given raw service key data
19
+ * @param rawData Raw JSON data from service key file
20
+ * @returns true if data has direct XSUAA fields (url, clientid, clientsecret) without nested uaa object
21
+ */
22
+ canParse(rawData: any): boolean;
23
+ /**
24
+ * Parse raw service key data
25
+ * @param rawData Raw JSON data from service key file
26
+ * @returns Parsed service key object (normalized format)
27
+ * @throws Error if data cannot be parsed or is invalid
28
+ */
29
+ parse(rawData: any): unknown;
30
+ }