@mcp-abap-adt/interfaces 0.2.3 → 0.2.5
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 +34 -0
- package/README.md +13 -5
- package/dist/connection/IAbapConnection.d.ts +38 -3
- package/dist/connection/IAbapConnection.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/token/ITokenProviderOptions.d.ts +4 -3
- package/dist/token/ITokenProviderOptions.d.ts.map +1 -1
- package/dist/token/ITokenRefresher.d.ts +39 -0
- package/dist/token/ITokenRefresher.d.ts.map +1 -0
- package/dist/token/ITokenRefresher.js +12 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,40 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.5] - 2025-12-21
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **ITokenRefresher Interface**: New interface for dependency injection of token refresh logic into connections
|
|
14
|
+
- `getToken(): Promise<string>` - Get current valid token (cached or refreshed)
|
|
15
|
+
- `refreshToken(): Promise<string>` - Force refresh token and save to session store
|
|
16
|
+
- Created by `AuthBroker.createTokenRefresher(destination)` and injected into `JwtAbapConnection`
|
|
17
|
+
- Enables connections to handle 401/403 errors transparently without knowing about auth internals
|
|
18
|
+
- Exported from `@mcp-abap-adt/interfaces` in token domain
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
- **IAbapConnection Simplified**: Removed implementation details from interface, keeping only consumer-facing methods
|
|
22
|
+
- Removed `getConfig()` - internal implementation detail
|
|
23
|
+
- Removed `getAuthHeaders()` - handled internally by `makeAdtRequest()`
|
|
24
|
+
- Removed `connect()` - handled internally, connection established on first request
|
|
25
|
+
- Removed `reset()` - internal method for token refresh logic
|
|
26
|
+
- Kept: `getBaseUrl()`, `getSessionId()`, `setSessionType()`, `makeAdtRequest()`
|
|
27
|
+
- This change simplifies the interface for consumers who only need to make requests
|
|
28
|
+
|
|
29
|
+
### Deprecated
|
|
30
|
+
- **IAbapConnectionExtended**: Added for backward compatibility, extends `IAbapConnection` with removed methods
|
|
31
|
+
- `getConfig()`, `getAuthHeaders()`, `connect()`, `reset()`
|
|
32
|
+
- Will be removed in next major version
|
|
33
|
+
- Use `IAbapConnection` for new code
|
|
34
|
+
|
|
35
|
+
## [0.2.4] - 2025-12-21
|
|
36
|
+
|
|
37
|
+
### Added
|
|
38
|
+
- **Headless Browser Mode**: Added `"headless"` option to `ITokenProviderOptions.browser`
|
|
39
|
+
- `"headless"`: Does not open browser, logs authentication URL and waits for manual callback
|
|
40
|
+
- Ideal for SSH sessions, remote terminals, and environments without display
|
|
41
|
+
- Differs from `"none"` which immediately rejects (for automated tests)
|
|
42
|
+
- Updated JSDoc documentation for browser option with all supported values
|
|
43
|
+
|
|
10
44
|
## [0.2.3] - 2025-12-19
|
|
11
45
|
|
|
12
46
|
### Added
|
package/README.md
CHANGED
|
@@ -163,9 +163,13 @@ This package is responsible for:
|
|
|
163
163
|
- `AuthType` - Auth type: `'jwt' | 'xsuaa' | 'basic'`
|
|
164
164
|
|
|
165
165
|
### Token Domain (`token/`)
|
|
166
|
-
- `ITokenProvider` - Token provider interface
|
|
166
|
+
- `ITokenProvider` - Token provider interface (for auth-broker to get tokens from OAuth)
|
|
167
167
|
- `ITokenProviderResult` - Result from token provider
|
|
168
168
|
- `ITokenProviderOptions` - Options for token providers
|
|
169
|
+
- `ITokenRefresher` - Token refresher interface for DI into connections
|
|
170
|
+
- Created by `AuthBroker.createTokenRefresher(destination)`
|
|
171
|
+
- Injected into `JwtAbapConnection` to enable automatic token refresh
|
|
172
|
+
- Methods: `getToken()`, `refreshToken()`
|
|
169
173
|
|
|
170
174
|
### Session Domain (`session/`)
|
|
171
175
|
- `ISessionStore` - Session storage interface
|
|
@@ -174,10 +178,14 @@ This package is responsible for:
|
|
|
174
178
|
- `IServiceKeyStore` - Service key storage interface
|
|
175
179
|
|
|
176
180
|
### Connection Domain (`connection/`)
|
|
177
|
-
- `IAbapConnection` -
|
|
178
|
-
-
|
|
179
|
-
-
|
|
180
|
-
-
|
|
181
|
+
- `IAbapConnection` - Minimal connection interface for ADT operations
|
|
182
|
+
- Consumer-facing methods only: `getBaseUrl()`, `getSessionId()`, `setSessionType()`, `makeAdtRequest()`
|
|
183
|
+
- Implementation details (auth, CSRF, cookies, token refresh) are encapsulated
|
|
184
|
+
- For JWT: token refresh handled internally via `ITokenRefresher`
|
|
185
|
+
- For Basic: no token refresh needed
|
|
186
|
+
- `IAbapConnectionExtended` - Deprecated, for backward compatibility
|
|
187
|
+
- Extends `IAbapConnection` with: `getConfig()`, `getAuthHeaders()`, `connect()`, `reset()`
|
|
188
|
+
- Will be removed in next major version
|
|
181
189
|
- `IAbapRequestOptions` - Request options for ADT operations
|
|
182
190
|
|
|
183
191
|
### SAP Domain (`sap/`)
|
|
@@ -1,17 +1,52 @@
|
|
|
1
|
-
import type { ISapConfig } from '../sap/ISapConfig';
|
|
2
1
|
import type { IAbapRequestOptions } from './IAbapRequestOptions';
|
|
3
2
|
/**
|
|
4
3
|
* Axios response type - using any to avoid dependency on axios package
|
|
5
4
|
* Consumers should use proper AxiosResponse type from axios
|
|
6
5
|
*/
|
|
7
6
|
export type AxiosResponse = any;
|
|
7
|
+
/**
|
|
8
|
+
* ABAP Connection interface
|
|
9
|
+
*
|
|
10
|
+
* Minimal interface for consumers to interact with SAP ADT.
|
|
11
|
+
* Implementation details (auth, token refresh, CSRF, cookies) are encapsulated.
|
|
12
|
+
*
|
|
13
|
+
* For JWT connections, token refresh is handled internally via ITokenRefresher.
|
|
14
|
+
* For Basic connections, no token refresh is needed.
|
|
15
|
+
*/
|
|
8
16
|
export interface IAbapConnection {
|
|
9
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Get base URL of SAP system
|
|
19
|
+
*/
|
|
10
20
|
getBaseUrl(): Promise<string>;
|
|
11
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Get current session ID (for stateful connections)
|
|
23
|
+
*/
|
|
12
24
|
getSessionId(): string | null;
|
|
25
|
+
/**
|
|
26
|
+
* Set session type for subsequent requests
|
|
27
|
+
* @param type - "stateful" for persistent session, "stateless" for independent requests
|
|
28
|
+
*/
|
|
13
29
|
setSessionType(type: "stateful" | "stateless"): void;
|
|
30
|
+
/**
|
|
31
|
+
* Make ADT request to SAP system
|
|
32
|
+
*
|
|
33
|
+
* Handles all auth concerns internally:
|
|
34
|
+
* - Adds authorization header (Basic or Bearer)
|
|
35
|
+
* - Manages CSRF token
|
|
36
|
+
* - Retries on 401/403 with token refresh (JWT only)
|
|
37
|
+
*
|
|
38
|
+
* @param options - Request options (url, method, data, etc.)
|
|
39
|
+
* @returns Promise with Axios response
|
|
40
|
+
*/
|
|
14
41
|
makeAdtRequest(options: IAbapRequestOptions): Promise<AxiosResponse>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated Use IAbapConnection instead. Extended interface kept for backward compatibility.
|
|
45
|
+
* Will be removed in next major version.
|
|
46
|
+
*/
|
|
47
|
+
export interface IAbapConnectionExtended extends IAbapConnection {
|
|
48
|
+
getConfig(): any;
|
|
49
|
+
getAuthHeaders(): Promise<Record<string, string>>;
|
|
15
50
|
connect(): Promise<void>;
|
|
16
51
|
reset(): void;
|
|
17
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IAbapConnection.d.ts","sourceRoot":"","sources":["../../src/connection/IAbapConnection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"IAbapConnection.d.ts","sourceRoot":"","sources":["../../src/connection/IAbapConnection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC;AAEhC;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAE9B;;OAEG;IACH,YAAY,IAAI,MAAM,GAAG,IAAI,CAAC;IAE9B;;;OAGG;IACH,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,WAAW,GAAG,IAAI,CAAC;IAErD;;;;;;;;;;OAUG;IACH,cAAc,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CACtE;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAwB,SAAQ,eAAe;IAC9D,SAAS,IAAI,GAAG,CAAC;IACjB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAClD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,KAAK,IAAI,IAAI,CAAC;CACf"}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,13 +11,14 @@ export type { AuthType } from './auth/AuthType';
|
|
|
11
11
|
export type { ITokenProvider } from './token/ITokenProvider';
|
|
12
12
|
export type { ITokenProviderResult } from './token/ITokenProviderResult';
|
|
13
13
|
export type { ITokenProviderOptions } from './token/ITokenProviderOptions';
|
|
14
|
+
export type { ITokenRefresher } from './token/ITokenRefresher';
|
|
14
15
|
export { TOKEN_PROVIDER_ERROR_CODES } from './token/TokenProviderErrorCodes';
|
|
15
16
|
export type { TokenProviderErrorCode } from './token/TokenProviderErrorCodes';
|
|
16
17
|
export type { ISessionStore } from './session/ISessionStore';
|
|
17
18
|
export type { IServiceKeyStore } from './serviceKey/IServiceKeyStore';
|
|
18
19
|
export { STORE_ERROR_CODES } from './store/StoreErrorCodes';
|
|
19
20
|
export type { StoreErrorCode } from './store/StoreErrorCodes';
|
|
20
|
-
export type { IAbapConnection } from './connection/IAbapConnection';
|
|
21
|
+
export type { IAbapConnection, IAbapConnectionExtended } from './connection/IAbapConnection';
|
|
21
22
|
export type { IAbapRequestOptions } from './connection/IAbapRequestOptions';
|
|
22
23
|
export { NETWORK_ERROR_CODES, isNetworkError } from './connection/NetworkErrors';
|
|
23
24
|
export type { NetworkErrorCode } from './connection/NetworkErrors';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,YAAY,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACxE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,YAAY,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGhD,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,YAAY,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,YAAY,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,YAAY,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAG9E,YAAY,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D,YAAY,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,YAAY,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,YAAY,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,YAAY,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACxE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CA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,CAAC;AAC9E,YAAY,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAGvE,YAAY,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG7D,cAAc,WAAW,CAAC;AAG1B,YAAY,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -8,9 +8,10 @@ import type { ILogger } from '../logging/ILogger';
|
|
|
8
8
|
export interface ITokenProviderOptions {
|
|
9
9
|
/**
|
|
10
10
|
* Browser type for browser-based authentication
|
|
11
|
-
* Supported values: "chrome", "edge", "firefox", "system" (default), "none"
|
|
12
|
-
* - "system": Uses system default browser
|
|
13
|
-
* - "
|
|
11
|
+
* Supported values: "chrome", "edge", "firefox", "system" (default), "none", "headless"
|
|
12
|
+
* - "system": Uses system default browser (default)
|
|
13
|
+
* - "headless": Does not open browser, logs URL and waits for manual callback (for SSH/remote sessions)
|
|
14
|
+
* - "none": Does not open browser, immediately rejects with error (for automated tests)
|
|
14
15
|
*/
|
|
15
16
|
browser?: string;
|
|
16
17
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ITokenProviderOptions.d.ts","sourceRoot":"","sources":["../../src/token/ITokenProviderOptions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,WAAW,qBAAqB;IACpC
|
|
1
|
+
{"version":3,"file":"ITokenProviderOptions.d.ts","sourceRoot":"","sources":["../../src/token/ITokenProviderOptions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,WAAW,qBAAqB;IACpC;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token Refresher interface
|
|
3
|
+
*
|
|
4
|
+
* Provides token management with automatic refresh capability.
|
|
5
|
+
* Implementations are created by AuthBroker and injected into connections.
|
|
6
|
+
*
|
|
7
|
+
* This enables dependency injection of token refresh logic into connections,
|
|
8
|
+
* allowing connections to focus on making requests while the refresher
|
|
9
|
+
* handles all auth/token lifecycle concerns.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Interface for token refresher
|
|
13
|
+
*
|
|
14
|
+
* Created by AuthBroker for a specific destination.
|
|
15
|
+
* Injected into JwtAbapConnection to enable automatic token refresh.
|
|
16
|
+
*/
|
|
17
|
+
export interface ITokenRefresher {
|
|
18
|
+
/**
|
|
19
|
+
* Get current valid token.
|
|
20
|
+
*
|
|
21
|
+
* May return cached token if still valid, or refresh if expired.
|
|
22
|
+
* Implementation decides when to refresh based on token expiration.
|
|
23
|
+
*
|
|
24
|
+
* @returns Promise that resolves to valid JWT token
|
|
25
|
+
*/
|
|
26
|
+
getToken(): Promise<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Force refresh token.
|
|
29
|
+
*
|
|
30
|
+
* Always obtains new token from provider, regardless of current token validity.
|
|
31
|
+
* Saves new token to session store (cache).
|
|
32
|
+
*
|
|
33
|
+
* Use this when getToken() returned a token that was rejected by server (401/403).
|
|
34
|
+
*
|
|
35
|
+
* @returns Promise that resolves to new JWT token
|
|
36
|
+
*/
|
|
37
|
+
refreshToken(): Promise<string>;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=ITokenRefresher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ITokenRefresher.d.ts","sourceRoot":"","sources":["../../src/token/ITokenRefresher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;;OAOG;IACH,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAE5B;;;;;;;;;OASG;IACH,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CACjC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Token Refresher interface
|
|
4
|
+
*
|
|
5
|
+
* Provides token management with automatic refresh capability.
|
|
6
|
+
* Implementations are created by AuthBroker and injected into connections.
|
|
7
|
+
*
|
|
8
|
+
* This enables dependency injection of token refresh logic into connections,
|
|
9
|
+
* allowing connections to focus on making requests while the refresher
|
|
10
|
+
* handles all auth/token lifecycle concerns.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|