@mcp-abap-adt/connection 25.0.1 → 25.2.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +104 -1
  2. package/README.md +97 -1
  3. package/dist/connection/AbstractAbapConnection.d.ts +12 -4
  4. package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
  5. package/dist/connection/AbstractAbapConnection.js +256 -81
  6. package/dist/connection/HttpTransport.d.ts +3 -1
  7. package/dist/connection/HttpTransport.d.ts.map +1 -1
  8. package/dist/connection/HttpTransport.js +76 -17
  9. package/dist/connection/IAdtTransport.d.ts +38 -1
  10. package/dist/connection/IAdtTransport.d.ts.map +1 -1
  11. package/dist/connection/RfcTransport.d.ts.map +1 -1
  12. package/dist/connection/RfcTransport.js +67 -24
  13. package/dist/connection/createConnection.d.ts.map +1 -1
  14. package/dist/connection/createConnection.js +6 -1
  15. package/dist/connection/csrfRetry.d.ts +10 -0
  16. package/dist/connection/csrfRetry.d.ts.map +1 -0
  17. package/dist/connection/csrfRetry.js +43 -0
  18. package/dist/connection/exactText.d.ts +43 -0
  19. package/dist/connection/exactText.d.ts.map +1 -0
  20. package/dist/connection/exactText.js +168 -0
  21. package/dist/connection/failureFacts.d.ts +3 -1
  22. package/dist/connection/failureFacts.d.ts.map +1 -1
  23. package/dist/connection/failureFacts.js +33 -3
  24. package/dist/connection/quietLine.d.ts +44 -0
  25. package/dist/connection/quietLine.d.ts.map +1 -0
  26. package/dist/connection/quietLine.js +113 -0
  27. package/dist/connection/statefulRequest.d.ts +13 -0
  28. package/dist/connection/statefulRequest.d.ts.map +1 -1
  29. package/dist/connection/statefulRequest.js +27 -1
  30. package/dist/connection/withCheckRelogon.d.ts +7 -1
  31. package/dist/connection/withCheckRelogon.d.ts.map +1 -1
  32. package/dist/connection/withCheckRelogon.js +18 -5
  33. package/docs/STATEFUL_SESSION_GUIDE.md +5 -1
  34. package/docs/USAGE.md +38 -2
  35. package/package.json +2 -2
@@ -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");
@@ -165,6 +166,10 @@ function deletesCookie(attributes) {
165
166
  }
166
167
  /** The cookie that names a stateful ABAP context. */
167
168
  const CONTEXT_COOKIE = 'sap-contextid';
169
+ /** How an exchange's answer is folded in: quietly for a `noLog` request's. */
170
+ function quietIngest(context) {
171
+ return context.noLog ? { noLog: true } : undefined;
172
+ }
168
173
  /** The platform's logoff, which answers `200` while expiring the session cookie. */
169
174
  const ICF_LOGOFF_PATH = '/sap/public/bc/icf/logoff';
170
175
  /**
@@ -399,10 +404,10 @@ class HttpTransport {
399
404
  * establishment or a replacement is a question about the session's lifetime,
400
405
  * which this has no way to answer and no business answering.
401
406
  */
