@mcp-abap-adt/connection 11.0.0 → 11.0.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 +36 -1
- package/README.md +12 -0
- package/dist/connection/AbstractAbapConnection.d.ts +7 -2
- package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
- package/dist/connection/AbstractAbapConnection.js +7 -5
- package/dist/connection/CloudHttpTransport.d.ts.map +1 -1
- package/dist/connection/CloudHttpTransport.js +3 -0
- package/dist/connection/HttpTransport.d.ts +54 -8
- package/dist/connection/HttpTransport.d.ts.map +1 -1
- package/dist/connection/HttpTransport.js +163 -7
- package/dist/connection/OnPremHttpTransport.d.ts.map +1 -1
- package/dist/connection/OnPremHttpTransport.js +3 -0
- package/docs/STATEFUL_SESSION_GUIDE.md +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,40 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [11.0.1] - 2026-10-06
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- **The SAP client is addressed from the first request on.** An HTTP wire
|
|
15
|
+
given a `client` applied it only through the `sap-usercontext` cookie, which
|
|
16
|
+
it held only once a response had set one — so the first request, the one
|
|
17
|
+
that opens the session and earns the CSRF token, always landed in the
|
|
18
|
+
system's DEFAULT client, and a wrong client failed one request late. Every
|
|
19
|
+
request of `OnPremHttpTransport`, `LegacyOnPremHttpTransport` and
|
|
20
|
+
`CloudHttpTransport` now carries the `sap-client` header and the
|
|
21
|
+
`sap-usercontext=sap-client=<n>` cookie, the establishing call, the cloud
|
|
22
|
+
session preflight and the goodbye included. Measured on an on-prem system:
|
|
23
|
+
with client `999` the first request is now refused (`401`); before, it
|
|
24
|
+
answered `200` from the default client.
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- **`X-SAP-Client` is no longer sent**, and `getAuthHeaders()` no longer
|
|
29
|
+
returns it: ABAP ignores that header (`X-SAP-Client: 999` answers `200` from
|
|
30
|
+
the default client; `sap-client: 999` answers `401`). The client is the
|
|
31
|
+
wire's to address — `sap-client` over HTTP, the logon over RFC. A consumer
|
|
32
|
+
that put `config.client` on the connection but not on the transport was
|
|
33
|
+
never addressing the client over HTTP; pass it to the transport's `client`
|
|
34
|
+
option.
|
|
35
|
+
- **A request cannot name another client.** A `sap-client` header, query
|
|
36
|
+
parameter, `params` entry or `sap-usercontext` cookie, in any case, that differs from the transport's `client` — or
|
|
37
|
+
names one when the transport was given none — is refused with an error
|
|
38
|
+
before anything is sent; naming the same client passes, and the header goes
|
|
39
|
+
out once. Another client is another logon (its own user, password, session
|
|
40
|
+
and CSRF token), so it is another connection: sending it would have landed
|
|
41
|
+
the request in that client with this one's session cookie and credential.
|
|
42
|
+
Over RFC the client is fixed by the logon and nothing changes.
|
|
43
|
+
|
|
10
44
|
## [11.0.0] - 2026-10-04
|
|
11
45
|
|
|
12
46
|
### Breaking
|
|
@@ -2138,7 +2172,8 @@ const connection = createAbapConnection(config, logger);
|
|
|
2138
2172
|
- JWT token refresh now properly handles connection errors (401/403 during initial connect)
|
|
2139
2173
|
- Permission errors (403 with "ExceptionResourceNoAccess") no longer trigger JWT refresh loops
|
|
2140
2174
|
- Proper separation: base class handles HTTP/session, concrete classes handle auth-specific errors
|
|
2141
|
-
[Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/v11.0.
|
|
2175
|
+
[Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/v11.0.1...HEAD
|
|
2176
|
+
[11.0.1]: https://github.com/fr0ster/mcp-abap-connection/compare/v11.0.0...v11.0.1
|
|
2142
2177
|
[11.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v10.0.3...v11.0.0
|
|
2143
2178
|
[10.0.3]: https://github.com/fr0ster/mcp-abap-connection/compare/v10.0.2...v10.0.3
|
|
2144
2179
|
[10.0.2]: https://github.com/fr0ster/mcp-abap-connection/compare/v10.0.1...v10.0.2
|
package/README.md
CHANGED
|
@@ -247,6 +247,18 @@ const response = await connection.makeAdtRequest({
|
|
|
247
247
|
});
|
|
248
248
|
```
|
|
249
249
|
|
|
250
|
+
**The client is the wire's.** The transport's `client` option is what addresses
|
|
251
|
+
the SAP client (mandant): an HTTP wire sends it as the `sap-client` header and
|
|
252
|
+
the `sap-usercontext=sap-client=<n>` cookie on every request, the first one —
|
|
253
|
+
which opens the session and earns the CSRF token — included. `config.client`
|
|
254
|
+
alone does not reach the system over HTTP; pass the same value to the
|
|
255
|
+
transport, as above. `X-SAP-Client` is not sent: ABAP ignores it. A request
|
|
256
|
+
cannot name another client: a `sap-client` header, query parameter, `params`
|
|
257
|
+
entry or `sap-usercontext` cookie (in any case) that differs from the connection's — or names one when the connection was
|
|
258
|
+
given none — is refused before anything is sent. Another client is another
|
|
259
|
+
logon, with its own user, password, session and CSRF token, so it is another
|
|
260
|
+
connection.
|
|
261
|
+
|
|
250
262
|
### Cloud Usage (JWT/OAuth2)
|
|
251
263
|
|
|
252
264
|
```typescript
|
|
@@ -426,8 +426,13 @@ declare abstract class AbstractAbapConnection implements AbapConnection, ISessio
|
|
|
426
426
|
getBaseUrl(): Promise<string>;
|
|
427
427
|
getAuthHeaders(): Promise<Record<string, string>>;
|
|
428
428
|
/**
|
|
429
|
-
* What every request carries
|
|
430
|
-
*
|
|
429
|
+
* What every request carries from the credential. On every path, the
|
|
430
|
+
* establishing call included.
|
|
431
|
+
*
|
|
432
|
+
* Not the client. It used to be written here as `X-SAP-Client`, a header
|
|
433
|
+
* ABAP ignores; the client is the wire's to address — the HTTP wire with the
|
|
434
|
+
* `sap-client` header and the `sap-usercontext` cookie, the RFC wire at its
|
|
435
|
+
* logon — because how a system is told its client is a fact about the wire.
|
|
431
436
|
*/
|
|
432
437
|
protected credentialHeaders(headers: Record<string, string>): Promise<void>;
|
|
433
438
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractAbapConnection.d.ts","sourceRoot":"","sources":["../../src/connection/AbstractAbapConnection.ts"],"names":[],"mappings":"AAEA,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;AAMvC,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;AAGxC,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAEL,KAAK,aAAa,EAInB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAGnB,MAAM,oBAAoB,CAAC;AAgD5B,uBAAe,sBACb,YACE,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB;IAuGjB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,SAAS,EAAE,aAAa;IACjC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAlH3C;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,SAAS,mBAA0B;IAEtD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,WAAW,CAAyC;IAE5D;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,gBAAgB,CAAgC;IACxD;;;;;;;;;;OAUG;IACH;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,OAAO,CAAoC;IAEnD,O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O,CAAC,IAAI,CAAC;IAgBnD;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,eAAe;IAcvB,WAAW,IAAI,OAAO;IAItB;;;;;;;;;OASG;IACH,kBAAkB,IAAI,MAAM,GAAG,IAAI;IAInC;;;;OAIG;IAEH;;;;;;;;;OASG;IAEH;;;;;;OAMG;IACH,SAAS,CAAC,cAAc,IAAI,kBAAkB;IAW9C;;;;;;;;;;;;OAYG;YACW,kBAAkB;IAmJhC,sEAAsE;IACtE,SAAS,KAAK,aAAa,IAAI,MAAM,CAEpC;IAED;;;;;;OAMG;IACH,SAAS,KAAK,iBAAiB,IAAI,MAAM,CAExC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAShD;;;;;;;OAOG;IACH,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IASnD;;;;;;;;OAQG;IACH,SAAS,CAAC,eAAe,CACvB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,UAAU,CAAC,EAAE,MAAM,GAClB,IAAI;IA2BP;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,mBAAmB;IAc3B;;;;;;;;OAQG;IACH,OAAO,CAAC,qBAAqB;IAc7B,+EAA+E;IAC/E,OAAO,CAAC,iBAAiB;IASzB;;;;;;;OAOG;IACH,SAAS,CAAC,kBAAkB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAI7C,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAI7B,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAMvD
|
|
1
|
+
{"version":3,"file":"AbstractAbapConnection.d.ts","sourceRoot":"","sources":["../../src/connection/AbstractAbapConnection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,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;;;;;;;;;OAeG;IACH,OAAO,CAAC,aAAa;IAiCrB;;;;OAIG;IACH,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAIlD;;;;;;;;OAQG;IACH,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,eAAe;CA6BxB;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -811,13 +811,15 @@ class AbstractAbapConnection {
|
|
|
811
811
|
return headers;
|
|
812
812
|
}
|
|
813
813
|
/**
|
|
814
|
-
* What every request carries
|
|
815
|
-
*
|
|
814
|
+
* What every request carries from the credential. On every path, the
|
|
815
|
+
* establishing call included.
|
|
816
|
+
*
|
|
817
|
+
* Not the client. It used to be written here as `X-SAP-Client`, a header
|
|
818
|
+
* ABAP ignores; the client is the wire's to address — the HTTP wire with the
|
|
819
|
+
* `sap-client` header and the `sap-usercontext` cookie, the RFC wire at its
|
|
820
|
+
* logon — because how a system is told its client is a fact about the wire.
|
|
816
821
|
*/
|
|
817
822
|
async credentialHeaders(headers) {
|
|
818
|
-
if (this.config.client) {
|
|
819
|
-
headers['X-SAP-Client'] = this.config.client;
|
|
820
|
-
}
|
|
821
823
|
await this.authorizeRequest(headers);
|
|
822
824
|
}
|
|
823
825
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudHttpTransport.d.ts","sourceRoot":"","sources":["../../src/connection/CloudHttpTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAa9E,qBAAa,kBACX,SAAQ,aACR,YAAW,eAAe;IAE1B,SAAkB,IAAI,gBAAgB;IAEtC,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAG,OAAO,CAAU;IAEnC;;;;;;;;;;;;;;;;;OAiBG;cACgB,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAI3D,iFAAiF;IACjF,OAAO,CAAC,QAAQ,CAAuB;IAExB,IAAI,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IA4DhD,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"CloudHttpTransport.d.ts","sourceRoot":"","sources":["../../src/connection/CloudHttpTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAa9E,qBAAa,kBACX,SAAQ,aACR,YAAW,eAAe;IAE1B,SAAkB,IAAI,gBAAgB;IAEtC,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAG,OAAO,CAAU;IAEnC;;;;;;;;;;;;;;;;;OAiBG;cACgB,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAI3D,iFAAiF;IACjF,OAAO,CAAC,QAAQ,CAAuB;IAExB,IAAI,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IA4DhD,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgDhE;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;CAW5B"}
|
|
@@ -135,6 +135,9 @@ class CloudHttpTransport extends HttpTransport_js_1.HttpTransport {
|
|
|
135
135
|
url: new URL(resource, context.baseUrl).toString(),
|
|
136
136
|
headers: {
|
|
137
137
|
...affinity,
|
|
138
|
+
// Detached, so not dressed: the client is said here in so many
|
|
139
|
+
// words, as on every other request of this wire.
|
|
140
|
+
...this.clientHeaders(),
|
|
138
141
|
...auth,
|
|
139
142
|
...context.extraHeaders,
|
|
140
143
|
Cookie: (0, cookies_js_1.mergeCookieHeaders)(auth.Cookie, cookies),
|
|
@@ -27,10 +27,10 @@ export declare class HttpTransport implements IAdtTransport {
|
|
|
27
27
|
private readonly agentOptions;
|
|
28
28
|
protected readonly logger: ILogger | null;
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
30
|
+
* The SAP client (mandant) every request on this wire addresses, from the
|
|
31
|
+
* first one on: the establishing call is where the session and its CSRF
|
|
32
|
+
* token are issued, so a client applied any later is applied to a session
|
|
33
|
+
* that already lives in another one. See `clientHeaders()`.
|
|
34
34
|
*/
|
|
35
35
|
private readonly options;
|
|
36
36
|
/**
|
|
@@ -66,10 +66,10 @@ export declare class HttpTransport implements IAdtTransport {
|
|
|
66
66
|
private token;
|
|
67
67
|
constructor(agentOptions?: () => AgentOptions, logger?: ILogger | null,
|
|
68
68
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
69
|
+
* The SAP client (mandant) every request on this wire addresses, from the
|
|
70
|
+
* first one on: the establishing call is where the session and its CSRF
|
|
71
|
+
* token are issued, so a client applied any later is applied to a session
|
|
72
|
+
* that already lives in another one. See `clientHeaders()`.
|
|
73
73
|
*/
|
|
74
74
|
options?: {
|
|
75
75
|
client?: string;
|
|
@@ -109,6 +109,33 @@ export declare class HttpTransport implements IAdtTransport {
|
|
|
109
109
|
* server is going down, send us elsewhere rather than fail.
|
|
110
110
|
*/
|
|
111
111
|
affinityHeaders(): Record<string, string>;
|
|
112
|
+
/**
|
|
113
|
+
* The client, said the way ABAP hears it: the `sap-client` header.
|
|
114
|
+
*
|
|
115
|
+
* ICF takes the client from the `sap-client` header or query parameter, or
|
|
116
|
+
* from the `sap-usercontext` cookie — and NOT from `X-SAP-Client`, which it
|
|
117
|
+
* ignores. Measured against an on-prem system (client 100 the default),
|
|
118
|
+
* plain curl with basic auth on `/sap/bc/adt/core/discovery`:
|
|
119
|
+
* `X-SAP-Client: 999` answers 200 from client 100, `sap-client: 999` answers
|
|
120
|
+
* 401. Before this, the client reached the system only through the cookie,
|
|
121
|
+
* which the wire holds from the first response on — so the first request,
|
|
122
|
+
* the one that opens the session and earns the CSRF token, always landed in
|
|
123
|
+
* the default client, and a wrong client failed one request late.
|
|
124
|
+
*
|
|
125
|
+
* The header rather than the query parameter: it addresses the client
|
|
126
|
+
* without rewriting a URL the caller built, and it rides on the detached
|
|
127
|
+
* goodbye the same way it rides on everything else.
|
|
128
|
+
*/
|
|
129
|
+
protected clientHeaders(): Record<string, string>;
|
|
130
|
+
/**
|
|
131
|
+
* The `sap-usercontext` cookie the client is asserted with, from the first
|
|
132
|
+
* request on — before any response could have set one.
|
|
133
|
+
*
|
|
134
|
+
* Added when a request is dressed rather than put in the jar: the jar is
|
|
135
|
+
* what the server issued, and a jar that held something before the first
|
|
136
|
+
* answer would read as a connection that holds a session.
|
|
137
|
+
*/
|
|
138
|
+
private clientCookie;
|
|
112
139
|
/**
|
|
113
140
|
* What this wire says about the session it is already in, on every request.
|
|
114
141
|
*
|
|
@@ -157,6 +184,17 @@ export declare class HttpTransport implements IAdtTransport {
|
|
|
157
184
|
* `LegacyOnPremHttpTransport`).
|
|
158
185
|
*/
|
|
159
186
|
protected sessionTypeHeaders(): Record<string, string>;
|
|
187
|
+
/**
|
|
188
|
+
* The client belongs to the connection. Another client is another logon —
|
|
189
|
+
* its own user and password, its own session and CSRF token — so a caller
|
|
190
|
+
* that names one in a `sap-client` header, query string or `params` entry, in
|
|
191
|
+
* any case, or in a `sap-usercontext` cookie, is refused before anything is sent: sending it would land the request in
|
|
192
|
+
* that client with the session and credential of this one. Naming the
|
|
193
|
+
* connection's own client is harmless and passes.
|
|
194
|
+
*/
|
|
195
|
+
private refuseAnotherClient;
|
|
196
|
+
/** The client the jar's `sap-usercontext` names, as the system set it. */
|
|
197
|
+
private jarClient;
|
|
160
198
|
/** A path becomes an address; anything already absolute is left alone. */
|
|
161
199
|
private address;
|
|
162
200
|
/**
|
|
@@ -193,6 +231,14 @@ export declare class HttpTransport implements IAdtTransport {
|
|
|
193
231
|
* to add it.
|
|
194
232
|
*/
|
|
195
233
|
send(request: IAdtTransportRequest): Promise<IAdtTransportResponse>;
|
|
234
|
+
/**
|
|
235
|
+
* The request read once, into plain values: what the client guard checks is
|
|
236
|
+
* then exactly what goes out. The headers are copied, and the URL and
|
|
237
|
+
* `params` are serialised here, once, by axios — the dispatch sends that URL
|
|
238
|
+
* and no `params`, so nothing the caller handed over is read a second time
|
|
239
|
+
* (a getter that answers differently on its second read changes nothing).
|
|
240
|
+
*/
|
|
241
|
+
private fix;
|
|
196
242
|
/**
|
|
197
243
|
* Send EXACTLY these headers, with nothing of the wire's live state mixed in.
|
|
198
244
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpTransport.d.ts","sourceRoot":"","sources":["../../src/connection/HttpTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAS,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAGV,YAAY,EACb,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAI5C,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAE3B,MAAM,oBAAoB,CAAC;AAuC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AA6DzD,qBAAa,aAAc,YAAW,aAAa;IAsC/C,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IACzC;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,CAAC,OAAO;IA7C1B;;;;;;;;;OASG;IACH,QAAQ,CAAC,IA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,uEAAuE;IACvE,SAAS,IAAI,MAAM,GAAG,IAAI;IAI1B,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAI1C,4EAA4E;IAC5E,aAAa,IAAI,IAAI;IASrB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAWzB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,KAAK;IA0Cb;;;;;OAKG;IACH,SAAS,CAAC,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAItD;;;;;;;OAOG;IACH,OAAO,CAAC,mBAAmB;IAoE3B,0EAA0E;IAC1E,OAAO,CAAC,SAAS;IASjB,0EAA0E;IAC1E,OAAO,CAAC,OAAO;IAQf;;;;;;;OAOG;IACH,SAAS,CAAC,WAAW,IAAI,YAAY;IAiBrC,OAAO,CAAC,MAAM;IAuBd;;;;;;;OAOG;IACG,IAAI,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAItD;;;;;;OAMG;IACG,KAAK,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAExD;;;;;OAKG;IACG,IAAI,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAKzE;;;;;;OAMG;IACH,OAAO,CAAC,GAAG;IAmBX;;;;;;;;;;;;;OAaG;cACa,YAAY,CAC1B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;YAInB,QAAQ;CA4BvB"}
|
|
@@ -158,10 +158,10 @@ class HttpTransport {
|
|
|
158
158
|
token = null;
|
|
159
159
|
constructor(agentOptions = () => ({}), logger = null,
|
|
160
160
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
161
|
+
* The SAP client (mandant) every request on this wire addresses, from the
|
|
162
|
+
* first one on: the establishing call is where the session and its CSRF
|
|
163
|
+
* token are issued, so a client applied any later is applied to a session
|
|
164
|
+
* that already lives in another one. See `clientHeaders()`.
|
|
165
165
|
*/
|
|
166
166
|
options = {}) {
|
|
167
167
|
this.agentOptions = agentOptions;
|
|
@@ -199,6 +199,10 @@ class HttpTransport {
|
|
|
199
199
|
continue;
|
|
200
200
|
this.jar.set(trimmed, rest.join('=').trim());
|
|
201
201
|
}
|
|
202
|
+
// SAP answers `sap-usercontext` with the system default rather than the
|
|
203
|
+
// client that was asked for; folded in as it came, later requests would
|
|
204
|
+
// route to a client the caller never named — on a read-only one, every
|
|
205
|
+
// write comes back 403.
|
|
202
206
|
if (this.options.client) {
|
|
203
207
|
this.jar.set('sap-usercontext', `sap-client=${this.options.client}`);
|
|
204
208
|
}
|
|
@@ -254,6 +258,39 @@ class HttpTransport {
|
|
|
254
258
|
: {}),
|
|
255
259
|
};
|
|
256
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* The client, said the way ABAP hears it: the `sap-client` header.
|
|
263
|
+
*
|
|
264
|
+
* ICF takes the client from the `sap-client` header or query parameter, or
|
|
265
|
+
* from the `sap-usercontext` cookie — and NOT from `X-SAP-Client`, which it
|
|
266
|
+
* ignores. Measured against an on-prem system (client 100 the default),
|
|
267
|
+
* plain curl with basic auth on `/sap/bc/adt/core/discovery`:
|
|
268
|
+
* `X-SAP-Client: 999` answers 200 from client 100, `sap-client: 999` answers
|
|
269
|
+
* 401. Before this, the client reached the system only through the cookie,
|
|
270
|
+
* which the wire holds from the first response on — so the first request,
|
|
271
|
+
* the one that opens the session and earns the CSRF token, always landed in
|
|
272
|
+
* the default client, and a wrong client failed one request late.
|
|
273
|
+
*
|
|
274
|
+
* The header rather than the query parameter: it addresses the client
|
|
275
|
+
* without rewriting a URL the caller built, and it rides on the detached
|
|
276
|
+
* goodbye the same way it rides on everything else.
|
|
277
|
+
*/
|
|
278
|
+
clientHeaders() {
|
|
279
|
+
return this.options.client ? { 'sap-client': this.options.client } : {};
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* The `sap-usercontext` cookie the client is asserted with, from the first
|
|
283
|
+
* request on — before any response could have set one.
|
|
284
|
+
*
|
|
285
|
+
* Added when a request is dressed rather than put in the jar: the jar is
|
|
286
|
+
* what the server issued, and a jar that held something before the first
|
|
287
|
+
* answer would read as a connection that holds a session.
|
|
288
|
+
*/
|
|
289
|
+
clientCookie() {
|
|
290
|
+
return this.options.client
|
|
291
|
+
? `sap-usercontext=sap-client=${this.options.client}`
|
|
292
|
+
: undefined;
|
|
293
|
+
}
|
|
257
294
|
/**
|
|
258
295
|
* What this wire says about the session it is already in, on every request.
|
|
259
296
|
*
|
|
@@ -418,6 +455,7 @@ class HttpTransport {
|
|
|
418
455
|
* looking like it carried a session.
|
|
419
456
|
*/
|
|
420
457
|
dress(request) {
|
|
458
|
+
this.refuseAnotherClient(request);
|
|
421
459
|
const headers = request.headers;
|
|
422
460
|
const stateful = (0, statefulRequest_js_1.isStatefulRequest)(request);
|
|
423
461
|
const dressed = {
|
|
@@ -426,17 +464,27 @@ class HttpTransport {
|
|
|
426
464
|
...(stateful ? this.sessionTypeHeaders() : {}),
|
|
427
465
|
...headers,
|
|
428
466
|
};
|
|
467
|
+
// The caller's spelling of the client goes; the wire's goes in last. It is
|
|
468
|
+
// the same value — refuseAnotherClient saw to that — said once.
|
|
469
|
+
for (const name of Object.keys(dressed)) {
|
|
470
|
+
if (name.trim().toLowerCase() === 'sap-client')
|
|
471
|
+
delete dressed[name];
|
|
472
|
+
}
|
|
473
|
+
Object.assign(dressed, this.clientHeaders());
|
|
429
474
|
// Whatever the caller spelled the header as: HTTP does not tell `Cookie`
|
|
430
475
|
// from `cookie`, and a lowercase one spread in above would bypass the
|
|
431
476
|
// filter below.
|
|
432
477
|
let callerCookie;
|
|
433
478
|
for (const name of Object.keys(dressed)) {
|
|
434
|
-
if (name.toLowerCase() !== 'cookie')
|
|
479
|
+
if (name.trim().toLowerCase() !== 'cookie')
|
|
435
480
|
continue;
|
|
436
481
|
callerCookie = (0, cookies_js_1.mergeCookieHeaders)(callerCookie, dressed[name]);
|
|
437
482
|
delete dressed[name];
|
|
438
483
|
}
|
|
439
|
-
|
|
484
|
+
// The client cookie last, so it wins: on the first request it is the only
|
|
485
|
+
// thing that names the client, and later the jar already holds the same
|
|
486
|
+
// value.
|
|
487
|
+
const merged = (0, cookies_js_1.mergeCookieHeaders)((0, cookies_js_1.mergeCookieHeaders)(callerCookie, this.combined ?? undefined), this.clientCookie());
|
|
440
488
|
// Filtered on the merged header, not only on the jar: a caller's own
|
|
441
489
|
// `Cookie` can carry the context too — the connection's CSRF and 401
|
|
442
490
|
// retries put the whole jar there — and a non-stateful request must not
|
|
@@ -457,6 +505,88 @@ class HttpTransport {
|
|
|
457
505
|
sessionTypeHeaders() {
|
|
458
506
|
return { [statefulRequest_js_1.SESSION_TYPE_HEADER]: 'stateful' };
|
|
459
507
|
}
|
|
508
|
+
/**
|
|
509
|
+
* The client belongs to the connection. Another client is another logon —
|
|
510
|
+
* its own user and password, its own session and CSRF token — so a caller
|
|
511
|
+
* that names one in a `sap-client` header, query string or `params` entry, in
|
|
512
|
+
* any case, or in a `sap-usercontext` cookie, is refused before anything is sent: sending it would land the request in
|
|
513
|
+
* that client with the session and credential of this one. Naming the
|
|
514
|
+
* connection's own client is harmless and passes.
|
|
515
|
+
*/
|
|
516
|
+
refuseAnotherClient(request) {
|
|
517
|
+
const own = this.options.client || undefined;
|
|
518
|
+
const named = [];
|
|
519
|
+
for (const [name, value] of Object.entries(request.headers ?? {})) {
|
|
520
|
+
if (name.trim().toLowerCase() === 'sap-client')
|
|
521
|
+
named.push(String(value));
|
|
522
|
+
}
|
|
523
|
+
// The query as axios will send it — the URL's own and the structured
|
|
524
|
+
// `params`, serialised by axios itself (which trims and encodes names), so
|
|
525
|
+
// what is checked is what goes out. A name is compared trimmed and in any
|
|
526
|
+
// case, as ICF reads it.
|
|
527
|
+
// The request is fixed by now (`fix`): its URL already holds the `params`,
|
|
528
|
+
// serialised once by axios.
|
|
529
|
+
const sent = axios_1.default.getUri({
|
|
530
|
+
url: request.url ?? '',
|
|
531
|
+
...(request.params !== undefined ? { params: request.params } : {}),
|
|
532
|
+
});
|
|
533
|
+
// Then read the way Node's adapter addresses it: through a WHATWG URL,
|
|
534
|
+
// which drops tabs and line breaks anywhere in it — `sap-cl\nient` goes
|
|
535
|
+
// out as `sap-client`. A URL that does not parse is not sent either.
|
|
536
|
+
let search;
|
|
537
|
+
try {
|
|
538
|
+
search = new URL(sent, 'http://client.check.invalid').searchParams;
|
|
539
|
+
}
|
|
540
|
+
catch {
|
|
541
|
+
search = new URLSearchParams();
|
|
542
|
+
}
|
|
543
|
+
for (const [name, value] of search) {
|
|
544
|
+
// A list goes out as `sap-client[]=…`; refused all the same.
|
|
545
|
+
if (/^sap-client(\[\])?$/.test(name.trim().toLowerCase())) {
|
|
546
|
+
named.push(value);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
// And the cookie ICF also reads: `sap-usercontext=sap-client=<n>` in a
|
|
550
|
+
// caller's `Cookie`. The connection's own CSRF and 401 retries put the
|
|
551
|
+
// whole jar there, so a wire given no client admits the client its jar
|
|
552
|
+
// holds — the one the system answered with — and nothing else.
|
|
553
|
+
const cookieOwn = own ?? this.jarClient();
|
|
554
|
+
const cookieNamed = [];
|
|
555
|
+
for (const [name, value] of Object.entries(request.headers ?? {})) {
|
|
556
|
+
if (name.trim().toLowerCase() !== 'cookie')
|
|
557
|
+
continue;
|
|
558
|
+
for (const pair of String(value).split(';')) {
|
|
559
|
+
const [cookieName, ...rest] = pair.split('=');
|
|
560
|
+
if (cookieName?.trim().toLowerCase() !== 'sap-usercontext')
|
|
561
|
+
continue;
|
|
562
|
+
for (const [key, client] of new URLSearchParams(rest.join('=').trim())) {
|
|
563
|
+
if (key.trim().toLowerCase() === 'sap-client')
|
|
564
|
+
cookieNamed.push(client);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
for (const client of cookieNamed) {
|
|
569
|
+
if (client === cookieOwn)
|
|
570
|
+
continue;
|
|
571
|
+
throw new Error(`the request names client ${client}, but the connection is ${own ? `for client ${own}` : 'given no client'}: the client belongs to the connection — another client is another connection, with its own credential`);
|
|
572
|
+
}
|
|
573
|
+
for (const client of named) {
|
|
574
|
+
if (client === own)
|
|
575
|
+
continue;
|
|
576
|
+
throw new Error(`the request names client ${client}, but the connection is ${own ? `for client ${own}` : 'given no client'}: the client belongs to the connection — another client is another connection, with its own credential`);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
/** The client the jar's `sap-usercontext` names, as the system set it. */
|
|
580
|
+
jarClient() {
|
|
581
|
+
const context = this.jar.get('sap-usercontext');
|
|
582
|
+
if (context === undefined)
|
|
583
|
+
return undefined;
|
|
584
|
+
for (const [key, client] of new URLSearchParams(context)) {
|
|
585
|
+
if (key.toLowerCase() === 'sap-client')
|
|
586
|
+
return client;
|
|
587
|
+
}
|
|
588
|
+
return undefined;
|
|
589
|
+
}
|
|
460
590
|
/** A path becomes an address; anything already absolute is left alone. */
|
|
461
591
|
address(url) {
|
|
462
592
|
if (!url.startsWith('/') || !this.options.baseUrl)
|
|
@@ -534,7 +664,33 @@ class HttpTransport {
|
|
|
534
664
|
* to add it.
|
|
535
665
|
*/
|
|
536
666
|
async send(request) {
|
|
537
|
-
|
|
667
|
+
const fixed = this.fix(request);
|
|
668
|
+
return this.dispatch(fixed, this.dress(fixed));
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* The request read once, into plain values: what the client guard checks is
|
|
672
|
+
* then exactly what goes out. The headers are copied, and the URL and
|
|
673
|
+
* `params` are serialised here, once, by axios — the dispatch sends that URL
|
|
674
|
+
* and no `params`, so nothing the caller handed over is read a second time
|
|
675
|
+
* (a getter that answers differently on its second read changes nothing).
|
|
676
|
+
*/
|
|
677
|
+
fix(request) {
|
|
678
|
+
const { headers, params, url, ...rest } = request;
|
|
679
|
+
const fixed = {
|
|
680
|
+
...rest,
|
|
681
|
+
url: axios_1.default.getUri({
|
|
682
|
+
url: url ?? '',
|
|
683
|
+
...(params !== undefined ? { params } : {}),
|
|
684
|
+
}),
|
|
685
|
+
};
|
|
686
|
+
if (headers !== undefined) {
|
|
687
|
+
const copied = {};
|
|
688
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
689
|
+
copied[name] = value;
|
|
690
|
+
}
|
|
691
|
+
fixed.headers = copied;
|
|
692
|
+
}
|
|
693
|
+
return fixed;
|
|
538
694
|
}
|
|
539
695
|
/**
|
|
540
696
|
* Send EXACTLY these headers, with nothing of the wire's live state mixed in.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OnPremHttpTransport.d.ts","sourceRoot":"","sources":["../../src/connection/OnPremHttpTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAI5B,qBAAa,mBACX,SAAQ,aACR,YAAW,gBAAgB;IAE3B,SAAkB,IAAI,EAAE,MAAM,CAAiB;IAE/C,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAG,QAAQ,CAAU;IAEpC;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW,CAAS;IAEb,SAAS,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7D,aAAa,IAAI,IAAI;IAK9B;;;;;;;OAOG;IAEY,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"OnPremHttpTransport.d.ts","sourceRoot":"","sources":["../../src/connection/OnPremHttpTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAI5B,qBAAa,mBACX,SAAQ,aACR,YAAW,gBAAgB;IAE3B,SAAkB,IAAI,EAAE,MAAM,CAAiB;IAE/C,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAG,QAAQ,CAAU;IAEpC;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW,CAAS;IAEb,SAAS,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7D,aAAa,IAAI,IAAI;IAK9B;;;;;;;OAOG;IAEY,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;CA2CjE"}
|
|
@@ -77,6 +77,9 @@ class OnPremHttpTransport extends HttpTransport_js_1.HttpTransport {
|
|
|
77
77
|
url: `${context.baseUrl}${ICF_LOGOFF_PATH}`,
|
|
78
78
|
headers: {
|
|
79
79
|
...affinity,
|
|
80
|
+
// Detached, so not dressed: the client is said here in so many
|
|
81
|
+
// words, as on every other request of this wire.
|
|
82
|
+
...this.clientHeaders(),
|
|
80
83
|
...auth,
|
|
81
84
|
...context.extraHeaders,
|
|
82
85
|
Cookie: (0, cookies_js_1.mergeCookieHeaders)(auth.Cookie, cookies),
|
|
@@ -18,6 +18,7 @@ This document explains how `@mcp-abap-adt/connection` manages HTTP-level session
|
|
|
18
18
|
|
|
19
19
|
- Fetch and cache CSRF token (per connection instance)
|
|
20
20
|
- Store/reuse SAP cookies (`SAP_SESSIONID`, `sap-usercontext`, etc.)
|
|
21
|
+
- Address the configured SAP client from the first request on (`sap-client` header and `sap-usercontext` cookie)
|
|
21
22
|
- Track WHICH SAP session a connection is in, and refuse to work once it is lost
|
|
22
23
|
|
|
23
24
|
The connection layer **does not** decide when to lock/unlock objects—that logic lives in the ADT clients. Instead it ensures every request shares the same HTTP session when desired.
|