@mcp-abap-adt/connection 21.0.0 → 22.0.0
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 +53 -1
- package/README.md +73 -1
- package/dist/connection/AbstractAbapConnection.d.ts +15 -0
- package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
- package/dist/connection/AbstractAbapConnection.js +42 -8
- package/dist/connection/IAdtTransport.d.ts +6 -0
- package/dist/connection/IAdtTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.d.ts +21 -1
- package/dist/connection/RfcTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.js +292 -51
- package/dist/connection/authErrors.d.ts +14 -0
- package/dist/connection/authErrors.d.ts.map +1 -1
- package/dist/connection/authErrors.js +19 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/docs/INDEX.md +1 -0
- package/docs/MIGRATION-22.0.md +78 -0
- package/docs/USAGE.md +37 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,57 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [22.0.0] - 2026-11-12
|
|
11
|
+
|
|
12
|
+
Over RFC, a request carries its passport and a failure names its error by fields, and an RFC
|
|
13
|
+
error that ends the stateful conversation ends the instance's session: the connection does not
|
|
14
|
+
open a new one on its own. Breaking for code that went on with an instance after such an error,
|
|
15
|
+
and for code that read the passport from the endpoint's header fields. See
|
|
16
|
+
[docs/MIGRATION-22.0.md](docs/MIGRATION-22.0.md).
|
|
17
|
+
|
|
18
|
+
### Changed — breaking
|
|
19
|
+
|
|
20
|
+
- **An RFC error that ends the stateful conversation is the session lost.** When sap-rfc-lite
|
|
21
|
+
releases the stateful conversation after a failed call (`alive` false, and not a close of
|
|
22
|
+
ours), the request rejects `ADT_SESSION_REPLACED` with the call's `rfc`, the instance is
|
|
23
|
+
spent, and every later request and `connect()` reject `ADT_NOT_CONNECTED` with nothing sent.
|
|
24
|
+
Nothing opens a new session: with sap-rfc-lite 0.3.x the next request went on, silently, on a
|
|
25
|
+
new one, its locks gone. A new session is a new connection.
|
|
26
|
+
- **The `SAP-PASSPORT` header is no longer a header field over RFC.** It becomes the RFC call's
|
|
27
|
+
passport (below); `SADT_REST_RFC_ENDPOINT` never read it as a field.
|
|
28
|
+
- **`@mcp-abap-adt/sap-rfc-lite` ^0.4.0** (optional, as before), whose minor is itself breaking;
|
|
29
|
+
**`@mcp-abap-adt/interfaces-adt-connection` ^4.1.0**.
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
|
|
33
|
+
- **A failed RFC call carries `rfc: { key, group, code, codeString }`** (`IRfcErrorInfo`;
|
|
34
|
+
`codeString` one of `RFC_RCS`), checked once where the wire receives the SDK's error: own
|
|
35
|
+
data properties only, no getter run, nothing read out of a message. `rfc` is carried on every
|
|
36
|
+
conversation, stateful or not. The message is the call's (`RFC call to SADT_REST_RFC_ENDPOINT
|
|
37
|
+
failed: …`, ending in fixed words when the thrown value cannot be described) and the top-level
|
|
38
|
+
`code` is not set — except when the error ended the stateful conversation: then the message is
|
|
39
|
+
the session-lost one and `code` is `ADT_SESSION_REPLACED` (above). Neither describing the
|
|
40
|
+
thrown value nor a logger that throws — the wire's or the connection's — can replace that
|
|
41
|
+
verdict or the call's `rfc`.
|
|
42
|
+
- **The passport over RFC.** A request's `SAP-PASSPORT` header (name read without case) is
|
|
43
|
+
hex-decoded and handed to sap-rfc-lite as the call's own passport, for that call only, so a
|
|
44
|
+
program started over RFC is caught by a terminal-mode external debugger listening for the
|
|
45
|
+
passport's ids. A value that is not hex, or the header named twice, is refused before
|
|
46
|
+
anything is sent, the value never quoted. No header: no passport. `IRfcConversation.call`
|
|
47
|
+
takes an optional third parameter, `{ passport? }`.
|
|
48
|
+
- **`WireSessionLostError`**, exported beside `WireLogonError`: a wire's mark that the session
|
|
49
|
+
it carries has ended. The connection acts on the class, never on the wire's kind.
|
|
50
|
+
|
|
51
|
+
### Changed
|
|
52
|
+
|
|
53
|
+
- **A non-stateful RFC conversation an RFC error ended is dropped**, not reset or closed (both
|
|
54
|
+
would reject); the next call opens another, and the instance goes on.
|
|
55
|
+
- **An ADT exception type that is not an own key of the status table** (`toString`,
|
|
56
|
+
`constructor`, `__proto__`) reads as `500`; it fell through to `200 OK` before.
|
|
57
|
+
- **No regular expression in the RFC wire:** the exception type and the header names redacted
|
|
58
|
+
in the wire log are read by plain code, with the same results; the exception type in one
|
|
59
|
+
linear scan.
|
|
60
|
+
|
|
10
61
|
## [21.0.0] - 2026-11-11
|
|
11
62
|
|
|
12
63
|
The CSRF token fetch asks once. Breaking for code that reads `CSRF_CONFIG.RETRY_COUNT` /
|
|
@@ -2907,7 +2958,8 @@ const connection = createAbapConnection(config, logger);
|
|
|
2907
2958
|
- JWT token refresh now properly handles connection errors (401/403 during initial connect)
|
|
2908
2959
|
- Permission errors (403 with "ExceptionResourceNoAccess") no longer trigger JWT refresh loops
|
|
2909
2960
|
- Proper separation: base class handles HTTP/session, concrete classes handle auth-specific errors
|
|
2910
|
-
[Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/
|
|
2961
|
+
[Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/v22.0.0...HEAD
|
|
2962
|
+
[22.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v21.0.0...v22.0.0
|
|
2911
2963
|
[21.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v20.1.0...v21.0.0
|
|
2912
2964
|
[20.1.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v20.0.0...v20.1.0
|
|
2913
2965
|
[20.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v19.1.0...v20.0.0
|
package/README.md
CHANGED
|
@@ -162,6 +162,7 @@ the packages above. See [Migration to 9.0.0](./docs/MIGRATION-9.0.md).
|
|
|
162
162
|
|
|
163
163
|
- 📦 **[Installation Guide](./docs/INSTALLATION.md)** - Setup and installation instructions
|
|
164
164
|
- 📚 **[Usage Guide](./docs/USAGE.md)** - Detailed usage examples and API documentation
|
|
165
|
+
- 🚚 **[Migration to 22.0.0](./docs/MIGRATION-22.0.md)** - over RFC: a connection-ending RFC error on the stateful conversation is `ADT_SESSION_REPLACED` and spends the instance (no silent reconnect); a failed RFC call carries `rfc: { key, group, code, codeString }`; the `SAP-PASSPORT` header becomes the RFC call's passport; `@mcp-abap-adt/sap-rfc-lite` ^0.4.0
|
|
165
166
|
- 🚚 **[Migration to 21.0.0](./docs/MIGRATION-21.0.md)** - the CSRF token fetch asks once: no retry, no delay; `CSRF_CONFIG.RETRY_COUNT` / `RETRY_DELAY`, the establish context's `retries` / `retryDelayMs` / `isFatal`, `fetchCsrfToken`'s retry parameters and `endsTheExchange` are removed
|
|
166
167
|
- 🚚 **[Migration to 20.0.0](./docs/MIGRATION-20.0.md)** - an RFC config is an `ISapRfcConfig` that states its address (`ashost` + `sysnr`, or `mshost` + `msserv` / `sysid` + `group`), `client` and `language`: no URL, no defaults, no `SAP_SYSNR`; `getBaseUrl()` may answer `undefined`; hand-built HTTP transports take `baseUrl`; `IAdtSessionContext` has no `baseUrl`
|
|
167
168
|
- 🚚 **[Migration to 19.0.0](./docs/MIGRATION-19.0.md)** - `@mcp-abap-adt/sap-rfc-lite` ^0.3.2: no compile on install; prebuilt RFC bindings for linux-x64, win32-x64, darwin-arm64; elsewhere build sap-rfc-lite's binding from its repository; the API is unchanged
|
|
@@ -501,7 +502,7 @@ package state from causing PAK/058 on later writes or SADT_RESOURCE/007 on a
|
|
|
501
502
|
read after create. Concurrent calls use a separate conversation. See
|
|
502
503
|
[RFC conversation isolation](./docs/STATEFUL_SESSION_GUIDE.md#rfc-conversation-isolation-932-and-933).
|
|
503
504
|
|
|
504
|
-
Needs `npm install @mcp-abap-adt/sap-rfc-lite` (0.
|
|
505
|
+
Needs `npm install @mcp-abap-adt/sap-rfc-lite` (0.4.0 or newer: it installs with no install
|
|
505
506
|
script and carries prebuilt bindings for linux-x64 glibc, win32-x64 and darwin-arm64; elsewhere,
|
|
506
507
|
build one from its repository) and the SAP NetWeaver RFC library at run time: on Windows, the
|
|
507
508
|
64-bit `sapnwrfc.dll` SAP GUI installs into `System32` is enough; otherwise the SAP NW RFC SDK, its
|
|
@@ -541,6 +542,77 @@ await connection.connect();
|
|
|
541
542
|
// disconnect. What differs is where the session lives — see below.
|
|
542
543
|
```
|
|
543
544
|
|
|
545
|
+
**The passport travels as the call's own** (22.0.0). A request that carries a
|
|
546
|
+
`SAP-PASSPORT` header (its name read without case) is sent over RFC with that
|
|
547
|
+
passport as the RFC call's passport, for that call only — so an ABAP program
|
|
548
|
+
started over RFC is caught by an external debugger listening in terminal mode
|
|
549
|
+
for the passport's ids, as it is over HTTP. `SADT_REST_RFC_ENDPOINT` reads no
|
|
550
|
+
passport from a header field, so the header is not sent as one. Its value must
|
|
551
|
+
be the passport in hex (non-empty, even length, `0`–`9` / `a`–`f` / `A`–`F`);
|
|
552
|
+
anything else, or the header named twice, is refused before anything is sent,
|
|
553
|
+
the header named and its value never quoted. The passport's structure is
|
|
554
|
+
sap-rfc-lite's to check. A request without the header carries no passport, as
|
|
555
|
+
before: the wire invents, derives and keeps none. Over HTTP the header goes as
|
|
556
|
+
it always went.
|
|
557
|
+
|
|
558
|
+
**A caught session stays caught.** sap-rfc-lite does not reset a stateful
|
|
559
|
+
session: once a listener has caught a call on it, later calls on the same
|
|
560
|
+
session are caught too, with or without a passport, until the session ends.
|
|
561
|
+
The connection does not reset it either — that would drop its locks. A run
|
|
562
|
+
meant to be caught belongs on a non-stateful request (the kept conversation is
|
|
563
|
+
reset after every call), or on a connection of its own.
|
|
564
|
+
|
|
565
|
+
**A failed RFC call names its error by fields** (22.0.0). When the SDK
|
|
566
|
+
reports the failure, the `Error` the caller receives carries it as
|
|
567
|
+
`rfc: { key, group, code, codeString }` (`IRfcErrorInfo`, typed by
|
|
568
|
+
`IAbapConnectionError` in `@mcp-abap-adt/interfaces-adt-connection`;
|
|
569
|
+
`codeString` is one of `RFC_RCS`). Read the failure from those, never from the
|
|
570
|
+
message: a call's failure says `RFC call to SADT_REST_RFC_ENDPOINT failed: …`
|
|
571
|
+
and sets no top-level `code`; when the error ended the stateful conversation,
|
|
572
|
+
the message is the session-lost one and `code` is `ADT_SESSION_REPLACED`
|
|
573
|
+
(below). `rfc` is carried either way, on every conversation. An error the SDK
|
|
574
|
+
did not name — the closed-connection error, a refused passport — carries no
|
|
575
|
+
`rfc`.
|
|
576
|
+
|
|
577
|
+
```typescript
|
|
578
|
+
import type { RfcReturnCodeName } from "@mcp-abap-adt/interfaces-adt-connection";
|
|
579
|
+
|
|
580
|
+
/** The RFC return code a caught value names in `rfc`, or undefined. */
|
|
581
|
+
function rfcCodeOf(error: unknown): string | undefined {
|
|
582
|
+
if (typeof error !== "object" || error === null || !("rfc" in error)) {
|
|
583
|
+
return undefined;
|
|
584
|
+
}
|
|
585
|
+
const { rfc } = error;
|
|
586
|
+
return typeof rfc === "object" && rfc !== null && "codeString" in rfc &&
|
|
587
|
+
typeof rfc.codeString === "string"
|
|
588
|
+
? rfc.codeString
|
|
589
|
+
: undefined;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
try {
|
|
593
|
+
await connection.makeAdtRequest({ url: "/sap/bc/adt/discovery", method: "GET", timeout: 0 });
|
|
594
|
+
} catch (error) {
|
|
595
|
+
const closed: RfcReturnCodeName = "RFC_CLOSED";
|
|
596
|
+
if (rfcCodeOf(error) === closed) {
|
|
597
|
+
// the other side closed the conversation
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
**An RFC error that ends the session ends the instance** (22.0.0). When an RFC
|
|
603
|
+
error ends the stateful conversation — the one that carries the instance's
|
|
604
|
+
session and its locks (sap-rfc-lite releases it: `alive` is `false`) — the
|
|
605
|
+
request rejects with `code` `ADT_SESSION_REPLACED` and the call's `rfc`; the
|
|
606
|
+
instance is spent, and every later request and `connect()` reject
|
|
607
|
+
`ADT_NOT_CONNECTED` with nothing sent. The connection does not open a new
|
|
608
|
+
session on its own: a lock held in the old one is gone and is never presented
|
|
609
|
+
as still held. A new session is a new connection, which only you create.
|
|
610
|
+
(`terminateDebugger` on the debugger's stateful session ends it this way:
|
|
611
|
+
`RFC_CLOSED`.) A non-stateful conversation an RFC error ends carries no session
|
|
612
|
+
of the instance: it is replaced as a reset replaces it, and the request's error
|
|
613
|
+
still carries its `rfc`. A wire of your own says the same with
|
|
614
|
+
`WireSessionLostError`, exported beside `WireLogonError`.
|
|
615
|
+
|
|
544
616
|
**Where to look for it.** An HTTP session is an ICF session and appears in
|
|
545
617
|
**SM05**. An RFC conversation is a gateway client: it appears in **SMGW → Logged
|
|
546
618
|
on Clients** as `NWRFC`, and never in SM05, because there is no ICM in that
|
|
@@ -464,6 +464,12 @@ declare abstract class AbstractAbapConnection implements AbapConnection, ISessio
|
|
|
464
464
|
* wait for the very request that raised it.
|
|
465
465
|
*/
|
|
466
466
|
protected raiseSessionLost(reason: string): void;
|
|
467
|
+
/**
|
|
468
|
+
* A log line on a failure path: a logger that throws must not replace the
|
|
469
|
+
* failure being reported — a session verdict, the wire's error with its
|
|
470
|
+
* `rfc` — so its throw is dropped. There is nowhere left to say so.
|
|
471
|
+
*/
|
|
472
|
+
private logQuietly;
|
|
467
473
|
/**
|
|
468
474
|
* Whether an error is this connection's own verdict about the session rather
|
|
469
475
|
* than something the server said about a request.
|
|
@@ -632,6 +638,15 @@ declare abstract class AbstractAbapConnection implements AbapConnection, ISessio
|
|
|
632
638
|
* current one, so its answer is not acted on.
|
|
633
639
|
*/
|
|
634
640
|
private throwIfSessionDead;
|
|
641
|
+
/**
|
|
642
|
+
* The wire saying the session it carried has ended — over RFC, an RFC error
|
|
643
|
+
* ended the stateful conversation — is the same verdict: SESSION_REPLACED,
|
|
644
|
+
* the instance spent, the call's `rfc` kept on the error. Acted on by the
|
|
645
|
+
* class of the mark, never by which wire raised it. Nothing opens a new
|
|
646
|
+
* session: that is a new instance, the caller's to create. A mark from a
|
|
647
|
+
* previous session says nothing about the current one and is not acted on.
|
|
648
|
+
*/
|
|
649
|
+
private throwWireSessionLost;
|
|
635
650
|
/**
|
|
636
651
|
* What a request whose lease went stale gets: a session verdict as it is,
|
|
637
652
|
* anything else — the wire's error, the provider's refusal — replaced by
|
|
@@ -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,
|
|
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,EAC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C,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"}
|
|
@@ -938,15 +938,29 @@ class AbstractAbapConnection {
|
|
|
938
938
|
* wait for the very request that raised it.
|
|
939
939
|
*/
|
|
940
940
|
raiseSessionLost(reason) {
|
|
941
|
-
this.logger?.warn(`Session lost: ${reason}`);
|
|
942
941
|
// The instance's one session is gone: it is spent, as after disconnect().
|
|
943
|
-
// Nothing else is decided here — the caller is told, and decides.
|
|
942
|
+
// Nothing else is decided here — the caller is told, and decides. The
|
|
943
|
+
// verdict first, then the word: a logger that throws cannot undo it.
|
|
944
944
|
this.spent = true;
|
|
945
945
|
this.lifecycle.beginTeardown({ origin: 'internal', sessionLost: true });
|
|
946
946
|
void this.lifecycle.transition('cleanup', async () => {
|
|
947
947
|
this.clearSessionState();
|
|
948
948
|
this.lifecycle.markDisconnected();
|
|
949
949
|
});
|
|
950
|
+
this.logQuietly(() => this.logger?.warn(`Session lost: ${reason}`));
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
953
|
+
* A log line on a failure path: a logger that throws must not replace the
|
|
954
|
+
* failure being reported — a session verdict, the wire's error with its
|
|
955
|
+
* `rfc` — so its throw is dropped. There is nowhere left to say so.
|
|
956
|
+
*/
|
|
957
|
+
logQuietly(write) {
|
|
958
|
+
try {
|
|
959
|
+
write();
|
|
960
|
+
}
|
|
961
|
+
catch {
|
|
962
|
+
// The failure being reported outranks the logger's.
|
|
963
|
+
}
|
|
950
964
|
}
|
|
951
965
|
/**
|
|
952
966
|
* Whether an error is this connection's own verdict about the session rather
|
|
@@ -1363,7 +1377,7 @@ class AbstractAbapConnection {
|
|
|
1363
1377
|
//
|
|
1364
1378
|
// A stale request gets its error back and nothing else happens.
|
|
1365
1379
|
if (!this.lifecycle.isCurrent(lease)) {
|
|
1366
|
-
this.logger?.debug('A request from a previous session failed; its recovery is fenced');
|
|
1380
|
+
this.logQuietly(() => this.logger?.debug('A request from a previous session failed; its recovery is fenced'));
|
|
1367
1381
|
throw error;
|
|
1368
1382
|
}
|
|
1369
1383
|
const errorDetails = {
|
|
@@ -1389,15 +1403,15 @@ class AbstractAbapConnection {
|
|
|
1389
1403
|
// Don't retry for network errors - these indicate infrastructure/VPN issues
|
|
1390
1404
|
const networkError = (0, networkErrors_js_1.isNetworkError)(error);
|
|
1391
1405
|
if (networkError) {
|
|
1392
|
-
this.logger?.error(`Network error - cannot connect to SAP system: ${errorDetails.message}`, errorDetails);
|
|
1406
|
+
this.logQuietly(() => this.logger?.error(`Network error - cannot connect to SAP system: ${errorDetails.message}`, errorDetails));
|
|
1393
1407
|
throw error;
|
|
1394
1408
|
}
|
|
1395
1409
|
// Log 404 as debug (common for existence checks), other errors as error
|
|
1396
1410
|
if (errorDetails.status === 404) {
|
|
1397
|
-
this.logger?.debug(errorDetails.message, errorDetails);
|
|
1411
|
+
this.logQuietly(() => this.logger?.debug(errorDetails.message, errorDetails));
|
|
1398
1412
|
}
|
|
1399
1413
|
else {
|
|
1400
|
-
this.logger?.error(errorDetails.message, errorDetails);
|
|
1414
|
+
this.logQuietly(() => this.logger?.error(errorDetails.message, errorDetails));
|
|
1401
1415
|
}
|
|
1402
1416
|
// No session is discarded and reopened on this instance to retry a
|
|
1403
1417
|
// request: one instance is one session. A 401 on a mutation that holds a
|
|
@@ -1439,9 +1453,9 @@ class AbstractAbapConnection {
|
|
|
1439
1453
|
if (this.outranksOriginal(retryError)) {
|
|
1440
1454
|
throw retryError;
|
|
1441
1455
|
}
|
|
1442
|
-
this.logger?.debug(`CSRF retry failed; rethrowing original error: ${retryError instanceof Error
|
|
1456
|
+
this.logQuietly(() => this.logger?.debug(`CSRF retry failed; rethrowing original error: ${retryError instanceof Error
|
|
1443
1457
|
? retryError.message
|
|
1444
|
-
: String(retryError)}`);
|
|
1458
|
+
: String(retryError)}`));
|
|
1445
1459
|
throw error;
|
|
1446
1460
|
}
|
|
1447
1461
|
}
|
|
@@ -1523,6 +1537,9 @@ class AbstractAbapConnection {
|
|
|
1523
1537
|
* current one, so its answer is not acted on.
|
|
1524
1538
|
*/
|
|
1525
1539
|
throwIfSessionDead(error, lease) {
|
|
1540
|
+
if (error instanceof authErrors_js_1.WireSessionLostError) {
|
|
1541
|
+
this.throwWireSessionLost(error, lease);
|
|
1542
|
+
}
|
|
1526
1543
|
if (!this.isDeadSessionResponse(error))
|
|
1527
1544
|
return;
|
|
1528
1545
|
if (!this.lifecycle.isCurrent(lease))
|
|
@@ -1532,6 +1549,23 @@ class AbstractAbapConnection {
|
|
|
1532
1549
|
// in the field. The caller decides.
|
|
1533
1550
|
throw (0, SessionLifecycle_js_1.sessionError)(interfaces_adt_connection_1.ADT_SESSION_ERROR.SESSION_REPLACED, 'The SAP session no longer exists; any lock handle from it is dead');
|
|
1534
1551
|
}
|
|
1552
|
+
/**
|
|
1553
|
+
* The wire saying the session it carried has ended — over RFC, an RFC error
|
|
1554
|
+
* ended the stateful conversation — is the same verdict: SESSION_REPLACED,
|
|
1555
|
+
* the instance spent, the call's `rfc` kept on the error. Acted on by the
|
|
1556
|
+
* class of the mark, never by which wire raised it. Nothing opens a new
|
|
1557
|
+
* session: that is a new instance, the caller's to create. A mark from a
|
|
1558
|
+
* previous session says nothing about the current one and is not acted on.
|
|
1559
|
+
*/
|
|
1560
|
+
throwWireSessionLost(error, lease) {
|
|
1561
|
+
if (!this.lifecycle.isCurrent(lease))
|
|
1562
|
+
return;
|
|
1563
|
+
this.raiseSessionLost('the wire reports the session ended');
|
|
1564
|
+
const verdict = (0, SessionLifecycle_js_1.sessionError)(interfaces_adt_connection_1.ADT_SESSION_ERROR.SESSION_REPLACED, "The RFC conversation that carried this connection's SAP session has ended; any lock held in it is gone. Create a new connection for a new session.");
|
|
1565
|
+
throw error.rfc === undefined
|
|
1566
|
+
? verdict
|
|
1567
|
+
: Object.assign(verdict, { rfc: error.rfc });
|
|
1568
|
+
}
|
|
1535
1569
|
/**
|
|
1536
1570
|
* What a request whose lease went stale gets: a session verdict as it is,
|
|
1537
1571
|
* anything else — the wire's error, the provider's refusal — replaced by
|
|
@@ -165,6 +165,12 @@ export interface IAdtTransport {
|
|
|
165
165
|
* on the error — that is the shape the request path classifies against, and
|
|
166
166
|
* a transport that resolved instead would turn a 401 into a success with a
|
|
167
167
|
* logon page in the body.
|
|
168
|
+
*
|
|
169
|
+
* A wire that loses the session it carries — `RfcTransport` when an RFC
|
|
170
|
+
* error ends the stateful conversation — throws `WireSessionLostError`, and
|
|
171
|
+
* decides nothing else: the connection reports the session lost and the
|
|
172
|
+
* instance is spent. It opens no other session in its place. The HTTP wires
|
|
173
|
+
* never throw it: SAP says so in an answer there.
|
|
168
174
|
*/
|
|
169
175
|
send(request: IAdtTransportRequest): Promise<IAdtTransportResponse>;
|
|
170
176
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IAdtTransport.d.ts","sourceRoot":"","sources":["../../src/connection/IAdtTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE,4DAA4D;AAC5D,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,C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CAAC;IAE1C;;;;;;;;;;;;OAYG;IACH,kBAAkB,IAAI,OAAO,CAAC;IAE9B,4EAA4E;IAC5E,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE1C;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExD,0EAA0E;IAC1E,SAAS,IAAI,MAAM,GAAG,IAAI,CAAC;IAE3B;;;;;;OAMG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IAE3C,oDAAoD;IACpD,aAAa,IAAI,IAAI,CAAC;CACvB;AAED;;;;;;;;;;;;GAYG;AACH;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;CAC3B;AAED,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,qBAAqB,GAAG,IAAI,CAQtE"}
|
|
@@ -58,7 +58,15 @@ import type { IAdtEstablishContext, IAdtSessionContext, IAdtTransportRequest, IA
|
|
|
58
58
|
export interface IRfcConversation {
|
|
59
59
|
open(): Promise<void>;
|
|
60
60
|
close(): Promise<void>;
|
|
61
|
-
|
|
61
|
+
/**
|
|
62
|
+
* `options.passport`, when given, is the SAP passport sent with this call
|
|
63
|
+
* only (`@mcp-abap-adt/sap-rfc-lite` >= 0.4.0). A conversation written for
|
|
64
|
+
* two arguments still conforms: it is never handed a third unless a request
|
|
65
|
+
* carried a passport.
|
|
66
|
+
*/
|
|
67
|
+
call(fm: string, params: Record<string, unknown>, options?: {
|
|
68
|
+
passport?: Buffer | undefined;
|
|
69
|
+
}): Promise<Record<string, unknown>>;
|
|
62
70
|
readonly alive: boolean;
|
|
63
71
|
/**
|
|
64
72
|
* Ends the ABAP session context and keeps the connection open
|
|
@@ -225,6 +233,18 @@ export declare class RfcTransport implements IOnPremTransport {
|
|
|
225
233
|
* answers, whatever the answer.
|
|
226
234
|
*/
|
|
227
235
|
private carryOnThrowaway;
|
|
236
|
+
/**
|
|
237
|
+
* The stateful conversation is `conversation` no more: the library released
|
|
238
|
+
* it, so there is nothing left to close, and a close would only reject.
|
|
239
|
+
*/
|
|
240
|
+
private dropSession;
|
|
241
|
+
/** The kept stateless conversation is `conversation` no more. */
|
|
242
|
+
private dropStateless;
|
|
243
|
+
/**
|
|
244
|
+
* A conversation used for one call, closed — unless an RFC error ended it:
|
|
245
|
+
* the library has released it, and a close would only reject.
|
|
246
|
+
*/
|
|
247
|
+
private closeUnlessReleased;
|
|
228
248
|
/**
|
|
229
249
|
* A new conversation, logged on with `parameters`. The logon takes time
|
|
230
250
|
* (~0.5 s on E19); if the wire was closed meanwhile, the conversation is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RfcTransport.d.ts","sourceRoot":"","sources":["../../src/connection/RfcTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;
|
|
1
|
+
{"version":3,"file":"RfcTransport.d.ts","sourceRoot":"","sources":["../../src/connection/RfcTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAUH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAa5B,sFAAsF;AACtF,MAAM,WAAW,gBAAgB;IAC/B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,KAAK,IAAI,OAAO,CA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AC,WAAW;IAQnB,iEAAiE;IACjE,OAAO,CAAC,aAAa;IAOrB;;;OAGG;YACW,mBAAmB;IAMjC;;;;;OAKG;YACW,OAAO;IAcrB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAgBnB,gEAAgE;YAClD,eAAe;IAM7B;;;;OAIG;IACH,OAAO,CAAC,UAAU;IAMlB;;;;OAIG;YACW,UAAU;IAYxB;;;;OAIG;IACH,OAAO,CAAC,UAAU;YAQJ,YAAY;YAQZ,KAAK;CA6MpB"}
|
|
@@ -57,6 +57,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
57
57
|
exports.RfcTransport = void 0;
|
|
58
58
|
const node_crypto_1 = require("node:crypto");
|
|
59
59
|
const auth_errors_1 = require("@mcp-abap-adt/auth-errors");
|
|
60
|
+
const interfaces_adt_connection_1 = require("@mcp-abap-adt/interfaces-adt-connection");
|
|
60
61
|
const authErrors_js_1 = require("./authErrors.js");
|
|
61
62
|
const statefulRequest_js_1 = require("./statefulRequest.js");
|
|
62
63
|
/**
|
|
@@ -146,19 +147,119 @@ const EXCEPTION_STATUS = {
|
|
|
146
147
|
ExceptionNotSupported: { code: 501, text: 'Not Implemented' },
|
|
147
148
|
ExceptionConflict: { code: 409, text: 'Conflict' },
|
|
148
149
|
};
|
|
150
|
+
const TYPE_OPEN = '<exc:type';
|
|
151
|
+
const TYPE_CLOSE = '</exc:type>';
|
|
152
|
+
/**
|
|
153
|
+
* The text of the first `<exc:type …>TEXT</exc:type>` in `body`: from a
|
|
154
|
+
* `<exc:type`, the first `>` after it opens the text, which runs to the next
|
|
155
|
+
* `<` and counts only when it is not empty and that `<` begins `</exc:type>`.
|
|
156
|
+
*
|
|
157
|
+
* Linear: every search starts where the previous one ended, so the body is
|
|
158
|
+
* read once, left to right. A failed candidate need not be followed by the next
|
|
159
|
+
* `<exc:type` after it: one that begins before its `>` holds no `>` of its own
|
|
160
|
+
* in its first nine characters, so it meets the same `>` and the same `<` and
|
|
161
|
+
* fails the same way; and none begins between that `>` and the `<` that ended
|
|
162
|
+
* the text, since a candidate begins with `<`. The next candidate is searched
|
|
163
|
+
* from that `<`. With no `<` after the `>`, no candidate is left.
|
|
164
|
+
*/
|
|
165
|
+
function exceptionType(body) {
|
|
166
|
+
let open = body.indexOf(TYPE_OPEN);
|
|
167
|
+
while (open >= 0) {
|
|
168
|
+
const tagEnd = body.indexOf('>', open + TYPE_OPEN.length);
|
|
169
|
+
if (tagEnd < 0)
|
|
170
|
+
return undefined;
|
|
171
|
+
const textEnd = body.indexOf('<', tagEnd + 1);
|
|
172
|
+
if (textEnd < 0)
|
|
173
|
+
return undefined;
|
|
174
|
+
if (textEnd > tagEnd + 1 && body.startsWith(TYPE_CLOSE, textEnd)) {
|
|
175
|
+
return body.slice(tagEnd + 1, textEnd);
|
|
176
|
+
}
|
|
177
|
+
open = body.indexOf(TYPE_OPEN, textEnd);
|
|
178
|
+
}
|
|
179
|
+
return undefined;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* The status an exception document stands for. A type is looked up only as an
|
|
183
|
+
* own key of `EXCEPTION_STATUS`: `toString`, `constructor` and the other
|
|
184
|
+
* members every object inherits name no status, and give 500 as an unknown
|
|
185
|
+
* type does.
|
|
186
|
+
*/
|
|
149
187
|
function statusFromExceptionXml(body) {
|
|
150
|
-
const type =
|
|
151
|
-
return
|
|
152
|
-
|
|
153
|
-
text: 'Internal Server Error'
|
|
154
|
-
});
|
|
188
|
+
const type = exceptionType(body)?.trim();
|
|
189
|
+
return type && Object.hasOwn(EXCEPTION_STATUS, type)
|
|
190
|
+
? EXCEPTION_STATUS[type]
|
|
191
|
+
: { code: 500, text: 'Internal Server Error' };
|
|
155
192
|
}
|
|
193
|
+
/** An own data property of `source`, read without running a getter. */
|
|
194
|
+
function ownData(source, name) {
|
|
195
|
+
const descriptor = Object.getOwnPropertyDescriptor(source, name);
|
|
196
|
+
return descriptor !== undefined && 'value' in descriptor
|
|
197
|
+
? descriptor.value
|
|
198
|
+
: undefined;
|
|
199
|
+
}
|
|
200
|
+
function isInteger(value) {
|
|
201
|
+
return typeof value === 'number' && Number.isInteger(value);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The SDK's error as fields, or `undefined` when `thrown` is not that shape.
|
|
205
|
+
*
|
|
206
|
+
* The one place an SDK error enters, so the one place it is checked: `key` and
|
|
207
|
+
* `codeString` own data properties holding strings, `group` and `code` own
|
|
208
|
+
* data properties holding integers, and `codeString` one of the closed list
|
|
209
|
+
* `RFC_RCS`. No getter runs, and an object whose traps throw reads as no
|
|
210
|
+
* shape. `name` and `message` are not read, and nothing is read out of a
|
|
211
|
+
* message.
|
|
212
|
+
*/
|
|
213
|
+
function rfcErrorOf(thrown) {
|
|
214
|
+
if (typeof thrown !== 'object' || thrown === null)
|
|
215
|
+
return undefined;
|
|
216
|
+
try {
|
|
217
|
+
const key = ownData(thrown, 'key');
|
|
218
|
+
const group = ownData(thrown, 'group');
|
|
219
|
+
const code = ownData(thrown, 'code');
|
|
220
|
+
const codeString = ownData(thrown, 'codeString');
|
|
221
|
+
if (typeof key !== 'string' || !isInteger(group) || !isInteger(code)) {
|
|
222
|
+
return undefined;
|
|
223
|
+
}
|
|
224
|
+
// Compared with each listed name, so only a string can match: this is
|
|
225
|
+
// the check of `codeString`, and what is stored is the listed member.
|
|
226
|
+
const listed = interfaces_adt_connection_1.RFC_RCS.find((name) => name === codeString);
|
|
227
|
+
if (listed === undefined)
|
|
228
|
+
return undefined;
|
|
229
|
+
return Object.freeze({ key, group, code, codeString: listed });
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
return undefined;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* What a failed call throws: an `Error` with today's words, and the SDK's
|
|
237
|
+
* fields as `rfc` when the SDK named the failure. The top-level `code` is not
|
|
238
|
+
* set: `rfc` does not change what it means.
|
|
239
|
+
*/
|
|
240
|
+
function rfcCallError(text, rfc) {
|
|
241
|
+
const error = new Error(text);
|
|
242
|
+
return rfc === undefined ? error : Object.assign(error, { rfc });
|
|
243
|
+
}
|
|
244
|
+
/** Words a value is described by when describing it throws. */
|
|
245
|
+
const UNDESCRIBABLE = 'the failure could not be described';
|
|
246
|
+
/**
|
|
247
|
+
* A thrown value in words, for a message and a log line. It never throws:
|
|
248
|
+
* `instanceof` runs a Proxy's trap, `message` may be a getter, and
|
|
249
|
+
* `JSON.stringify` runs every enumerable getter and `toJSON` — any of which
|
|
250
|
+
* may throw. Then the words are fixed, and nothing the throw said is kept.
|
|
251
|
+
*/
|
|
156
252
|
function message(e) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
253
|
+
try {
|
|
254
|
+
if (e instanceof Error)
|
|
255
|
+
return String(e.message);
|
|
256
|
+
if (e && typeof e === 'object')
|
|
257
|
+
return String(JSON.stringify(e));
|
|
258
|
+
return String(e);
|
|
259
|
+
}
|
|
260
|
+
catch {
|
|
261
|
+
return UNDESCRIBABLE;
|
|
262
|
+
}
|
|
162
263
|
}
|
|
163
264
|
/**
|
|
164
265
|
* Header names whose VALUE must never reach a log.
|
|
@@ -169,25 +270,98 @@ function message(e) {
|
|
|
169
270
|
* (`SAP_SESSIONID_*`, `MYSAPSSO2`), an `x-csrf-token` or its own `X-Api-Key`
|
|
170
271
|
* arrives here too. A log line advertised as safe to paste into an issue has
|
|
171
272
|
* to be safe for the headers nobody here anticipated, so this matches by
|
|
172
|
-
*
|
|
273
|
+
* part of the name rather than by the list we happened to think of.
|
|
274
|
+
*
|
|
275
|
+
* Plain string code, no regular expression: the name is folded to lower case
|
|
276
|
+
* in ASCII `A`–`Z` only (the former `/i` patterns, without the `u` flag, never
|
|
277
|
+
* folded a non-ASCII character to an ASCII letter — `toLowerCase()` would map
|
|
278
|
+
* the Kelvin sign to `k`), then searched for each part.
|
|
173
279
|
*/
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
280
|
+
const SECRET_HEADER_PARTS = [
|
|
281
|
+
'authorization',
|
|
282
|
+
'cookie',
|
|
283
|
+
'token',
|
|
284
|
+
'secret',
|
|
285
|
+
'password',
|
|
286
|
+
'credential',
|
|
287
|
+
'apikey',
|
|
288
|
+
'api-key',
|
|
289
|
+
'api_key',
|
|
182
290
|
];
|
|
291
|
+
/** `text` with ASCII `A`–`Z` lowered, every other character as it is. */
|
|
292
|
+
function asciiLowerCase(text) {
|
|
293
|
+
let folded = '';
|
|
294
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
295
|
+
const unit = text.charCodeAt(i);
|
|
296
|
+
folded +=
|
|
297
|
+
unit >= 0x41 && unit <= 0x5a
|
|
298
|
+
? String.fromCharCode(unit + 0x20)
|
|
299
|
+
: text.charAt(i);
|
|
300
|
+
}
|
|
301
|
+
return folded;
|
|
302
|
+
}
|
|
303
|
+
/** Whether a header's value must not reach a log, by its name. */
|
|
304
|
+
function isSecretHeader(name) {
|
|
305
|
+
const folded = asciiLowerCase(name);
|
|
306
|
+
return SECRET_HEADER_PARTS.some((part) => folded.includes(part));
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* The header an HTTP request carries the SAP passport in. Over RFC it is not a
|
|
310
|
+
* header field: `SADT_REST_RFC_ENDPOINT` does not read one there, so the
|
|
311
|
+
* passport goes to the SDK as the call's own.
|
|
312
|
+
*/
|
|
313
|
+
const PASSPORT_HEADER = 'sap-passport';
|
|
314
|
+
function isPassportHeader(name) {
|
|
315
|
+
return asciiLowerCase(name) === PASSPORT_HEADER;
|
|
316
|
+
}
|
|
317
|
+
/** `0`–`9`, `A`–`F`, `a`–`f`. */
|
|
318
|
+
function isHexDigit(unit) {
|
|
319
|
+
return ((unit >= 0x30 && unit <= 0x39) ||
|
|
320
|
+
(unit >= 0x41 && unit <= 0x46) ||
|
|
321
|
+
(unit >= 0x61 && unit <= 0x66));
|
|
322
|
+
}
|
|
323
|
+
/** Non-empty, of even length, and every character a hex digit. */
|
|
324
|
+
function isHex(value) {
|
|
325
|
+
if (value.length === 0 || value.length % 2 !== 0)
|
|
326
|
+
return false;
|
|
327
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
328
|
+
if (!isHexDigit(value.charCodeAt(i)))
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
return true;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* The passport a request carries in `SAP-PASSPORT` (its name read without
|
|
335
|
+
* case), decoded; `undefined` when it carries none. Refused, before anything
|
|
336
|
+
* is sent, when the header is named more than once or its value is not hex —
|
|
337
|
+
* the header named, its value never quoted. The passport's structure is the
|
|
338
|
+
* SDK's to check.
|
|
339
|
+
*/
|
|
340
|
+
function passportOf(headers) {
|
|
341
|
+
let value;
|
|
342
|
+
for (const [name, each] of Object.entries(headers ?? {})) {
|
|
343
|
+
if (!isPassportHeader(name))
|
|
344
|
+
continue;
|
|
345
|
+
if (value !== undefined) {
|
|
346
|
+
throw new Error('The request names SAP-PASSPORT more than once; nothing was sent.');
|
|
347
|
+
}
|
|
348
|
+
value = each;
|
|
349
|
+
}
|
|
350
|
+
if (value === undefined)
|
|
351
|
+
return undefined;
|
|
352
|
+
if (!isHex(value)) {
|
|
353
|
+
throw new Error('The SAP-PASSPORT header is not a passport in hex; nothing was sent.');
|
|
354
|
+
}
|
|
355
|
+
// Only after the test: `Buffer.from(…, 'hex')` stops silently at the first
|
|
356
|
+
// pair that is not hex.
|
|
357
|
+
return Buffer.from(value, 'hex');
|
|
358
|
+
}
|
|
183
359
|
/**
|
|
184
360
|
* The NAME is kept and only the VALUE goes — a redacted header still says it
|
|
185
361
|
* was sent, which is half of what the log is read for.
|
|
186
362
|
*/
|
|
187
363
|
function redactHeaders(fields) {
|
|
188
|
-
return fields.map((field) =>
|
|
189
|
-
? { ...field, VALUE: '[redacted]' }
|
|
190
|
-
: field);
|
|
364
|
+
return fields.map((field) => isSecretHeader(field.NAME) ? { ...field, VALUE: '[redacted]' } : field);
|
|
191
365
|
}
|
|
192
366
|
/**
|
|
193
367
|
* How much of a body a log line carries before it is cut. An ADT payload is
|
|
@@ -394,15 +568,16 @@ class RfcTransport {
|
|
|
394
568
|
// Taken once, here: every await below compares against it, and a call
|
|
395
569
|
// that finds the wire closed since it began sends nothing.
|
|
396
570
|
const generation = this.generation;
|
|
571
|
+
const passport = passportOf(request.headers);
|
|
397
572
|
const language = requestedLanguage(request);
|
|
398
573
|
if ((0, statefulRequest_js_1.isStatefulRequest)(request)) {
|
|
399
574
|
const other = otherLanguage(language, this.logonLanguage);
|
|
400
575
|
if (other !== undefined) {
|
|
401
576
|
throw new Error(`The request asks for ${LANGUAGE_FIELD} ${other}, but the stateful RFC session is logged on in ${this.logonLanguage ?? 'a language neither the RFC conversation factory nor the provider states'}: a session cannot change its language, so the request was not sent.`);
|
|
402
577
|
}
|
|
403
|
-
return this.carry(request, this.conversation, generation);
|
|
578
|
+
return this.carry(request, this.conversation, generation, passport, true);
|
|
404
579
|
}
|
|
405
|
-
return this.carryOnItsOwn(request, language, generation);
|
|
580
|
+
return this.carryOnItsOwn(request, language, generation, passport);
|
|
406
581
|
}
|
|
407
582
|
/**
|
|
408
583
|
* A request that is not stateful, in a fresh ABAP session.
|
|
@@ -422,13 +597,13 @@ class RfcTransport {
|
|
|
422
597
|
* it: the kept one when that one's logon language is the same, else one of
|
|
423
598
|
* its own logged on with that `lang`, closed after the call.
|
|
424
599
|
*/
|
|
425
|
-
async carryOnItsOwn(request, language, generation) {
|
|
600
|
+
async carryOnItsOwn(request, language, generation, passport) {
|
|
426
601
|
if (this.canReset !== false && !this.statelessBusy) {
|
|
427
|
-
return this.carryOnKept(request, language, generation);
|
|
602
|
+
return this.carryOnKept(request, language, generation, passport);
|
|
428
603
|
}
|
|
429
|
-
return this.carryOnThrowaway(request, inLanguage(await this.logonParameters(), language), generation);
|
|
604
|
+
return this.carryOnThrowaway(request, inLanguage(await this.logonParameters(), language), generation, passport);
|
|
430
605
|
}
|
|
431
|
-
async carryOnKept(request, language, generation) {
|
|
606
|
+
async carryOnKept(request, language, generation, passport) {
|
|
432
607
|
this.statelessBusy = true;
|
|
433
608
|
try {
|
|
434
609
|
let kept = this.stateless;
|
|
@@ -437,7 +612,7 @@ class RfcTransport {
|
|
|
437
612
|
// kept conversation would log on in, before any logon is made.
|
|
438
613
|
const parameters = await this.logonParameters();
|
|
439
614
|
if (otherLanguage(language, this.languageOf(parameters)) !== undefined) {
|
|
440
|
-
return await this.carryOnThrowaway(request, inLanguage(parameters, language), generation);
|
|
615
|
+
return await this.carryOnThrowaway(request, inLanguage(parameters, language), generation, passport);
|
|
441
616
|
}
|
|
442
617
|
const opened = await this.openOwn(parameters, generation);
|
|
443
618
|
// Checked again after the await: close() may have run since openOwn()
|
|
@@ -452,10 +627,10 @@ class RfcTransport {
|
|
|
452
627
|
// and every later call opens its own.
|
|
453
628
|
this.canReset = false;
|
|
454
629
|
try {
|
|
455
|
-
return await this.carry(request, opened, generation);
|
|
630
|
+
return await this.carry(request, opened, generation, passport);
|
|
456
631
|
}
|
|
457
632
|
finally {
|
|
458
|
-
await this.
|
|
633
|
+
await this.closeUnlessReleased(opened);
|
|
459
634
|
}
|
|
460
635
|
}
|
|
461
636
|
this.canReset = true;
|
|
@@ -465,23 +640,30 @@ class RfcTransport {
|
|
|
465
640
|
this.logger?.debug('RFC stateless conversation opened (reset per call)');
|
|
466
641
|
}
|
|
467
642
|
else if (otherLanguage(language, this.statelessLanguage) !== undefined) {
|
|
468
|
-
return await this.carryOnThrowaway(request, inLanguage(await this.logonParameters(), language), generation);
|
|
643
|
+
return await this.carryOnThrowaway(request, inLanguage(await this.logonParameters(), language), generation, passport);
|
|
469
644
|
}
|
|
470
645
|
try {
|
|
471
|
-
return await this.carry(request, kept, generation);
|
|
646
|
+
return await this.carry(request, kept, generation, passport);
|
|
472
647
|
}
|
|
473
648
|
finally {
|
|
474
|
-
|
|
475
|
-
|
|
649
|
+
if (!kept.alive) {
|
|
650
|
+
// An RFC error ended it, and the library released it: nothing is
|
|
651
|
+
// left to reset or close, and either would reject. It carried no
|
|
652
|
+
// session of this instance — a reset clears it after every call —
|
|
653
|
+
// so it is replaced as a failed reset replaces it: dropped, and the
|
|
654
|
+
// next call opens another.
|
|
655
|
+
this.dropStateless(kept);
|
|
476
656
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
657
|
+
else {
|
|
658
|
+
try {
|
|
659
|
+
await kept.resetServerContext?.();
|
|
660
|
+
}
|
|
661
|
+
catch (e) {
|
|
662
|
+
// A context that could not be reset must not serve the next call.
|
|
663
|
+
this.logQuietly(() => `RFC reset failed, dropping the conversation: ${message(e)}`);
|
|
664
|
+
this.dropStateless(kept);
|
|
665
|
+
await this.closeQuietly(kept);
|
|
483
666
|
}
|
|
484
|
-
await this.closeQuietly(kept);
|
|
485
667
|
}
|
|
486
668
|
}
|
|
487
669
|
}
|
|
@@ -493,16 +675,42 @@ class RfcTransport {
|
|
|
493
675
|
* A conversation opened for this one call with `parameters`, closed when it
|
|
494
676
|
* answers, whatever the answer.
|
|
495
677
|
*/
|
|
496
|
-
async carryOnThrowaway(request, parameters, generation) {
|
|
678
|
+
async carryOnThrowaway(request, parameters, generation, passport) {
|
|
497
679
|
const own = await this.openOwn(parameters, generation);
|
|
498
680
|
try {
|
|
499
681
|
this.logger?.debug('RFC conversation opened for one stateless call');
|
|
500
|
-
return await this.carry(request, own, generation);
|
|
682
|
+
return await this.carry(request, own, generation, passport);
|
|
501
683
|
}
|
|
502
684
|
finally {
|
|
503
|
-
await this.
|
|
685
|
+
await this.closeUnlessReleased(own);
|
|
504
686
|
}
|
|
505
687
|
}
|
|
688
|
+
/**
|
|
689
|
+
* The stateful conversation is `conversation` no more: the library released
|
|
690
|
+
* it, so there is nothing left to close, and a close would only reject.
|
|
691
|
+
*/
|
|
692
|
+
dropSession(conversation) {
|
|
693
|
+
if (this.conversation === conversation) {
|
|
694
|
+
this.conversation = null;
|
|
695
|
+
this.conversationId = '';
|
|
696
|
+
this.logonLanguage = undefined;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
/** The kept stateless conversation is `conversation` no more. */
|
|
700
|
+
dropStateless(conversation) {
|
|
701
|
+
if (this.stateless === conversation) {
|
|
702
|
+
this.stateless = null;
|
|
703
|
+
this.statelessLanguage = undefined;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* A conversation used for one call, closed — unless an RFC error ended it:
|
|
708
|
+
* the library has released it, and a close would only reject.
|
|
709
|
+
*/
|
|
710
|
+
async closeUnlessReleased(conversation) {
|
|
711
|
+
if (conversation.alive)
|
|
712
|
+
await this.closeQuietly(conversation);
|
|
713
|
+
}
|
|
506
714
|
/**
|
|
507
715
|
* A new conversation, logged on with `parameters`. The logon takes time
|
|
508
716
|
* (~0.5 s on E19); if the wire was closed meanwhile, the conversation is
|
|
@@ -589,7 +797,9 @@ class RfcTransport {
|
|
|
589
797
|
this.logQuietly(() => `RFC close error: ${message(e)}`);
|
|
590
798
|
}
|
|
591
799
|
}
|
|
592
|
-
async carry(request, conversation, generation
|
|
800
|
+
async carry(request, conversation, generation, passport,
|
|
801
|
+
/** Whether `conversation` is the stateful one: the instance's session. */
|
|
802
|
+
carriesSession = false) {
|
|
593
803
|
const method = request.method.toUpperCase();
|
|
594
804
|
// HTTP clients serialise `params`; RFC has no such step, so they go into
|
|
595
805
|
// the URI here or they do not travel at all.
|
|
@@ -599,7 +809,11 @@ class RfcTransport {
|
|
|
599
809
|
const serialised = new URLSearchParams(query.map(([k, v]) => [k, String(v)])).toString();
|
|
600
810
|
uri += (uri.includes('?') ? '&' : '?') + serialised;
|
|
601
811
|
}
|
|
602
|
-
|
|
812
|
+
// The passport is not a header field over RFC: it goes to the SDK as the
|
|
813
|
+
// call's own (`passport`, read in `send()`).
|
|
814
|
+
const headerFields = Object.entries(request.headers ?? {})
|
|
815
|
+
.filter(([NAME]) => !isPassportHeader(NAME))
|
|
816
|
+
.map(([NAME, VALUE]) => ({ NAME, VALUE: String(VALUE) }));
|
|
603
817
|
// ADT refuses a request with no Accept — `400 ExceptionResourceBadRequest:
|
|
604
818
|
// Accept header missing`, measured on E19. Over HTTP axios supplies the
|
|
605
819
|
// default and nobody notices; this endpoint forwards only what it is
|
|
@@ -652,7 +866,7 @@ class RfcTransport {
|
|
|
652
866
|
}
|
|
653
867
|
let raw;
|
|
654
868
|
try {
|
|
655
|
-
|
|
869
|
+
const params = {
|
|
656
870
|
REQUEST: {
|
|
657
871
|
REQUEST_LINE: {
|
|
658
872
|
METHOD: method,
|
|
@@ -662,13 +876,40 @@ class RfcTransport {
|
|
|
662
876
|
HEADER_FIELDS: headerFields,
|
|
663
877
|
MESSAGE_BODY: body ? Buffer.from(body, 'utf-8') : Buffer.alloc(0),
|
|
664
878
|
},
|
|
665
|
-
}
|
|
879
|
+
};
|
|
880
|
+
// The passport, for this call only; without one, the call as it always
|
|
881
|
+
// was — two arguments, so a conversation written for two still works.
|
|
882
|
+
raw =
|
|
883
|
+
passport === undefined
|
|
884
|
+
? await conversation.call('SADT_REST_RFC_ENDPOINT', params)
|
|
885
|
+
: await conversation.call('SADT_REST_RFC_ENDPOINT', params, {
|
|
886
|
+
passport,
|
|
887
|
+
});
|
|
666
888
|
}
|
|
667
889
|
catch (e) {
|
|
668
890
|
// An RFC-level failure, not an answer: nothing came back to classify.
|
|
891
|
+
// The verdict comes first — the SDK's fields, read once, and whether the
|
|
892
|
+
// session survived — so nothing that describes the failure afterwards
|
|
893
|
+
// (formatting the thrown value, a logger) can stand in for it.
|
|
894
|
+
const rfc = rfcErrorOf(e);
|
|
895
|
+
// The library released the stateful conversation after the error
|
|
896
|
+
// (`alive` false), and it was not a close() of ours: the session it
|
|
897
|
+
// carried is gone, with every lock taken in it. Said, not cured — no
|
|
898
|
+
// other conversation is opened in its place.
|
|
899
|
+
const lost = carriesSession && !conversation.alive && generation === this.generation;
|
|
900
|
+
if (lost)
|
|
901
|
+
this.dropSession(conversation);
|
|
669
902
|
const msg = message(e);
|
|
670
|
-
|
|
671
|
-
|
|
903
|
+
const text = `RFC call to SADT_REST_RFC_ENDPOINT failed: ${msg}`;
|
|
904
|
+
try {
|
|
905
|
+
this.logger?.error(`RFC call failed: ${msg}`);
|
|
906
|
+
}
|
|
907
|
+
catch {
|
|
908
|
+
// A broken logger must not replace the call's failure.
|
|
909
|
+
}
|
|
910
|
+
if (lost)
|
|
911
|
+
throw new authErrors_js_1.WireSessionLostError(text, rfc);
|
|
912
|
+
throw rfcCallError(text, rfc);
|
|
672
913
|
}
|
|
673
914
|
const answer = record(raw.RESPONSE) ?? raw;
|
|
674
915
|
const statusLine = record(answer.STATUS_LINE);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* What the connection raises when the credential says no, and the mark a wire
|
|
3
3
|
* puts on a failure that is a refused logon.
|
|
4
4
|
*/
|
|
5
|
+
import type { IAbapConnectionError, IRfcErrorInfo } from '@mcp-abap-adt/interfaces-adt-connection';
|
|
5
6
|
import type { AuthOutcome, IAuthRefusal } from '@mcp-abap-adt/interfaces-auth';
|
|
6
7
|
/** When in the connection's life the credential refused. */
|
|
7
8
|
export type AuthRefusalMoment = 'prepare' | 'logon' | 'request';
|
|
@@ -35,6 +36,19 @@ export declare class WireLogonError extends Error {
|
|
|
35
36
|
readonly cause: unknown;
|
|
36
37
|
constructor(cause: unknown, status?: number);
|
|
37
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* A wire's mark: the session this wire carries has ended under it — over RFC,
|
|
41
|
+
* an RFC error ended the stateful conversation, and the locks taken in it
|
|
42
|
+
* with it. It decides nothing: the connection reports the session lost and
|
|
43
|
+
* the instance is spent; nothing opens a new session in its place.
|
|
44
|
+
*
|
|
45
|
+
* Exported so a consumer's own wire can say the same thing. `rfc` is the
|
|
46
|
+
* failed call's fields when the SDK named the failure.
|
|
47
|
+
*/
|
|
48
|
+
export declare class WireSessionLostError extends Error implements IAbapConnectionError {
|
|
49
|
+
readonly rfc?: IRfcErrorInfo | undefined;
|
|
50
|
+
constructor(message: string, rfc?: IRfcErrorInfo);
|
|
51
|
+
}
|
|
38
52
|
/**
|
|
39
53
|
* A provider threw instead of answering, or answered something that is not an
|
|
40
54
|
* outcome: a bug in the provider, not an answer.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authErrors.d.ts","sourceRoot":"","sources":["../../src/connection/authErrors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE/E,4DAA4D;AAC5D,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAEhE;;;;;;;;;;;GAWG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,EAAE,EAAE,iBAAiB,CAAC;IAC/B,SAAkB,KAAK,CAAC,EAAE,OAAO,CAAC;gBAEtB,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,OAAO;CAU1E;AAmBD;;;;;;GAMG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,SAAkB,KAAK,EAAE,OAAO,CAAC;gBAErB,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM;CAM5C;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,iBAAiB,GAAG,YAAY,CAElE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,iBAAiB,GAAG,YAAY,CAEhE;AAED,oEAAoE;AACpE,eAAO,MAAM,sBAAsB,EAAE,YAEnC,CAAC;AAEH;;;;GAIG;AACH,MAAM,WAAW,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D;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,iBAAiB,GAAG,YAAY,CAElE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,iBAAiB,GAAG,YAAY,CAEhE;AAED,oEAAoE;AACpE,eAAO,MAAM,sBAAsB,EAAE,YAEnC,CAAC;AAEH;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,OAAO,CAC3B,IAAI,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,EAChC,EAAE,EAAE,iBAAiB,GACpB,OAAO,CAAC,aAAa,CAAC,CAOxB"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* puts on a failure that is a refused logon.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.NO_CREDENTIAL_TO_RENEW = exports.WireLogonError = exports.AuthRefusedError = void 0;
|
|
7
|
+
exports.NO_CREDENTIAL_TO_RENEW = exports.WireSessionLostError = exports.WireLogonError = exports.AuthRefusedError = void 0;
|
|
8
8
|
exports.providerFailed = providerFailed;
|
|
9
9
|
exports.refusedAgain = refusedAgain;
|
|
10
10
|
exports.guarded = guarded;
|
|
@@ -66,6 +66,24 @@ class WireLogonError extends Error {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
exports.WireLogonError = WireLogonError;
|
|
69
|
+
/**
|
|
70
|
+
* A wire's mark: the session this wire carries has ended under it — over RFC,
|
|
71
|
+
* an RFC error ended the stateful conversation, and the locks taken in it
|
|
72
|
+
* with it. It decides nothing: the connection reports the session lost and
|
|
73
|
+
* the instance is spent; nothing opens a new session in its place.
|
|
74
|
+
*
|
|
75
|
+
* Exported so a consumer's own wire can say the same thing. `rfc` is the
|
|
76
|
+
* failed call's fields when the SDK named the failure.
|
|
77
|
+
*/
|
|
78
|
+
class WireSessionLostError extends Error {
|
|
79
|
+
rfc;
|
|
80
|
+
constructor(message, rfc) {
|
|
81
|
+
super(message);
|
|
82
|
+
this.name = 'WireSessionLostError';
|
|
83
|
+
this.rfc = rfc;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.WireSessionLostError = WireSessionLostError;
|
|
69
87
|
/**
|
|
70
88
|
* A provider threw instead of answering, or answered something that is not an
|
|
71
89
|
* outcome: a bug in the provider, not an answer.
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { sapConfigSignature } from './config/sapConfig.js';
|
|
|
4
4
|
export type { AbapConnection, AbapRequestOptions, } from './connection/AbapConnection.js';
|
|
5
5
|
export { AdtCloudConnector } from './connection/AdtCloudConnector.js';
|
|
6
6
|
export { AdtOnPremConnector } from './connection/AdtOnPremConnector.js';
|
|
7
|
-
export { type AuthRefusalMoment, AuthRefusedError, WireLogonError, } from './connection/authErrors.js';
|
|
7
|
+
export { type AuthRefusalMoment, AuthRefusedError, WireLogonError, WireSessionLostError, } from './connection/authErrors.js';
|
|
8
8
|
export { CloudHttpTransport } from './connection/CloudHttpTransport.js';
|
|
9
9
|
export { type CloudHttpSpec, type ConnectionSpec, type CreatedConnection, createConnection, type OnPremHttpSpec, type OnPremRfcSpec, } from './connection/createConnection.js';
|
|
10
10
|
export { CSRF_CONFIG, CSRF_ERROR_MESSAGES } from './connection/csrfConfig.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EACV,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,kCAAkC,CAAC;AAK1C,YAAY,EACV,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,YAAY,GACb,MAAM,uBAAuB,CAAC;AA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AAC;AAEnD,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,aAAa,EACb,cAAc,GACf,MAAM,+BAA+B,CAAC;AACvC,YAAY,EACV,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,YAAY,GACb,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACL,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,mBAAmB,EACnB,aAAa,GACd,MAAM,iCAAiC,CAAC;AACzC,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Types - re-exported from the contract packages, under the names this
|
|
3
3
|
// package has always published them by.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.rfcParamsFrom = exports.rfcConversationFrom = exports.RfcTransport = exports.OnPremHttpTransport = exports.LegacyOnPremHttpTransport = exports.nodeHttpClient = exports.HttpTransport = exports.GenericWebSocketTransport = exports.CSRF_ERROR_MESSAGES = exports.CSRF_CONFIG = exports.createConnection = exports.CloudHttpTransport = exports.WireLogonError = exports.AuthRefusedError = exports.AdtOnPremConnector = exports.AdtCloudConnector = exports.sapConfigSignature = void 0;
|
|
5
|
+
exports.rfcParamsFrom = exports.rfcConversationFrom = exports.RfcTransport = exports.OnPremHttpTransport = exports.LegacyOnPremHttpTransport = exports.nodeHttpClient = exports.HttpTransport = exports.GenericWebSocketTransport = exports.CSRF_ERROR_MESSAGES = exports.CSRF_CONFIG = exports.createConnection = exports.CloudHttpTransport = exports.WireSessionLostError = exports.WireLogonError = exports.AuthRefusedError = exports.AdtOnPremConnector = exports.AdtCloudConnector = exports.sapConfigSignature = void 0;
|
|
6
6
|
// Config utilities
|
|
7
7
|
var sapConfig_js_1 = require("./config/sapConfig.js");
|
|
8
8
|
Object.defineProperty(exports, "sapConfigSignature", { enumerable: true, get: function () { return sapConfig_js_1.sapConfigSignature; } });
|
|
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "AdtOnPremConnector", { enumerable: true, get: fu
|
|
|
13
13
|
var authErrors_js_1 = require("./connection/authErrors.js");
|
|
14
14
|
Object.defineProperty(exports, "AuthRefusedError", { enumerable: true, get: function () { return authErrors_js_1.AuthRefusedError; } });
|
|
15
15
|
Object.defineProperty(exports, "WireLogonError", { enumerable: true, get: function () { return authErrors_js_1.WireLogonError; } });
|
|
16
|
+
Object.defineProperty(exports, "WireSessionLostError", { enumerable: true, get: function () { return authErrors_js_1.WireSessionLostError; } });
|
|
16
17
|
var CloudHttpTransport_js_1 = require("./connection/CloudHttpTransport.js");
|
|
17
18
|
Object.defineProperty(exports, "CloudHttpTransport", { enumerable: true, get: function () { return CloudHttpTransport_js_1.CloudHttpTransport; } });
|
|
18
19
|
// The recommended way to build a connection: the system and the wire stated,
|
package/docs/INDEX.md
CHANGED
|
@@ -15,6 +15,7 @@ mcp-abap-connection/
|
|
|
15
15
|
│ ├── INSTALLATION.md # Setup and installation guide
|
|
16
16
|
│ ├── USAGE.md # API documentation and examples
|
|
17
17
|
│ ├── MIGRATION-2.0.md # Moving to the explicit session lifecycle
|
|
18
|
+
│ ├── MIGRATION-22.0.md # RFC: the session lost after a connection-ending error; rfc fields; the passport
|
|
18
19
|
│ ├── MIGRATION-21.0.md # the CSRF token fetch asks once: no retry, no delay
|
|
19
20
|
│ ├── MIGRATION-20.0.md # an RFC config states its address, client and language; no URL over RFC
|
|
20
21
|
│ ├── MIGRATION-18.0.md # rfcParamsFrom returns RfcAddress; RFC through a message server
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Migration to 22.0
|
|
2
|
+
|
|
3
|
+
22.0.0 changes three things on the RFC wire. HTTP is unchanged.
|
|
4
|
+
|
|
5
|
+
## What changed
|
|
6
|
+
|
|
7
|
+
- **An RFC error that ends the stateful conversation ends the instance's
|
|
8
|
+
session.** The stateful conversation carries the instance's session and every
|
|
9
|
+
lock taken in it. When an RFC error ends it — sap-rfc-lite 0.4.0 releases it
|
|
10
|
+
(`alive` is `false`) — the request rejects with `code`
|
|
11
|
+
`ADT_SESSION_REPLACED` and the RFC call's fields as `rfc`; the instance is
|
|
12
|
+
spent: every later request and `connect()` reject `ADT_NOT_CONNECTED`, and
|
|
13
|
+
nothing is sent. The connection opens no new session on its own. With 21.x
|
|
14
|
+
and sap-rfc-lite 0.3.x the next request went on, silently, on a new session,
|
|
15
|
+
and a lock taken in the old one was gone without a word.
|
|
16
|
+
- **A failed RFC call carries `rfc`.** When the SDK names the failure, the
|
|
17
|
+
error carries `rfc: { key, group, code, codeString }` (`IRfcErrorInfo` from
|
|
18
|
+
`@mcp-abap-adt/interfaces-adt-connection` 4.1; `codeString` is one of
|
|
19
|
+
`RFC_RCS`), on every conversation, stateful or not. The top-level `code`
|
|
20
|
+
keeps its meaning: unset on a call's failure, whose message is the call's
|
|
21
|
+
(`RFC call to SADT_REST_RFC_ENDPOINT failed: …`); when the error ended the
|
|
22
|
+
stateful conversation, the message is the session-lost one and `code` is
|
|
23
|
+
`ADT_SESSION_REPLACED` (above).
|
|
24
|
+
- **The `SAP-PASSPORT` header becomes the RFC call's passport.** Over RFC the
|
|
25
|
+
header is hex-decoded and handed to sap-rfc-lite for that call only; it is no
|
|
26
|
+
longer sent to `SADT_REST_RFC_ENDPOINT` as a header field (which never read
|
|
27
|
+
it). A value that is not hex, or the header named twice, is refused before
|
|
28
|
+
anything is sent.
|
|
29
|
+
- **`@mcp-abap-adt/sap-rfc-lite` ^0.4.0**, an optional dependency as before.
|
|
30
|
+
|
|
31
|
+
## What to do
|
|
32
|
+
|
|
33
|
+
**Read an RFC failure from `rfc`, not from the message.** The caught value
|
|
34
|
+
is checked, as anything caught is; what it may carry is
|
|
35
|
+
`IAbapConnectionError` (`code`, `rfc`):
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import type { RfcReturnCodeName } from "@mcp-abap-adt/interfaces-adt-connection";
|
|
39
|
+
|
|
40
|
+
function rfcCodeOf(error: unknown): string | undefined {
|
|
41
|
+
if (typeof error !== "object" || error === null || !("rfc" in error)) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const { rfc } = error;
|
|
45
|
+
return typeof rfc === "object" && rfc !== null && "codeString" in rfc &&
|
|
46
|
+
typeof rfc.codeString === "string"
|
|
47
|
+
? rfc.codeString
|
|
48
|
+
: undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const closed: RfcReturnCodeName = "RFC_CLOSED";
|
|
52
|
+
function conversationClosed(error: unknown): boolean {
|
|
53
|
+
return rfcCodeOf(error) === closed;
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**After `ADT_SESSION_REPLACED` over RFC, create a new connection.** The
|
|
58
|
+
instance is spent, as after any lost session. Every lock taken on the old
|
|
59
|
+
session is gone: take it again on the new one, never carry its lock handle
|
|
60
|
+
over. `disconnect()` is still owed once on the old instance; it sends nothing
|
|
61
|
+
for the ended conversation.
|
|
62
|
+
|
|
63
|
+
**A stateful session caught by a debugger stays caught.** Once an external
|
|
64
|
+
debugger caught a call on the stateful RFC session, later calls on it are
|
|
65
|
+
caught too, with or without a passport, until the session ends; the connection
|
|
66
|
+
does not reset it, because that would drop its locks. Send a run meant to be
|
|
67
|
+
caught as a non-stateful request, or on a connection of its own.
|
|
68
|
+
|
|
69
|
+
**Install sap-rfc-lite 0.4.0 or newer** where you take the RFC wire:
|
|
70
|
+
`npm install @mcp-abap-adt/sap-rfc-lite@^0.4.0`.
|
|
71
|
+
|
|
72
|
+
**A wire of your own** that loses the session it carries throws
|
|
73
|
+
`WireSessionLostError` (exported beside `WireLogonError`); the connection then
|
|
74
|
+
reports `ADT_SESSION_REPLACED` and spends the instance, as it does for RFC.
|
|
75
|
+
|
|
76
|
+
**A conversation factory of your own** (`RfcConversationFactory`) keeps
|
|
77
|
+
working: `IRfcConversation.call` gains an optional third parameter
|
|
78
|
+
(`{ passport? }`), passed only when a request carries a passport.
|
package/docs/USAGE.md
CHANGED
|
@@ -709,6 +709,24 @@ written. The old session SAP already ended, and a session reported gone
|
|
|
709
709
|
`ADT_SESSION_REPLACED` reaches the caller as before. Over RFC the
|
|
710
710
|
conversation is the session and no answer can replace it.
|
|
711
711
|
|
|
712
|
+
**Over RFC, an RFC error can end the session** (22.0.0). When an RFC error
|
|
713
|
+
ends the stateful conversation — sap-rfc-lite releases it (`alive` is
|
|
714
|
+
`false`) — the session it carried is gone with its locks. The request rejects
|
|
715
|
+
`ADT_SESSION_REPLACED`, with the RFC call's fields as `rfc` (`key`, `group`,
|
|
716
|
+
`code`, `codeString`), and the instance is spent as above: `connect()` and
|
|
717
|
+
every request reject `ADT_NOT_CONNECTED`, nothing is sent, and no new
|
|
718
|
+
conversation is opened. Before 22.0.0 the next request went on, silently, on a
|
|
719
|
+
new session, its locks gone. Create a new connection for a new session. A
|
|
720
|
+
non-stateful conversation an RFC error ends is not the instance's session: it
|
|
721
|
+
is dropped as a failed reset drops it, the next call opens another, and the
|
|
722
|
+
instance goes on. The wire says it with `WireSessionLostError`; the connection
|
|
723
|
+
acts on that class, whichever wire throws it.
|
|
724
|
+
|
|
725
|
+
**A caught stateful session stays caught.** Once an external debugger caught
|
|
726
|
+
a call on the stateful RFC session, later calls on it are caught too, with or
|
|
727
|
+
without a passport, until it ends. The connection does not reset it: that
|
|
728
|
+
would drop its locks.
|
|
729
|
+
|
|
712
730
|
## Advanced Features
|
|
713
731
|
|
|
714
732
|
### Session ID Management
|
|
@@ -1099,6 +1117,25 @@ carries it; the wire never reads `config.username` or `config.password`.
|
|
|
1099
1117
|
over RFC: the open fails, the provider is asked, and you get its refusal.
|
|
1100
1118
|
- A failed RFC open is thrown as `WireLogonError` with the SDK's own error as
|
|
1101
1119
|
`cause`, so a provider can read the SDK's `key` and message.
|
|
1120
|
+
- **A failed RFC call carries `rfc`** (22.0.0): `{ key, group, code,
|
|
1121
|
+
codeString }` (`IRfcErrorInfo`, `codeString` one of `RFC_RCS`, both from
|
|
1122
|
+
`@mcp-abap-adt/interfaces-adt-connection`), checked once where the wire
|
|
1123
|
+
receives the SDK's error — own data properties only, nothing read out of a
|
|
1124
|
+
message. An error the SDK did not name carries no `rfc`. `rfc` is carried on
|
|
1125
|
+
every conversation, stateful or not. The message is the call's
|
|
1126
|
+
(`RFC call to SADT_REST_RFC_ENDPOINT failed: …`, ending in fixed words when
|
|
1127
|
+
the thrown value cannot be described) and the top-level `code` is not set —
|
|
1128
|
+
except when the error ended the stateful conversation: then the message is
|
|
1129
|
+
the session-lost one ("The RFC conversation that carried this connection's
|
|
1130
|
+
SAP session has ended; …") and `code` is `ADT_SESSION_REPLACED`, the instance
|
|
1131
|
+
spent (README, "RFC").
|
|
1132
|
+
- **The `SAP-PASSPORT` header is the RFC call's passport** (22.0.0). Its name
|
|
1133
|
+
read without case, its value hex-decoded and handed to sap-rfc-lite as
|
|
1134
|
+
`call(…, { passport })` for that call only, on whichever conversation carries
|
|
1135
|
+
the request; it is not sent as a header field (`SADT_REST_RFC_ENDPOINT` reads
|
|
1136
|
+
none). A value that is not hex, or the header named twice, is refused before
|
|
1137
|
+
anything is sent, the value never quoted. No header: no passport, the call as
|
|
1138
|
+
before.
|
|
1102
1139
|
|
|
1103
1140
|
**`logWire` dumps the wire, and is off.** With it on, `RfcTransport` adds three
|
|
1104
1141
|
debug lines per request — the header fields, the request body and the response
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-abap-adt/connection",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "22.0.0",
|
|
4
4
|
"description": "ABAP connection layer for MCP ABAP ADT server",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@mcp-abap-adt/auth-errors": "^2.2.1",
|
|
55
|
-
"@mcp-abap-adt/interfaces-adt-connection": "^4.
|
|
55
|
+
"@mcp-abap-adt/interfaces-adt-connection": "^4.1.0",
|
|
56
56
|
"@mcp-abap-adt/interfaces-auth": "^7.5.0",
|
|
57
57
|
"@mcp-abap-adt/interfaces-auth-sap": "^4.0.0",
|
|
58
58
|
"@mcp-abap-adt/interfaces-network": "^2.0.1",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"axios": "^1.16.0"
|
|
61
61
|
},
|
|
62
62
|
"optionalDependencies": {
|
|
63
|
-
"@mcp-abap-adt/sap-rfc-lite": "^0.
|
|
63
|
+
"@mcp-abap-adt/sap-rfc-lite": "^0.4.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@biomejs/biome": "^2.3.14",
|