@mcp-abap-adt/auth-broker 3.0.4 → 4.0.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 (51) hide show
  1. package/CHANGELOG.md +448 -1
  2. package/README.md +723 -533
  3. package/dist/AuthBroker.d.ts +178 -29
  4. package/dist/AuthBroker.d.ts.map +1 -1
  5. package/dist/AuthBroker.js +494 -101
  6. package/dist/DestinationConfigError.d.ts +27 -0
  7. package/dist/DestinationConfigError.d.ts.map +1 -0
  8. package/dist/DestinationConfigError.js +36 -0
  9. package/dist/SessionWriter.d.ts +54 -0
  10. package/dist/SessionWriter.d.ts.map +1 -0
  11. package/dist/SessionWriter.js +135 -0
  12. package/dist/binding.d.ts +95 -0
  13. package/dist/binding.d.ts.map +1 -0
  14. package/dist/binding.js +207 -0
  15. package/dist/bindingOf.d.ts +36 -0
  16. package/dist/bindingOf.d.ts.map +1 -0
  17. package/dist/bindingOf.js +53 -0
  18. package/dist/destinations.d.ts +139 -0
  19. package/dist/destinations.d.ts.map +1 -0
  20. package/dist/destinations.js +429 -0
  21. package/dist/index.d.ts +7 -3
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +11 -7
  24. package/dist/providers/ITokenProvider.d.ts +2 -1
  25. package/dist/providers/ITokenProvider.d.ts.map +1 -1
  26. package/dist/providers/index.d.ts +2 -2
  27. package/dist/providers/index.js +2 -2
  28. package/dist/stores/index.d.ts +2 -2
  29. package/dist/stores/index.js +2 -2
  30. package/dist/stores/interfaces.d.ts +4 -3
  31. package/dist/stores/interfaces.d.ts.map +1 -1
  32. package/dist/stores/interfaces.js +2 -2
  33. package/dist/types.d.ts +5 -2
  34. package/dist/types.d.ts.map +1 -1
  35. package/dist/types.js +3 -1
  36. package/package.json +25 -45
  37. package/CONTRIBUTORS.md +0 -33
  38. package/dist/__tests__/helpers/configHelpers.d.ts +0 -59
  39. package/dist/__tests__/helpers/configHelpers.d.ts.map +0 -1
  40. package/dist/__tests__/helpers/configHelpers.js +0 -206
  41. package/dist/__tests__/helpers/netHelpers.d.ts +0 -3
  42. package/dist/__tests__/helpers/netHelpers.d.ts.map +0 -1
  43. package/dist/__tests__/helpers/netHelpers.js +0 -63
  44. package/dist/__tests__/helpers/testLogger.d.ts +0 -7
  45. package/dist/__tests__/helpers/testLogger.d.ts.map +0 -1
  46. package/dist/__tests__/helpers/testLogger.js +0 -54
  47. package/dist/bin/mcp-auth.js +0 -752
  48. package/dist/bin/mcp-sso.js +0 -825
  49. package/dist/bin/mcpSsoConfig.js +0 -566
  50. package/dist/bin/samlMetadata.js +0 -175
  51. package/dist/bin/workDir.js +0 -79
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * Token provider interface
4
4
  *
5
- * Provider implementations are in separate packages:
6
- * - @mcp-abap-adt/auth-providers - XSUAA and BTP providers
5
+ * Provider implementations: `@mcp-abap-adt/auth-providers`, or any
6
+ * `IRefreshableTokenProvider`.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Storage interfaces for AuthBroker
3
3
  *
4
- * Store implementations are in separate packages:
5
- * - @mcp-abap-adt/auth-stores-btp - BTP and ABAP stores
4
+ * Store implementations: `@mcp-abap-adt/auth-stores`, or any
5
+ * `ISessionStore` / `IServiceKeyStore`.
6
6
  */
7
7
  export type { IAuthorizationConfig, IConnectionConfig, IServiceKeyStore, ISessionStore, } from './interfaces';
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * Storage interfaces for AuthBroker
4
4
  *
