@mcp-abap-adt/connection 16.0.0 → 17.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 +44 -1
- package/README.md +74 -18
- package/dist/connection/AbstractAbapConnection.d.ts +51 -19
- package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
- package/dist/connection/AbstractAbapConnection.js +100 -32
- package/dist/connection/AdtCloudConnector.d.ts +6 -1
- package/dist/connection/AdtCloudConnector.d.ts.map +1 -1
- package/dist/connection/AdtCloudConnector.js +7 -2
- package/dist/connection/AdtOnPremConnector.d.ts +6 -1
- package/dist/connection/AdtOnPremConnector.d.ts.map +1 -1
- package/dist/connection/AdtOnPremConnector.js +7 -2
- package/dist/connection/CloudHttpTransport.d.ts.map +1 -1
- package/dist/connection/CloudHttpTransport.js +2 -3
- package/dist/connection/CredentialAbapConnection.d.ts +3 -1
- package/dist/connection/CredentialAbapConnection.d.ts.map +1 -1
- package/dist/connection/CredentialAbapConnection.js +4 -2
- package/dist/connection/GenericWebSocketTransport.d.ts.map +1 -1
- package/dist/connection/GenericWebSocketTransport.js +7 -4
- package/dist/connection/HttpTransport.d.ts +19 -0
- package/dist/connection/HttpTransport.d.ts.map +1 -1
- package/dist/connection/HttpTransport.js +115 -5
- package/dist/connection/IAdtTransport.d.ts +34 -3
- package/dist/connection/IAdtTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.d.ts +7 -0
- package/dist/connection/RfcTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.js +14 -3
- package/dist/connection/createConnection.d.ts +18 -0
- package/dist/connection/createConnection.d.ts.map +1 -1
- package/dist/connection/createConnection.js +8 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -5
- package/docs/INDEX.md +2 -0
- package/docs/MIGRATION-17.0.md +119 -0
- package/docs/SCOPE.md +7 -2
- package/docs/STATEFUL_SESSION_GUIDE.md +12 -11
- package/docs/USAGE.md +88 -36
- package/package.json +1 -1
- package/dist/utils/timeouts.d.ts +0 -18
- package/dist/utils/timeouts.d.ts.map +0 -1
- package/dist/utils/timeouts.js +0 -37
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,48 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [17.0.0] - 2026-10-13
|
|
11
|
+
|
|
12
|
+
What this package answers for is listed in [docs/SCOPE.md](./docs/SCOPE.md).
|
|
13
|
+
See [docs/MIGRATION-17.0.md](./docs/MIGRATION-17.0.md).
|
|
14
|
+
|
|
15
|
+
### Breaking
|
|
16
|
+
- **No deadline of the package's own.** A client deadline closes the socket,
|
|
17
|
+
and SAP then ends the synchronous request running on it — a write in it is
|
|
18
|
+
lost. So:
|
|
19
|
+
- `getTimeout`, `getTimeoutConfig` and `TimeoutConfig` are no longer
|
|
20
|
+
exported (`src/utils/timeouts.ts` is gone), and no `SAP_TIMEOUT_*`
|
|
21
|
+
variable is read;
|
|
22
|
+
- a request carries the caller's `timeout`, unchanged, and nothing else;
|
|
23
|
+
the CSRF fetch and the cloud preflight carry none (they were bounded by
|
|
24
|
+
`SAP_TIMEOUT_CSRF`);
|
|
25
|
+
- inside a critical section a request carries no deadline at all, not even
|
|
26
|
+
the caller's (it was raised to `SAP_TIMEOUT_CRITICAL`, 600 s); the
|
|
27
|
+
critical section itself is unchanged;
|
|
28
|
+
- `GenericWebSocketTransport.connect()` sets no timer unless the caller
|
|
29
|
+
passes `connectTimeoutMs` (the default was 15 s);
|
|
30
|
+
- `IAdtEstablishContext.timeoutMs` is removed.
|
|
31
|
+
- **`IAdtTransport` has two new required members**, `resume(context, session)`
|
|
32
|
+
and `sessionCookies()`. `HttpTransport` and its subclasses implement them;
|
|
33
|
+
`RfcTransport` refuses `resume` and answers `null`. A custom wire adds both.
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
- **An instance on an existing session.** `createConnection({ …, session })`
|
|
37
|
+
(and a sixth constructor argument, `session`, on `AdtOnPremConnector` /
|
|
38
|
+
`AdtCloudConnector`) takes the cookies of a session that already exists.
|
|
39
|
+
`connect()` then does not log on: it makes one request in that session
|
|
40
|
+
without the credential — the CSRF fetch; on cloud with
|
|
41
|
+
`x-sap-security-session: use` — and SAP's answer says whether the session
|
|
42
|
+
is alive. Alive (a token, and the `SAP_SESSIONID` handed over, unchanged):
|
|
43
|
+
the session is the instance's, a stateful request reaches its
|
|
44
|
+
`sap-contextid`, and `disconnect()` logs it off as for any instance. Gone (a
|
|
45
|
+
`401`, or any answer that is not the session's): `connect()` rejects with
|
|
46
|
+
SAP's answer as it is, nothing is logged off, and the instance is spent.
|
|
47
|
+
HTTP wires only: over RFC `session` is refused at construction.
|
|
48
|
+
- **`sessionCookies()`**: the instance's session cookies as the string
|
|
49
|
+
`session` takes — the wire's jar without `sap-XSRF_*`; `null` before a
|
|
50
|
+
session, after it ended, and over RFC. Never logged.
|
|
51
|
+
|
|
10
52
|
## [16.0.0] - 2026-10-13
|
|
11
53
|
|
|
12
54
|
What this package answers for is listed in [docs/SCOPE.md](./docs/SCOPE.md).
|
|
@@ -2588,7 +2630,8 @@ const connection = createAbapConnection(config, logger);
|
|
|
2588
2630
|
- JWT token refresh now properly handles connection errors (401/403 during initial connect)
|
|
2589
2631
|
- Permission errors (403 with "ExceptionResourceNoAccess") no longer trigger JWT refresh loops
|
|
2590
2632
|
- Proper separation: base class handles HTTP/session, concrete classes handle auth-specific errors
|
|
2591
|
-
[Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/
|
|
2633
|
+
[Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/v17.0.0...HEAD
|
|
2634
|
+
[17.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v16.0.0...v17.0.0
|
|
2592
2635
|
[16.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v15.1.0...v16.0.0
|
|
2593
2636
|
[15.1.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v15.0.1...v15.1.0
|
|
2594
2637
|
[15.0.1]: https://github.com/fr0ster/mcp-abap-connection/compare/v15.0.0...v15.0.1
|
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ ABAP connection layer for MCP ABAP ADT server. Provides a unified interface for
|
|
|
25
25
|
- Reusable for debugger/traces and other event-driven flows
|
|
26
26
|
- 📝 **Custom Logging**: Pluggable logger interface for integration with any logging system
|
|
27
27
|
- 📦 **TypeScript**: Full TypeScript support with type definitions included
|
|
28
|
-
-
|
|
28
|
+
- ⏱️ **No built-in deadline**: a request carries the caller's own `timeout` and nothing else — inside a critical section, none at all
|
|
29
29
|
|
|
30
30
|
## Architecture
|
|
31
31
|
|
|
@@ -161,6 +161,7 @@ the packages above. See [Migration to 9.0.0](./docs/MIGRATION-9.0.md).
|
|
|
161
161
|
|
|
162
162
|
- 📦 **[Installation Guide](./docs/INSTALLATION.md)** - Setup and installation instructions
|
|
163
163
|
- 📚 **[Usage Guide](./docs/USAGE.md)** - Detailed usage examples and API documentation
|
|
164
|
+
- 🚚 **[Migration to 17.0.0](./docs/MIGRATION-17.0.md)** - no deadline of the package's own: `getTimeout`, `getTimeoutConfig` and `SAP_TIMEOUT_*` are gone, and a request inside a critical section carries none at all; an instance can be built on an existing session (`session`, `sessionCookies()`)
|
|
164
165
|
- 🚚 **[Migration to 16.0.0](./docs/MIGRATION-16.0.md)** - the per-request `signal` (15.1.0) and `ADT_REQUEST_ABORTED` are removed; `disconnect()` resolves once the logoff is written, not answered — a process about to exit awaits it; `flushGoodbye()` when the answer matters
|
|
165
166
|
- 🚚 **[Migration to 15.0.0](./docs/MIGRATION-15.0.md)** - on `@mcp-abap-adt/interfaces-adt-connection` 2: `makeAdtRequest`'s answer is `unknown` unless its type is named; nothing changes at run time
|
|
166
167
|
- 🚚 **[Migration to 14.0.0](./docs/MIGRATION-14.0.md)** - the `sap-abap-auth` CLI is removed, with its `open` and `commander` dependencies; use `@mcp-abap-adt/auth-broker-cli`; the library's API is unchanged
|
|
@@ -181,7 +182,7 @@ the packages above. See [Migration to 9.0.0](./docs/MIGRATION-9.0.md).
|
|
|
181
182
|
- 💾 **Session Management**: Session headers management (cookies, CSRF tokens) for HTTP communication
|
|
182
183
|
- 📝 **Custom Logging**: Pluggable logger interface for integration with any logging system (optional)
|
|
183
184
|
- 📦 **TypeScript**: Full TypeScript support with type definitions included
|
|
184
|
-
-
|
|
185
|
+
- ⏱️ **No built-in deadline**: a request carries the caller's own `timeout` and nothing else — inside a critical section, none at all
|
|
185
186
|
- 🌐 **Network Error Detection**: Automatic detection and proper handling of network-level errors (connection refused, timeout, DNS failures)
|
|
186
187
|
|
|
187
188
|
## Installation
|
|
@@ -225,7 +226,7 @@ For detailed installation instructions, see [Installation Guide](./docs/INSTALLA
|
|
|
225
226
|
### The recommended way: `createConnection`
|
|
226
227
|
|
|
227
228
|
```typescript
|
|
228
|
-
import { createConnection
|
|
229
|
+
import { createConnection } from "@mcp-abap-adt/connection";
|
|
229
230
|
import type { SapConfig } from "@mcp-abap-adt/connection";
|
|
230
231
|
import { BasicAuthProvider } from "@mcp-abap-adt/auth-providers";
|
|
231
232
|
|
|
@@ -254,7 +255,7 @@ try {
|
|
|
254
255
|
await connection.makeAdtRequest({
|
|
255
256
|
method: "GET",
|
|
256
257
|
url: "/sap/bc/adt/discovery",
|
|
257
|
-
timeout:
|
|
258
|
+
timeout: 0,
|
|
258
259
|
});
|
|
259
260
|
} finally {
|
|
260
261
|
await connection.disconnect(); // resolves once the logoff is written
|
|
@@ -270,6 +271,63 @@ what the wire logs about itself, `logger` and `sessionId` for the connection.
|
|
|
270
271
|
The constructors below remain available; the factory only names the four
|
|
271
272
|
combinations that exist.
|
|
272
273
|
|
|
274
|
+
**No deadline but yours.** A request carries the `timeout` you pass and
|
|
275
|
+
nothing else: no wire sets one of its own, because a client deadline closes
|
|
276
|
+
the socket and SAP then ends the request running on it — a write in it lost.
|
|
277
|
+
`IAbapRequestOptions` still requires the field; `0` is none over HTTP. Inside
|
|
278
|
+
a critical section (`beginCriticalSection()`) a request carries none at all,
|
|
279
|
+
not even yours.
|
|
280
|
+
|
|
281
|
+
### An instance on an existing session
|
|
282
|
+
|
|
283
|
+
An instance may be built on a session that already exists, instead of logging
|
|
284
|
+
on: `session` takes the cookies an earlier instance's `sessionCookies()`
|
|
285
|
+
returned. `connect()` then sends no logon. It makes one request in that
|
|
286
|
+
session **without the credential** — so a session that is gone cannot quietly
|
|
287
|
+
become a new one — and SAP's answer says whether the session is alive: if it
|
|
288
|
+
is, the instance is on it (a stateful request reaches the same ABAP context,
|
|
289
|
+
and `disconnect()` logs it off); if not, `connect()` rejects with SAP's answer
|
|
290
|
+
as it is (a `401`), nothing is logged off, and the instance is spent. HTTP
|
|
291
|
+
wires only; over RFC `session` is refused at construction.
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
import { createConnection } from "@mcp-abap-adt/connection";
|
|
295
|
+
import type { SapConfig } from "@mcp-abap-adt/connection";
|
|
296
|
+
import { BasicAuthProvider } from "@mcp-abap-adt/auth-providers";
|
|
297
|
+
|
|
298
|
+
const system: SapConfig = {
|
|
299
|
+
url: "https://your-sap-system.com",
|
|
300
|
+
client: "100",
|
|
301
|
+
authType: "basic",
|
|
302
|
+
username: "your-username",
|
|
303
|
+
password: "your-password",
|
|
304
|
+
};
|
|
305
|
+
const credential = new BasicAuthProvider(system.username!, system.password!);
|
|
306
|
+
|
|
307
|
+
const first = createConnection({ system: "onprem", transport: "http", config: system, credential });
|
|
308
|
+
await first.connect();
|
|
309
|
+
// The session's cookies, for you to keep — they act as the user while the
|
|
310
|
+
// session lives, so keep them as a secret. null before a session, and over RFC.
|
|
311
|
+
const kept = first.sessionCookies();
|
|
312
|
+
|
|
313
|
+
// Later — another process, say: the same SAP session, no new logon.
|
|
314
|
+
if (kept !== null) {
|
|
315
|
+
const resumed = createConnection({
|
|
316
|
+
system: "onprem",
|
|
317
|
+
transport: "http",
|
|
318
|
+
config: system,
|
|
319
|
+
credential,
|
|
320
|
+
session: kept,
|
|
321
|
+
});
|
|
322
|
+
await resumed.connect(); // rejects with SAP's 401 when the session is gone
|
|
323
|
+
try {
|
|
324
|
+
await resumed.makeAdtRequest({ method: "GET", url: "/sap/bc/adt/discovery", timeout: 0 });
|
|
325
|
+
} finally {
|
|
326
|
+
await resumed.disconnect(); // logs the session off, as for any instance
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
```
|
|
330
|
+
|
|
273
331
|
### Basic Usage (On-Premise), with the constructors
|
|
274
332
|
|
|
275
333
|
```typescript
|
|
@@ -277,7 +335,6 @@ import {
|
|
|
277
335
|
AdtOnPremConnector,
|
|
278
336
|
OnPremHttpTransport,
|
|
279
337
|
SapConfig,
|
|
280
|
-
getTimeout,
|
|
281
338
|
} from "@mcp-abap-adt/connection";
|
|
282
339
|
import { BasicAuthProvider } from "@mcp-abap-adt/auth-providers";
|
|
283
340
|
|
|
@@ -314,7 +371,7 @@ await connection.connect(); // required before any request
|
|
|
314
371
|
const response = await connection.makeAdtRequest({
|
|
315
372
|
method: "GET",
|
|
316
373
|
url: "/sap/bc/adt/programs/programs/your-program",
|
|
317
|
-
timeout:
|
|
374
|
+
timeout: 0,
|
|
318
375
|
});
|
|
319
376
|
```
|
|
320
377
|
|
|
@@ -337,7 +394,6 @@ import {
|
|
|
337
394
|
AdtCloudConnector,
|
|
338
395
|
CloudHttpTransport,
|
|
339
396
|
SapConfig,
|
|
340
|
-
getTimeout,
|
|
341
397
|
} from "@mcp-abap-adt/connection";
|
|
342
398
|
import { TokenAuthProvider } from "@mcp-abap-adt/auth-providers";
|
|
343
399
|
|
|
@@ -375,7 +431,7 @@ await connection.connect();
|
|
|
375
431
|
const response = await connection.makeAdtRequest({
|
|
376
432
|
method: "GET",
|
|
377
433
|
url: "/sap/bc/adt/programs/programs/your-program",
|
|
378
|
-
timeout:
|
|
434
|
+
timeout: 0,
|
|
379
435
|
});
|
|
380
436
|
```
|
|
381
437
|
|
|
@@ -433,7 +489,6 @@ import {
|
|
|
433
489
|
AdtOnPremConnector,
|
|
434
490
|
OnPremHttpTransport,
|
|
435
491
|
SapConfig,
|
|
436
|
-
getTimeout,
|
|
437
492
|
} from "@mcp-abap-adt/connection";
|
|
438
493
|
import { SamlAuthProvider } from "@mcp-abap-adt/auth-providers";
|
|
439
494
|
|
|
@@ -458,7 +513,7 @@ await connection.connect();
|
|
|
458
513
|
const response = await connection.makeAdtRequest({
|
|
459
514
|
method: "GET",
|
|
460
515
|
url: "/sap/bc/adt/programs/programs/your-program",
|
|
461
|
-
timeout:
|
|
516
|
+
timeout: 0,
|
|
462
517
|
});
|
|
463
518
|
```
|
|
464
519
|
|
|
@@ -475,7 +530,6 @@ import {
|
|
|
475
530
|
AdtCloudConnector,
|
|
476
531
|
CloudHttpTransport,
|
|
477
532
|
SapConfig,
|
|
478
|
-
getTimeout,
|
|
479
533
|
} from "@mcp-abap-adt/connection";
|
|
480
534
|
import { TokenAuthProvider } from "@mcp-abap-adt/auth-providers";
|
|
481
535
|
import type { ITokenRefresher } from "@mcp-abap-adt/interfaces-auth";
|
|
@@ -518,7 +572,7 @@ await connection.connect();
|
|
|
518
572
|
const response = await connection.makeAdtRequest({
|
|
519
573
|
method: "GET",
|
|
520
574
|
url: "/sap/bc/adt/programs/programs/your-program",
|
|
521
|
-
timeout:
|
|
575
|
+
timeout: 0,
|
|
522
576
|
});
|
|
523
577
|
```
|
|
524
578
|
|
|
@@ -596,7 +650,6 @@ cookies and the CSRF token remain available in both modes. See the
|
|
|
596
650
|
import {
|
|
597
651
|
AdtOnPremConnector,
|
|
598
652
|
OnPremHttpTransport,
|
|
599
|
-
getTimeout,
|
|
600
653
|
} from "@mcp-abap-adt/connection";
|
|
601
654
|
import { BasicAuthProvider } from "@mcp-abap-adt/auth-providers";
|
|
602
655
|
|
|
@@ -724,8 +777,8 @@ contract type re-exported under a second name is a contract type that can drift.
|
|
|
724
777
|
**The connection does not track locks.** Deciding when to disconnect, and
|
|
725
778
|
preparing for it, belongs to the caller; pairing every LOCK with its UNLOCK
|
|
726
779
|
belongs to `@mcp-abap-adt/adt-clients`, which holds the handles. What this layer
|
|
727
|
-
owns is not being interrupted by a
|
|
728
|
-
`beginCriticalSection()`
|
|
780
|
+
owns is not being interrupted by a deadline mid-operation: inside
|
|
781
|
+
`beginCriticalSection()` a request carries none, not even the caller's.
|
|
729
782
|
|
|
730
783
|
See [docs/USAGE.md — Session Lifecycle](./docs/USAGE.md#session-lifecycle).
|
|
731
784
|
|
|
@@ -733,6 +786,7 @@ See [docs/USAGE.md — Session Lifecycle](./docs/USAGE.md#session-lifecycle).
|
|
|
733
786
|
- `setSessionType(type)`: Programmatically switch between stateful and stateless modes *(on the contract)*
|
|
734
787
|
- `getSessionId()`: Returns the client-side conversation id, an auto-generated UUID *(on the contract)*
|
|
735
788
|
- `getSessionMode()`: Returns current session mode *(HTTP classes only)*
|
|
789
|
+
- `sessionCookies()`: The cookies of the instance's SAP session, as `createConnection({ …, session })` takes them — `null` before a session, after it ended, and over RFC. They act as the user while the session lives: keep them as a secret; the package never logs them *(this package's connectors)*
|
|
736
790
|
|
|
737
791
|
#### `ILogger`
|
|
738
792
|
|
|
@@ -754,10 +808,12 @@ interface ILogger {
|
|
|
754
808
|
Builds a NEW connection from what the caller states: `system` (`'cloud'` or
|
|
755
809
|
`'onprem'`) and `transport` (`'http'`, `'legacy-http'` or `'rfc'`), plus
|
|
756
810
|
`config`, `credential` and, optionally, `logger`, `wireLogger`, `sessionId`,
|
|
757
|
-
`agentOptions` (HTTP) or `rfc` (`IRfcTransportOptions`). Nothing is inferred,
|
|
811
|
+
`agentOptions` and `session` (HTTP) or `rfc` (`IRfcTransportOptions`). Nothing is inferred,
|
|
758
812
|
not even from `config.connectionType`. A combination that does not exist is
|
|
759
|
-
refused with a `TypeError
|
|
760
|
-
for a new one
|
|
813
|
+
refused with a `TypeError`, and so is `session` over RFC. One instance is one
|
|
814
|
+
SAP session: call it again for a new one — or pass `session` (the string an
|
|
815
|
+
instance's `sessionCookies()` returned) to build it on an existing session,
|
|
816
|
+
which `connect()` then takes over instead of logging on.
|
|
761
817
|
|
|
762
818
|
#### `rfcConversationFrom(config)`
|
|
763
819
|
|
|
@@ -48,14 +48,11 @@ declare abstract class AbstractAbapConnection implements AbapConnection, ISessio
|
|
|
48
48
|
private profilingRequest;
|
|
49
49
|
/**
|
|
50
50
|
* When true, requests are treated as part of an uninterruptible critical
|
|
51
|
-
* section (e.g. a lock → modify → unlock chain). In this state a
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* lost while the lock lives on in that session. While set, makeAdtRequest
|
|
57
|
-
* raises the effective timeout to CRITICAL_SECTION_TIMEOUT (a large ceiling)
|
|
58
|
-
* so the request runs to completion instead of being interrupted.
|
|
51
|
+
* section (e.g. a lock → modify → unlock chain). In this state a request
|
|
52
|
+
* carries no deadline at all, not even the caller's: a client deadline closes
|
|
53
|
+
* the socket, SAP then ends the request running on it — a write in it lost —
|
|
54
|
+
* and what this side knew goes with it: whether the change was applied, and
|
|
55
|
+
* the handle `unlock` needs, while the lock lives on in that session.
|
|
59
56
|
*/
|
|
60
57
|
/**
|
|
61
58
|
* The last goodbye this connection dispatched, so a caller can wait for it.
|
|
@@ -93,6 +90,12 @@ declare abstract class AbstractAbapConnection implements AbapConnection, ISessio
|
|
|
93
90
|
* `disconnect()` waits for (the writes) and `flushGoodbye()` (the answers).
|
|
94
91
|
*/
|
|
95
92
|
private ended;
|
|
93
|
+
/**
|
|
94
|
+
* The existing session this instance takes over at `connect()`, instead of
|
|
95
|
+
* logging on: its cookies, as `sessionCookies()` handed them out. Dropped
|
|
96
|
+
* once the takeover is attempted — a session is taken over once.
|
|
97
|
+
*/
|
|
98
|
+
private resumeFrom;
|
|
96
99
|
private inCriticalSection;
|
|
97
100
|
/** Reference count for nested beginCriticalSection()/endCriticalSection() pairs. */
|
|
98
101
|
private criticalSectionDepth;
|
|
@@ -150,7 +153,13 @@ declare abstract class AbstractAbapConnection implements AbapConnection, ISessio
|
|
|
150
153
|
* arrives built. The credential's TLS material is not among them: the
|
|
151
154
|
* provider offers it to the wire at logon.
|
|
152
155
|
*/
|
|
153
|
-
transport: IAdtTransport, logger: ILogger | null, sessionId?: string
|
|
156
|
+
transport: IAdtTransport, logger: ILogger | null, sessionId?: string,
|
|
157
|
+
/**
|
|
158
|
+
* An existing session to take over instead of logging on: the cookies
|
|
159
|
+
* `sessionCookies()` handed out for it. `connect()` then sends no logon
|
|
160
|
+
* and asks SAP, without the credential, whether that session is alive.
|
|
161
|
+
*/
|
|
162
|
+
session?: string);
|
|
154
163
|
/**
|
|
155
164
|
* Set session type (stateful or stateless)
|
|
156
165
|
* Marks the requests that follow as `stateful` for the transport, which says
|
|
@@ -181,22 +190,21 @@ declare abstract class AbstractAbapConnection implements AbapConnection, ISessio
|
|
|
181
190
|
* Enter an uninterruptible critical section.
|
|
182
191
|
*
|
|
183
192
|
* Call this BEFORE acquiring a lock (and pair it with endCriticalSection()
|
|
184
|
-
* in a finally, AFTER unlocking). While in a critical section
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
* lock survives inside the ABAP session that owns it.
|
|
193
|
+
* in a finally, AFTER unlocking). While in a critical section a request
|
|
194
|
+
* carries no deadline — the caller's `timeout` is not applied — so a slow
|
|
195
|
+
* PUT/activate/unlock is not cut mid-flight. A client deadline closes the
|
|
196
|
+
* socket, and SAP then ends the request that was running on it (a write in
|
|
197
|
+
* it lost); and it strands the caller: the outcome is unknown and the handle
|
|
198
|
+
* `unlock` needs is gone, while the lock survives inside the ABAP session
|
|
199
|
+
* that owns it.
|
|
192
200
|
*
|
|
193
201
|
* Nesting is reference-counted so nested begin/end pairs are safe.
|
|
194
202
|
*/
|
|
195
203
|
beginCriticalSection(): void;
|
|
196
204
|
/**
|
|
197
205
|
* Leave the uninterruptible critical section. See beginCriticalSection().
|
|
198
|
-
* Safe to call more times than begin (clamped at 0).
|
|
199
|
-
* timeouts
|
|
206
|
+
* Safe to call more times than begin (clamped at 0). The caller's own
|
|
207
|
+
* per-request timeouts apply again once the outermost section ends.
|
|
200
208
|
*/
|
|
201
209
|
endCriticalSection(): void;
|
|
202
210
|
/**
|
|
@@ -388,6 +396,20 @@ declare abstract class AbstractAbapConnection implements AbapConnection, ISessio
|
|
|
388
396
|
* than written twice — the two would drift apart, as they did once before.
|
|
389
397
|
*/
|
|
390
398
|
private establishAndCommit;
|
|
399
|
+
/**
|
|
400
|
+
* Takes over the session `resumeFrom` names, and publishes it — the
|
|
401
|
+
* counterpart of `establishAndCommit` for an instance built on an existing
|
|
402
|
+
* session.
|
|
403
|
+
*
|
|
404
|
+
* No logon: the wire makes one request in that session without the
|
|
405
|
+
* credential (`IAdtTransport.resume`). Alive, the session is this
|
|
406
|
+
* instance's — its `SAP_SESSIONID`, and its `sap-contextid` when the caller
|
|
407
|
+
* kept one — and `disconnect()` logs it off as for any instance. Gone, or
|
|
408
|
+
* any answer that is not the session's: `connect()` rejects with SAP's
|
|
409
|
+
* answer as it is, nothing is logged off — nothing was opened — and the
|
|
410
|
+
* instance is spent.
|
|
411
|
+
*/
|
|
412
|
+
private resumeAndCommit;
|
|
391
413
|
/** The teardown epoch, for a recovery to capture before it starts. */
|
|
392
414
|
protected get teardownEpoch(): number;
|
|
393
415
|
/**
|
|
@@ -478,6 +500,16 @@ declare abstract class AbstractAbapConnection implements AbapConnection, ISessio
|
|
|
478
500
|
* overwritten on every response.
|
|
479
501
|
*/
|
|
480
502
|
protected sessionFingerprint(): Map<string, string>;
|
|
503
|
+
/**
|
|
504
|
+
* The cookies of this instance's SAP session, for the caller to keep: the
|
|
505
|
+
* string `createConnection({ …, session })` takes to build a later instance
|
|
506
|
+
* on the same session. `null` before a session, after it ended, and over
|
|
507
|
+
* RFC, whose session is a conversation no cookie names.
|
|
508
|
+
*
|
|
509
|
+
* It authenticates as the session's user for as long as the session lives:
|
|
510
|
+
* keep it as a secret. Nothing here logs it.
|
|
511
|
+
*/
|
|
512
|
+
sessionCookies(): string | null;
|
|
481
513
|
getBaseUrl(): Promise<string>;
|
|
482
514
|
getAuthHeaders(): Promise<Record<string, string>>;
|
|
483
515
|
/**
|
|
@@ -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;
|
|
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,EAInB,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;;;;;OAeG;IACH,OAAO,CAAC,aAAa;IAiCrB;;;;OAIG;IACH,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAIlD;;;;;;;;OAQG;IACH,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,eAAe;CA6BxB;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -5,7 +5,6 @@ const node_crypto_1 = require("node:crypto");
|
|
|
5
5
|
const interfaces_adt_connection_1 = require("@mcp-abap-adt/interfaces-adt-connection");
|
|
6
6
|
const SessionLifecycle_js_1 = require("../session/SessionLifecycle.js");
|
|
7
7
|
const networkErrors_js_1 = require("../utils/networkErrors.js");
|
|
8
|
-
const timeouts_js_1 = require("../utils/timeouts.js");
|
|
9
8
|
const authErrors_js_1 = require("./authErrors.js");
|
|
10
9
|
const csrfConfig_js_1 = require("./csrfConfig.js");
|
|
11
10
|
const IAdtTransport_js_1 = require("./IAdtTransport.js");
|
|
@@ -83,14 +82,11 @@ class AbstractAbapConnection {
|
|
|
83
82
|
profilingRequest = 'server-time';
|
|
84
83
|
/**
|
|
85
84
|
* When true, requests are treated as part of an uninterruptible critical
|
|
86
|
-
* section (e.g. a lock → modify → unlock chain). In this state a
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* lost while the lock lives on in that session. While set, makeAdtRequest
|
|
92
|
-
* raises the effective timeout to CRITICAL_SECTION_TIMEOUT (a large ceiling)
|
|
93
|
-
* so the request runs to completion instead of being interrupted.
|
|
85
|
+
* section (e.g. a lock → modify → unlock chain). In this state a request
|
|
86
|
+
* carries no deadline at all, not even the caller's: a client deadline closes
|
|
87
|
+
* the socket, SAP then ends the request running on it — a write in it lost —
|
|
88
|
+
* and what this side knew goes with it: whether the change was applied, and
|
|
89
|
+
* the handle `unlock` needs, while the lock lives on in that session.
|
|
94
90
|
*/
|
|
95
91
|
/**
|
|
96
92
|
* The last goodbye this connection dispatched, so a caller can wait for it.
|
|
@@ -128,6 +124,12 @@ class AbstractAbapConnection {
|
|
|
128
124
|
* `disconnect()` waits for (the writes) and `flushGoodbye()` (the answers).
|
|
129
125
|
*/
|
|
130
126
|
ended = null;
|
|
127
|
+
/**
|
|
128
|
+
* The existing session this instance takes over at `connect()`, instead of
|
|
129
|
+
* logging on: its cookies, as `sessionCookies()` handed them out. Dropped
|
|
130
|
+
* once the takeover is attempted — a session is taken over once.
|
|
131
|
+
*/
|
|
132
|
+
resumeFrom;
|
|
131
133
|
inCriticalSection = false;
|
|
132
134
|
/** Reference count for nested beginCriticalSection()/endCriticalSection() pairs. */
|
|
133
135
|
criticalSectionDepth = 0;
|
|
@@ -185,10 +187,22 @@ class AbstractAbapConnection {
|
|
|
185
187
|
* arrives built. The credential's TLS material is not among them: the
|
|
186
188
|
* provider offers it to the wire at logon.
|
|
187
189
|
*/
|
|
188
|
-
transport, logger, sessionId
|
|
190
|
+
transport, logger, sessionId,
|
|
191
|
+
/**
|
|
192
|
+
* An existing session to take over instead of logging on: the cookies
|
|
193
|
+
* `sessionCookies()` handed out for it. `connect()` then sends no logon
|
|
194
|
+
* and asks SAP, without the credential, whether that session is alive.
|
|
195
|
+
*/
|
|
196
|
+
session) {
|
|
189
197
|
this.config = config;
|
|
190
198
|
this.transport = transport;
|
|
191
199
|
this.logger = logger;
|
|
200
|
+
// Fixed words: the session's cookies are never echoed.
|
|
201
|
+
if (session !== undefined &&
|
|
202
|
+
(typeof session !== 'string' || session.trim() === '')) {
|
|
203
|
+
throw new TypeError('session: the cookies of an existing session, as sessionCookies() returned them; an empty one names no session.');
|
|
204
|
+
}
|
|
205
|
+
this.resumeFrom = session ?? null;
|
|
192
206
|
// Generate sessionId (used for sap-adt-connection-id header)
|
|
193
207
|
this.sessionId = sessionId || (0, node_crypto_1.randomUUID)();
|
|
194
208
|
// Initialize baseUrl from config (required, will throw if invalid)
|
|
@@ -242,14 +256,13 @@ class AbstractAbapConnection {
|
|
|
242
256
|
* Enter an uninterruptible critical section.
|
|
243
257
|
*
|
|
244
258
|
* Call this BEFORE acquiring a lock (and pair it with endCriticalSection()
|
|
245
|
-
* in a finally, AFTER unlocking). While in a critical section
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
* lock survives inside the ABAP session that owns it.
|
|
259
|
+
* in a finally, AFTER unlocking). While in a critical section a request
|
|
260
|
+
* carries no deadline — the caller's `timeout` is not applied — so a slow
|
|
261
|
+
* PUT/activate/unlock is not cut mid-flight. A client deadline closes the
|
|
262
|
+
* socket, and SAP then ends the request that was running on it (a write in
|
|
263
|
+
* it lost); and it strands the caller: the outcome is unknown and the handle
|
|
264
|
+
* `unlock` needs is gone, while the lock survives inside the ABAP session
|
|
265
|
+
* that owns it.
|
|
253
266
|
*
|
|
254
267
|
* Nesting is reference-counted so nested begin/end pairs are safe.
|
|
255
268
|
*/
|
|
@@ -260,8 +273,8 @@ class AbstractAbapConnection {
|
|
|
260
273
|
}
|
|
261
274
|
/**
|
|
262
275
|
* Leave the uninterruptible critical section. See beginCriticalSection().
|
|
263
|
-
* Safe to call more times than begin (clamped at 0).
|
|
264
|
-
* timeouts
|
|
276
|
+
* Safe to call more times than begin (clamped at 0). The caller's own
|
|
277
|
+
* per-request timeouts apply again once the outermost section ends.
|
|
265
278
|
*/
|
|
266
279
|
endCriticalSection() {
|
|
267
280
|
if (this.criticalSectionDepth > 0) {
|
|
@@ -338,6 +351,12 @@ class AbstractAbapConnection {
|
|
|
338
351
|
// Before the wire opens, so that a credential which cannot get ready
|
|
339
352
|
// sends nothing and the wire's logon has something to bring.
|
|
340
353
|
await this.prepareCredential();
|
|
354
|
+
// An instance built on an existing session takes it over: no logon,
|
|
355
|
+
// and SAP's answer to one request says whether the session is alive.
|
|
356
|
+
if (this.resumeFrom !== null) {
|
|
357
|
+
await this.resumeAndCommit(baselineEpoch);
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
341
360
|
// The wire logs on inside, through the context, and then the session is
|
|
342
361
|
// established: one step, which a refused logon repeats once.
|
|
343
362
|
try {
|
|
@@ -788,6 +807,47 @@ class AbstractAbapConnection {
|
|
|
788
807
|
}
|
|
789
808
|
this.lifecycle.markConnected(this.sessionFingerprint());
|
|
790
809
|
}
|
|
810
|
+
/**
|
|
811
|
+
* Takes over the session `resumeFrom` names, and publishes it — the
|
|
812
|
+
* counterpart of `establishAndCommit` for an instance built on an existing
|
|
813
|
+
* session.
|
|
814
|
+
*
|
|
815
|
+
* No logon: the wire makes one request in that session without the
|
|
816
|
+
* credential (`IAdtTransport.resume`). Alive, the session is this
|
|
817
|
+
* instance's — its `SAP_SESSIONID`, and its `sap-contextid` when the caller
|
|
818
|
+
* kept one — and `disconnect()` logs it off as for any instance. Gone, or
|
|
819
|
+
* any answer that is not the session's: `connect()` rejects with SAP's
|
|
820
|
+
* answer as it is, nothing is logged off — nothing was opened — and the
|
|
821
|
+
* instance is spent.
|
|
822
|
+
*/
|
|
823
|
+
async resumeAndCommit(baselineEpoch) {
|
|
824
|
+
if (this.spent)
|
|
825
|
+
throw spentError();
|
|
826
|
+
if (this.lifecycle.teardownEpoch !== baselineEpoch) {
|
|
827
|
+
throw (0, SessionLifecycle_js_1.sessionError)(interfaces_adt_connection_1.ADT_SESSION_ERROR.NOT_CONNECTED, 'Establishment abandoned: a teardown was requested for this connection');
|
|
828
|
+
}
|
|
829
|
+
const session = this.resumeFrom;
|
|
830
|
+
this.resumeFrom = null;
|
|
831
|
+
this.lifecycle.forgetIdentity();
|
|
832
|
+
try {
|
|
833
|
+
await this.transport.resume(this.sessionContext(), session);
|
|
834
|
+
}
|
|
835
|
+
catch (error) {
|
|
836
|
+
// Nothing was opened, so nothing is logged off: the session was the
|
|
837
|
+
// caller's, and whatever it is now, it stays theirs. What the wire was
|
|
838
|
+
// seeded with goes, and the instance is spent.
|
|
839
|
+
this.spent = true;
|
|
840
|
+
this.invalidateSession();
|
|
841
|
+
this.lifecycle.markDisconnected();
|
|
842
|
+
throw error;
|
|
843
|
+
}
|
|
844
|
+
if (this.lifecycle.teardownEpoch !== baselineEpoch) {
|
|
845
|
+
// As in `establishAndCommit`: the queued teardown clears, and — the
|
|
846
|
+
// session now being this instance's — logs it off.
|
|
847
|
+
throw (0, SessionLifecycle_js_1.sessionError)(interfaces_adt_connection_1.ADT_SESSION_ERROR.NOT_CONNECTED, 'Establishment abandoned: a teardown was requested while it was in flight');
|
|
848
|
+
}
|
|
849
|
+
this.lifecycle.markConnected(this.sessionFingerprint());
|
|
850
|
+
}
|
|
791
851
|
/** The teardown epoch, for a recovery to capture before it starts. */
|
|
792
852
|
get teardownEpoch() {
|
|
793
853
|
return this.lifecycle.teardownEpoch;
|
|
@@ -945,6 +1005,18 @@ class AbstractAbapConnection {
|
|
|
945
1005
|
sessionFingerprint() {
|
|
946
1006
|
return this.transport.sessionFingerprint();
|
|
947
1007
|
}
|
|
1008
|
+
/**
|
|
1009
|
+
* The cookies of this instance's SAP session, for the caller to keep: the
|
|
1010
|
+
* string `createConnection({ …, session })` takes to build a later instance
|
|
1011
|
+
* on the same session. `null` before a session, after it ended, and over
|
|
1012
|
+
* RFC, whose session is a conversation no cookie names.
|
|
1013
|
+
*
|
|
1014
|
+
* It authenticates as the session's user for as long as the session lives:
|
|
1015
|
+
* keep it as a secret. Nothing here logs it.
|
|
1016
|
+
*/
|
|
1017
|
+
sessionCookies() {
|
|
1018
|
+
return this.transport.sessionCookies();
|
|
1019
|
+
}
|
|
948
1020
|
async getBaseUrl() {
|
|
949
1021
|
return this.baseUrl;
|
|
950
1022
|
}
|
|
@@ -1088,16 +1160,13 @@ class AbstractAbapConnection {
|
|
|
1088
1160
|
}
|
|
1089
1161
|
}
|
|
1090
1162
|
}
|
|
1091
|
-
//
|
|
1092
|
-
//
|
|
1093
|
-
//
|
|
1094
|
-
//
|
|
1095
|
-
// the lock stays held in that session.
|
|
1096
|
-
//
|
|
1097
|
-
|
|
1098
|
-
const effectiveTimeout = this.inCriticalSection
|
|
1099
|
-
? Math.max(timeout ?? 0, (0, timeouts_js_1.getCriticalSectionTimeout)())
|
|
1100
|
-
: timeout;
|
|
1163
|
+
// The only deadline a request carries is the caller's own, and inside an
|
|
1164
|
+
// uninterruptible critical section (lock → modify → unlock) not even that:
|
|
1165
|
+
// a client deadline closes the socket, SAP then ends the request running
|
|
1166
|
+
// on it — a write in it lost — and the outcome is unknown, the unlock
|
|
1167
|
+
// handle lost while the lock stays held in that session. Decided once for
|
|
1168
|
+
// the whole request: the retry paths below reuse requestConfig.
|
|
1169
|
+
const callerTimeout = this.inCriticalSection ? undefined : timeout;
|
|
1101
1170
|
const requestConfig = {
|
|
1102
1171
|
method: normalizedMethod,
|
|
1103
1172
|
url: requestUrl,
|
|
@@ -1109,7 +1178,7 @@ class AbstractAbapConnection {
|
|
|
1109
1178
|
headers: await this.authorizedFrom(requestHeaders).catch((error) => {
|
|
1110
1179
|
throw this.staleOr(error, lease);
|
|
1111
1180
|
}),
|
|
1112
|
-
timeout:
|
|
1181
|
+
...(callerTimeout !== undefined ? { timeout: callerTimeout } : {}),
|
|
1113
1182
|
// `unknown` on the caller's options, a record on the seam: the two
|
|
1114
1183
|
// transports serialise a query differently and both need the pairs.
|
|
1115
1184
|
params: params,
|
|
@@ -1516,7 +1585,6 @@ class AbstractAbapConnection {
|
|
|
1516
1585
|
: this.leasedContext(fence)),
|
|
1517
1586
|
retries: retryCount,
|
|
1518
1587
|
retryDelayMs: retryDelay,
|
|
1519
|
-
timeoutMs: (0, timeouts_js_1.getTimeout)('csrf'),
|
|
1520
1588
|
isFatal: (error) => this.endsTheExchange(error),
|
|
1521
1589
|
});
|
|
1522
1590
|
const token = this.transport.csrfToken();
|
|
@@ -29,6 +29,11 @@ export declare class AdtCloudConnector<TCredential extends IAuthProvider = IAuth
|
|
|
29
29
|
*/
|
|
30
30
|
TTransport extends ICloudTransport = CloudHttpTransport> extends CredentialAbapConnection<TCredential> {
|
|
31
31
|
readonly transport: TTransport;
|
|
32
|
-
constructor(config: SapConfig, credential: TCredential, transport: TTransport, logger?: ILogger | null, sessionId?: string
|
|
32
|
+
constructor(config: SapConfig, credential: TCredential, transport: TTransport, logger?: ILogger | null, sessionId?: string,
|
|
33
|
+
/**
|
|
34
|
+
* An existing session to take over instead of logging on: the cookies
|
|
35
|
+
* `sessionCookies()` returned for it. HTTP wires only.
|
|
36
|
+
*/
|
|
37
|
+
session?: string);
|
|
33
38
|
}
|
|
34
39
|
//# sourceMappingURL=AdtCloudConnector.d.ts.map
|