@mcp-abap-adt/connection 25.0.0 → 25.0.1
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 +12 -1
- package/README.md +8 -1
- package/dist/connection/AbstractAbapConnection.d.ts +2 -0
- package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
- package/dist/connection/AbstractAbapConnection.js +1 -0
- package/dist/connection/createConnection.d.ts.map +1 -1
- package/dist/connection/createConnection.js +7 -0
- package/dist/connection/withCheckRelogon.d.ts +8 -0
- package/dist/connection/withCheckRelogon.d.ts.map +1 -0
- package/dist/connection/withCheckRelogon.js +68 -0
- package/docs/USAGE.md +22 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [25.0.1] - 2026-11-21
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- For HTTP connections made by `createConnection`, a stateless syntax check
|
|
15
|
+
(`POST /sap/bc/adt/checkruns`) that SAP rejects with a CSRF validation error
|
|
16
|
+
while replacing the session is retried once after logging on to a fresh
|
|
17
|
+
session. A failed logon is returned to the caller. The temporary session
|
|
18
|
+
is closed and the original instance remains spent.
|
|
19
|
+
|
|
10
20
|
## [25.0.0] - 2026-11-13
|
|
11
21
|
|
|
12
22
|
No error the connection hands out, and no line it logs, carries a thrown
|
|
@@ -3107,7 +3117,8 @@ const connection = createAbapConnection(config, logger);
|
|
|
3107
3117
|
- JWT token refresh now properly handles connection errors (401/403 during initial connect)
|
|
3108
3118
|
- Permission errors (403 with "ExceptionResourceNoAccess") no longer trigger JWT refresh loops
|
|
3109
3119
|
- Proper separation: base class handles HTTP/session, concrete classes handle auth-specific errors
|
|
3110
|
-
[Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/v25.0.
|
|
3120
|
+
[Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/v25.0.1...HEAD
|
|
3121
|
+
[25.0.1]: https://github.com/fr0ster/mcp-abap-connection/compare/v25.0.0...v25.0.1
|
|
3111
3122
|
[25.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v24.0.0...v25.0.0
|
|
3112
3123
|
[24.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v23.0.0...v24.0.0
|
|
3113
3124
|
[23.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v22.0.1...v23.0.0
|
package/README.md
CHANGED
|
@@ -272,6 +272,11 @@ try {
|
|
|
272
272
|
// One instance is one SAP session: a new session is a new createConnection().
|
|
273
273
|
```
|
|
274
274
|
|
|
275
|
+
For modern HTTP connections, `createConnection` can retry a stateless ADT
|
|
276
|
+
syntax check once on a temporary session when SAP rejects the CSRF token and
|
|
277
|
+
the connection detects session replacement. The caller receives the retry
|
|
278
|
+
result or the new logon's error. See [Session Lifecycle](docs/USAGE.md#session-lifecycle).
|
|
279
|
+
|
|
275
280
|
`createConnection` returns a **new instance on every call**. Any other
|
|
276
281
|
combination of system and wire (cloud over RFC, say) is refused at
|
|
277
282
|
construction. The transport options are passed through as you give them:
|
|
@@ -902,7 +907,9 @@ connection.setSessionType("stateless");
|
|
|
902
907
|
request rejects `ADT_SESSION_REPLACED`; a stateless one gets SAP's answer as it
|
|
903
908
|
came — a success resolves, a refusal rejects as itself — marked
|
|
904
909
|
`sessionLost: 'ADT_SESSION_REPLACED'` (since 23.0.0). Either way the instance
|
|
905
|
-
is spent
|
|
910
|
+
is spent. Create a new connection for later calls. The factory can finish a
|
|
911
|
+
[stateless syntax check](./docs/USAGE.md#syntax-check-recovery-on-http) on a
|
|
912
|
+
temporary session after an explicit CSRF refusal. See
|
|
906
913
|
[When the session is lost](./docs/USAGE.md#when-the-session-is-lost).
|
|
907
914
|
|
|
908
915
|
### Custom Logger
|
|
@@ -12,6 +12,8 @@ import { type IAdtSessionContext, type IAdtTransport } from './IAdtTransport.js'
|
|
|
12
12
|
* replaced, the session is lost, and the answer is the caller's.
|
|
13
13
|
*/
|
|
14
14
|
type SessionObservation = 'kept' | 'lost';
|
|
15
|
+
/** Whether a thrown value is a refusal this connection marked `sessionLost`. */
|
|
16
|
+
export declare function carriesSessionLost(error: unknown): boolean;
|
|
15
17
|
declare abstract class AbstractAbapConnection implements AbapConnection, ISessionLifecycleAware, ICriticalSection, IRequestProfiling {
|
|
16
18
|
private readonly config;
|
|
17
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractAbapConnection.d.ts","sourceRoot":"","sources":["../../src/connection/AbstractAbapConnection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACb,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,KAAK,YAAY,EACjB,gBAAgB,EAEjB,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAEL,KAAK,aAAa,EAMnB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAGnB,MAAM,oBAAoB,CAAC;AA4C5B;;;;GAIG;AACH,KAAK,kBAAkB,GAAG,MAAM,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"AbstractAbapConnection.d.ts","sourceRoot":"","sources":["../../src/connection/AbstractAbapConnection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,iBAAi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kBAAkB;IAkB1B;;;;;;;OAOG;IACH,OAAO,CAAC,oBAAoB;IAe5B;;;;OAIG;IACH,OAAO,CAAC,YAAY;IAQpB,+EAA+E;IAC/E,OAAO,CAAC,OAAO;IAOf;;;;;;;OAOG;YACW,eAAe;IAsB7B;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAgB3B;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAQxB;;;;;;;OAOG;YACW,gBAAgB;IAqC9B;;;;;;;;OAQG;cACa,cAAc,CAC5B,IAAI,EAAE,MAAM;IACZ;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,GAChD,OAAO,CAAC,MAAM,CAAC;IAelB,SAAS,CAAC,YAAY,IAAI,MAAM,GAAG,IAAI;IAIvC;;OAEG;IACH,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAMlD;;OAEG;IACH,SAAS,CAAC,UAAU,IAAI,MAAM,GAAG,IAAI;IAIrC;;;;;;OAMG;IACH,SAAS,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAMlD;;;;;;;;OAQG;YACW,eAAe;IAO7B;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,aAAa;IAgCrB;;;;;;;;OAQG;IACH,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,eAAe;CA6BxB;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AbstractAbapConnection = void 0;
|
|
4
|
+
exports.carriesSessionLost = carriesSessionLost;
|
|
4
5
|
const node_crypto_1 = require("node:crypto");
|
|
5
6
|
const interfaces_adt_connection_1 = require("@mcp-abap-adt/interfaces-adt-connection");
|
|
6
7
|
const SessionLifecycle_js_1 = require("../session/SessionLifecycle.js");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createConnection.d.ts","sourceRoot":"","sources":["../../src/connection/createConnection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACd,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,KAAK,oBAAoB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"createConnection.d.ts","sourceRoot":"","sources":["../../src/connection/createConnection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACd,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO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C,EACrC,eAAe;IACjB,MAAM,EAAE,QAAQ,CAAC;IACjB,6EAA6E;IAC7E,SAAS,EAAE,MAAM,GAAG,aAAa,CAAC;CACnC;AAED,MAAM,WAAW,aAAa,CAC5B,WAAW,SAAS,aAAa,GAAG,aAAa,CACjD,SAAQ,kBAAkB,CAAC,WAAW,CAAC;IACvC,MAAM,EAAE,QAAQ,CAAC;IACjB,SAAS,EAAE,KAAK,CAAC;IACjB;;;OAGG;IACH,MAAM,EAAE,aAAa,CAAC;IACtB,oEAAoE;IACpE,GAAG,CAAC,EAAE,oBAAoB,GAAG,SAAS,CAAC;IACvC;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AAED,MAAM,MAAM,cAAc,CAAC,WAAW,SAAS,aAAa,GAAG,aAAa,IACxE,aAAa,CAAC,WAAW,CAAC,GAC1B,cAAc,CAAC,WAAW,CAAC,GAC3B,aAAa,CAAC,WAAW,CAAC,CAAC;AAa/B;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,CAC3B,WAAW,SAAS,aAAa,GAAG,aAAa,IAE/C,iBAAiB,CAAC,WAAW,EAAE,kBAAkB,CAAC,GAClD,kBAAkB,CAChB,WAAW,EACX,mBAAmB,GAAG,yBAAyB,GAAG,YAAY,CAC/D,CAAC;AAkBN,wBAAgB,gBAAgB,CAAC,WAAW,SAAS,aAAa,EAChE,IAAI,EAAE,cAAc,CAAC,WAAW,CAAC,GAChC,iBAAiB,CAAC,WAAW,CAAC,CAMhC"}
|
|
@@ -8,6 +8,7 @@ const LegacyOnPremHttpTransport_js_1 = require("./LegacyOnPremHttpTransport.js")
|
|
|
8
8
|
const OnPremHttpTransport_js_1 = require("./OnPremHttpTransport.js");
|
|
9
9
|
const RfcTransport_js_1 = require("./RfcTransport.js");
|
|
10
10
|
const rfcConversation_js_1 = require("./rfcConversation.js");
|
|
11
|
+
const withCheckRelogon_js_1 = require("./withCheckRelogon.js");
|
|
11
12
|
/**
|
|
12
13
|
* Fixed words: nothing the caller passed is echoed back. Typed `never`: the
|
|
13
14
|
* compiler proves every combination of the spec type is handled before it,
|
|
@@ -28,6 +29,12 @@ function httpAddress(spec) {
|
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
function createConnection(spec) {
|
|
32
|
+
const connection = buildConnection(spec);
|
|
33
|
+
if (spec.transport !== 'http')
|
|
34
|
+
return connection;
|
|
35
|
+
return (0, withCheckRelogon_js_1.withCheckRelogon)(connection, () => buildConnection({ ...spec, session: undefined }));
|
|
36
|
+
}
|
|
37
|
+
function buildConnection(spec) {
|
|
31
38
|
const logger = spec.logger ?? null;
|
|
32
39
|
const wireLogger = spec.wireLogger ?? null;
|
|
33
40
|
// The spec is a union discriminated by `transport` and `system`: each branch
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CreatedConnection } from './createConnection.js';
|
|
2
|
+
/**
|
|
3
|
+
* The syntax-check POST is a read. A 403 explicitly rejecting its CSRF token
|
|
4
|
+
* means SAP did not run it. Retry on a separate session only when that same
|
|
5
|
+
* response proved the original session gone.
|
|
6
|
+
*/
|
|
7
|
+
export declare function withCheckRelogon<TConnection extends CreatedConnection>(connection: TConnection, fresh: () => TConnection): TConnection;
|
|
8
|
+
//# sourceMappingURL=withCheckRelogon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withCheckRelogon.d.ts","sourceRoot":"","sources":["../../src/connection/withCheckRelogon.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI/D;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,SAAS,iBAAiB,EACpE,UAAU,EAAE,WAAW,EACvB,KAAK,EAAE,MAAM,WAAW,GACvB,WAAW,CA0Db"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withCheckRelogon = withCheckRelogon;
|
|
4
|
+
const interfaces_adt_connection_1 = require("@mcp-abap-adt/interfaces-adt-connection");
|
|
5
|
+
const AbstractAbapConnection_js_1 = require("./AbstractAbapConnection.js");
|
|
6
|
+
const IAdtTransport_js_1 = require("./IAdtTransport.js");
|
|
7
|
+
const statefulRequest_js_1 = require("./statefulRequest.js");
|
|
8
|
+
/**
|
|
9
|
+
* The syntax-check POST is a read. A 403 explicitly rejecting its CSRF token
|
|
10
|
+
* means SAP did not run it. Retry on a separate session only when that same
|
|
11
|
+
* response proved the original session gone.
|
|
12
|
+
*/
|
|
13
|
+
function withCheckRelogon(connection, fresh) {
|
|
14
|
+
const send = connection.makeAdtRequest.bind(connection);
|
|
15
|
+
const disconnect = connection.disconnect.bind(connection);
|
|
16
|
+
const pending = new Set();
|
|
17
|
+
let closing = false;
|
|
18
|
+
connection.disconnect = async () => {
|
|
19
|
+
closing = true;
|
|
20
|
+
await Promise.all([disconnect(), ...Array.from(pending, (stop) => stop())]);
|
|
21
|
+
};
|
|
22
|
+
connection.makeAdtRequest = async (request) => {
|
|
23
|
+
const eligible = request.method.toUpperCase() === 'POST' &&
|
|
24
|
+
request.url.split('?', 1)[0] === '/sap/bc/adt/checkruns' &&
|
|
25
|
+
typeof request.data === 'string' &&
|
|
26
|
+
connection.getSessionMode() === 'stateless' &&
|
|
27
|
+
!connection.isInCriticalSection() &&
|
|
28
|
+
!(0, statefulRequest_js_1.isStatefulRequest)({
|
|
29
|
+
url: request.url,
|
|
30
|
+
method: request.method,
|
|
31
|
+
headers: request.headers,
|
|
32
|
+
});
|
|
33
|
+
try {
|
|
34
|
+
return await send(request);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
if (!eligible || closing || !(0, AbstractAbapConnection_js_1.carriesSessionLost)(error))
|
|
38
|
+
throw error;
|
|
39
|
+
const refusal = (0, IAdtTransport_js_1.refusalOf)(error);
|
|
40
|
+
if (refusal?.status !== 403 ||
|
|
41
|
+
typeof refusal.data !== 'string' ||
|
|
42
|
+
!refusal.data.includes('CSRF token validation failed'))
|
|
43
|
+
throw error;
|
|
44
|
+
const replacement = fresh();
|
|
45
|
+
let stopped;
|
|
46
|
+
const stop = () => (stopped ??= replacement.disconnect());
|
|
47
|
+
pending.add(stop);
|
|
48
|
+
try {
|
|
49
|
+
await replacement.connect();
|
|
50
|
+
if (closing)
|
|
51
|
+
throw error;
|
|
52
|
+
const result = await replacement.makeAdtRequest(request);
|
|
53
|
+
return { ...result, sessionLost: interfaces_adt_connection_1.ADT_SESSION_ERROR.SESSION_REPLACED };
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
// Disconnect waits until the logoff is written, as for any session.
|
|
57
|
+
// A caller closing during recovery shares this same disconnect.
|
|
58
|
+
try {
|
|
59
|
+
await stop();
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
pending.delete(stop);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
return connection;
|
|
68
|
+
}
|
package/docs/USAGE.md
CHANGED
|
@@ -710,9 +710,8 @@ on whether it is stateful (since 23.0.0):
|
|
|
710
710
|
rejects as itself — with `sessionLost: 'ADT_SESSION_REPLACED'` on that
|
|
711
711
|
response or on that error (`IAdtWireResponse`, `IAbapConnectionError`,
|
|
712
712
|
`@mcp-abap-adt/interfaces-adt-connection`, since 4.2.0). Only the request whose own
|
|
713
|
-
answer showed the replacement carries it.
|
|
714
|
-
|
|
715
|
-
reaches you.
|
|
713
|
+
answer showed the replacement carries it. The original instance is spent
|
|
714
|
+
before the answer reaches you.
|
|
716
715
|
|
|
717
716
|
The connection's own exchanges inside a request (a CSRF fetch, a logon) have no
|
|
718
717
|
answer of yours to keep: a replacement seen on one is `ADT_SESSION_REPLACED`.
|
|
@@ -730,11 +729,11 @@ nothing here suggests a working session to continue on — the one we had is
|
|
|
730
729
|
confirmed dead, and re-establishing silently is what let the old connector
|
|
731
730
|
carry on over a session the caller never opened.
|
|
732
731
|
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
732
|
+
The factory can complete a [stateless syntax check](#syntax-check-recovery-on-http)
|
|
733
|
+
after SAP explicitly rejects its CSRF token and the response confirms session
|
|
734
|
+
replacement. Recovery for other requests is the caller's decision. At the HTTP
|
|
735
|
+
wire level, the pooled-socket resend still applies only when no answer byte
|
|
736
|
+
arrived (see "Kept-alive connections, and the one resend" under the transports).
|
|
738
737
|
|
|
739
738
|
**A lost session spends the instance** (since 16.0.0), as `disconnect()` does.
|
|
740
739
|
After either of these — a stateless answer marked `sessionLost` included —
|
|
@@ -838,6 +837,21 @@ await connection.makeAdtRequest({ method: 'POST', url: '...' , timeout: 0 });
|
|
|
838
837
|
connection.setSessionType('stateless');
|
|
839
838
|
```
|
|
840
839
|
|
|
840
|
+
### Syntax check recovery on HTTP
|
|
841
|
+
|
|
842
|
+
On a modern HTTP connection built by `createConnection`, an ADT syntax check
|
|
843
|
+
(`POST /sap/bc/adt/checkruns` with an XML string body) is retried once during
|
|
844
|
+
the same call if SAP rejects the CSRF token and the response also shows that
|
|
845
|
+
the original session was replaced. The retry logs on with the same destination
|
|
846
|
+
and provider, then sends the check on a temporary session. A failure to log on
|
|
847
|
+
is the call's error. The temporary session is logged off and the original
|
|
848
|
+
connection remains spent. A successful retry still carries
|
|
849
|
+
`sessionLost: ADT_SESSION_REPLACED` so the caller can discard state tied to the
|
|
850
|
+
original session.
|
|
851
|
+
|
|
852
|
+
This applies to stateless checks outside a critical section. Stateful requests
|
|
853
|
+
and operations under an existing lock retain their session-bound behavior.
|
|
854
|
+
|
|
841
855
|
### Starting Over
|
|
842
856
|
|
|
843
857
|
There is no local-only reset. Discarding the cookie does not end the ABAP
|