@mcp-abap-adt/connection 6.0.0 → 7.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/LICENSE CHANGED
@@ -1,21 +1,165 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Oleksii Kyslytsia
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
package/README.md CHANGED
@@ -745,7 +745,28 @@ See [CHANGELOG.md](./CHANGELOG.md) for detailed version history and breaking cha
745
745
 
746
746
  ## License
747
747
 
748
- MIT
748
+ **GNU Lesser General Public License v3.0 only** (`LGPL-3.0-only`).
749
+ Earlier published versions were MIT and stay MIT — a licence change is not
750
+ retroactive.
751
+
752
+ Copyright © 2025–2026 Oleksii Kyslytsia
753
+
754
+ This library is free software: you can redistribute it and/or modify it under the
755
+ terms of the GNU Lesser General Public License as published by the Free Software
756
+ Foundation, version 3.
757
+
758
+ It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
759
+ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
760
+ PURPOSE. See the GNU Lesser General Public License for more details.
761
+
762
+ Both texts ship with the package and both are needed: [`LICENSE`](LICENSE) is the
763
+ LGPL, [`COPYING`](COPYING) is the GPL it is written on top of, since the LGPL is a
764
+ set of additional permissions over the GPL and cannot be read alone.
765
+
766
+ **What this means if you depend on this package.** Linking it into your own
767
+ program — importing it, as every consumer of an npm package does — does not put
768
+ your program under the LGPL. What the licence asks is that changes *to this
769
+ library* stay free, and that your users can replace it with their own build.
749
770
 
750
771
  ## Repository
751
772
 
@@ -3,7 +3,6 @@ const fs = require("fs");
3
3
  const path = require("path");
4
4
  const axios = require("axios");
5
5
  const { program } = require("commander");
6
- const express = require("express");
7
6
  const open = require("open").default;
8
7
  const http = require("http");
9
8
 
