@mcp-abap-adt/auth-broker 0.1.0 → 0.1.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 CHANGED
@@ -9,12 +9,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  Thank you to all contributors! See [CONTRIBUTORS.md](CONTRIBUTORS.md) for the complete list.
11
11
 
12
- ## [0.1.0] - 2025-01-XX
12
+ ## [0.1.1] - 2025-11-30
13
+
14
+ ### Added
15
+ - **AuthBroker.getSapUrl()** - New method to get SAP URL for destination
16
+ - Loads URL from `.env` file first, then from service key
17
+ - Returns `undefined` if URL not found
18
+ - Useful for destination-based authentication where URL comes from destination, not headers
19
+
20
+ ## [0.1.0] - 2025-11-30
13
21
 
14
22
  ### Added
15
23
  - **AuthBroker class** - Main class for managing JWT authentication tokens
16
24
  - `getToken(destination)` - Get token for destination (loads, validates, refreshes if needed)
17
25
  - `refreshToken(destination)` - Force refresh token using service key or browser authentication
26
+ - `getSapUrl(destination)` - Get SAP URL for destination (loads from .env or service key)
18
27
  - `clearCache(destination)` - Clear cached token for specific destination
19
28
  - `clearAllCache()` - Clear all cached tokens
20
29
  - **Multi-path file search** - Configurable search paths for `.env` and `.json` files
@@ -38,6 +38,13 @@ export declare class AuthBroker {
38
38
  * @returns Promise that resolves to new JWT token string
39
39
  */
40
40
  refreshToken(destination: string): Promise<string>;
41
+ /**
42
+ * Get SAP URL for destination.
43
+ * Tries to load from .env file first, then from service key.
44
+ * @param destination Destination name (e.g., "TRIAL")
45
+ * @returns Promise that resolves to SAP URL string, or undefined if not found
46
+ */
47
+ getSapUrl(destination: string): Promise<string | undefined>;
41
48
  /**
42
49
  * Save token to {destination}.env file
43
50
  * Creates .env file similar to sap-abap-auth utility format
@@ -1 +1 @@
1
- {"version":3,"file":"AuthBroker.d.ts","sourceRoot":"","sources":["../src/AuthBroker.ts"],"names":[],"mappings":"AAAA;;GAE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;;;;;OAKG;IACG,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAgBjE;;;;OAIG;YACW,cAAc;IA6E5B;;;OAGG;IACH,OAAO,CAAC,cAAc;IAyCtB;;;OAGG;IACH,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAIrC;;OAEG;IACH,aAAa,IAAI,IAAI;CAGtB"}
@@ -39,6 +39,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.AuthBroker = void 0;
40
40
  const fs = __importStar(require("fs"));
41
41
  const path = __importStar(require("path"));
42
+ const envLoader_1 = require("./envLoader");
43
+ const serviceKeyLoader_1 = require("./serviceKeyLoader");
42
44
  const cache_1 = require("./cache");
43
45
  const pathResolver_1 = require("./pathResolver");
44
46
  const logger_1 = require("./logger");
@@ -90,6 +92,25 @@ class AuthBroker {
90
92
  // Use refreshToken function with logger and browser
91
93
  return (0, refreshToken_1.refreshToken)(destination, this.searchPaths, this.logger);
92
94
  }
95
+ /**
96
+ * Get SAP URL for destination.
97
+ * Tries to load from .env file first, then from service key.
98
+ * @param destination Destination name (e.g., "TRIAL")
99
+ * @returns Promise that resolves to SAP URL string, or undefined if not found
100
+ */
101
+ async getSapUrl(destination) {
102
+ // Try to load from .env file first
103
+ const envConfig = await (0, envLoader_1.loadEnvFile)(destination, this.searchPaths);
104
+ if (envConfig?.sapUrl) {
105
+ return envConfig.sapUrl;
106
+ }
107
+ // Try service key
108
+ const serviceKey = await (0, serviceKeyLoader_1.loadServiceKey)(destination, this.searchPaths);
109
+ if (serviceKey) {
110
+ return serviceKey.url || serviceKey.abap?.url || serviceKey.sap_url;
111
+ }
112
+ return undefined;
113
+ }
93
114
  /**
94
115
  * Save token to {destination}.env file
95
116
  * Creates .env file similar to sap-abap-auth utility format
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-abap-adt/auth-broker",
3
- "version": "0.1.0",
3
+ "version": "0.1.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",