@mcp-abap-adt/connection 25.1.0 → 25.2.1

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 CHANGED
@@ -7,6 +7,59 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [25.2.1] - 2026-11-23
11
+
12
+ ### Changed
13
+
14
+ - **The optional RFC binding's floor is `@mcp-abap-adt/sap-rfc-lite` `^0.4.1`.**
15
+ 0.4.1 fixes two defects in the binding: a client stayed locked for good
16
+ after a call whose preparation failed (no worker released its hold on the
17
+ error path), and the per-client lock was released from another thread than
18
+ the one that took it (undefined behaviour for `std::mutex`). Nothing in this
19
+ package's code changes.
20
+
21
+ ## [25.2.0] - 2026-11-22
22
+
23
+ One per-request option, declared by `IAbapRequestOptions` in
24
+ `@mcp-abap-adt/interfaces-adt-connection` 5.3.0 (the floor is now `^5.3.0`),
25
+ so that an abapGit file reads back as its original text. A request without it
26
+ behaves exactly as on 25.1.0. See
27
+ [README — Request options](README.md#request-options-noresend-nolog-stateless).
28
+
29
+ ### Added
30
+
31
+ - **`rawText: true`** — changes only the body the caller receives as the
32
+ final answer: a success's `data`, or the `response.data` of the error the
33
+ caller gets, is the exact text SAP sent. Nothing internal changes: the CSRF
34
+ recovery, the session verdicts (a replacement cookie included), the
35
+ replays, the credential provider (`IAuthRejection.error`, and
36
+ `AuthRefusedError.cause`), the log lines and the error's shape read what
37
+ the unflagged path reads. That holds for the shipped HTTP client; an
38
+ injected `httpClient` configured with defaults of its own
39
+ (`transitional.forcedJSONParsing`, `responseType`) owns how its bodies
40
+ look. Over HTTP the body is received as bytes (`responseType:
41
+ 'arraybuffer'`); from them the connection takes exactly what axios's
42
+ defaults would have made (UTF-8, a leading BOM dropped, JSON parsed when it
43
+ parses) for everything inside, and decodes the caller's text in the charset
44
+ the `Content-Type` declares when `TextDecoder` knows it, else UTF-8, the BOM
45
+ kept, non-fatally — an invalid byte reads as U+FFFD. It applies on every
46
+ send the request takes (the ordinary one, `noResend`, the CSRF recovery's
47
+ resend, the dead-pooled-socket resend, `createConnection`'s check replay)
48
+ and to the refusal of the CSRF fetch made for a `noResend` request
49
+ (`IAdtSessionContext.rawText`). A `noLog` line counts the bytes that
50
+ arrived. `IAdtTransportRequest` carries the flag to the wire.
51
+
52
+ ### Fixed
53
+
54
+ - Over HTTP a file's text came back changed: the wire read every body
55
+ through axios's default `transformResponse`, which parses JSON even under
56
+ `text/plain` — a JSON-object file arrived as an object, a JSON-string file
57
+ without its quotes and its trailing newline. SAP's abapGit file resource
58
+ answers only `text/plain; charset=utf-8`, so the fix is on this side:
59
+ `rawText`.
60
+ - RFC needed no change: the body is the UTF-8 text of `MESSAGE_BODY`, never
61
+ parsed, with or without the flag (now proven by a test).
62
+
10
63
  ## [25.1.0] - 2026-11-22
11
64
 
12
65
  Three per-request options, declared by `IAbapRequestOptions` in
@@ -3176,7 +3229,9 @@ const connection = createAbapConnection(config, logger);
3176
3229
  - JWT token refresh now properly handles connection errors (401/403 during initial connect)
3177
3230
  - Permission errors (403 with "ExceptionResourceNoAccess") no longer trigger JWT refresh loops
3178
3231
  - Proper separation: base class handles HTTP/session, concrete classes handle auth-specific errors
3179
- [Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/v25.1.0...HEAD
3232
+ [Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/v25.2.1...HEAD
3233
+ [25.2.1]: https://github.com/fr0ster/mcp-abap-connection/compare/v25.2.0...v25.2.1
3234
+ [25.2.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v25.1.0...v25.2.0
3180
3235
  [25.1.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v25.0.1...v25.1.0
3181
3236
  [25.0.1]: https://github.com/fr0ster/mcp-abap-connection/compare/v25.0.0...v25.0.1
3182
3237
  [25.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v24.0.0...v25.0.0
package/README.md CHANGED
@@ -339,9 +339,10 @@ of these three resends: see the request options below.
339
339
 
340
340
  ### Request options: `noResend`, `noLog`, `stateless`
341
341
 
342
- Since 25.1.0, three optional flags of `IAbapRequestOptions`
343
- (`@mcp-abap-adt/interfaces-adt-connection` 5.2.0) change one request and
344
- nothing else. A request without them behaves as before.
342
+ Since 25.1.0, optional flags of `IAbapRequestOptions` change one request and
343
+ nothing else: `noResend`, `noLog` and `stateless`
344
+ (`@mcp-abap-adt/interfaces-adt-connection` 5.2.0), and since 25.2.0 `rawText`
345
+ (5.3.0). A request without them behaves as before.
345
346
 
346
347
  ```typescript
347
348
  await connection.makeAdtRequest({
@@ -353,6 +354,14 @@ await connection.makeAdtRequest({
353
354
  noLog: true, // nothing of the request or its answer in a log
354
355
  stateless: true, // stateless whatever the session mode
355
356
  });
357
+
358
+ // An abapGit file as the exact text SAP sent:
359
+ const file = await connection.makeAdtRequest({
360
+ method: "GET",
361
+ url: "/sap/bc/adt/abapgit/repos/R1/files/package.json",
362
+ timeout: 0,
363
+ rawText: true, // the body is the text, not parsed
364
+ });
356
365
  ```
357
366
 
358
367
  - **`noResend: true`** — the request is sent once. It gates every replay: the
@@ -399,6 +408,29 @@ await connection.makeAdtRequest({
399
408
  wire strips that header and the `sap-contextid` cookie from the request (over
400
409
  RFC, the call goes on a conversation other than the stateful one). The session
401
410
  mode is not changed: the next ordinary request follows it.
411
+ - **`rawText: true`** (25.2.0) — changes only the body you receive as the
412
+ final answer: a success's `data`, or the `response.data` of the error you
413
+ get, is the exact text SAP sent, a string — a JSON-object file is not an
414
+ object, a JSON-string file keeps its quotes and its trailing newline, and a
415
+ leading byte-order mark stays. Nothing inside the connection changes: the
416
+ CSRF recovery, the session verdicts (a replacement cookie included), the
417
+ replays, the credential provider (`IAuthRejection.error`), the log lines
418
+ and the error's shape all read what the request without the flag reads, so
419
+ the same answer gets the same handling either way. That guarantee is for
420
+ the shipped HTTP client: a consumer that injects an `httpClient` configured
421
+ with defaults of its own — `transitional.forcedJSONParsing`, `responseType`
422
+ — owns how its bodies look, and with them what those consumers read. Over HTTP the body is received as bytes; the text is decoded in the
423
+ charset the `Content-Type` declares when `TextDecoder` knows it, else
424
+ UTF-8, the BOM kept, and **non-fatally: a byte that is not text in that
425
+ charset reads as U+FFFD** — no error is raised for it. (SAP's abapGit file
426
+ resource answers `text/plain; charset=utf-8`, already UTF-8 on SAP's side.)
427
+ It applies on every send the request takes — the ordinary one, `noResend`,
428
+ the CSRF recovery's resend, the dead-pooled-socket resend,
429
+ `createConnection`'s check replay — and to the refusal of the CSRF fetch
430
+ made for a `noResend` request when that is the answer. A `noLog` line counts
431
+ the bytes that arrived; nothing else of it changes. Over RFC the body is
432
+ already the UTF-8 text of `MESSAGE_BODY`, never parsed, with or without the
433
+ flag.
402
434
 
403
435
  ### An instance on an existing session
404
436
 
@@ -574,7 +606,7 @@ package state from causing PAK/058 on later writes or SADT_RESOURCE/007 on a
574
606
  read after create. Concurrent calls use a separate conversation. See
575
607
  [RFC conversation isolation](./docs/STATEFUL_SESSION_GUIDE.md#rfc-conversation-isolation-932-and-933).
576
608
 
577
- Needs `npm install @mcp-abap-adt/sap-rfc-lite` (0.4.0 or newer: it installs with no install
609
+ Needs `npm install @mcp-abap-adt/sap-rfc-lite` (0.4.1 or newer: it installs with no install
578
610
  script and carries prebuilt bindings for linux-x64 glibc, win32-x64 and darwin-arm64; elsewhere,
579
611
  build one from its repository) and the SAP NetWeaver RFC library at run time: on Windows, the
580
612
  64-bit `sapnwrfc.dll` SAP GUI installs into `System32` is enough; otherwise the SAP NW RFC SDK, its
@@ -13,7 +13,7 @@ import { type IAdtSessionContext, type IAdtTransport, type IAdtTransportRequest
13
13
  */
14
14
  type SessionObservation = 'kept' | 'lost';
15
15
  /** The flags of a request that reach the exchanges made for it. */
16
- type RequestFlags = Pick<IAdtTransportRequest, 'noResend' | 'noLog'>;
16
+ type RequestFlags = Pick<IAdtTransportRequest, 'noResend' | 'noLog' | 'rawText'>;
17
17
  /** Whether a thrown value is a refusal this connection marked `sessionLost`. */
18
18
  export declare function carriesSessionLost(error: unknown): boolean;
19
19
  declare abstract class AbstractAbapConnection implements AbapConnection, ISessionLifecycleAware, ICriticalSection, IRequestProfiling {
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractAbapConnection.d.ts","sourceRoot":"","sources":["../../src/connection/AbstractAbapConnection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACb,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,KAAK,YAAY,EACjB,gBAAgB,EAEjB,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAEL,KAAK,aAAa,EAMnB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EAE1B,MAAM,oBAAoB,CAAC;AA6C5B;;;;GAIG;AACH,KAAK,kBAAkB,GAAG,MAAM,GAAG,MAAM,CAAC;AAiB1C,mEAAmE;AACnE,KAAK,YAAY,GAAG,IAAI,CAAC,oBAAoB,EAAE,UAAU,GAAG,OAAO,CAAC,CAAC;AAkBrE,gFAAgF;AAChF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAO1D;AAqBD,uBAAe,sBACb,YACE,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB;IAwIjB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,SAAS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AAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAMlD;;;;;;;;OAQG;YACW,eAAe;IAS7B;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,aAAa;IA0CrB;;;;;;;;OAQG;IACH,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,eAAe;CA6BxB;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
1
+ {"version":3,"file":"AbstractAbapConnection.d.ts","sourceRoot":"","sources":["../../src/connection/AbstractAbapConnection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACb,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,KAAK,YAAY,EACjB,gBAAgB,EAEjB,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAEL,KAAK,aAAa,EAMnB,MAAM,iBAAiB,CAAC;AAKzB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EAE1B,MAAM,oBAAoB,CAAC;AA6C5B;;;;GAIG;AACH,KAAK,kBAAkB,GAAG,MAAM,GAAG,MAAM,CAAC;AAiB1C,mEAAmE;AACnE,KAAK,YAAY,GAAG,IAAI,CACtB,oBAAoB,EACpB,UAAU,GAAG,OAAO,GAAG,SAAS,CACjC,CAAC;AAmBF,gFAAgF;AAChF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAO1D;AAqBD,uBAAe,sBACb,YACE,cAAc,EACd,sBAAsB,EACtB,gBA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AAI;IAMlD;;OAEG;IACH,SAAS,CAAC,UAAU,IAAI,MAAM,GAAG,IAAI;IAIrC;;;;;;OAMG;IACH,SAAS,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAMlD;;;;;;;;OAQG;YACW,eAAe;IAS7B;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,aAAa;IA2CrB;;;;;;;;OAQG;IACH,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,eAAe;CASxB;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.AbstractAbapConnection = void 0;
4
37
  exports.carriesSessionLost = carriesSessionLost;
@@ -8,6 +41,8 @@ const SessionLifecycle_js_1 = require("../session/SessionLifecycle.js");
8
41
  const networkErrors_js_1 = require("../utils/networkErrors.js");
9
42
  const authErrors_js_1 = require("./authErrors.js");
10
43
  const csrfConfig_js_1 = require("./csrfConfig.js");
44
+ const csrfRetry = __importStar(require("./csrfRetry.js"));
45
+ const exactText_js_1 = require("./exactText.js");
11
46
  const failureFacts_js_1 = require("./failureFacts.js");
12
47
  const IAdtTransport_js_1 = require("./IAdtTransport.js");
13
48
  const quietLine_js_1 = require("./quietLine.js");
@@ -67,11 +102,12 @@ function dataPreview(data) {
67
102
  return undefined;
68
103
  }
69
104
  }
70
- /** A request's `noResend` and `noLog`, and nothing else of it. */
105
+ /** A request's `noResend`, `noLog` and `rawText`, and nothing else of it. */
71
106
  function flagsOf(request) {
72
107
  return {
73
108
  ...(request.noResend ? { noResend: true } : {}),
74
109
  ...(request.noLog ? { noLog: true } : {}),
110
+ ...(request.rawText ? { rawText: true } : {}),
75
111
  };
76
112
  }
77
113
  /**
@@ -1237,10 +1273,21 @@ class AbstractAbapConnection {
1237
1273
  // shut the door.
1238
1274
  const lease = this.lifecycle.admitRequest();
1239
1275
  try {
1240
- return await this.performRequest(options, lease);
1276
+ const response = await this.performRequest(options, lease);
1277
+ // `rawText`: the caller's view, and only the caller's — everything
1278
+ // inside has read the answer by now.
1279
+ if (options.rawText)
1280
+ (0, exactText_js_1.toCallerView)(response);
1281
+ return response;
1241
1282
  }
1242
1283
  catch (error) {
1243
- throw (0, authErrors_js_1.outwardLogonError)(error);
1284
+ const outward = (0, authErrors_js_1.outwardLogonError)(error);
1285
+ if (options.rawText) {
1286
+ const refusal = (0, IAdtTransport_js_1.refusalOf)(outward);
1287
+ if (refusal)
1288
+ (0, exactText_js_1.toCallerView)(refusal);
1289
+ }
1290
+ throw outward;
1244
1291
  }
1245
1292
  finally {
1246
1293
  lease.release();
@@ -1380,6 +1427,9 @@ class AbstractAbapConnection {
1380
1427
  // `noLog`: every line about this request, here and on the wire, is the
1381
1428
  // quiet one.
1382
1429
  ...(options.noLog ? { noLog: true } : {}),
1430
+ // `rawText`: only the caller's view changes (`toCallerView`, at the
1431
+ // door); every resend below reuses requestConfig.
1432
+ ...(options.rawText ? { rawText: true } : {}),
1383
1433
  };
1384
1434
  if (data !== undefined) {
1385
1435
  requestConfig.data = data;
@@ -1442,9 +1492,14 @@ class AbstractAbapConnection {
1442
1492
  const answer = response;
1443
1493
  // The answer itself says the session is gone: a field, on the one object
1444
1494
  // that answers this request, never a word.
1445
- return observed === 'lost'
1446
- ? { ...answer, sessionLost: interfaces_adt_connection_1.ADT_SESSION_ERROR.SESSION_REPLACED }
1447
- : answer;
1495
+ if (observed !== 'lost')
1496
+ return answer;
1497
+ const marked = {
1498
+ ...answer,
1499
+ sessionLost: interfaces_adt_connection_1.ADT_SESSION_ERROR.SESSION_REPLACED,
1500
+ };
1501
+ (0, exactText_js_1.carryExact)(answer, marked);
1502
+ return marked;
1448
1503
  }
1449
1504
  /**
1450
1505
  * SAP's refusal of a stateless request whose answer showed the session
@@ -2003,6 +2058,7 @@ class AbstractAbapConnection {
2003
2058
  return {
2004
2059
  ...(flags.noResend ? { noResend: true } : {}),
2005
2060
  ...(quiet ? { noLog: true } : {}),
2061
+ ...(flags.rawText ? { rawText: true } : {}),
2006
2062
  authorize: async (headers) => {
2007
2063
  await this.credentialHeaders(headers);
2008
2064
  if (lease && !this.lifecycle.isCurrent(lease)) {
@@ -2049,26 +2105,10 @@ class AbstractAbapConnection {
2049
2105
  this.lifecycle.forgetIdentity();
2050
2106
  }
2051
2107
  shouldRetryCsrf(error, method) {
2052
- const refusal = (0, IAdtTransport_js_1.refusalOf)(error);
2053
- if (!refusal) {
2054
- return false;
2055
- }
2056
- const responseData = refusal.data;
2057
- const responseText = typeof responseData === 'string'
2058
- ? responseData
2059
- : JSON.stringify(responseData || '');
2060
- // Retry on 403 with CSRF message, or if response mentions CSRF token
2061
- // Also retry on 401 for POST/PUT/DELETE if we don't have CSRF token yet (might need to get cookies first)
2062
- // Handed in rather than read off `error.config`, which is axios's own
2063
- // record of the request and does not exist on another wire's refusal. The
2064
- // caller already normalised the method; asking the error for it was asking
2065
- // the HTTP client.
2066
- const normalized = method?.toUpperCase();
2067
- const isPostPutDelete = normalized && ['POST', 'PUT', 'DELETE'].includes(normalized);
2068
- const needsCsrfToken = !!isPostPutDelete && !this.transport.csrfToken();
2069
- return ((refusal.status === 403 && responseText.includes('CSRF')) ||
2070
- responseText.includes('CSRF token') ||
2071
- (needsCsrfToken && refusal.status === 401));
2108
+ // Asked through its module: the order it is asked in is observable.
2109
+ return csrfRetry.shouldRetryCsrf(error, method,
2110
+ // Read only where the predicate always read it.
2111
+ () => this.transport.csrfToken());
2072
2112
  }
2073
2113
  }
2074
2114
  exports.AbstractAbapConnection = AbstractAbapConnection;
@@ -1 +1 @@
1
- {"version":3,"file":"HttpTransport.d.ts","sourceRoot":"","sources":["../../src/connection/HttpTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,IAAI,SAAS,EAGlB,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAA2B,MAAM,YAAY,CAAC;AAG/E,OAAO,KAAK,EAGV,YAAY,EACb,MAAM,+BAA+B,CAAC;AACvC,OAAc,EACZ,KAAK,aAAa,EAGnB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAK5C,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAE3B,MAAM,oBAAoB,CAAC;AA4M5B,OAAO,EAAE,iBAAi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;;OAKG;IACG,IAAI,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAKzE;;;;;;OAMG;IACH,OAAO,CAAC,GAAG;IAmBX;;;;;;;;;;;;;;OAcG;cACa,YAAY,CAC1B,OAAO,EAAE,oBAAoB;IAC7B,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,IAAI,GACnB,OAAO,CAAC,qBAAqB,CAAC;IAIjC;;;;;OAKG;IACH,SAAS,CAAC,aAAa,CACrB,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,GAC9C,aAAa;IAOhB,0DAA0D;IAC1D,OAAO,CAAC,YAAY;IAOpB;;;;;;;;;;;;;;;;;;OAkBG;YACW,UAAU;YAyCV,QAAQ;CAmFvB"}
@@ -34,6 +34,7 @@ const axios_1 = __importDefault(require("axios"));
34
34
  const cookies_js_1 = require("../utils/cookies.js");
35
35
  const authErrors_js_1 = require("./authErrors.js");
36
36
  const csrfConfig_js_1 = require("./csrfConfig.js");
37
+ const exactText_js_1 = require("./exactText.js");
37
38
  const failureFacts_js_1 = require("./failureFacts.js");
38
39
  const IAdtTransport_js_1 = require("./IAdtTransport.js");
39
40
  const statefulRequest_js_1 = require("./statefulRequest.js");
@@ -711,6 +712,8 @@ class HttpTransport {
711
712
  // `noResend` the fetch, too, goes once and follows no redirect.
712
713
  ...(context.noResend ? { noResend: true } : {}),
713
714
  ...(context.noLog ? { noLog: true } : {}),
715
+ // `rawText`: under `noResend` this answer may be the request's.
716
+ ...(context.rawText ? { rawText: true } : {}),
714
717
  });
715
718
  // Handed up BEFORE the token is read: the cookies are the session,
716
719
  // and a fold that only happened on success would lose the session a
@@ -1274,6 +1277,10 @@ class HttpTransport {
1274
1277
  ...(request.validateStatus !== undefined
1275
1278
  ? { validateStatus: request.validateStatus }
1276
1279
  : {}),
1280
+ // `rawText`: the body as bytes, which axios's default transform leaves
1281
+ // alone; what the connection reads and what the caller gets are both
1282
+ // made of them (`rawTextAnswer`).
1283
+ ...(request.rawText ? { responseType: 'arraybuffer' } : {}),
1277
1284
  };
1278
1285
  // A logoff opens a socket of its own and is never resent: its answer is
1279
1286
  // not read, and its write is what `disconnect()` resolves at.
@@ -1288,14 +1295,15 @@ class HttpTransport {
1288
1295
  // Never as the client threw it: axios's error holds this request's
1289
1296
  // config — its credential headers among it — and words naming the host.
1290
1297
  // SAP's answer and the code go up; nothing else of it does.
1291
- throw (0, failureFacts_js_1.httpFailure)(error);
1298
+ throw (0, failureFacts_js_1.httpFailure)(error, request.rawText === true);
1292
1299
  }
1293
- return {
1300
+ const answer = {
1294
1301
  status: response.status,
1295
1302
  statusText: response.statusText,
1296
1303
  headers: response.headers,
1297
1304
  data: response.data,
1298
1305
  };
1306
+ return request.rawText ? (0, exactText_js_1.rawTextAnswer)(answer) : answer;
1299
1307
  }
1300
1308
  }
1301
1309
  exports.HttpTransport = HttpTransport;
@@ -73,6 +73,12 @@ export interface IAdtTransportRequest {
73
73
  * the byte count, and nothing else.
74
74
  */
75
75
  noLog?: true | undefined;
76
+ /**
77
+ * The caller's `rawText: true`: the body the caller receives as the final
78
+ * answer is the exact text SAP sent; everything inside the connection reads
79
+ * what it reads without the flag (`exactText.ts`).
80
+ */
81
+ rawText?: true | undefined;
76
82
  }
77
83
  /** What came back, in the terms every transport can produce. */
78
84
  export interface IAdtTransportResponse {
@@ -123,6 +129,8 @@ export interface IAdtSessionContext {
123
129
  */
124
130
  noResend?: true | undefined;
125
131
  noLog?: true | undefined;
132
+ /** The request's `rawText`: under `noResend` the exchange's answer may be its answer. */
133
+ rawText?: true | undefined;
126
134
  /** Where to hand each answer, so the connection sees what the wire saw. */
127
135
  observe: (headers: unknown) => void;
128
136
  }
@@ -1 +1 @@
1
- {"version":3,"file":"IAdtTransport.d.ts","sourceRoot":"","sources":["../../src/connection/IAdtTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAA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A4E;IAC5E,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE1C;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExD,0EAA0E;IAC1E,SAAS,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;;;;;;;;;;;;;GAaG;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"}
@@ -0,0 +1,10 @@
1
+ export declare function shouldRetryCsrf(error: unknown,
2
+ /** The request's method, already normalised by the caller. */
3
+ method: string | undefined,
4
+ /**
5
+ * The wire's CSRF token — read lazily, at the point the predicate always
6
+ * read it: after the refusal is serialised, and only for a `POST`, `PUT` or
7
+ * `DELETE`.
8
+ */
9
+ csrfToken: () => string | null): boolean;
10
+ //# sourceMappingURL=csrfRetry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csrfRetry.d.ts","sourceRoot":"","sources":["../../src/connection/csrfRetry.ts"],"names":[],"mappings":"AAWA,wBAAgB,eAAe,CAC7B,KAAK,EAAE,OAAO;AACd,8DAA8D;AAC9D,MAAM,EAAE,MAAM,GAAG,SAAS;AAC1B;;;;GAIG;AACH,SAAS,EAAE,MAAM,MAAM,GAAG,IAAI,GAC7B,OAAO,CA4BT"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.shouldRetryCsrf = shouldRetryCsrf;
4
+ /**
5
+ * Whether a refusal is the one fault the CSRF recovery cures in the same
6
+ * session: a `403` naming CSRF, any answer whose text holds `CSRF token`, or
7
+ * a `401` to a mutation sent while the wire holds no token yet.
8
+ *
9
+ * A module of its own so the order the connection asks it in is observable:
10
+ * it is asked only after the refusal's cookies were observed, and never for
11
+ * an answer that already lost the session.
12
+ */
13
+ const IAdtTransport_js_1 = require("./IAdtTransport.js");
14
+ function shouldRetryCsrf(error,
15
+ /** The request's method, already normalised by the caller. */
16
+ method,
17
+ /**
18
+ * The wire's CSRF token — read lazily, at the point the predicate always
19
+ * read it: after the refusal is serialised, and only for a `POST`, `PUT` or
20
+ * `DELETE`.
21
+ */
22
+ csrfToken) {
23
+ const refusal = (0, IAdtTransport_js_1.refusalOf)(error);
24
+ if (!refusal) {
25
+ return false;
26
+ }
27
+ const responseData = refusal.data;
28
+ const responseText = typeof responseData === 'string'
29
+ ? responseData
30
+ : JSON.stringify(responseData || '');
31
+ // Retry on 403 with CSRF message, or if response mentions CSRF token
32
+ // Also retry on 401 for POST/PUT/DELETE if we don't have CSRF token yet (might need to get cookies first)
33
+ // Handed in rather than read off `error.config`, which is axios's own
34
+ // record of the request and does not exist on another wire's refusal. The
35
+ // caller already normalised the method; asking the error for it was asking
36
+ // the HTTP client.
37
+ const normalized = method?.toUpperCase();
38
+ const isPostPutDelete = normalized && ['POST', 'PUT', 'DELETE'].includes(normalized);
39
+ const needsCsrfToken = !!isPostPutDelete && !csrfToken();
40
+ return ((refusal.status === 403 && responseText.includes('CSRF')) ||
41
+ responseText.includes('CSRF token') ||
42
+ (needsCsrfToken && refusal.status === 401));
43
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * `rawText`: the body the caller receives as the final answer is the exact
3
+ * text SAP sent. Nothing internal changes.
4
+ *
5
+ * The HTTP wire reads a `rawText` answer's body as bytes and makes two things
6
+ * of them. The body every consumer inside the connection reads — the CSRF
7
+ * recovery, the session verdicts, the replays, logging, the error's shape —
8
+ * is exactly what the unflagged path has: what axios's defaults make of the
9
+ * same bytes (UTF-8, a leading BOM dropped, JSON parsed when it parses). The
10
+ * exact text is kept beside the answer object, in a module-private map, with
11
+ * the raw byte length for `noLog`'s line; it replaces `data` only on the
12
+ * object the caller receives, at the connection's door (`toCallerView`).
13
+ *
14
+ * The exact text is decoded in the charset the `Content-Type` declares when
15
+ * `TextDecoder` knows it, else UTF-8, the BOM kept, non-fatally: a byte that
16
+ * is not text in that charset reads as U+FFFD.
17
+ */
18
+ import type { IAdtTransportResponse } from './IAdtTransport.js';
19
+ /**
20
+ * A `rawText` answer as the connection reads it: `data` is what the
21
+ * unflagged path has, and the exact text and raw byte length are kept beside
22
+ * it. A body that is not bytes (a client that made something else of it) is
23
+ * left as it is.
24
+ */
25
+ export declare function rawTextAnswer(answer: IAdtTransportResponse): IAdtTransportResponse;
26
+ /** The same exact text on another object carrying the same answer. */
27
+ export declare function carryExact(from: object, to: object): void;
28
+ /** A `rawText` answer's raw byte length, else `undefined`. */
29
+ export declare function rawByteLength(answer: object): number | undefined;
30
+ /**
31
+ * The caller's view, at the connection's door: a `rawText` answer's `data`
32
+ * becomes its exact text. Every consumer inside has read it by then.
33
+ */
34
+ export declare function toCallerView(answer: {
35
+ data: unknown;
36
+ }): void;
37
+ /**
38
+ * The body as consumers inside read it, for one that sits outside the
39
+ * connection's door (the check replay of `createConnection`): what the
40
+ * unflagged path has, whether or not the caller's view was applied.
41
+ */
42
+ export declare function internalBody(answer: IAdtTransportResponse): unknown;
43
+ //# sourceMappingURL=exactText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exactText.d.ts","sourceRoot":"","sources":["../../src/connection/exactText.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AA0HhE;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,qBAAqB,GAC5B,qBAAqB,CAWvB;AAED,sEAAsE;AACtE,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAGzD;AAED,8DAA8D;AAC9D,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEhE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAG5D;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAGnE"}
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rawTextAnswer = rawTextAnswer;
4
+ exports.carryExact = carryExact;
5
+ exports.rawByteLength = rawByteLength;
6
+ exports.toCallerView = toCallerView;
7
+ exports.internalBody = internalBody;
8
+ const EXACT = new WeakMap();
9
+ /** The body's bytes: a Buffer, any other view, or a plain `ArrayBuffer`. */
10
+ function bytesOf(body) {
11
+ if (body instanceof Uint8Array)
12
+ return body;
13
+ if (ArrayBuffer.isView(body)) {
14
+ return new Uint8Array(body.buffer, body.byteOffset, body.byteLength);
15
+ }
16
+ if (body instanceof ArrayBuffer)
17
+ return new Uint8Array(body);
18
+ return undefined;
19
+ }
20
+ /**
21
+ * What the unflagged path makes of these bytes, step for step as axios does:
22
+ * UTF-8 (`Buffer#toString`), a leading BOM dropped, then its default
23
+ * `transformResponse` — a non-empty string parsed as JSON when it parses.
24
+ */
25
+ function unflaggedBody(bytes) {
26
+ const decoded = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString('utf8');
27
+ const text = decoded.charCodeAt(0) === 0xfeff ? decoded.slice(1) : decoded;
28
+ if (text === '')
29
+ return text;
30
+ try {
31
+ return JSON.parse(text);
32
+ }
33
+ catch {
34
+ return text;
35
+ }
36
+ }
37
+ /**
38
+ * The first `charset` parameter of the answer's `Content-Type`, unquoted, or
39
+ * `undefined`. Parameters are split on `;` outside quoted strings. Headers
40
+ * are the wire's, from outside the type system. Plain string code.
41
+ */
42
+ function charsetOf(headers) {
43
+ if (typeof headers !== 'object' || headers === null)
44
+ return undefined;
45
+ let type;
46
+ for (const [name, value] of Object.entries(headers)) {
47
+ if (name.toLowerCase() === 'content-type' && typeof value === 'string') {
48
+ type = value;
49
+ }
50
+ }
51
+ if (type === undefined)
52
+ return undefined;
53
+ for (const parameter of parametersOf(type)) {
54
+ const at = parameter.indexOf('=');
55
+ if (at < 0)
56
+ continue;
57
+ if (parameter.slice(0, at).trim().toLowerCase() !== 'charset')
58
+ continue;
59
+ return unquoted(parameter.slice(at + 1).trim());
60
+ }
61
+ return undefined;
62
+ }
63
+ /** A media type's parameters: split on `;` outside quoted strings. */
64
+ function parametersOf(type) {
65
+ const parts = [];
66
+ let current = '';
67
+ let quoted = false;
68
+ let escaped = false;
69
+ for (const char of type) {
70
+ if (escaped) {
71
+ escaped = false;
72
+ }
73
+ else if (quoted && char === '\\') {
74
+ escaped = true;
75
+ }
76
+ else if (char === '"') {
77
+ quoted = !quoted;
78
+ }
79
+ else if (char === ';' && !quoted) {
80
+ parts.push(current);
81
+ current = '';
82
+ continue;
83
+ }
84
+ current += char;
85
+ }
86
+ parts.push(current);
87
+ return parts.slice(1);
88
+ }
89
+ /** A parameter value without its quotes and escapes, when it is quoted. */
90
+ function unquoted(value) {
91
+ if (!(value.length >= 2 && value.startsWith('"') && value.endsWith('"'))) {
92
+ return value;
93
+ }
94
+ let out = '';
95
+ let escaped = false;
96
+ for (const char of value.slice(1, -1)) {
97
+ if (escaped) {
98
+ out += char;
99
+ escaped = false;
100
+ }
101
+ else if (char === '\\') {
102
+ escaped = true;
103
+ }
104
+ else {
105
+ out += char;
106
+ }
107
+ }
108
+ return out;
109
+ }
110
+ /** The declared charset's decoder when `TextDecoder` knows it, else UTF-8. */
111
+ function decoderFor(charset) {
112
+ if (charset !== undefined) {
113
+ try {
114
+ return new TextDecoder(charset, { ignoreBOM: true });
115
+ }
116
+ catch {
117
+ // A label `TextDecoder` does not know: UTF-8.
118
+ }
119
+ }
120
+ return new TextDecoder('utf-8', { ignoreBOM: true });
121
+ }
122
+ /**
123
+ * A `rawText` answer as the connection reads it: `data` is what the
124
+ * unflagged path has, and the exact text and raw byte length are kept beside
125
+ * it. A body that is not bytes (a client that made something else of it) is
126
+ * left as it is.
127
+ */
128
+ function rawTextAnswer(answer) {
129
+ const bytes = bytesOf(answer.data);
130
+ if (bytes === undefined)
131
+ return answer;
132
+ const internal = unflaggedBody(bytes);
133
+ const read = { ...answer, data: internal };
134
+ EXACT.set(read, {
135
+ text: decoderFor(charsetOf(answer.headers)).decode(bytes),
136
+ bytes: bytes.byteLength,
137
+ internal,
138
+ });
139
+ return read;
140
+ }
141
+ /** The same exact text on another object carrying the same answer. */
142
+ function carryExact(from, to) {
143
+ const exact = EXACT.get(from);
144
+ if (exact !== undefined)
145
+ EXACT.set(to, exact);
146
+ }
147
+ /** A `rawText` answer's raw byte length, else `undefined`. */
148
+ function rawByteLength(answer) {
149
+ return EXACT.get(answer)?.bytes;
150
+ }
151
+ /**
152
+ * The caller's view, at the connection's door: a `rawText` answer's `data`
153
+ * becomes its exact text. Every consumer inside has read it by then.
154
+ */
155
+ function toCallerView(answer) {
156
+ const exact = EXACT.get(answer);
157
+ if (exact !== undefined)
158
+ answer.data = exact.text;
159
+ }
160
+ /**
161
+ * The body as consumers inside read it, for one that sits outside the
162
+ * connection's door (the check replay of `createConnection`): what the
163
+ * unflagged path has, whether or not the caller's view was applied.
164
+ */
165
+ function internalBody(answer) {
166
+ const exact = EXACT.get(answer);
167
+ return exact === undefined ? answer.data : exact.internal;
168
+ }
@@ -91,7 +91,9 @@ export type HttpFailure = Error & IAbapConnectionError & {
91
91
  * `Request failed with status code <n>`, built from the status), else the
92
92
  * code (`ECONNREFUSED`, `ECONNABORTED`, …) and `The request failed: <code>`.
93
93
  */
94
- export declare function httpFailure(thrown: unknown): HttpFailure;
94
+ export declare function httpFailure(thrown: unknown,
95
+ /** The request's `rawText`: SAP's answer as bytes, read as `rawTextAnswer`. */
96
+ rawText?: boolean): HttpFailure;
95
97
  /**
96
98
  * The wire's error as it arrived: the value an `httpFailure` was made from,
97
99
  * or `value` itself. For `IAuthRejection.error` only — never for a consumer.
@@ -1 +1 @@
1
- {"version":3,"file":"failureFacts.d.ts","sourceRoot":"","sources":["../../src/connection/failureFacts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAEnB,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEhE,uEAAuE;AACvE,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAK7D;AAMD;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAkBrE;AAcD;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAa1D;AAKD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAa/D;AAsBD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAY5D;AAED,2CAA2C;AAC3C,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,CAAC,EAAE,aAAa,CAAC;IAC7B,mEAAmE;IACnE,QAAQ,CAAC,QAAQ,CAAC,EAA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;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAIjD"}
@@ -27,6 +27,7 @@ exports.failureCopy = failureCopy;
27
27
  exports.httpFailure = httpFailure;
28
28
  exports.asArrived = asArrived;
29
29
  const interfaces_adt_connection_1 = require("@mcp-abap-adt/interfaces-adt-connection");
30
+ const exactText_js_1 = require("./exactText.js");
30
31
  /** An own data property of `source`, read without running a getter. */
31
32
  function ownData(source, name) {
32
33
  const descriptor = Object.getOwnPropertyDescriptor(source, name);
@@ -231,17 +232,39 @@ function answerOf(thrown) {
231
232
  if (!isInteger(status))
232
233
  return undefined;
233
234
  const statusText = ownData(response, 'statusText');
234
- return {
235
+ const copy = {
235
236
  status,
236
237
  ...(typeof statusText === 'string' ? { statusText } : {}),
237
238
  headers: ownData(response, 'headers'),
238
239
  data: ownData(response, 'data'),
239
240
  };
241
+ // A `rawText` answer's exact text goes with every copy of it.
242
+ (0, exactText_js_1.carryExact)(response, copy);
243
+ return copy;
240
244
  }
241
245
  catch {
242
246
  return undefined;
243
247
  }
244
248
  }
249
+ /**
250
+ * A `rawText` rejection's own `response.data` set to what the connection
251
+ * reads — the body the unflagged path has — so nothing inside, the
252
+ * credential provider included, sees the bytes. A value that will not take
253
+ * it is left as it is.
254
+ */
255
+ function arrivedBody(thrown, data) {
256
+ if (typeof thrown !== 'object' || thrown === null)
257
+ return;
258
+ try {
259
+ const response = ownData(thrown, 'response');
260
+ if (typeof response === 'object' && response !== null) {
261
+ Reflect.set(response, 'data', data);
262
+ }
263
+ }
264
+ catch {
265
+ // A response that will not be read or written: left as it arrived.
266
+ }
267
+ }
245
268
  /**
246
269
  * What an HTTP client's rejection becomes before it leaves the wire: an
247
270
  * `Error` in fixed words with its facts and SAP's answer, and nothing else.
@@ -253,8 +276,15 @@ function answerOf(thrown) {
253
276
  * `Request failed with status code <n>`, built from the status), else the
254
277
  * code (`ECONNREFUSED`, `ECONNABORTED`, …) and `The request failed: <code>`.
255
278
  */
256
- function httpFailure(thrown) {
257
- const response = answerOf(thrown);
279
+ function httpFailure(thrown,
280
+ /** The request's `rawText`: SAP's answer as bytes, read as `rawTextAnswer`. */
281
+ rawText = false) {
282
+ const copied = answerOf(thrown);
283
+ const response = rawText && copied !== undefined ? (0, exactText_js_1.rawTextAnswer)(copied) : copied;
284
+ // The provider reads the wire's error as it arrived (`asArrived`): its
285
+ // body, too, is what the unflagged path has, never the bytes.
286
+ if (rawText && response !== undefined)
287
+ arrivedBody(thrown, response.data);
258
288
  const code = failureCode(thrown);
259
289
  const error = new Error(response !== undefined
260
290
  ? `Request failed with status code ${response.status}`
@@ -1 +1 @@
1
- {"version":3,"file":"quietLine.d.ts","sourceRoot":"","sources":["../../src/connection/quietLine.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,oDAAoD;AACpD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,4EAA4E;AAC5E,eAAO,MAAM,cAAc,qBAAqB,CAAC;AAEjD;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAgB1C;AA+BD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAW/C;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACvB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GACzC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,CAYrC"}
1
+ {"version":3,"file":"quietLine.d.ts","sourceRoot":"","sources":["../../src/connection/quietLine.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,oDAAoD;AACpD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,4EAA4E;AAC5E,eAAO,MAAM,cAAc,qBAAqB,CAAC;AAEjD;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAgB1C;AA+BD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAW/C;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACvB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GACzC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,CAarC"}
@@ -12,6 +12,7 @@ exports.UNPARSABLE_URL = void 0;
12
12
  exports.pathOf = pathOf;
13
13
  exports.byteCount = byteCount;
14
14
  exports.quietLine = quietLine;
15
+ const exactText_js_1 = require("./exactText.js");
15
16
  /** What a quiet line names for a URL that does not parse: nothing of it. */
16
17
  exports.UNPARSABLE_URL = '<unparsable url>';
17
18
  /**
@@ -103,7 +104,8 @@ function quietLine(rawMethod, url, answer) {
103
104
  if (answer === undefined || !Number.isInteger(answer.status)) {
104
105
  return { line: `${method} ${path} → no answer`, facts: { method, path } };
105
106
  }
106
- const bytes = byteCount(answer.data);
107
+ // A `rawText` answer counts the bytes that arrived.
108
+ const bytes = (0, exactText_js_1.rawByteLength)(answer) ?? byteCount(answer.data);
107
109
  return {
108
110
  line: `${method} ${path} → ${answer.status} (${bytes} bytes)`,
109
111
  facts: { method, path, status: answer.status, bytes },
@@ -1 +1 @@
1
- {"version":3,"file":"withCheckRelogon.d.ts","sourceRoot":"","sources":["../../src/connection/withCheckRelogon.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI/D;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,SAAS,iBAAiB,EACpE,UAAU,EAAE,WAAW;AACvB;;;;GAIG;AACH,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,WAAW,GACrC,WAAW,CA4Db"}
1
+ {"version":3,"file":"withCheckRelogon.d.ts","sourceRoot":"","sources":["../../src/connection/withCheckRelogon.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAK/D;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,SAAS,iBAAiB,EACpE,UAAU,EAAE,WAAW;AACvB;;;;GAIG;AACH,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,WAAW,GACrC,WAAW,CA+Db"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withCheckRelogon = withCheckRelogon;
4
4
  const interfaces_adt_connection_1 = require("@mcp-abap-adt/interfaces-adt-connection");
5
5
  const AbstractAbapConnection_js_1 = require("./AbstractAbapConnection.js");
6
+ const exactText_js_1 = require("./exactText.js");
6
7
  const IAdtTransport_js_1 = require("./IAdtTransport.js");
7
8
  const statefulRequest_js_1 = require("./statefulRequest.js");
8
9
  /**
@@ -46,9 +47,12 @@ fresh) {
46
47
  if (!eligible || closing || !(0, AbstractAbapConnection_js_1.carriesSessionLost)(error))
47
48
  throw error;
48
49
  const refusal = (0, IAdtTransport_js_1.refusalOf)(error);
50
+ // The body as the connection read it: `rawText` changes only the
51
+ // caller's view, applied at the connection's door below this replay.
52
+ const body = refusal === null ? undefined : (0, exactText_js_1.internalBody)(refusal);
49
53
  if (refusal?.status !== 403 ||
50
- typeof refusal.data !== 'string' ||
51
- !refusal.data.includes('CSRF token validation failed'))
54
+ typeof body !== 'string' ||
55
+ !body.includes('CSRF token validation failed'))
52
56
  throw error;
53
57
  const replacement = fresh(request.noLog === true);
54
58
  let stopped;
package/docs/USAGE.md CHANGED
@@ -855,8 +855,9 @@ check sent with `noResend: true` is not retried: the refusal is its answer.
855
855
 
856
856
  ### Request options: `noResend`, `noLog`, `stateless`
857
857
 
858
- Three optional flags of `IAbapRequestOptions` (25.1.0) change one request and
859
- nothing else; a request without them behaves as before. In short:
858
+ Optional flags of `IAbapRequestOptions` (`noResend`, `noLog`, `stateless`:
859
+ 25.1.0; `rawText`: 25.2.0) change one request and nothing else; a request
860
+ without them behaves as before. In short:
860
861
 
861
862
  - `noResend: true` — sent once: no CSRF recovery, no resend after the
862
863
  credential's renewal (the provider is not asked), no resend on a dead pooled
@@ -872,6 +873,16 @@ nothing else; a request without them behaves as before. In short:
872
873
  - `stateless: true` — stateless on HTTP and RFC whatever the session mode, over
873
874
  the caller's own `x-sap-adt-sessiontype` header in any letter case; the header
874
875
  and the `sap-contextid` cookie are stripped; the session mode stays.
876
+ - `rawText: true` — only the body you receive as the final answer changes: a
877
+ success's `data`, or your error's `response.data`, is the exact text SAP
878
+ sent. Everything inside the connection — CSRF recovery, session verdicts,
879
+ replays, the credential provider, logs, the error's shape — reads what it
880
+ reads without the flag, on the shipped HTTP client; an injected `httpClient`
881
+ with defaults of its own (`transitional.forcedJSONParsing`, `responseType`)
882
+ owns how its bodies look. HTTP
883
+ decodes the declared charset when `TextDecoder` knows it, else UTF-8, the BOM
884
+ kept, non-fatally: an invalid byte reads as U+FFFD. `noLog` counts the bytes
885
+ that arrived. RFC: already the text of `MESSAGE_BODY`.
875
886
 
876
887
  The whole contract, and why `noResend` exists: [README — Request options](../README.md#request-options-noresend-nolog-stateless).
877
888
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-abap-adt/connection",
3
- "version": "25.1.0",
3
+ "version": "25.2.1",
4
4
  "description": "ABAP connection layer for MCP ABAP ADT server",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -52,7 +52,7 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@mcp-abap-adt/auth-errors": "^2.2.1",
55
- "@mcp-abap-adt/interfaces-adt-connection": "^5.2.0",
55
+ "@mcp-abap-adt/interfaces-adt-connection": "^5.3.0",
56
56
  "@mcp-abap-adt/interfaces-auth": "^7.5.0",
57
57
  "@mcp-abap-adt/interfaces-auth-sap": "^4.0.0",
58
58
  "@mcp-abap-adt/interfaces-network": "^2.0.1",
@@ -60,7 +60,7 @@
60
60
  "axios": "^1.16.0"
61
61
  },
62
62
  "optionalDependencies": {
63
- "@mcp-abap-adt/sap-rfc-lite": "^0.4.0"
63
+ "@mcp-abap-adt/sap-rfc-lite": "^0.4.1"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@biomejs/biome": "^2.3.14",