@@ -262,6 +261,57 @@ function getJwtAuthorizationUrl(serviceKey, port = 3001) {
262
261
  )}&response_type=code&redirect_uri=${encodeURIComponent(redirectUri)}`;
263
262
  }
264
263
 
264
+ /**
265
+ * How long to wait for the browser to come back.
266
+ *
267
+ * Five minutes was the fixed value, and a real BTP login does not fit in it:
268
+ * the identity provider, a password manager and whatever second factor the
269
+ * tenant asks for all happen before the redirect is issued. Measured twice —
270
+ * both times the window closed first, and the browser then had nowhere to
271
+ * redirect to, which reads to the user as the authentication having failed.
272
+ *
273
+ * So it is a decision the caller makes: `--timeout` in minutes, or
274
+ * `SAP_AUTH_TIMEOUT_MS` for a script that would rather not pass an argument.
275
+ * The default is fifteen, which covered the login this was measured against
276
+ * with room to spare and still bounds a run that has been abandoned.
277
+ */
278
+ const DEFAULT_AUTH_TIMEOUT_MS = 15 * 60 * 1000;
279
+
280
+ function resolveAuthTimeout(minutes) {
281
+ if (minutes !== undefined) {
282
+ const value = Number(minutes);
283
+ if (!Number.isFinite(value) || value <= 0) {
284
+ throw new Error(
285
+ `--timeout must be a positive number of minutes, got: ${minutes}`
286
+ );
287
+ }
288
+ return value * 60 * 1000;
289
+ }
290
+ const fromEnv = process.env.SAP_AUTH_TIMEOUT_MS;
291
+ if (fromEnv !== undefined && fromEnv !== "") {
292
+ const value = Number(fromEnv);
293
+ if (!Number.isFinite(value) || value <= 0) {
294
+ throw new Error(
295
+ `SAP_AUTH_TIMEOUT_MS must be a positive number of milliseconds, got: ${fromEnv}`
296
+ );
297
+ }
298
+ return value;
299
+ }
300
+ return DEFAULT_AUTH_TIMEOUT_MS;
301
+ }
302
+
303
+ /**
304
+ * One reply, with the header express used to set on our behalf.
305
+ *
306
+ * `res.send()` chose a Content-Type from what it was handed; `node:http` sends
307
+ * exactly what it is told, so the type is stated here. Without it a browser is
308
+ * free to render the success page as plain text.
309
+ */
310
+ function send(res, status, contentType, body) {
311
+ res.writeHead(status, { "Content-Type": contentType });
312
+ res.end(body);
313
+ }
314
+
265
315
  /**
266
316
  * Starts a local server to intercept the authentication response
267
317
  * @param {Object} serviceKey SAP BTP service key object
@@ -269,26 +319,42 @@ function getJwtAuthorizationUrl(serviceKey, port = 3001) {
269
319
  * @param {string} flow Flow type: jwt (OAuth2)
270
320
  * @returns {Promise<{accessToken: string, refreshToken?: string}>} Promise that resolves to tokens
271
321
  */
272
- async function startAuthServer(serviceKey, browser = undefined, flow = "jwt") {
322
+ async function startAuthServer(
323
+ serviceKey,
324
+ browser = undefined,
325
+ flow = "jwt",
326
+ timeoutMs = DEFAULT_AUTH_TIMEOUT_MS
327
+ ) {
273
328
  return new Promise((resolve, reject) => {
274
- const app = express();
275
- const server = http.createServer(app);
276
329
  const PORT = 3001;
277
330
  let serverInstance = null;
278
331
 
279
332
  // Choose the authorization URL
280
333
  const authorizationUrl = getJwtAuthorizationUrl(serviceKey, PORT);
281
334
 
282
- // JWT OAuth2 flow (get code, exchange for token)
283
- app.get("/callback", async (req, res) => {
335
+ // JWT OAuth2 flow (get code, exchange for token). One route, and the
336
+ // routing express did is two comparisons: a browser fetching /favicon.ico
337
+ // must not be mistaken for the redirect we are waiting for.
338
+ const server = http.createServer(async (req, res) => {
339
+ const url = new URL(req.url, `http://localhost:${PORT}`);
340
+ if (req.method !== "GET" || url.pathname !== "/callback") {
341
+ send(res, 404, "text/plain; charset=utf-8", "Not Found");
342
+ return;
343
+ }
344
+
284
345
  try {
285
- const { code } = req.query;
346
+ const code = url.searchParams.get("code");
286
347
  if (!code) {
287
- res.status(400).send("Error: Authorization code missing");
348
+ send(
349
+ res,
350
+ 400,
351
+ "text/plain; charset=utf-8",
352
+ "Error: Authorization code missing"
353
+ );
288
354
  return reject(new Error("Authorization code missing"));
289
355
  }
290
356
  console.log("Authorization code received");
291
- res.send(`<!DOCTYPE html>
357
+ send(res, 200, "text/html; charset=utf-8", `<!DOCTYPE html>
292
358
  <html lang="en">
293
359
  <head>
294
360
  <meta charset="UTF-8">
@@ -363,7 +429,12 @@ async function startAuthServer(serviceKey, browser = undefined, flow = "jwt") {
363
429
  }
364
430
  } catch (error) {
365
431
  console.error("Error handling callback:", error);
366
- res.status(500).send("Error processing authentication");
432
+ send(
433
+ res,
434
+ 500,
435
+ "text/plain; charset=utf-8",
436
+ "Error processing authentication"
437
+ );
367
438
  reject(error);
368
439
  }
369
440
  });
@@ -395,9 +466,17 @@ async function startAuthServer(serviceKey, browser = undefined, flow = "jwt") {
395
466
  setTimeout(() => {
396
467
  if (serverInstance) {
397
468
  serverInstance.close();
398
- reject(new Error("Authentication timeout. Process aborted."));
469
+ reject(
470
+ new Error(
471
+ `Authentication timeout after ${
472
+ timeoutMs >= 60000
473
+ ? `${Math.round(timeoutMs / 60000)} min`
474
+ : `${Math.round(timeoutMs / 1000)}s`
475
+ }. Process aborted. Raise it with --timeout <minutes> or SAP_AUTH_TIMEOUT_MS if the login needs longer.`
476
+ )
477
+ );
399
478
  }
400
- }, 5 * 60 * 1000);
479
+ }, timeoutMs);
401
480
  });