5
- * Store implementations are in separate packages:
6
- * - @mcp-abap-adt/auth-stores-btp - BTP and ABAP stores
5
+ * Store implementations: `@mcp-abap-adt/auth-stores`, or any
6
+ * `ISessionStore` / `IServiceKeyStore`.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * Storage interfaces for AuthBroker
3
3
  *
4
- * All interfaces are imported from @mcp-abap-adt/interfaces package.
5
- * Type aliases (type) are in types.ts.
4
+ * The store contracts come from `@mcp-abap-adt/interfaces-auth-broker`;
5
+ * `IAuthorizationConfig` from `@mcp-abap-adt/interfaces-auth-sap`.
6
6
  */
7
- import type { IAuthorizationConfig, IConnectionConfig, IServiceKeyStore, ISessionStore } from '@mcp-abap-adt/interfaces-auth-sap';
7
+ import type { IConnectionConfig, IServiceKeyStore, ISessionStore } from '@mcp-abap-adt/interfaces-auth-broker';
8
+ import type { IAuthorizationConfig } from '@mcp-abap-adt/interfaces-auth-sap';
8
9
  export type { IAuthorizationConfig, IConnectionConfig, IServiceKeyStore, ISessionStore, };
9
10
  //# sourceMappingURL=interfaces.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/stores/interfaces.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACd,MAAM,mCAAmC,CAAC;AAG3C,YAAY,EACV,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,GACd,CAAC"}
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/stores/interfaces.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACd,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAG9E,YAAY,EACV,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,GACd,CAAC"}
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * Storage interfaces for AuthBroker
4
4
  *
5
- * All interfaces are imported from @mcp-abap-adt/interfaces package.
6
- * Type aliases (type) are in types.ts.
5
+ * The store contracts come from `@mcp-abap-adt/interfaces-auth-broker`;
6
+ * `IAuthorizationConfig` from `@mcp-abap-adt/interfaces-auth-sap`.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
package/dist/types.d.ts CHANGED
@@ -1,8 +1,11 @@
1
1
  /**
2
2
  * Type definitions for auth-broker package
3
3
  *
4
- * Type aliases (type) are defined here. Interfaces are imported from @mcp-abap-adt/interfaces.
4
+ * The store contracts (`IConfig`, `IConnectionConfig`, `ISessionStore`,
5
+ * `IServiceKeyStore`) come from `@mcp-abap-adt/interfaces-auth-broker`;
6
+ * `IAuthorizationConfig` from `@mcp-abap-adt/interfaces-auth-sap`.
5
7
  */
6
- import type { IAuthorizationConfig, IConfig, IConnectionConfig, IServiceKeyStore, ISessionStore } from '@mcp-abap-adt/interfaces-auth-sap';
8
+ import type { IConfig, IConnectionConfig, IServiceKeyStore, ISessionStore } from '@mcp-abap-adt/interfaces-auth-broker';
9
+ import type { IAuthorizationConfig } from '@mcp-abap-adt/interfaces-auth-sap';
7
10
  export type { IAuthorizationConfig, IConfig, IConnectionConfig, IServiceKeyStore, ISessionStore, };
8
11
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,oBAAoB,EACpB,OAAO,EACP,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACd,MAAM,mCAAmC,CAAC;AAG3C,YAAY,EACV,oBAAoB,EACpB,OAAO,EACP,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,GACd,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,OAAO,EACP,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACd,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAG9E,YAAY,EACV,oBAAoB,EACpB,OAAO,EACP,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,GACd,CAAC"}
package/dist/types.js CHANGED
@@ -2,6 +2,8 @@
2
2
  /**
3
3
  * Type definitions for auth-broker package
4
4
  *
5
- * Type aliases (type) are defined here. Interfaces are imported from @mcp-abap-adt/interfaces.
5
+ * The store contracts (`IConfig`, `IConnectionConfig`, `ISessionStore`,
6
+ * `IServiceKeyStore`) come from `@mcp-abap-adt/interfaces-auth-broker`;
7
+ * `IAuthorizationConfig` from `@mcp-abap-adt/interfaces-auth-sap`.
6
8
  */
7
9
  Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,14 +1,13 @@