402
- ingest(headers) {
407
+ ingest(headers, options) {
403
408
  if (!headers)
404
409
  return;
405
- this.rememberAppServer(headers);
410
+ this.rememberAppServer(headers, options?.noLog === true);
406
411
  const setCookie = headers['set-cookie'];
407
412
  // Nothing was set, so nothing is folded in — not even the client, which is
408
413
  // an assertion ON the cookies a response brought rather than a cookie of
@@ -687,7 +692,9 @@ class HttpTransport {
687
692
  // which the server says by answering 404 there. Asked after a refused
688
693
  // connection or a network error, it would ask a host that is not
689
694
  // answering to answer a different path.
690
- if (index > 0 && !absentEndpoint(last))
695
+ // `noResend`: the fetch is one request, the fallback a second — the
696
+ // first answer, whatever it is, is the request's.
697
+ if (index > 0 && (context.noResend || !absentEndpoint(last)))
691
698
  break;
692
699
  try {
693
700
  // Authorized per request: a provider may renew behind the call.
@@ -701,14 +708,28 @@ class HttpTransport {
701
708
  ...context.extraHeaders,
702
709
  ...csrfConfig_js_1.CSRF_CONFIG.REQUIRED_HEADERS,
703
710
  },
711
+ // The flags of the request the token is fetched for: under
712
+ // `noResend` the fetch, too, goes once and follows no redirect.
713
+ ...(context.noResend ? { noResend: true } : {}),
714
+ ...(context.noLog ? { noLog: true } : {}),
715
+ // `rawText`: under `noResend` this answer may be the request's.
716
+ ...(context.rawText ? { rawText: true } : {}),
704
717
  });
705
718
  // Handed up BEFORE the token is read: the cookies are the session,
706
719
  // and a fold that only happened on success would lose the session a
707
720
  // tokenless answer still opened. And before the fold: an answer the
708
721
  // connection refuses as a gone session's throws here, and nothing
709
722
  // of it reaches the jar.
723
+ //
724
+ // `noResend`: a status the client resolved outside `2xx` is SAP's
725
+ // refusal, and goes on as one — its status and body, the shape any
726
+ // refusal has — to the handling below, which observes it once.
727
+ if (context.noResend &&
728
+ (response.status < 200 || response.status >= 300)) {
729
+ throw (0, failureFacts_js_1.httpFailure)({ response });
730
+ }
710
731
  context.observe(response.headers);
711
- this.ingest(headerFields(response.headers));
732
+ this.ingest(headerFields(response.headers), quietIngest(context));
712
733
  const token = csrfTokenIn(response.headers);
713
734
  if (token !== undefined) {
714
735
  this.token = token;
@@ -734,7 +755,7 @@ class HttpTransport {
734
755
  // A refusal can still carry the cookies that matter — handed up
735
756
  // first, so one the connection refuses is not folded in.
736
757
  context.observe(headers);
737
- this.ingest(headers);
758
+ this.ingest(headers, quietIngest(context));
738
759
  }
739
760
  // A refused logon, named as one — after its cookies are in. What to
740
761
  // do about it is not the wire's to decide.
@@ -744,10 +765,15 @@ class HttpTransport {
744
765
  // …and the token itself. SAP answers 405 to a GET on some endpoints
745
766
  // and puts the token in the header anyway, and other refusals carry
746
767
  // one too.
747
- const onError = csrfTokenIn(headers);
768
+ //
769
+ // `noResend`: only a `2xx` fetch yields a token; a refusal is the
770
+ // request's answer.
771
+ const onError = context.noResend ? undefined : csrfTokenIn(headers);
748
772
  if (onError !== undefined) {
749
773
  this.token = onError;
750
- this.logger?.debug('CSRF token arrived on a refusal, and is kept');
774
+ if (!context.noLog) {
775
+ this.logger?.debug('CSRF token arrived on a refusal, and is kept');
776
+ }
751
777
  return;
752
778
  }
753
779
  }
@@ -777,12 +803,16 @@ class HttpTransport {
777
803
  * Take the application server's name from a response, if it named one. Only
778
804
  * ever from the server's own answer — never guessed.
779
805
  */
780
- rememberAppServer(headers) {
806
+ rememberAppServer(headers,
807
+ /** A `noLog` request's answer: the server is kept, its name not logged. */
808
+ quiet) {
781
809
  const key = Object.keys(headers).find((k) => k.toLowerCase() === 'sap-adt-saplb');
782
810
  const value = key ? headers[key] : undefined;
783
811
  if (typeof value === 'string' && value && value !== this.appServer) {
784
812
  this.appServer = value;
785
- this.logger?.debug(`Session is on application server ${value}`);
813
+ if (!quiet) {
814
+ this.logger?.debug(`Session is on application server ${value}`);
815
+ }
786
816
  }
787
817
  }
788
818
  /**
@@ -807,6 +837,15 @@ class HttpTransport {
807
837
  ...(stateful ? this.sessionTypeHeaders() : {}),
808
838
  ...headers,
809
839
  };
840
+ // `stateless`: the caller's own session header goes, in whatever letter
841
+ // case it was written; the context cookie is filtered below, as for every
842
+ // request that is not stateful.
843
+ if (request.stateless) {
844
+ for (const name of Object.keys(dressed)) {
845
+ if ((0, statefulRequest_js_1.isSessionTypeHeader)(name))
846
+ delete dressed[name];
847
+ }
848
+ }
810
849
  // The caller's spelling of the client goes; the wire's goes in last. It is
811
850
  // the same value — refuseAnotherClient saw to that — said once.
812
851
  for (const name of Object.keys(dressed)) {
@@ -1061,10 +1100,15 @@ class HttpTransport {
1061
1100
  Cookie: snapshot.cookies,
1062
1101
  },
1063
1102
  }, written);
1064
- this.logger?.debug('Told the server the session is finished');
1103
+ // `noLog`: a logoff a `noLog` request's answer caused writes no line.
1104
+ if (!context.noLog) {
1105
+ this.logger?.debug('Told the server the session is finished');
1106
+ }
1065
1107
  }
1066
1108
  catch (error) {
1067
- this.logger?.debug(`Could not tell the server the session is finished: ${(0, failureFacts_js_1.factWords)(error)}`);
1109
+ if (!context.noLog) {
1110
+ this.logger?.debug(`Could not tell the server the session is finished: ${(0, failureFacts_js_1.factWords)(error)}`);
1111
+ }
1068
1112
  }
1069
1113
  }
1070
1114
  /**
@@ -1159,7 +1203,11 @@ class HttpTransport {
1159
1203
  * The risk, stated: a server that read the request and died before a byte of
1160
1204
  * its answer would run it twice.
1161
1205
  */
1162
- async sendPooled(config) {
1206
+ async sendPooled(config,
1207
+ /** The request's `noResend`: sent once, its failure the caller's. */
1208
+ once,
1209
+ /** The request's `noLog`: the wire writes no line about it. */
1210
+ quiet) {
1163
1211
  const attempt = {};
1164
1212
  try {
1165
1213
  return await pooledAttempts.run(attempt, () => this.client()({
@@ -1171,12 +1219,16 @@ class HttpTransport {
1171
1219
  }
1172
1220
  catch (error) {
1173
1221
  const fresh = this.fresh;
1174
- if (fresh === null ||
1222
+ if (once ||
1223
+ fresh === null ||
1175
1224
  !resendable(config.data) ||
1176
1225
  !diedOnPooledSocket(error, attempt)) {
1177
1226
  throw error;
1178
1227
  }
1179
- this.logger?.debug('HTTP: a pooled connection closed before any answer; the request is sent once more on a new connection');
1228
+ // `noLog`: the request's one line is the connection's quiet one.
1229
+ if (!quiet) {
1230
+ this.logger?.debug('HTTP: a pooled connection closed before any answer; the request is sent once more on a new connection');
1231
+ }
1180
1232
  return this.client()({
1181
1233
  ...config,
1182
1234
  httpAgent: fresh.http,
@@ -1189,6 +1241,8 @@ class HttpTransport {
1189
1241
  redirects) {
1190
1242
  const config = {
1191
1243
  ...(redirects ?? {}),
1244
+ // `noResend`: following a redirect would send the request again.
1245
+ ...(request.noResend ? { maxRedirects: 0 } : {}),
1192
1246
  // The write is the point `disconnect()` resolves at: the request's
1193
1247
  // `finish`, emitted once its bytes are handed to the socket — not when
1194
1248
  // the server answers, which it may do minutes later or never.
@@ -1223,6 +1277,10 @@ class HttpTransport {
1223
1277
  ...(request.validateStatus !== undefined
1224
1278
  ? { validateStatus: request.validateStatus }
1225
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' } : {}),
1226
1284
  };
1227
1285
  // A logoff opens a socket of its own and is never resent: its answer is
1228
1286
  // not read, and its write is what `disconnect()` resolves at.
@@ -1231,20 +1289,21 @@ class HttpTransport {
1231
1289
  response =
1232
1290
  written !== undefined
1233
1291
  ? await this.client()(config)
1234
- : await this.sendPooled(config);
1292
+ : await this.sendPooled(config, request.noResend === true, request.noLog === true);
1235
1293
  }
1236
1294
  catch (error) {
1237
1295
  // Never as the client threw it: axios's error holds this request's
1238
1296
  // config — its credential headers among it — and words naming the host.
1239
1297
  // SAP's answer and the code go up; nothing else of it does.
1240
- throw (0, failureFacts_js_1.httpFailure)(error);
1298
+ throw (0, failureFacts_js_1.httpFailure)(error, request.rawText === true);
1241
1299
  }
1242
- return {
1300
+ const answer = {
1243
1301
  status: response.status,
1244
1302
  statusText: response.statusText,
1245
1303
  headers: response.headers,
1246
1304
  data: response.data,
1247
1305
  };
1306
+ return request.rawText ? (0, exactText_js_1.rawTextAnswer)(answer) : answer;
1248
1307
  }
1249
1308
  }
1250
1309
  exports.HttpTransport = HttpTransport;
@@ -55,6 +55,30 @@ export interface IAdtTransportRequest {
55
55
  * `HttpTransport.dress`.
56
56
  */
57
57
  stateful?: boolean;
58
+ /**
59
+ * The caller's `stateless: true`: the request goes stateless whatever the
60
+ * session mode and whatever session header it carries. Wins in
61
+ * `isStatefulRequest`; the wire strips a conflicting `x-sap-adt-sessiontype`
62
+ * header, in any letter case, and the `sap-contextid` cookie from it.
63
+ */
64
+ stateless?: true | undefined;
65
+ /**
66
+ * The caller's `noResend: true`: the wire sends the request once — no resend
67
+ * on a dead pooled socket — and follows no redirect.
68
+ */
69
+ noResend?: true | undefined;
70
+ /**
71
+ * The caller's `noLog: true`: a line the wire writes about the request
72
+ * carries the method, the path without its query, the integer status and
73
+ * the byte count, and nothing else.
74
+ */
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;
58
82
  }
59
83
  /** What came back, in the terms every transport can produce. */
60
84
  export interface IAdtTransportResponse {
@@ -98,6 +122,15 @@ export interface IAdtSessionContext {
98
122
  logon(target: ILogonTarget): Promise<void>;
99
123
  /** Anything the conversation carries — the ADT connection id, today. */
100
124
  extraHeaders?: Record<string, string>;
125
+ /**
126
+ * The flags of the request this exchange is made for — its CSRF token
127
+ * fetch, say: `noResend` sends the exchange once and follows no redirect,
128
+ * `noLog` keeps what it sees out of the wire's lines.
129
+ */
130
+ noResend?: true | undefined;
131
+ noLog?: true | undefined;
132
+ /** The request's `rawText`: under `noResend` the exchange's answer may be its answer. */
133
+ rawText?: true | undefined;
101
134
  /** Where to hand each answer, so the connection sees what the wire saw. */
102
135
  observe: (headers: unknown) => void;
103
136
  }
@@ -183,7 +216,11 @@ export interface IAdtTransport {
183
216
  * establishment or a replacement is a question about the session's lifetime,
184
217
  * and it is answered above.
185
218
  */
186
- ingest(headers?: Record<string, unknown>): void;
219
+ ingest(headers?: Record<string, unknown>,
220
+ /** The answer is a `noLog` request's: nothing of it reaches a line. */
221
+ options?: {
222
+ noLog?: true | undefined;
223
+ }): void;
187
224
  /** What to put on the `Cookie` header, or `null` for a wire that has none. */
188
225
  cookies(): string | null;
189
226
  /**
@@ -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;IAC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BAAqB,CAAC;IAwBzE;;;;;;;;;;;;;;;;;OAiBG;YACW,aAAa;YAiBb,WAAW;IAiGzB;;;OAGG;YACW,gBAAgB;IAqB9B;;;OAGG;IACH,OAAO,CAAC,WAAW;IAQnB,iEAAiE;IACjE,OAAO,CAAC,aAAa;IAOrB;;;OAGG;YACW,mBAAmB;IAQjC;;;;;OAKG;YACW,OAAO;IAgBrB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAgBnB,gEAAgE;YAClD,eAAe;IAM7B;;;;OAIG;IACH,OAAO,CAAC,UAAU;IAMlB;;;;;;;;;;OAUG;YACW,UAAU;IAwBxB;;;;OAIG;IACH,OAAO,CAAC,UAAU;YAQJ,YAAY;YAYZ,KAAK;CAyOpB"}
@@ -565,12 +565,12 @@ class RfcTransport {
565
565
  if (otherLanguage(language, this.languageOf(parameters)) !== undefined) {
566
566
  return await this.carryOnThrowaway(request, inLanguage(parameters, language), generation, passport);
567
567
  }
568
- const opened = await this.openOwn(parameters, generation);
568
+ const opened = await this.openOwn(parameters, generation, request.noLog === true);
569
569
  // Checked again after the await: close() may have run since openOwn()
570
570
  // checked, and a conversation of a closed wire must not become the
571
571
  // kept one of the next.
572
572
  if (generation !== this.generation) {
573
- await this.closeQuietly(opened);
573
+ await this.closeQuietly(opened, request.noLog === true);
574
574
  throw new Error('RFC transport was closed while the call was being opened; nothing was sent.');
575
575
  }
576
576
  if (typeof opened.resetServerContext !== 'function') {
@@ -581,14 +581,16 @@ class RfcTransport {
581
581
  return await this.carry(request, opened, generation, passport);
582
582
  }
583
583
  finally {
584
- await this.closeUnlessReleased(opened);
584
+ await this.closeUnlessReleased(opened, request.noLog === true);
585
585
  }
586
586
  }
587
587
  this.canReset = true;
588
588
  this.stateless = opened;
589
589
  this.statelessLanguage = this.languageOf(parameters);
590
590
  kept = opened;
591
- this.logger?.debug('RFC stateless conversation opened (reset per call)');
591
+ if (!request.noLog) {
592
+ this.logger?.debug('RFC stateless conversation opened (reset per call)');
593
+ }
592
594
  }
593
595
  else if (otherLanguage(language, this.statelessLanguage) !== undefined) {
594
596
  return await this.carryOnThrowaway(request, inLanguage(await this.logonParameters(), language), generation, passport);
@@ -611,9 +613,11 @@ class RfcTransport {
611
613
  }
612
614
  catch (e) {
613
615
  // A context that could not be reset must not serve the next call.
614
- this.logQuietly(() => `RFC reset failed, dropping the conversation: ${failureWords(e)}`);
616
+ if (!request.noLog) {
617
+ this.logQuietly(() => `RFC reset failed, dropping the conversation: ${failureWords(e)}`);
618
+ }
615
619
  this.dropStateless(kept);
616
- await this.closeQuietly(kept);
620
+ await this.closeQuietly(kept, request.noLog === true);
617
621
  }
618
622
  }
619
623
  }
@@ -627,13 +631,15 @@ class RfcTransport {
627
631
  * answers, whatever the answer.
628
632
  */
629
633
  async carryOnThrowaway(request, parameters, generation, passport) {
630
- const own = await this.openOwn(parameters, generation);
634
+ const own = await this.openOwn(parameters, generation, request.noLog === true);
631
635
  try {
632
- this.logger?.debug('RFC conversation opened for one stateless call');
636
+ if (!request.noLog) {
637
+ this.logger?.debug('RFC conversation opened for one stateless call');
638
+ }
633
639
  return await this.carry(request, own, generation, passport);
634
640
  }
635
641
  finally {
636
- await this.closeUnlessReleased(own);
642
+ await this.closeUnlessReleased(own, request.noLog === true);
637
643
  }
638
644
  }
639
645
  /**
@@ -658,9 +664,11 @@ class RfcTransport {
658
664
  * A conversation used for one call, closed — unless an RFC error ended it:
659
665
  * the library has released it, and a close would only reject.
660
666
  */
661
- async closeUnlessReleased(conversation) {
667
+ async closeUnlessReleased(conversation,
668
+ /** A `noLog` request's conversation: a failed close writes no line. */
669
+ quiet = false) {
662
670
  if (conversation.alive)
663
- await this.closeQuietly(conversation);
671
+ await this.closeQuietly(conversation, quiet);
664
672
  }
665
673
  /**
666
674
  * A new conversation, logged on with `parameters`. The logon takes time
@@ -668,10 +676,12 @@ class RfcTransport {
668
676
  * closed again and nothing is sent — not a PUT, not a DELETE — on a wire
669
677
  * already given back.
670
678
  */
671
- async openOwn(parameters, generation) {
679
+ async openOwn(parameters, generation,
680
+ /** For a `noLog` request: a failed close writes no line. */
681
+ quiet = false) {
672
682
  const own = await this.openedWith(parameters);
673
683
  if (generation !== this.generation || !this.conversation?.alive) {
674
- await this.closeQuietly(own);
684
+ await this.closeQuietly(own, quiet);
675
685
  throw new Error('RFC transport was closed while the call was being opened; nothing was sent.');
676
686
  }
677
687
  return own;
@@ -757,12 +767,15 @@ class RfcTransport {
757
767
  // A broken logger must not stop a close; there is nowhere left to say so.
758
768
  }
759
769
  }
760
- async closeQuietly(conversation) {
770
+ async closeQuietly(conversation,
771
+ /** A `noLog` request's conversation: a failed close writes no line. */
772
+ quiet = false) {
761
773
  try {
762
774
  await conversation.close();
763
775
  }
764
776
  catch (e) {
765
- this.logQuietly(() => `RFC close error: ${failureWords(e)}`);
777
+ if (!quiet)
778
+ this.logQuietly(() => `RFC close error: ${failureWords(e)}`);
766
779
  }
767
780
  }
768
781
  async carry(request, conversation, generation, passport,
@@ -779,9 +792,28 @@ class RfcTransport {
779
792
  }
780
793
  // The passport is not a header field over RFC: it goes to the SDK as the
781
794
  // call's own (`passport`, read in `send()`).
782
- const headerFields = Object.entries(request.headers ?? {})
783
- .filter(([NAME]) => !isPassportHeader(NAME))
784
- .map(([NAME, VALUE]) => ({ NAME, VALUE: String(VALUE) }));
795
+ // `stateless`: the caller's own session header does not travel, in any
796
+ // letter case, and neither does the `sap-contextid` cookie — before
797
+ // anything else reads the fields.
798
+ const headerFields = [];
799
+ for (const [NAME, value] of Object.entries(request.headers ?? {})) {
800
+ if (isPassportHeader(NAME))
801
+ continue;
802
+ const VALUE = String(value);
803
+ if (!request.stateless) {
804
+ headerFields.push({ NAME, VALUE });
805
+ continue;
806
+ }
807
+ if ((0, statefulRequest_js_1.isSessionTypeHeader)(NAME))
808
+ continue;
809
+ if (NAME.trim().toLowerCase() === 'cookie') {
810
+ const kept = (0, statefulRequest_js_1.cookieWithoutContext)(VALUE);
811
+ if (kept !== undefined)
812
+ headerFields.push({ NAME, VALUE: kept });
813
+ continue;
814
+ }
815
+ headerFields.push({ NAME, VALUE });
816
+ }
785
817
  // ADT refuses a request with no Accept — `400 ExceptionResourceBadRequest:
786
818
  // Accept header missing`, measured on E19. Over HTTP axios supplies the
787
819
  // default and nobody notices; this endpoint forwards only what it is
@@ -799,14 +831,18 @@ class RfcTransport {
799
831
  VALUE: 'text/plain; charset=utf-8',
800
832
  });
801
833
  }
802
- this.logger?.debug(`RFC → ${method} ${uri}`);
834
+ // `noLog`: nothing before the answer, and nothing of the request at all —
835
+ // its one line is the quiet one below, once there is a status.
836
+ const noLog = request.noLog === true;
837
+ if (!noLog)
838
+ this.logger?.debug(`RFC → ${method} ${uri}`);
803
839
  // `RFC → METHOD URI` alone was not enough to debug a body that goes
804
840
  // missing or gets mis-serialised on the way to `SADT_REST_RFC_ENDPOINT`
805
841
  // (found chasing a `superPackage` that disappeared before it reached
806
842
  // SAP) — the actual bytes matter, so the debug channel carries them too
807
843
  // when the caller asks for it, redacted and clipped so a captured log is
808
844
  // safe to paste into an issue and small enough to want to.
809
- if (this.logger && this.options.logWire) {
845
+ if (this.logger && this.options.logWire && !noLog) {
810
846
  this.logger.debug(`RFC HEADERS: ${JSON.stringify(redactHeaders(headerFields))}`);
811
847
  // A GET has no body, and `RFC BODY (0 chars):` says nothing.
812
848
  if (body) {
@@ -871,7 +907,9 @@ class RfcTransport {
871
907
  const words = rfc?.codeString ?? UNNAMED;
872
908
  const text = `RFC call to SADT_REST_RFC_ENDPOINT failed: ${words}`;
873
909
  try {
874
- this.logger?.error(`RFC call failed: ${words}`);
910
+ // `noLog`: the request's one line is the connection's.
911
+ if (!noLog)
912
+ this.logger?.error(`RFC call failed: ${words}`);
875
913
  }
876
914
  catch {
877
915
  // A broken logger must not replace the call's failure.
@@ -911,16 +949,21 @@ class RfcTransport {
911
949
  const detected = statusFromExceptionXml(data);
912
950
  status = detected.code;
913
951
  statusText = detected.text;
914
- this.logger?.debug(`RFC: STATUS_LINE empty, read ${status} out of the exception XML`);
952
+ if (!noLog) {
953
+ this.logger?.debug(`RFC: STATUS_LINE empty, read ${status} out of the exception XML`);
954
+ }
915
955
  }
916
956
  if (!status) {
917
957
  status = 200;
918
958
  statusText = statusText || 'OK';
919
959
  }
920
- this.logger?.debug(`RFC ← ${status} ${statusText} (${data.length} bytes)`);
960
+ // `noLog`: the request's one line is the connection's quiet one.
961
+ if (!noLog) {
962
+ this.logger?.debug(`RFC ← ${status} ${statusText} (${data.length} bytes)`);
963
+ }
921
964
  // The line above already carries the size, so an empty body needs no line
922
965
  // of its own.
923
- if (this.logger && this.options.logWire && data) {
966
+ if (this.logger && this.options.logWire && data && !noLog) {
924
967
  this.logger.debug(`RFC RESPONSE BODY: ${this.clipped(data)}`);
925
968
  }
926
969
  const response = {
@@ -1 +1 @@
1
- {"version":3,"file":"createConnection.d.ts","sourceRoot":"","sources":["../../src/connection/createConnection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACd,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,KAAK,oBAAoB,EAAE,YAAY,EAAE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AW,CAAC;IACvC,MAAM,EAAE,QAAQ,CAAC;IACjB,SAAS,EAAE,KAAK,CAAC;IACjB;;;OAGG;IACH,MAAM,EAAE,aAAa,CAAC;IACtB,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;AAa/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;AAkBN,wBAAgB,gBAAgB,CAAC,WAAW,SAAS,aAAa,EAChE,IAAI,EAAE,cAAc,CAAC,WAAW,CAAC,GAChC,iBAAiB,CAAC,WAAW,CAAC,CAWhC"}
@@ -32,7 +32,12 @@ function createConnection(spec) {
32
32
  const connection = buildConnection(spec);
33
33
  if (spec.transport !== 'http')
34
34
  return connection;
35
- return (0, withCheckRelogon_js_1.withCheckRelogon)(connection, () => buildConnection({ ...spec, session: undefined }));
35
+ return (0, withCheckRelogon_js_1.withCheckRelogon)(connection, (quiet) => buildConnection({
36
+ ...spec,
37
+ session: undefined,
38
+ // A `noLog` call's replay: nothing of it reaches a log.
39
+ ...(quiet ? { logger: undefined, wireLogger: undefined } : {}),
40
+ }));
36
41
  }
37
42
  function buildConnection(spec) {
38
43
  const logger = spec.logger ?? null;
@@ -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