@mcp-abap-adt/header-validator 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.1.4] - 2024-12-04
9
+
10
+ ### Added
11
+ - **Interfaces Package Integration**: Migrated to use `@mcp-abap-adt/interfaces` package for all interface definitions
12
+ - All interfaces now imported from shared package
13
+ - Backward compatibility maintained with type aliases
14
+ - Dependency on `@mcp-abap-adt/interfaces@^0.1.0` added
15
+
16
+ ### Changed
17
+ - **Interface Renaming**: Interfaces renamed to follow `I` prefix convention:
18
+ - `ValidatedAuthConfig` → `IValidatedAuthConfig` (type alias for backward compatibility)
19
+ - `HeaderValidationResult` → `IHeaderValidationResult` (type alias for backward compatibility)
20
+ - `AuthType` and `AuthMethodPriority` now imported from interfaces package
21
+ - Old names still work via type aliases for backward compatibility
22
+
8
23
  ## [0.1.3] - 2025-12-01
9
24
 
10
25
  ### Fixed
package/README.md CHANGED
@@ -9,6 +9,56 @@ Header validator for MCP ABAP ADT - validates and prioritizes authentication hea
9
9
  - ✅ **Error Reporting**: Detailed error messages and warnings
10
10
  - ✅ **Type Safety**: Full TypeScript support with type definitions
11
11
 
12
+ ## Responsibilities and Design Principles
13
+
14
+ ### Core Development Principle
15
+
16
+ **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**.
17
+
18
+ This means:
19
+ - Does not know about concrete implementation classes from other packages
20
+ - Does not know about internal data structures or methods not defined in interfaces
21
+ - Does not make assumptions about implementation behavior beyond interface contracts
22
+ - Does not access properties or methods not explicitly defined in interfaces
23
+
24
+ This principle ensures:
25
+ - **Loose coupling**: Validator is decoupled from concrete implementations in other packages
26
+ - **Flexibility**: New implementations can be added without modifying validator
27
+ - **Testability**: Easy to mock dependencies for testing
28
+ - **Maintainability**: Changes to implementations don't affect validator
29
+
30
+ ### Package Responsibilities
31
+
32
+ This package is responsible for:
33
+
34
+ 1. **Header validation**: Validates authentication headers from HTTP requests
35
+ 2. **Priority resolution**: Determines which authentication method to use based on header presence and priority rules
36
+ 3. **Configuration extraction**: Extracts authentication configuration from headers
37
+ 4. **Error reporting**: Provides detailed validation errors and warnings
38
+
39
+ #### What This Package Does
40
+
41
+ - **Validates headers**: Checks authentication headers for validity and completeness
42
+ - **Prioritizes methods**: Determines authentication method priority (SAP destination > MCP destination > JWT token > Basic auth)
43
+ - **Extracts config**: Extracts `SapConfig` from validated headers
44
+ - **Reports errors**: Provides detailed error messages and warnings for invalid configurations
45
+ - **Type safety**: Returns typed validation results with configuration objects
46
+
47
+ #### What This Package Does NOT Do
48
+
49
+ - **Does NOT handle authentication**: Authentication is handled by `@mcp-abap-adt/connection` and `@mcp-abap-adt/auth-broker`
50
+ - **Does NOT manage tokens**: Token management is handled by `@mcp-abap-adt/auth-broker`
51
+ - **Does NOT make HTTP requests**: HTTP requests are handled by `@mcp-abap-adt/connection`
52
+ - **Does NOT store configuration**: Configuration storage is handled by consumers
53
+ - **Does NOT know about destinations**: Destination resolution is handled by `@mcp-abap-adt/auth-broker`
54
+
55
+ ### External Dependencies
56
+
57
+ This package interacts with external packages **ONLY through interfaces**:
58
+
59
+ - **`@mcp-abap-adt/connection`**: Uses `SapConfig` type for configuration - does not know about concrete connection implementation
60
+ - **No direct dependencies on other packages**: All interactions happen through well-defined types and interfaces
61
+
12
62
  ## Installation
13
63
 