1
1
  {
2
2
  "name": "@mcp-abap-adt/auth-broker",
3
- "version": "3.0.4",
4
- "description": "Per-destination token broker for SAP BTP and ABAP: sessions and service keys from stores, tokens from an injected provider, results persisted - plus the mcp-auth and mcp-sso CLIs",
3
+ "version": "4.0.0",
4
+ "description": "Per-destination credential broker for SAP BTP and ABAP: the IAuthProvider a destination states, built from its key store and session store, with every secret it obtains stored back; and a token API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [
8
8
  "dist",
9
9
  "README.md",
10
10
  "CHANGELOG.md",
11
- "CONTRIBUTORS.md",
12
11
  "LICENSE",
13
12
  "COPYING"
14
13
  ],
@@ -24,70 +23,51 @@
24
23
  "abap-adt",
25
24
  "xsuaa",
26
25
  "oauth2",
27
- "saml",
28
- "sso"
26
+ "saml"
29
27
  ],
30
28
  "author": "Oleksii Kyslytsia <oleksij.kyslytsja@gmail.com>",
31
29
  "license": "LGPL-3.0-only",
32
- "homepage": "https://github.com/fr0ster/mcp-abap-adt-auth-broker#readme",
30
+ "homepage": "https://github.com/fr0ster/mcp-abap-adt-auth-broker/tree/main/packages/auth-broker#readme",
33
31
  "bugs": {
34
32
  "url": "https://github.com/fr0ster/mcp-abap-adt-auth-broker/issues"
35
33
  },
36
34
  "repository": {
37
35
  "type": "git",
38
- "url": "git+https://github.com/fr0ster/mcp-abap-adt-auth-broker.git"
36
+ "url": "git+https://github.com/fr0ster/mcp-abap-adt-auth-broker.git",
37
+ "directory": "packages/auth-broker"
39
38
  },
40
39
  "publishConfig": {
41
40
  "access": "public"
42
41
  },
43
42
  "scripts": {
44
- "chrono": "./tools/version-stats.sh",
45
- "clean": "rm -rf dist tsconfig.tsbuildinfo",
46
- "lint": "biome check --write src",
47
- "lint:check": "biome check src",
48
- "format": "biome format --write src",
49
- "build": "npm run --silent clean && biome check src --diagnostic-level=error && tsc -p tsconfig.json && tsc -p tsconfig.cli.json",
50
- "build:fast": "tsc -p tsconfig.json && tsc -p tsconfig.cli.json",
51
- "test": "NODE_OPTIONS=--experimental-vm-modules jest",
52
- "test:check": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
53
- "test:mcp-auth": "sh tests/sso-demo/run-mcp-auth.sh",
54
- "test:mcp-sso": "sh tests/sso-demo/run-mcp-sso.sh",
55
- "test:device-code": "sh tests/keycloak/run-oidc.sh",
56
- "test:saml-pure": "sh tests/keycloak/run-saml.sh",
57
- "test:sso": "sh tests/keycloak/run-interactive.sh",
58
- "prepublishOnly": "npm run build",
59
- "prepack": "npm run build",
60
- "generate-env": "tsx bin/generate-env-from-service-key.ts"
61
- },
62
- "bin": {
63
- "mcp-auth": "./dist/bin/mcp-auth.js",
64
- "mcp-sso": "./dist/bin/mcp-sso.js"
43
+ "clean": "node -e \"for (const p of ['dist', 'tsconfig.tsbuildinfo', 'tsconfig.build.tsbuildinfo']) require('fs').rmSync(p, { recursive: true, force: true })\"",
44
+ "build": "tsc -b tsconfig.build.json",
45
+ "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
46
+ "test:live": "cross-env NODE_OPTIONS=--experimental-vm-modules jest -c jest.live.config.js",
47
+ "test:stand": "tests/stand/run.sh",
48
+ "stand:up": "tests/stand/up.sh",
49
+ "stand:down": "tests/stand/down.sh",
50
+ "test:check": "tsc -p tsconfig.json --noEmit",
51
+ "prepublishOnly": "npm run --prefix ../.. check"
65
52
  },
66
53
  "engines": {
67
54
  "node": "^22 || ^24 || ^26"
68
55
  },
