@mcp-abap-adt/connection 10.0.3 → 11.0.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 +26 -1
- package/README.md +23 -10
- package/dist/connection/HttpTransport.d.ts +2 -0
- package/dist/connection/HttpTransport.d.ts.map +1 -1
- package/dist/connection/HttpTransport.js +27 -7
- package/docs/INDEX.md +2 -0
- package/docs/INSTALLATION.md +31 -3
- package/docs/MIGRATION-11.0.md +90 -0
- package/docs/USAGE.md +5 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [11.0.0] - 2026-10-04
|
|
11
|
+
|
|
12
|
+
### Breaking
|
|
13
|
+
|
|
14
|
+
- **The server certificate is verified by default.** Up to 10.x the HTTPS agent
|
|
15
|
+
verified it only when `NODE_TLS_REJECT_UNAUTHORIZED` or
|
|
16
|
+
`TLS_REJECT_UNAUTHORIZED` was `1`; with neither set it accepted any
|
|
17
|
+
certificate — on every HTTP wire, `CloudHttpTransport` included. Now it
|
|
18
|
+
verifies as Node does, and turns verification off only when told so:
|
|
19
|
+
`agentOptions: { rejectUnauthorized: false }`, or — with `agentOptions`
|
|
20
|
+
leaving it unset — `TLS_REJECT_UNAUTHORIZED=0` or
|
|
21
|
+
`NODE_TLS_REJECT_UNAUTHORIZED=0`. Any other value (`1`, `false`, `no`, empty)
|
|
22
|
+
verifies. `agentOptions.rejectUnauthorized` wins over the environment.
|
|
23
|
+
A system with a self-signed or company-CA certificate that worked without
|
|
24
|
+
any setting is now refused at the first request: trust its CA with
|
|
25
|
+
`agentOptions: { ca }` (or `NODE_EXTRA_CA_CERTS`), or opt out explicitly.
|
|
26
|
+
See [MIGRATION-11.0.md](./docs/MIGRATION-11.0.md).
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
- An opt-out is logged once per wire at debug level, in fixed words:
|
|
31
|
+
`TLS: the server certificate is not verified (explicit opt-out)`. The old
|
|
32
|
+
`TLS configuration: rejectUnauthorized=…` debug line is gone.
|
|
33
|
+
|
|
10
34
|
## [10.0.3] - 2026-10-02
|
|
11
35
|
|
|
12
36
|
### Changed
|
|
@@ -2114,7 +2138,8 @@ const connection = createAbapConnection(config, logger);
|
|
|
2114
2138
|
- JWT token refresh now properly handles connection errors (401/403 during initial connect)
|
|
2115
2139
|
- Permission errors (403 with "ExceptionResourceNoAccess") no longer trigger JWT refresh loops
|
|
2116
2140
|
- Proper separation: base class handles HTTP/session, concrete classes handle auth-specific errors
|
|
2117
|
-
[Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/
|
|
2141
|
+
[Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/v11.0.0...HEAD
|
|
2142
|
+
[11.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v10.0.3...v11.0.0
|
|
2118
2143
|
[10.0.3]: https://github.com/fr0ster/mcp-abap-connection/compare/v10.0.2...v10.0.3
|
|
2119
2144
|
[10.0.2]: https://github.com/fr0ster/mcp-abap-connection/compare/v10.0.1...v10.0.2
|
|
2120
2145
|
[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()`
|
|
@@ -474,6 +475,28 @@ try {
|
|
|
474
475
|
|
|
475
476
|
See [USAGE.md](./docs/USAGE.md#when-the-credential-is-refused).
|
|
476
477
|
|
|
478
|
+
### The server certificate
|
|
479
|
+
|
|
480
|
+
The HTTP wire verifies the server certificate, as Node does. For a system with a
|
|
481
|
+
self-signed certificate or one from a company CA, trust that CA:
|
|
482
|
+
|
|
483
|
+
```typescript
|
|
484
|
+
import { readFileSync } from "node:fs";
|
|
485
|
+
import { OnPremHttpTransport } from "@mcp-abap-adt/connection";
|
|
486
|
+
|
|
487
|
+
const ca = readFileSync("/path/to/sap-system-ca.pem", "utf8");
|
|
488
|
+
const transport = new OnPremHttpTransport(() => ({ ca }), logger, {
|
|
489
|
+
client: config.client,
|
|
490
|
+
baseUrl: config.url,
|
|
491
|
+
});
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
Verification is turned off only explicitly — `agentOptions: { rejectUnauthorized:
|
|
495
|
+
false }`, or (when `agentOptions` leaves it unset) `TLS_REJECT_UNAUTHORIZED=0` or
|
|
496
|
+
`NODE_TLS_REJECT_UNAUTHORIZED=0`; any other value verifies. A last resort, never
|
|
497
|
+
for production. Before 11.0.0 the certificate was not verified by default: see
|
|
498
|
+
[MIGRATION-11.0.md](./docs/MIGRATION-11.0.md).
|
|
499
|
+
|
|
477
500
|
### Stateful Sessions
|
|
478
501
|
|
|
479
502
|
Enable stateful mode for requests that need the ABAP context, such as LOCK and
|
|
@@ -537,14 +560,6 @@ class MyLogger implements ILogger {
|
|
|
537
560
|
debug(message: string, meta?: any): void {
|
|
538
561
|
// Your logging implementation
|
|
539
562
|
}
|
|
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
563
|
}
|
|
549
564
|
|
|
550
565
|
const logger = new MyLogger();
|
|
@@ -698,8 +713,6 @@ interface ILogger {
|
|
|
698
713
|
error(message: string, meta?: any): void;
|
|
699
714
|
warn(message: string, meta?: any): void;
|
|
700
715
|
debug(message: string, meta?: any): void;
|
|
701
|
-
csrfToken?(action: "fetch" | "retry" | "success" | "error", message: string, meta?: any): void;
|
|
702
|
-
tlsConfig?(rejectUnauthorized: boolean): void;
|
|
703
716
|
}
|
|
704
717
|
```
|
|
705
718
|
|
|
@@ -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
|
*
|
|
@@ -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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;OAKG;IACG,IAAI,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAIzE;;;;;;;;;;;;;OAaG;cACa,YAAY,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
|
*
|
|
@@ -472,16 +492,16 @@ class HttpTransport {
|
|
|
472
492
|
}
|
|
473
493
|
client() {
|
|
474
494
|
if (!this.instance) {
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
495
|
+
const options = this.agentOptions();
|
|
496
|
+
const rejectUnauthorized = verifiesServerCertificate(options);
|
|
497
|
+
if (!rejectUnauthorized && !this.saidUnverified) {
|
|
498
|
+
this.saidUnverified = true;
|
|
499
|
+
this.logger?.debug('TLS: the server certificate is not verified (explicit opt-out)');
|
|
500
|
+
}
|
|
481
501
|
this.instance = axios_1.default.create({
|
|
482
502
|
httpsAgent: new node_https_1.Agent({
|
|
503
|
+
...options,
|
|
483
504
|
rejectUnauthorized,
|
|
484
|
-
...this.agentOptions(),
|
|
485
505
|
...this.material,
|
|
486
506
|
}),
|
|
487
507
|
});
|
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()`
|
package/docs/INSTALLATION.md
CHANGED
|
@@ -328,13 +328,41 @@ npm run build
|
|
|
328
328
|
|
|
329
329
|
### SSL/TLS errors
|
|
330
330
|
|
|
331
|
-
|
|
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
|
|
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
|
-
|
|
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.
|
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`.
|
|
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
|