@mcp-abap-adt/connection 10.0.3 → 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 CHANGED
@@ -7,6 +7,64 @@ 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
+
44
+ ## [11.0.0] - 2026-10-04
45
+
46
+ ### Breaking
47
+
48
+ - **The server certificate is verified by default.** Up to 10.x the HTTPS agent
49
+ verified it only when `NODE_TLS_REJECT_UNAUTHORIZED` or
50
+ `TLS_REJECT_UNAUTHORIZED` was `1`; with neither set it accepted any
51
+ certificate — on every HTTP wire, `CloudHttpTransport` included. Now it
52
+ verifies as Node does, and turns verification off only when told so:
53
+ `agentOptions: { rejectUnauthorized: false }`, or — with `agentOptions`
54
+ leaving it unset — `TLS_REJECT_UNAUTHORIZED=0` or
55
+ `NODE_TLS_REJECT_UNAUTHORIZED=0`. Any other value (`1`, `false`, `no`, empty)
56
+ verifies. `agentOptions.rejectUnauthorized` wins over the environment.
57
+ A system with a self-signed or company-CA certificate that worked without
58
+ any setting is now refused at the first request: trust its CA with
59
+ `agentOptions: { ca }` (or `NODE_EXTRA_CA_CERTS`), or opt out explicitly.
60
+ See [MIGRATION-11.0.md](./docs/MIGRATION-11.0.md).
61
+
62
+ ### Added
63
+
64
+ - An opt-out is logged once per wire at debug level, in fixed words:
65
+ `TLS: the server certificate is not verified (explicit opt-out)`. The old
66
+ `TLS configuration: rejectUnauthorized=…` debug line is gone.
67
+
10
68
  ## [10.0.3] - 2026-10-02
11
69
 
12
70
  ### Changed
@@ -2114,7 +2172,9 @@ const connection = createAbapConnection(config, logger);
2114
2172
  - JWT token refresh now properly handles connection errors (401/403 during initial connect)
2115
2173
  - Permission errors (403 with "ExceptionResourceNoAccess") no longer trigger JWT refresh loops
2116
2174
  - Proper separation: base class handles HTTP/session, concrete classes handle auth-specific errors
