@mcp-abap-adt/connection 15.0.1 → 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 +187 -1
- package/README.md +68 -9
- package/dist/connection/AbstractAbapConnection.d.ts +86 -31
- package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
- package/dist/connection/AbstractAbapConnection.js +216 -136
- 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 -15
- package/dist/connection/IAdtTransport.d.ts +12 -1
- 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/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 -29
- package/docs/USAGE.md +156 -38
- package/package.json +2 -2
|
@@ -23,6 +23,13 @@
|
|
|
23
23
|
* back to the platform logoff — an inference, and the only one left in this
|
|
24
24
|
* layer. A consumer that reaches an on-prem system with this transport has
|
|
25
25
|
* taken the wrong one, and finds out rather than being silently downgraded.
|
|
26
|
+
*
|
|
27
|
+
* **The platform logoff when no link was published.** Not an inference about
|
|
28
|
+
* the system: `/sap/public/bc/icf/logoff` ends a cloud security session too
|
|
29
|
+
* (measured on a BTP trial with bare HTTP, 2026-10-13: a preflight answered
|
|
30
|
+
* without a logoff link yet set a live `SAP_SESSIONID`; after that logoff the
|
|
31
|
+
* same cookies got `401`, before it `200`). So a held session with no link is
|
|
32
|
+
* logged off there, as the on-prem wire does.
|
|
26
33
|
*/
|
|
27
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
35
|
exports.CloudHttpTransport = void 0;
|
|
@@ -104,8 +111,8 @@ class CloudHttpTransport extends HttpTransport_js_1.HttpTransport {
|
|
|
104
111
|
this.logger?.debug(`Session resource answered ${response.status} but published no securitysession link`);
|
|
105
112
|
return;
|
|
106
113
|
}
|
|
107
|
-
// Published only while its ICF service is active; without it
|
|
108
|
-
//
|
|
114
|
+
// Published only while its ICF service is active; without it the close
|
|
115
|
+
// sends the platform's own logoff instead.
|
|
109
116
|
this.logoff = this.resolveLink(this.linkHref(response.data, LOGOFF_REL), `${context.baseUrl}${SESSIONS_PATH}`);
|
|
110
117
|
this.logger?.debug(`Security session opened: ${resource}`);
|
|
111
118
|
}
|
|
@@ -120,27 +127,33 @@ class CloudHttpTransport extends HttpTransport_js_1.HttpTransport {
|
|
|
120
127
|
this.logger?.debug(`Could not open a security session: ${error instanceof Error ? error.message : String(error)}`);
|
|
121
128
|
}
|
|
122
129
|
}
|
|
123
|
-
async close(context) {
|
|
130
|
+
async close(context, written) {
|
|
124
131
|
const logoff = this.logoff;
|
|
125
132
|
this.logoff = null;
|
|
126
|
-
// Read SYNCHRONOUSLY, before the first await.
|
|
127
|
-
//
|
|
128
|
-
//
|
|
129
|
-
//
|
|
130
|
-
|
|
133
|
+
// Read SYNCHRONOUSLY, before the first await. The teardown's
|
|
134
|
+
// `forgetSession()` runs as soon as the close is dispatched — the
|
|
135
|
+
// connection waits for its write only after the transition — so a
|
|
136
|
+
// goodbye assembled after an await would carry no cookie, which is the
|
|
137
|
+
// one thing that proves the session is ours to end.
|
|
138
|
+
// Without `sap-contextid`: see `logoffCookies()`.
|
|
139
|
+
const cookies = this.logoffCookies();
|
|
131
140
|
// Snapshotted for the same reason: the logoff must reach the server holding
|
|
132
141
|
// this session, not whichever one the wire is pinned to when it goes out.
|
|
133
142
|
const affinity = this.affinityHeaders();
|
|
134
143
|
const session = this.sessionHeaders();
|
|
135
|
-
if (!cookies) {
|
|
136
|
-
//
|
|
137
|
-
//
|
|
144
|
+
if (!cookies || !this.holdsSessionCookie()) {
|
|
145
|
+
// The same rule as on-prem: a logoff only for a non-empty
|
|
146
|
+
// `SAP_SESSIONID_*` this wire received — here the security session the
|
|
147
|
+
// preflight created. Holding that cookie is the whole permission to end
|
|
148
|
+
// one, and without it the ICF logoff ends nothing.
|
|
138
149
|
return;
|
|
139
150
|
}
|
|
140
151
|
if (!logoff) {
|
|
141
|
-
// A session
|
|
142
|
-
//
|
|
143
|
-
|
|
152
|
+
// A session is held, but the server linked no logoff resource (a
|
|
153
|
+
// preflight that published none, or failed): the platform's own logoff
|
|
154
|
+
// ends it, sent exactly as the on-prem wire sends it.
|
|
155
|
+
this.logger?.debug('The server published no logoff resource; sending the platform logoff');
|
|
156
|
+
await this.sendIcfLogoff(context, { cookies, affinity }, written);
|
|
144
157
|
return;
|
|
145
158
|
}
|
|
146
159
|
await this.sendLogoff(context, logoff, {
|
|
@@ -149,7 +162,7 @@ class CloudHttpTransport extends HttpTransport_js_1.HttpTransport {
|
|
|
149
162
|
// `x-sap-security-session: use`, as Eclipse sends it on the logoff: it
|
|
150
163
|
// names the session the logoff ends, like every other request here.
|
|
151
164
|
session,
|
|
152
|
-
});
|
|
165
|
+
}, written);
|
|
153
166
|
}
|
|
154
167
|
/**
|
|
155
168
|
* An href resolved against the document that published it, as a link in an
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* not the credential). Material that changes between logons drops the client;
|
|
19
19
|
* the cookie jar and the CSRF token are the session's and stay.
|
|
20
20
|
*/
|
|
21
|
+
import { type ClientRequest, type IncomingMessage, type RequestOptions } from 'node:http';
|
|
21
22
|
import { type AgentOptions } from 'node:https';
|
|
22
23
|
import type { ILogonTarget } from '@mcp-abap-adt/interfaces-auth';
|
|
23
24
|
import type { ILogger } from '../logger.js';
|
|
@@ -93,6 +94,34 @@ export declare class HttpTransport implements IAdtTransport {
|
|
|
93
94
|
* replacement every time the client was re-asserted.
|
|
94
95
|
*/
|
|
95
96
|
sessionFingerprint(): Map<string, string>;
|
|
97
|
+
/**
|
|
98
|
+
* The cookies a logoff carries: the jar without `sap-contextid`.
|
|
99
|
+
*
|
|
100
|
+
* The logoff ends the HTTP security session `SAP_SESSIONID` names, and with
|
|
101
|
+
* it every ABAP context of that session. Measured on an on-premise system with bare HTTP
|
|
102
|
+
* (2026-10-13): a LOCK held in a stateful context, then a logoff carrying
|
|
103
|
+
* `SAP_SESSIONID_ABC_001` and `sap-usercontext` but no `sap-contextid` →
|
|
104
|
+
* 200, `SAP_SESSIONID` deleted, and an independent session then got the
|
|
105
|
+
* LOCK: the context ended and the lock was released. A logoff that carried a
|
|
106
|
+
* stale (deleted) `sap-contextid` got 400 and closed nothing. So the
|
|
107
|
+
* context cookie never rides on a logoff.
|
|
108
|
+
*/
|
|
109
|
+
protected logoffCookies(): string | null;
|
|
110
|
+
/**
|
|
111
|
+
* Whether this wire holds a non-empty `SAP_SESSIONID_*` cookie it received —
|
|
112
|
+
* the one condition under which a logoff is sent.
|
|
113
|
+
*
|
|
114
|
+
* Read from the jar, never from `sessionEstablished()`, which a wire may
|
|
115
|
+
* answer otherwise (BASIS 7.40 says yes with no such cookie). The evidence,
|
|
116
|
+
* on an on-premise system (ABAP code and measurement): `CL_HTTP_SERVER_NET->send_response`
|
|
117
|
+
* sets `SAP_SESSIONID_<SID>_<CLIENT>` only when that request created a
|
|
118
|
+
* security session (`m_security_session_created`), whatever the status — a
|
|
119
|
+
* 404 or 403 after logon carried it and the session was alive; and the ICF
|
|
120
|
+
* logoff ends a session only when that cookie is present. So a logoff
|
|
121
|
+
* without it ends nothing, and one with it is owed whatever the status that
|
|
122
|
+
* brought it.
|
|
123
|
+
*/
|
|
124
|
+
protected holdsSessionCookie(): boolean;
|
|
96
125
|
/**
|
|
97
126
|
* A session exists when the server named one.
|
|
98
127
|
*
|
|
@@ -223,7 +252,20 @@ export declare class HttpTransport implements IAdtTransport {
|
|
|
223
252
|
* session document links to, the on-prem one the platform logoff. A bare HTTP wire has
|
|
224
253
|
* neither, and says so by doing nothing.
|
|
225
254
|
*/
|
|
226
|
-
close(_context: IAdtSessionContext): Promise<void>;
|
|
255
|
+
close(_context: IAdtSessionContext, _written?: () => void): Promise<void>;
|
|
256
|
+
/**
|
|
257
|
+
* The platform's own logoff, `/sap/public/bc/icf/logoff`: the session's
|
|
258
|
+
* cookies (taken by the caller before its first await, without
|
|
259
|
+
* `sap-contextid`), no session headers, its write reported through
|
|
260
|
+
* `written`. On-prem it is the only goodbye; on cloud it is the goodbye when
|
|
261
|
+
* the server linked no logoff resource of its own — it ends a cloud security
|
|
262
|
+
* session too (measured on a BTP trial with bare HTTP, 2026-10-13: the same
|
|
263
|
+
* cookies were refused with 401 right after it, accepted before).
|
|
264
|
+
*/
|
|
265
|
+
protected sendIcfLogoff(context: IAdtSessionContext, snapshot: {
|
|
266
|
+
cookies: string;
|
|
267
|
+
affinity: Record<string, string>;
|
|
268
|
+
}, written?: () => void): Promise<void>;
|
|
227
269
|
/**
|
|
228
270
|
* The logoff, sent as Eclipse ADT 3.60.3 sends it when a project is closed.
|
|
229
271
|
*
|
|
@@ -243,7 +285,9 @@ export declare class HttpTransport implements IAdtTransport {
|
|
|
243
285
|
cookies: string;
|
|
244
286
|
affinity: Record<string, string>;
|
|
245
287
|
session: Record<string, string>;
|
|
246
|
-
}
|
|
288
|
+
},
|
|
289
|
+
/** Called once the logoff's bytes are on the socket; see `close()`. */
|
|
290
|
+
written?: () => void): Promise<void>;
|
|
247
291
|
/**
|
|
248
292
|
* Throws for a status the request does not admit — by doing nothing, because
|
|
249
293
|
* that is already what axios does, and `AxiosError` already carries
|
|
@@ -262,9 +306,10 @@ export declare class HttpTransport implements IAdtTransport {
|
|
|
262
306
|
/**
|
|
263
307
|
* Send EXACTLY these headers, with nothing of the wire's live state mixed in.
|
|
264
308
|
*
|
|
265
|
-
* For a goodbye, and only for a goodbye. `disconnect()`
|
|
266
|
-
*
|
|
267
|
-
* connection is already free to `connect()`
|
|
309
|
+
* For a goodbye, and only for a goodbye. `disconnect()` releases the
|
|
310
|
+
* transition queue before the logoff is even written, so the request is
|
|
311
|
+
* still being assembled while the connection is already free to `connect()`
|
|
312
|
+
* again — and by the time it goes
|
|
268
313
|
* out, the jar can hold a different session. Dressing it then merges the LIVE
|
|
269
314
|
* `SAP_SESSIONID` over the snapshot, and `mergeCookieHeaders` lets the later
|
|
270
315
|
* value win on a repeated name, so the goodbye for the old session arrives
|
|
@@ -273,7 +318,17 @@ export declare class HttpTransport implements IAdtTransport {
|
|
|
273
318
|
* Reading the cookies synchronously is necessary and was not sufficient: the
|
|
274
319
|
* snapshot survived only until the send path put the jar back on top of it.
|
|
275
320
|
*/
|
|
276
|
-
protected sendDetached(request: IAdtTransportRequest
|
|
321
|
+
protected sendDetached(request: IAdtTransportRequest,
|
|
322
|
+
/** Called once the request's bytes are on the socket. */
|
|
323
|
+
written?: () => void): Promise<IAdtTransportResponse>;
|
|
324
|
+
/**
|
|
325
|
+
* The node request a logoff goes out on — the seam where its write is seen.
|
|
326
|
+
*
|
|
327
|
+
* A test replaces it to hold a request's socket shut; the wire uses node's
|
|
328
|
+
* own `http` / `https`, as axios would with redirects off. The logoff's
|
|
329
|
+
* answer is not read, so not following a redirect changes nothing.
|
|
330
|
+
*/
|
|
331
|
+
protected logoffRequest(options: RequestOptions, onResponse: (response: IncomingMessage) => void): ClientRequest;
|
|
277
332
|
private dispatch;
|
|
278
333
|
}
|
|
279
334
|
//# sourceMappingURL=HttpTransport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpTransport.d.ts","sourceRoot":"","sources":["../../src/connection/HttpTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;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AE,MAAM,IAAI,GACnB,OAAO,CAAC,qBAAqB,CAAC;IAIjC;;;;;;OAMG;IACH,SAAS,CAAC,aAAa,CACrB,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,GAC9C,aAAa;YAMF,QAAQ;CA2DvB"}
|
|
@@ -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"));
|
|
@@ -33,8 +34,34 @@ 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
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
|
+
}
|
|
36
61
|
/** The cookie that names a stateful ABAP context. */
|
|
37
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';
|
|
38
65
|
/**
|
|
39
66
|
* A `Cookie` header without `sap-contextid`, for a request that is not stateful.
|
|
40
67
|
*
|
|
@@ -192,13 +219,22 @@ class HttpTransport {
|
|
|
192
219
|
for (const entry of Array.isArray(setCookie) ? setCookie : [setCookie]) {
|
|
193
220
|
if (typeof entry !== 'string')
|
|
194
221
|
continue;
|
|
195
|
-
const [nameValue] = entry.split(';');
|
|
222
|
+
const [nameValue, ...attributes] = entry.split(';');
|
|
196
223
|
if (!nameValue)
|
|
197
224
|
continue;
|
|
198
225
|
const [name, ...rest] = nameValue.split('=');
|
|
199
226
|
const trimmed = name?.trim();
|
|
200
227
|
if (!trimmed)
|
|
201
228
|
continue;
|
|
229
|
+
// A deletion removes the cookie, and is told by its expiry, not its
|
|
230
|
+
// value: SAP's logoff deletes every cookie with a one-character value
|
|
231
|
+
// and `expires=Tue, 01-Jan-1980 00:00:01 GMT` (on-premise, 2026-10-13). Kept,
|
|
232
|
+
// a deleted `SAP_SESSIONID` would read as a session the server has
|
|
233
|
+
// just ended.
|
|
234
|
+
if (deletesCookie(attributes)) {
|
|
235
|
+
this.jar.delete(trimmed);
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
202
238
|
this.jar.set(trimmed, rest.join('=').trim());
|
|
203
239
|
}
|
|
204
240
|
// SAP answers `sap-usercontext` with the system default rather than the
|
|
@@ -208,13 +244,11 @@ class HttpTransport {
|
|
|
208
244
|
if (this.options.client) {
|
|
209
245
|
this.jar.set('sap-usercontext', `sap-client=${this.options.client}`);
|
|
210
246
|
}
|
|
211
|
-
|
|
212
|
-
return;
|
|
247
|
+
// Recomputed from what the jar holds now, deletions included.
|
|
213
248
|
const combined = Array.from(this.jar.entries())
|
|
214
249
|
.map(([name, value]) => (value ? `${name}=${value}` : name))
|
|
215
250
|
.join('; ');
|
|
216
|
-
|
|
217
|
-
this.combined = combined;
|
|
251
|
+
this.combined = combined || null;
|
|
218
252
|
}
|
|
219
253
|
/** What to put on the `Cookie` header, or nothing if the jar is empty. */
|
|
220
254
|
cookies() {
|
|
@@ -230,11 +264,48 @@ class HttpTransport {
|
|
|
230
264
|
sessionFingerprint() {
|
|
231
265
|
const fingerprint = new Map();
|
|
232
266
|
for (const [name, value] of this.jar) {
|
|
233
|
-
|
|
267
|
+
// Non-empty only: an empty value names no session.
|
|
268
|
+
if (name.startsWith('SAP_SESSIONID') && value !== '') {
|
|
234
269
|
fingerprint.set(name, value);
|
|
270
|
+
}
|
|
235
271
|
}
|
|
236
272
|
return fingerprint;
|
|
237
273
|
}
|
|
274
|
+
/**
|
|
275
|
+
* The cookies a logoff carries: the jar without `sap-contextid`.
|
|
276
|
+
*
|
|
277
|
+
* The logoff ends the HTTP security session `SAP_SESSIONID` names, and with
|
|
278
|
+
* it every ABAP context of that session. Measured on an on-premise system with bare HTTP
|
|
279
|
+
* (2026-10-13): a LOCK held in a stateful context, then a logoff carrying
|
|
280
|
+
* `SAP_SESSIONID_ABC_001` and `sap-usercontext` but no `sap-contextid` →
|
|
281
|
+
* 200, `SAP_SESSIONID` deleted, and an independent session then got the
|
|
282
|
+
* LOCK: the context ended and the lock was released. A logoff that carried a
|
|
283
|
+
* stale (deleted) `sap-contextid` got 400 and closed nothing. So the
|
|
284
|
+
* context cookie never rides on a logoff.
|
|
285
|
+
*/
|
|
286
|
+
logoffCookies() {
|
|
287
|
+
const pairs = Array.from(this.jar.entries())
|
|
288
|
+
.filter(([name]) => name !== CONTEXT_COOKIE)
|
|
289
|
+
.map(([name, value]) => (value ? `${name}=${value}` : name));
|
|
290
|
+
return pairs.length > 0 ? pairs.join('; ') : null;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Whether this wire holds a non-empty `SAP_SESSIONID_*` cookie it received —
|
|
294
|
+
* the one condition under which a logoff is sent.
|
|
295
|
+
*
|
|
296
|
+
* Read from the jar, never from `sessionEstablished()`, which a wire may
|
|
297
|
+
* answer otherwise (BASIS 7.40 says yes with no such cookie). The evidence,
|
|
298
|
+
* on an on-premise system (ABAP code and measurement): `CL_HTTP_SERVER_NET->send_response`
|
|
299
|
+
* sets `SAP_SESSIONID_<SID>_<CLIENT>` only when that request created a
|
|
300
|
+
* security session (`m_security_session_created`), whatever the status — a
|
|
301
|
+
* 404 or 403 after logon carried it and the session was alive; and the ICF
|
|
302
|
+
* logoff ends a session only when that cookie is present. So a logoff
|
|
303
|
+
* without it ends nothing, and one with it is owed whatever the status that
|
|
304
|
+
* brought it.
|
|
305
|
+
*/
|
|
306
|
+
holdsSessionCookie() {
|
|
307
|
+
return this.sessionFingerprint().size > 0;
|
|
308
|
+
}
|
|
238
309
|
/**
|
|
239
310
|
* A session exists when the server named one.
|
|
240
311
|
*
|
|
@@ -661,7 +732,19 @@ class HttpTransport {
|
|
|
661
732
|
* session document links to, the on-prem one the platform logoff. A bare HTTP wire has
|
|
662
733
|
* neither, and says so by doing nothing.
|
|
663
734
|
*/
|
|
664
|
-
async close(_context) { }
|
|
735
|
+
async close(_context, _written) { }
|
|
736
|
+
/**
|
|
737
|
+
* The platform's own logoff, `/sap/public/bc/icf/logoff`: the session's
|
|
738
|
+
* cookies (taken by the caller before its first await, without
|
|
739
|
+
* `sap-contextid`), no session headers, its write reported through
|
|
740
|
+
* `written`. On-prem it is the only goodbye; on cloud it is the goodbye when
|
|
741
|
+
* the server linked no logoff resource of its own — it ends a cloud security
|
|
742
|
+
* session too (measured on a BTP trial with bare HTTP, 2026-10-13: the same
|
|
743
|
+
* cookies were refused with 401 right after it, accepted before).
|
|
744
|
+
*/
|
|
745
|
+
async sendIcfLogoff(context, snapshot, written) {
|
|
746
|
+
await this.sendLogoff(context, `${context.baseUrl}${ICF_LOGOFF_PATH}`, { ...snapshot, session: {} }, written);
|
|
747
|
+
}
|
|
665
748
|
/**
|
|
666
749
|
* The logoff, sent as Eclipse ADT 3.60.3 sends it when a project is closed.
|
|
667
750
|
*
|
|
@@ -677,13 +760,20 @@ class HttpTransport {
|
|
|
677
760
|
* about THIS session; and when the logoff cannot end one, the reason is an
|
|
678
761
|
* error message whose status the ICF kernel picks, which no ABAP source shows.
|
|
679
762
|
*/
|
|
680
|
-
async sendLogoff(context, url, snapshot
|
|
763
|
+
async sendLogoff(context, url, snapshot,
|
|
764
|
+
/** Called once the logoff's bytes are on the socket; see `close()`. */
|
|
765
|
+
written) {
|
|
681
766
|
// Nothing that logs on, whoever put it in the context: the goodbye carries
|
|
682
767
|
// the session's cookie and no credential.
|
|
683
768
|
const extra = Object.fromEntries(Object.entries(context.extraHeaders ?? {}).filter(([name]) => name.trim().toLowerCase() !== 'authorization'));
|
|
684
769
|
try {
|
|
685
770
|
await this.sendDetached({
|
|
686
771
|
method: 'GET',
|
|
772
|
+
// A redirect is an answer like any other: the logoff has arrived,
|
|
773
|
+
// and its answer is not read. Not followed — that would send the
|
|
774
|
+
// session's cookie on to wherever the server points — and not
|
|
775
|
+
// reported as a failure to say goodbye.
|
|
776
|
+
validateStatus: (status) => status >= 200 && status < 400,
|
|
687
777
|
url,
|
|
688
778
|
headers: {
|
|
689
779
|
...snapshot.affinity,
|
|
@@ -697,7 +787,7 @@ class HttpTransport {
|
|
|
697
787
|
'sap-cancel-on-close': 'true',
|
|
698
788
|
Cookie: snapshot.cookies,
|
|
699
789
|
},
|
|
700
|
-
});
|
|
790
|
+
}, written);
|
|
701
791
|
this.logger?.debug('Told the server the session is finished');
|
|
702
792
|
}
|
|
703
793
|
catch (error) {
|
|
@@ -742,9 +832,10 @@ class HttpTransport {
|
|
|
742
832
|
/**
|
|
743
833
|
* Send EXACTLY these headers, with nothing of the wire's live state mixed in.
|
|
744
834
|
*
|
|
745
|
-
* For a goodbye, and only for a goodbye. `disconnect()`
|
|
746
|
-
*
|
|
747
|
-
* connection is already free to `connect()`
|
|
835
|
+
* For a goodbye, and only for a goodbye. `disconnect()` releases the
|
|
836
|
+
* transition queue before the logoff is even written, so the request is
|
|
837
|
+
* still being assembled while the connection is already free to `connect()`
|
|
838
|
+
* again — and by the time it goes
|
|
748
839
|
* out, the jar can hold a different session. Dressing it then merges the LIVE
|
|
749
840
|
* `SAP_SESSIONID` over the snapshot, and `mergeCookieHeaders` lets the later
|
|
750
841
|
* value win on a repeated name, so the goodbye for the old session arrives
|
|
@@ -753,11 +844,49 @@ class HttpTransport {
|
|
|
753
844
|
* Reading the cookies synchronously is necessary and was not sufficient: the
|
|
754
845
|
* snapshot survived only until the send path put the jar back on top of it.
|
|
755
846
|
*/
|
|
756
|
-
async sendDetached(request
|
|
757
|
-
|
|
847
|
+
async sendDetached(request,
|
|
848
|
+
/** Called once the request's bytes are on the socket. */
|
|
849
|
+
written) {
|
|
850
|
+
return this.dispatch(request, { ...request.headers }, written);
|
|
758
851
|
}
|
|
759
|
-
|
|
852
|
+
/**
|
|
853
|
+
* The node request a logoff goes out on — the seam where its write is seen.
|
|
854
|
+
*
|
|
855
|
+
* A test replaces it to hold a request's socket shut; the wire uses node's
|
|
856
|
+
* own `http` / `https`, as axios would with redirects off. The logoff's
|
|
857
|
+
* answer is not read, so not following a redirect changes nothing.
|
|
858
|
+
*/
|
|
859
|
+
logoffRequest(options, onResponse) {
|
|
860
|
+
return options.protocol === 'https:'
|
|
861
|
+
? (0, node_https_1.request)(options, onResponse)
|
|
862
|
+
: (0, node_http_1.request)(options, onResponse);
|
|
863
|
+
}
|
|
864
|
+
async dispatch(request, headers, written) {
|
|
760
865
|
const response = await this.client()({
|
|
866
|
+
// The write is the point `disconnect()` resolves at: the request's
|
|
867
|
+
// `finish`, emitted once its bytes are handed to the socket — not when
|
|
868
|
+
// the server answers, which it may do minutes later or never.
|
|
869
|
+
...(written !== undefined
|
|
870
|
+
? {
|
|
871
|
+
transport: {
|
|
872
|
+
request: (options, onResponse) => {
|
|
873
|
+
// A socket of its own: with no agent of the wire's (plain
|
|
874
|
+
// `http:` — the TLS material's agent and a proxy's are kept),
|
|
875
|
+
// node would take a pooled keep-alive socket, whose write can
|
|
876
|
+
// succeed after the server closed it, losing the logoff after
|
|
877
|
+
// `finish`. `agent: false` opens a fresh connection, and node
|
|
878
|
+
// sends `Connection: close` on it. Over `https:` the wire's
|
|
879
|
+
// own agent keeps no socket alive unless the caller's
|
|
880
|
+
// `agentOptions` say `keepAlive: true`.
|
|
881
|
+
const outgoing = this.logoffRequest(options.agent === undefined
|
|
882
|
+
? { ...options, agent: false }
|
|
883
|
+
: options, onResponse);
|
|
884
|
+
outgoing.once('finish', written);
|
|
885
|
+
return outgoing;
|
|
886
|
+
},
|
|
887
|
+
},
|
|
888
|
+
}
|
|
889
|
+
: {}),
|
|
761
890
|
method: request.method,
|
|
762
891
|
// The connection hands over a PATH; putting a server in front of it is
|
|
763
892
|
// this wire's job. RFC's is to write the same path into the request line
|
|
@@ -150,8 +150,19 @@ export interface IAdtTransport {
|
|
|
150
150
|
* `disconnect()`, which promises to settle. What it does is the wire's: a
|
|
151
151
|
* the logoff the cloud session document links to, the platform's logoff, or
|
|
152
152
|
* closing the conversation.
|
|
153
|
+
*
|
|
154
|
+
* **Two points, told apart.** `written` is called once the goodbye has left
|
|
155
|
+
* — its bytes handed to the socket, not answered — and the returned promise
|
|
156
|
+
* settles when the close is over, answer included. `disconnect()` resolves
|
|
157
|
+
* at the first: SAP queues a logoff behind a request still running in the
|
|
158
|
+
* same stateful ABAP session and answers it only after, yet the ENQUEUE
|
|
159
|
+
* locks go once it arrives (measured on an on-premise system, 2026-10-12 and 2026-10-13), so
|
|
160
|
+
* a caller about to
|
|
161
|
+
* exit needs it sent, not answered. A wire that sends nothing, or whose
|
|
162
|
+
* close is over at once (RFC: when the close call has returned), need not
|
|
163
|
+
* call it: a settled close is past the write.
|
|
153
164
|
*/
|
|
154
|
-
close(context: IAdtSessionContext): Promise<void>;
|
|
165
|
+
close(context: IAdtSessionContext, written?: () => void): Promise<void>;
|
|
155
166
|
/**
|
|
156
167
|
* Issue one request.
|
|
157
168
|
*
|
|
@@ -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,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IAC7C;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,gEAAgE;AAChE,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;CACf;AAED,6DAA6D;AAC7D;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG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I,CAAC;CACvB;AAED;;;;;;;;;;;;GAYG;AACH;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;CAC3B;AAED,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,qBAAqB,GAAG,IAAI,CAQtE"}
|
|
@@ -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;
|