@mcp-abap-adt/auth-stores 1.0.1 → 1.0.2

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
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.0.2] - 2026-02-12
11
+
12
+ ### Fixed
13
+ - Service key JSON loading now tolerates `cf service-key` output (leading text) and unwraps `credentials` wrapper for XSUAA keys.
14
+ - Added XSUAA service key parsing tests for both direct JSON and `credentials`-wrapped formats.
15
+
10
16
  ## [1.0.0] - 2026-02-10
11
17
 
12
18
  ### Added
@@ -5,6 +5,8 @@
5
5
  * Utility class for working with JSON files
6
6
  */
7
7
  export declare class JsonFileHandler {
8
+ private static unwrapCredentials;
9
+ private static extractJsonFromText;
8
10
  /**
9
11
  * Load JSON data from file
10
12
  * @param fileName File name (e.g., "TRIAL.json")
@@ -43,6 +43,27 @@ const path = __importStar(require("node:path"));
43
43
  * Utility class for working with JSON files
44
44
  */
45
45
  class JsonFileHandler {
46
+ static unwrapCredentials(data) {
47
+ const keys = Object.keys(data);
48
+ if (keys.length !== 1 || keys[0] !== 'credentials') {
49
+ return data;
50
+ }
51
+ const credentials = data.credentials;
52
+ if (credentials &&
53
+ typeof credentials === 'object' &&
54
+ !Array.isArray(credentials)) {
55
+ return credentials;
56
+ }
57
+ return data;
58
+ }
59
+ static extractJsonFromText(text) {
60
+ const start = text.indexOf('{');
61
+ const end = text.lastIndexOf('}');
62
+ if (start === -1 || end === -1 || end <= start) {
63
+ return null;
64
+ }
65
+ return text.slice(start, end + 1);
66
+ }
46
67
  /**
47
68
  * Load JSON data from file
48
69
  * @param fileName File name (e.g., "TRIAL.json")
@@ -57,11 +78,32 @@ class JsonFileHandler {
57
78
  }
58
79
  try {
59
80
  const fileContent = fs.readFileSync(filePath, 'utf8');
60
- return JSON.parse(fileContent);
81
+ const parsed = JSON.parse(fileContent);
82
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
83
+ return JsonFileHandler.unwrapCredentials(parsed);
84
+ }
85
+ return parsed;
61
86
  }
62
87
  catch (error) {
63
88
  if (error instanceof SyntaxError) {
64
- throw new Error(`Invalid JSON in file "${fileName}": ${error.message}`);
89
+ try {
90
+ const fileContent = fs.readFileSync(filePath, 'utf8');
91
+ const extracted = JsonFileHandler.extractJsonFromText(fileContent);
92
+ if (!extracted) {
93
+ throw new Error(`Invalid JSON in file "${fileName}": ${error.message}`);
94
+ }
95
+ const parsed = JSON.parse(extracted);
96
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
97
+ return JsonFileHandler.unwrapCredentials(parsed);
98
+ }
99
+ return parsed;
100
+ }
101
+ catch (inner) {
102
+ if (inner instanceof Error) {
103
+ throw new Error(`Invalid JSON in file "${fileName}": ${inner.message}`);
104
+ }
105
+ throw new Error(`Invalid JSON in file "${fileName}": ${String(inner)}`);
106
+ }
65
107
  }
66
108
  throw new Error(`Failed to load JSON file "${fileName}": ${error instanceof Error ? error.message : String(error)}`);
67
109
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-abap-adt/auth-stores",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Stores for MCP ABAP ADT auth-broker - BTP, ABAP, and XSUAA implementations",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",