2117
- [Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/v10.0.3...HEAD
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
2177
+ [11.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v10.0.3...v11.0.0
2118
2178
  [10.0.3]: https://github.com/fr0ster/mcp-abap-connection/compare/v10.0.2...v10.0.3
2119
2179
  [10.0.2]: https://github.com/fr0ster/mcp-abap-connection/compare/v10.0.1...v10.0.2
2120
2180
  [10.0.1]: https://github.com/fr0ster/mcp-abap-connection/compare/v10.0.0...v10.0.1
package/README.md CHANGED
@@ -154,6 +154,7 @@ the packages above. See [Migration to 9.0.0](./docs/MIGRATION-9.0.md).
154
154
 
155
155
  - 📦 **[Installation Guide](./docs/INSTALLATION.md)** - Setup and installation instructions
156
156
  - 📚 **[Usage Guide](./docs/USAGE.md)** - Detailed usage examples and API documentation
157
+ - 🚚 **[Migration to 11.0.0](./docs/MIGRATION-11.0.md)** - the server certificate is verified by default; trust a self-signed system with `agentOptions.ca`, or opt out explicitly
157
158
  - 🚚 **[Migration to 10.0.0](./docs/MIGRATION-10.0.md)** - the credential providers moved to `@mcp-abap-adt/auth-providers`; the connection speaks `IAuthProvider` 3.0; `AuthRefusedError`; the RFC factory takes the logon parameters
158
159
  - 🚚 **[Migration to 9.0.0](./docs/MIGRATION-9.0.md)** - the contracts split out of `@mcp-abap-adt/interfaces`; which package each one moved to
159
160
  - 🚚 **[Migration to 7.0.0 and 8.0.0](./docs/MIGRATION-8.0.md)** - request headers leave the stateful branch, the contracts floor moves, and `flushGoodbye()`
@@ -246,6 +247,18 @@ const response = await connection.makeAdtRequest({
246
247
  });
247
248
  ```
248
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
+
249
262
  ### Cloud Usage (JWT/OAuth2)
250
263
 
251
264
  ```typescript
@@ -474,6 +487,28 @@ try {
474
487
 
475
488
  See [USAGE.md](./docs/USAGE.md#when-the-credential-is-refused).
476
489
 
490
+ ### The server certificate
491
+
492
+ The HTTP wire verifies the server certificate, as Node does. For a system with a
493
+ self-signed certificate or one from a company CA, trust that CA:
494
+
495
+ ```typescript
496
+ import { readFileSync } from "node:fs";
497
+ import { OnPremHttpTransport } from "@mcp-abap-adt/connection";
498
+
499
+ const ca = readFileSync("/path/to/sap-system-ca.pem", "utf8");
500
+ const transport = new OnPremHttpTransport(() => ({ ca }), logger, {
501
+ client: config.client,
502
+ baseUrl: config.url,
503
+ });
504
+ ```
505
+
506
+ Verification is turned off only explicitly — `agentOptions: { rejectUnauthorized:
507
+ false }`, or (when `agentOptions` leaves it unset) `TLS_REJECT_UNAUTHORIZED=0` or
508
+ `NODE_TLS_REJECT_UNAUTHORIZED=0`; any other value verifies. A last resort, never
509
+ for production. Before 11.0.0 the certificate was not verified by default: see
510
+ [MIGRATION-11.0.md](./docs/MIGRATION-11.0.md).
511
+
477
512
  ### Stateful Sessions
478
513
 
479
514
  Enable stateful mode for requests that need the ABAP context, such as LOCK and
@@ -537,14 +572,6 @@ class MyLogger implements ILogger {
537
572
  debug(message: string, meta?: any): void {
538
573
  // Your logging implementation
539
574
  }
540
-
541
- csrfToken(action: "fetch" | "retry" | "success" | "error", message: string, meta?: any): void {
542
- // CSRF token specific logging
543
- }
544
-
545
- tlsConfig(rejectUnauthorized: boolean): void {
546
- // TLS configuration logging
547
- }
548
575
  }
549
576
 
550
577
  const logger = new MyLogger();
@@ -698,8 +725,6 @@ interface ILogger {
698
725
  error(message: string, meta?: any): void;
699
726
  warn(message: string, meta?: any): void;
700
727
  debug(message: string, meta?: any): void;
701
- csrfToken?(action: "fetch" | "retry" | "success" | "error", message: string, meta?: any): void;
702
- tlsConfig?(rejectUnauthorized: boolean): void;
703
728
  }
704
729
  ```
705
730
 
@@ -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: the client, then whatever the credential
430
- * writes. On every path, the establishing call included.
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,aA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: the client, then whatever the credential
815
- * writes. On every path, the establishing call included.
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;IA6ChE;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;CAW5B"}
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
- * `client` because SAP answers `sap-usercontext` with the system default
31
- * rather than the client that was asked for, and later requests then route
32
- * to a client the caller never named — on a read-only one, every write
33
- * comes back 403.
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
  /**
@@ -50,6 +50,8 @@ export declare class HttpTransport implements IAdtTransport {
50
50
  * a logon offering different material drops the client — never the jar.
51
51
  */
52
52
  private material;
53
+ /** Whether this wire has said that it does not verify the server certificate. */
54
+ private saidUnverified;
53
55
  /**
54
56
  * The wire's own state.
55
57
  *
@@ -64,10 +66,10 @@ export declare class HttpTransport implements IAdtTransport {
64
66
  private token;
65
67
  constructor(agentOptions?: () => AgentOptions, logger?: ILogger | null,
66
68
  /**
67
- * `client` because SAP answers `sap-usercontext` with the system default
68
- * rather than the client that was asked for, and later requests then route
69
- * to a client the caller never named — on a read-only one, every write
70
- * comes back 403.
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()`.
71
73
  */
72
74
  options?: {
73
75
  client?: string;
@@ -107,6 +109,33 @@ export declare class HttpTransport implements IAdtTransport {
107
109
  * server is going down, send us elsewhere rather than fail.
108
110
  */
109
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;
110
139
  /**
111
140
  * What this wire says about the session it is already in, on every request.
112
141
  *
@@ -155,6 +184,17 @@ export declare class HttpTransport implements IAdtTransport {
155
184
  * `LegacyOnPremHttpTransport`).
156
185
  */
157
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;
158
198
  /** A path becomes an address; anything already absolute is left alone. */
159
199
  private address;
160
200
  /**
@@ -191,6 +231,14 @@ export declare class HttpTransport implements IAdtTransport {
191
231
  * to add it.
192
232
  */
193
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;
194
242
  /**
195
243
  * Send EXACTLY these headers, with nothing of the wire's live state mixed in.
196
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,oBAAo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Y,CAC1B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;YAInB,QAAQ;CA4BvB"}
@@ -103,6 +103,24 @@ function sameMaterial(a, b) {
103
103
  return Buffer.from(left).equals(Buffer.from(right));
104
104
  });
105
105
  }
106
+ /**
107
+ * Whether the server certificate is verified: yes, as Node does, unless told
108
+ * otherwise in so many words.
109
+ *
110
+ * `agentOptions.rejectUnauthorized`, when the caller set it, decides — it is
111
+ * the caller's own code. Otherwise `TLS_REJECT_UNAUTHORIZED=0` or
112
+ * `NODE_TLS_REJECT_UNAUTHORIZED=0` turns verification off, and nothing else
113
+ * does: unset, `1` and a typo (`false`, `no`) all verify, so a misread
114
+ * variable fails closed. A self-signed system is trusted with
115
+ * `agentOptions.ca`, not by turning verification off.
116
+ */
117
+ function verifiesServerCertificate(options) {
118
+ if (typeof options.rejectUnauthorized === 'boolean') {
119
+ return options.rejectUnauthorized;
120
+ }
121
+ return !(process.env.TLS_REJECT_UNAUTHORIZED === '0' ||
122
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED === '0');
123
+ }
106
124
  class HttpTransport {
107
125
  agentOptions;
108
126
  logger;
@@ -124,6 +142,8 @@ class HttpTransport {
124
142
  * a logon offering different material drops the client — never the jar.
125
143
  */
126
144
  material = null;
145
+ /** Whether this wire has said that it does not verify the server certificate. */
146
+ saidUnverified = false;
127
147
  /**
128
148
  * The wire's own state.
129
149
  *
@@ -138,10 +158,10 @@ class HttpTransport {
138
158
  token = null;
139
159
  constructor(agentOptions = () => ({}), logger = null,
140
160
  /**
141
- * `client` because SAP answers `sap-usercontext` with the system default
142
- * rather than the client that was asked for, and later requests then route
143
- * to a client the caller never named — on a read-only one, every write
144
- * comes back 403.
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()`.
145
165
  */
146
166
  options = {}) {
147
167
  this.agentOptions = agentOptions;
@@ -179,6 +199,10 @@ class HttpTransport {
179
199
  continue;
180
200
  this.jar.set(trimmed, rest.join('=').trim());
181
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.
182
206
  if (this.options.client) {
183
207
  this.jar.set('sap-usercontext', `sap-client=${this.options.client}`);
184
208
  }
@@ -234,6 +258,39 @@ class HttpTransport {
234
258
  : {}),
235
259
  };
236
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
+ }
237
294
  /**
238
295
  * What this wire says about the session it is already in, on every request.
239
296
  *
@@ -398,6 +455,7 @@ class HttpTransport {
398
455
  * looking like it carried a session.
399
456
  */
400
457
  dress(request) {
458
+ this.refuseAnotherClient(request);
401
459
  const headers = request.headers;
402
460
  const stateful = (0, statefulRequest_js_1.isStatefulRequest)(request);
403
461
  const dressed = {
@@ -406,17 +464,27 @@ class HttpTransport {
406
464
  ...(stateful ? this.sessionTypeHeaders() : {}),
407
465
  ...headers,
408
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());
409
474
  // Whatever the caller spelled the header as: HTTP does not tell `Cookie`
410
475
  // from `cookie`, and a lowercase one spread in above would bypass the
411
476
  // filter below.
412
477
  let callerCookie;
413
478
  for (const name of Object.keys(dressed)) {
414
- if (name.toLowerCase() !== 'cookie')
479
+ if (name.trim().toLowerCase() !== 'cookie')
415
480
  continue;
416
481
  callerCookie = (0, cookies_js_1.mergeCookieHeaders)(callerCookie, dressed[name]);
417
482
  delete dressed[name];
418
483
  }
419
- const merged = (0, cookies_js_1.mergeCookieHeaders)(callerCookie, this.combined ?? undefined);
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());
420
488
  // Filtered on the merged header, not only on the jar: a caller's own
421
489
  // `Cookie` can carry the context too — the connection's CSRF and 401
422
490
  // retries put the whole jar there — and a non-stateful request must not
@@ -437,6 +505,88 @@ class HttpTransport {
437
505
  sessionTypeHeaders() {
438
506
  return { [statefulRequest_js_1.SESSION_TYPE_HEADER]: 'stateful' };
439
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
+ }
440
590
  /** A path becomes an address; anything already absolute is left alone. */
441
591
  address(url) {
442
592
  if (!url.startsWith('/') || !this.options.baseUrl)
@@ -472,16 +622,16 @@ class HttpTransport {
472
622
  }
473
623
  client() {
474
624
  if (!this.instance) {
475
- // Kept as it was: an explicit opt-IN, so a misread env var cannot quietly
476
- // turn verification off.
477
- const rejectUnauthorized = process.env.NODE_TLS_REJECT_UNAUTHORIZED === '1' ||
478
- (process.env.TLS_REJECT_UNAUTHORIZED === '1' &&
479
- process.env.NODE_TLS_REJECT_UNAUTHORIZED !== '0');
480
- this.logger?.debug(`TLS configuration: rejectUnauthorized=${rejectUnauthorized}`);
625
+ const options = this.agentOptions();
626
+ const rejectUnauthorized = verifiesServerCertificate(options);
627
+ if (!rejectUnauthorized && !this.saidUnverified) {
628
+ this.saidUnverified = true;
629
+ this.logger?.debug('TLS: the server certificate is not verified (explicit opt-out)');
630
+ }
481
631
  this.instance = axios_1.default.create({
482
632
  httpsAgent: new node_https_1.Agent({
633
+ ...options,
483
634
  rejectUnauthorized,
484
- ...this.agentOptions(),
485
635
  ...this.material,
486
636
  }),
487
637
  });
@@ -514,7 +664,33 @@ class HttpTransport {
514
664
  * to add it.
515
665
  */
516
666
  async send(request) {
517
- return this.dispatch(request, this.dress(request));
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;
518
694
  }
519
695
  /**
520
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;CAwCjE"}
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),
package/docs/INDEX.md CHANGED
@@ -15,6 +15,7 @@ mcp-abap-connection/
15
15
  │ ├── INSTALLATION.md # Setup and installation guide
16
16
  │ ├── USAGE.md # API documentation and examples
17
17
  │ ├── MIGRATION-2.0.md # Moving to the explicit session lifecycle
18
+ │ ├── MIGRATION-11.0.md # the server certificate is verified by default
18
19
  │ ├── MIGRATION-10.0.md # providers move to auth-providers; IAuthProvider 3.0; AuthRefusedError
19
20
  │ ├── MIGRATION-9.0.md # the contracts split out of @mcp-abap-adt/interfaces
20
21
  │ ├── MIGRATION-8.0.md # request headers leave the stateful branch; onto interfaces 39; flushGoodbye
@@ -47,6 +48,7 @@ mcp-abap-connection/
47
48
  - 🔑 [JWT Auth Tools](./JWT_AUTH_TOOLS.md) - CLI tool for browser-based authentication
48
49
 
49
50
  ### Upgrading
51
+ - 🚚 [Migrating to 11.0.0](./MIGRATION-11.0.md) - the server certificate is verified by default; trust a self-signed system with `agentOptions.ca`, or opt out explicitly with `TLS_REJECT_UNAUTHORIZED=0`
50
52
  - 🚚 [Migrating to 10.0.0](./MIGRATION-10.0.md) - the credential providers moved to `@mcp-abap-adt/auth-providers`; the connection speaks `IAuthProvider` 3.0 and raises `AuthRefusedError`; the RFC factory takes the logon parameters
51
53
  - 🚚 [Migrating to 9.0.0](./MIGRATION-9.0.md) - the contracts split into `interfaces-adt`, `-auth`, `-network` and `-utils`, and this package stopped depending on the umbrella; `interfaces-auth-sap` joined them in the release after, when authentication split into what is SAP's and what is not
52
54
  - 🚚 [Migrating to 7.0.0 and 8.0.0](./MIGRATION-8.0.md) - `sap-adt-request-id` and `X-sap-adt-profiling` on every request, `x-sap-security-session: use` on cloud, the contracts floor at 39, and `flushGoodbye()`
@@ -328,13 +328,41 @@ npm run build
328
328
 
329
329
  ### SSL/TLS errors
330
330
 
331
- For development with self-signed certificates:
331
+ The server certificate is verified by default (since 11.0.0). A system whose
332
+ certificate Node does not trust — self-signed, or issued by a company CA — is
333
+ refused at the first request with an error such as `DEPTH_ZERO_SELF_SIGNED_CERT`
334
+ or `UNABLE_TO_VERIFY_LEAF_SIGNATURE`.
335
+
336
+ **Trust the system's CA** (preferred): pass it as `ca` in the transport's
337
+ `agentOptions`, or add it to Node's store for the whole process.
338
+
339
+ ```typescript
340
+ import { readFileSync } from 'node:fs';
341
+ import { OnPremHttpTransport } from '@mcp-abap-adt/connection';
342
+
343
+ const ca = readFileSync('/path/to/sap-system-ca.pem', 'utf8');
344
+ const transport = new OnPremHttpTransport(() => ({ ca }), null, {
345
+ client: '100',
346
+ baseUrl: 'https://sap.example.com:44300',
347
+ });
348
+ ```
349
+
350
+ ```bash
351
+ export NODE_EXTRA_CA_CERTS=/path/to/sap-system-ca.pem
352
+ ```
353
+
354
+ **Turn verification off** (last resort, development only), explicitly — only the
355
+ value `0` does it, anything else verifies:
332
356
 
333
357
  ```bash
334
- export NODE_TLS_REJECT_UNAUTHORIZED=0
358
+ export TLS_REJECT_UNAUTHORIZED=0 # this package's HTTP wire only
359
+ export NODE_TLS_REJECT_UNAUTHORIZED=0 # every TLS connection in the process
335
360
  ```
336
361
 
337
- **⚠️ Warning**: Never use this in production!
362
+ or `agentOptions: { rejectUnauthorized: false }`, which wins over both
363
+ variables. **⚠️ Warning**: never in production — anyone in the path can then
364
+ read and change the traffic, credentials included. See
365
+ [MIGRATION-11.0.md](./MIGRATION-11.0.md).
338
366
 
339
367
  ## Version Compatibility
340
368
 
@@ -0,0 +1,90 @@
1
+ # Migration to 11.0
2
+
3
+ 11.0.0 changes one thing: **the HTTP wire verifies the server certificate by
4
+ default**, as Node does. Nothing else in the API changed.
5
+
6
+ ## What was wrong
7
+
8
+ Up to 10.x, `HttpTransport` — and so `OnPremHttpTransport`,
9
+ `LegacyOnPremHttpTransport` and `CloudHttpTransport` — built its HTTPS agent with
10
+ `rejectUnauthorized: true` only when `NODE_TLS_REJECT_UNAUTHORIZED` or
11
+ `TLS_REJECT_UNAUTHORIZED` was set to `1`. With neither set, which is the usual
12
+ case, the server certificate was **not verified**: any certificate, from anyone
13
+ in the path, was accepted. That held on every HTTPS connection, BTP included.
14
+
15
+ ## What it does now
16
+
17
+ | What you set | Verified? |
18
+ |---|---|
19
+ | nothing | **yes** |
20
+ | `agentOptions: { ca }` | yes, also against that CA |
21
+ | `agentOptions: { rejectUnauthorized: false }` | no |
22
+ | `agentOptions: { rejectUnauthorized: true }` | yes, whatever the environment says |
23
+ | `TLS_REJECT_UNAUTHORIZED=0` | no (unless `agentOptions.rejectUnauthorized` says otherwise) |
24
+ | `NODE_TLS_REJECT_UNAUTHORIZED=0` | no (unless `agentOptions.rejectUnauthorized` says otherwise) |
25
+ | either variable with any other value — `1`, `false`, `no`, empty | yes |
26
+
27
+ `agentOptions.rejectUnauthorized` wins over the environment: it is your own
28
+ code. Only the exact value `0` turns verification off through a variable, so a
29
+ typo fails closed. When verification is off the wire logs, once and at debug
30
+ level, `TLS: the server certificate is not verified (explicit opt-out)`.
31
+
32
+ ## Who is affected
33
+
34
+ **Anyone whose system presents a certificate Node does not trust and who never
35
+ set anything** — typically an on-premise system with a self-signed certificate
36
+ or one issued by a company CA that is not in Node's store. Those connections
37
+ worked by accident and now fail at the first request with a TLS error such as
38
+ `DEPTH_ZERO_SELF_SIGNED_CERT`, `SELF_SIGNED_CERT_IN_CHAIN` or
39
+ `UNABLE_TO_VERIFY_LEAF_SIGNATURE`, before anything reaches the system.
40
+
41
+ Not affected: a system with a publicly trusted certificate (SAP BTP, most
42
+ hosted systems), anyone who already set one of the variables to `0`, and the RFC
43
+ wire, which does not use TLS through this package.
44
+
45
+ ## What to do
46
+
47
+ **Trust the system's CA** — the right fix. Pass the certificate (or the CA that
48
+ issued it) as `ca` in `agentOptions`:
49
+
50
+ ```typescript
51
+ import { readFileSync } from 'node:fs';
52
+ import { OnPremHttpTransport } from '@mcp-abap-adt/connection';
53
+
54
+ const ca = readFileSync('/path/to/sap-system-ca.pem', 'utf8');
55
+
56
+ const transport = new OnPremHttpTransport(() => ({ ca }), null, {
57
+ client: '100',
58
+ baseUrl: 'https://sap.example.com:44300',
59
+ });
60
+ ```
61
+
62
+ `ca` replaces Node's built-in list of trusted CAs for that wire, so it must
63
+ hold every CA the connection has to trust. Alternatively, `NODE_EXTRA_CA_CERTS=/path/to/sap-system-ca.pem` adds it
64
+ to Node's store for the whole process, without code changes.
65
+
66
+ **Turn verification off** — the last resort, for a development system only.
67
+ Either in code:
68
+
69
+ ```typescript
70
+ import { OnPremHttpTransport } from '@mcp-abap-adt/connection';
71
+
72
+ const unverified = new OnPremHttpTransport(
73
+ () => ({ rejectUnauthorized: false }),
74
+ null,
75
+ { client: '100', baseUrl: 'https://sap.example.com:44300' },
76
+ );
77
+ ```
78
+
79
+ or in the environment:
80
+
81
+ ```bash
82
+ export TLS_REJECT_UNAUTHORIZED=0 # this package only
83
+ export NODE_TLS_REJECT_UNAUTHORIZED=0 # every TLS connection in the process
84
+ ```
85
+
86
+ Prefer `TLS_REJECT_UNAUTHORIZED`: `NODE_TLS_REJECT_UNAUTHORIZED=0` also turns
87
+ verification off for everything else the process connects to.
88
+
89
+ If you set `TLS_REJECT_UNAUTHORIZED=1` or `NODE_TLS_REJECT_UNAUTHORIZED=1` to get
90
+ verification in 10.x, you can drop it: it is the default now.
@@ -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.
package/docs/USAGE.md CHANGED
@@ -617,16 +617,6 @@ class CustomLogger implements ILogger {
617
617
  console.debug(`[DEBUG] ${message}`, meta);
618
618
  }
619
619
  }
620
-
621
- // Optional: CSRF-specific logging
622
- csrfToken?(action: 'fetch' | 'retry' | 'success' | 'error', message: string, meta?: any) {
623
- console.log(`[CSRF:${action.toUpperCase()}] ${message}`, meta);
624
- }
625
-
626
- // Optional: TLS config logging
627
- tlsConfig?(rejectUnauthorized: boolean) {
628
- console.log(`[TLS] rejectUnauthorized=${rejectUnauthorized}`);
629
- }
630
620
  }
631
621
 
632
622
  const logger = new CustomLogger();
@@ -815,7 +805,11 @@ carries it; the wire never reads `config.username` or `config.password`.
815
805
 
816
806
  - HTTP takes TLS material (`cert`, `key`, `pfx`, `passphrase`) at logon and builds
817
807
  its `https.Agent` from it. `agentOptions` stays for what is not the credential
818
- — `ca` and `rejectUnauthorized`. A later logon offering different material
808
+ — `ca` and `rejectUnauthorized`. The server certificate is verified unless
809
+ `agentOptions.rejectUnauthorized` is `false`, or — with that left unset —
810
+ `TLS_REJECT_UNAUTHORIZED` or `NODE_TLS_REJECT_UNAUTHORIZED` is exactly `0`;
811
+ trust a self-signed system with `ca` rather than turning verification off
812
+ (see [MIGRATION-11.0.md](./MIGRATION-11.0.md)). A later logon offering different material
819
813
  replaces the client; the cookie jar and CSRF token are the session's and stay.
820
814
  HTTP refuses logon parameters.
821
815
  - RFC takes logon parameters (a password, or SNC settings) on every conversation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-abap-adt/connection",
3
- "version": "10.0.3",
3
+ "version": "11.0.1",
4
4
  "description": "ABAP connection layer for MCP ABAP ADT server",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",