@mcp-abap-adt/auth-broker 0.1.5 → 0.1.6
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 +229 -0
- package/README.md +172 -15
- package/bin/generate-env-from-service-key.ts +128 -0
- package/dist/AuthBroker.d.ts +19 -29
- package/dist/AuthBroker.d.ts.map +1 -1
- package/dist/AuthBroker.js +86 -132
- package/dist/__tests__/helpers/configHelpers.d.ts +49 -0
- package/dist/__tests__/helpers/configHelpers.d.ts.map +1 -0
- package/dist/__tests__/helpers/configHelpers.js +169 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -8
- package/dist/providers/ITokenProvider.d.ts +49 -0
- package/dist/providers/ITokenProvider.d.ts.map +1 -0
- package/dist/providers/ITokenProvider.js +10 -0
- package/dist/providers/index.d.ts +8 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +8 -0
- package/dist/stores/index.d.ts +5 -5
- package/dist/stores/index.d.ts.map +1 -1
- package/dist/stores/index.js +4 -8
- package/dist/stores/interfaces.d.ts +88 -22
- package/dist/stores/interfaces.d.ts.map +1 -1
- package/dist/stores/interfaces.js +1 -2
- package/dist/types.d.ts +7 -31
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -0
- package/package.json +13 -6
- package/dist/__tests__/testHelpers.d.ts +0 -44
- package/dist/__tests__/testHelpers.d.ts.map +0 -1
- package/dist/__tests__/testHelpers.js +0 -136
- package/dist/browserAuth.d.ts +0 -17
- package/dist/browserAuth.d.ts.map +0 -1
- package/dist/browserAuth.js +0 -305
- package/dist/cache.d.ts +0 -20
- package/dist/cache.d.ts.map +0 -1
- package/dist/cache.js +0 -46
- package/dist/envLoader.d.ts +0 -12
- package/dist/envLoader.d.ts.map +0 -1
- package/dist/envLoader.js +0 -90
- package/dist/getToken.d.ts +0 -14
- package/dist/getToken.d.ts.map +0 -1
- package/dist/getToken.js +0 -62
- package/dist/logger.d.ts +0 -40
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -186
- package/dist/pathResolver.d.ts +0 -21
- package/dist/pathResolver.d.ts.map +0 -1
- package/dist/pathResolver.js +0 -105
- package/dist/refreshToken.d.ts +0 -14
- package/dist/refreshToken.d.ts.map +0 -1
- package/dist/refreshToken.js +0 -71
- package/dist/serviceKeyLoader.d.ts +0 -12
- package/dist/serviceKeyLoader.d.ts.map +0 -1
- package/dist/serviceKeyLoader.js +0 -72
- package/dist/stores/FileServiceKeyStore.d.ts +0 -38
- package/dist/stores/FileServiceKeyStore.d.ts.map +0 -1
- package/dist/stores/FileServiceKeyStore.js +0 -47
- package/dist/stores/FileSessionStore.d.ts +0 -50
- package/dist/stores/FileSessionStore.d.ts.map +0 -1
- package/dist/stores/FileSessionStore.js +0 -116
- package/dist/stores/SafeSessionStore.d.ts +0 -35
- package/dist/stores/SafeSessionStore.d.ts.map +0 -1
- package/dist/stores/SafeSessionStore.js +0 -42
- package/dist/tokenRefresher.d.ts +0 -17
- package/dist/tokenRefresher.d.ts.map +0 -1
- package/dist/tokenRefresher.js +0 -53
- package/dist/tokenStorage.d.ts +0 -15
- package/dist/tokenStorage.d.ts.map +0 -1
- package/dist/tokenStorage.js +0 -107
- package/dist/tokenValidator.d.ts +0 -11
- package/dist/tokenValidator.d.ts.map +0 -1
- package/dist/tokenValidator.js +0 -108
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token Provider interface
|
|
3
|
+
*
|
|
4
|
+
* Converts IAuthorizationConfig to IConnectionConfig by obtaining tokens.
|
|
5
|
+
* Different implementations handle different authentication flows:
|
|
6
|
+
* - XSUAA: client_credentials grant type (no browser)
|
|
7
|
+
* - BTP/ABAP: browser-based OAuth2 or refresh token
|
|
8
|
+
*/
|
|
9
|
+
import { IAuthorizationConfig, IConnectionConfig } from '../stores/interfaces';
|
|
10
|
+
/**
|
|
11
|
+
* Result from token provider
|
|
12
|
+
*/
|
|
13
|
+
export interface TokenProviderResult {
|
|
14
|
+
/** Connection configuration with authorization token */
|
|
15
|
+
connectionConfig: IConnectionConfig;
|
|
16
|
+
/** Refresh token (optional, for BTP/ABAP) */
|
|
17
|
+
refreshToken?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Interface for token providers
|
|
21
|
+
*
|
|
22
|
+
* Takes authorization configuration and returns connection configuration with token.
|
|
23
|
+
*/
|
|
24
|
+
export interface ITokenProvider {
|
|
25
|
+
/**
|
|
26
|
+
* Get connection configuration with token from authorization configuration
|
|
27
|
+
* @param authConfig Authorization configuration (UAA credentials, optional refresh token)
|
|
28
|
+
* @param options Optional provider-specific options (e.g., browser type for BTP)
|
|
29
|
+
* @returns Promise that resolves to connection configuration with authorization token and optional refresh token
|
|
30
|
+
*/
|
|
31
|
+
getConnectionConfig(authConfig: IAuthorizationConfig, options?: TokenProviderOptions): Promise<TokenProviderResult>;
|
|
32
|
+
/**
|
|
33
|
+
* Validate JWT token by testing connection to service
|
|
34
|
+
* @param token JWT token to validate
|
|
35
|
+
* @param serviceUrl Service URL (optional, for services that require URL validation)
|
|
36
|
+
* @returns Promise that resolves to true if token is valid, false otherwise
|
|
37
|
+
*/
|
|
38
|
+
validateToken?(token: string, serviceUrl?: string): Promise<boolean>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Options for token providers
|
|
42
|
+
*/
|
|
43
|
+
export interface TokenProviderOptions {
|
|
44
|
+
/** Browser type for browser-based authentication (chrome, edge, firefox, system, none) */
|
|
45
|
+
browser?: string;
|
|
46
|
+
/** Logger instance for logging */
|
|
47
|
+
logger?: import('@mcp-abap-adt/logger').Logger;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=ITokenProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ITokenProvider.d.ts","sourceRoot":"","sources":["../../src/providers/ITokenProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE/E;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,wDAAwD;IACxD,gBAAgB,EAAE,iBAAiB,CAAC;IACpC,6CAA6C;IAC7C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,mBAAmB,CACjB,UAAU,EAAE,oBAAoB,EAChC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAEhC;;;;;OAKG;IACH,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACtE;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,0FAA0F;IAC1F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,MAAM,CAAC,EAAE,OAAO,sBAAsB,EAAE,MAAM,CAAC;CAChD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Token Provider interface
|
|
4
|
+
*
|
|
5
|
+
* Converts IAuthorizationConfig to IConnectionConfig by obtaining tokens.
|
|
6
|
+
* Different implementations handle different authentication flows:
|
|
7
|
+
* - XSUAA: client_credentials grant type (no browser)
|
|
8
|
+
* - BTP/ABAP: browser-based OAuth2 or refresh token
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token provider interface
|
|
3
|
+
*
|
|
4
|
+
* Provider implementations are in separate packages:
|
|
5
|
+
* - @mcp-abap-adt/auth-providers - XSUAA and BTP providers
|
|
6
|
+
*/
|
|
7
|
+
export type { ITokenProvider, TokenProviderOptions, TokenProviderResult } from './ITokenProvider';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/stores/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Storage
|
|
2
|
+
* Storage interfaces for AuthBroker
|
|
3
|
+
*
|
|
4
|
+
* Store implementations are in separate packages:
|
|
5
|
+
* - @mcp-abap-adt/auth-stores-btp - BTP and ABAP stores
|
|
3
6
|
*/
|
|
4
|
-
export { IServiceKeyStore, ISessionStore,
|
|
5
|
-
export { FileServiceKeyStore } from './FileServiceKeyStore';
|
|
6
|
-
export { FileSessionStore } from './FileSessionStore';
|
|
7
|
-
export { SafeSessionStore } from './SafeSessionStore';
|
|
7
|
+
export type { IServiceKeyStore, ISessionStore, IAuthorizationConfig, IConnectionConfig } from './interfaces';
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stores/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stores/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/stores/index.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Storage
|
|
3
|
+
* Storage interfaces for AuthBroker
|
|
4
|
+
*
|
|
5
|
+
* Store implementations are in separate packages:
|
|
6
|
+
* - @mcp-abap-adt/auth-stores-btp - BTP and ABAP stores
|
|
4
7
|
*/
|
|
5
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SafeSessionStore = exports.FileSessionStore = exports.FileServiceKeyStore = void 0;
|
|
7
|
-
var FileServiceKeyStore_1 = require("./FileServiceKeyStore");
|
|
8
|
-
Object.defineProperty(exports, "FileServiceKeyStore", { enumerable: true, get: function () { return FileServiceKeyStore_1.FileServiceKeyStore; } });
|
|
9
|
-
var FileSessionStore_1 = require("./FileSessionStore");
|
|
10
|
-
Object.defineProperty(exports, "FileSessionStore", { enumerable: true, get: function () { return FileSessionStore_1.FileSessionStore; } });
|
|
11
|
-
var SafeSessionStore_1 = require("./SafeSessionStore");
|
|
12
|
-
Object.defineProperty(exports, "SafeSessionStore", { enumerable: true, get: function () { return SafeSessionStore_1.SafeSessionStore; } });
|
|
@@ -1,51 +1,117 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Storage interfaces for AuthBroker
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* for service keys and session data (tokens, configuration).
|
|
4
|
+
* All interfaces are defined here. Types (type aliases) are in types.ts.
|
|
6
5
|
*/
|
|
7
|
-
import {
|
|
6
|
+
import type { IConfig } from '../types';
|
|
7
|
+
/**
|
|
8
|
+
* Authorization configuration - values needed for obtaining and refreshing tokens
|
|
9
|
+
* Returned by stores with actual values (not file paths)
|
|
10
|
+
*/
|
|
11
|
+
export interface IAuthorizationConfig {
|
|
12
|
+
/** UAA URL for token refresh */
|
|
13
|
+
uaaUrl: string;
|
|
14
|
+
/** UAA client ID */
|
|
15
|
+
uaaClientId: string;
|
|
16
|
+
/** UAA client secret */
|
|
17
|
+
uaaClientSecret: string;
|
|
18
|
+
/** Refresh token for token renewal (optional) */
|
|
19
|
+
refreshToken?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Connection configuration - values needed for connecting to services
|
|
23
|
+
* Returned by stores with actual values (not file paths)
|
|
24
|
+
*/
|
|
25
|
+
export interface IConnectionConfig {
|
|
26
|
+
/** Service URL (SAP/ABAP/MCP URL) - undefined for XSUAA if not provided */
|
|
27
|
+
serviceUrl?: string;
|
|
28
|
+
/** Authorization token (JWT token) */
|
|
29
|
+
authorizationToken: string;
|
|
30
|
+
/** SAP client number (optional, for ABAP/BTP) */
|
|
31
|
+
sapClient?: string;
|
|
32
|
+
/** Language (optional, for ABAP/BTP) */
|
|
33
|
+
language?: string;
|
|
34
|
+
}
|
|
8
35
|
/**
|
|
9
36
|
* Interface for storing and retrieving service keys
|
|
10
37
|
*
|
|
11
|
-
* Service keys contain UAA credentials and
|
|
12
|
-
* Default implementation: FileServiceKeyStore (reads from {destination}.json files)
|
|
38
|
+
* Service keys contain UAA credentials and connection URLs.
|
|
13
39
|
*/
|
|
14
40
|
export interface IServiceKeyStore {
|
|
15
41
|
/**
|
|
16
|
-
* Get service key for destination
|
|
42
|
+
* Get raw service key for destination
|
|
43
|
+
* @param destination Destination name (e.g., "TRIAL")
|
|
44
|
+
* @returns Service key object (implementation-specific) or null if not found
|
|
45
|
+
*/
|
|
46
|
+
getServiceKey(destination: string): Promise<IConfig | null>;
|
|
47
|
+
/**
|
|
48
|
+
* Get authorization configuration from service key
|
|
49
|
+
* Returns values needed for obtaining and refreshing tokens
|
|
50
|
+
* @param destination Destination name (e.g., "TRIAL")
|
|
51
|
+
* @returns IAuthorizationConfig with actual values or null if not found
|
|
52
|
+
*/
|
|
53
|
+
getAuthorizationConfig(destination: string): Promise<IAuthorizationConfig | null>;
|
|
54
|
+
/**
|
|
55
|
+
* Get connection configuration from service key
|
|
56
|
+
* Returns values needed for connecting to services
|
|
17
57
|
* @param destination Destination name (e.g., "TRIAL")
|
|
18
|
-
* @returns
|
|
58
|
+
* @returns IConnectionConfig with actual values or null if not found
|
|
19
59
|
*/
|
|
20
|
-
|
|
60
|
+
getConnectionConfig(destination: string): Promise<IConnectionConfig | null>;
|
|
21
61
|
}
|
|
22
62
|
/**
|
|
23
|
-
* Interface for
|
|
63
|
+
* Interface for session stores - stores and retrieves session data
|
|
24
64
|
*
|
|
25
|
-
* Session
|
|
26
|
-
* Default implementation: FileSessionStore (reads/writes {destination}.env files)
|
|
65
|
+
* Session stores handle loading, saving, and managing session data (tokens, configuration).
|
|
27
66
|
*/
|
|
28
67
|
export interface ISessionStore {
|
|
29
68
|
/**
|
|
30
69
|
* Load session configuration for destination
|
|
31
|
-
*
|
|
32
|
-
*
|
|
70
|
+
* Returns optional composition of IAuthorizationConfig and IConnectionConfig
|
|
71
|
+
* Can contain either authorization config, or connection config, or both
|
|
72
|
+
* @param destination Destination name (e.g., "TRIAL" or "mcp")
|
|
73
|
+
* @returns IConfig with actual values or null if not found
|
|
33
74
|
*/
|
|
34
|
-
loadSession(destination: string): Promise<
|
|
75
|
+
loadSession(destination: string): Promise<IConfig | null>;
|
|
35
76
|
/**
|
|
36
77
|
* Save session configuration for destination
|
|
37
|
-
*
|
|
38
|
-
* @param
|
|
78
|
+
* Accepts IConfig (optional composition) or internal representation (for backward compatibility)
|
|
79
|
+
* @param destination Destination name (e.g., "TRIAL" or "mcp")
|
|
80
|
+
* @param config IConfig or internal session configuration to save
|
|
39
81
|
*/
|
|
40
|
-
saveSession(destination: string, config:
|
|
82
|
+
saveSession(destination: string, config: IConfig | unknown): Promise<void>;
|
|
41
83
|
/**
|
|
42
84
|
* Delete session for destination (optional)
|
|
43
|
-
* @param destination Destination name (e.g., "TRIAL")
|
|
85
|
+
* @param destination Destination name (e.g., "TRIAL" or "mcp")
|
|
44
86
|
*/
|
|
45
87
|
deleteSession?(destination: string): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Get authorization configuration with actual values (not file paths)
|
|
90
|
+
* Returns values needed for obtaining and refreshing tokens
|
|
91
|
+
* @param destination Destination name (e.g., "TRIAL" or "mcp")
|
|
92
|
+
* @returns IAuthorizationConfig with actual values or null if not found
|
|
93
|
+
*/
|
|
94
|
+
getAuthorizationConfig(destination: string): Promise<IAuthorizationConfig | null>;
|
|
95
|
+
/**
|
|
96
|
+
* Get connection configuration with actual values (not file paths)
|
|
97
|
+
* Returns values needed for connecting to services
|
|
98
|
+
* @param destination Destination name (e.g., "TRIAL" or "mcp")
|
|
99
|
+
* @returns IConnectionConfig with actual values or null if not found
|
|
100
|
+
*/
|
|
101
|
+
getConnectionConfig(destination: string): Promise<IConnectionConfig | null>;
|
|
102
|
+
/**
|
|
103
|
+
* Set authorization configuration
|
|
104
|
+
* Updates values needed for obtaining and refreshing tokens
|
|
105
|
+
* @param destination Destination name (e.g., "TRIAL" or "mcp")
|
|
106
|
+
* @param config IAuthorizationConfig with values to set
|
|
107
|
+
*/
|
|
108
|
+
setAuthorizationConfig(destination: string, config: IAuthorizationConfig): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Set connection configuration
|
|
111
|
+
* Updates values needed for connecting to services
|
|
112
|
+
* @param destination Destination name (e.g., "TRIAL" or "mcp")
|
|
113
|
+
* @param config IConnectionConfig with values to set
|
|
114
|
+
*/
|
|
115
|
+
setConnectionConfig(destination: string, config: IConnectionConfig): Promise<void>;
|
|
46
116
|
}
|
|
47
|
-
/** @deprecated Use IServiceKeyStore instead */
|
|
48
|
-
export type ServiceKeyStore = IServiceKeyStore;
|
|
49
|
-
/** @deprecated Use ISessionStore instead */
|
|
50
|
-
export type SessionStore = ISessionStore;
|
|
51
117
|
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/stores/interfaces.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/stores/interfaces.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,wBAAwB;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,iDAAiD;IACjD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAE5D;;;;;OAKG;IACH,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAElF;;;;;OAKG;IACH,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;CAC7E;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;OAMG;IACH,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAE1D;;;;;OAKG;IACH,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3E;;;OAGG;IACH,aAAa,CAAC,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnD;;;;;OAKG;IACH,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAElF;;;;;OAKG;IACH,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IAE5E;;;;;OAKG;IACH,sBAAsB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzF;;;;;OAKG;IACH,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpF"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Storage interfaces for AuthBroker
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* for service keys and session data (tokens, configuration).
|
|
5
|
+
* All interfaces are defined here. Types (type aliases) are in types.ts.
|
|
7
6
|
*/
|
|
8
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/types.d.ts
CHANGED
|
@@ -1,37 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type definitions for auth-broker package
|
|
3
|
+
*
|
|
4
|
+
* Type aliases (type) are defined here. Interfaces are in stores/interfaces.ts.
|
|
3
5
|
*/
|
|
6
|
+
import type { IAuthorizationConfig, IConnectionConfig } from './stores/interfaces';
|
|
4
7
|
/**
|
|
5
|
-
*
|
|
8
|
+
* Configuration - optional composition of authorization and connection configuration
|
|
9
|
+
* Can contain either authorization config, or connection config, or both
|
|
6
10
|
*/
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
sapClient?: string;
|
|
10
|
-
jwtToken: string;
|
|
11
|
-
refreshToken?: string;
|
|
12
|
-
uaaUrl?: string;
|
|
13
|
-
uaaClientId?: string;
|
|
14
|
-
uaaClientSecret?: string;
|
|
15
|
-
language?: string;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Service key structure from JSON file
|
|
19
|
-
*/
|
|
20
|
-
export interface ServiceKey {
|
|
21
|
-
url?: string;
|
|
22
|
-
abap?: {
|
|
23
|
-
url?: string;
|
|
24
|
-
client?: string;
|
|
25
|
-
language?: string;
|
|
26
|
-
};
|
|
27
|
-
sap_url?: string;
|
|
28
|
-
client?: string;
|
|
29
|
-
sap_client?: string;
|
|
30
|
-
language?: string;
|
|
31
|
-
uaa: {
|
|
32
|
-
url: string;
|
|
33
|
-
clientid: string;
|
|
34
|
-
clientsecret: string;
|
|
35
|
-
};
|
|
36
|
-
}
|
|
11
|
+
export type IConfig = Partial<IAuthorizationConfig> & Partial<IConnectionConfig>;
|
|
12
|
+
export type { IAuthorizationConfig, IConnectionConfig, IServiceKeyStore, ISessionStore, } from './stores/interfaces';
|
|
37
13
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEnF;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAGjF,YAAY,EACV,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,GACd,MAAM,qBAAqB,CAAC"}
|
package/dist/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-abap-adt/auth-broker",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
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",
|
|
@@ -41,24 +41,31 @@
|
|
|
41
41
|
"build:fast": "npx tsc -p tsconfig.json",
|
|
42
42
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
|
|
43
43
|
"test:check": "npx tsc --noEmit",
|
|
44
|
-
"prepublishOnly": "npm run build"
|
|
44
|
+
"prepublishOnly": "npm run build",
|
|
45
|
+
"generate-env": "tsx bin/generate-env-from-service-key.ts"
|
|
46
|
+
},
|
|
47
|
+
"bin": {
|
|
48
|
+
"generate-env-from-service-key": "./bin/generate-env-from-service-key.ts"
|
|
45
49
|
},
|
|
46
50
|
"engines": {
|
|
47
51
|
"node": ">=18.0.0"
|
|
48
52
|
},
|
|
49
53
|
"dependencies": {
|
|
50
54
|
"@mcp-abap-adt/connection": "^0.1.13",
|
|
51
|
-
"
|
|
52
|
-
"dotenv": "^17.2.1",
|
|
53
|
-
"express": "^5.1.0",
|
|
54
|
-
"open": "^11.0.0"
|
|
55
|
+
"@mcp-abap-adt/logger": "^0.1.0"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
58
|
+
"@mcp-abap-adt/auth-providers": "^0.1.0",
|
|
59
|
+
"@mcp-abap-adt/auth-stores-btp": "^0.1.0",
|
|
60
|
+
"@mcp-abap-adt/auth-stores-xsuaa": "^0.1.0",
|
|
57
61
|
"@types/express": "^5.0.5",
|
|
58
62
|
"@types/jest": "^30.0.0",
|
|
63
|
+
"@types/js-yaml": "^4.0.9",
|
|
59
64
|
"@types/node": "^24.2.1",
|
|
60
65
|
"jest": "^30.2.0",
|
|
66
|
+
"js-yaml": "^4.1.1",
|
|
61
67
|
"ts-jest": "^29.2.5",
|
|
68
|
+
"tsx": "^4.21.0",
|
|
62
69
|
"typescript": "^5.9.2"
|
|
63
70
|
}
|
|
64
71
|
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Common test helpers for AuthBroker tests
|
|
3
|
-
*/
|
|
4
|
-
import { AuthBroker } from '../AuthBroker';
|
|
5
|
-
export declare const TEST_DESTINATIONS_PATH: string;
|
|
6
|
-
export interface TestBrokers {
|
|
7
|
-
tempDir: string;
|
|
8
|
-
broker: AuthBroker;
|
|
9
|
-
testDestinationsBroker: AuthBroker;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Setup test brokers for a test suite
|
|
13
|
-
*/
|
|
14
|
-
export declare function setupTestBrokers(testName: string): TestBrokers;
|
|
15
|
-
/**
|
|
16
|
-
* Cleanup test brokers
|
|
17
|
-
*/
|
|
18
|
-
export declare function cleanupTestBrokers(brokers: TestBrokers): void;
|
|
19
|
-
/**
|
|
20
|
-
* Check if NO_EXISTS.json exists and skip test if it does
|
|
21
|
-
*/
|
|
22
|
-
export declare function checkNoExistsFile(): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Prepare Test 2: Remove TRIAL.env if exists, check for TRIAL.json
|
|
25
|
-
*/
|
|
26
|
-
export declare function prepareTest2(): {
|
|
27
|
-
envFile: string;
|
|
28
|
-
serviceKeyPath: string;
|
|
29
|
-
shouldSkip: boolean;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Prepare Test 3: Check for TRIAL.json and TRIAL.env
|
|
33
|
-
*/
|
|
34
|
-
export declare function prepareTest3(): {
|
|
35
|
-
envFile: string;
|
|
36
|
-
serviceKeyPath: string;
|
|
37
|
-
sapUrl: string;
|
|
38
|
-
shouldSkip: boolean;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Verify .env file contains required tokens
|
|
42
|
-
*/
|
|
43
|
-
export declare function verifyEnvFile(envFile: string, requireRefreshToken?: boolean): void;
|
|
44
|
-
//# sourceMappingURL=testHelpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testHelpers.d.ts","sourceRoot":"","sources":["../../src/__tests__/testHelpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,eAAO,MAAM,sBAAsB,QAAsF,CAAC;AAE1H,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,CAAC;IACnB,sBAAsB,EAAE,UAAU,CAAC;CACpC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CAY9D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAM7D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAM3C;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAe/F;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAsB/G;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,mBAAmB,GAAE,OAAe,GAAG,IAAI,CAOzF"}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Common test helpers for AuthBroker tests
|
|
4
|
-
*/
|
|
5
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
-
}
|
|
11
|
-
Object.defineProperty(o, k2, desc);
|
|
12
|
-
}) : (function(o, m, k, k2) {
|
|
13
|
-
if (k2 === undefined) k2 = k;
|
|
14
|
-
o[k2] = m[k];
|
|
15
|
-
}));
|
|
16
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
-
}) : function(o, v) {
|
|
19
|
-
o["default"] = v;
|
|
20
|
-
});
|
|
21
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
-
var ownKeys = function(o) {
|
|
23
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
-
var ar = [];
|
|
25
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
-
return ar;
|
|
27
|
-
};
|
|
28
|
-
return ownKeys(o);
|
|
29
|
-
};
|
|
30
|
-
return function (mod) {
|
|
31
|
-
if (mod && mod.__esModule) return mod;
|
|
32
|
-
var result = {};
|
|
33
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
-
__setModuleDefault(result, mod);
|
|
35
|
-
return result;
|
|
36
|
-
};
|
|
37
|
-
})();
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.TEST_DESTINATIONS_PATH = void 0;
|
|
40
|
-
exports.setupTestBrokers = setupTestBrokers;
|
|
41
|
-
exports.cleanupTestBrokers = cleanupTestBrokers;
|
|
42
|
-
exports.checkNoExistsFile = checkNoExistsFile;
|
|
43
|
-
exports.prepareTest2 = prepareTest2;
|
|
44
|
-
exports.prepareTest3 = prepareTest3;
|
|
45
|
-
exports.verifyEnvFile = verifyEnvFile;
|
|
46
|
-
const path = __importStar(require("path"));
|
|
47
|
-
const os = __importStar(require("os"));
|
|
48
|
-
const fs = __importStar(require("fs"));
|
|
49
|
-
const AuthBroker_1 = require("../AuthBroker");
|
|
50
|
-
const logger_1 = require("../logger");
|
|
51
|
-
const stores_1 = require("../stores");
|
|
52
|
-
// Fixed test destinations path - user can place service keys here
|
|
53
|
-
exports.TEST_DESTINATIONS_PATH = process.env.TEST_DESTINATIONS_PATH || path.join(process.cwd(), 'test-destinations');
|
|
54
|
-
/**
|
|
55
|
-
* Setup test brokers for a test suite
|
|
56
|
-
*/
|
|
57
|
-
function setupTestBrokers(testName) {
|
|
58
|
-
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), `auth-broker-${testName}-test-`));
|
|
59
|
-
const broker = new AuthBroker_1.AuthBroker({
|
|
60
|
-
serviceKeyStore: new stores_1.FileServiceKeyStore([tempDir]),
|
|
61
|
-
sessionStore: new stores_1.FileSessionStore([tempDir]),
|
|
62
|
-
}, undefined, logger_1.testLogger);
|
|
63
|
-
const testDestinationsBroker = new AuthBroker_1.AuthBroker({
|
|
64
|
-
serviceKeyStore: new stores_1.FileServiceKeyStore([exports.TEST_DESTINATIONS_PATH]),
|
|
65
|
-
sessionStore: new stores_1.FileSessionStore([exports.TEST_DESTINATIONS_PATH]),
|
|
66
|
-
}, undefined, logger_1.testLogger);
|
|
67
|
-
return { tempDir, broker, testDestinationsBroker };
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Cleanup test brokers
|
|
71
|
-
*/
|
|
72
|
-
function cleanupTestBrokers(brokers) {
|
|
73
|
-
if (brokers.tempDir && fs.existsSync(brokers.tempDir)) {
|
|
74
|
-
fs.rmSync(brokers.tempDir, { recursive: true, force: true });
|
|
75
|
-
}
|
|
76
|
-
brokers.broker.clearAllCache();
|
|
77
|
-
brokers.testDestinationsBroker.clearAllCache();
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Check if NO_EXISTS.json exists and skip test if it does
|
|
81
|
-
*/
|
|
82
|
-
function checkNoExistsFile() {
|
|
83
|
-
const noExistsJson = path.join(exports.TEST_DESTINATIONS_PATH, 'NO_EXISTS.json');
|
|
84
|
-
if (fs.existsSync(noExistsJson)) {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Prepare Test 2: Remove TRIAL.env if exists, check for TRIAL.json
|
|
91
|
-
*/
|
|
92
|
-
function prepareTest2() {
|
|
93
|
-
const envFile = path.join(exports.TEST_DESTINATIONS_PATH, 'TRIAL.env');
|
|
94
|
-
const serviceKeyPath = path.join(exports.TEST_DESTINATIONS_PATH, 'TRIAL.json');
|
|
95
|
-
// Remove TRIAL.env if it exists before Test 2
|
|
96
|
-
if (fs.existsSync(envFile)) {
|
|
97
|
-
fs.unlinkSync(envFile);
|
|
98
|
-
}
|
|
99
|
-
// Check if service key exists
|
|
100
|
-
if (!fs.existsSync(serviceKeyPath)) {
|
|
101
|
-
return { envFile, serviceKeyPath, shouldSkip: true };
|
|
102
|
-
}
|
|
103
|
-
return { envFile, serviceKeyPath, shouldSkip: false };
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Prepare Test 3: Check for TRIAL.json and TRIAL.env
|
|
107
|
-
*/
|
|
108
|
-
function prepareTest3() {
|
|
109
|
-
const serviceKeyPath = path.join(exports.TEST_DESTINATIONS_PATH, 'TRIAL.json');
|
|
110
|
-
const envFile = path.join(exports.TEST_DESTINATIONS_PATH, 'TRIAL.env');
|
|
111
|
-
// Check if service key exists
|
|
112
|
-
if (!fs.existsSync(serviceKeyPath)) {
|
|
113
|
-
return { envFile, serviceKeyPath, sapUrl: '', shouldSkip: true };
|
|
114
|
-
}
|
|
115
|
-
// Test 3 requires TRIAL.env file to exist
|
|
116
|
-
if (!fs.existsSync(envFile)) {
|
|
117
|
-
return { envFile, serviceKeyPath, sapUrl: '', shouldSkip: true };
|
|
118
|
-
}
|
|
119
|
-
const serviceKey = JSON.parse(fs.readFileSync(serviceKeyPath, 'utf8'));
|
|
120
|
-
const envContent = fs.readFileSync(envFile, 'utf8');
|
|
121
|
-
// Extract SAP_URL from .env or service key
|
|
122
|
-
const urlMatch = envContent.match(/SAP_URL=(.+)/);
|
|
123
|
-
const sapUrl = urlMatch ? urlMatch[1].trim() : (serviceKey.url || serviceKey.abap?.url || serviceKey.sap_url);
|
|
124
|
-
return { envFile, serviceKeyPath, sapUrl, shouldSkip: false };
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Verify .env file contains required tokens
|
|
128
|
-
*/
|
|
129
|
-
function verifyEnvFile(envFile, requireRefreshToken = false) {
|
|
130
|
-
expect(fs.existsSync(envFile)).toBe(true);
|
|
131
|
-
const envContent = fs.readFileSync(envFile, 'utf8');
|
|
132
|
-
expect(envContent).toContain('SAP_JWT_TOKEN=');
|
|
133
|
-
if (requireRefreshToken) {
|
|
134
|
-
expect(envContent).toContain('SAP_REFRESH_TOKEN=');
|
|
135
|
-
}
|
|
136
|
-
}
|
package/dist/browserAuth.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Browser authentication - OAuth2 flow for obtaining tokens
|
|
3
|
-
*/
|
|
4
|
-
import { ServiceKey } from './types';
|
|
5
|
-
import { Logger } from './logger';
|
|
6
|
-
/**
|
|
7
|
-
* Start browser authentication flow
|
|
8
|
-
* @param serviceKey Service key with UAA configuration
|
|
9
|
-
* @param browser Browser name (chrome, edge, firefox, system, none)
|
|
10
|
-
* @param logger Optional logger instance. If not provided, uses default logger.
|
|
11
|
-
* @returns Promise that resolves to tokens
|
|
12
|
-
*/
|
|
13
|
-
export declare function startBrowserAuth(serviceKey: ServiceKey, browser?: string, logger?: Logger): Promise<{
|
|
14
|
-
accessToken: string;
|
|
15
|
-
refreshToken?: string;
|
|
16
|
-
}>;
|
|
17
|
-
//# sourceMappingURL=browserAuth.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"browserAuth.d.ts","sourceRoot":"","sources":["../src/browserAuth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,MAAM,EAAiB,MAAM,UAAU,CAAC;AA4DjD;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE,MAAiB,EAC1B,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAyMzD"}
|