69
56
  "dependencies": {
70
- "@mcp-abap-adt/auth-providers": "^4.2.0",
71
- "@mcp-abap-adt/auth-stores": "^1.2.3",
72
- "@mcp-abap-adt/interfaces-auth": "^2.1.0",
73
- "@mcp-abap-adt/interfaces-auth-sap": "^1.0.1",
74
- "@mcp-abap-adt/interfaces-utils": "^1.1.0",
75
- "@mcp-abap-adt/logger": "^0.4.0",
76
- "axios": "^1.13.5"
57
+ "@mcp-abap-adt/auth-providers": "^5.2.1",
58
+ "@mcp-abap-adt/interfaces-auth": "^3.0.0",
59
+ "@mcp-abap-adt/interfaces-auth-broker": "^1.1.0",
60
+ "@mcp-abap-adt/interfaces-auth-sap": "^2.0.0",
61
+ "@mcp-abap-adt/interfaces-utils": "^1.1.0"
77
62
  },
78
63
  "devDependencies": {
79
- "@biomejs/biome": "^2.3.14",
80
- "@types/express": "^5.0.5",
81
- "@types/jest": "^30.0.0",
64
+ "@mcp-abap-adt/auth-mocks": "^0.3.0",
65
+ "@mcp-abap-adt/auth-stores": "^3.2.0",
66
+ "@mcp-abap-adt/connection": "^10.0.3",
67
+ "@mcp-abap-adt/logger": "^0.4.0",
82
68
  "@types/js-yaml": "^4.0.9",
83
- "@types/node": "^25.2.3",
84
- "jest": "^30.2.0",
85
- "jest-util": "^30.2.0",
86
69
  "js-yaml": "^4.1.1",
87
70
  "pino": "^10.1.0",
88
- "pino-pretty": "^13.1.3",
89
- "ts-jest": "^29.2.5",
90
- "tsx": "^4.21.0",
91
- "typescript": "^5.9.2"
71
+ "pino-pretty": "^13.1.3"
92
72
  }
93
73
  }
