@mcp-abap-adt/connection 15.1.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 +187 -1
- package/README.md +137 -33
- package/dist/connection/AbstractAbapConnection.d.ts +140 -58
- package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
- package/dist/connection/AbstractAbapConnection.js +349 -255
- 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 +8 -1
- package/dist/connection/CloudHttpTransport.d.ts.map +1 -1
- package/dist/connection/CloudHttpTransport.js +30 -18
- 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 +80 -6
- package/dist/connection/HttpTransport.d.ts.map +1 -1
- package/dist/connection/HttpTransport.js +258 -25
- package/dist/connection/IAdtTransport.d.ts +46 -22
- 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 +7 -6
- package/dist/connection/RfcTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.js +27 -49
- package/dist/connection/createConnection.d.ts +95 -0
- package/dist/connection/createConnection.d.ts.map +1 -0
- package/dist/connection/createConnection.js +44 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/docs/INDEX.md +6 -2
- package/docs/MIGRATION-16.0.md +123 -0
- package/docs/MIGRATION-17.0.md +119 -0
- package/docs/SCOPE.md +22 -45
- package/docs/STATEFUL_SESSION_GUIDE.md +49 -49
- package/docs/USAGE.md +244 -120
- 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
- package/dist/utils/timeouts.d.ts +0 -18
- package/dist/utils/timeouts.d.ts.map +0 -1
- package/dist/utils/timeouts.js +0 -37
|
@@ -25,6 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.HttpTransport = exports.isStatefulRequest = void 0;
|
|
27
27
|
const node_crypto_1 = require("node:crypto");
|
|
28
|
+
const node_http_1 = require("node:http");
|
|
28
29
|
const node_https_1 = require("node:https");
|
|
29
30
|
const auth_errors_1 = require("@mcp-abap-adt/auth-errors");
|
|
30
31
|
const axios_1 = __importDefault(require("axios"));
|
|
@@ -32,10 +33,35 @@ const cookies_js_1 = require("../utils/cookies.js");
|
|
|
32
33
|
const authErrors_js_1 = require("./authErrors.js");
|
|
33
34
|
const csrfConfig_js_1 = require("./csrfConfig.js");
|
|
34
35
|
const IAdtTransport_js_1 = require("./IAdtTransport.js");
|
|
35
|
-
const requestAbort_js_1 = require("./requestAbort.js");
|
|
36
36
|
const statefulRequest_js_1 = require("./statefulRequest.js");
|
|
37
|
+
/**
|
|
38
|
+
* Whether a `Set-Cookie`'s attributes delete it: `Max-Age` of zero or less, or
|
|
39
|
+
* an `Expires` already in the past — SAP's own deletions are the latter
|
|
40
|
+
* (`expires=Tue, 01-Jan-1980 00:00:01 GMT`, a one-character value). Read by
|
|
41
|
+
* splitting, not by pattern; `Date.parse` reads the date.
|
|
42
|
+
*/
|
|
43
|
+
function deletesCookie(attributes) {
|
|
44
|
+
for (const attribute of attributes) {
|
|
45
|
+
const [rawName, ...rawValue] = attribute.split('=');
|
|
46
|
+
const name = rawName?.trim().toLowerCase();
|
|
47
|
+
const value = rawValue.join('=').trim();
|
|
48
|
+
if (name === 'max-age') {
|
|
49
|
+
const seconds = Number(value);
|
|
50
|
+
if (value !== '' && Number.isFinite(seconds) && seconds <= 0)
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
if (name === 'expires') {
|
|
54
|
+
const at = Date.parse(value);
|
|
55
|
+
if (Number.isFinite(at) && at <= Date.now())
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
37
61
|
/** The cookie that names a stateful ABAP context. */
|
|
38
62
|
const CONTEXT_COOKIE = 'sap-contextid';
|
|
63
|
+
/** The platform's logoff, which answers `200` while expiring the session cookie. */
|
|
64
|
+
const ICF_LOGOFF_PATH = '/sap/public/bc/icf/logoff';
|
|
39
65
|
/**
|
|
40
66
|
* A `Cookie` header without `sap-contextid`, for a request that is not stateful.
|
|
41
67
|
*
|
|
@@ -77,6 +103,27 @@ function absentEndpoint(error) {
|
|
|
77
103
|
?.response?.status;
|
|
78
104
|
return status === 404 || status === 501;
|
|
79
105
|
}
|
|
106
|
+
/** The cookie the CSRF token is bound to: re-earned with the token, never kept. */
|
|
107
|
+
const XSRF_COOKIE_PREFIX = 'sap-XSRF_';
|
|
108
|
+
/** Two fingerprints name the same session: the same cookies, the same values. */
|
|
109
|
+
function sameSession(a, b) {
|
|
110
|
+
if (a.size !== b.size)
|
|
111
|
+
return false;
|
|
112
|
+
for (const [name, value] of a) {
|
|
113
|
+
if (b.get(name) !== value)
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* SAP answered, but not as the session handed over. The answer rides on the
|
|
120
|
+
* error as `response`, as on any refusal; the words are fixed.
|
|
121
|
+
*/
|
|
122
|
+
function notTheSession(response, what) {
|
|
123
|
+
const error = new Error(`The session handed over did not answer as itself: ${what}. Nothing was logged on and nothing is logged off; this connection is spent.`);
|
|
124
|
+
error.response = response;
|
|
125
|
+
return error;
|
|
126
|
+
}
|
|
80
127
|
const MATERIAL_FIELDS = ['cert', 'key', 'pfx', 'passphrase'];
|
|
81
128
|
/**
|
|
82
129
|
* The material fields a provider offered, and nothing else: a key outside
|
|
@@ -193,13 +240,22 @@ class HttpTransport {
|
|
|
193
240
|
for (const entry of Array.isArray(setCookie) ? setCookie : [setCookie]) {
|
|
194
241
|
if (typeof entry !== 'string')
|
|
195
242
|
continue;
|
|
196
|
-
const [nameValue] = entry.split(';');
|
|
243
|
+
const [nameValue, ...attributes] = entry.split(';');
|
|
197
244
|
if (!nameValue)
|
|
198
245
|
continue;
|
|
199
246
|
const [name, ...rest] = nameValue.split('=');
|
|
200
247
|
const trimmed = name?.trim();
|
|
201
248
|
if (!trimmed)
|
|
202
249
|
continue;
|
|
250
|
+
// A deletion removes the cookie, and is told by its expiry, not its
|
|
251
|
+
// value: SAP's logoff deletes every cookie with a one-character value
|
|
252
|
+
// and `expires=Tue, 01-Jan-1980 00:00:01 GMT` (on-premise, 2026-10-13). Kept,
|
|
253
|
+
// a deleted `SAP_SESSIONID` would read as a session the server has
|
|
254
|
+
// just ended.
|
|
255
|
+
if (deletesCookie(attributes)) {
|
|
256
|
+
this.jar.delete(trimmed);
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
203
259
|
this.jar.set(trimmed, rest.join('=').trim());
|
|
204
260
|
}
|
|
205
261
|
// SAP answers `sap-usercontext` with the system default rather than the
|
|
@@ -209,18 +265,105 @@ class HttpTransport {
|
|
|
209
265
|
if (this.options.client) {
|
|
210
266
|
this.jar.set('sap-usercontext', `sap-client=${this.options.client}`);
|
|
211
267
|
}
|
|
212
|
-
|
|
213
|
-
return;
|
|
268
|
+
// Recomputed from what the jar holds now, deletions included.
|
|
214
269
|
const combined = Array.from(this.jar.entries())
|
|
215
270
|
.map(([name, value]) => (value ? `${name}=${value}` : name))
|
|
216
271
|
.join('; ');
|
|
217
|
-
|
|
218
|
-
this.combined = combined;
|
|
272
|
+
this.combined = combined || null;
|
|
219
273
|
}
|
|
220
274
|
/** What to put on the `Cookie` header, or nothing if the jar is empty. */
|
|
221
275
|
cookies() {
|
|
222
276
|
return this.combined;
|
|
223
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* The session's cookies, for the caller to keep and hand back to
|
|
280
|
+
* `resume()`: the jar without `sap-XSRF_*`, which belongs to the CSRF token
|
|
281
|
+
* and is earned again with it. `SAP_SESSIONID_*`, `sap-usercontext`,
|
|
282
|
+
* `sap-contextid` — so a stateful request after the resume reaches the same
|
|
283
|
+
* ABAP context — and whatever else the server set to keep the session where
|
|
284
|
+
* it lives. `null` while the wire holds no live `SAP_SESSIONID`.
|
|
285
|
+
*/
|
|
286
|
+
sessionCookies() {
|
|
287
|
+
if (!this.holdsSessionCookie())
|
|
288
|
+
return null;
|
|
289
|
+
const pairs = Array.from(this.jar.entries())
|
|
290
|
+
.filter(([name]) => !name.startsWith(XSRF_COOKIE_PREFIX))
|
|
291
|
+
.map(([name, value]) => (value ? `${name}=${value}` : name));
|
|
292
|
+
return pairs.join('; ');
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Take over the session `session` names: see `IAdtTransport.resume`.
|
|
296
|
+
*
|
|
297
|
+
* The request is the CSRF fetch on the discovery endpoint — the fallback on
|
|
298
|
+
* a `404` there, as `establish()` does, in the same session — with no
|
|
299
|
+
* credential and no retry. On the cloud wire it says
|
|
300
|
+
* `x-sap-security-session: use`, because the seeded jar holds a session
|
|
301
|
+
* (`sessionHeaders`).
|
|
302
|
+
*/
|
|
303
|
+
async resume(context, session) {
|
|
304
|
+
this.forgetSession();
|
|
305
|
+
this.ingest({
|
|
306
|
+
'set-cookie': session
|
|
307
|
+
.split(';')
|
|
308
|
+
.map((entry) => entry.trim())
|
|
309
|
+
.filter((entry) => entry !== ''),
|
|
310
|
+
});
|
|
311
|
+
const handed = this.sessionFingerprint();
|
|
312
|
+
if (handed.size === 0) {
|
|
313
|
+
this.forgetSession();
|
|
314
|
+
throw new Error('The session handed over names no SAP_SESSIONID, so there is no session to take over; nothing was sent.');
|
|
315
|
+
}
|
|
316
|
+
const base = context.baseUrl.endsWith('/')
|
|
317
|
+
? context.baseUrl.slice(0, -1)
|
|
318
|
+
: context.baseUrl;
|
|
319
|
+
const endpoints = [
|
|
320
|
+
`${base}${csrfConfig_js_1.CSRF_CONFIG.ENDPOINT}`,
|
|
321
|
+
`${base}${csrfConfig_js_1.CSRF_CONFIG.FALLBACK_ENDPOINT}`,
|
|
322
|
+
];
|
|
323
|
+
let response;
|
|
324
|
+
for (const [index, url] of endpoints.entries()) {
|
|
325
|
+
try {
|
|
326
|
+
// No `context.authorize`: the session's cookies are the only thing
|
|
327
|
+
// that may authenticate this request. And no redirect followed: a
|
|
328
|
+
// redirect is not the session answering — followed, a login page's
|
|
329
|
+
// 200, or a SAP_SESSIONID replaced on the way, would be judged
|
|
330
|
+
// instead of what SAP said. Not admitted, a 3xx rejects as it came.
|
|
331
|
+
const fixed = this.fix({
|
|
332
|
+
method: 'GET',
|
|
333
|
+
url,
|
|
334
|
+
headers: {
|
|
335
|
+
...context.extraHeaders,
|
|
336
|
+
...csrfConfig_js_1.CSRF_CONFIG.REQUIRED_HEADERS,
|
|
337
|
+
},
|
|
338
|
+
});
|
|
339
|
+
response = await this.dispatch(fixed, this.dress(fixed), undefined, {
|
|
340
|
+
maxRedirects: 0,
|
|
341
|
+
});
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
catch (error) {
|
|
345
|
+
if (index === 0 && absentEndpoint(error))
|
|
346
|
+
continue;
|
|
347
|
+
// SAP's answer as it is — a 401 for a session that is gone.
|
|
348
|
+
throw error;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (!response)
|
|
352
|
+
throw new Error(csrfConfig_js_1.CSRF_ERROR_MESSAGES.NOT_IN_HEADERS);
|
|
353
|
+
context.observe(response.headers);
|
|
354
|
+
this.ingest(response.headers);
|
|
355
|
+
if (!sameSession(handed, this.sessionFingerprint())) {
|
|
356
|
+
throw notTheSession(response, 'the answer names another session, or none');
|
|
357
|
+
}
|
|
358
|
+
const token = response.headers['x-csrf-token'];
|
|
359
|
+
if (typeof token !== 'string' || token === '') {
|
|
360
|
+
throw notTheSession(response, 'the answer carries no CSRF token');
|
|
361
|
+
}
|
|
362
|
+
this.token = token;
|
|
363
|
+
// The credential's logon, now that the session has answered: what it
|
|
364
|
+
// brings — TLS material — is for the requests that follow.
|
|
365
|
+
await context.logon(this.logonTarget());
|
|
366
|
+
}
|
|
224
367
|
/**
|
|
225
368
|
* Which ABAP session this wire is on.
|
|
226
369
|
*
|
|
@@ -231,11 +374,48 @@ class HttpTransport {
|
|
|
231
374
|
sessionFingerprint() {
|
|
232
375
|
const fingerprint = new Map();
|
|
233
376
|
for (const [name, value] of this.jar) {
|
|
234
|
-
|
|
377
|
+
// Non-empty only: an empty value names no session.
|
|
378
|
+
if (name.startsWith('SAP_SESSIONID') && value !== '') {
|
|
235
379
|
fingerprint.set(name, value);
|
|
380
|
+
}
|
|
236
381
|
}
|
|
237
382
|
return fingerprint;
|
|
238
383
|
}
|
|
384
|
+
/**
|
|
385
|
+
* The cookies a logoff carries: the jar without `sap-contextid`.
|
|
386
|
+
*
|
|
387
|
+
* The logoff ends the HTTP security session `SAP_SESSIONID` names, and with
|
|
388
|
+
* it every ABAP context of that session. Measured on an on-premise system with bare HTTP
|
|
389
|
+
* (2026-10-13): a LOCK held in a stateful context, then a logoff carrying
|
|
390
|
+
* `SAP_SESSIONID_ABC_001` and `sap-usercontext` but no `sap-contextid` →
|
|
391
|
+
* 200, `SAP_SESSIONID` deleted, and an independent session then got the
|
|
392
|
+
* LOCK: the context ended and the lock was released. A logoff that carried a
|
|
393
|
+
* stale (deleted) `sap-contextid` got 400 and closed nothing. So the
|
|
394
|
+
* context cookie never rides on a logoff.
|
|
395
|
+
*/
|
|
396
|
+
logoffCookies() {
|
|
397
|
+
const pairs = Array.from(this.jar.entries())
|
|
398
|
+
.filter(([name]) => name !== CONTEXT_COOKIE)
|
|
399
|
+
.map(([name, value]) => (value ? `${name}=${value}` : name));
|
|
400
|
+
return pairs.length > 0 ? pairs.join('; ') : null;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Whether this wire holds a non-empty `SAP_SESSIONID_*` cookie it received —
|
|
404
|
+
* the one condition under which a logoff is sent.
|
|
405
|
+
*
|
|
406
|
+
* Read from the jar, never from `sessionEstablished()`, which a wire may
|
|
407
|
+
* answer otherwise (BASIS 7.40 says yes with no such cookie). The evidence,
|
|
408
|
+
* on an on-premise system (ABAP code and measurement): `CL_HTTP_SERVER_NET->send_response`
|
|
409
|
+
* sets `SAP_SESSIONID_<SID>_<CLIENT>` only when that request created a
|
|
410
|
+
* security session (`m_security_session_created`), whatever the status — a
|
|
411
|
+
* 404 or 403 after logon carried it and the session was alive; and the ICF
|
|
412
|
+
* logoff ends a session only when that cookie is present. So a logoff
|
|
413
|
+
* without it ends nothing, and one with it is owed whatever the status that
|
|
414
|
+
* brought it.
|
|
415
|
+
*/
|
|
416
|
+
holdsSessionCookie() {
|
|
417
|
+
return this.sessionFingerprint().size > 0;
|
|
418
|
+
}
|
|
239
419
|
/**
|
|
240
420
|
* A session exists when the server named one.
|
|
241
421
|
*
|
|
@@ -334,7 +514,7 @@ class HttpTransport {
|
|
|
334
514
|
for (const [index, url] of endpoints.entries()) {
|
|
335
515
|
// The fallback exists for a system that HAS no
|
|
336
516
|
// `/sap/bc/adt/core/discovery` — BASIS < 7.52 — which the server says by
|
|
337
|
-
// answering 404 there. Trying it after a refused connection or a
|
|
517
|
+
// answering 404 there. Trying it after a refused connection or a network
|
|
338
518
|
// asks a host that is not answering to answer a different path, which
|
|
339
519
|
// doubles the wait before the caller is told what is actually wrong.
|
|
340
520
|
if (index > 0 && !absentEndpoint(last))
|
|
@@ -344,11 +524,6 @@ class HttpTransport {
|
|
|
344
524
|
// Authorized per attempt: a provider may renew behind the call.
|
|
345
525
|
const auth = {};
|
|
346
526
|
await context.authorize(auth);
|
|
347
|
-
// The last point before the wire: the exchange's request was
|
|
348
|
-
// aborted in a turn since its authorize answered. Fatal to the
|
|
349
|
-
// exchange through `isFatal`, like the abort `authorize` raises.
|
|
350
|
-
if (context.signal?.aborted)
|
|
351
|
-
throw (0, requestAbort_js_1.requestAborted)();
|
|
352
527
|
const response = await this.send({
|
|
353
528
|
method: 'GET',
|
|
354
529
|
url,
|
|
@@ -357,9 +532,6 @@ class HttpTransport {
|
|
|
357
532
|
...context.extraHeaders,
|
|
358
533
|
...csrfConfig_js_1.CSRF_CONFIG.REQUIRED_HEADERS,
|
|
359
534
|
},
|
|
360
|
-
...(context.timeoutMs !== undefined
|
|
361
|
-
? { timeout: context.timeoutMs }
|
|
362
|
-
: {}),
|
|
363
535
|
});
|
|
364
536
|
// Handed up BEFORE the token is read: the cookies are the session,
|
|
365
537
|
// and a fold that only happened on success would lose the session a
|
|
@@ -667,7 +839,19 @@ class HttpTransport {
|
|
|
667
839
|
* session document links to, the on-prem one the platform logoff. A bare HTTP wire has
|
|
668
840
|
* neither, and says so by doing nothing.
|
|
669
841
|
*/
|
|
670
|
-
async close(_context) { }
|
|
842
|
+
async close(_context, _written) { }
|
|
843
|
+
/**
|
|
844
|
+
* The platform's own logoff, `/sap/public/bc/icf/logoff`: the session's
|
|
845
|
+
* cookies (taken by the caller before its first await, without
|
|
846
|
+
* `sap-contextid`), no session headers, its write reported through
|
|
847
|
+
* `written`. On-prem it is the only goodbye; on cloud it is the goodbye when
|
|
848
|
+
* the server linked no logoff resource of its own — it ends a cloud security
|
|
849
|
+
* session too (measured on a BTP trial with bare HTTP, 2026-10-13: the same
|
|
850
|
+
* cookies were refused with 401 right after it, accepted before).
|
|
851
|
+
*/
|
|
852
|
+
async sendIcfLogoff(context, snapshot, written) {
|
|
853
|
+
await this.sendLogoff(context, `${context.baseUrl}${ICF_LOGOFF_PATH}`, { ...snapshot, session: {} }, written);
|
|
854
|
+
}
|
|
671
855
|
/**
|
|
672
856
|
* The logoff, sent as Eclipse ADT 3.60.3 sends it when a project is closed.
|
|
673
857
|
*
|
|
@@ -683,13 +867,20 @@ class HttpTransport {
|
|
|
683
867
|
* about THIS session; and when the logoff cannot end one, the reason is an
|
|
684
868
|
* error message whose status the ICF kernel picks, which no ABAP source shows.
|
|
685
869
|
*/
|
|
686
|
-
async sendLogoff(context, url, snapshot
|
|
870
|
+
async sendLogoff(context, url, snapshot,
|
|
871
|
+
/** Called once the logoff's bytes are on the socket; see `close()`. */
|
|
872
|
+
written) {
|
|
687
873
|
// Nothing that logs on, whoever put it in the context: the goodbye carries
|
|
688
874
|
// the session's cookie and no credential.
|
|
689
875
|
const extra = Object.fromEntries(Object.entries(context.extraHeaders ?? {}).filter(([name]) => name.trim().toLowerCase() !== 'authorization'));
|
|
690
876
|
try {
|
|
691
877
|
await this.sendDetached({
|
|
692
878
|
method: 'GET',
|
|
879
|
+
// A redirect is an answer like any other: the logoff has arrived,
|
|
880
|
+
// and its answer is not read. Not followed — that would send the
|
|
881
|
+
// session's cookie on to wherever the server points — and not
|
|
882
|
+
// reported as a failure to say goodbye.
|
|
883
|
+
validateStatus: (status) => status >= 200 && status < 400,
|
|
693
884
|
url,
|
|
694
885
|
headers: {
|
|
695
886
|
...snapshot.affinity,
|
|
@@ -703,7 +894,7 @@ class HttpTransport {
|
|
|
703
894
|
'sap-cancel-on-close': 'true',
|
|
704
895
|
Cookie: snapshot.cookies,
|
|
705
896
|
},
|
|
706
|
-
});
|
|
897
|
+
}, written);
|
|
707
898
|
this.logger?.debug('Told the server the session is finished');
|
|
708
899
|
}
|
|
709
900
|
catch (error) {
|
|
@@ -748,9 +939,10 @@ class HttpTransport {
|
|
|
748
939
|
/**
|
|
749
940
|
* Send EXACTLY these headers, with nothing of the wire's live state mixed in.
|
|
750
941
|
*
|
|
751
|
-
* For a goodbye, and only for a goodbye. `disconnect()`
|
|
752
|
-
*
|
|
753
|
-
* connection is already free to `connect()`
|
|
942
|
+
* For a goodbye, and only for a goodbye. `disconnect()` releases the
|
|
943
|
+
* transition queue before the logoff is even written, so the request is
|
|
944
|
+
* still being assembled while the connection is already free to `connect()`
|
|
945
|
+
* again — and by the time it goes
|
|
754
946
|
* out, the jar can hold a different session. Dressing it then merges the LIVE
|
|
755
947
|
* `SAP_SESSIONID` over the snapshot, and `mergeCookieHeaders` lets the later
|
|
756
948
|
* value win on a repeated name, so the goodbye for the old session arrives
|
|
@@ -759,11 +951,52 @@ class HttpTransport {
|
|
|
759
951
|
* Reading the cookies synchronously is necessary and was not sufficient: the
|
|
760
952
|
* snapshot survived only until the send path put the jar back on top of it.
|
|
761
953
|
*/
|
|
762
|
-
async sendDetached(request
|
|
763
|
-
|
|
954
|
+
async sendDetached(request,
|
|
955
|
+
/** Called once the request's bytes are on the socket. */
|
|
956
|
+
written) {
|
|
957
|
+
return this.dispatch(request, { ...request.headers }, written);
|
|
764
958
|
}
|
|
765
|
-
|
|
959
|
+
/**
|
|
960
|
+
* The node request a logoff goes out on — the seam where its write is seen.
|
|
961
|
+
*
|
|
962
|
+
* A test replaces it to hold a request's socket shut; the wire uses node's
|
|
963
|
+
* own `http` / `https`, as axios would with redirects off. The logoff's
|
|
964
|
+
* answer is not read, so not following a redirect changes nothing.
|
|
965
|
+
*/
|
|
966
|
+
logoffRequest(options, onResponse) {
|
|
967
|
+
return options.protocol === 'https:'
|
|
968
|
+
? (0, node_https_1.request)(options, onResponse)
|
|
969
|
+
: (0, node_http_1.request)(options, onResponse);
|
|
970
|
+
}
|
|
971
|
+
async dispatch(request, headers, written,
|
|
972
|
+
/** `maxRedirects: 0` for the adoption probe alone; see `resume()`. */
|
|
973
|
+
redirects) {
|
|
766
974
|
const response = await this.client()({
|
|
975
|
+
...(redirects ?? {}),
|
|
976
|
+
// The write is the point `disconnect()` resolves at: the request's
|
|
977
|
+
// `finish`, emitted once its bytes are handed to the socket — not when
|
|
978
|
+
// the server answers, which it may do minutes later or never.
|
|
979
|
+
...(written !== undefined
|
|
980
|
+
? {
|
|
981
|
+
transport: {
|
|
982
|
+
request: (options, onResponse) => {
|
|
983
|
+
// A socket of its own: with no agent of the wire's (plain
|
|
984
|
+
// `http:` — the TLS material's agent and a proxy's are kept),
|
|
985
|
+
// node would take a pooled keep-alive socket, whose write can
|
|
986
|
+
// succeed after the server closed it, losing the logoff after
|
|
987
|
+
// `finish`. `agent: false` opens a fresh connection, and node
|
|
988
|
+
// sends `Connection: close` on it. Over `https:` the wire's
|
|
989
|
+
// own agent keeps no socket alive unless the caller's
|
|
990
|
+
// `agentOptions` say `keepAlive: true`.
|
|
991
|
+
const outgoing = this.logoffRequest(options.agent === undefined
|
|
992
|
+
? { ...options, agent: false }
|
|
993
|
+
: options, onResponse);
|
|
994
|
+
outgoing.once('finish', written);
|
|
995
|
+
return outgoing;
|
|
996
|
+
},
|
|
997
|
+
},
|
|
998
|
+
}
|
|
999
|
+
: {}),
|
|
767
1000
|
method: request.method,
|
|
768
1001
|
// The connection hands over a PATH; putting a server in front of it is
|
|
769
1002
|
// this wire's job. RFC's is to write the same path into the request line
|
|
@@ -30,7 +30,12 @@ export interface IAdtTransportRequest {
|
|
|
30
30
|
* its query — silently, and only on one of the two wires.
|
|
31
31
|
*/
|
|
32
32
|
params?: Record<string, unknown>;
|
|
33
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Milliseconds: the caller's own deadline, and the only one a request
|
|
35
|
+
* carries. Absent means none — no wire sets one of its own, because a
|
|
36
|
+
* client deadline closes the socket and SAP then ends the request running
|
|
37
|
+
* on it, a write in it lost.
|
|
38
|
+
*/
|
|
34
39
|
timeout?: number;
|
|
35
40
|
/**
|
|
36
41
|
* Which statuses resolve rather than throw. Absent means the default: 2xx
|
|
@@ -50,14 +55,6 @@ export interface IAdtTransportRequest {
|
|
|
50
55
|
* `HttpTransport.dress`.
|
|
51
56
|
*/
|
|
52
57
|
stateful?: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* The caller's signal, for the waits a wire makes on this request's behalf
|
|
55
|
-
* before it sends — over RFC, the logon and the open of a conversation of
|
|
56
|
-
* its own. An abort ends such a wait for this request only; whatever it
|
|
57
|
-
* opened for this request alone is given back. Not a cancel: a request
|
|
58
|
-
* already sent is not recalled, so no wire hands it to its client.
|
|
59
|
-
*/
|
|
60
|
-
signal?: AbortSignal | undefined;
|
|
61
58
|
}
|
|
62
59
|
/** What came back, in the terms every transport can produce. */
|
|
63
60
|
export interface IAdtTransportResponse {
|
|
@@ -118,8 +115,6 @@ export interface IAdtEstablishContext extends IAdtSessionContext {
|
|
|
118
115
|
retries?: number;
|
|
119
116
|
/** Milliseconds between attempts. Absent means the transport's own default. */
|
|
120
117
|
retryDelayMs?: number;
|
|
121
|
-
/** Milliseconds per attempt. Absent means the transport's own default. */
|
|
122
|
-
timeoutMs?: number;
|
|
123
118
|
/**
|
|
124
119
|
* Which failures must not be retried.
|
|
125
120
|
*
|
|
@@ -129,16 +124,6 @@ export interface IAdtEstablishContext extends IAdtSessionContext {
|
|
|
129
124
|
* apart, so it asks.
|
|
130
125
|
*/
|
|
131
126
|
isFatal?: (error: unknown) => boolean;
|
|
132
|
-
/**
|
|
133
|
-
* The signal of the one request this exchange is made for — its upfront
|
|
134
|
-
* token fetch, its CSRF recovery. Absent for `connect()`'s establishment,
|
|
135
|
-
* which is nobody's single request. A wire checks it immediately before
|
|
136
|
-
* each send of the exchange, in the same turn, and sends nothing once it
|
|
137
|
-
* has fired: the answer to an earlier `authorize` leaves turns in between.
|
|
138
|
-
* The exchange is that request's alone — no other request waits on it —
|
|
139
|
-
* so stopping it takes nothing from another caller.
|
|
140
|
-
*/
|
|
141
|
-
signal?: AbortSignal | undefined;
|
|
142
127
|
}
|
|
143
128
|
export interface IAdtTransport {
|
|
144
129
|
/** For logs, so which transport ran is never inferred from behaviour. */
|
|
@@ -168,8 +153,19 @@ export interface IAdtTransport {
|
|
|
168
153
|
* `disconnect()`, which promises to settle. What it does is the wire's: a
|
|
169
154
|
* the logoff the cloud session document links to, the platform's logoff, or
|
|
170
155
|
* closing the conversation.
|
|
156
|
+
*
|
|
157
|
+
* **Two points, told apart.** `written` is called once the goodbye has left
|
|
158
|
+
* — its bytes handed to the socket, not answered — and the returned promise
|
|
159
|
+
* settles when the close is over, answer included. `disconnect()` resolves
|
|
160
|
+
* at the first: SAP queues a logoff behind a request still running in the
|
|
161
|
+
* same stateful ABAP session and answers it only after, yet the ENQUEUE
|
|
162
|
+
* locks go once it arrives (measured on an on-premise system, 2026-10-12 and 2026-10-13), so
|
|
163
|
+
* a caller about to
|
|
164
|
+
* exit needs it sent, not answered. A wire that sends nothing, or whose
|
|
165
|
+
* close is over at once (RFC: when the close call has returned), need not
|
|
166
|
+
* call it: a settled close is past the write.
|
|
171
167
|
*/
|
|
172
|
-
close(context: IAdtSessionContext): Promise<void>;
|
|
168
|
+
close(context: IAdtSessionContext, written?: () => void): Promise<void>;
|
|
173
169
|
/**
|
|
174
170
|
* Issue one request.
|
|
175
171
|
*
|
|
@@ -192,6 +188,34 @@ export interface IAdtTransport {
|
|
|
192
188
|
ingest(headers?: Record<string, unknown>): void;
|
|
193
189
|
/** What to put on the `Cookie` header, or `null` for a wire that has none. */
|
|
194
190
|
cookies(): string | null;
|
|
191
|
+
/**
|
|
192
|
+
* Take over a session that already exists, instead of logging on.
|
|
193
|
+
*
|
|
194
|
+
* `session` is what `sessionCookies()` handed out for it. The wire seeds its
|
|
195
|
+
* jar with those cookies and makes ONE request in that session **without
|
|
196
|
+
* the credential**, earning its CSRF token: a dead session must not quietly
|
|
197
|
+
* become a new one, and a credential on the request would open one (a dead
|
|
198
|
+
* cookie with a good password gets a new `SAP_SESSIONID`, measured). The
|
|
199
|
+
* credential's logon (`context.logon`) is offered only once the session has
|
|
200
|
+
* answered, so what it brings rides on the requests that follow, never on
|
|
201
|
+
* this one.
|
|
202
|
+
*
|
|
203
|
+
* Resolves when SAP answered as that session — a CSRF token, and the
|
|
204
|
+
* `SAP_SESSIONID` it was handed, unchanged. Rejects otherwise with SAP's
|
|
205
|
+
* answer as it is: a `401`, or an error carrying the `response` that did not
|
|
206
|
+
* belong to the session. Nothing is logged off either way: the wire opened
|
|
207
|
+
* nothing.
|
|
208
|
+
*
|
|
209
|
+
* A wire whose session is not something a cookie names — RFC, where it is a
|
|
210
|
+
* conversation — rejects without sending anything.
|
|
211
|
+
*/
|
|
212
|
+
resume(context: IAdtSessionContext, session: string): Promise<void>;
|
|
213
|
+
/**
|
|
214
|
+
* The cookies of the session this wire is on, as `resume()` takes them, or
|
|
215
|
+
* `null` while it is on none (or on a wire whose session no cookie names).
|
|
216
|
+
* For the caller to keep; never logged.
|
|
217
|
+
*/
|
|
218
|
+
sessionCookies(): string | null;
|
|
195
219
|
/**
|
|
196
220
|
* Which session this wire is on, as something comparable.
|
|
197
221
|
*
|
|
@@ -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,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC
|
|
1
|
+
{"version":3,"file":"IAdtTransport.d.ts","sourceRoot":"","sources":["../../src/connection/IAdtTransport.ts"],"names":[],"mappings":"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"}
|
|
@@ -16,22 +16,11 @@
|
|
|
16
16
|
* first to see whether it answers.
|
|
17
17
|
*/
|
|
18
18
|
import { HttpTransport } from './HttpTransport.js';
|
|
19
|
-
import type {
|
|
19
|
+
import type { IAdtSessionContext, IOnPremTransport } from './IAdtTransport.js';
|
|
20
20
|
export declare class OnPremHttpTransport extends HttpTransport implements IOnPremTransport {
|
|
21
21
|
readonly kind: string;
|
|
22
22
|
/** Which system this wire is for. Read by the compiler, never at runtime. */
|
|
23
23
|
readonly system: "onprem";
|
|
24
|
-
/**
|
|
25
|
-
* Whether an establishment actually succeeded.
|
|
26
|
-
*
|
|
27
|
-
* Cookies alone cannot answer it: a 401 that refuses us can carry a
|
|
28
|
-
* `Set-Cookie`, and that is debris, not a session. Telling the server we are
|
|
29
|
-
* finished with something we never had sends a request nobody asked for —
|
|
30
|
-
* into the middle of an authentication exchange, in the case that found this.
|
|
31
|
-
*/
|
|
32
|
-
private established;
|
|
33
|
-
establish(context: IAdtEstablishContext): Promise<void>;
|
|
34
|
-
forgetSession(): void;
|
|
35
24
|
/**
|
|
36
25
|
* Nothing to ask for: the session comes with the establishing request.
|
|
37
26
|
*
|
|
@@ -40,6 +29,6 @@ export declare class OnPremHttpTransport extends HttpTransport implements IOnPre
|
|
|
40
29
|
* only ever read by the connection to decide whether to send a close — a
|
|
41
30
|
* decision that is now this class's, below.
|
|
42
31
|
*/
|
|
43
|
-
close(context: IAdtSessionContext): Promise<void>;
|
|
32
|
+
close(context: IAdtSessionContext, written?: () => void): Promise<void>;
|
|
44
33
|
}
|
|
45
34
|
//# sourceMappingURL=OnPremHttpTransport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OnPremHttpTransport.d.ts","sourceRoot":"","sources":["../../src/connection/OnPremHttpTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"OnPremHttpTransport.d.ts","sourceRoot":"","sources":["../../src/connection/OnPremHttpTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE/E,qBAAa,mBACX,SAAQ,aACR,YAAW,gBAAgB;IAE3B,SAAkB,IAAI,EAAE,MAAM,CAAiB;IAE/C,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAG,QAAQ,CAAU;IAEpC;;;;;;;OAOG;IAEY,KAAK,CAClB,OAAO,EAAE,kBAAkB,EAC3B,OAAO,CAAC,EAAE,MAAM,IAAI,GACnB,OAAO,CAAC,IAAI,CAAC;CA0BjB"}
|
|
@@ -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;
|