@mcp-abap-adt/connection 15.1.0 → 16.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 +144 -1
- package/README.md +68 -20
- package/dist/connection/AbstractAbapConnection.d.ts +89 -39
- package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
- package/dist/connection/AbstractAbapConnection.js +249 -223
- package/dist/connection/CloudHttpTransport.d.ts +8 -1
- package/dist/connection/CloudHttpTransport.d.ts.map +1 -1
- package/dist/connection/CloudHttpTransport.js +28 -15
- package/dist/connection/HttpTransport.d.ts +61 -6
- package/dist/connection/HttpTransport.d.ts.map +1 -1
- package/dist/connection/HttpTransport.js +144 -21
- package/dist/connection/IAdtTransport.d.ts +12 -19
- package/dist/connection/IAdtTransport.d.ts.map +1 -1
- package/dist/connection/OnPremHttpTransport.d.ts +2 -13
- package/dist/connection/OnPremHttpTransport.d.ts.map +1 -1
- package/dist/connection/OnPremHttpTransport.js +16 -32
- package/dist/connection/RfcTransport.d.ts +0 -6
- package/dist/connection/RfcTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.js +13 -46
- package/dist/connection/createConnection.d.ts +77 -0
- package/dist/connection/createConnection.d.ts.map +1 -0
- package/dist/connection/createConnection.js +39 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/docs/INDEX.md +4 -2
- package/docs/MIGRATION-16.0.md +123 -0
- package/docs/SCOPE.md +17 -45
- package/docs/STATEFUL_SESSION_GUIDE.md +37 -38
- package/docs/USAGE.md +156 -84
- package/package.json +2 -2
- package/dist/connection/requestAbort.d.ts +0 -32
- package/dist/connection/requestAbort.d.ts.map +0 -1
- package/dist/connection/requestAbort.js +0 -69
|
@@ -19,28 +19,10 @@
|
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.OnPremHttpTransport = void 0;
|
|
21
21
|
const HttpTransport_js_1 = require("./HttpTransport.js");
|
|
22
|
-
const ICF_LOGOFF_PATH = '/sap/public/bc/icf/logoff';
|
|
23
22
|
class OnPremHttpTransport extends HttpTransport_js_1.HttpTransport {
|
|
24
23
|
kind = 'onprem-http';
|
|
25
24
|
/** Which system this wire is for. Read by the compiler, never at runtime. */
|
|
26
25
|
system = 'onprem';
|
|
27
|
-
/**
|
|
28
|
-
* Whether an establishment actually succeeded.
|
|
29
|
-
*
|
|
30
|
-
* Cookies alone cannot answer it: a 401 that refuses us can carry a
|
|
31
|
-
* `Set-Cookie`, and that is debris, not a session. Telling the server we are
|
|
32
|
-
* finished with something we never had sends a request nobody asked for —
|
|
33
|
-
* into the middle of an authentication exchange, in the case that found this.
|
|
34
|
-
*/
|
|
35
|
-
established = false;
|
|
36
|
-
async establish(context) {
|
|
37
|
-
await super.establish(context);
|
|
38
|
-
this.established = true;
|
|
39
|
-
}
|
|
40
|
-
forgetSession() {
|
|
41
|
-
super.forgetSession();
|
|
42
|
-
this.established = false;
|
|
43
|
-
}
|
|
44
26
|
/**
|
|
45
27
|
* Nothing to ask for: the session comes with the establishing request.
|
|
46
28
|
*
|
|
@@ -49,28 +31,30 @@ class OnPremHttpTransport extends HttpTransport_js_1.HttpTransport {
|
|
|
49
31
|
* only ever read by the connection to decide whether to send a close — a
|
|
50
32
|
* decision that is now this class's, below.
|
|
51
33
|
*/
|
|
52
|
-
async close(context) {
|
|
34
|
+
async close(context, written) {
|
|
53
35
|
// Read synchronously, for the same reason as the cloud wire: the teardown
|
|
54
36
|
// clears the jar while this is suspended on its first await.
|
|
55
|
-
|
|
56
|
-
const
|
|
37
|
+
// Without `sap-contextid`: see `logoffCookies()`.
|
|
38
|
+
const cookies = this.logoffCookies();
|
|
39
|
+
const session = this.holdsSessionCookie();
|
|
57
40
|
// Snapshotted too, and for the same reason as the cookies: the goodbye must
|
|
58
41
|
// reach the application server that holds THIS session, and by the time it
|
|
59
42
|
// goes out the wire may be pinned to the one holding the next.
|
|
60
43
|
const affinity = this.affinityHeaders();
|
|
61
|
-
if (!
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
44
|
+
if (!session || !cookies) {
|
|
45
|
+
// Sent if and only if this wire holds a non-empty `SAP_SESSIONID_*` it
|
|
46
|
+
// received, whatever the status of the answer that brought it
|
|
47
|
+
// (`holdsSessionCookie`): a 404 or 403 after logon carries one and
|
|
48
|
+
// leaves a live security session, which this ends; a 401's debris
|
|
49
|
+
// cookie, or a 200 with only `sap-XSRF_*` (the session limit), names
|
|
50
|
+
// none, and a logoff then would end nothing. Holding the cookie is also
|
|
51
|
+
// the whole permission to end a session: the pool is shared per user —
|
|
52
|
+
// a SAP GUI logon of the same user sits in the same SM04 list — so a
|
|
53
|
+
// connector that tidied up sessions it did not open would eventually
|
|
54
|
+
// close somebody's GUI.
|
|
67
55
|
return;
|
|
68
56
|
}
|
|
69
|
-
await this.
|
|
70
|
-
cookies,
|
|
71
|
-
affinity,
|
|
72
|
-
session: {},
|
|
73
|
-
});
|
|
57
|
+
await this.sendIcfLogoff(context, { cookies, affinity }, written);
|
|
74
58
|
}
|
|
75
59
|
}
|
|
76
60
|
exports.OnPremHttpTransport = OnPremHttpTransport;
|
|
@@ -196,12 +196,6 @@ export declare class RfcTransport implements IOnPremTransport {
|
|
|
196
196
|
* A new conversation, logged on: the provider is asked what to open with,
|
|
197
197
|
* every time, and a failed open is a refused logon whose cause is the SDK's
|
|
198
198
|
* own error, untouched — a provider reads its `key` and message.
|
|
199
|
-
*
|
|
200
|
-
* With a request's signal — a call that opens a conversation of its own —
|
|
201
|
-
* both waits are that request's: the provider's logon and the open. An
|
|
202
|
-
* abort ends either for this request at once. A logon it stopped waiting
|
|
203
|
-
* for opens nothing; an open it stopped waiting for runs on, and the
|
|
204
|
-
* conversation it opens — this request's alone — is closed when it does.
|
|
205
199
|
*/
|
|
206
200
|
private loggedOn;
|
|
207
201
|
private closeQuietly;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RfcTransport.d.ts","sourceRoot":"","sources":["../../src/connection/RfcTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAKH,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;
|
|
1
|
+
{"version":3,"file":"RfcTransport.d.ts","sourceRoot":"","sources":["../../src/connection/RfcTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAKH,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,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,CACF,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB;;;;;OAKG;IACH,kBAAkB,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAgFD,uDAAuD;AACvD,MAAM,WAAW,oBAAoB;IACnC;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAKD,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O,CAAC,OAAO;IAcT,IAAI,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBvD,0DAA0D;IACpD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAwBtB,IAAI,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAezE;;;;;;;;;;;;;OAaG;YACW,aAAa;YAUb,WAAW;IAqDzB,uEAAuE;YACzD,gBAAgB;IAa9B;;;;OAIG;YACW,OAAO;IAWrB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAgBnB;;;;OAIG;YACW,QAAQ;YAYR,YAAY;YAQZ,KAAK;CA+KpB"}
|
|
@@ -46,7 +46,6 @@ exports.RfcTransport = void 0;
|
|
|
46
46
|
const node_crypto_1 = require("node:crypto");
|
|
47
47
|
const auth_errors_1 = require("@mcp-abap-adt/auth-errors");
|
|
48
48
|
const authErrors_js_1 = require("./authErrors.js");
|
|
49
|
-
const requestAbort_js_1 = require("./requestAbort.js");
|
|
50
49
|
const statefulRequest_js_1 = require("./statefulRequest.js");
|
|
51
50
|
/**
|
|
52
51
|
* The SDK answers with untyped structures: each level is read as a record and
|
|
@@ -295,7 +294,7 @@ class RfcTransport {
|
|
|
295
294
|
const generation = this.generation;
|
|
296
295
|
return (0, statefulRequest_js_1.isStatefulRequest)(request)
|
|
297
296
|
? this.carry(request, this.conversation, generation)
|
|
298
|
-
: this.carryOnItsOwn(request, generation
|
|
297
|
+
: this.carryOnItsOwn(request, generation);
|
|
299
298
|
}
|
|
300
299
|
/**
|
|
301
300
|
* A request that is not stateful, in a fresh ABAP session.
|
|
@@ -311,17 +310,17 @@ class RfcTransport {
|
|
|
311
310
|
* package the first one saved would refuse the second one's write (PAK/058).
|
|
312
311
|
* So a concurrent call takes a conversation of its own instead of waiting.
|
|
313
312
|
*/
|
|
314
|
-
async carryOnItsOwn(request, generation
|
|
313
|
+
async carryOnItsOwn(request, generation) {
|
|
315
314
|
if (this.canReset !== false && !this.statelessBusy) {
|
|
316
|
-
return this.carryOnKept(request, generation
|
|
315
|
+
return this.carryOnKept(request, generation);
|
|
317
316
|
}
|
|
318
|
-
return this.carryOnThrowaway(request, generation
|
|
317
|
+
return this.carryOnThrowaway(request, generation);
|
|
319
318
|
}
|
|
320
|
-
async carryOnKept(request, generation
|
|
319
|
+
async carryOnKept(request, generation) {
|
|
321
320
|
this.statelessBusy = true;
|
|
322
321
|
try {
|
|
323
322
|
if (!this.stateless?.alive) {
|
|
324
|
-
const opened = await this.openOwn(generation
|
|
323
|
+
const opened = await this.openOwn(generation);
|
|
325
324
|
// Checked again after the await: close() may have run since openOwn()
|
|
326
325
|
// checked, and a conversation of a closed wire must not become the
|
|
327
326
|
// kept one of the next.
|
|
@@ -366,8 +365,8 @@ class RfcTransport {
|
|
|
366
365
|
}
|
|
367
366
|
}
|
|
368
367
|
/** A conversation opened for this one call, closed when it answers. */
|
|
369
|
-
async carryOnThrowaway(request, generation
|
|
370
|
-
const own = await this.openOwn(generation
|
|
368
|
+
async carryOnThrowaway(request, generation) {
|
|
369
|
+
const own = await this.openOwn(generation);
|
|
371
370
|
this.logger?.debug('RFC conversation opened for one stateless call');
|
|
372
371
|
try {
|
|
373
372
|
return await this.carry(request, own, generation);
|
|
@@ -381,8 +380,8 @@ class RfcTransport {
|
|
|
381
380
|
* wire was closed meanwhile, the conversation is closed again and nothing is
|
|
382
381
|
* sent — not a PUT, not a DELETE — on a wire already given back.
|
|
383
382
|
*/
|
|
384
|
-
async openOwn(generation
|
|
385
|
-
const own = await this.loggedOn(
|
|
383
|
+
async openOwn(generation) {
|
|
384
|
+
const own = await this.loggedOn();
|
|
386
385
|
if (generation !== this.generation || !this.conversation?.alive) {
|
|
387
386
|
await this.closeQuietly(own);
|
|
388
387
|
throw new Error('RFC transport was closed while the call was being opened; nothing was sent.');
|
|
@@ -415,42 +414,16 @@ class RfcTransport {
|
|
|
415
414
|
* A new conversation, logged on: the provider is asked what to open with,
|
|
416
415
|
* every time, and a failed open is a refused logon whose cause is the SDK's
|
|
417
416
|
* own error, untouched — a provider reads its `key` and message.
|
|
418
|
-
*
|
|
419
|
-
* With a request's signal — a call that opens a conversation of its own —
|
|
420
|
-
* both waits are that request's: the provider's logon and the open. An
|
|
421
|
-
* abort ends either for this request at once. A logon it stopped waiting
|
|
422
|
-
* for opens nothing; an open it stopped waiting for runs on, and the
|
|
423
|
-
* conversation it opens — this request's alone — is closed when it does.
|
|
424
417
|
*/
|
|
425
|
-
async loggedOn(
|
|
418
|
+
async loggedOn() {
|
|
426
419
|
const parameters = {};
|
|
427
|
-
|
|
428
|
-
await (0, requestAbort_js_1.untilAborted)(signal, this.context.logon(this.logonTarget(parameters)));
|
|
429
|
-
}
|
|
420
|
+
await this.context?.logon(this.logonTarget(parameters));
|
|
430
421
|
const conversation = this.connect(parameters);
|
|
431
|
-
// An `open()` that throws instead of rejecting is a refused logon too.
|
|
432
|
-
let opened;
|
|
433
422
|
try {
|
|
434
|
-
|
|
423
|
+
await conversation.open();
|
|
435
424
|
}
|
|
436
425
|
catch (e) {
|
|
437
|
-
opened = Promise.reject(e);
|
|
438
|
-
}
|
|
439
|
-
const opening = opened.catch((e) => {
|
|
440
426
|
throw new authErrors_js_1.WireLogonError(e);
|
|
441
|
-
});
|
|
442
|
-
try {
|
|
443
|
-
await (0, requestAbort_js_1.untilAborted)(signal, opening);
|
|
444
|
-
}
|
|
445
|
-
catch (e) {
|
|
446
|
-
if ((0, requestAbort_js_1.isRequestAborted)(e)) {
|
|
447
|
-
// A failed open has nothing to close, and its failure is nobody's.
|
|
448
|
-
// What would have become the kept conversation is closed too, not
|
|
449
|
-
// kept: the next call pays a logon, and no session outlives a call
|
|
450
|
-
// its caller gave up on.
|
|
451
|
-
opening.then(() => this.closeQuietly(conversation), () => { });
|
|
452
|
-
}
|
|
453
|
-
throw e;
|
|
454
427
|
}
|
|
455
428
|
return conversation;
|
|
456
429
|
}
|
|
@@ -523,12 +496,6 @@ class RfcTransport {
|
|
|
523
496
|
if (generation !== this.generation) {
|
|
524
497
|
throw new Error('RFC transport was closed before the call was sent; nothing was sent.');
|
|
525
498
|
}
|
|
526
|
-
// And the caller's abort, here for the same reason: the logon and the
|
|
527
|
-
// open answered turns ago, and an abort since must stop the call. A
|
|
528
|
-
// conversation opened for this call alone is closed by its caller's
|
|
529
|
-
// `finally`; the kept one is reset and stays kept.
|
|
530
|
-
if (request.signal?.aborted)
|
|
531
|
-
throw (0, requestAbort_js_1.requestAborted)();
|
|
532
499
|
let raw;
|
|
533
500
|
try {
|
|
534
501
|
raw = await conversation.call('SADT_REST_RFC_ENDPOINT', {
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a connection: the connector for the system, and the wire it travels
|
|
3
|
+
* over — both stated by the caller.
|
|
4
|
+
*
|
|
5
|
+
* Choosing the wire is the part consumers get wrong, so the four combinations
|
|
6
|
+
* that exist are named here once. Nothing is inferred: not from the config,
|
|
7
|
+
* not from the host name, not from `SapConfig.connectionType`. Taking a
|
|
8
|
+
* system and a transport is the caller stating which system it is dialling
|
|
9
|
+
* and what it travels over — the rule the connectors themselves follow.
|
|
10
|
+
*
|
|
11
|
+
* **A new instance on every call.** One connection instance is one SAP
|
|
12
|
+
* session: after its `disconnect()` (or a logoff of its own) it is spent, and
|
|
13
|
+
* a new session is a new call to this.
|
|
14
|
+
*
|
|
15
|
+
* Every transport option is passed through as the caller gives it; what is
|
|
16
|
+
* not given takes the constructor's own default, nothing more.
|
|
17
|
+
*/
|
|
18
|
+
import type { AgentOptions } from 'node:https';
|
|
19
|
+
import type { IAuthProvider } from '@mcp-abap-adt/interfaces-auth';
|
|
20
|
+
import type { SapConfig } from '../config/sapConfig.js';
|
|
21
|
+
import type { ILogger } from '../logger.js';
|
|
22
|
+
import { AdtCloudConnector } from './AdtCloudConnector.js';
|
|
23
|
+
import { AdtOnPremConnector } from './AdtOnPremConnector.js';
|
|
24
|
+
import { CloudHttpTransport } from './CloudHttpTransport.js';
|
|
25
|
+
import { LegacyOnPremHttpTransport } from './LegacyOnPremHttpTransport.js';
|
|
26
|
+
import { OnPremHttpTransport } from './OnPremHttpTransport.js';
|
|
27
|
+
import { type IRfcTransportOptions, RfcTransport } from './RfcTransport.js';
|
|
28
|
+
/** What every combination takes. */
|
|
29
|
+
interface ConnectionSpecBase<TCredential extends IAuthProvider> {
|
|
30
|
+
/** The system: its URL, client and, over RFC, what the conversation needs. */
|
|
31
|
+
config: SapConfig;
|
|
32
|
+
/** The credential, handed to the connector as it is. */
|
|
33
|
+
credential: TCredential;
|
|
34
|
+
/** The connection's logger. Absent: none. */
|
|
35
|
+
logger?: ILogger | null | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* The wire's own logger — what it logs about carrying requests. Absent:
|
|
38
|
+
* none, as the transport constructors default. Separate from `logger` so a
|
|
39
|
+
* caller can keep the wire quiet, or route it elsewhere.
|
|
40
|
+
*/
|
|
41
|
+
wireLogger?: ILogger | null | undefined;
|
|
42
|
+
/** The client-side conversation id. Absent: a generated one. */
|
|
43
|
+
sessionId?: string | undefined;
|
|
44
|
+
}
|
|
45
|
+
/** What the HTTP wires take besides. */
|
|
46
|
+
interface HttpWireOptions {
|
|
47
|
+
/**
|
|
48
|
+
* The HTTPS agent's options — `ca`, `rejectUnauthorized` and the like, not
|
|
49
|
+
* the credential (its TLS material arrives at logon). Absent: none.
|
|
50
|
+
*/
|
|
51
|
+
agentOptions?: (() => AgentOptions) | undefined;
|
|
52
|
+
}
|
|
53
|
+
export interface CloudHttpSpec<TCredential extends IAuthProvider = IAuthProvider> extends ConnectionSpecBase<TCredential>, HttpWireOptions {
|
|
54
|
+
system: 'cloud';
|
|
55
|
+
transport: 'http';
|
|
56
|
+
}
|
|
57
|
+
export interface OnPremHttpSpec<TCredential extends IAuthProvider = IAuthProvider> extends ConnectionSpecBase<TCredential>, HttpWireOptions {
|
|
58
|
+
system: 'onprem';
|
|
59
|
+
/** `legacy-http`: BASIS 7.40, where the stateful header must not be sent. */
|
|
60
|
+
transport: 'http' | 'legacy-http';
|
|
61
|
+
}
|
|
62
|
+
export interface OnPremRfcSpec<TCredential extends IAuthProvider = IAuthProvider> extends ConnectionSpecBase<TCredential> {
|
|
63
|
+
system: 'onprem';
|
|
64
|
+
transport: 'rfc';
|
|
65
|
+
/** The RFC wire's own options (`logWire`, `maxLoggedBodyChars`). */
|
|
66
|
+
rfc?: IRfcTransportOptions | undefined;
|
|
67
|
+
}
|
|
68
|
+
export type ConnectionSpec<TCredential extends IAuthProvider = IAuthProvider> = CloudHttpSpec<TCredential> | OnPremHttpSpec<TCredential> | OnPremRfcSpec<TCredential>;
|
|
69
|
+
/**
|
|
70
|
+
* What `createConnection` returns: one of the four connections that exist. A
|
|
71
|
+
* caller that needs the exact wire in the type narrows it (`instanceof`), or
|
|
72
|
+
* builds the connection with the constructors, which keep both in the type.
|
|
73
|
+
*/
|
|
74
|
+
export type CreatedConnection<TCredential extends IAuthProvider = IAuthProvider> = AdtCloudConnector<TCredential, CloudHttpTransport> | AdtOnPremConnector<TCredential, OnPremHttpTransport | LegacyOnPremHttpTransport | RfcTransport>;
|
|
75
|
+
export declare function createConnection<TCredential extends IAuthProvider>(spec: ConnectionSpec<TCredential>): CreatedConnection<TCredential>;
|
|
76
|
+
export {};
|
|
77
|
+
//# sourceMappingURL=createConnection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createConnection.d.ts","sourceRoot":"","sources":["../../src/connection/createConnection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,iBAAiB,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Aa,GAAG,aAAa,CACjD,SAAQ,kBAAkB,CAAC,WAAW,CAAC;IACvC,MAAM,EAAE,QAAQ,CAAC;IACjB,SAAS,EAAE,KAAK,CAAC;IACjB,oEAAoE;IACpE,GAAG,CAAC,EAAE,oBAAoB,GAAG,SAAS,CAAC;CACxC;AAED,MAAM,MAAM,cAAc,CAAC,WAAW,SAAS,aAAa,GAAG,aAAa,IACxE,aAAa,CAAC,WAAW,CAAC,GAC1B,cAAc,CAAC,WAAW,CAAC,GAC3B,aAAa,CAAC,WAAW,CAAC,CAAC;AAQ/B;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,CAC3B,WAAW,SAAS,aAAa,GAAG,aAAa,IAE/C,iBAAiB,CAAC,WAAW,EAAE,kBAAkB,CAAC,GAClD,kBAAkB,CAChB,WAAW,EACX,mBAAmB,GAAG,yBAAyB,GAAG,YAAY,CAC/D,CAAC;AAEN,wBAAgB,gBAAgB,CAAC,WAAW,SAAS,aAAa,EAChE,IAAI,EAAE,cAAc,CAAC,WAAW,CAAC,GAChC,iBAAiB,CAAC,WAAW,CAAC,CAkDhC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createConnection = createConnection;
|
|
4
|
+
const AdtCloudConnector_js_1 = require("./AdtCloudConnector.js");
|
|
5
|
+
const AdtOnPremConnector_js_1 = require("./AdtOnPremConnector.js");
|
|
6
|
+
const CloudHttpTransport_js_1 = require("./CloudHttpTransport.js");
|
|
7
|
+
const LegacyOnPremHttpTransport_js_1 = require("./LegacyOnPremHttpTransport.js");
|
|
8
|
+
const OnPremHttpTransport_js_1 = require("./OnPremHttpTransport.js");
|
|
9
|
+
const RfcTransport_js_1 = require("./RfcTransport.js");
|
|
10
|
+
const rfcConversation_js_1 = require("./rfcConversation.js");
|
|
11
|
+
/** Whatever a caller passed, read as the two words that pick the wire. */
|
|
12
|
+
function stated(spec) {
|
|
13
|
+
const record = (spec ?? {});
|
|
14
|
+
return { system: record.system, transport: record.transport };
|
|
15
|
+
}
|
|
16
|
+
function createConnection(spec) {
|
|
17
|
+
const { system, transport } = stated(spec);
|
|
18
|
+
const logger = spec.logger ?? null;
|
|
19
|
+
const wireLogger = spec.wireLogger ?? null;
|
|
20
|
+
const address = { client: spec.config.client, baseUrl: spec.config.url };
|
|
21
|
+
if (system === 'cloud' && transport === 'http') {
|
|
22
|
+
const http = spec;
|
|
23
|
+
return new AdtCloudConnector_js_1.AdtCloudConnector(spec.config, spec.credential, new CloudHttpTransport_js_1.CloudHttpTransport(http.agentOptions, wireLogger, address), logger, spec.sessionId);
|
|
24
|
+
}
|
|
25
|
+
if (system === 'onprem' && transport === 'http') {
|
|
26
|
+
const http = spec;
|
|
27
|
+
return new AdtOnPremConnector_js_1.AdtOnPremConnector(spec.config, spec.credential, new OnPremHttpTransport_js_1.OnPremHttpTransport(http.agentOptions, wireLogger, address), logger, spec.sessionId);
|
|
28
|
+
}
|
|
29
|
+
if (system === 'onprem' && transport === 'legacy-http') {
|
|
30
|
+
const http = spec;
|
|
31
|
+
return new AdtOnPremConnector_js_1.AdtOnPremConnector(spec.config, spec.credential, new LegacyOnPremHttpTransport_js_1.LegacyOnPremHttpTransport(http.agentOptions, wireLogger, address), logger, spec.sessionId);
|
|
32
|
+
}
|
|
33
|
+
if (system === 'onprem' && transport === 'rfc') {
|
|
34
|
+
const rfc = spec;
|
|
35
|
+
return new AdtOnPremConnector_js_1.AdtOnPremConnector(spec.config, spec.credential, new RfcTransport_js_1.RfcTransport((0, rfcConversation_js_1.rfcConversationFrom)(spec.config), wireLogger, rfc.rfc), logger, spec.sessionId);
|
|
36
|
+
}
|
|
37
|
+
// Fixed words: nothing the caller passed is echoed back.
|
|
38
|
+
throw new TypeError("createConnection: no such combination of system and transport. ABAP Cloud has one wire, 'http'; on-prem takes 'http', 'legacy-http' or 'rfc'. Both are stated by the caller, never inferred.");
|
|
39
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { AdtCloudConnector } from './connection/AdtCloudConnector.js';
|
|
|
6
6
|
export { AdtOnPremConnector } from './connection/AdtOnPremConnector.js';
|
|
7
7
|
export { type AuthRefusalMoment, AuthRefusedError, WireLogonError, } from './connection/authErrors.js';
|
|
8
8
|
export { CloudHttpTransport } from './connection/CloudHttpTransport.js';
|
|
9
|
+
export { type CloudHttpSpec, type ConnectionSpec, type CreatedConnection, createConnection, type OnPremHttpSpec, type OnPremRfcSpec, } from './connection/createConnection.js';
|
|
9
10
|
export { CSRF_CONFIG, CSRF_ERROR_MESSAGES } from './connection/csrfConfig.js';
|
|
10
11
|
export { GenericWebSocketTransport, type IWebSocketFactory, type IWebSocketLike, } from './connection/GenericWebSocketTransport.js';
|
|
11
12
|
export { HttpTransport } from './connection/HttpTransport.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,GAClB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,YAAY,EACV,cAAc,EACd,kBAAkB,GACnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EACL,KAAK,iBAAiB,EACtB,gBAAgB,EAChB,cAAc,GACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","s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ACb,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACL,KAAK,mBAAmB,EACxB,mBAAmB,EACnB,aAAa,GACd,MAAM,iCAAiC,CAAC;AACzC,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,KAAK,aAAa,GACnB,MAAM,qBAAqB,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.getTimeoutConfig = exports.getTimeout = exports.rfcParamsFrom = exports.rfcConversationFrom = exports.RfcTransport = exports.OnPremHttpTransport = exports.LegacyOnPremHttpTransport = exports.HttpTransport = exports.GenericWebSocketTransport = exports.CSRF_ERROR_MESSAGES = exports.CSRF_CONFIG = exports.CloudHttpTransport = exports.WireLogonError = exports.AuthRefusedError = exports.AdtOnPremConnector = exports.AdtCloudConnector = exports.sapConfigSignature = void 0;
|
|
5
|
+
exports.getTimeoutConfig = exports.getTimeout = exports.rfcParamsFrom = exports.rfcConversationFrom = exports.RfcTransport = exports.OnPremHttpTransport = exports.LegacyOnPremHttpTransport = 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;
|
|
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; } });
|
|
@@ -15,6 +15,10 @@ Object.defineProperty(exports, "AuthRefusedError", { enumerable: true, get: func
|
|
|
15
15
|
Object.defineProperty(exports, "WireLogonError", { enumerable: true, get: function () { return authErrors_js_1.WireLogonError; } });
|
|
16
16
|
var CloudHttpTransport_js_1 = require("./connection/CloudHttpTransport.js");
|
|
17
17
|
Object.defineProperty(exports, "CloudHttpTransport", { enumerable: true, get: function () { return CloudHttpTransport_js_1.CloudHttpTransport; } });
|
|
18
|
+
// The recommended way to build a connection: the system and the wire stated,
|
|
19
|
+
// a new instance per session.
|
|
20
|
+
var createConnection_js_1 = require("./connection/createConnection.js");
|
|
21
|
+
Object.defineProperty(exports, "createConnection", { enumerable: true, get: function () { return createConnection_js_1.createConnection; } });
|
|
18
22
|
// The session lifecycle vocabulary — ISessionLifecycleAware, ADT_SESSION_ERROR —
|
|
19
23
|
// is deliberately NOT exported here. It lives in @mcp-abap-adt/interfaces-adt-connection, and a
|
|
20
24
|
// consumer imports it from there: re-exporting a contract type gives it two
|
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-16.0.md # the request signal removed; disconnect() resolves once the logoff is written
|
|
18
19
|
│ ├── MIGRATION-15.0.md # interfaces-adt-connection 2: makeAdtRequest answers unknown
|
|
19
20
|
│ ├── MIGRATION-14.0.md # the sap-abap-auth CLI, open and commander are removed
|
|
20
21
|
│ ├── MIGRATION-13.0.md # interfaces-auth 7, auth-errors 2, auth-providers 6.0.0; no behaviour change
|
|
@@ -25,7 +26,7 @@ mcp-abap-connection/
|
|
|
25
26
|
│ ├── MIGRATION-8.0.md # request headers leave the stateful branch; onto interfaces 39; flushGoodbye
|
|
26
27
|
│ ├── MIGRATION-6.0.md # the factory and the per-credential classes go; RFC is a transport
|
|
27
28
|
│ ├── MIGRATION-4.0.md # JWT error classification: 401 refreshes, 403 propagates
|
|
28
|
-
│ ├── SCOPE.md # What this package
|
|
29
|
+
│ ├── SCOPE.md # What this package answers for, and only that
|
|
29
30
|
│ └── STATEFUL_SESSION_GUIDE.md # Stateful requests and lock windows
|
|
30
31
|
├── examples/ # Working code examples
|
|
31
32
|
│ ├── README.md # Examples overview
|
|
@@ -43,9 +44,10 @@ mcp-abap-connection/
|
|
|
43
44
|
- 📦 [Installation Guide](./INSTALLATION.md) - How to install and set up the package
|
|
44
45
|
- 📚 [Usage Guide](./USAGE.md) - Basic usage and comprehensive API documentation
|
|
45
46
|
- 📖 [Main README](../README.md) - Package overview and quick start
|
|
46
|
-
- 🧭 [Scope
|
|
47
|
+
- 🧭 [Scope](./SCOPE.md) - What this package answers for, and only that
|
|
47
48
|
|
|
48
49
|
### Upgrading
|
|
50
|
+
- 🚚 [Migrating to 16.0.0](./MIGRATION-16.0.md) - the per-request `signal` and `ADT_REQUEST_ABORTED` are removed; `disconnect()` resolves once the logoff is written; `flushGoodbye()` waits for the answer
|
|
49
51
|
- 🚚 [Migrating to 15.0.0](./MIGRATION-15.0.md) - on `@mcp-abap-adt/interfaces-adt-connection` 2: `makeAdtRequest`'s answer is `unknown` unless its type is named
|
|
50
52
|
- 🚚 [Migrating to 14.0.0](./MIGRATION-14.0.md) - the `sap-abap-auth` CLI is removed; use `@mcp-abap-adt/auth-broker-cli`
|
|
51
53
|
- 🚚 [Migrating to 13.0.0](./MIGRATION-13.0.md) - interfaces-auth 7 and auth-errors 2; the connection's behaviour is unchanged, a consumer holds one interfaces-auth major and takes the providers from auth-providers 6.0.0
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Migration to 16.0
|
|
2
|
+
|
|
3
|
+
16.0.0 makes this package answer for what [SCOPE.md](./SCOPE.md) lists, and for
|
|
4
|
+
nothing else. For a consumer on 15.x that means the following.
|
|
5
|
+
|
|
6
|
+
## What changed
|
|
7
|
+
|
|
8
|
+
- **`signal` is gone from request options.** This matches
|
|
9
|
+
`@mcp-abap-adt/interfaces-adt-connection` 3.0.0, which drops
|
|
10
|
+
`IAbapRequestOptions.signal`, `ADT_REQUEST_ERROR` and `AdtRequestErrorCode`.
|
|
11
|
+
No request rejects with `ADT_REQUEST_ABORTED` any more. A request behaves as
|
|
12
|
+
it did in 15.0.1: once admitted, it runs to its answer or its `timeout`.
|
|
13
|
+
`IAdtTransportRequest.signal` and `IAdtEstablishContext.signal` are gone
|
|
14
|
+
from the transport seam. Measured on an on-premise system (BASIS 816, 2026-10-12): ABAP
|
|
15
|
+
neither cancels a request that reached it nor rolls back across requests,
|
|
16
|
+
and a logoff releases the locks — so the signal protected nothing.
|
|
17
|
+
- **One connection instance is one SAP session.** The instance is spent after
|
|
18
|
+
`disconnect()`, after a failed `connect()` that received a session cookie
|
|
19
|
+
(a `SAP_SESSIONID_*`; over RFC, an open conversation) — whether or not a
|
|
20
|
+
logoff was sent for it —, or after a lost session: `ADT_SESSION_REPLACED`, raised
|
|
21
|
+
exactly as in 15.0.1 for a changed `SAP_SESSIONID` or a 400 "session not
|
|
22
|
+
found". On a spent instance, `connect()` and every request reject
|
|
23
|
+
`ADT_SESSION_ERROR.NOT_CONNECTED`. The connector decides nothing beyond
|
|
24
|
+
that; what to do next is yours.
|
|
25
|
+
- On a spent instance, `connect()` rejects with
|
|
26
|
+
`ADT_SESSION_ERROR.NOT_CONNECTED`: "This connection's SAP session has
|
|
27
|
+
ended (it was disconnected, logged off or lost); one connection instance is one
|
|
28
|
+
session. Create a new connection for a new session."
|
|
29
|
+
- A failed `connect()` that received no session cookie (a 401, a network
|
|
30
|
+
error, a 200 with only `sap-XSRF_*`) leaves the instance usable, and
|
|
31
|
+
`connect()` may be retried.
|
|
32
|
+
- **No 401 opens a new session on the same instance.** Before 16.0.0, a
|
|
33
|
+
mutation refused with a 401 while a CSRF token was cached (outside a
|
|
34
|
+
critical section) discarded the session and retried in a new one, and a GET
|
|
35
|
+
refused with a 401 on a wire with no cookies fetched a token to open one,
|
|
36
|
+
and a GET refused with a 401 while cookies were held was resent once with
|
|
37
|
+
them before the provider was asked. All three are removed. The 401 goes to the provider (`rejected`); on
|
|
38
|
+
Ok the request is resent once in the same session, otherwise you get
|
|
39
|
+
`AuthRefusedError` carrying SAP's 401. The CSRF refetch for a 403 "CSRF
|
|
40
|
+
token validation failed" (cookies kept) and the provider's re-ask stay.
|
|
41
|
+
- **`disconnect()` resolves once the logoff is written.** It resolves when the
|
|
42
|
+
bytes are handed to the socket over HTTP, or when the close call has
|
|
43
|
+
returned over RFC. It does not wait for SAP's answer. The first call never
|
|
44
|
+
throws: a logoff that fails is logged.
|
|
45
|
+
- **Call it once per instance.** A second call rejects with
|
|
46
|
+
`ADT_SESSION_ERROR.NOT_CONNECTED` ("disconnect() was already called for
|
|
47
|
+
this connection; call it once per instance"), whether it comes while the
|
|
48
|
+
first is still writing or after it. The first call is unaffected.
|
|
49
|
+
- No timer bounds the write. A server that never takes the bytes holds
|
|
50
|
+
`disconnect()` until the socket fails. That failure is logged, not thrown.
|
|
51
|
+
- **"Written" means handed to the operating system.** The logoff goes out
|
|
52
|
+
on a connection of its own over HTTP. Over HTTPS this holds while your
|
|
53
|
+
`agentOptions` leave `keepAlive` off.
|
|
54
|
+
- **Over RFC, the close waits for a call still running on its
|
|
55
|
+
conversation.** In `@mcp-abap-adt/sap-rfc-lite` 0.2.2, a call holds the
|
|
56
|
+
client's invocation mutex until it returns, and `close()` takes the same
|
|
57
|
+
mutex.
|
|
58
|
+
- **When the logoff is sent.** It is sent if and only if the instance holds
|
|
59
|
+
a live `SAP_SESSIONID_*` that it received: not one deleted by a past
|
|
60
|
+
`expires` or `Max-Age=0`.
|
|
61
|
+
- A `connect()` that fails as a whole after the server opened a session (a
|
|
62
|
+
cloud preflight's, or a 403/404 after logon on both discovery endpoints)
|
|
63
|
+
logs it off, and rejects only once the logoff is written.
|
|
64
|
+
- A 404 on core discovery alone is not a failure: the fallback runs in the
|
|
65
|
+
same session.
|
|
66
|
+
- A 401, or a 200 with only `sap-XSRF_*`, has no session, so nothing is
|
|
67
|
+
sent.
|
|
68
|
+
- The logoff never carries `sap-contextid`. Measured on an on-premise system (2026-10-13), a
|
|
69
|
+
logoff carrying a stale one got 400 and closed nothing, while one without
|
|
70
|
+
it ended the context and released its lock.
|
|
71
|
+
- A redirect answering the logoff counts as its answer: it is not
|
|
72
|
+
followed.
|
|
73
|
+
- On cloud, a session the server linked no logoff resource for is logged
|
|
74
|
+
off through the platform's ICF logoff (`/sap/public/bc/icf/logoff`), as
|
|
75
|
+
on-prem, instead of being left to the server's timeout. A linked logoff
|
|
76
|
+
resource is used as before.
|
|
77
|
+
- **`flushGoodbye(timeoutMs?)` has no default bound.** Without an argument it
|
|
78
|
+
waits for SAP's answer to the logoff for as long as it takes. With
|
|
79
|
+
`timeoutMs` it waits at most that long and returns without throwing.
|
|
80
|
+
- **`IAdtTransport.close(context, written?)`**: a wire reports the write by
|
|
81
|
+
calling `written`. `disconnect()` resolves at the first of `written()` and
|
|
82
|
+
the close settling.
|
|
83
|
+
|
|
84
|
+
## What a consumer must do
|
|
85
|
+
|
|
86
|
+
- **Build connections with `createConnection(spec)`** (recommended). You state
|
|
87
|
+
`system` and `transport` (`cloud`+`http`, or `onprem` with `http`,
|
|
88
|
+
`legacy-http` or `rfc`). The factory builds the matching connector and wire
|
|
89
|
+
and passes your transport options through. It returns a new instance on
|
|
90
|
+
every call. The constructors still work.
|
|
91
|
+
- **Drop `signal`** from the options passed to `makeAdtRequest`, and drop any
|
|
92
|
+
check for `ADT_REQUEST_ERROR` or `'ADT_REQUEST_ABORTED'`.
|
|
93
|
+
- **Call `disconnect()` once.** If more than one path in your code can end a
|
|
94
|
+
connection, such as a `finally` and a signal handler, let one of them own
|
|
95
|
+
the call, or catch the second call's rejection.
|
|
96
|
+
- **A process about to exit awaits `disconnect()`.** Once it resolves, the
|
|
97
|
+
logoff has left:
|
|
98
|
+
```typescript
|
|
99
|
+
await connection.disconnect();
|
|
100
|
+
process.exit(0);
|
|
101
|
+
```
|
|
102
|
+
- **A new session is a new instance, and creating it is yours.** Use your
|
|
103
|
+
own factory or `createConnection`. Anywhere you called `connect()` again on
|
|
104
|
+
an instance after `disconnect()`, create a new connection instead.
|
|
105
|
+
- **On a 401, create a new instance if you want a new session.** The
|
|
106
|
+
connection no longer opens one for you. Where you relied on a mutation's
|
|
107
|
+
401 being retried in a fresh session, catch the `AuthRefusedError` (or the
|
|
108
|
+
`ADT_SESSION_REPLACED` the resend may raise), `disconnect()` the instance,
|
|
109
|
+
and redo the work on a new connection — under a new lock, if it held one.
|
|
110
|
+
- **`flushGoodbye()` no longer gives up after 5 s.** If you need a bound,
|
|
111
|
+
pass one: `flushGoodbye(5000)`.
|
|
112
|
+
- **Await `flushGoodbye()` as well if SAP's answer matters**, for example
|
|
113
|
+
before a new connection connects, so that the server never holds two
|
|
114
|
+
sessions:
|
|
115
|
+
```typescript
|
|
116
|
+
await connection.disconnect();
|
|
117
|
+
await connection.flushGoodbye();
|
|
118
|
+
const next = createYourConnection();
|
|
119
|
+
await next.connect();
|
|
120
|
+
```
|
|
121
|
+
- **A custom transport** (`IAdtTransport`) whose `close()` stays pending long
|
|
122
|
+
after its goodbye has left should call the new `written` argument at that
|
|
123
|
+
point. Otherwise `disconnect()` waits for the close to settle.
|
package/docs/SCOPE.md
CHANGED
|
@@ -1,45 +1,17 @@
|
|
|
1
|
-
# Scope
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
| Session state persistence across processes | `@mcp-abap-adt/auth-broker` |
|
|
19
|
-
| Auth-type constants, provider error codes, auth lifecycle contracts | `@mcp-abap-adt/interfaces-auth`, `@mcp-abap-adt/interfaces-auth-sap` |
|
|
20
|
-
| Minting and classifying an auth refusal (`IAuthProviderError`) | `@mcp-abap-adt/auth-errors` |
|
|
21
|
-
|
|
22
|
-
The rule: **if it is about *acquiring* or *refreshing* credentials, it is not our job.** We receive credentials that are valid at call time and use them. The consumer is responsible for handing us fresh ones — they know their IdP, their refresh cadence, their re-auth UX.
|
|
23
|
-
|
|
24
|
-
## Why there is no RFC to SAP BTP / cloud
|
|
25
|
-
|
|
26
|
-
Short answer: because SAP does not support it that way, and Eclipse ADT does not do it that way either.
|
|
27
|
-
|
|
28
|
-
**1. Eclipse ADT talks to cloud over HTTP, not RFC.**
|
|
29
|
-
The `com.sap.adt.communication.http.*` package is the only transport Eclipse ADT uses for ADT itself. Cloud login in Eclipse goes through `SamlWithReentranceTicketLogonFacade` → `IcfEndpointBasedSystemUrlInfoProvider` → `HttpLowLevelConnection.sendRequest`. This is an HTTP flow via the ABAP ICF (Internet Communication Framework) endpoint, with a browser SAML login minting a short-lived reentrance ticket, which is then exchanged for a `MYSAPSSO2` session cookie over HTTP. There is no RFC anywhere in this path. JCo/RFC calls that appear in Eclipse logs come from unrelated features (GUI integration, JCo destination tests) — not ADT.
|
|
30
|
-
|
|
31
|
-
**2. NW RFC SDK has no JWT or SAML-2.0-XML logon parameter.**
|
|
32
|
-
Inspection of `sapnwrfc.h` and the SDK's reference `sapnwrfc.ini` confirms the supported client logon parameters are: `USER`/`PASSWD`, `X509CERT`, `MYSAPSSO2` (accepts SSO2 tickets and SAP-internal "assertion tickets", *not* SAML 2.0 XML assertions), plus SNC (`SNC_QOP`, `SNC_MYNAME`, `SNC_PARTNERNAME`, `SNC_LIB`) for Kerberos/x509 over RFC. For WebSocket-RFC: `WSHOST`/`WSPORT`, `ALIAS_USER`, `TLS_CLIENT_PSE`, `TLS_CLIENT_CERTIFICATE_LOGON`. No `JWT`, no `BEARER`, no `SAML_ASSERTION`, no `OAUTH` keys exist in the SDK headers.
|
|
33
|
-
|
|
34
|
-
**3. `@mcp-abap-adt/sap-rfc-lite` is a pure passthrough.**
|
|
35
|
-
It forwards every `(name, value)` pair from the JS `Client(params)` object to `RFC_CONNECTION_PARAMETER[]` without filtering. So the wrapper is not a constraint — the constraint is the SDK itself.
|
|
36
|
-
|
|
37
|
-
**4. For BTP on-prem scenarios (Cloud Connector), the JWT→x509/SNC swap happens server-side in the CC.** The client-side RFC call still carries classic credentials (x509 + SNC), not the JWT. Supporting that would be adding SNC-over-RFC for on-prem backends behind a CC tunnel — an on-prem extension, not a "cloud RFC" feature.
|
|
38
|
-
|
|
39
|
-
**Conclusion:** "RFC to cloud" is not a missing feature that would be useful to add; it is a category error. ADT to cloud = HTTP (already supported here). RFC to on-prem = supported here, by handing `AdtOnPremConnector` an `RfcTransport`. Anything claiming a third combination does not map to what the SAP stack actually exposes.
|
|
40
|
-
|
|
41
|
-
## See also
|
|
42
|
-
|
|
43
|
-
- [`INSTALLATION.md`](./INSTALLATION.md)
|
|
44
|
-
- [`USAGE.md`](./USAGE.md)
|
|
45
|
-
- Sibling packages: `@mcp-abap-adt/interfaces-adt-connection`, `@mcp-abap-adt/interfaces-auth`, `@mcp-abap-adt/interfaces-auth-sap`, `@mcp-abap-adt/interfaces-network`, `@mcp-abap-adt/interfaces-utils`, `@mcp-abap-adt/auth-errors` (mints and classifies every auth refusal), `@mcp-abap-adt/sap-rfc-lite`, `@mcp-abap-adt/auth-broker`
|
|
1
|
+
# Scope
|
|
2
|
+
|
|
3
|
+
`@mcp-abap-adt/connection` answers for this, and only this:
|
|
4
|
+
|
|
5
|
+
1. **Building a connection.** `createConnection({ system, transport, … })`: cloud + HTTP,
|
|
6
|
+
on-prem + HTTP, on-prem + legacy HTTP (BASIS 7.40), on-prem + RFC. The caller states
|
|
7
|
+
the system and the transport; nothing is inferred.
|
|
8
|
+
2. **One instance, one SAP session.** `connect()` logs on; the first authenticated request
|
|
9
|
+
opens the session. A new session is a new instance.
|
|
10
|
+
3. **Requests.** Each carries the credential the `IAuthProvider` hands over, the CSRF token
|
|
11
|
+
and the session's cookies. A request is sent stateful (`LOCK`, `UNLOCK`, activation) or
|
|
12
|
+
stateless; nothing else of the session is kept between requests.
|
|
13
|
+
4. **SAP's answer** reaches the caller as SAP gave it.
|
|
14
|
+
5. **`disconnect()`, once.** It sends the logoff when the instance holds a live
|
|
15
|
+
`SAP_SESSIONID` and resolves when the logoff is written. A `connect()` that failed after
|
|
16
|
+
opening a session logs it off before it rejects. `flushGoodbye(ms?)` waits for SAP's
|
|
17
|
+
answer to the logoff.
|