@mcp-abap-adt/connection 1.3.0 → 1.3.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/dist/connection/AbstractAbapConnection.d.ts +4 -0
- package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
- package/dist/connection/AbstractAbapConnection.js +37 -14
- package/dist/connection/connectionFactory.d.ts +3 -1
- package/dist/connection/connectionFactory.d.ts.map +1 -1
- package/dist/connection/connectionFactory.js +3 -3
- package/dist/connection/csrfConfig.d.ts +8 -2
- package/dist/connection/csrfConfig.d.ts.map +1 -1
- package/dist/connection/csrfConfig.js +8 -2
- package/package.json +1 -1
|
@@ -63,6 +63,10 @@ declare abstract class AbstractAbapConnection implements AbapConnection {
|
|
|
63
63
|
* Protected method for use by concrete implementations in their connect() method
|
|
64
64
|
*/
|
|
65
65
|
protected fetchCsrfToken(url: string, retryCount?: number, retryDelay?: number): Promise<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Fetch CSRF token from a specific endpoint with retries
|
|
68
|
+
*/
|
|
69
|
+
private fetchCsrfTokenFromEndpoint;
|
|
66
70
|
/**
|
|
67
71
|
* Get CSRF token (protected for use by subclasses)
|
|
68
72
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractAbapConnection.d.ts","sourceRoot":"","sources":["../../src/connection/AbstractAbapConnection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAkB,MAAM,0BAA0B,CAAC;AAM7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAG9E,uBAAe,sBAAuB,YAAW,cAAc;IAW3D,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,SAAS,CAAC,QAAQ,CAAC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P,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAI7B,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAevD;;;;;;;;OAQG;IACH,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE3B,cAAc,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EACnC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IA4P9B,SAAS,CAAC,QAAQ,CAAC,wBAAwB,IAAI,MAAM;IAErD;;;OAGG;cACa,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,UAAU,GAAE,MAAgC,EAC5C,UAAU,GAAE,MAAgC,GAC3C,OAAO,CAAC,MAAM,CAAC;IA2ClB;;OAEG;YACW,0BAA0B;IAsKxC;;OAEG;IACH,SAAS,CAAC,YAAY,IAAI,MAAM,GAAG,IAAI;IAIvC;;OAEG;IACH,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAIlD;;OAEG;IACH,SAAS,CAAC,UAAU,IAAI,MAAM,GAAG,IAAI;IAIrC,SAAS,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIlD,OAAO,CAAC,yBAAyB;IAkEjC,OAAO,CAAC,gBAAgB;YAqBV,oBAAoB;IAiClC,OAAO,CAAC,eAAe;CA+BxB;AAGD,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -321,20 +321,43 @@ class AbstractAbapConnection {
|
|
|
321
321
|
* Protected method for use by concrete implementations in their connect() method
|
|
322
322
|
*/
|
|
323
323
|
async fetchCsrfToken(url, retryCount = csrfConfig_js_1.CSRF_CONFIG.RETRY_COUNT, retryDelay = csrfConfig_js_1.CSRF_CONFIG.RETRY_DELAY) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
324
|
+
// Try primary endpoint first, then fallback for older systems
|
|
325
|
+
const baseUrl = url.includes('/sap/bc/adt/')
|
|
326
|
+
? url.split('/sap/bc/adt')[0]
|
|
327
|
+
: url.endsWith('/')
|
|
328
|
+
? url.slice(0, -1)
|
|
329
|
+
: url;
|
|
330
|
+
let endpoints;
|
|
331
|
+
// If the URL already contains a specific endpoint, use only that
|
|
332
|
+
if (url.includes(csrfConfig_js_1.CSRF_CONFIG.ENDPOINT)) {
|
|
333
|
+
endpoints = [url];
|
|
334
|
+
}
|
|
335
|
+
else if (url.includes(csrfConfig_js_1.CSRF_CONFIG.FALLBACK_ENDPOINT)) {
|
|
336
|
+
endpoints = [url];
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
endpoints = [
|
|
340
|
+
`${baseUrl}${csrfConfig_js_1.CSRF_CONFIG.ENDPOINT}`,
|
|
341
|
+
`${baseUrl}${csrfConfig_js_1.CSRF_CONFIG.FALLBACK_ENDPOINT}`,
|
|
342
|
+
];
|
|
343
|
+
}
|
|
344
|
+
let lastError;
|
|
345
|
+
for (const csrfUrl of endpoints) {
|
|
346
|
+
try {
|
|
347
|
+
return await this.fetchCsrfTokenFromEndpoint(csrfUrl, retryCount, retryDelay);
|
|
348
|
+
}
|
|
349
|
+
catch (error) {
|
|
350
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
351
|
+
this.logger?.debug(`CSRF token not available from ${csrfUrl}, trying next endpoint...`);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
// All endpoints exhausted
|
|
355
|
+
throw lastError ?? new Error('CSRF token fetch failed unexpectedly');
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Fetch CSRF token from a specific endpoint with retries
|
|
359
|
+
*/
|
|
360
|
+
async fetchCsrfTokenFromEndpoint(csrfUrl, retryCount, retryDelay) {
|
|
338
361
|
this.logger?.debug(`Fetching CSRF token from: ${csrfUrl}`);
|
|
339
362
|
for (let attempt = 0; attempt <= retryCount; attempt++) {
|
|
340
363
|
try {
|
|
@@ -2,5 +2,7 @@ import type { ITokenRefresher } from '@mcp-abap-adt/interfaces';
|
|
|
2
2
|
import type { SapConfig } from '../config/sapConfig.js';
|
|
3
3
|
import type { ILogger } from '../logger.js';
|
|
4
4
|
import type { AbapConnection } from './AbapConnection.js';
|
|
5
|
-
export declare function createAbapConnection(config: SapConfig, logger?: ILogger | null, sessionId?: string, tokenRefresher?: ITokenRefresher
|
|
5
|
+
export declare function createAbapConnection(config: SapConfig, logger?: ILogger | null, sessionId?: string, tokenRefresher?: ITokenRefresher, options?: {
|
|
6
|
+
skipSessionType?: boolean;
|
|
7
|
+
}): AbapConnection;
|
|
6
8
|
//# sourceMappingURL=connectionFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectionFactory.d.ts","sourceRoot":"","sources":["../../src/connection/connectionFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAK1D,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,EACjB,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,EACvB,SAAS,CAAC,EAAE,MAAM,EAClB,cAAc,CAAC,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"connectionFactory.d.ts","sourceRoot":"","sources":["../../src/connection/connectionFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAK1D,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,EACjB,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,EACvB,SAAS,CAAC,EAAE,MAAM,EAClB,cAAc,CAAC,EAAE,eAAe,EAChC,OAAO,CAAC,EAAE;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,GACtC,cAAc,CAahB"}
|
|
@@ -4,14 +4,14 @@ exports.createAbapConnection = createAbapConnection;
|
|
|
4
4
|
const BaseAbapConnection_js_1 = require("./BaseAbapConnection.js");
|
|
5
5
|
const JwtAbapConnection_js_1 = require("./JwtAbapConnection.js");
|
|
6
6
|
const SamlAbapConnection_js_1 = require("./SamlAbapConnection.js");
|
|
7
|
-
function createAbapConnection(config, logger, sessionId, tokenRefresher) {
|
|
7
|
+
function createAbapConnection(config, logger, sessionId, tokenRefresher, options) {
|
|
8
8
|
switch (config.authType) {
|
|
9
9
|
case 'basic':
|
|
10
|
-
return new BaseAbapConnection_js_1.BaseAbapConnection(config, logger, sessionId);
|
|
10
|
+
return new BaseAbapConnection_js_1.BaseAbapConnection(config, logger, sessionId, options);
|
|
11
11
|
case 'jwt':
|
|
12
12
|
return new JwtAbapConnection_js_1.JwtAbapConnection(config, logger, sessionId, tokenRefresher);
|
|
13
13
|
case 'saml':
|
|
14
|
-
return new SamlAbapConnection_js_1.SamlAbapConnection(config, logger, sessionId);
|
|
14
|
+
return new SamlAbapConnection_js_1.SamlAbapConnection(config, logger, sessionId, options);
|
|
15
15
|
default:
|
|
16
16
|
throw new Error(`Unsupported SAP authentication type: ${config.authType}`);
|
|
17
17
|
}
|
|
@@ -16,10 +16,16 @@ export declare const CSRF_CONFIG: {
|
|
|
16
16
|
*/
|
|
17
17
|
readonly RETRY_DELAY: 1000;
|
|
18
18
|
/**
|
|
19
|
-
* CSRF token endpoint path
|
|
20
|
-
* Standard SAP ADT core discovery endpoint (
|
|
19
|
+
* CSRF token endpoint path (primary)
|
|
20
|
+
* Standard SAP ADT core discovery endpoint (newer systems, returns smaller response)
|
|
21
21
|
*/
|
|
22
22
|
readonly ENDPOINT: "/sap/bc/adt/core/discovery";
|
|
23
|
+
/**
|
|
24
|
+
* CSRF token endpoint path (fallback)
|
|
25
|
+
* Legacy SAP ADT discovery endpoint for older systems (e.g. BASIS < 7.52)
|
|
26
|
+
* that don't have /sap/bc/adt/core/discovery
|
|
27
|
+
*/
|
|
28
|
+
readonly FALLBACK_ENDPOINT: "/sap/bc/adt/discovery";
|
|
23
29
|
/**
|
|
24
30
|
* Required headers for CSRF token fetch
|
|
25
31
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csrfConfig.d.ts","sourceRoot":"","sources":["../../src/connection/csrfConfig.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,WAAW;IACtB;;;OAGG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;OAEG;;;;;CAKK,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,mBAAmB;sCACL,MAAM,SAAS,MAAM;;;CAOtC,CAAC"}
|
|
1
|
+
{"version":3,"file":"csrfConfig.d.ts","sourceRoot":"","sources":["../../src/connection/csrfConfig.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,WAAW;IACtB;;;OAGG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;;OAIG;;IAGH;;OAEG;;;;;CAKK,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,mBAAmB;sCACL,MAAM,SAAS,MAAM;;;CAOtC,CAAC"}
|
|
@@ -19,10 +19,16 @@ exports.CSRF_CONFIG = {
|
|
|
19
19
|
*/
|
|
20
20
|
RETRY_DELAY: 1000,
|
|
21
21
|
/**
|
|
22
|
-
* CSRF token endpoint path
|
|
23
|
-
* Standard SAP ADT core discovery endpoint (
|
|
22
|
+
* CSRF token endpoint path (primary)
|
|
23
|
+
* Standard SAP ADT core discovery endpoint (newer systems, returns smaller response)
|
|
24
24
|
*/
|
|
25
25
|
ENDPOINT: '/sap/bc/adt/core/discovery',
|
|
26
|
+
/**
|
|
27
|
+
* CSRF token endpoint path (fallback)
|
|
28
|
+
* Legacy SAP ADT discovery endpoint for older systems (e.g. BASIS < 7.52)
|
|
29
|
+
* that don't have /sap/bc/adt/core/discovery
|
|
30
|
+
*/
|
|
31
|
+
FALLBACK_ENDPOINT: '/sap/bc/adt/discovery',
|
|
26
32
|
/**
|
|
27
33
|
* Required headers for CSRF token fetch
|
|
28
34
|
*/
|