@mcp-abap-adt/connection 19.1.0 → 20.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +83 -1
- package/README.md +110 -26
- package/dist/config/sapConfig.d.ts +6 -1
- package/dist/config/sapConfig.d.ts.map +1 -1
- package/dist/config/sapConfig.js +11 -0
- package/dist/connection/AbstractAbapConnection.d.ts +8 -2
- package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
- package/dist/connection/AbstractAbapConnection.js +17 -8
- package/dist/connection/CloudHttpTransport.js +2 -2
- package/dist/connection/CredentialAbapConnection.d.ts.map +1 -1
- package/dist/connection/CredentialAbapConnection.js +0 -1
- package/dist/connection/HttpTransport.d.ts +60 -18
- package/dist/connection/HttpTransport.d.ts.map +1 -1
- package/dist/connection/HttpTransport.js +46 -27
- package/dist/connection/IAdtTransport.d.ts +3 -2
- package/dist/connection/IAdtTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.d.ts +64 -9
- package/dist/connection/RfcTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.js +174 -31
- package/dist/connection/createConnection.d.ts +20 -4
- package/dist/connection/createConnection.d.ts.map +1 -1
- package/dist/connection/createConnection.js +45 -28
- package/dist/connection/rfcConversation.d.ts +31 -26
- package/dist/connection/rfcConversation.d.ts.map +1 -1
- package/dist/connection/rfcConversation.js +32 -46
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/docs/INDEX.md +2 -0
- package/docs/MIGRATION-18.0.md +2 -0
- package/docs/MIGRATION-20.0.md +121 -0
- package/docs/MIGRATION-6.0.md +2 -0
- package/docs/USAGE.md +37 -13
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,86 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [20.1.0] - 2026-11-09
|
|
11
|
+
|
|
12
|
+
A request runs in its `sap-language` over RFC as it does over HTTP.
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- **`RfcTransport` honours a request's `sap-language`.** `SADT_REST_RFC_ENDPOINT` has no ICF
|
|
17
|
+
logon: it ran every request in the conversation's logon language and ignored `sap-language`
|
|
18
|
+
as a header, a query parameter or a body attribute — a class created with `sap-language: RU`
|
|
19
|
+
on an EN logon got master language EN, where over HTTP it gets RU (measured on S/4HANA 2025).
|
|
20
|
+
Now a non-stateful request whose `sap-language` (a header, or the query parameter in `params`
|
|
21
|
+
or in the URL) names another language than the logon language of the conversation that would
|
|
22
|
+
carry it — the `lang` its logon carries: the provider's where it writes one, else the
|
|
23
|
+
factory's — goes on a conversation logged on in that language (its `lang` over any the
|
|
24
|
+
provider writes), opened for that call and closed after it, whatever the answer — a logger
|
|
25
|
+
that throws included; nothing is kept. A stateful request naming another language than the
|
|
26
|
+
stateful conversation's is refused before anything is sent, in words naming both languages: a session cannot change its language. A request naming two different
|
|
27
|
+
languages is refused the same way. Language keys are compared without case; the same
|
|
28
|
+
language, or none, goes as before. `HttpTransport` is unchanged. Measured on E19 (2026-11-09):
|
|
29
|
+
a class created over RFC with `sap-language: RU` on an EN logon reads back
|
|
30
|
+
`adtcore:masterLanguage="RU"`.
|
|
31
|
+
- **`RfcTransport.close()` closes every conversation whatever a close or the logger does.** A
|
|
32
|
+
stateless conversation whose close rejected, under a logger whose `debug` threw, stopped
|
|
33
|
+
`close()` before the stateful conversation was closed. Every close-path log line is now
|
|
34
|
+
written so that it cannot throw.
|
|
35
|
+
|
|
36
|
+
### Added
|
|
37
|
+
|
|
38
|
+
- **`RfcConversationFactory`**: what `RfcTransport` takes — the factory function, and its logon
|
|
39
|
+
`language` where stated. `rfcConversationFrom(config)` states the config's `language`. A plain
|
|
40
|
+
factory function still compiles; one that states no `language`, under a provider that writes no
|
|
41
|
+
`lang`, has every request naming a `sap-language` treated as naming another one.
|
|
42
|
+
|
|
43
|
+
## [20.0.0] - 2026-11-08
|
|
44
|
+
|
|
45
|
+
An RFC destination states its own address. Breaking for an RFC config and for code that reads
|
|
46
|
+
`getBaseUrl()`, builds an HTTP transport by hand or reads the session context's `baseUrl`; an HTTP
|
|
47
|
+
config passed to `createConnection` or the connectors compiles and behaves as before. See
|
|
48
|
+
[docs/MIGRATION-20.0.md](docs/MIGRATION-20.0.md).
|
|
49
|
+
|
|
50
|
+
### Changed — breaking
|
|
51
|
+
|
|
52
|
+
- **`@mcp-abap-adt/interfaces-auth-sap` ^4.0.0 and `@mcp-abap-adt/interfaces-adt-connection`
|
|
53
|
+
^4.0.0** (from ^3.4.0 and ^3.0.0). `ISapConfig` is a union by `connectionType`: an
|
|
54
|
+
`ISapHttpConfig` carries `url` and no RFC key; an `ISapRfcConfig` carries `client`, `language`
|
|
55
|
+
and one address — `ashost` + `sysnr`, or `mshost` + `msserv` / `sysid` (or both) + `group` —
|
|
56
|
+
and no `url`.
|
|
57
|
+
- **`rfcParamsFrom` / `rfcConversationFrom` take an `ISapRfcConfig` and read it as stated.** No
|
|
58
|
+
host or system number from a URL (the `80NN` port convention is gone), no `SAP_SYSNR` from the
|
|
59
|
+
environment, no `'000'` / `'EN'` / `'PUBLIC'` defaults, no trimming, no throw. `language` is the
|
|
60
|
+
SDK's `lang`; `msserv`, `sysid` and `saprouter` are sent exactly when stated.
|
|
61
|
+
`RfcMessageServerParams` is the "`msserv`, `sysid` or both" shape.
|
|
62
|
+
- **`createConnection`: each spec takes its own config shape** — `ISapHttpConfig` for the HTTP
|
|
63
|
+
wires, `ISapRfcConfig` for RFC — and the spec is narrowed by the compiler, with no cast. A `null`
|
|
64
|
+
or `undefined` spec fails with the runtime's own `TypeError`; any other value built past the
|
|
65
|
+
types is refused in the fixed words, as before.
|
|
66
|
+
- **`getBaseUrl(): Promise<string | undefined>`**: the `url`'s origin over HTTP, `undefined` over
|
|
67
|
+
RFC. An RFC config's construction parses no URL.
|
|
68
|
+
- **The HTTP transports take `baseUrl` as a required option**; a caller's path is put on it, and
|
|
69
|
+
the CSRF fetch, the cloud preflight and the logoff go to its origin, as before.
|
|
70
|
+
**`IAdtSessionContext` has no `baseUrl`**, and `establishSession` reads no `getBaseUrl()`.
|
|
71
|
+
|
|
72
|
+
### Added
|
|
73
|
+
|
|
74
|
+
- `SapHttpConfig` and `SapRfcConfig`, the two shapes of `SapConfig`.
|
|
75
|
+
- **`httpClient`, an option of the HTTP transports** (`HttpTransport`, `OnPremHttpTransport`,
|
|
76
|
+
`LegacyOnPremHttpTransport`, `CloudHttpTransport`): an `HttpClientFactory` — `create(agents)`
|
|
77
|
+
returns the axios instance the wire sends through, built from its two pooled agents
|
|
78
|
+
(`HttpClientAgents`), and `logoffRequest(options, onResponse)` the Node request a logoff goes
|
|
79
|
+
out on. Left out, it is the exported `nodeHttpClient`, which is what the wire used before:
|
|
80
|
+
nothing changes for a wire built without it. A test double goes under the wire through it.
|
|
81
|
+
`createConnection` passes it through for cloud + http, on-prem + http and on-prem + legacy-http
|
|
82
|
+
(`httpClient` beside `agentOptions` in `CloudHttpSpec` / `OnPremHttpSpec`).
|
|
83
|
+
|
|
84
|
+
### Fixed
|
|
85
|
+
|
|
86
|
+
- **`sapConfigSignature` names the RFC address**: it carries `connectionType`, `ashost`, `sysnr`,
|
|
87
|
+
`mshost`, `msserv`, `sysid`, `group`, `saprouter` and `language` besides `url` and `client`, so
|
|
88
|
+
two configs that dial different servers no longer share a signature.
|
|
89
|
+
|
|
10
90
|
## [19.1.0] - 2026-10-23
|
|
11
91
|
|
|
12
92
|
The HTTP wire's sockets change (below: Fixed and the first two Changed entries; a minor release because `https:` now keeps sockets alive); the
|
|
@@ -2790,7 +2870,9 @@ const connection = createAbapConnection(config, logger);
|
|
|
2790
2870
|
- JWT token refresh now properly handles connection errors (401/403 during initial connect)
|
|
2791
2871
|
- Permission errors (403 with "ExceptionResourceNoAccess") no longer trigger JWT refresh loops
|
|
2792
2872
|
- Proper separation: base class handles HTTP/session, concrete classes handle auth-specific errors
|
|
2793
|
-
[Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/
|
|
2873
|
+
[Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/v20.1.0...HEAD
|
|
2874
|
+
[20.1.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v20.0.0...v20.1.0
|
|
2875
|
+
[20.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v19.1.0...v20.0.0
|
|
2794
2876
|
[19.1.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v19.0.0...v19.1.0
|
|
2795
2877
|
[19.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v18.0.1...v19.0.0
|
|
2796
2878
|
[18.0.1]: https://github.com/fr0ster/mcp-abap-connection/compare/v18.0.0...v18.0.1
|
package/README.md
CHANGED
|
@@ -80,9 +80,10 @@ The package uses a clean separation of concerns:
|
|
|
80
80
|
conversation that IS the session
|
|
81
81
|
- On-prem is where this is a real choice; ABAP Cloud has one wire and its
|
|
82
82
|
connector takes no such parameter
|
|
83
|
-
- `rfcConversationFrom(config)` builds what `RfcTransport` needs
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
- `rfcConversationFrom(config)` builds what `RfcTransport` needs from an
|
|
84
|
+
RFC config's stated address, client and language — nothing derived, no
|
|
85
|
+
URL — and loads the SDK only when a conversation opens. It reads no user
|
|
86
|
+
or password: the provider writes the logon parameters
|
|
86
87
|
|
|
87
88
|
- **`GenericWebSocketTransport`** (concrete, exported):
|
|
88
89
|
- Transport abstraction for realtime WS message flows
|
|
@@ -161,6 +162,7 @@ the packages above. See [Migration to 9.0.0](./docs/MIGRATION-9.0.md).
|
|
|
161
162
|
|
|
162
163
|
- 📦 **[Installation Guide](./docs/INSTALLATION.md)** - Setup and installation instructions
|
|
163
164
|
- 📚 **[Usage Guide](./docs/USAGE.md)** - Detailed usage examples and API documentation
|
|
165
|
+
- 🚚 **[Migration to 20.0.0](./docs/MIGRATION-20.0.md)** - an RFC config is an `ISapRfcConfig` that states its address (`ashost` + `sysnr`, or `mshost` + `msserv` / `sysid` + `group`), `client` and `language`: no URL, no defaults, no `SAP_SYSNR`; `getBaseUrl()` may answer `undefined`; hand-built HTTP transports take `baseUrl`; `IAdtSessionContext` has no `baseUrl`
|
|
164
166
|
- 🚚 **[Migration to 19.0.0](./docs/MIGRATION-19.0.md)** - `@mcp-abap-adt/sap-rfc-lite` ^0.3.2: no compile on install; prebuilt RFC bindings for linux-x64, win32-x64, darwin-arm64; elsewhere build sap-rfc-lite's binding from its repository; the API is unchanged
|
|
165
167
|
- 🚚 **[Migration to 18.0.0](./docs/MIGRATION-18.0.md)** - `rfcParamsFrom` returns `RfcAddress` (application server or message server): narrow before reading `.ashost` / `.sysnr`; RFC through a message server and a logon group (`mshost`, `msserv` | `sysid`, `group`, `saprouter`)
|
|
166
168
|
- 🚚 **[Migration to 17.0.0](./docs/MIGRATION-17.0.md)** - no deadline of the package's own: `getTimeout`, `getTimeoutConfig` and `SAP_TIMEOUT_*` are gone, and a request inside a critical section carries none at all; an instance can be built on an existing session (`session`, `sessionCookies()`)
|
|
@@ -268,7 +270,7 @@ try {
|
|
|
268
270
|
`createConnection` returns a **new instance on every call**. Any other
|
|
269
271
|
combination of system and wire (cloud over RFC, say) is refused at
|
|
270
272
|
construction. The transport options are passed through as you give them:
|
|
271
|
-
`agentOptions` for the HTTP wires, `rfc` for the RFC wire, `wireLogger` for
|
|
273
|
+
`agentOptions` and `httpClient` for the HTTP wires, `rfc` for the RFC wire, `wireLogger` for
|
|
272
274
|
what the wire logs about itself, `logger` and `sessionId` for the connection.
|
|
273
275
|
The constructors below remain available; the factory only names the four
|
|
274
276
|
combinations that exist.
|
|
@@ -485,12 +487,26 @@ import {
|
|
|
485
487
|
RfcTransport,
|
|
486
488
|
rfcConversationFrom,
|
|
487
489
|
} from "@mcp-abap-adt/connection";
|
|
490
|
+
import type { SapRfcConfig } from "@mcp-abap-adt/connection";
|
|
488
491
|
import { BasicAuthProvider } from "@mcp-abap-adt/auth-providers";
|
|
489
492
|
|
|
493
|
+
// An RFC destination states its address — here one application server, its
|
|
494
|
+
// host and system number — and its client and logon language. No URL.
|
|
495
|
+
const rfcConfig: SapRfcConfig = {
|
|
496
|
+
connectionType: "rfc",
|
|
497
|
+
ashost: "your-sap-host",
|
|
498
|
+
sysnr: "00",
|
|
499
|
+
client: "100",
|
|
500
|
+
language: "EN",
|
|
501
|
+
authType: "basic",
|
|
502
|
+
username: "your-username",
|
|
503
|
+
password: "your-password",
|
|
504
|
+
};
|
|
505
|
+
|
|
490
506
|
const connection = new AdtOnPremConnector(
|
|
491
|
-
|
|
492
|
-
new BasicAuthProvider(
|
|
493
|
-
new RfcTransport(rfcConversationFrom(
|
|
507
|
+
rfcConfig,
|
|
508
|
+
new BasicAuthProvider(rfcConfig.username!, rfcConfig.password!),
|
|
509
|
+
new RfcTransport(rfcConversationFrom(rfcConfig), logger),
|
|
494
510
|
logger,
|
|
495
511
|
);
|
|
496
512
|
|
|
@@ -663,6 +679,35 @@ false }`, or (when `agentOptions` leaves it unset) `TLS_REJECT_UNAUTHORIZED=0` o
|
|
|
663
679
|
for production. Before 11.0.0 the certificate was not verified by default: see
|
|
664
680
|
[MIGRATION-11.0.md](./docs/MIGRATION-11.0.md).
|
|
665
681
|
|
|
682
|
+
### The HTTP client
|
|
683
|
+
|
|
684
|
+
An HTTP wire reaches the network through an `HttpClientFactory`, the `httpClient`
|
|
685
|
+
option of its constructor (20.0.0). Left out, it is `nodeHttpClient`: axios over
|
|
686
|
+
the wire's own pooled agents, and Node's `http` / `https` for the logoff — what
|
|
687
|
+
the wire has always used. Hand your own to put something under the wire, a test
|
|
688
|
+
double above all: everything the wire adds to its requests (cookies, CSRF token,
|
|
689
|
+
affinity headers, `sap-client`) still runs, and only the exchange is yours.
|
|
690
|
+
|
|
691
|
+
```typescript
|
|
692
|
+
import axios from "axios";
|
|
693
|
+
import {
|
|
694
|
+
type HttpClientFactory,
|
|
695
|
+
OnPremHttpTransport,
|
|
696
|
+
nodeHttpClient,
|
|
697
|
+
} from "@mcp-abap-adt/connection";
|
|
698
|
+
|
|
699
|
+
const httpClient: HttpClientFactory = {
|
|
700
|
+
...nodeHttpClient,
|
|
701
|
+
// Built from the wire's agents; built anew when a logon offers other TLS material.
|
|
702
|
+
create: (agents) => axios.create({ ...agents }),
|
|
703
|
+
};
|
|
704
|
+
const transport = new OnPremHttpTransport(() => ({}), logger, {
|
|
705
|
+
client: config.client,
|
|
706
|
+
baseUrl: config.url,
|
|
707
|
+
httpClient,
|
|
708
|
+
});
|
|
709
|
+
```
|
|
710
|
+
|
|
666
711
|
### Stateful Sessions
|
|
667
712
|
|
|
668
713
|
Enable stateful mode for requests that need the ABAP context, such as LOCK and
|
|
@@ -776,7 +821,7 @@ interface AbapConnection {
|
|
|
776
821
|
makeAdtRequest<T = unknown, D = unknown>(
|
|
777
822
|
options: AbapRequestOptions,
|
|
778
823
|
): Promise<IAdtWireResponse<T, D>>;
|
|
779
|
-
getBaseUrl(): Promise<string>;
|
|
824
|
+
getBaseUrl(): Promise<string | undefined>; // undefined over RFC: no HTTP origin
|
|
780
825
|
setSessionType(type: "stateless" | "stateful"): void; // Switch session type
|
|
781
826
|
getSessionId(): string | null; // Client-side conversation id
|
|
782
827
|
}
|
|
@@ -833,7 +878,7 @@ interface ILogger {
|
|
|
833
878
|
Builds a NEW connection from what the caller states: `system` (`'cloud'` or
|
|
834
879
|
`'onprem'`) and `transport` (`'http'`, `'legacy-http'` or `'rfc'`), plus
|
|
835
880
|
`config`, `credential` and, optionally, `logger`, `wireLogger`, `sessionId`,
|
|
836
|
-
`agentOptions` and `session` (HTTP) or `rfc` (`IRfcTransportOptions`). Nothing is inferred,
|
|
881
|
+
`agentOptions`, `httpClient` and `session` (HTTP) or `rfc` (`IRfcTransportOptions`). Nothing is inferred,
|
|
837
882
|
not even from `config.connectionType`. A combination that does not exist is
|
|
838
883
|
refused with a `TypeError`, and so is `session` over RFC. One instance is one
|
|
839
884
|
SAP session: call it again for a new one — or pass `session` (the string an
|
|
@@ -842,17 +887,19 @@ which `connect()` then takes over instead of logging on.
|
|
|
842
887
|
|
|
843
888
|
#### `rfcConversationFrom(config)`
|
|
844
889
|
|
|
845
|
-
What `RfcTransport` is constructed with
|
|
890
|
+
What `RfcTransport` is constructed with, from an RFC config
|
|
891
|
+
(`SapRfcConfig`, `connectionType: 'rfc'`). An RFC config has no URL: it states
|
|
892
|
+
its address, its `client` and its logon `language`, and the SDK gets them as
|
|
893
|
+
they are — nothing is derived, defaulted, trimmed or read from the environment.
|
|
894
|
+
The address is one of two, and the config's type admits exactly one:
|
|
846
895
|
|
|
847
|
-
- **One application server
|
|
848
|
-
|
|
849
|
-
`
|
|
850
|
-
|
|
851
|
-
config's `mshost`, `msserv` or `sysid` (one of the two is required) and
|
|
852
|
-
`group` (default `PUBLIC`) go to the SDK as they are, and the url gives no
|
|
853
|
-
host or system number — the message server picks the application server.
|
|
896
|
+
- **One application server**: `ashost` and `sysnr`.
|
|
897
|
+
- **A message server and a logon group**: `mshost`, its service as `msserv`,
|
|
898
|
+
`sysid` or both, and `group` — the message server picks the application
|
|
899
|
+
server.
|
|
854
900
|
|
|
855
|
-
`saprouter` goes with either.
|
|
901
|
+
`saprouter` goes with either. `language` reaches the SDK as `lang`. The
|
|
902
|
+
provider's logon parameters are spread over the address at each open.
|
|
856
903
|
|
|
857
904
|
The SAP NW RFC SDK is loaded when a conversation opens, not when this is called,
|
|
858
905
|
so a machine without it fails at `connect()` with a message saying what to
|
|
@@ -860,10 +907,12 @@ install rather than at construction.
|
|
|
860
907
|
|
|
861
908
|
```text
|
|
862
909
|
function rfcConversationFrom(
|
|
863
|
-
config:
|
|
864
|
-
):
|
|
865
|
-
|
|
866
|
-
//
|
|
910
|
+
config: SapRfcConfig,
|
|
911
|
+
): RfcConversationFactory & { readonly language: string };
|
|
912
|
+
// RfcConversationFactory = ((logon: Readonly<Record<string, string>>) => IRfcConversation)
|
|
913
|
+
// & { readonly language?: string } // the logon language
|
|
914
|
+
function rfcParamsFrom(config: SapRfcConfig): RfcAddress; // the address only
|
|
915
|
+
// RfcAddress = RfcConnectionParams (ashost, sysnr) | RfcMessageServerParams (mshost, msserv and/or sysid, group)
|
|
867
916
|
```
|
|
868
917
|
|
|
869
918
|
```typescript
|
|
@@ -875,9 +924,9 @@ import {
|
|
|
875
924
|
import { BasicAuthProvider } from "@mcp-abap-adt/auth-providers";
|
|
876
925
|
|
|
877
926
|
const connection = new AdtOnPremConnector(
|
|
878
|
-
|
|
879
|
-
new BasicAuthProvider(
|
|
880
|
-
new RfcTransport(rfcConversationFrom(
|
|
927
|
+
rfcConfig,
|
|
928
|
+
new BasicAuthProvider(rfcConfig.username!, rfcConfig.password!),
|
|
929
|
+
new RfcTransport(rfcConversationFrom(rfcConfig), logger),
|
|
881
930
|
logger,
|
|
882
931
|
);
|
|
883
932
|
```
|
|
@@ -885,7 +934,7 @@ const connection = new AdtOnPremConnector(
|
|
|
885
934
|
A third argument turns on the wire log, which is off by default:
|
|
886
935
|
|
|
887
936
|
```typescript
|
|
888
|
-
new RfcTransport(rfcConversationFrom(
|
|
937
|
+
new RfcTransport(rfcConversationFrom(rfcConfig), logger, { logWire: true });
|
|
889
938
|
```
|
|
890
939
|
|
|
891
940
|
It adds three debug lines per request — header fields, request body, response
|
|
@@ -896,6 +945,41 @@ themselves are not redacted, so read a captured log before pasting it into an
|
|
|
896
945
|
issue. `HttpTransport` never logs bodies, so this is the one wire whose debug
|
|
897
946
|
channel can be asked for the payload.
|
|
898
947
|
|
|
948
|
+
#### A request's language over RFC
|
|
949
|
+
|
|
950
|
+
A request runs in the language its `sap-language` names — a header, or the
|
|
951
|
+
`sap-language` query parameter in `params` or in the URL — on both wires. Over
|
|
952
|
+
HTTP the ICF layer reads it. `SADT_REST_RFC_ENDPOINT` runs a request in its
|
|
953
|
+
conversation's logon language and ignores `sap-language`, so `RfcTransport`
|
|
954
|
+
compares the two (SAP language keys, without case) — the request's language
|
|
955
|
+
with the logon language of the conversation that would carry it. A
|
|
956
|
+
conversation's logon language is the `lang` its logon carries: the provider's,
|
|
957
|
+
where it writes one among its logon parameters at that logon, else the one the
|
|
958
|
+
factory states (`rfcConversationFrom` states the config's `language`):
|
|
959
|
+
|
|
960
|
+
- **None named:** the request goes as any other.
|
|
961
|
+
- **A stateful request** is compared with the stateful conversation's logon
|
|
962
|
+
language.
|
|
963
|
+
- **A non-stateful request** is compared with the kept stateless
|
|
964
|
+
conversation's logon language — once it is open, the language it logged on
|
|
965
|
+
in; before, the language the provider's logon parameters for it name. The
|
|
966
|
+
same language: it goes on the kept conversation, as any other. Another: it
|
|
967
|
+
goes on a conversation logged on in the request's language (`lang` as the
|
|
968
|
+
request names it, over any `lang` the provider writes), opened for that one
|
|
969
|
+
call and closed when it answers, whatever the answer. Nothing is kept: the
|
|
970
|
+
next such call logs on again.
|
|
971
|
+
- **A stateful request in another language** (a `LOCK`, an `UNLOCK`, anything
|
|
972
|
+
in the lock's session): refused before anything is sent, with an error naming
|
|
973
|
+
both languages — a session cannot change its language. Connect with the
|
|
974
|
+
language the locked work needs.
|
|
975
|
+
- **Two different languages named on one request:** refused before anything is
|
|
976
|
+
sent.
|
|
977
|
+
|
|
978
|
+
A factory of your own that does not state `language`, with a provider that
|
|
979
|
+
writes no `lang`, leaves the wire without a logon language to compare: every
|
|
980
|
+
non-stateful request naming a `sap-language` then takes a conversation of its
|
|
981
|
+
own in that language, and every stateful one naming it is refused.
|
|
982
|
+
|
|
899
983
|
#### `CSRF_CONFIG` and `CSRF_ERROR_MESSAGES`
|
|
900
984
|
|
|
901
985
|
**New in 0.1.13+:** Exported constants for consistent CSRF token handling across different connection implementations.
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import type { ISapConfig, SapAuthType, SapConnectionType } from '@mcp-abap-adt/interfaces-auth-sap';
|
|
1
|
+
import type { ISapConfig, ISapHttpConfig, ISapRfcConfig, SapAuthType, SapConnectionType } from '@mcp-abap-adt/interfaces-auth-sap';
|
|
2
2
|
export type { SapAuthType, SapConnectionType };
|
|
3
|
+
/** A system's configuration: `SapHttpConfig` or `SapRfcConfig`, by `connectionType`. */
|
|
3
4
|
export type SapConfig = ISapConfig;
|
|
5
|
+
/** An HTTP destination: its URL, no RFC key. */
|
|
6
|
+
export type SapHttpConfig = ISapHttpConfig;
|
|
7
|
+
/** An RFC destination: its stated address, client and language, no URL. */
|
|
8
|
+
export type SapRfcConfig = ISapRfcConfig;
|
|
4
9
|
export declare function sapConfigSignature(config: ISapConfig): string;
|
|
5
10
|
//# sourceMappingURL=sapConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sapConfig.d.ts","sourceRoot":"","sources":["../../src/config/sapConfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,iBAAiB,EAClB,MAAM,mCAAmC,CAAC;AAG3C,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC;AAC/C,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"sapConfig.d.ts","sourceRoot":"","sources":["../../src/config/sapConfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,aAAa,EACb,WAAW,EACX,iBAAiB,EAClB,MAAM,mCAAmC,CAAC;AAG3C,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC;AAC/C,wFAAwF;AACxF,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC;AACnC,gDAAgD;AAChD,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC;AAC3C,2EAA2E;AAC3E,MAAM,MAAM,YAAY,GAAG,aAAa,CAAC;AAEzC,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAuC7D"}
|
package/dist/config/sapConfig.js
CHANGED
|
@@ -14,8 +14,19 @@ function sapConfigSignature(config) {
|
|
|
14
14
|
? `${config.sessionCookies.substring(0, 10)}...${config.sessionCookies.substring(Math.max(0, config.sessionCookies.length - 10))}`
|
|
15
15
|
: null;
|
|
16
16
|
return JSON.stringify({
|
|
17
|
+
connectionType: config.connectionType ?? null,
|
|
17
18
|
url: config.url,
|
|
19
|
+
// The RFC address, as stated: two configs that dial different servers
|
|
20
|
+
// never share a signature. An HTTP config has none of these.
|
|
21
|
+
ashost: config.ashost ?? null,
|
|
22
|
+
sysnr: config.sysnr ?? null,
|
|
23
|
+
mshost: config.mshost ?? null,
|
|
24
|
+
msserv: config.msserv ?? null,
|
|
25
|
+
sysid: config.sysid ?? null,
|
|
26
|
+
group: config.group ?? null,
|
|
27
|
+
saprouter: config.saprouter ?? null,
|
|
18
28
|
client: config.client ?? null,
|
|
29
|
+
language: config.language ?? null,
|
|
19
30
|
authType: config.authType,
|
|
20
31
|
username: config.username ?? null,
|
|
21
32
|
password: config.password ? 'set' : null,
|
|
@@ -27,7 +27,12 @@ declare abstract class AbstractAbapConnection implements AbapConnection, ISessio
|
|
|
27
27
|
* transports share this unit instead of a base class.
|
|
28
28
|
*/
|
|
29
29
|
protected readonly lifecycle: SessionLifecycle;
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
* The system's HTTP origin, read off an HTTP config's `url`. `undefined` for
|
|
32
|
+
* an RFC config: an RFC destination states its address and has no URL, and
|
|
33
|
+
* none is invented for it.
|
|
34
|
+
*/
|
|
35
|
+
private readonly baseUrl;
|
|
31
36
|
private sessionId;
|
|
32
37
|
private sessionMode;
|
|
33
38
|
/**
|
|
@@ -526,7 +531,8 @@ declare abstract class AbstractAbapConnection implements AbapConnection, ISessio
|
|
|
526
531
|
* keep it as a secret. Nothing here logs it.
|
|
527
532
|
*/
|
|
528
533
|
sessionCookies(): string | null;
|
|
529
|
-
|
|
534
|
+
/** The system's HTTP origin; `undefined` over RFC, which has none. */
|
|
535
|
+
getBaseUrl(): Promise<string | undefined>;
|
|
530
536
|
getAuthHeaders(): Promise<Record<string, string>>;
|
|
531
537
|
/**
|
|
532
538
|
* What every request carries from the credential. On every path, the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractAbapConnection.d.ts","sourceRoot":"","sources":["../../src/connection/AbstractAbapConnection.ts"],"names":[],"mappings":"AACA,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;AACvC,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;AAExC,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;AAwD5B,uBAAe,sBACb,YACE,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB;
|
|
1
|
+
{"version":3,"file":"AbstractAbapConnection.d.ts","sourceRoot":"","sources":["../../src/connection/AbstractAbapConnection.ts"],"names":[],"mappings":"AACA,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;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,KAAK,YAAY,EACjB,gBAAgB,E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,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAMlD;;OAEG;IACH,SAAS,CAAC,UAAU,IAAI,MAAM,GAAG,IAAI;IAIrC;;;;;;OAMG;IACH,SAAS,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAMlD;;;;;;;;OAQG;YACW,eAAe;IAU7B;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,aAAa;IAgCrB;;;;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"}
|
|
@@ -61,6 +61,11 @@ class AbstractAbapConnection {
|
|
|
61
61
|
* transports share this unit instead of a base class.
|
|
62
62
|
*/
|
|
63
63
|
lifecycle = new SessionLifecycle_js_1.SessionLifecycle();
|
|
64
|
+
/**
|
|
65
|
+
* The system's HTTP origin, read off an HTTP config's `url`. `undefined` for
|
|
66
|
+
* an RFC config: an RFC destination states its address and has no URL, and
|
|
67
|
+
* none is invented for it.
|
|
68
|
+
*/
|
|
64
69
|
baseUrl;
|
|
65
70
|
sessionId = null;
|
|
66
71
|
sessionMode = 'stateless';
|
|
@@ -205,13 +210,18 @@ class AbstractAbapConnection {
|
|
|
205
210
|
this.resumeFrom = session ?? null;
|
|
206
211
|
// Generate sessionId (used for sap-adt-connection-id header)
|
|
207
212
|
this.sessionId = sessionId || (0, node_crypto_1.randomUUID)();
|
|
208
|
-
//
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
this.baseUrl =
|
|
213
|
+
// The HTTP origin of an HTTP config's URL (an unparsable one refused); an
|
|
214
|
+
// RFC config has none.
|
|
215
|
+
if (config.connectionType === 'rfc') {
|
|
216
|
+
this.baseUrl = undefined;
|
|
212
217
|
}
|
|
213
|
-
|
|
214
|
-
|
|
218
|
+
else {
|
|
219
|
+
try {
|
|
220
|
+
this.baseUrl = new URL(config.url).origin;
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
throw new Error(`Invalid URL in configuration: ${error instanceof Error ? error.message : error}`);
|
|
224
|
+
}
|
|
215
225
|
}
|
|
216
226
|
this.logger?.debug(`AbstractAbapConnection - Session ID: ${this.sessionId.substring(0, 8)}...`);
|
|
217
227
|
}
|
|
@@ -664,7 +674,6 @@ class AbstractAbapConnection {
|
|
|
664
674
|
*/
|
|
665
675
|
sessionContext() {
|
|
666
676
|
return {
|
|
667
|
-
baseUrl: this.baseUrl,
|
|
668
677
|
authorize: (headers) => this.credentialHeaders(headers),
|
|
669
678
|
logon: (target) => this.logon(target),
|
|
670
679
|
extraHeaders: { 'sap-adt-connection-id': this.getSessionId() ?? '' },
|
|
@@ -1078,6 +1087,7 @@ class AbstractAbapConnection {
|
|
|
1078
1087
|
sessionCookies() {
|
|
1079
1088
|
return this.transport.sessionCookies();
|
|
1080
1089
|
}
|
|
1090
|
+
/** The system's HTTP origin; `undefined` over RFC, which has none. */
|
|
1081
1091
|
async getBaseUrl() {
|
|
1082
1092
|
return this.baseUrl;
|
|
1083
1093
|
}
|
|
@@ -1717,7 +1727,6 @@ class AbstractAbapConnection {
|
|
|
1717
1727
|
*/
|
|
1718
1728
|
leasedContext(lease, generation = lease?.generation) {
|
|
1719
1729
|
return {
|
|
1720
|
-
baseUrl: this.baseUrl,
|
|
1721
1730
|
authorize: async (headers) => {
|
|
1722
1731
|
await this.credentialHeaders(headers);
|
|
1723
1732
|
if (lease && !this.lifecycle.isCurrent(lease)) {
|
|
@@ -85,7 +85,7 @@ class CloudHttpTransport extends HttpTransport_js_1.HttpTransport {
|
|
|
85
85
|
// The cache-buster is Eclipse's; kept because this must not be served
|
|
86
86
|
// from anything's cache — a cached session document would hand back an
|
|
87
87
|
// address that belongs to a session somebody else already ended.
|
|
88
|
-
url: `${
|
|
88
|
+
url: `${this.origin()}${SESSIONS_PATH}?_=${Date.now()}`,
|
|
89
89
|
// No deadline: a client deadline closes the socket, and SAP then
|
|
90
90
|
// ends what was running on it. connect() waits for SAP's answer.
|
|
91
91
|
headers: {
|
|
@@ -112,7 +112,7 @@ class CloudHttpTransport extends HttpTransport_js_1.HttpTransport {
|
|
|
112
112
|
}
|
|
113
113
|
// Published only while its ICF service is active; without it the close
|
|
114
114
|
// sends the platform's own logoff instead.
|
|
115
|
-
this.logoff = this.resolveLink(this.linkHref(response.data, LOGOFF_REL), `${
|
|
115
|
+
this.logoff = this.resolveLink(this.linkHref(response.data, LOGOFF_REL), `${this.origin()}${SESSIONS_PATH}`);
|
|
116
116
|
this.logger?.debug(`Security session opened: ${resource}`);
|
|
117
117
|
}
|
|
118
118
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CredentialAbapConnection.d.ts","sourceRoot":"","sources":["../../src/connection/CredentialAbapConnection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,YAAY,EACb,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAoB,KAAK,aAAa,EAAW,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,KAAK,aAAa,EAAa,MAAM,oBAAoB,CAAC;AAGnE,8BAAsB,wBAAwB,CAC5C,WAAW,SAAS,aAAa,GAAG,aAAa,CACjD,SAAQ,sBAAsB;IAG5B,6EAA6E;IAC7E,QAAQ,CAAC,UAAU,EAAE,WAAW;gBAFhC,MAAM,EAAE,SAAS;IACjB,6EAA6E;IACpE,UAAU,EAAE,WAAW,EAChC,SAAS,EAAE,aAAa,EACxB,MAAM,GAAE,OAAO,G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C7B,SAAS,CAAC,EAAE,MAAM;IAClB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM;IAKlB;;;;;;;;;;OAUG;cACsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAU3D;;;;;;;OAOG;cACsB,gBAAgB,CACvC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,OAAO,CAAC,IAAI,CAAC;IAYhB,6EAA6E;cACpD,KAAK,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAUnE;;;OAGG;cACsB,kBAAkB,CACzC,SAAS,EAAE,cAAc,GACxB,OAAO,CAAC,aAAa,CAAC;cAIT,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;CA8ClD"}
|
|
@@ -89,7 +89,6 @@ class CredentialAbapConnection extends AbstractAbapConnection_js_1.AbstractAbapC
|
|
|
89
89
|
// credential itself, with nobody deciding anything.
|
|
90
90
|
await this.transport.establish({
|
|
91
91
|
...this.sessionContext(),
|
|
92
|
-
baseUrl: await this.getBaseUrl(),
|
|
93
92
|
isFatal: (error) => this.endsTheExchange(error),
|
|
94
93
|
});
|
|
95
94
|
this.logger?.debug('Connected', {
|
|
@@ -19,20 +19,46 @@
|
|
|
19
19
|
* not the credential). Material that changes between logons drops the client;
|
|
20
20
|
* the cookie jar and the CSRF token are the session's and stay.
|
|
21
21
|
*/
|
|
22
|
-
import { type ClientRequest, type IncomingMessage, type RequestOptions } from 'node:http';
|
|
23
|
-
import { type AgentOptions } from 'node:https';
|
|
22
|
+
import { type ClientRequest, Agent as HttpAgent, type IncomingMessage, type RequestOptions } from 'node:http';
|
|
23
|
+
import { Agent, type AgentOptions } from 'node:https';
|
|
24
24
|
import type { ILogonTarget } from '@mcp-abap-adt/interfaces-auth';
|
|
25
|
+
import { type AxiosInstance } from 'axios';
|
|
25
26
|
import type { ILogger } from '../logger.js';
|
|
26
27
|
import { type IAdtEstablishContext, type IAdtSessionContext, type IAdtTransport, type IAdtTransportRequest, type IAdtTransportResponse } from './IAdtTransport.js';
|
|
27
28
|
export { isStatefulRequest } from './statefulRequest.js';
|
|
29
|
+
/** What an HTTP wire builds its client from: its two pooled agents. */
|
|
30
|
+
export interface HttpClientAgents {
|
|
31
|
+
httpAgent: HttpAgent;
|
|
32
|
+
httpsAgent: Agent;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* How an HTTP wire reaches the network: the axios instance every request goes
|
|
36
|
+
* through, built from the wire's agents (built anew when a logon offers other
|
|
37
|
+
* TLS material), and the node request a logoff goes out on — the seam where
|
|
38
|
+
* its write is seen. `nodeHttpClient` is the shipped one; a consumer or a test
|
|
39
|
+
* hands its own to the constructor (`httpClient`).
|
|
40
|
+
*/
|
|
41
|
+
export interface HttpClientFactory {
|
|
42
|
+
create(agents: HttpClientAgents): AxiosInstance;
|
|
43
|
+
logoffRequest(options: RequestOptions, onResponse: (response: IncomingMessage) => void): ClientRequest;
|
|
44
|
+
}
|
|
45
|
+
/** axios over the wire's agents, and node's own `http` / `https` for a logoff. */
|
|
46
|
+
export declare const nodeHttpClient: HttpClientFactory;
|
|
28
47
|
export declare class HttpTransport implements IAdtTransport {
|
|
29
48
|
private readonly agentOptions;
|
|
30
49
|
protected readonly logger: ILogger | null;
|
|
31
50
|
/**
|
|
32
|
-
*
|
|
33
|
-
* first one on: the establishing call is where the
|
|
34
|
-
* token are issued, so a client applied any later is
|
|
35
|
-
* that already lives in another one. See
|
|
51
|
+
* `client`: the SAP client (mandant) every request on this wire
|
|
52
|
+
* addresses, from the first one on: the establishing call is where the
|
|
53
|
+
* session and its CSRF token are issued, so a client applied any later is
|
|
54
|
+
* applied to a session that already lives in another one. See
|
|
55
|
+
* `clientHeaders()`.
|
|
56
|
+
*
|
|
57
|
+
* `baseUrl`: the system this wire addresses, required. A path a caller
|
|
58
|
+
* sends is put on it; every request the wire originates itself — the
|
|
59
|
+
* CSRF fetch, the cloud preflight, the logoff — goes to its origin.
|
|
60
|
+
*
|
|
61
|
+
* `httpClient`: how the wire reaches the network. Absent: `nodeHttpClient`.
|
|
36
62
|
*/
|
|
37
63
|
private readonly options;
|
|
38
64
|
/**
|
|
@@ -72,17 +98,34 @@ export declare class HttpTransport implements IAdtTransport {
|
|
|
72
98
|
private combined;
|
|
73
99
|
private appServer;
|
|
74
100
|
private token;
|
|
75
|
-
constructor(agentOptions
|
|
101
|
+
constructor(agentOptions: (() => AgentOptions) | undefined, logger: (ILogger | null) | undefined,
|
|
76
102
|
/**
|
|
77
|
-
*
|
|
78
|
-
* first one on: the establishing call is where the
|
|
79
|
-
* token are issued, so a client applied any later is
|
|
80
|
-
* that already lives in another one. See
|
|
103
|
+
* `client`: the SAP client (mandant) every request on this wire
|
|
104
|
+
* addresses, from the first one on: the establishing call is where the
|
|
105
|
+
* session and its CSRF token are issued, so a client applied any later is
|
|
106
|
+
* applied to a session that already lives in another one. See
|
|
107
|
+
* `clientHeaders()`.
|
|
108
|
+
*
|
|
109
|
+
* `baseUrl`: the system this wire addresses, required. A path a caller
|
|
110
|
+
* sends is put on it; every request the wire originates itself — the
|
|
111
|
+
* CSRF fetch, the cloud preflight, the logoff — goes to its origin.
|
|
112
|
+
*
|
|
113
|
+
* `httpClient`: how the wire reaches the network. Absent: `nodeHttpClient`.
|
|
81
114
|
*/
|
|
82
|
-
options
|
|
115
|
+
options: {
|
|
83
116
|
client?: string;
|
|
84
|
-
baseUrl
|
|
117
|
+
baseUrl: string;
|
|
118
|
+
httpClient?: HttpClientFactory;
|
|
85
119
|
});
|
|
120
|
+
/**
|
|
121
|
+
* The system's origin: where the wire's own requests go — the CSRF fetch,
|
|
122
|
+
* the session check, the cloud preflight, the logoff — whatever path the
|
|
123
|
+
* configured URL carries. The same base the connection's `getBaseUrl()`
|
|
124
|
+
* answers.
|
|
125
|
+
*/
|
|
126
|
+
protected origin(): string;
|
|
127
|
+
/** The base URL without a trailing slash, for a caller's path to be put on. */
|
|
128
|
+
protected base(): string;
|
|
86
129
|
/**
|
|
87
130
|
* Fold a response into the wire state.
|
|
88
131
|
*
|
|
@@ -348,11 +391,10 @@ export declare class HttpTransport implements IAdtTransport {
|
|
|
348
391
|
/** Called once the request's bytes are on the socket. */
|
|
349
392
|
written?: () => void): Promise<IAdtTransportResponse>;
|
|
350
393
|
/**
|
|
351
|
-
* The node request a logoff goes out on — the seam where its write is seen
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
* answer is not read, so not following a redirect changes nothing.
|
|
394
|
+
* The node request a logoff goes out on — the seam where its write is seen:
|
|
395
|
+
* the `httpClient`'s, node's own `http` / `https` by default, as axios would
|
|
396
|
+
* use with redirects off. The logoff's answer is not read, so not following a
|
|
397
|
+
* redirect changes nothing.
|
|
356
398
|
*/
|
|
357
399
|
protected logoffRequest(options: RequestOptions, onResponse: (response: IncomingMessage) => void): ClientRequest;
|
|
358
400
|
/** The agent a logoff goes out on: never a pooled one. */
|