@mcp-abap-adt/connection 16.0.0 → 17.1.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 +63 -1
- package/README.md +74 -18
- package/dist/connection/AbstractAbapConnection.d.ts +67 -19
- package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
- package/dist/connection/AbstractAbapConnection.js +141 -32
- package/dist/connection/AdtCloudConnector.d.ts +6 -1
- package/dist/connection/AdtCloudConnector.d.ts.map +1 -1
- package/dist/connection/AdtCloudConnector.js +7 -2
- package/dist/connection/AdtOnPremConnector.d.ts +6 -1
- package/dist/connection/AdtOnPremConnector.d.ts.map +1 -1
- package/dist/connection/AdtOnPremConnector.js +7 -2
- package/dist/connection/CloudHttpTransport.d.ts.map +1 -1
- package/dist/connection/CloudHttpTransport.js +2 -3
- package/dist/connection/CredentialAbapConnection.d.ts +3 -1
- package/dist/connection/CredentialAbapConnection.d.ts.map +1 -1
- package/dist/connection/CredentialAbapConnection.js +4 -2
- package/dist/connection/GenericWebSocketTransport.d.ts.map +1 -1
- package/dist/connection/GenericWebSocketTransport.js +7 -4
- package/dist/connection/HttpTransport.d.ts +19 -0
- package/dist/connection/HttpTransport.d.ts.map +1 -1
- package/dist/connection/HttpTransport.js +115 -5
- package/dist/connection/IAdtTransport.d.ts +34 -3
- package/dist/connection/IAdtTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.d.ts +7 -0
- package/dist/connection/RfcTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.js +14 -3
- package/dist/connection/createConnection.d.ts +18 -0
- package/dist/connection/createConnection.d.ts.map +1 -1
- package/dist/connection/createConnection.js +8 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -5
- package/docs/INDEX.md +2 -0
- package/docs/MIGRATION-17.0.md +119 -0
- package/docs/SCOPE.md +7 -2
- package/docs/STATEFUL_SESSION_GUIDE.md +12 -11
- package/docs/USAGE.md +119 -36
- package/package.json +1 -1
- package/dist/utils/timeouts.d.ts +0 -18
- package/dist/utils/timeouts.d.ts.map +0 -1
- package/dist/utils/timeouts.js +0 -37
|
@@ -103,6 +103,27 @@ function absentEndpoint(error) {
|
|
|
103
103
|
?.response?.status;
|
|
104
104
|
return status === 404 || status === 501;
|
|
105
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
|
+
}
|
|
106
127
|
const MATERIAL_FIELDS = ['cert', 'key', 'pfx', 'passphrase'];
|
|
107
128
|
/**
|
|
108
129
|
* The material fields a provider offered, and nothing else: a key outside
|
|
@@ -254,6 +275,95 @@ class HttpTransport {
|
|
|
254
275
|
cookies() {
|
|
255
276
|
return this.combined;
|
|
256
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
|
+
}
|
|
257
367
|
/**
|
|
258
368
|
* Which ABAP session this wire is on.
|
|
259
369
|
*
|
|
@@ -404,7 +514,7 @@ class HttpTransport {
|
|
|
404
514
|
for (const [index, url] of endpoints.entries()) {
|
|
405
515
|
// The fallback exists for a system that HAS no
|
|
406
516
|
// `/sap/bc/adt/core/discovery` — BASIS < 7.52 — which the server says by
|
|
407
|
-
// answering 404 there. Trying it after a refused connection or a
|
|
517
|
+
// answering 404 there. Trying it after a refused connection or a network
|
|
408
518
|
// asks a host that is not answering to answer a different path, which
|
|
409
519
|
// doubles the wait before the caller is told what is actually wrong.
|
|
410
520
|
if (index > 0 && !absentEndpoint(last))
|
|
@@ -422,9 +532,6 @@ class HttpTransport {
|
|
|
422
532
|
...context.extraHeaders,
|
|
423
533
|
...csrfConfig_js_1.CSRF_CONFIG.REQUIRED_HEADERS,
|
|
424
534
|
},
|
|
425
|
-
...(context.timeoutMs !== undefined
|
|
426
|
-
? { timeout: context.timeoutMs }
|
|
427
|
-
: {}),
|
|
428
535
|
});
|
|
429
536
|
// Handed up BEFORE the token is read: the cookies are the session,
|
|
430
537
|
// and a fold that only happened on success would lose the session a
|
|
@@ -861,8 +968,11 @@ class HttpTransport {
|
|
|
861
968
|
? (0, node_https_1.request)(options, onResponse)
|
|
862
969
|
: (0, node_http_1.request)(options, onResponse);
|
|
863
970
|
}
|
|
864
|
-
async dispatch(request, headers, written
|
|
971
|
+
async dispatch(request, headers, written,
|
|
972
|
+
/** `maxRedirects: 0` for the adoption probe alone; see `resume()`. */
|
|
973
|
+
redirects) {
|
|
865
974
|
const response = await this.client()({
|
|
975
|
+
...(redirects ?? {}),
|
|
866
976
|
// The write is the point `disconnect()` resolves at: the request's
|
|
867
977
|
// `finish`, emitted once its bytes are handed to the socket — not when
|
|
868
978
|
// the server answers, which it may do minutes later or never.
|
|
@@ -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
|
|
@@ -110,8 +115,6 @@ export interface IAdtEstablishContext extends IAdtSessionContext {
|
|
|
110
115
|
retries?: number;
|
|
111
116
|
/** Milliseconds between attempts. Absent means the transport's own default. */
|
|
112
117
|
retryDelayMs?: number;
|
|
113
|
-
/** Milliseconds per attempt. Absent means the transport's own default. */
|
|
114
|
-
timeoutMs?: number;
|
|
115
118
|
/**
|
|
116
119
|
* Which failures must not be retried.
|
|
117
120
|
*
|
|
@@ -185,6 +188,34 @@ export interface IAdtTransport {
|
|
|
185
188
|
ingest(headers?: Record<string, unknown>): void;
|
|
186
189
|
/** What to put on the `Cookie` header, or `null` for a wire that has none. */
|
|
187
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;
|
|
188
219
|
/**
|
|
189
220
|
* Which session this wire is on, as something comparable.
|
|
190
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":"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,M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S,IAAI,MAAM,GAAG,IAAI,CAAC;IAE3B;;;;;;OAMG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IAE3C,oDAAoD;IACpD,aAAa,IAAI,IAAI,CAAC;CACvB;AAED;;;;;;;;;;;;GAYG;AACH;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;CAC3B;AAED,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,qBAAqB,GAAG,IAAI,CAQtE"}
|
|
@@ -118,6 +118,13 @@ export declare class RfcTransport implements IOnPremTransport {
|
|
|
118
118
|
ingest(): void;
|
|
119
119
|
/** None, and never any: see `ingest()`. */
|
|
120
120
|
cookies(): null;
|
|
121
|
+
/** None: the session is the conversation, which no cookie names. */
|
|
122
|
+
sessionCookies(): null;
|
|
123
|
+
/**
|
|
124
|
+
* Refused, with nothing sent: an RFC session is a conversation, opened by
|
|
125
|
+
* this process and held by it, and a conversation cannot be taken over.
|
|
126
|
+
*/
|
|
127
|
+
resume(): Promise<void>;
|
|
121
128
|
/**
|
|
122
129
|
* Nothing to establish. `open()` made the ABAP session, and there is no token
|
|
123
130
|
* to earn: this endpoint answers `x-csrf-token: fetch` with the same two
|
|
@@ -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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AAkB,IAAI,OAAO;IAI7B,kBAAkB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAQzC,2EAA2E;IAC3E,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIzC;;;;OAIG;IACH,aAAa,IAAI,IAAI;IAErB;;;;;OAKG;gBAEgB,OAAO,EAAE,CACxB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KACpC,gBAAgB,EACJ,MAAM,GAAE,OAAO,GAAG,IAAW,EAC7B,OAAO,GAAE,oBAAyB;IAGrD,oDAAoD;IACpD,OAAO,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"}
|
|
@@ -170,6 +170,17 @@ class RfcTransport {
|
|
|
170
170
|
cookies() {
|
|
171
171
|
return null;
|
|
172
172
|
}
|
|
173
|
+
/** None: the session is the conversation, which no cookie names. */
|
|
174
|
+
sessionCookies() {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Refused, with nothing sent: an RFC session is a conversation, opened by
|
|
179
|
+
* this process and held by it, and a conversation cannot be taken over.
|
|
180
|
+
*/
|
|
181
|
+
async resume() {
|
|
182
|
+
throw new TypeError('An RFC session cannot be taken over: it is a conversation, not something a cookie names. Over RFC, connect() opens a new session.');
|
|
183
|
+
}
|
|
173
184
|
/**
|
|
174
185
|
* Nothing to establish. `open()` made the ABAP session, and there is no token
|
|
175
186
|
* to earn: this endpoint answers `x-csrf-token: fetch` with the same two
|
|
@@ -488,9 +499,9 @@ class RfcTransport {
|
|
|
488
499
|
//
|
|
489
500
|
// Nor is one needed. What bounds this call is the server: a dialog step
|
|
490
501
|
// ends at `rdisp/max_wprun_time`. And a call that cannot be torn down
|
|
491
|
-
// mid-flight is precisely what the connection
|
|
492
|
-
// a critical section
|
|
493
|
-
//
|
|
502
|
+
// mid-flight is precisely what the connection keeps over HTTP, where a
|
|
503
|
+
// request inside a critical section carries no deadline at all, so an
|
|
504
|
+
// abort cannot orphan a lock handle. Here that comes free.
|
|
494
505
|
// The last point before anything leaves: nothing awaits between this
|
|
495
506
|
// check and the call, so a close() that ran at any await above stops it.
|
|
496
507
|
if (generation !== this.generation) {
|
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
* session: after its `disconnect()` (or a logoff of its own) it is spent, and
|
|
13
13
|
* a new session is a new call to this.
|
|
14
14
|
*
|
|
15
|
+
* **Or an existing session.** `session` — the cookies an earlier instance's
|
|
16
|
+
* `sessionCookies()` returned — builds the instance on that session instead:
|
|
17
|
+
* `connect()` does not log on, and SAP's answer to its one request says
|
|
18
|
+
* whether the session is alive. HTTP wires only; over RFC it is refused here.
|
|
19
|
+
*
|
|
15
20
|
* Every transport option is passed through as the caller gives it; what is
|
|
16
21
|
* not given takes the constructor's own default, nothing more.
|
|
17
22
|
*/
|
|
@@ -49,6 +54,14 @@ interface HttpWireOptions {
|
|
|
49
54
|
* the credential (its TLS material arrives at logon). Absent: none.
|
|
50
55
|
*/
|
|
51
56
|
agentOptions?: (() => AgentOptions) | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* An existing session to build the instance on, instead of logging on: the
|
|
59
|
+
* string an instance's `sessionCookies()` returned. `connect()` then sends
|
|
60
|
+
* no logon; it asks SAP, without the credential, whether that session is
|
|
61
|
+
* alive, and rejects with SAP's answer when it is not. Absent: `connect()`
|
|
62
|
+
* logs on and opens a new session.
|
|
63
|
+
*/
|
|
64
|
+
session?: string | undefined;
|
|
52
65
|
}
|
|
53
66
|
export interface CloudHttpSpec<TCredential extends IAuthProvider = IAuthProvider> extends ConnectionSpecBase<TCredential>, HttpWireOptions {
|
|
54
67
|
system: 'cloud';
|
|
@@ -64,6 +77,11 @@ export interface OnPremRfcSpec<TCredential extends IAuthProvider = IAuthProvider
|
|
|
64
77
|
transport: 'rfc';
|
|
65
78
|
/** The RFC wire's own options (`logWire`, `maxLoggedBodyChars`). */
|
|
66
79
|
rfc?: IRfcTransportOptions | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Not over RFC: its session is a conversation, which cannot be taken over.
|
|
82
|
+
* Refused at construction.
|
|
83
|
+
*/
|
|
84
|
+
session?: undefined;
|
|
67
85
|
}
|
|
68
86
|
export type ConnectionSpec<TCredential extends IAuthProvider = IAuthProvider> = CloudHttpSpec<TCredential> | OnPremHttpSpec<TCredential> | OnPremRfcSpec<TCredential>;
|
|
69
87
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createConnection.d.ts","sourceRoot":"","sources":["../../src/connection/createConnection.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"createConnection.d.ts","sourceRoot":"","sources":["../../src/connection/createConnection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;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,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC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jD,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;IACvC;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;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,CA8DhC"}
|
|
@@ -15,20 +15,25 @@ function stated(spec) {
|
|
|
15
15
|
}
|
|
16
16
|
function createConnection(spec) {
|
|
17
17
|
const { system, transport } = stated(spec);
|
|
18
|
+
// Fixed words, before anything is built.
|
|
19
|
+
if (transport === 'rfc' &&
|
|
20
|
+
spec.session !== undefined) {
|
|
21
|
+
throw new TypeError("createConnection: an RFC session cannot be taken over — it is a conversation, not something a cookie names. 'session' is for the HTTP wires; over RFC, connect() opens a new session.");
|
|
22
|
+
}
|
|
18
23
|
const logger = spec.logger ?? null;
|
|
19
24
|
const wireLogger = spec.wireLogger ?? null;
|
|
20
25
|
const address = { client: spec.config.client, baseUrl: spec.config.url };
|
|
21
26
|
if (system === 'cloud' && transport === 'http') {
|
|
22
27
|
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);
|
|
28
|
+
return new AdtCloudConnector_js_1.AdtCloudConnector(spec.config, spec.credential, new CloudHttpTransport_js_1.CloudHttpTransport(http.agentOptions, wireLogger, address), logger, spec.sessionId, http.session);
|
|
24
29
|
}
|
|
25
30
|
if (system === 'onprem' && transport === 'http') {
|
|
26
31
|
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);
|
|
32
|
+
return new AdtOnPremConnector_js_1.AdtOnPremConnector(spec.config, spec.credential, new OnPremHttpTransport_js_1.OnPremHttpTransport(http.agentOptions, wireLogger, address), logger, spec.sessionId, http.session);
|
|
28
33
|
}
|
|
29
34
|
if (system === 'onprem' && transport === 'legacy-http') {
|
|
30
35
|
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);
|
|
36
|
+
return new AdtOnPremConnector_js_1.AdtOnPremConnector(spec.config, spec.credential, new LegacyOnPremHttpTransport_js_1.LegacyOnPremHttpTransport(http.agentOptions, wireLogger, address), logger, spec.sessionId, http.session);
|
|
32
37
|
}
|
|
33
38
|
if (system === 'onprem' && transport === 'rfc') {
|
|
34
39
|
const rfc = spec;
|
package/dist/index.d.ts
CHANGED
|
@@ -16,5 +16,4 @@ export { OnPremHttpTransport } from './connection/OnPremHttpTransport.js';
|
|
|
16
16
|
export { type IRfcConversation, type IRfcTransportOptions, RfcTransport, } from './connection/RfcTransport.js';
|
|
17
17
|
export { type RfcConnectionParams, rfcConversationFrom, rfcParamsFrom, } from './connection/rfcConversation.js';
|
|
18
18
|
export type { ILogger } from './logger.js';
|
|
19
|
-
export { getTimeout, getTimeoutConfig, type TimeoutConfig, } from './utils/timeouts.js';
|
|
20
19
|
//# sourceMappingURL=index.d.ts.map
|
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;AAGxE,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,kCAAkC,CAAC;AAQ1C,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EACL,yBAAyB,EACzB,KAAK,iBAAiB,EACtB,KAAK,cAAc,GACpB,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,YAAY,EACV,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AACvC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AA2C,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,YAAY,EACV,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,YAAY,GACb,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACL,KAAK,mBAAmB,EACxB,mBAAmB,EACnB,aAAa,GACd,MAAM,iCAAiC,CAAC;AACzC,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Types - re-exported from the contract packages, under the names this
|
|
3
3
|
// package has always published them by.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.
|
|
5
|
+
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; } });
|
|
@@ -45,7 +45,3 @@ Object.defineProperty(exports, "RfcTransport", { enumerable: true, get: function
|
|
|
45
45
|
var rfcConversation_js_1 = require("./connection/rfcConversation.js");
|
|
46
46
|
Object.defineProperty(exports, "rfcConversationFrom", { enumerable: true, get: function () { return rfcConversation_js_1.rfcConversationFrom; } });
|
|
47
47
|
Object.defineProperty(exports, "rfcParamsFrom", { enumerable: true, get: function () { return rfcConversation_js_1.rfcParamsFrom; } });
|
|
48
|
-
// Timeouts
|
|
49
|
-
var timeouts_js_1 = require("./utils/timeouts.js");
|
|
50
|
-
Object.defineProperty(exports, "getTimeout", { enumerable: true, get: function () { return timeouts_js_1.getTimeout; } });
|
|
51
|
-
Object.defineProperty(exports, "getTimeoutConfig", { enumerable: true, get: function () { return timeouts_js_1.getTimeoutConfig; } });
|
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-17.0.md # no deadline of the package's own; an instance on an existing session
|
|
18
19
|
│ ├── MIGRATION-16.0.md # the request signal removed; disconnect() resolves once the logoff is written
|
|
19
20
|
│ ├── MIGRATION-15.0.md # interfaces-adt-connection 2: makeAdtRequest answers unknown
|
|
20
21
|
│ ├── MIGRATION-14.0.md # the sap-abap-auth CLI, open and commander are removed
|
|
@@ -47,6 +48,7 @@ mcp-abap-connection/
|
|
|
47
48
|
- 🧭 [Scope](./SCOPE.md) - What this package answers for, and only that
|
|
48
49
|
|
|
49
50
|
### Upgrading
|
|
51
|
+
- 🚚 [Migrating to 17.0.0](./MIGRATION-17.0.md) - `getTimeout`, `getTimeoutConfig` and `SAP_TIMEOUT_*` are gone; a request carries only the caller's `timeout`, and none inside a critical section; `createConnection({ …, session })` and `sessionCookies()`
|
|
50
52
|
- 🚚 [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
|
|
51
53
|
- 🚚 [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
|
|
52
54
|
- 🚚 [Migrating to 14.0.0](./MIGRATION-14.0.md) - the `sap-abap-auth` CLI is removed; use `@mcp-abap-adt/auth-broker-cli`
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Migration to 17.0
|
|
2
|
+
|
|
3
|
+
17.0.0 does two things that [SCOPE.md](./SCOPE.md) lists: a request carries no
|
|
4
|
+
deadline but the caller's own, and an instance can be built on an existing SAP
|
|
5
|
+
session. For a consumer on 16.x that means the following.
|
|
6
|
+
|
|
7
|
+
## No deadline of the package's own
|
|
8
|
+
|
|
9
|
+
A client deadline closes the socket, and SAP then ends the synchronous request
|
|
10
|
+
that was running on it — a write in it is lost. So nothing this package sends
|
|
11
|
+
carries a deadline it chose.
|
|
12
|
+
|
|
13
|
+
### What changed
|
|
14
|
+
|
|
15
|
+
- **`getTimeout`, `getTimeoutConfig` and the `TimeoutConfig` type are no longer
|
|
16
|
+
exported**, and nothing reads `SAP_TIMEOUT_DEFAULT`, `SAP_TIMEOUT_CSRF`,
|
|
17
|
+
`SAP_TIMEOUT_LONG` or `SAP_TIMEOUT_CRITICAL` any more. Setting them changes
|
|
18
|
+
nothing.
|
|
19
|
+
- **A request carries the `timeout` you pass, unchanged, and nothing else.**
|
|
20
|
+
The CSRF fetch (in `connect()`, before a mutation, and the one a refused
|
|
21
|
+
token triggers) and the cloud session preflight carry none; before, each was
|
|
22
|
+
bounded by `SAP_TIMEOUT_CSRF` (15 s).
|
|
23
|
+
- **Inside a critical section a request carries no deadline at all — not even
|
|
24
|
+
yours.** Before, `beginCriticalSection()` raised the request's timeout to
|
|
25
|
+
`max(yours, SAP_TIMEOUT_CRITICAL)` (600 s by default). Now the `timeout` you
|
|
26
|
+
pass is not applied while a section is active, and applies again once the
|
|
27
|
+
outermost section ends. The critical section itself is unchanged.
|
|
28
|
+
- **`GenericWebSocketTransport.connect()` sets no timer** unless you pass
|
|
29
|
+
`connectTimeoutMs`; the 15 s default is gone. A `connectTimeoutMs` you pass is
|
|
30
|
+
honoured as before.
|
|
31
|
+
- **`IAdtEstablishContext.timeoutMs` is gone** from the transport seam.
|
|
32
|
+
- `ITimeoutConfig` in `@mcp-abap-adt/interfaces-adt-connection` is unchanged;
|
|
33
|
+
this package no longer uses it.
|
|
34
|
+
|
|
35
|
+
### What you do
|
|
36
|
+
|
|
37
|
+
- Replace `timeout: getTimeout('default')` (or `'csrf'`, `'long'`) with a number
|
|
38
|
+
of your own. `IAbapRequestOptions.timeout` is still a required field of the
|
|
39
|
+
contract; `0` means none over HTTP (axios reads it so), and the RFC wire does
|
|
40
|
+
not read it at all.
|
|
41
|
+
- Drop `SAP_TIMEOUT_*` from your environment, or read them yourself if you want
|
|
42
|
+
them to keep meaning something.
|
|
43
|
+
- If you relied on `connect()` giving up after 15 s against a host that does
|
|
44
|
+
not answer: it now waits for the network to fail. A bound on it is yours to
|
|
45
|
+
set around the call.
|
|
46
|
+
|
|
47
|
+
Before:
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
import { getTimeout } from '@mcp-abap-adt/connection';
|
|
51
|
+
await connection.makeAdtRequest({ method: 'GET', url, timeout: getTimeout('default') });
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
After:
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { createConnection } from '@mcp-abap-adt/connection';
|
|
58
|
+
import type { SapConfig } from '@mcp-abap-adt/connection';
|
|
59
|
+
import { BasicAuthProvider } from '@mcp-abap-adt/auth-providers';
|
|
60
|
+
|
|
61
|
+
const system: SapConfig = {
|
|
62
|
+
url: 'https://your-sap-system.com',
|
|
63
|
+
client: '100',
|
|
64
|
+
authType: 'basic',
|
|
65
|
+
username: 'your-username',
|
|
66
|
+
password: 'your-password',
|
|
67
|
+
};
|
|
68
|
+
const connection = createConnection({
|
|
69
|
+
system: 'onprem',
|
|
70
|
+
transport: 'http',
|
|
71
|
+
config: system,
|
|
72
|
+
credential: new BasicAuthProvider(system.username!, system.password!),
|
|
73
|
+
});
|
|
74
|
+
await connection.connect();
|
|
75
|
+
// Your own deadline, or 0 for none.
|
|
76
|
+
await connection.makeAdtRequest({ method: 'GET', url: '/sap/bc/adt/discovery', timeout: 45_000 });
|
|
77
|
+
await connection.disconnect();
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## An instance on an existing session
|
|
81
|
+
|
|
82
|
+
New, and nothing changes for a consumer that does not use it.
|
|
83
|
+
|
|
84
|
+
- **`sessionCookies()`** on every connector: the cookies of the instance's SAP
|
|
85
|
+
session as one `Cookie`-header string — `SAP_SESSIONID_*`, `sap-usercontext`,
|
|
86
|
+
`sap-contextid` when a stateful request opened a context, and whatever else
|
|
87
|
+
the server set to keep the session where it lives; everything the wire holds
|
|
88
|
+
but `sap-XSRF_*`. `null` before a session, after it ended, and over RFC. It
|
|
89
|
+
acts as the user while the session lives: keep it as a secret. The package
|
|
90
|
+
never logs it.
|
|
91
|
+
- **`createConnection({ …, session })`** (and a sixth constructor argument,
|
|
92
|
+
`session`, on `AdtOnPremConnector` / `AdtCloudConnector`) builds the instance
|
|
93
|
+
on that session. `connect()` does not log on: it makes one request in that
|
|
94
|
+
session without the credential — the CSRF fetch; on cloud with
|
|
95
|
+
`x-sap-security-session: use` and no preflight — following no redirect, and
|
|
96
|
+
SAP's answer says whether the session is alive. Alive: the session is the instance's, a stateful
|
|
97
|
+
request reaches its `sap-contextid`, and `disconnect()` logs it off as for any
|
|
98
|
+
instance. Gone (a `401`, a redirect — not followed, its target never asked —
|
|
99
|
+
or an answer that is not the session's):
|
|
100
|
+
`connect()` rejects with SAP's answer as it is, nothing is logged off, and the
|
|
101
|
+
instance is spent.
|
|
102
|
+
- **HTTP wires only.** Over RFC, `session` is refused by `createConnection` at
|
|
103
|
+
construction, and by the RFC wire at `connect()` when the connector was built
|
|
104
|
+
by hand, before anything is sent. An empty `session` is refused at
|
|
105
|
+
construction.
|
|
106
|
+
|
|
107
|
+
See [USAGE.md — An instance on an existing session](./USAGE.md#an-instance-on-an-existing-session-session-and-sessioncookies).
|
|
108
|
+
|
|
109
|
+
## A wire of your own
|
|
110
|
+
|
|
111
|
+
`IAdtTransport` has two new required members:
|
|
112
|
+
|
|
113
|
+
- `resume(context, session): Promise<void>` — take over the session `session`
|
|
114
|
+
names, without the credential, or reject with the server's answer. A wire
|
|
115
|
+
whose session no cookie names rejects without sending anything, as
|
|
116
|
+
`RfcTransport` does.
|
|
117
|
+
- `sessionCookies(): string | null` — what `resume()` takes, or `null`.
|
|
118
|
+
|
|
119
|
+
A wire built on `HttpTransport` inherits both.
|
package/docs/SCOPE.md
CHANGED
|
@@ -6,10 +6,15 @@
|
|
|
6
6
|
on-prem + HTTP, on-prem + legacy HTTP (BASIS 7.40), on-prem + RFC. The caller states
|
|
7
7
|
the system and the transport; nothing is inferred.
|
|
8
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.
|
|
9
|
+
opens the session. A new session is a new instance. An instance may instead be built on
|
|
10
|
+
an existing session: `createConnection({ …, session })` takes that session's cookies;
|
|
11
|
+
`connect()` does not log on, and SAP's answer to the first request says whether the
|
|
12
|
+
session is alive. The cookies of the instance's session are readable (`sessionCookies()`),
|
|
13
|
+
for the caller to keep.
|
|
10
14
|
3. **Requests.** Each carries the credential the `IAuthProvider` hands over, the CSRF token
|
|
11
15
|
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.
|
|
16
|
+
stateless; nothing else of the session is kept between requests. A request carries no
|
|
17
|
+
deadline but the caller's own timeout.
|
|
13
18
|
4. **SAP's answer** reaches the caller as SAP gave it.
|
|
14
19
|
5. **`disconnect()`, once.** It sends the logoff when the instance holds a live
|
|
15
20
|
`SAP_SESSIONID` and resolves when the logoff is written. A `connect()` that failed after
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
> and context cookie. Another handler can flip it back while your lock is open. Nothing in this
|
|
6
6
|
> layer tracks locks: that belongs to `@mcp-abap-adt/adt-clients`, which holds the
|
|
7
7
|
> handles and pairs each LOCK with its UNLOCK per object. What the connection
|
|
8
|
-
> offers is `beginCriticalSection()` / `endCriticalSection()`,
|
|
9
|
-
>
|
|
8
|
+
> offers is `beginCriticalSection()` / `endCriticalSection()`, inside which a
|
|
9
|
+
> request carries no deadline at all, so nothing cuts it mid-span. See
|
|
10
10
|
> [USAGE.md — Session Lifecycle](./USAGE.md#session-lifecycle).
|
|
11
11
|
|
|
12
12
|
|
|
@@ -106,7 +106,6 @@ const logger = console;
|
|
|
106
106
|
import {
|
|
107
107
|
AdtOnPremConnector,
|
|
108
108
|
OnPremHttpTransport,
|
|
109
|
-
getTimeout,
|
|
110
109
|
} from '@mcp-abap-adt/connection';
|
|
111
110
|
import { BasicAuthProvider } from '@mcp-abap-adt/auth-providers';
|
|
112
111
|
|
|
@@ -125,7 +124,7 @@ await connection.connect(); // required before any request
|
|
|
125
124
|
connection.setSessionType('stateful');
|
|
126
125
|
|
|
127
126
|
// Following requests use the stateful context until the mode is changed
|
|
128
|
-
await connection.makeAdtRequest({ method: 'GET', url: '/sap/bc/adt/discovery' , timeout:
|
|
127
|
+
await connection.makeAdtRequest({ method: 'GET', url: '/sap/bc/adt/discovery' , timeout: 0 });
|
|
129
128
|
|
|
130
129
|
// Switch back to stateless
|
|
131
130
|
connection.setSessionType('stateless');
|
|
@@ -280,16 +279,18 @@ server's own timeout releases them together.
|
|
|
280
279
|
This is what makes an aborted request expensive, and it is not what it looks
|
|
281
280
|
like. Aborting costs you **knowledge**, not a session: whether the modification
|
|
282
281
|
was applied becomes unknowable, and the handle `unlock` needs is gone, while the
|
|
283
|
-
lock is still very much held.
|
|
284
|
-
|
|
285
|
-
|
|
282
|
+
lock is still very much held. And SAP, seeing the socket close, ends the
|
|
283
|
+
synchronous request that was running on it — a write in it is lost. That — not
|
|
284
|
+
any teardown — is why a request inside `beginCriticalSection()` carries no
|
|
285
|
+
deadline at all for the duration of a `lock → modify → unlock` chain.
|
|
286
286
|
|
|
287
287
|
Since 8.0.0 you reach it through the contract rather than the class: it is
|
|
288
288
|
`ICriticalSection` in `@mcp-abap-adt/interfaces-adt-connection`, which this connection declares.
|
|
289
|
-
What it promises is narrow and worth stating exactly — inside a section
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
289
|
+
What it promises is narrow and worth stating exactly — inside a section no
|
|
290
|
+
deadline of this package's applies, and the caller's per-request `timeout` is
|
|
291
|
+
not applied either (17.0.0; before, a ten-minute `SAP_TIMEOUT_CRITICAL` ceiling
|
|
292
|
+
replaced it). Not that no request can be cut short: the network, a proxy or the
|
|
293
|
+
server's own limits end a request whatever a contract says.
|
|
293
294
|
|
|
294
295
|
A section keeps its session through a credential renewal: a mutation refused
|
|
295
296
|
with a 401 inside it is renewed and resent on the same session, never moved to
|