402
481
  }
403
482
 
@@ -540,6 +619,10 @@ async function main() {
540
619
  "-f, --force",
541
620
  "Force browser authentication even if valid tokens exist in .env"
542
621
  )
622
+ .option(
623
+ "-t, --timeout <minutes>",
624
+ "How long to wait for the browser redirect, in minutes (default: 15, or SAP_AUTH_TIMEOUT_MS in ms)"
625
+ )
543
626
  .helpOption("-h, --help", "Show help for the auth command")
544
627
  .action(async (options) => {
545
628
  try {
@@ -594,7 +677,12 @@ async function main() {
594
677
  // Fallback to browser authentication if refresh failed or was skipped
595
678
  if (!tokens) {
596
679
  console.log("🌐 Starting browser authentication...");
597
- tokens = await startAuthServer(serviceKey, options.browser, "jwt");
680
+ tokens = await startAuthServer(
681
+ serviceKey,
682
+ options.browser,
683
+ "jwt",
684
+ resolveAuthTimeout(options.timeout)
685
+ );
598
686
  if (!tokens || !tokens.accessToken) {
599
687
  console.error("JWT token was not obtained. Authentication failed.");
600
688
  process.exit(1);
@@ -4,28 +4,6 @@ import type { ILogger } from '../logger.js';
4
4
  import { SessionLifecycle } from '../session/SessionLifecycle.js';
5
5
  import type { AbapConnection, AbapRequestOptions } from './AbapConnection.js';
6
6
  import { type IAdtSessionContext, type IAdtTransport } from './IAdtTransport.js';
7
- /**
8
- * Declares the capabilities explicitly rather than satisfying them by accident.
9
- * `AbapConnection` is the base contract every transport honours; these two are
10
- * the HTTP session's own, and naming them means a signature that drifts from
11
- * the published contract fails to compile here instead of at the consumer.
12
- *
13
- * **This gives the consumer instruments; it does not decide for it.** `connect()`
14
- * opens one session and `disconnect()` closes it. How many connections to hold,
15
- * how long to hold them and when to let go stays with the caller — there are no
16
- * thresholds here, no pooling and no eviction, because none of that is knowable
17
- * from inside a single connection. A session this one did not open is not its
18
- * business: the session limit is per user and the pool is shared, so a SAP GUI
19
- * logon of the same user sits in the same list.
20
- *
21
- * **Nothing the server decides is treated as something to count on.** Whether it
22
- * issues a session cookie, whether it still holds a session it issued, how many
23
- * it will tolerate, how fast it answers a logoff — all of that is its own and
24
- * may differ by system and release. So each is observed and reported, never
25
- * relied upon: the logoff is best effort under a bound the caller sets, a
26
- * missing session cookie is a warning rather than a rule, and no code here
27
- * counts sessions or predicts the next answer from the last one.
28
- */
29
7
  declare abstract class AbstractAbapConnection implements AbapConnection, ISessionLifecycleAware {
30
8
  private readonly config;
31
9
  /**
@@ -48,6 +26,22 @@ declare abstract class AbstractAbapConnection implements AbapConnection, ISessio
48
26
  private baseUrl;
49
27
  private sessionId;
50
28
  private sessionMode;
29
+ /**
30
+ * What this connection asks the server to report about its own processing.
31
+ *
32
+ * Sent on every request as `X-sap-adt-profiling`, which is what Eclipse does
33
+ * — measured from an ADT 3.60.0 trace, where it rides on a stateless source
34
+ * `PUT` as readily as on a lock. `null` stops asking.
35
+ *
36
+ * Settable because it is a request's business, not a session's, and because
37
+ * a caller can already need something other than the default: a profiler run
38
+ * in `@mcp-abap-adt/adt-clients` writes its own value today, by putting the
39
+ * header in the request by hand. Nothing in this package reads the
40
+ * `server-time=…` that comes back — but an investigation does, and this
41
+ * session used it to establish that the unit is microseconds, so the default
42
+ * stays on and the way to turn it off is this property rather than a fork.
43
+ */
44
+ private profilingRequest;
51
45
  /**
52
46
  * When true, requests are treated as part of an uninterruptible critical
53
47
  * section (e.g. a lock → modify → unlock chain). In this state a short
@@ -131,6 +125,14 @@ declare abstract class AbstractAbapConnection implements AbapConnection, ISessio
131
125
  * Get current session mode
132
126
  */
133
127
  getSessionMode(): 'stateless' | 'stateful';
128
+ /**
129
+ * What to ask the server to report, or `null` to ask nothing.
130
+ *
131
+ * @param what the `X-sap-adt-profiling` value; `'server-time'` is Eclipse's.
132
+ */
133
+ setProfilingRequest(what: string | null): void;
134
+ /** What this connection is currently asking for. */
135
+ getProfilingRequest(): string | null;
134
136
  /**
135
137
  * Enter an uninterruptible critical section.
136
138
  *
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractAbapConnection.d.ts","sourceRoot":"","sources":["../../src/connection/AbstractAbapConnection.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAE5B,MAAM,0BAA0B,CAAC;AAMlC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAEL,gBAAgB,EAEjB,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;A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I;IAMlD;;OAEG;IACH,SAAS,CAAC,UAAU,IAAI,MAAM,GAAG,IAAI;IAIrC;;;;;;OAMG;IACH,SAAS,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAMlD;;;;OAIG;IACH,SAAS,CAAC,oBAAoB,IAAI,OAAO,YAAY,EAAE,YAAY;IAInE;;;;;;;;OAQG;YACW,eAAe;IAW7B;;;;;;;;OAQG;IACH,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,eAAe;CA6BxB;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -29,6 +29,18 @@ const IAdtTransport_js_1 = require("./IAdtTransport.js");
29
29
  * missing session cookie is a warning rather than a rule, and no code here
30
30
  * counts sessions or predicts the next answer from the last one.
31
31
  */
32
+ /**
33
+ * Whether a header is already set, whatever case the caller spelled it in.
34
+ *
35
+ * HTTP header names are case-insensitive and these arrive from two directions —
36
+ * this file writes `X-sap-adt-profiling`, a caller may write
37
+ * `x-sap-adt-profiling` — so a plain key lookup would answer "absent" for a
38
+ * header that is present and write it twice.
39
+ */
40
+ function hasHeader(headers, name) {
41
+ const wanted = name.toLowerCase();
42
+ return Object.keys(headers).some((key) => key.toLowerCase() === wanted);
43
+ }
32
44
  class AbstractAbapConnection {
33
45
  config;
34
46
  transport;
@@ -42,6 +54,22 @@ class AbstractAbapConnection {
42
54
  baseUrl;
43
55
  sessionId = null;
44
56
  sessionMode = 'stateless';
57
+ /**
58
+ * What this connection asks the server to report about its own processing.
59
+ *
60
+ * Sent on every request as `X-sap-adt-profiling`, which is what Eclipse does
61
+ * — measured from an ADT 3.60.0 trace, where it rides on a stateless source
62
+ * `PUT` as readily as on a lock. `null` stops asking.
63
+ *
64
+ * Settable because it is a request's business, not a session's, and because
65
+ * a caller can already need something other than the default: a profiler run
66
+ * in `@mcp-abap-adt/adt-clients` writes its own value today, by putting the
67
+ * header in the request by hand. Nothing in this package reads the
68
+ * `server-time=…` that comes back — but an investigation does, and this
69
+ * session used it to establish that the unit is microseconds, so the default
70
+ * stays on and the way to turn it off is this property rather than a fork.
71
+ */
72
+ profilingRequest = 'server-time';
45
73
  /**
46
74
  * When true, requests are treated as part of an uninterruptible critical
47
75
  * section (e.g. a lock → modify → unlock chain). In this state a short
@@ -147,6 +175,18 @@ class AbstractAbapConnection {
147
175
  getSessionMode() {
148
176
  return this.sessionMode;
149
177
  }
178
+ /**
179
+ * What to ask the server to report, or `null` to ask nothing.
180
+ *
181
+ * @param what the `X-sap-adt-profiling` value; `'server-time'` is Eclipse's.
182
+ */
183
+ setProfilingRequest(what) {
184
+ this.profilingRequest = what;
185
+ }
186
+ /** What this connection is currently asking for. */
187
+ getProfilingRequest() {
188
+ return this.profilingRequest;
189
+ }
150
190
  /**
151
191
  * Enter an uninterruptible critical section.
152
192
  *
@@ -747,11 +787,33 @@ class AbstractAbapConnection {
747
787
  if (this.sessionId) {
748
788
  requestHeaders['sap-adt-connection-id'] = this.sessionId;
749
789
  }
750
- // Add stateful session headers if stateful mode is enabled
790
+ // A request id identifies the **request**, so every request gets a fresh
791
+ // one. It used to be written only in the stateful branch, which was
792
+ // invisible while every write happened inside a lock window — the window
793
+ // was stateful, so the writes carried it. `@mcp-abap-adt/adt-clients` has
794
+ // since narrowed stateful to the `LOCK` and the `UNLOCK`, and the writes
795
+ // silently lost the header as a side effect. Eclipse sends it on
796
+ // everything: measured on ADT 3.60.0, a stateless source `PUT` carries
797
+ // `sap-adt-request-id` and `X-sap-adt-profiling` and no session type at all.
798
+ //
799
+ // **A default, not an override.** The caller's headers were copied in
800
+ // above, and a caller who names either of these means it: `adt-clients`
801
+ // passes its own id to `getDiscovery({ requestId })` so the id it logs is
802
+ // the id on the wire, and a profiler run asks for something other than
803
+ // `server-time`. Replacing those would break the correlation the caller
804
+ // asked for, silently. The name is matched without case because HTTP does
805
+ // not distinguish it and callers spell it both ways.
806
+ if (!hasHeader(requestHeaders, 'sap-adt-request-id')) {
807
+ requestHeaders['sap-adt-request-id'] = (0, node_crypto_1.randomUUID)().replace(/-/g, '');
808
+ }
809
+ if (this.profilingRequest !== null &&
810
+ !hasHeader(requestHeaders, 'x-sap-adt-profiling')) {
811
+ requestHeaders['X-sap-adt-profiling'] = this.profilingRequest;
812
+ }
813
+ // And this one really is the session's: it says how the server should treat
814
+ // the request, which is the only one of the three that varies with the mode.
751
815
  if (this.sessionMode === 'stateful') {
752
816
  requestHeaders['x-sap-adt-sessiontype'] = 'stateful';
753
- requestHeaders['sap-adt-request-id'] = (0, node_crypto_1.randomUUID)().replace(/-/g, '');
754
- requestHeaders['X-sap-adt-profiling'] = 'server-time';
755
817
  }
756
818
  // Add auth headers (these MUST NOT be overridden)
757
819
  Object.assign(requestHeaders, await this.getAuthHeaders());
@@ -22,6 +22,25 @@ export declare class CloudHttpTransport extends HttpTransport implements ICloudT
22
22
  readonly kind = "cloud-http";
23
23
  /** Which system this wire is for. Read by the compiler, never at runtime. */
24
24
  readonly system: "cloud";
25
+ /**
26
+ * `x-sap-security-session: use` — on every request, once there is a session.
27
+ *
28
+ * ABAP Cloud issues its session as a resource asked for at
29
+ * `/sap/bc/adt/core/http/sessions`, and Eclipse then names it on everything
30
+ * that follows rather than relying on the cookie alone. Measured from ADT
31
+ * 3.60.3 against a BTP trial: a plain
32
+ * `GET …/businessservices/odatav4/ZAC_SRVB01` carries it, and so does
33
+ * `POST …/unpublishjobs` — a read and a write, both stateless, both saying
34
+ * `use`.
35
+ *
36
+ * Only when a session exists: saying `use` with nothing to use is a claim
37
+ * about state this wire is not in, and `create` is the request that makes one.
38
+ *
39
+ * On-prem is left alone deliberately. Its session arrives with the logon and
40
+ * there is no trace of Eclipse sending this there, so adding it would be a
41
+ * guess wearing a measurement's clothes.
42
+ */
43
+ protected sessionHeaders(): Record<string, string>;
25
44
  /** The address this server published for our session — the only close target. */
26
45
  private resource;
27
46
  open(context: IAdtSessionContext): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"CloudHttpTransport.d.ts","sourceRoot":"","sources":["../../src/connection/CloudHttpTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAa9E,qBAAa,kBACX,SAAQ,aACR,YAAW,eAAe;IAE1B,SAAkB,IAAI,gBAAgB;IAEtC,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAG,OAAO,CAAU;IAEnC,iFAAiF;IACjF,OAAO,CAAC,QAAQ,CAAuB;IAExB,IAAI,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAqDhD,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IA4ChE;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;CAW5B"}
1
+ {"version":3,"file":"CloudHttpTransport.d.ts","sourceRoot":"","sources":["../../src/connection/CloudHttpTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAa9E,qBAAa,kBACX,SAAQ,aACR,YAAW,eAAe;IAE1B,SAAkB,IAAI,gBAAgB;IAEtC,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAG,OAAO,CAAU;IAEnC;;;;;;;;;;;;;;;;;OAiBG;cACgB,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAI3D,iFAAiF;IACjF,OAAO,CAAC,QAAQ,CAAuB;IAExB,IAAI,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAqDhD,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IA4ChE;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;CAW5B"}
@@ -32,6 +32,27 @@ class CloudHttpTransport extends HttpTransport_js_1.HttpTransport {
32
32
  kind = 'cloud-http';
33
33
  /** Which system this wire is for. Read by the compiler, never at runtime. */
34
34
  system = 'cloud';
35
+ /**
36
+ * `x-sap-security-session: use` — on every request, once there is a session.
37
+ *
38
+ * ABAP Cloud issues its session as a resource asked for at
39
+ * `/sap/bc/adt/core/http/sessions`, and Eclipse then names it on everything
40
+ * that follows rather than relying on the cookie alone. Measured from ADT
41
+ * 3.60.3 against a BTP trial: a plain
42
+ * `GET …/businessservices/odatav4/ZAC_SRVB01` carries it, and so does
43
+ * `POST …/unpublishjobs` — a read and a write, both stateless, both saying
44
+ * `use`.
45
+ *
46
+ * Only when a session exists: saying `use` with nothing to use is a claim
47
+ * about state this wire is not in, and `create` is the request that makes one.
48
+ *
49
+ * On-prem is left alone deliberately. Its session arrives with the logon and
50
+ * there is no trace of Eclipse sending this there, so adding it would be a
51
+ * guess wearing a measurement's clothes.
52
+ */
53
+ sessionHeaders() {
54
+ return this.sessionEstablished() ? { 'x-sap-security-session': 'use' } : {};
55
+ }
35
56
  /** The address this server published for our session — the only close target. */
36
57
  resource = null;
37
58
  async open(context) {
@@ -100,6 +100,15 @@ export declare class HttpTransport implements IAdtTransport {
100
100
  * server is going down, send us elsewhere rather than fail.
101
101
  */
102
102
  affinityHeaders(): Record<string, string>;
103
+ /**
104
+ * What this wire says about the session it is already in, on every request.
105
+ *
106
+ * Empty here, because it is not the same on every wire: a cloud session is a
107
+ * resource that has to be named, an on-prem one arrives with the logon, and
108
+ * an RFC conversation has no such notion at all. A wire that has something to
109
+ * say overrides this.
110
+ */
111
+ protected sessionHeaders(): Record<string, string>;
103
112
  /**
104
113
  * Earn a CSRF token, and with it the cookies that name the session.
105
114
  *