@mcp-abap-adt/connection 25.0.0 → 25.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +72 -1
- package/README.md +73 -2
- package/dist/connection/AbstractAbapConnection.d.ts +14 -4
- package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
- package/dist/connection/AbstractAbapConnection.js +192 -56
- package/dist/connection/HttpTransport.d.ts +3 -1
- package/dist/connection/HttpTransport.d.ts.map +1 -1
- package/dist/connection/HttpTransport.js +66 -15
- package/dist/connection/IAdtTransport.d.ts +30 -1
- package/dist/connection/IAdtTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.js +67 -24
- package/dist/connection/createConnection.d.ts.map +1 -1
- package/dist/connection/createConnection.js +12 -0
- package/dist/connection/quietLine.d.ts +44 -0
- package/dist/connection/quietLine.d.ts.map +1 -0
- package/dist/connection/quietLine.js +111 -0
- package/dist/connection/statefulRequest.d.ts +13 -0
- package/dist/connection/statefulRequest.d.ts.map +1 -1
- package/dist/connection/statefulRequest.js +27 -1
- package/dist/connection/withCheckRelogon.d.ts +14 -0
- package/dist/connection/withCheckRelogon.d.ts.map +1 -0
- package/dist/connection/withCheckRelogon.js +77 -0
- package/docs/STATEFUL_SESSION_GUIDE.md +5 -1
- package/docs/USAGE.md +48 -9
- package/package.json +2 -2
|
@@ -165,6 +165,10 @@ function deletesCookie(attributes) {
|
|
|
165
165
|
}
|
|
166
166
|
/** The cookie that names a stateful ABAP context. */
|
|
167
167
|
const CONTEXT_COOKIE = 'sap-contextid';
|
|
168
|
+
/** How an exchange's answer is folded in: quietly for a `noLog` request's. */
|
|
169
|
+
function quietIngest(context) {
|
|
170
|
+
return context.noLog ? { noLog: true } : undefined;
|
|
171
|
+
}
|
|
168
172
|
/** The platform's logoff, which answers `200` while expiring the session cookie. */
|
|
169
173
|
const ICF_LOGOFF_PATH = '/sap/public/bc/icf/logoff';
|
|
170
174
|
/**
|
|
@@ -399,10 +403,10 @@ class HttpTransport {
|
|
|
399
403
|
* establishment or a replacement is a question about the session's lifetime,
|
|
400
404
|
* which this has no way to answer and no business answering.
|
|
401
405
|
*/
|
|
402
|
-
ingest(headers) {
|
|
406
|
+
ingest(headers, options) {
|
|
403
407
|
if (!headers)
|
|
404
408
|
return;
|
|
405
|
-
this.rememberAppServer(headers);
|
|
409
|
+
this.rememberAppServer(headers, options?.noLog === true);
|
|
406
410
|
const setCookie = headers['set-cookie'];
|
|
407
411
|
// Nothing was set, so nothing is folded in — not even the client, which is
|
|
408
412
|
// an assertion ON the cookies a response brought rather than a cookie of
|
|
@@ -687,7 +691,9 @@ class HttpTransport {
|
|
|
687
691
|
// which the server says by answering 404 there. Asked after a refused
|
|
688
692
|
// connection or a network error, it would ask a host that is not
|
|
689
693
|
// answering to answer a different path.
|
|
690
|
-
|
|
694
|
+
// `noResend`: the fetch is one request, the fallback a second — the
|
|
695
|
+
// first answer, whatever it is, is the request's.
|
|
696
|
+
if (index > 0 && (context.noResend || !absentEndpoint(last)))
|
|
691
697
|
break;
|
|
692
698
|
try {
|
|
693
699
|
// Authorized per request: a provider may renew behind the call.
|
|
@@ -701,14 +707,26 @@ class HttpTransport {
|
|
|
701
707
|
...context.extraHeaders,
|
|
702
708
|
...csrfConfig_js_1.CSRF_CONFIG.REQUIRED_HEADERS,
|
|
703
709
|
},
|
|
710
|
+
// The flags of the request the token is fetched for: under
|
|
711
|
+
// `noResend` the fetch, too, goes once and follows no redirect.
|
|
712
|
+
...(context.noResend ? { noResend: true } : {}),
|
|
713
|
+
...(context.noLog ? { noLog: true } : {}),
|
|
704
714
|
});
|
|
705
715
|
// Handed up BEFORE the token is read: the cookies are the session,
|
|
706
716
|
// and a fold that only happened on success would lose the session a
|
|
707
717
|
// tokenless answer still opened. And before the fold: an answer the
|
|
708
718
|
// connection refuses as a gone session's throws here, and nothing
|
|
709
719
|
// of it reaches the jar.
|
|
720
|
+
//
|
|
721
|
+
// `noResend`: a status the client resolved outside `2xx` is SAP's
|
|
722
|
+
// refusal, and goes on as one — its status and body, the shape any
|
|
723
|
+
// refusal has — to the handling below, which observes it once.
|
|
724
|
+
if (context.noResend &&
|
|
725
|
+
(response.status < 200 || response.status >= 300)) {
|
|
726
|
+
throw (0, failureFacts_js_1.httpFailure)({ response });
|
|
727
|
+
}
|
|
710
728
|
context.observe(response.headers);
|
|
711
|
-
this.ingest(headerFields(response.headers));
|
|
729
|
+
this.ingest(headerFields(response.headers), quietIngest(context));
|
|
712
730
|
const token = csrfTokenIn(response.headers);
|
|
713
731
|
if (token !== undefined) {
|
|
714
732
|
this.token = token;
|
|
@@ -734,7 +752,7 @@ class HttpTransport {
|
|
|
734
752
|
// A refusal can still carry the cookies that matter — handed up
|
|
735
753
|
// first, so one the connection refuses is not folded in.
|
|
736
754
|
context.observe(headers);
|
|
737
|
-
this.ingest(headers);
|
|
755
|
+
this.ingest(headers, quietIngest(context));
|
|
738
756
|
}
|
|
739
757
|
// A refused logon, named as one — after its cookies are in. What to
|
|
740
758
|
// do about it is not the wire's to decide.
|
|
@@ -744,10 +762,15 @@ class HttpTransport {
|
|
|
744
762
|
// …and the token itself. SAP answers 405 to a GET on some endpoints
|
|
745
763
|
// and puts the token in the header anyway, and other refusals carry
|
|
746
764
|
// one too.
|
|
747
|
-
|
|
765
|
+
//
|
|
766
|
+
// `noResend`: only a `2xx` fetch yields a token; a refusal is the
|
|
767
|
+
// request's answer.
|
|
768
|
+
const onError = context.noResend ? undefined : csrfTokenIn(headers);
|
|
748
769
|
if (onError !== undefined) {
|
|
749
770
|
this.token = onError;
|
|
750
|
-
|
|
771
|
+
if (!context.noLog) {
|
|
772
|
+
this.logger?.debug('CSRF token arrived on a refusal, and is kept');
|
|
773
|
+
}
|
|
751
774
|
return;
|
|
752
775
|
}
|
|
753
776
|
}
|
|
@@ -777,12 +800,16 @@ class HttpTransport {
|
|
|
777
800
|
* Take the application server's name from a response, if it named one. Only
|
|
778
801
|
* ever from the server's own answer — never guessed.
|
|
779
802
|
*/
|
|
780
|
-
rememberAppServer(headers
|
|
803
|
+
rememberAppServer(headers,
|
|
804
|
+
/** A `noLog` request's answer: the server is kept, its name not logged. */
|
|
805
|
+
quiet) {
|
|
781
806
|
const key = Object.keys(headers).find((k) => k.toLowerCase() === 'sap-adt-saplb');
|
|
782
807
|
const value = key ? headers[key] : undefined;
|
|
783
808
|
if (typeof value === 'string' && value && value !== this.appServer) {
|
|
784
809
|
this.appServer = value;
|
|
785
|
-
|
|
810
|
+
if (!quiet) {
|
|
811
|
+
this.logger?.debug(`Session is on application server ${value}`);
|
|
812
|
+
}
|
|
786
813
|
}
|
|
787
814
|
}
|
|
788
815
|
/**
|
|
@@ -807,6 +834,15 @@ class HttpTransport {
|
|
|
807
834
|
...(stateful ? this.sessionTypeHeaders() : {}),
|
|
808
835
|
...headers,
|
|
809
836
|
};
|
|
837
|
+
// `stateless`: the caller's own session header goes, in whatever letter
|
|
838
|
+
// case it was written; the context cookie is filtered below, as for every
|
|
839
|
+
// request that is not stateful.
|
|
840
|
+
if (request.stateless) {
|
|
841
|
+
for (const name of Object.keys(dressed)) {
|
|
842
|
+
if ((0, statefulRequest_js_1.isSessionTypeHeader)(name))
|
|
843
|
+
delete dressed[name];
|
|
844
|
+
}
|
|
845
|
+
}
|
|
810
846
|
// The caller's spelling of the client goes; the wire's goes in last. It is
|
|
811
847
|
// the same value — refuseAnotherClient saw to that — said once.
|
|
812
848
|
for (const name of Object.keys(dressed)) {
|
|
@@ -1061,10 +1097,15 @@ class HttpTransport {
|
|
|
1061
1097
|
Cookie: snapshot.cookies,
|
|
1062
1098
|
},
|
|
1063
1099
|
}, written);
|
|
1064
|
-
|
|
1100
|
+
// `noLog`: a logoff a `noLog` request's answer caused writes no line.
|
|
1101
|
+
if (!context.noLog) {
|
|
1102
|
+
this.logger?.debug('Told the server the session is finished');
|
|
1103
|
+
}
|
|
1065
1104
|
}
|
|
1066
1105
|
catch (error) {
|
|
1067
|
-
|
|
1106
|
+
if (!context.noLog) {
|
|
1107
|
+
this.logger?.debug(`Could not tell the server the session is finished: ${(0, failureFacts_js_1.factWords)(error)}`);
|
|
1108
|
+
}
|
|
1068
1109
|
}
|
|
1069
1110
|
}
|
|
1070
1111
|
/**
|
|
@@ -1159,7 +1200,11 @@ class HttpTransport {
|
|
|
1159
1200
|
* The risk, stated: a server that read the request and died before a byte of
|
|
1160
1201
|
* its answer would run it twice.
|
|
1161
1202
|
*/
|
|
1162
|
-
async sendPooled(config
|
|
1203
|
+
async sendPooled(config,
|
|
1204
|
+
/** The request's `noResend`: sent once, its failure the caller's. */
|
|
1205
|
+
once,
|
|
1206
|
+
/** The request's `noLog`: the wire writes no line about it. */
|
|
1207
|
+
quiet) {
|
|
1163
1208
|
const attempt = {};
|
|
1164
1209
|
try {
|
|
1165
1210
|
return await pooledAttempts.run(attempt, () => this.client()({
|
|
@@ -1171,12 +1216,16 @@ class HttpTransport {
|
|
|
1171
1216
|
}
|
|
1172
1217
|
catch (error) {
|
|
1173
1218
|
const fresh = this.fresh;
|
|
1174
|
-
if (
|
|
1219
|
+
if (once ||
|
|
1220
|
+
fresh === null ||
|
|
1175
1221
|
!resendable(config.data) ||
|
|
1176
1222
|
!diedOnPooledSocket(error, attempt)) {
|
|
1177
1223
|
throw error;
|
|
1178
1224
|
}
|
|
1179
|
-
|
|
1225
|
+
// `noLog`: the request's one line is the connection's quiet one.
|
|
1226
|
+
if (!quiet) {
|
|
1227
|
+
this.logger?.debug('HTTP: a pooled connection closed before any answer; the request is sent once more on a new connection');
|
|
1228
|
+
}
|
|
1180
1229
|
return this.client()({
|
|
1181
1230
|
...config,
|
|
1182
1231
|
httpAgent: fresh.http,
|
|
@@ -1189,6 +1238,8 @@ class HttpTransport {
|
|
|
1189
1238
|
redirects) {
|
|
1190
1239
|
const config = {
|
|
1191
1240
|
...(redirects ?? {}),
|
|
1241
|
+
// `noResend`: following a redirect would send the request again.
|
|
1242
|
+
...(request.noResend ? { maxRedirects: 0 } : {}),
|
|
1192
1243
|
// The write is the point `disconnect()` resolves at: the request's
|
|
1193
1244
|
// `finish`, emitted once its bytes are handed to the socket — not when
|
|
1194
1245
|
// the server answers, which it may do minutes later or never.
|
|
@@ -1231,7 +1282,7 @@ class HttpTransport {
|
|
|
1231
1282
|
response =
|
|
1232
1283
|
written !== undefined
|
|
1233
1284
|
? await this.client()(config)
|
|
1234
|
-
: await this.sendPooled(config);
|
|
1285
|
+
: await this.sendPooled(config, request.noResend === true, request.noLog === true);
|
|
1235
1286
|
}
|
|
1236
1287
|
catch (error) {
|
|
1237
1288
|
// Never as the client threw it: axios's error holds this request's
|
|
@@ -55,6 +55,24 @@ 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;
|
|
58
76
|
}
|
|
59
77
|
/** What came back, in the terms every transport can produce. */
|
|
60
78
|
export interface IAdtTransportResponse {
|
|
@@ -98,6 +116,13 @@ export interface IAdtSessionContext {
|
|
|
98
116
|
logon(target: ILogonTarget): Promise<void>;
|
|
99
117
|
/** Anything the conversation carries — the ADT connection id, today. */
|
|
100
118
|
extraHeaders?: Record<string, string>;
|
|
119
|
+
/**
|
|
120
|
+
* The flags of the request this exchange is made for — its CSRF token
|
|
121
|
+
* fetch, say: `noResend` sends the exchange once and follows no redirect,
|
|
122
|
+
* `noLog` keeps what it sees out of the wire's lines.
|
|
123
|
+
*/
|
|
124
|
+
noResend?: true | undefined;
|
|
125
|
+
noLog?: true | undefined;
|
|
101
126
|
/** Where to hand each answer, so the connection sees what the wire saw. */
|
|
102
127
|
observe: (headers: unknown) => void;
|
|
103
128
|
}
|
|
@@ -183,7 +208,11 @@ export interface IAdtTransport {
|
|
|
183
208
|
* establishment or a replacement is a question about the session's lifetime,
|
|
184
209
|
* and it is answered above.
|
|
185
210
|
*/
|
|
186
|
-
ingest(headers?: Record<string, unknown
|
|
211
|
+
ingest(headers?: Record<string, unknown>,
|
|
212
|
+
/** The answer is a `noLog` request's: nothing of it reaches a line. */
|
|
213
|
+
options?: {
|
|
214
|
+
noLog?: true | undefined;
|
|
215
|
+
}): void;
|
|
187
216
|
/** What to put on the `Cookie` header, or `null` for a wire that has none. */
|
|
188
217
|
cookies(): string | null;
|
|
189
218
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IAdtTransport.d.ts","sourceRoot":"","sources":["../../src/connection/IAdtTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE,4DAA4D;AAC5D,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC;;;;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port.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AASH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"RfcTransport.d.ts","sourceRoot":"","sources":["../../src/connection/RfcTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AASH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAkB5B,sFAAsF;AACtF,MAAM,WAAW,gBAAgB;IAC/B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB;;;;;OAKG;IACH,IAAI,CACF,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,GAC1C,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB;;;;;OAKG;IACH,kBAAkB,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CACpC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM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H,cAAc,IAAI,IAAI;IAEtB;;;OAGG;IACH,6EAA6E;IAC7E,kBAAkB,IAAI,OAAO;IAI7B,kBAAkB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAQzC,2EAA2E;IAC3E,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIzC;;;;OAIG;IACH,aAAa,IAAI,IAAI;IAErB;;;;;OAKG;gBAEgB,OAAO,EAAE,sBAAsB,EAC/B,MAAM,GAAE,OAAO,GAAG,IAAW,EAC7B,OAAO,GAAE,oBAAyB;IAGrD,oDAAoD;IACpD,OAAO,CAAC,OAAO;IAcT,IAAI,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBvD,0DAA0D;IACpD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA2BtB,IAAI,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
783
|
-
|
|
784
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,w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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"}
|
|
@@ -8,6 +8,7 @@ const LegacyOnPremHttpTransport_js_1 = require("./LegacyOnPremHttpTransport.js")
|
|
|
8
8
|
const OnPremHttpTransport_js_1 = require("./OnPremHttpTransport.js");
|
|
9
9
|
const RfcTransport_js_1 = require("./RfcTransport.js");
|
|
10
10
|
const rfcConversation_js_1 = require("./rfcConversation.js");
|
|
11
|
+
const withCheckRelogon_js_1 = require("./withCheckRelogon.js");
|
|
11
12
|
/**
|
|
12
13
|
* Fixed words: nothing the caller passed is echoed back. Typed `never`: the
|
|
13
14
|
* compiler proves every combination of the spec type is handled before it,
|
|
@@ -28,6 +29,17 @@ function httpAddress(spec) {
|
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
function createConnection(spec) {
|
|
32
|
+
const connection = buildConnection(spec);
|
|
33
|
+
if (spec.transport !== 'http')
|
|
34
|
+
return connection;
|
|
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
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
function buildConnection(spec) {
|
|
31
43
|
const logger = spec.logger ?? null;
|
|
32
44
|
const wireLogger = spec.wireLogger ?? null;
|
|
33
45
|
// The spec is a union discriminated by `transport` and `system`: each branch
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one line a `noLog` request may write: the method, the path without its
|
|
3
|
+
* query, the integer status and the byte count — nothing of the request's
|
|
4
|
+
* query, headers or body, nothing of the answer's headers, status text or body.
|
|
5
|
+
*
|
|
6
|
+
* Shared by the connection and both wires, so a `noLog` line reads the same
|
|
7
|
+
* whichever of them wrote it.
|
|
8
|
+
*/
|
|
9
|
+
/** What a quiet line carries, as its log fields. */
|
|
10
|
+
export interface QuietFacts {
|
|
11
|
+
method: string;
|
|
12
|
+
path: string;
|
|
13
|
+
status?: number;
|
|
14
|
+
bytes?: number;
|
|
15
|
+
}
|
|
16
|
+
/** What a quiet line names for a URL that does not parse: nothing of it. */
|
|
17
|
+
export declare const UNPARSABLE_URL = "<unparsable url>";
|
|
18
|
+
/**
|
|
19
|
+
* The path of a request URL. A path (`/…`, not `//…`) is cut at its query or
|
|
20
|
+
* fragment; anything else is parsed as an absolute URL and gives its pathname
|
|
21
|
+
* alone — never its user, password, host, query or fragment, which the WHATWG
|
|
22
|
+
* parser separates. One with a scheme and no authority (`user:pass@host/x`)
|
|
23
|
+
* names nothing; one that does not parse (a bad port, `//host/x`) names the
|
|
24
|
+
* fixed placeholder, never any part of the input.
|
|
25
|
+
*/
|
|
26
|
+
export declare function pathOf(url: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* The size of an answer's body in bytes. A body is the wire's, from outside the
|
|
29
|
+
* type system: a string or bytes as they are, anything else as it serialises;
|
|
30
|
+
* one that will not serialise counts as none.
|
|
31
|
+
*/
|
|
32
|
+
export declare function byteCount(data: unknown): number;
|
|
33
|
+
/**
|
|
34
|
+
* The quiet line: `METHOD /path → STATUS (N bytes)` for an answer, and
|
|
35
|
+
* `METHOD /path → no answer` for a request that got none.
|
|
36
|
+
*/
|
|
37
|
+
export declare function quietLine(rawMethod: string, url: string, answer?: {
|
|
38
|
+
status: number;
|
|
39
|
+
data: unknown;
|
|
40
|
+
}): {
|
|
41
|
+
line: string;
|
|
42
|
+
facts: QuietFacts;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=quietLine.d.ts.map
|
|
@@ -0,0 +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"}
|