14
64
  ```bash
@@ -7,7 +7,7 @@
7
7
  * 3. Basic auth (x-sap-login + x-sap-password) - lowest priority
8
8
  */
9
9
  import { IncomingHttpHeaders } from 'http';
10
- import { HeaderValidationResult } from './types';
10
+ import type { HeaderValidationResult } from './types';
11
11
  /**
12
12
  * Validate and prioritize authentication headers
13
13
  *
@@ -9,7 +9,7 @@
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.validateAuthHeaders = validateAuthHeaders;
12
- const types_1 = require("./types");
12
+ const interfaces_1 = require("@mcp-abap-adt/interfaces");
13
13
  /**
14
14
  * Extract header value (handles array values)
15
15
  * Node.js normalizes headers to lowercase, but check both cases for safety
@@ -59,7 +59,7 @@ function validateSapDestinationAuth(headers) {
59
59
  if (!destination || destination.length === 0) {
60
60
  errors.push('x-sap-destination header is empty');
61
61
  return {
62
- priority: types_1.AuthMethodPriority.NONE,
62
+ priority: interfaces_1.AuthMethodPriority.NONE,
63
63
  authType: 'jwt', // SAP destination always uses JWT
64
64
  sapUrl: '', // URL will be loaded from destination
65
65
  errors,
@@ -87,7 +87,7 @@ function validateSapDestinationAuth(headers) {
87
87
  warnings.push('x-sap-auth-type is ignored when x-sap-destination is present (always uses JWT)');
88
88
  }
89
89
  return {
90
- priority: types_1.AuthMethodPriority.SAP_DESTINATION,
90
+ priority: interfaces_1.AuthMethodPriority.SAP_DESTINATION,
91
91
  authType: 'jwt', // Always JWT for x-sap-destination
92
92
  sapUrl: '', // URL will be loaded from destination (service key or .env)
93
93
  sapClient,
@@ -117,7 +117,7 @@ function validateMcpDestinationAuth(headers, sapUrl) {
117
117
  if (!destination || destination.length === 0) {
118
118
  errors.push('x-mcp-destination header is empty');
119
119
  return {
120
- priority: types_1.AuthMethodPriority.NONE,
120
+ priority: interfaces_1.AuthMethodPriority.NONE,
121
121
  authType: 'jwt', // MCP destination always uses JWT
122
122
  sapUrl: '', // URL will be loaded from destination
123
123
  errors,
@@ -141,7 +141,7 @@ function validateMcpDestinationAuth(headers, sapUrl) {
141
141
  warnings.push('x-sap-jwt-token is ignored when x-mcp-destination is present (destination-based auth takes priority)');
142
142
  }
143
143
  return {
144
- priority: types_1.AuthMethodPriority.MCP_DESTINATION,
144
+ priority: interfaces_1.AuthMethodPriority.MCP_DESTINATION,
145
145
  authType: 'jwt', // Always JWT for x-mcp-destination
146
146
  sapUrl: '', // URL will be loaded from destination (service key or .env)
147
147
  sapClient,
@@ -175,7 +175,7 @@ function validateDirectJwtAuth(headers, sapUrl, authType) {
175
175
  // Extract optional SAP client
176
176
  const sapClient = getHeaderValue(headers, 'x-sap-client');
177
177
  return {
178
- priority: types_1.AuthMethodPriority.DIRECT_JWT,
178
+ priority: interfaces_1.AuthMethodPriority.DIRECT_JWT,
179
179
  authType,
180
180
  sapUrl,
181
181
  sapClient,
@@ -214,7 +214,7 @@ function validateBasicAuth(headers, sapUrl, authType) {
214
214
  // Return config with errors if validation failed
215
215
  if (errors.length > 0) {
216
216
  return {
217
- priority: types_1.AuthMethodPriority.NONE,
217
+ priority: interfaces_1.AuthMethodPriority.NONE,
218
218
  authType,
219
219
  sapUrl,
220
220
  errors,
@@ -222,7 +222,7 @@ function validateBasicAuth(headers, sapUrl, authType) {
222
222
  };
223
223
  }
224
224
  return {
225
- priority: types_1.AuthMethodPriority.BASIC,
225
+ priority: interfaces_1.AuthMethodPriority.BASIC,
226
226
  authType,
227
227
  sapUrl,
228
228
  username,
@@ -372,7 +372,7 @@ function validateAuthHeaders(headers) {
372
372
  // Check for conflicts (multiple auth methods with same priority shouldn't happen, but check anyway)
373
373
  const samePriorityConfigs = configs.filter(c => c.priority === selectedConfig.priority);
374
374
  if (samePriorityConfigs.length > 1) {
375
- warnings.push(`Multiple authentication methods with same priority detected, using: ${types_1.AuthMethodPriority[selectedConfig.priority]}`);
375
+ warnings.push(`Multiple authentication methods with same priority detected, using: ${interfaces_1.AuthMethodPriority[selectedConfig.priority]}`);
376
376
  }
377
377
  // Merge errors and warnings
378
378
  const allErrors = [...errors, ...selectedConfig.errors];
package/dist/types.d.ts CHANGED
@@ -1,64 +1,9 @@
1
1
  /**
2
2
  * Types for header validator
3
3
  */
4
- /**
5
- * Authentication type
6
- */
7
- export type AuthType = 'jwt' | 'xsuaa' | 'basic';
8
- /**
9
- * Authentication method priority
10
- * Higher number = higher priority
11
- */
12
- export declare enum AuthMethodPriority {
13
- SAP_DESTINATION = 4,// x-sap-destination (uses AuthBroker, JWT only)
14
- MCP_DESTINATION = 3,// x-mcp-destination + x-sap-auth-type=jwt (uses AuthBroker)
15
- DIRECT_JWT = 2,// x-sap-jwt-token + x-sap-auth-type=jwt
16
- BASIC = 1,// x-sap-login + x-sap-password + x-sap-auth-type=basic
17
- NONE = 0
18
- }
19
- /**
20
- * Validated authentication configuration
21
- */
22
- export interface ValidatedAuthConfig {
23
- /** Authentication method priority */
24
- priority: AuthMethodPriority;
25
- /** Authentication type */
26
- authType: AuthType;
27
- /** SAP URL */
28
- sapUrl: string;
29
- /** SAP Client (optional) */
30
- sapClient?: string;
31
- /** Destination name (for destination-based auth: x-sap-destination or x-mcp-destination) */
32
- destination?: string;
33
- /** JWT token (for direct JWT auth) */
34
- jwtToken?: string;
35
- /** Refresh token (optional, for JWT auth) */
36
- refreshToken?: string;
37
- /** UAA URL (optional, for JWT auth) */
38
- uaaUrl?: string;
39
- /** UAA Client ID (optional, for JWT auth) */
40
- uaaClientId?: string;
41
- /** UAA Client Secret (optional, for JWT auth) */
42
- uaaClientSecret?: string;
43
- /** Username (for basic auth) */
44
- username?: string;
45
- /** Password (for basic auth) */
46
- password?: string;
47
- /** Validation errors (if any) */
48
- errors: string[];
49
- /** Warnings (if any) */
50
- warnings: string[];
51
- }
52
- /**
53
- * Header validation result
54
- */
55
- export interface HeaderValidationResult {
56
- /** Is configuration valid? */
57
- isValid: boolean;
58
- /** Validated authentication configuration */
59
- config?: ValidatedAuthConfig;
60
- /** Validation errors */
61
- errors: string[];
62
- /** Warnings */
63
- warnings: string[];
64
- }
4
+ import type { AuthType } from '@mcp-abap-adt/interfaces';
5
+ import { AuthMethodPriority, type IValidatedAuthConfig, type IHeaderValidationResult } from '@mcp-abap-adt/interfaces';
6
+ export type { AuthType };
7
+ export { AuthMethodPriority };
8
+ export type ValidatedAuthConfig = IValidatedAuthConfig;
9
+ export type HeaderValidationResult = IHeaderValidationResult;
package/dist/types.js CHANGED
@@ -4,15 +4,5 @@
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.AuthMethodPriority = void 0;
7
- /**
8
- * Authentication method priority
9
- * Higher number = higher priority
10
- */
11
- var AuthMethodPriority;
12
- (function (AuthMethodPriority) {
13
- AuthMethodPriority[AuthMethodPriority["SAP_DESTINATION"] = 4] = "SAP_DESTINATION";
14
- AuthMethodPriority[AuthMethodPriority["MCP_DESTINATION"] = 3] = "MCP_DESTINATION";
15
- AuthMethodPriority[AuthMethodPriority["DIRECT_JWT"] = 2] = "DIRECT_JWT";
16
- AuthMethodPriority[AuthMethodPriority["BASIC"] = 1] = "BASIC";
17
- AuthMethodPriority[AuthMethodPriority["NONE"] = 0] = "NONE"; // No valid authentication
18
- })(AuthMethodPriority || (exports.AuthMethodPriority = AuthMethodPriority = {}));
7
+ const interfaces_1 = require("@mcp-abap-adt/interfaces");
8
+ Object.defineProperty(exports, "AuthMethodPriority", { enumerable: true, get: function () { return interfaces_1.AuthMethodPriority; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-abap-adt/header-validator",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Header validator for MCP ABAP ADT - validates and prioritizes authentication headers",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -44,6 +44,9 @@
44
44
  "engines": {
45
45
  "node": ">=18.0.0"
46
46
  },
47
+ "dependencies": {
48
+ "@mcp-abap-adt/interfaces": "^0.1.0"
49
+ },
47
50
  "devDependencies": {
48
51
  "@types/jest": "^30.0.0",
49
52
  "@types/node": "^24.2.1",