package/CONTRIBUTORS.md DELETED
@@ -1,33 +0,0 @@
1
- # Contributors
2
-
3
- Thank you to all contributors who have helped make `@mcp-abap-adt/auth-broker` better!
4
-
5
- ## How to Contribute
6
-
7
- We welcome contributions! Please see the project documentation for details on how to get started.
8
-
9
- ## Contributors
10
-
11
- <!-- Contributors are listed alphabetically by last name -->
12
-
13
- ### Core Contributors
14
-
15
- - **Oleksii Kyslytsia** - Project creator and maintainer
16
-
17
- ---
18
-
19
- ## Recognition
20
-
21
- We appreciate every contribution, whether it's:
22
- - 🐛 Bug reports and fixes
23
- - ✨ New features and enhancements
24
- - 📚 Documentation improvements
25
- - 🧪 Test coverage
26
- - 💬 Feedback and suggestions
27
-
28
- Every contribution helps make `@mcp-abap-adt/auth-broker` better for everyone!
29
-
30
- ---
31
-
32
- **Note:** This list is manually maintained. If you've contributed but don't see your name here, please open an issue or submit a PR to update this file.
33
-
@@ -1,59 +0,0 @@
1
- /**
2
- * Configuration helpers for auth-broker tests
3
- * Loads test configuration from test-config.yaml
4
- */
5
- export interface TestConfig {
6
- auth_broker?: {
7
- paths?: {
8
- service_keys_dir?: string;
9
- sessions_dir?: string;
10
- };
11
- abap?: {
12
- destination?: string;
13
- expired_token?: string;
14
- refresh_token?: string;
15
- };
16
- xsuaa?: {
17
- btp_destination?: string;
18
- mcp_destination?: string;
19
- mcp_url?: string;
20
- };
21
- };
22
- }
23
- /**
24
- * Load test configuration from YAML
25
- * Uses test-config.yaml from tests/ directory
26
- */
27
- export declare function loadTestConfig(): TestConfig;
28
- /**
29
- * Check if test config has real values (not placeholders)
30
- */
31
- export declare function hasRealConfig(config: TestConfig, section: 'abap' | 'xsuaa'): boolean;
32
- /**
33
- * Get ABAP destination from config
34
- */
35
- export declare function getAbapDestination(config?: TestConfig): string | null;
36
- /**
37
- * Get XSUAA destinations from config
38
- */
39
- export declare function getXsuaaDestinations(config?: TestConfig): {
40
- btp_destination: string | null;
41
- mcp_url: string | null;
42
- };
43
- /**
44
- * Get service keys directory from config
45
- */
46
- export declare function getServiceKeysDir(config?: TestConfig): string | null;
47
- /**
48
- * Get sessions directory from config
49
- */
50
- export declare function getSessionsDir(config?: TestConfig): string | null;
51
- /**
52
- * Get expired token from config (real expired token from YAML)
53
- */
54
- export declare function getExpiredToken(config?: TestConfig): string | null;
55
- /**
56
- * Get refresh token from config (real refresh token from YAML)
57
- */
58
- export declare function getRefreshToken(config?: TestConfig): string | null;
59
- //# sourceMappingURL=configHelpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"configHelpers.d.ts","sourceRoot":"","sources":["../../../src/__tests__/helpers/configHelpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,MAAM,WAAW,UAAU;IACzB,WAAW,CAAC,EAAE;QACZ,KAAK,CAAC,EAAE;YACN,gBAAgB,CAAC,EAAE,MAAM,CAAC;YAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;SACvB,CAAC;QACF,IAAI,CAAC,EAAE;YACL,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,aAAa,CAAC,EAAE,MAAM,CAAC;YACvB,aAAa,CAAC,EAAE,MAAM,CAAC;SACxB,CAAC;QACF,KAAK,CAAC,EAAE;YACN,eAAe,CAAC,EAAE,MAAM,CAAC;YACzB,eAAe,CAAC,EAAE,MAAM,CAAC;YACzB,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC;KACH,CAAC;CACH;AAkBD;;;GAGG;AACH,wBAAgB,cAAc,IAAI,UAAU,CAyD3C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,MAAM,GAAG,OAAO,GACxB,OAAO,CAwBT;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAGrE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG;IACzD,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,CAOA;AAaD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CASpE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CASjE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAGlE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAGlE"}
@@ -1,206 +0,0 @@
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
- exports.getExpiredToken = getExpiredToken;
47
- exports.getRefreshToken = getRefreshToken;
48
- const fs = __importStar(require("node:fs"));
49
- const path = __importStar(require("node:path"));
50
- const yaml = __importStar(require("js-yaml"));
51
- let cachedConfig = null;
52
- /**
53
- * Find project root directory by looking for package.json
54
- */
55
- function findProjectRoot() {
56
- let currentDir = __dirname;
57
- while (currentDir !== path.dirname(currentDir)) {
58
- const packageJsonPath = path.join(currentDir, 'package.json');
59
- if (fs.existsSync(packageJsonPath)) {
60
- return currentDir;
61
- }
62
- currentDir = path.dirname(currentDir);
63
- }
64
- // Fallback to process.cwd() if package.json not found
65
- return process.cwd();
66
- }
67
- /**
68
- * Load test configuration from YAML
69
- * Uses test-config.yaml from tests/ directory
70
- */
71
- function loadTestConfig() {
72
- if (cachedConfig) {
73
- return cachedConfig;
74
- }
75
- // Find project root and load from tests/test-config.yaml
76
- const projectRoot = findProjectRoot();
77
- const configPath = path.resolve(projectRoot, 'tests', 'test-config.yaml');
78
- const templatePath = path.resolve(projectRoot, 'tests', 'test-config.yaml.template');
79
- if (process.env.TEST_VERBOSE) {
80
- console.log(`[configHelpers] Project root: ${projectRoot}`);
81
- console.log(`[configHelpers] Config path: ${configPath}`);
82
- console.log(`[configHelpers] Config exists: ${fs.existsSync(configPath)}`);
83
- }
84
- if (fs.existsSync(configPath)) {
85
- try {
86
- const configContent = fs.readFileSync(configPath, 'utf8');
87
- cachedConfig = yaml.load(configContent) || {};
88
- if (process.env.TEST_VERBOSE) {
89
- console.log(`[configHelpers] Loaded config:`, JSON.stringify(cachedConfig, null, 2));
90
- }
91
- return cachedConfig;
92
- }
93
- catch (error) {
94
- console.warn(`Failed to load test config from ${configPath}:`, error);
95
- return {};
96
- }
97
- }
98
- if (fs.existsSync(templatePath)) {
99
- console.warn('⚠️ tests/test-config.yaml not found. Using template (all integration tests will be disabled).');
100
- try {
101
- const templateContent = fs.readFileSync(templatePath, 'utf8');
102
- cachedConfig = yaml.load(templateContent) || {};
103
- return cachedConfig;
104
- }
105
- catch (error) {
106
- console.warn(`Failed to load test config template from ${templatePath}:`, error);
107
- return {};
108
- }
109
- }
110
- console.warn('⚠️ Test configuration files not found.');
111
- console.warn('Please create tests/test-config.yaml with test parameters.');
112
- return {};
113
- }
114
- /**
115
- * Check if test config has real values (not placeholders)
116
- */
117
- function hasRealConfig(config, section) {
118
- if (!config.auth_broker) {
119
- return false;
120
- }
121
- if (section === 'abap') {
122
- const abap = config.auth_broker.abap;
123
- if (!abap?.destination) {
124
- return false;
125
- }
126
- // Check if destination is not a placeholder
127
- return !abap.destination.includes('<') && !abap.destination.includes('>');
128
- }
129
- if (section === 'xsuaa') {
130
- const xsuaa = config.auth_broker.xsuaa;
131
- if (!xsuaa?.btp_destination || !xsuaa?.mcp_url) {
132
- return false;
133
- }
134
- // Check if values are not placeholders
135
- return !xsuaa.btp_destination.includes('<') && !xsuaa.mcp_url.includes('<');
136
- }
137
- return false;
138
- }
139
- /**
140
- * Get ABAP destination from config
141
- */
142
- function getAbapDestination(config) {
143
- const cfg = config || loadTestConfig();
144
- return cfg.auth_broker?.abap?.destination || null;
145
- }
146
- /**
147
- * Get XSUAA destinations from config
148
- */
149
- function getXsuaaDestinations(config) {
150
- const cfg = config || loadTestConfig();
151
- const xsuaa = cfg.auth_broker?.xsuaa;
152
- return {
153
- btp_destination: xsuaa?.btp_destination || null,
154
- mcp_url: xsuaa?.mcp_url || null,
155
- };
156
- }
157
- /**
158
- * Expand tilde (~) to home directory
159
- */
160
- function expandTilde(filePath) {
161
- if (filePath.startsWith('~')) {
162
- const os = require('node:os');
163
- return path.join(os.homedir(), filePath.slice(1));
164
- }
165
- return filePath;
166
- }
167
- /**
168
- * Get service keys directory from config
169
- */
170
- function getServiceKeysDir(config) {
171
- const cfg = config || loadTestConfig();
172
- const dir = cfg.auth_broker?.paths?.service_keys_dir;
173
- if (!dir) {
174
- return null;
175
- }
176
- // Expand ~ and normalize path
177
- const expanded = expandTilde(dir);
178
- return path.resolve(expanded);
179
- }
180
- /**
181
- * Get sessions directory from config
182
- */
183
- function getSessionsDir(config) {
184
- const cfg = config || loadTestConfig();
185
- const dir = cfg.auth_broker?.paths?.sessions_dir;
186
- if (!dir) {
187
- return null;
188
- }
189
- // Expand ~ and normalize path
190
- const expanded = expandTilde(dir);
191
- return path.resolve(expanded);
192
- }
193
- /**
194
- * Get expired token from config (real expired token from YAML)
195
- */
196
- function getExpiredToken(config) {
197
- const cfg = config || loadTestConfig();
198
- return cfg.auth_broker?.abap?.expired_token || null;
199
- }
200
- /**
201
- * Get refresh token from config (real refresh token from YAML)
202
- */
203
- function getRefreshToken(config) {
204
- const cfg = config || loadTestConfig();
205
- return cfg.auth_broker?.abap?.refresh_token || null;
206
- }
@@ -1,3 +0,0 @@
1
- export declare function getAvailablePort(): Promise<number>;
2
- export declare function canListenOnLocalhost(): Promise<boolean>;
3
- //# sourceMappingURL=netHelpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"netHelpers.d.ts","sourceRoot":"","sources":["../../../src/__tests__/helpers/netHelpers.ts"],"names":[],"mappings":"AAEA,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,CAcxD;AAED,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC,CAQ7D"}
@@ -1,63 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.getAvailablePort = getAvailablePort;
37
- exports.canListenOnLocalhost = canListenOnLocalhost;
38
- const net = __importStar(require("node:net"));
39
- async function getAvailablePort() {
40
- return new Promise((resolve, reject) => {
41
- const server = net.createServer();
42
- server.once('error', reject);
43
- server.listen(0, '127.0.0.1', () => {
44
- const address = server.address();
45
- if (typeof address === 'object' && address?.port) {
46
- const port = address.port;
47
- server.close(() => resolve(port));
48
- }
49
- else {
50
- server.close(() => reject(new Error('Failed to acquire a port')));
51
- }
52
- });
53
- });
54
- }
55
- async function canListenOnLocalhost() {
56
- return new Promise((resolve) => {
57
- const server = net.createServer();
58
- server.once('error', () => resolve(false));
59
- server.listen(0, '127.0.0.1', () => {
60
- server.close(() => resolve(true));
61
- });
62
- });
63
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Test logger with environment variable control
3
- * Uses DefaultLogger from @mcp-abap-adt/logger for proper formatting
4
- */
5
- import type { ILogger } from '@mcp-abap-adt/interfaces-utils';
6
- export declare function createTestLogger(prefix?: string): ILogger;
7
- //# sourceMappingURL=testLogger.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"testLogger.d.ts","sourceRoot":"","sources":["../../../src/__tests__/helpers/testLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAG9D,wBAAgB,gBAAgB,CAAC,MAAM,GAAE,MAAe,GAAG,OAAO,CAmDjE"}
@@ -1,54 +0,0 @@
1
- "use strict";
2
- /**
3
- * Test logger with environment variable control
4
- * Uses DefaultLogger from @mcp-abap-adt/logger for proper formatting
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.createTestLogger = createTestLogger;
8
- const logger_1 = require("@mcp-abap-adt/logger");
9
- function createTestLogger(prefix = 'TEST') {
10
- // Check if logging is enabled - requires explicit enable
11
- const isEnabled = () => {
12
- // Explicitly disabled (support both short and long names)
13
- if (process.env.DEBUG_BROKER === 'false' ||
14
- process.env.DEBUG_AUTH_BROKER === 'false') {
15
- return false;
16
- }
17
- // Explicitly enabled (support both short and long names)
18
- if (process.env.DEBUG_BROKER === 'true' ||
19
- process.env.DEBUG_AUTH_BROKER === 'true' ||
20
- process.env.DEBUG === 'true' ||
21
- process.env.DEBUG?.includes('broker') === true ||
22
- process.env.DEBUG?.includes('auth-broker') === true) {
23
- return true;
24
- }
25
- // Do not enable by default - require explicit enable
26
- return false;
27
- };
28
- // Create DefaultLogger with appropriate log level
29
- // getLogLevel respects AUTH_LOG_LEVEL env var and defaults to INFO
30
- const baseLogger = new logger_1.DefaultLogger((0, logger_1.getLogLevel)());
31
- // Return wrapper that checks if logging is enabled
32
- return {
33
- debug: (message, meta) => {
34
- if (isEnabled()) {
35
- baseLogger.debug(`[${prefix}] ${message}`, meta);
36
- }
37
- },
38
- info: (message, meta) => {
39
- if (isEnabled()) {
40
- baseLogger.info(`[${prefix}] ${message}`, meta);
41
- }
42
- },
43
- warn: (message, meta) => {
44
- if (isEnabled()) {
45
- baseLogger.warn(`[${prefix}] ${message}`, meta);
46
- }
47
- },
48
- error: (message, meta) => {
49
- if (isEnabled()) {
50
- baseLogger.error(`[${prefix}] ${message}`, meta);
51
- }
52
- },
53
- };
54
- }