@mcp-abap-adt/auth-providers 0.1.0 → 0.1.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 +38 -4
- package/README.md +52 -0
- package/dist/auth/browserAuth.d.ts +2 -3
- package/dist/auth/browserAuth.d.ts.map +1 -1
- package/dist/auth/browserAuth.js +2 -2
- package/dist/providers/BtpTokenProvider.d.ts +2 -3
- package/dist/providers/BtpTokenProvider.d.ts.map +1 -1
- package/dist/providers/XsuaaTokenProvider.d.ts +2 -3
- package/dist/providers/XsuaaTokenProvider.d.ts.map +1 -1
- package/package.json +4 -6
package/CHANGELOG.md
CHANGED
|
@@ -7,7 +7,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
## [0.1.
|
|
10
|
+
## [0.1.2] - 2025-12-05
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- **Dependency Injection**: Moved `@mcp-abap-adt/auth-stores` and `@mcp-abap-adt/logger` from `dependencies` to `devDependencies`
|
|
14
|
+
- These packages are only used in tests, not in production code
|
|
15
|
+
- Logger is injected via `ITokenProviderOptions.logger?: ILogger` interface in production code
|
|
16
|
+
- Auth stores are not used in production code (consumers inject their own store implementations)
|
|
17
|
+
|
|
18
|
+
### Removed
|
|
19
|
+
- **Unused Dependencies**: Removed `@mcp-abap-adt/connection` dependency (not used in production code)
|
|
20
|
+
|
|
21
|
+
## [0.1.1] - 2025-12-04
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
- **Interfaces Package Integration**: Migrated to use `@mcp-abap-adt/interfaces` package for all interface definitions
|
|
25
|
+
- All interfaces now imported from shared package
|
|
26
|
+
- Dependency on `@mcp-abap-adt/interfaces@^0.1.1` added
|
|
27
|
+
- Updated `@mcp-abap-adt/connection` dependency to `^0.1.14`
|
|
28
|
+
- Updated `@mcp-abap-adt/auth-stores` dependency to `^0.1.3`
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
- **Interface Renaming**: Interfaces renamed to follow `I` prefix convention:
|
|
32
|
+
- `TokenProviderResult` → `ITokenProviderResult` (type alias for backward compatibility)
|
|
33
|
+
- `TokenProviderOptions` → `ITokenProviderOptions` (type alias for backward compatibility)
|
|
34
|
+
- Old names still work via type aliases for backward compatibility
|
|
35
|
+
- **Logger Interface**: Updated to use `ILogger` from `@mcp-abap-adt/interfaces` instead of `Logger` from `@mcp-abap-adt/logger`
|
|
36
|
+
- `browserAuth.ts` now uses `ILogger` interface with basic methods (info, error, warn, debug)
|
|
37
|
+
- Browser-specific logging methods (browserUrl, browserOpening) now use basic `info` and `debug` methods
|
|
38
|
+
|
|
39
|
+
### Fixed
|
|
40
|
+
- **BtpTokenProvider Integration Tests**: Fixed to use ABAP destination and `AbapServiceKeyStore` instead of XSUAA
|
|
41
|
+
- BTP and ABAP use the same authentication flow and service key format
|
|
42
|
+
- Tests now correctly use `getAbapDestination` and `hasRealConfig(config, 'abap')`
|
|
43
|
+
- Tests now use `AbapServiceKeyStore` instead of `BtpServiceKeyStore` for loading service keys
|
|
44
|
+
|
|
45
|
+
## [0.1.0] - 2025-12-04
|
|
11
46
|
|
|
12
47
|
### Added
|
|
13
48
|
- Initial release
|
|
@@ -23,10 +58,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
23
58
|
- YAML-based test configuration (`tests/test-config.yaml.template`)
|
|
24
59
|
- Tests for service key to session conversion
|
|
25
60
|
- Tests for token validation
|
|
26
|
-
- BTP tests use `
|
|
61
|
+
- BTP tests use `AbapServiceKeyStore` (same format as ABAP) and `BtpSessionStore` (without `sapUrl`)
|
|
27
62
|
- ABAP tests use `AbapServiceKeyStore` and `AbapSessionStore` (with `sapUrl`)
|
|
28
|
-
- BTP tests use `
|
|
29
|
-
- ABAP tests use `abap.destination` from config
|
|
63
|
+
- Both BTP and ABAP tests use `abap.destination` from config (same authentication flow)
|
|
30
64
|
|
|
31
65
|
### Fixed
|
|
32
66
|
- **Integration Tests**: Corrected BTP and ABAP test separation
|
package/README.md
CHANGED
|
@@ -17,6 +17,58 @@ This package implements the `ITokenProvider` interface from `@mcp-abap-adt/auth-
|
|
|
17
17
|
- **XsuaaTokenProvider** - Uses `client_credentials` grant type (no browser required)
|
|
18
18
|
- **BtpTokenProvider** - Uses browser-based OAuth2 or refresh token flow
|
|
19
19
|
|
|
20
|
+
## Responsibilities and Design Principles
|
|
21
|
+
|
|
22
|
+
### Core Development Principle
|
|
23
|
+
|
|
24
|
+
**Interface-Only Communication**: This package follows a fundamental development principle: **all interactions with external dependencies happen ONLY through interfaces**. The code knows **NOTHING beyond what is defined in the interfaces**.
|
|
25
|
+
|
|
26
|
+
This means:
|
|
27
|
+
- Does not know about concrete implementation classes from other packages
|
|
28
|
+
- Does not know about internal data structures or methods not defined in interfaces
|
|
29
|
+
- Does not make assumptions about implementation behavior beyond interface contracts
|
|
30
|
+
- Does not access properties or methods not explicitly defined in interfaces
|
|
31
|
+
|
|
32
|
+
This principle ensures:
|
|
33
|
+
- **Loose coupling**: Providers are decoupled from concrete implementations in other packages
|
|
34
|
+
- **Flexibility**: New implementations can be added without modifying providers
|
|
35
|
+
- **Testability**: Easy to mock dependencies for testing
|
|
36
|
+
- **Maintainability**: Changes to implementations don't affect providers
|
|
37
|
+
|
|
38
|
+
### Package Responsibilities
|
|
39
|
+
|
|
40
|
+
This package is responsible for:
|
|
41
|
+
|
|
42
|
+
1. **Implementing token provider interface**: Provides concrete implementations of `ITokenProvider` interface defined in `@mcp-abap-adt/auth-broker`
|
|
43
|
+
2. **Token acquisition**: Handles OAuth2 flows (browser-based, refresh token, client credentials) to obtain JWT tokens
|
|
44
|
+
3. **Token validation**: Validates tokens by making HTTP requests to service endpoints
|
|
45
|
+
4. **OAuth2 flows**: Manages browser-based OAuth2 authorization code flow and refresh token flow
|
|
46
|
+
|
|
47
|
+
#### What This Package Does
|
|
48
|
+
|
|
49
|
+
- **Implements ITokenProvider**: Provides concrete implementations (`XsuaaTokenProvider`, `BtpTokenProvider`)
|
|
50
|
+
- **Handles OAuth2 flows**: Browser-based OAuth2, refresh token, and client credentials grant types
|
|
51
|
+
- **Obtains tokens**: Makes HTTP requests to UAA endpoints to obtain JWT tokens
|
|
52
|
+
- **Validates tokens**: Tests token validity by making requests to service endpoints
|
|
53
|
+
- **Returns connection config**: Returns `IConnectionConfig` with `authorizationToken` and optionally `serviceUrl` (if known)
|
|
54
|
+
|
|
55
|
+
#### What This Package Does NOT Do
|
|
56
|
+
|
|
57
|
+
- **Does NOT store tokens**: Token storage is handled by `@mcp-abap-adt/auth-stores`
|
|
58
|
+
- **Does NOT orchestrate authentication**: Token lifecycle management is handled by `@mcp-abap-adt/auth-broker`
|
|
59
|
+
- **Does NOT know about service keys**: Service key loading is handled by stores
|
|
60
|
+
- **Does NOT manage sessions**: Session management is handled by stores
|
|
61
|
+
- **Does NOT return `serviceUrl` if unknown**: Providers may not return `serviceUrl` because they only handle token acquisition, not connection configuration
|
|
62
|
+
|
|
63
|
+
### External Dependencies
|
|
64
|
+
|
|
65
|
+
This package interacts with external packages **ONLY through interfaces**:
|
|
66
|
+
|
|
67
|
+
- **`@mcp-abap-adt/auth-broker`**: Uses interfaces (`ITokenProvider`, `IAuthorizationConfig`, `IConnectionConfig`) - does not know about `AuthBroker` implementation
|
|
68
|
+
- **`@mcp-abap-adt/logger`**: Uses `Logger` interface for logging - does not know about concrete logger implementation
|
|
69
|
+
- **`@mcp-abap-adt/connection`**: Uses connection utilities for token validation - interacts through well-defined functions
|
|
70
|
+
- **No direct dependencies on stores**: All interactions with stores happen through interfaces passed by consumers
|
|
71
|
+
|
|
20
72
|
## Usage
|
|
21
73
|
|
|
22
74
|
### Basic Usage
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Browser authentication - OAuth2 flow for obtaining tokens
|
|
3
3
|
*/
|
|
4
|
-
import type { IAuthorizationConfig } from '@mcp-abap-adt/
|
|
5
|
-
import type { Logger } from '@mcp-abap-adt/logger';
|
|
4
|
+
import type { IAuthorizationConfig, ILogger } from '@mcp-abap-adt/interfaces';
|
|
6
5
|
/**
|
|
7
6
|
* Start browser authentication flow
|
|
8
7
|
* @param authConfig Authorization configuration with UAA credentials
|
|
@@ -10,7 +9,7 @@ import type { Logger } from '@mcp-abap-adt/logger';
|
|
|
10
9
|
* @param logger Optional logger instance. If not provided, uses default logger.
|
|
11
10
|
* @returns Promise that resolves to tokens
|
|
12
11
|
*/
|
|
13
|
-
export declare function startBrowserAuth(authConfig: IAuthorizationConfig, browser?: string, logger?:
|
|
12
|
+
export declare function startBrowserAuth(authConfig: IAuthorizationConfig, browser?: string, logger?: ILogger): Promise<{
|
|
14
13
|
accessToken: string;
|
|
15
14
|
refreshToken?: string;
|
|
16
15
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browserAuth.d.ts","sourceRoot":"","sources":["../../src/auth/browserAuth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EAAE,oBAAoB,EAAE,
|
|
1
|
+
{"version":3,"file":"browserAuth.d.ts","sourceRoot":"","sources":["../../src/auth/browserAuth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAkF9E;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,oBAAoB,EAChC,OAAO,GAAE,MAAiB,EAC1B,MAAM,CAAC,EAAE,OAAO,GACf,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAkSzD"}
|
package/dist/auth/browserAuth.js
CHANGED
|
@@ -116,8 +116,8 @@ async function startBrowserAuth(authConfig, browser = 'system', logger) {
|
|
|
116
116
|
info: (msg) => logger.info(msg),
|
|
117
117
|
debug: (msg) => logger.debug(msg),
|
|
118
118
|
error: (msg) => logger.error(msg),
|
|
119
|
-
browserUrl: (url) => logger.
|
|
120
|
-
browserOpening: () => logger.
|
|
119
|
+
browserUrl: (url) => logger.info(`🔗 Open in browser: ${url}`),
|
|
120
|
+
browserOpening: () => logger.debug('🌐 Opening browser for authentication...'),
|
|
121
121
|
} : defaultLogger;
|
|
122
122
|
return new Promise((originalResolve, originalReject) => {
|
|
123
123
|
let timeoutId = null;
|
|
@@ -4,15 +4,14 @@
|
|
|
4
4
|
* Uses browser-based OAuth2 or refresh token to obtain tokens.
|
|
5
5
|
* For ABAP and full-scope BTP connections.
|
|
6
6
|
*/
|
|
7
|
-
import type { ITokenProvider,
|
|
8
|
-
import type { IAuthorizationConfig } from '@mcp-abap-adt/auth-broker';
|
|
7
|
+
import type { ITokenProvider, ITokenProviderOptions, ITokenProviderResult, IAuthorizationConfig } from '@mcp-abap-adt/interfaces';
|
|
9
8
|
/**
|
|
10
9
|
* BTP/ABAP token provider implementation
|
|
11
10
|
*
|
|
12
11
|
* Uses browser-based OAuth2 (if no refresh token) or refresh token flow.
|
|
13
12
|
*/
|
|
14
13
|
export declare class BtpTokenProvider implements ITokenProvider {
|
|
15
|
-
getConnectionConfig(authConfig: IAuthorizationConfig, options?:
|
|
14
|
+
getConnectionConfig(authConfig: IAuthorizationConfig, options?: ITokenProviderOptions): Promise<ITokenProviderResult>;
|
|
16
15
|
validateToken(token: string, serviceUrl?: string): Promise<boolean>;
|
|
17
16
|
}
|
|
18
17
|
//# sourceMappingURL=BtpTokenProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BtpTokenProvider.d.ts","sourceRoot":"","sources":["../../src/providers/BtpTokenProvider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"BtpTokenProvider.d.ts","sourceRoot":"","sources":["../../src/providers/BtpTokenProvider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAKlI;;;;GAIG;AACH,qBAAa,gBAAiB,YAAW,cAAc;IAC/C,mBAAmB,CACvB,UAAU,EAAE,oBAAoB,EAChC,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,oBAAoB,CAAC;IAmC1B,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CA0C1E"}
|
|
@@ -4,15 +4,14 @@
|
|
|
4
4
|
* Uses client_credentials grant type to obtain tokens (no browser required).
|
|
5
5
|
* For XSUAA service keys with reduced scope access.
|
|
6
6
|
*/
|
|
7
|
-
import type { ITokenProvider,
|
|
8
|
-
import type { IAuthorizationConfig } from '@mcp-abap-adt/auth-broker';
|
|
7
|
+
import type { ITokenProvider, ITokenProviderOptions, ITokenProviderResult, IAuthorizationConfig } from '@mcp-abap-adt/interfaces';
|
|
9
8
|
/**
|
|
10
9
|
* XSUAA token provider implementation
|
|
11
10
|
*
|
|
12
11
|
* Uses client_credentials grant type - no browser, no refresh token needed.
|
|
13
12
|
*/
|
|
14
13
|
export declare class XsuaaTokenProvider implements ITokenProvider {
|
|
15
|
-
getConnectionConfig(authConfig: IAuthorizationConfig, options?:
|
|
14
|
+
getConnectionConfig(authConfig: IAuthorizationConfig, options?: ITokenProviderOptions): Promise<ITokenProviderResult>;
|
|
16
15
|
validateToken(token: string, serviceUrl?: string): Promise<boolean>;
|
|
17
16
|
}
|
|
18
17
|
//# sourceMappingURL=XsuaaTokenProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XsuaaTokenProvider.d.ts","sourceRoot":"","sources":["../../src/providers/XsuaaTokenProvider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"XsuaaTokenProvider.d.ts","sourceRoot":"","sources":["../../src/providers/XsuaaTokenProvider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAIlI;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,cAAc;IACjD,mBAAmB,CACvB,UAAU,EAAE,oBAAoB,EAChC,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,oBAAoB,CAAC;IAyB1B,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAgD1E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-abap-adt/auth-providers",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Token providers for MCP ABAP ADT auth-broker - XSUAA and BTP token providers",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -48,15 +48,14 @@
|
|
|
48
48
|
"node": ">=18.0.0"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@mcp-abap-adt/
|
|
52
|
-
"@mcp-abap-adt/connection": "^0.1.13",
|
|
53
|
-
"@mcp-abap-adt/auth-stores": "^0.1.2",
|
|
54
|
-
"@mcp-abap-adt/logger": "^0.1.0",
|
|
51
|
+
"@mcp-abap-adt/interfaces": "^0.1.1",
|
|
55
52
|
"axios": "^1.11.0",
|
|
56
53
|
"express": "^5.1.0",
|
|
57
54
|
"open": "^11.0.0"
|
|
58
55
|
},
|
|
59
56
|
"devDependencies": {
|
|
57
|
+
"@mcp-abap-adt/auth-stores": "^0.1.4",
|
|
58
|
+
"@mcp-abap-adt/logger": "^0.1.1",
|
|
60
59
|
"@types/express": "^5.0.5",
|
|
61
60
|
"@types/jest": "^30.0.0",
|
|
62
61
|
"@types/js-yaml": "^4.0.9",
|
|
@@ -67,4 +66,3 @@
|
|
|
67
66
|
"typescript": "^5.9.2"
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
|
-
|