@mcp-abap-adt/connection 9.4.2 → 10.0.2
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 +182 -1
- package/README.md +78 -37
- package/dist/connection/AbstractAbapConnection.d.ts +211 -56
- package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
- package/dist/connection/AbstractAbapConnection.js +622 -255
- package/dist/connection/CloudHttpTransport.d.ts.map +1 -1
- package/dist/connection/CloudHttpTransport.js +15 -5
- package/dist/connection/CredentialAbapConnection.d.ts +21 -20
- package/dist/connection/CredentialAbapConnection.d.ts.map +1 -1
- package/dist/connection/CredentialAbapConnection.js +39 -46
- package/dist/connection/HttpTransport.d.ts +30 -14
- package/dist/connection/HttpTransport.d.ts.map +1 -1
- package/dist/connection/HttpTransport.js +99 -19
- package/dist/connection/IAdtTransport.d.ts +19 -2
- package/dist/connection/IAdtTransport.d.ts.map +1 -1
- package/dist/connection/OnPremHttpTransport.d.ts.map +1 -1
- package/dist/connection/OnPremHttpTransport.js +4 -3
- package/dist/connection/RfcTransport.d.ts +23 -3
- package/dist/connection/RfcTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.js +48 -15
- package/dist/connection/authErrors.d.ts +61 -0
- package/dist/connection/authErrors.d.ts.map +1 -0
- package/dist/connection/authErrors.js +78 -0
- package/dist/connection/requestTarget.d.ts +12 -0
- package/dist/connection/requestTarget.d.ts.map +1 -0
- package/dist/connection/requestTarget.js +23 -0
- package/dist/connection/rfcConversation.d.ts +10 -5
- package/dist/connection/rfcConversation.d.ts.map +1 -1
- package/dist/connection/rfcConversation.js +6 -8
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -12
- package/dist/session/SessionLifecycle.d.ts +1 -1
- package/dist/session/SessionLifecycle.d.ts.map +1 -1
- package/docs/INDEX.md +4 -1
- package/docs/INSTALLATION.md +15 -7
- package/docs/JWT_AUTH_TOOLS.md +2 -2
- package/docs/MIGRATION-10.0.md +284 -0
- package/docs/SCOPE.md +2 -2
- package/docs/STATEFUL_SESSION_GUIDE.md +30 -10
- package/docs/USAGE.md +118 -35
- package/examples/README.md +5 -4
- package/examples/basic-connection.js +1 -1
- package/examples/jwt-with-token-refresh.js +14 -15
- package/examples/saml-connection.js +1 -1
- package/package.json +5 -4
- package/dist/auth/FileCertificateMaterialLoader.d.ts +0 -6
- package/dist/auth/FileCertificateMaterialLoader.d.ts.map +0 -1
- package/dist/auth/FileCertificateMaterialLoader.js +0 -28
- package/dist/auth/ntlm.d.ts +0 -26
- package/dist/auth/ntlm.d.ts.map +0 -1
- package/dist/auth/ntlm.js +0 -72
- package/dist/auth/providers.d.ts +0 -125
- package/dist/auth/providers.d.ts.map +0 -1
- package/dist/auth/providers.js +0 -183
- package/dist/utils/tokenRefresh.d.ts +0 -15
- package/dist/utils/tokenRefresh.d.ts.map +0 -1
- package/dist/utils/tokenRefresh.js +0 -55
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,184 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [10.0.2] - 2026-09-30
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- **Node.js 22, 24 or 26**: `engines` is `"^22 || ^24 || ^26"` (was `>=18.0.0`), the versions SAP BTP Cloud Foundry runs — the same range as `@mcp-abap-adt/auth-providers` 5.x, which 10.x consumers install beside it. Node 18 and 20 are end of life and no longer tested; CI runs 22, 24 and 26 on Linux and Windows, and the release builds on 22.
|
|
15
|
+
|
|
16
|
+
## [10.0.1] - 2026-09-30
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- **A `close()` that throws synchronously is absorbed like one that rejects.**
|
|
21
|
+
A custom wire's non-async `close()` that threw escaped before any `.catch` was
|
|
22
|
+
attached: after a failed establishment it replaced the establishment error and
|
|
23
|
+
skipped the clearing behind it, so the failed attempt's cookies survived into
|
|
24
|
+
the next `connect()`; in `disconnect()` it made the method that never throws,
|
|
25
|
+
throw. Every goodbye now goes through one path that absorbs both. `close()` is
|
|
26
|
+
still called synchronously — the wires snapshot the cookie jar and the
|
|
27
|
+
affinity headers on their first line, before the teardown clears them.
|
|
28
|
+
- **A request's own token fetch sends nothing once its session is gone.** The
|
|
29
|
+
upfront token fetch before a mutation, a CSRF recovery fetch and the fetch
|
|
30
|
+
after a refused logon awaited the provider's `authorize` before sending; a
|
|
31
|
+
`disconnect()` and `connect()` in that window let one discovery request go out
|
|
32
|
+
on the new session's cookies (no work request ever did). The request's lease
|
|
33
|
+
is now checked after the provider has written, and the request ends
|
|
34
|
+
`NOT_CONNECTED` with nothing sent. `connect()`'s own establishment is unchanged.
|
|
35
|
+
- **A resend answered "session not found" is `SESSION_REPLACED`, like the first
|
|
36
|
+
attempt.** Only the first attempt's `400` went through the dead-session check;
|
|
37
|
+
a resend — the one more attempt after a renewal (inside a critical section
|
|
38
|
+
too), the CSRF resend, a GET resent with the session's cookies — surfaced the
|
|
39
|
+
raw `400` and left the connection connected to a dead session. Every attempt
|
|
40
|
+
now goes through the same check: the session is lost and the caller gets
|
|
41
|
+
`SESSION_REPLACED`.
|
|
42
|
+
- **An answer to a request's token fetch that arrives after a reconnect is not
|
|
43
|
+
folded into the new session.** The wire ingested an establishment answer's
|
|
44
|
+
cookies and token itself, after the connection's fenced `observe`, so an old
|
|
45
|
+
session's answer could overwrite the new session's jar. The connection now
|
|
46
|
+
refuses such an answer from `observe` with a session verdict, which the wire
|
|
47
|
+
hands up before folding anything in; the request ends `NOT_CONNECTED`.
|
|
48
|
+
`connect()`'s own establishment is unchanged.
|
|
49
|
+
- **A resend refused after its session went away is `NOT_CONNECTED`**, not
|
|
50
|
+
`AuthRefusedError` (refused again): the session the request was admitted to
|
|
51
|
+
is gone, so the refusal says nothing about the credential.
|
|
52
|
+
- **A stale request ends `NOT_CONNECTED`, whatever stopped it.** When the
|
|
53
|
+
session a request was admitted to goes away while the provider authorizes
|
|
54
|
+
its first attempt, while it readies its wire, while the provider renews, or
|
|
55
|
+
during one of the wire's resends (the CSRF resend, a GET resent with its
|
|
56
|
+
cookies or after a token fetch), the caller gets `NOT_CONNECTED` — never the
|
|
57
|
+
wire's `WireLogonError`, a network error, or the provider's
|
|
58
|
+
`AuthRefusedError` about a session the request no longer holds. A session
|
|
59
|
+
verdict (`SESSION_REPLACED`) still comes through as it is. What the server
|
|
60
|
+
answered to an attempt sent while the session was current, other than a
|
|
61
|
+
credential refusal, still reaches the caller as it is.
|
|
62
|
+
|
|
63
|
+
### Changed
|
|
64
|
+
|
|
65
|
+
- **`fetchCsrfToken`'s protected fourth parameter accepts a request lease as
|
|
66
|
+
well as a session generation number.** A number keeps its 10.0.0 meaning: it
|
|
67
|
+
fences what the connection does with the answer, not the wire's own ingest,
|
|
68
|
+
and never stops the fetch being sent. Only a lease fences the send.
|
|
69
|
+
- **For custom-wire authors: `IAdtEstablishContext.observe` may throw.** For an
|
|
70
|
+
answer that belongs to a session that is gone, it throws a `NOT_CONNECTED`
|
|
71
|
+
session verdict. Call `observe` BEFORE your wire folds that answer into its
|
|
72
|
+
own state, and fold nothing when it throws; `HttpTransport` already does. A
|
|
73
|
+
wire that ingests first would write a gone session's cookies into the new
|
|
74
|
+
session's jar.
|
|
75
|
+
|
|
76
|
+
### Documentation
|
|
77
|
+
|
|
78
|
+
- **A dead session inside a critical section.** `docs/USAGE.md` and
|
|
79
|
+
`docs/STATEFUL_SESSION_GUIDE.md` now state the price of keeping a lock through
|
|
80
|
+
a renewal: when SAP answers the resend with the same session cookie, a session
|
|
81
|
+
it really lost ends the request as `AuthRefusedError` (refused again), not
|
|
82
|
+
`SESSION_REPLACED`, and the connection stays connected. Treat the lock as lost
|
|
83
|
+
and reconnect.
|
|
84
|
+
- **Renewal sharing.** `docs/USAGE.md` "Concurrency" no longer says providers
|
|
85
|
+
that renew share one renewal in flight: requests share one only if the provider
|
|
86
|
+
(for `TokenAuthProvider.from`, its refresher) does; the connection adds no
|
|
87
|
+
single-flight.
|
|
88
|
+
|
|
89
|
+
## [10.0.0] - 2026-09-30
|
|
90
|
+
|
|
91
|
+
**The connection is the process on the `IAuthProvider` 3.0 contract.** It no
|
|
92
|
+
longer knows what a credential is: it asks the provider before every attempt,
|
|
93
|
+
puts a refusal the wire could not cure to the provider, and gives the caller the
|
|
94
|
+
provider's own words when the answer is no. The credential providers left with
|
|
95
|
+
it. See [`docs/MIGRATION-10.0.md`](docs/MIGRATION-10.0.md).
|
|
96
|
+
|
|
97
|
+
### Breaking
|
|
98
|
+
|
|
99
|
+
- **`@mcp-abap-adt/interfaces-auth` `^3.0.0`.** The connection calls `prepare`
|
|
100
|
+
once, before the wire opens (it used to run after `transport.open()`);
|
|
101
|
+
`establish` at each logon; `authorize` before every attempt of every request,
|
|
102
|
+
including the CSRF fetch, the cloud preflight, the logoff and each resend; and
|
|
103
|
+
`rejected` when the system said no. A provider written against 2.x does not
|
|
104
|
+
type-check.
|
|
105
|
+
- **`IAdtSessionContext.authHeaders` is replaced by `authorize(headers)` and
|
|
106
|
+
`logon(target)`.** A custom `IAdtTransport` fills a request it originates with
|
|
107
|
+
`context.authorize(headers)` and calls `context.logon(target)` at each of its
|
|
108
|
+
logons.
|
|
109
|
+
- **A refusal reaches the caller as `AuthRefusedError { refusal, at, cause }`,
|
|
110
|
+
in the provider's words.** A 401 that survives the wire's own session recovery,
|
|
111
|
+
or a logon the system refused, goes to `rejected()`; on Ok the request is sent
|
|
112
|
+
exactly once more, and a second refusal is the verdict (the fixed reason "the
|
|
113
|
+
credential was refused again after the provider renewed it"). A 403 never goes
|
|
114
|
+
to the provider. A provider that throws is a refusal with the reason "the
|
|
115
|
+
credential provider failed".
|
|
116
|
+
- **Inside a critical section a renewal keeps the session.** A mutation refused
|
|
117
|
+
with a 401 while a CSRF token is cached used to drop the session and resend on
|
|
118
|
+
a new one, losing the lock the section held. Inside `beginCriticalSection()`
|
|
119
|
+
it now goes to `rejected({ at: 'request' })` and, on Ok, is resent on the same
|
|
120
|
+
session with the same token; a session SAP replaced surfaces as
|
|
121
|
+
`SESSION_REPLACED`. Outside a critical section the wire's recovery runs first,
|
|
122
|
+
as before.
|
|
123
|
+
- **RFC: the factory takes the logon parameters.** `RfcTransport`'s first
|
|
124
|
+
argument is `(logon) => IRfcConversation`, and every conversation it opens —
|
|
125
|
+
the session's own and each per-call one — gets the parameters the provider
|
|
126
|
+
wrote. `rfcConversationFrom(config)` returns such a factory. `rfcParamsFrom`
|
|
127
|
+
returns the address only and no longer reads `username` / `password`;
|
|
128
|
+
`RfcConnectionParams` loses `user` and `passwd`. A provider that writes no
|
|
129
|
+
logon parameters (a bearer token) cannot log on over RFC.
|
|
130
|
+
- **HTTP takes TLS material at logon.** The agent is built from
|
|
131
|
+
`{ rejectUnauthorized, ...agentOptions(), ...material }`, `material` being
|
|
132
|
+
only the defined `cert`, `key`, `pfx` and `passphrase` the provider offered;
|
|
133
|
+
the constructor's `agentOptions` stays for `ca` and `rejectUnauthorized`. A later logon offering
|
|
134
|
+
different material replaces the client; the cookie jar and CSRF token stay.
|
|
135
|
+
HTTP refuses logon parameters.
|
|
136
|
+
- **A failed RFC open is thrown as `WireLogonError`** carrying the raw
|
|
137
|
+
`sap-rfc-lite` error as `cause`, not wrapped in `Failed to open RFC
|
|
138
|
+
connection: …`.
|
|
139
|
+
- **An RFC open that fails for any reason, a network one included**
|
|
140
|
+
(`RFC_COMMUNICATION_FAILURE`, say), goes to the provider and reaches the
|
|
141
|
+
caller as `AuthRefusedError` at `'logon'` — the provider's words, or the fixed
|
|
142
|
+
"refused again" reason after its Ok — with the SDK error only in `cause`.
|
|
143
|
+
- **A 401 while HTTP establishes its session** is thrown at once as
|
|
144
|
+
`WireLogonError { status: 401 }` and is not retried by the establishment's own
|
|
145
|
+
retry loop.
|
|
146
|
+
|
|
147
|
+
### Added
|
|
148
|
+
|
|
149
|
+
- `AuthRefusedError` and `WireLogonError`, exported. `WireLogonError { cause,
|
|
150
|
+
status? }` is the mark a wire puts on a failure that is a refused logon, so a
|
|
151
|
+
consumer's own wire can say the same thing; it decides nothing.
|
|
152
|
+
- `AuthRefusalMoment` (`'prepare' | 'logon' | 'request'`), exported.
|
|
153
|
+
- `docs/MIGRATION-10.0.md`.
|
|
154
|
+
|
|
155
|
+
### Removed
|
|
156
|
+
|
|
157
|
+
- **`BasicAuthProvider`, `TokenAuthProvider`, `SamlAuthProvider`,
|
|
158
|
+
`CertificateAuthProvider` and `FileCertificateMaterialLoader`** — they are in
|
|
159
|
+
`@mcp-abap-adt/auth-providers` ^5.0.1, which this package depends on for
|
|
160
|
+
tests only. `TokenAuthProvider` is built with `.fixed(token)` or
|
|
161
|
+
`.from(refresher)`; `new TokenAuthProvider(x)` is gone.
|
|
162
|
+
- `CredentialAbapConnection.getHttpsAgentOptions`, `buildAuthorizationHeader`
|
|
163
|
+
and `isUnauthorized`; `AbstractAbapConnection.recoverSession` and
|
|
164
|
+
`discardSession`; `src/utils/tokenRefresh.ts` and `src/auth/ntlm.ts` — nothing
|
|
165
|
+
read them.
|
|
166
|
+
|
|
167
|
+
### Fixed
|
|
168
|
+
|
|
169
|
+
- **A stale CSRF token under Basic is no longer read as a refused password.**
|
|
170
|
+
The wire's session recovery runs first; only a 401 that survives it reaches
|
|
171
|
+
the provider.
|
|
172
|
+
- **Every resend is re-authorized.** The recovery resends used the
|
|
173
|
+
`Authorization` read once before the first attempt; a renewed token was never
|
|
174
|
+
on them.
|
|
175
|
+
- **The wire's recovery no longer hides a credential failure.** A failed retry
|
|
176
|
+
of a CSRF recovery, a swallowed token fetch, and the upfront token fetch
|
|
177
|
+
before a mutation used to throw the original error or send the mutation
|
|
178
|
+
anyway; an `AuthRefusedError`, a `WireLogonError` or a surviving 401 goes on
|
|
179
|
+
to the provider instead. One credential retry per request, whichever comes
|
|
180
|
+
first.
|
|
181
|
+
- **Documentation.** The README, `docs/USAGE.md` and the other guides no longer
|
|
182
|
+
import providers from this package, and no longer say that a 401 surfaces with
|
|
183
|
+
nothing renewing behind it or that `renew()` on an `IRenewableCredential` is
|
|
184
|
+
the seam. Concurrent requests meeting one expired token each call
|
|
185
|
+
`rejected()`; a provider that renews may share one renewal in flight
|
|
186
|
+
(`TokenAuthProvider.from` only if its refresher does).
|
|
187
|
+
|
|
10
188
|
## [9.4.2] - 2026-09-27
|
|
11
189
|
|
|
12
190
|
### Changed
|
|
@@ -1923,7 +2101,10 @@ const connection = createAbapConnection(config, logger);
|
|
|
1923
2101
|
- JWT token refresh now properly handles connection errors (401/403 during initial connect)
|
|
1924
2102
|
- Permission errors (403 with "ExceptionResourceNoAccess") no longer trigger JWT refresh loops
|
|
1925
2103
|
- Proper separation: base class handles HTTP/session, concrete classes handle auth-specific errors
|
|
1926
|
-
[Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/
|
|
2104
|
+
[Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/v10.0.2...HEAD
|
|
2105
|
+
[10.0.2]: https://github.com/fr0ster/mcp-abap-connection/compare/v10.0.1...v10.0.2
|
|
2106
|
+
[10.0.1]: https://github.com/fr0ster/mcp-abap-connection/compare/v10.0.0...v10.0.1
|
|
2107
|
+
[10.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v9.4.2...v10.0.0
|
|
1927
2108
|
[9.4.2]: https://github.com/fr0ster/mcp-abap-connection/compare/v9.4.1...v9.4.2
|
|
1928
2109
|
[9.4.1]: https://github.com/fr0ster/mcp-abap-connection/compare/v9.4.0...v9.4.1
|
|
1929
2110
|
[9.4.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v9.3.4...v9.4.0
|
package/README.md
CHANGED
|
@@ -56,16 +56,17 @@ The package uses a clean separation of concerns:
|
|
|
56
56
|
session open while the logoff removes it — so asking the server would pick the
|
|
57
57
|
mechanism that releases nothing.
|
|
58
58
|
|
|
59
|
-
- **Auth providers** (
|
|
60
|
-
`
|
|
61
|
-
|
|
62
|
-
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
- **Auth providers** (an `IAuthProvider` from `@mcp-abap-adt/interfaces-auth`; the
|
|
60
|
+
ready-made ones — `BasicAuthProvider`, `TokenAuthProvider`, `SamlAuthProvider`,
|
|
61
|
+
`CertificateAuthProvider` — are in `@mcp-abap-adt/auth-providers`, not here):
|
|
62
|
+
- What a connection authenticates with, passed in. The connection never asks
|
|
63
|
+
what kind of provider it was given; it calls the same four methods on all of
|
|
64
|
+
them: `prepare` once before the wire opens, `establish` at each logon,
|
|
65
|
+
`authorize` before every attempt, `rejected` when the system refused
|
|
66
|
+
- A `401` that survives the wire's own session recovery, or a refused logon, is
|
|
67
|
+
put to the provider through `rejected`. If it answers Ok (a renewed token, say)
|
|
68
|
+
the request gets exactly one more attempt; if it says no, or the retry is
|
|
69
|
+
refused too, you get an `AuthRefusedError` carrying the provider's own words
|
|
69
70
|
|
|
70
71
|
- **Transports** (`OnPremHttpTransport`, `CloudHttpTransport`, `RfcTransport`):
|
|
71
72
|
- What a request travels over, and everything that is true of that wire.
|
|
@@ -75,7 +76,8 @@ The package uses a clean separation of concerns:
|
|
|
75
76
|
- On-prem is where this is a real choice; ABAP Cloud has one wire and its
|
|
76
77
|
connector takes no such parameter
|
|
77
78
|
- `rfcConversationFrom(config)` builds what `RfcTransport` needs, deriving
|
|
78
|
-
`ashost` and `sysnr` and loading the SDK only when a conversation opens
|
|
79
|
+
`ashost` and `sysnr` and loading the SDK only when a conversation opens. It
|
|
80
|
+
reads no user or password: the provider writes the logon parameters
|
|
79
81
|
|
|
80
82
|
- **`GenericWebSocketTransport`** (concrete, exported):
|
|
81
83
|
- Transport abstraction for realtime WS message flows
|
|
@@ -137,7 +139,7 @@ dependencies of this one besides `axios`, `commander` and `open`:
|
|
|
137
139
|
| Package | What this package takes from it |
|
|
138
140
|
|---|---|
|
|
139
141
|
| `@mcp-abap-adt/interfaces-adt-connection` | `IAbapConnection`, `IAbapRequestOptions`, `IAdtWireResponse`, `ITimeoutConfig`, the capability atoms, `ADT_SESSION_ERROR` |
|
|
140
|
-
| `@mcp-abap-adt/interfaces-auth` | `IAuthProvider`, `
|
|
142
|
+
| `@mcp-abap-adt/interfaces-auth` | `IAuthProvider`, `AuthOutcome`, `IAuthRefusal`, `IAuthRejection`, `ILogonTarget`, `IRequestTarget`, `ICertificateMaterial`, `ITokenRefresher`, `ITokenRefreshResult` |
|
|
141
143
|
| `@mcp-abap-adt/interfaces-auth-sap` | `ISapConfig`, `SapAuthType`, `SapConnectionType`, `ICertificateMaterialLoader` |
|
|
142
144
|
| `@mcp-abap-adt/interfaces-network` | `NETWORK_ERROR_CODES`, the WebSocket contracts |
|
|
143
145
|
| `@mcp-abap-adt/interfaces-utils` | `ILogger` |
|
|
@@ -152,6 +154,7 @@ the packages above. See [Migration to 9.0.0](./docs/MIGRATION-9.0.md).
|
|
|
152
154
|
|
|
153
155
|
- 📦 **[Installation Guide](./docs/INSTALLATION.md)** - Setup and installation instructions
|
|
154
156
|
- 📚 **[Usage Guide](./docs/USAGE.md)** - Detailed usage examples and API documentation
|
|
157
|
+
- 🚚 **[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
|
|
155
158
|
- 🚚 **[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
|
|
156
159
|
- 🚚 **[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()`
|
|
157
160
|
- 🚚 **[Migration to 6.0.0](./docs/MIGRATION-6.0.md)** - the factory and the per-credential classes are removed; RFC is a transport, not a class
|
|
@@ -183,6 +186,14 @@ longer brings them along:
|
|
|
183
186
|
npm install @mcp-abap-adt/interfaces-adt-connection @mcp-abap-adt/interfaces-auth @mcp-abap-adt/interfaces-auth-sap
|
|
184
187
|
```
|
|
185
188
|
|
|
189
|
+
The credential providers (`BasicAuthProvider`, `TokenAuthProvider`,
|
|
190
|
+
`SamlAuthProvider`, `CertificateAuthProvider`) are not part of this package
|
|
191
|
+
since 10.0.0. Install them from where they live:
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
npm install @mcp-abap-adt/auth-providers
|
|
195
|
+
```
|
|
196
|
+
|
|
186
197
|
For detailed installation instructions, see [Installation Guide](./docs/INSTALLATION.md).
|
|
187
198
|
|
|
188
199
|
## Quick Start
|
|
@@ -192,11 +203,11 @@ For detailed installation instructions, see [Installation Guide](./docs/INSTALLA
|
|
|
192
203
|
```typescript
|
|
193
204
|
import {
|
|
194
205
|
AdtOnPremConnector,
|
|
195
|
-
BasicAuthProvider,
|
|
196
206
|
OnPremHttpTransport,
|
|
197
207
|
SapConfig,
|
|
198
208
|
getTimeout,
|
|
199
209
|
} from "@mcp-abap-adt/connection";
|
|
210
|
+
import { BasicAuthProvider } from "@mcp-abap-adt/auth-providers";
|
|
200
211
|
|
|
201
212
|
const config: SapConfig = {
|
|
202
213
|
url: "https://your-sap-system.com",
|
|
@@ -242,9 +253,9 @@ import {
|
|
|
242
253
|
AdtCloudConnector,
|
|
243
254
|
CloudHttpTransport,
|
|
244
255
|
SapConfig,
|
|
245
|
-
TokenAuthProvider,
|
|
246
256
|
getTimeout,
|
|
247
257
|
} from "@mcp-abap-adt/connection";
|
|
258
|
+
import { TokenAuthProvider } from "@mcp-abap-adt/auth-providers";
|
|
248
259
|
|
|
249
260
|
// JWT configuration
|
|
250
261
|
const config: SapConfig = {
|
|
@@ -262,12 +273,12 @@ const logger = {
|
|
|
262
273
|
};
|
|
263
274
|
|
|
264
275
|
// Logger is optional - if not provided, no logging output.
|
|
265
|
-
//
|
|
266
|
-
// `ITokenRefresher` instead and
|
|
276
|
+
// `.fixed` is a token with nothing behind it. `TokenAuthProvider.from` takes an
|
|
277
|
+
// `ITokenRefresher` instead and renews when the system refuses the token, which
|
|
267
278
|
// is what you want in anything long-lived.
|
|
268
279
|
const connection = new AdtCloudConnector(
|
|
269
280
|
config,
|
|
270
|
-
|
|
281
|
+
TokenAuthProvider.fixed(config.jwtToken!),
|
|
271
282
|
new CloudHttpTransport(() => ({}), logger, {
|
|
272
283
|
client: config.client,
|
|
273
284
|
baseUrl: config.url,
|
|
@@ -306,10 +317,10 @@ Needs the SAP NW RFC SDK on the machine and `npm install @mcp-abap-adt/sap-rfc-l
|
|
|
306
317
|
```typescript
|
|
307
318
|
import {
|
|
308
319
|
AdtOnPremConnector,
|
|
309
|
-
BasicAuthProvider,
|
|
310
320
|
RfcTransport,
|
|
311
321
|
rfcConversationFrom,
|
|
312
322
|
} from "@mcp-abap-adt/connection";
|
|
323
|
+
import { BasicAuthProvider } from "@mcp-abap-adt/auth-providers";
|
|
313
324
|
|
|
314
325
|
const connection = new AdtOnPremConnector(
|
|
315
326
|
config,
|
|
@@ -337,10 +348,10 @@ takes no transport parameter at all.
|
|
|
337
348
|
import {
|
|
338
349
|
AdtOnPremConnector,
|
|
339
350
|
OnPremHttpTransport,
|
|
340
|
-
SamlAuthProvider,
|
|
341
351
|
SapConfig,
|
|
342
352
|
getTimeout,
|
|
343
353
|
} from "@mcp-abap-adt/connection";
|
|
354
|
+
import { SamlAuthProvider } from "@mcp-abap-adt/auth-providers";
|
|
344
355
|
|
|
345
356
|
const config: SapConfig = {
|
|
346
357
|
url: "https://your-sap-system.com",
|
|
@@ -369,19 +380,20 @@ const response = await connection.makeAdtRequest({
|
|
|
369
380
|
|
|
370
381
|
### Cloud Usage with Automatic Token Refresh
|
|
371
382
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
the
|
|
383
|
+
Build `TokenAuthProvider.from` over an `ITokenRefresher` and the provider
|
|
384
|
+
replaces a token the system refused: the connection puts the `401` to
|
|
385
|
+
`rejected`, the provider fetches a new token, and the request is sent once more.
|
|
386
|
+
A token the source still believes in and the server refuses again is the
|
|
387
|
+
verdict, and that one **surfaces** as an `AuthRefusedError`:
|
|
376
388
|
|
|
377
389
|
```typescript
|
|
378
390
|
import {
|
|
379
391
|
AdtCloudConnector,
|
|
380
392
|
CloudHttpTransport,
|
|
381
393
|
SapConfig,
|
|
382
|
-
TokenAuthProvider,
|
|
383
394
|
getTimeout,
|
|
384
395
|
} from "@mcp-abap-adt/connection";
|
|
396
|
+
import { TokenAuthProvider } from "@mcp-abap-adt/auth-providers";
|
|
385
397
|
import type { ITokenRefresher } from "@mcp-abap-adt/interfaces-auth";
|
|
386
398
|
|
|
387
399
|
// Token refresher provides token acquisition and refresh
|
|
@@ -402,7 +414,7 @@ const config: SapConfig = {
|
|
|
402
414
|
// authenticate. Neither decides the other.
|
|
403
415
|
const connection = new AdtCloudConnector(
|
|
404
416
|
config,
|
|
405
|
-
|
|
417
|
+
TokenAuthProvider.from(tokenRefresher),
|
|
406
418
|
new CloudHttpTransport(() => ({}), logger, {
|
|
407
419
|
client: config.client,
|
|
408
420
|
baseUrl: config.url,
|
|
@@ -411,12 +423,15 @@ const connection = new AdtCloudConnector(
|
|
|
411
423
|
);
|
|
412
424
|
await connection.connect();
|
|
413
425
|
|
|
414
|
-
// On a 401
|
|
415
|
-
//
|
|
416
|
-
//
|
|
417
|
-
//
|
|
418
|
-
//
|
|
419
|
-
//
|
|
426
|
+
// On a 401 the connection asks the provider (`rejected`); on Ok it sends the
|
|
427
|
+
// request once more with the renewed token, otherwise you get an
|
|
428
|
+
// AuthRefusedError. The resend always runs under the same lease and generation
|
|
429
|
+
// as the attempt it repeats, so stale-request fencing applies. After a rejection
|
|
430
|
+
// at 'request' it goes out on the same session; after one at 'logon' the wire
|
|
431
|
+
// logs on again first. Inside a critical section a renewal keeps the session —
|
|
432
|
+
// or the request fails with SESSION_REPLACED if SAP replaced it. Outside one, a
|
|
433
|
+
// mutation refused with a 401 while a CSRF token is cached takes the wire's
|
|
434
|
+
// stale-session recovery first, which starts a new session.
|
|
420
435
|
const response = await connection.makeAdtRequest({
|
|
421
436
|
method: "GET",
|
|
422
437
|
url: "/sap/bc/adt/programs/programs/your-program",
|
|
@@ -436,6 +451,29 @@ error. Code matching on that message must branch on `error.response.status`
|
|
|
436
451
|
instead — which it can now do, since the status is no longer thrown away.
|
|
437
452
|
See [MIGRATION-4.0.md](./docs/MIGRATION-4.0.md).
|
|
438
453
|
|
|
454
|
+
### When the credential is refused
|
|
455
|
+
|
|
456
|
+
Every request asks the provider first (`authorize`). A `401` that survives the
|
|
457
|
+
wire's own session recovery, or a logon the system refused, is put to the
|
|
458
|
+
provider (`rejected`); on Ok the request is sent once more, otherwise it fails
|
|
459
|
+
with an `AuthRefusedError` carrying the provider's own words. A `403` is never
|
|
460
|
+
put to the provider.
|
|
461
|
+
|
|
462
|
+
```typescript
|
|
463
|
+
import { AuthRefusedError } from "@mcp-abap-adt/connection";
|
|
464
|
+
|
|
465
|
+
try {
|
|
466
|
+
await connection.connect();
|
|
467
|
+
} catch (error) {
|
|
468
|
+
if (error instanceof AuthRefusedError) {
|
|
469
|
+
console.error(error.refusal.reason, error.refusal.hint, error.at);
|
|
470
|
+
}
|
|
471
|
+
throw error;
|
|
472
|
+
}
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
See [USAGE.md](./docs/USAGE.md#when-the-credential-is-refused).
|
|
476
|
+
|
|
439
477
|
### Stateful Sessions
|
|
440
478
|
|
|
441
479
|
Enable stateful mode for requests that need the ABAP context, such as LOCK and
|
|
@@ -447,10 +485,10 @@ cookies and the CSRF token remain available in both modes. See the
|
|
|
447
485
|
```typescript
|
|
448
486
|
import {
|
|
449
487
|
AdtOnPremConnector,
|
|
450
|
-
BasicAuthProvider,
|
|
451
488
|
OnPremHttpTransport,
|
|
452
489
|
getTimeout,
|
|
453
490
|
} from "@mcp-abap-adt/connection";
|
|
491
|
+
import { BasicAuthProvider } from "@mcp-abap-adt/auth-providers";
|
|
454
492
|
|
|
455
493
|
const connection = new AdtOnPremConnector(
|
|
456
494
|
config,
|
|
@@ -480,7 +518,8 @@ connection.setSessionType("stateless");
|
|
|
480
518
|
### Custom Logger
|
|
481
519
|
|
|
482
520
|
```typescript
|
|
483
|
-
import { AdtOnPremConnector,
|
|
521
|
+
import { AdtOnPremConnector, ILogger, OnPremHttpTransport } from "@mcp-abap-adt/connection";
|
|
522
|
+
import { BasicAuthProvider } from "@mcp-abap-adt/auth-providers";
|
|
484
523
|
|
|
485
524
|
class MyLogger implements ILogger {
|
|
486
525
|
info(message: string, meta?: any): void {
|
|
@@ -677,17 +716,19 @@ so a machine without it fails at `connect()` with a message saying what to
|
|
|
677
716
|
install rather than at construction.
|
|
678
717
|
|
|
679
718
|
```text
|
|
680
|
-
function rfcConversationFrom(
|
|
681
|
-
|
|
719
|
+
function rfcConversationFrom(
|
|
720
|
+
config: SapConfig,
|
|
721
|
+
): (logon: Readonly<Record<string, string>>) => IRfcConversation;
|
|
722
|
+
function rfcParamsFrom(config: SapConfig): RfcConnectionParams; // the address only
|
|
682
723
|
```
|
|
683
724
|
|
|
684
725
|
```typescript
|
|
685
726
|
import {
|
|
686
727
|
AdtOnPremConnector,
|
|
687
|
-
BasicAuthProvider,
|
|
688
728
|
RfcTransport,
|
|
689
729
|
rfcConversationFrom,
|
|
690
730
|
} from "@mcp-abap-adt/connection";
|
|
731
|
+
import { BasicAuthProvider } from "@mcp-abap-adt/auth-providers";
|
|
691
732
|
|
|
692
733
|
const connection = new AdtOnPremConnector(
|
|
693
734
|
config,
|
|
@@ -782,7 +823,7 @@ async function fetchCsrfToken(baseUrl: string): Promise<string> {
|
|
|
782
823
|
|
|
783
824
|
## Requirements
|
|
784
825
|
|
|
785
|
-
- Node.js
|
|
826
|
+
- Node.js 22, 24 or 26 (`engines`: `^22 || ^24 || ^26`)
|
|
786
827
|
- Access to SAP ABAP system (on-premise or BTP)
|
|
787
828
|
|
|
788
829
|
## Changelog
|