@mcp-abap-adt/connection 15.0.0 → 15.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 +59 -1
- package/README.md +12 -1
- package/dist/connection/AbstractAbapConnection.d.ts +8 -3
- package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
- package/dist/connection/AbstractAbapConnection.js +90 -36
- package/dist/connection/HttpTransport.d.ts.map +1 -1
- package/dist/connection/HttpTransport.js +6 -0
- package/dist/connection/IAdtTransport.d.ts +18 -0
- package/dist/connection/IAdtTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.d.ts +6 -0
- package/dist/connection/RfcTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.js +46 -13
- package/dist/connection/requestAbort.d.ts +32 -0
- package/dist/connection/requestAbort.d.ts.map +1 -0
- package/dist/connection/requestAbort.js +69 -0
- package/docs/INSTALLATION.md +1 -1
- package/docs/STATEFUL_SESSION_GUIDE.md +9 -0
- package/docs/USAGE.md +47 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,62 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [15.1.0] - 2026-10-12
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **The request's signal, at every send boundary, on HTTP and RFC.**
|
|
14
|
+
`makeAdtRequest({ …, signal })` honours `IAbapRequestOptions.signal`
|
|
15
|
+
(`@mcp-abap-adt/interfaces-adt-connection` `^2.1.0`, was `^2.0.0`). It is
|
|
16
|
+
checked before the first send, before every resend (the CSRF recovery and the
|
|
17
|
+
cookie retry of a GET included) and before the provider's `rejected()`; and
|
|
18
|
+
every wait of the request races it — the provider's `authorize()` and
|
|
19
|
+
`rejected()`, a logon (`establish()`), the token exchange, and over RFC the
|
|
20
|
+
logon and `open()` of a conversation of its own, kept or throwaway. Once it
|
|
21
|
+
aborts, nothing more of the request is sent, and the call rejects at once
|
|
22
|
+
with `code: ADT_REQUEST_ERROR.ABORTED` (`'ADT_REQUEST_ABORTED'`) in fixed
|
|
23
|
+
words: nothing of the request, the signal's reason or a server's text in
|
|
24
|
+
them. A wait ends for that caller only — a provider's renewal behind it runs
|
|
25
|
+
on for every other request, and what it answers late is handled and
|
|
26
|
+
dropped. A token exchange the request started makes no further attempt; one
|
|
27
|
+
already on the wire is not recalled, and the token it earns is the
|
|
28
|
+
session's. The signal is checked once more right before every send, every
|
|
29
|
+
send of the request's own token exchange and every RFC call, so an abort
|
|
30
|
+
that lands after a wait answered still stops it. A
|
|
31
|
+
conversation an RFC call
|
|
32
|
+
opened for itself alone is closed when its `open()` answers. An aborted
|
|
33
|
+
request leaves the session's CSRF token and cookies as they are.
|
|
34
|
+
- `IAdtTransportRequest.signal`: the caller's signal, handed to the wire for
|
|
35
|
+
the waits it makes on the request's behalf before it sends. `RfcTransport`
|
|
36
|
+
races its per-call logon and `open()` against it, and checks it before the
|
|
37
|
+
call; no wire hands it to its client, because a request already sent is
|
|
38
|
+
not recalled.
|
|
39
|
+
- `IAdtEstablishContext.signal`: the signal of the one request a token
|
|
40
|
+
exchange is made for (its upfront fetch, its CSRF recovery); absent for
|
|
41
|
+
`connect()`'s. `HttpTransport.establish` checks it immediately before each
|
|
42
|
+
send of the exchange. The exchange is that request's alone, so stopping it
|
|
43
|
+
takes nothing from another caller. A custom wire's `establish()` should do
|
|
44
|
+
the same.
|
|
45
|
+
|
|
46
|
+
### Unchanged
|
|
47
|
+
- A request already sent is not recalled: the server may act on it, and its
|
|
48
|
+
answer is the caller's. `timeout` still bounds an HTTP request.
|
|
49
|
+
- Without a signal, a request behaves exactly as in 15.0.1. `disconnect()`, its
|
|
50
|
+
logoff and `flushGoodbye()` are not a caller's request and take no signal.
|
|
51
|
+
|
|
52
|
+
## [15.0.1] - 2026-10-12
|
|
53
|
+
|
|
54
|
+
The code is the same as 15.0.0.
|
|
55
|
+
|
|
56
|
+
### Changed
|
|
57
|
+
- The contract ranges are their current releases, as the auth stack (auth-providers 6.0.2,
|
|
58
|
+
auth-stores 5.0.1, auth-broker 5.0.6) declares them: `@mcp-abap-adt/interfaces-utils`
|
|
59
|
+
`^1.1.1` (was `^1.1.0`), `@mcp-abap-adt/interfaces-network` `^2.0.1` (was `^2.0.0`),
|
|
60
|
+
`@mcp-abap-adt/auth-errors` `^2.2.1` (was `^2.2.0`); the optional
|
|
61
|
+
`@mcp-abap-adt/sap-rfc-lite` `^0.2.2` (was `^0.2.1`). Their APIs are unchanged.
|
|
62
|
+
- Development: the dev dependency `@mcp-abap-adt/auth-providers` is `^6.0.2` (was `^6.0.0`);
|
|
63
|
+
the lockfile is refreshed from the registry.
|
|
64
|
+
- README, INSTALLATION and USAGE: connection 13.x to 15.x work with auth-providers 6.
|
|
65
|
+
|
|
10
66
|
## [15.0.0] - 2026-10-12
|
|
11
67
|
|
|
12
68
|
### Breaking
|
|
@@ -2390,7 +2446,9 @@ const connection = createAbapConnection(config, logger);
|
|
|
2390
2446
|
- JWT token refresh now properly handles connection errors (401/403 during initial connect)
|
|
2391
2447
|
- Permission errors (403 with "ExceptionResourceNoAccess") no longer trigger JWT refresh loops
|
|
2392
2448
|
- Proper separation: base class handles HTTP/session, concrete classes handle auth-specific errors
|
|
2393
|
-
[Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/v15.
|
|
2449
|
+
[Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/v15.1.0...HEAD
|
|
2450
|
+
[15.1.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v15.0.1...v15.1.0
|
|
2451
|
+
[15.0.1]: https://github.com/fr0ster/mcp-abap-connection/compare/v15.0.0...v15.0.1
|
|
2394
2452
|
[15.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v14.1.0...v15.0.0
|
|
2395
2453
|
[14.1.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v14.0.1...v14.1.0
|
|
2396
2454
|
[14.0.1]: https://github.com/fr0ster/mcp-abap-connection/compare/v14.0.0...v14.0.1
|
package/README.md
CHANGED
|
@@ -210,7 +210,7 @@ since 10.0.0. Install them from where they live:
|
|
|
210
210
|
npm install @mcp-abap-adt/auth-providers@^6
|
|
211
211
|
```
|
|
212
212
|
|
|
213
|
-
connection 13.x
|
|
213
|
+
connection 13.x to 15.x work with **auth-providers 6.0.0** (`^6.0.0`), the release
|
|
214
214
|
built on interfaces-auth 7 and auth-errors 2, and are tested with it: the 5.x
|
|
215
215
|
providers answer unbranded refusals and do not fit. See
|
|
216
216
|
[Migration to 13.0.0](./docs/MIGRATION-13.0.md) and
|
|
@@ -680,6 +680,17 @@ owns is not being interrupted by a timeout mid-operation — see
|
|
|
680
680
|
|
|
681
681
|
See [docs/USAGE.md — Session Lifecycle](./docs/USAGE.md#session-lifecycle).
|
|
682
682
|
|
|
683
|
+
**Cancelling a request.** `makeAdtRequest({ …, signal })` takes the caller's
|
|
684
|
+
`AbortSignal`. Once it aborts, nothing more of the request is sent — not the
|
|
685
|
+
first send, not a resend, not the CSRF recovery, not a renewal — and the call
|
|
686
|
+
rejects at once with `code: 'ADT_REQUEST_ABORTED'` (`ADT_REQUEST_ERROR.ABORTED`
|
|
687
|
+
from `@mcp-abap-adt/interfaces-adt-connection`), over HTTP and RFC alike. A
|
|
688
|
+
request already sent is not recalled, and a provider's renewal it was waiting
|
|
689
|
+
on runs on for the other requests. A token exchange the request started makes
|
|
690
|
+
no further attempt; the one already on the wire is not recalled, and the token
|
|
691
|
+
it earns is the session's. See
|
|
692
|
+
[docs/USAGE.md — Cancelling a request](./docs/USAGE.md#cancelling-a-request).
|
|
693
|
+
|
|
683
694
|
**Session Management:**
|
|
684
695
|
- `setSessionType(type)`: Programmatically switch between stateful and stateless modes *(on the contract)*
|
|
685
696
|
- `getSessionId()`: Returns the client-side conversation id, an auto-generated UUID *(on the contract)*
|
|
@@ -581,7 +581,12 @@ declare abstract class AbstractAbapConnection implements AbapConnection, ISessio
|
|
|
581
581
|
* wire's own ingest of it, and never stops the request being sent.
|
|
582
582
|
* Omitted during connect(), which has no lease.
|
|
583
583
|
*/
|
|
584
|
-
fence?: number | Pick<RequestLease, 'generation'
|
|
584
|
+
fence?: number | Pick<RequestLease, 'generation'>,
|
|
585
|
+
/**
|
|
586
|
+
* The request's signal: the exchange's own attempts stop once it aborts.
|
|
587
|
+
* Omitted during connect(), whose exchange is nobody's single request.
|
|
588
|
+
*/
|
|
589
|
+
signal?: AbortSignal): Promise<string>;
|
|
585
590
|
protected getCsrfToken(): string | null;
|
|
586
591
|
/**
|
|
587
592
|
* Set CSRF token (protected for use by subclasses)
|
|
@@ -628,8 +633,8 @@ declare abstract class AbstractAbapConnection implements AbapConnection, ISessio
|
|
|
628
633
|
private leasedContext;
|
|
629
634
|
/**
|
|
630
635
|
* What stops a token exchange at once, past its retries: a session verdict,
|
|
631
|
-
*
|
|
632
|
-
* the provider again.
|
|
636
|
+
* the provider's refusal to authorize it — asking again would only ask
|
|
637
|
+
* the provider again — or the abort of the request it was made for.
|
|
633
638
|
*/
|
|
634
639
|
protected endsTheExchange(error: unknown): boolean;
|
|
635
640
|
/**
|
|
@@ -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;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;
|
|
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;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;AAqD5B,uBAAe,sBACb,YACE,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB;IAuGjB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,SAAS,EAAE,aAAa;IACjC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAlH3C;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,SAAS,mBAA0B;IAEtD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,WAAW,CAAy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CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,MAAM,CAAC;IAoBlB,SAAS,CAAC,YAAY,IAAI,MAAM,GAAG,IAAI;IAIvC;;OAEG;IACH,SAAS,CAAC,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;IAkB7B;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,aAAa;IAyCrB;;;;OAIG;IACH,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAQlD;;;;;;;;OAQG;IACH,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,eAAe;CA6BxB;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -9,6 +9,7 @@ const timeouts_js_1 = require("../utils/timeouts.js");
|
|
|
9
9
|
const authErrors_js_1 = require("./authErrors.js");
|
|
10
10
|
const csrfConfig_js_1 = require("./csrfConfig.js");
|
|
11
11
|
const IAdtTransport_js_1 = require("./IAdtTransport.js");
|
|
12
|
+
const requestAbort_js_1 = require("./requestAbort.js");
|
|
12
13
|
/**
|
|
13
14
|
* Declares the capabilities explicitly rather than satisfying them by accident.
|
|
14
15
|
* `AbapConnection` is the base contract every transport honours; these two are
|
|
@@ -855,8 +856,11 @@ class AbstractAbapConnection {
|
|
|
855
856
|
}
|
|
856
857
|
}
|
|
857
858
|
async performRequest(options, lease) {
|
|
858
|
-
const { url: endpoint, method, timeout, data, params, headers: customHeaders, } = options;
|
|
859
|
+
const { url: endpoint, method, timeout, data, params, headers: customHeaders, signal, } = options;
|
|
859
860
|
const normalizedMethod = method.toUpperCase();
|
|
861
|
+
// Before the first send: a request its caller has already given up on
|
|
862
|
+
// asks the provider nothing and sends nothing.
|
|
863
|
+
(0, requestAbort_js_1.throwIfAborted)(signal);
|
|
860
864
|
// The PATH, not an address. Which server it belongs in front of — or
|
|
861
865
|
// whether it belongs in front of one at all — is the wire's to say.
|
|
862
866
|
const requestUrl = endpoint;
|
|
@@ -871,7 +875,7 @@ class AbstractAbapConnection {
|
|
|
871
875
|
// exchange itself does not stop the request — the CSRF recovery below
|
|
872
876
|
// handles a token that is missing — but a refused credential does.
|
|
873
877
|
if (mutation && !this.transport.csrfToken()) {
|
|
874
|
-
await this.readyWireUpfront(renewal, lease);
|
|
878
|
+
await this.readyWireUpfront(renewal, lease, signal);
|
|
875
879
|
}
|
|
876
880
|
// The request's own headers: everything but the credential's, which is
|
|
877
881
|
// written fresh onto a copy of these for every attempt (`authorizedFrom`).
|
|
@@ -958,7 +962,7 @@ class AbstractAbapConnection {
|
|
|
958
962
|
// the request's content negotiation outrank it (`authorizedFrom`).
|
|
959
963
|
// A provider that answers after the session went away answers for a
|
|
960
964
|
// request that no longer has one.
|
|
961
|
-
headers: await this.authorizedFrom(requestHeaders).catch((error) => {
|
|
965
|
+
headers: await this.authorizedFrom(requestHeaders, signal).catch((error) => {
|
|
962
966
|
throw this.staleOr(error, lease);
|
|
963
967
|
}),
|
|
964
968
|
timeout: effectiveTimeout,
|
|
@@ -966,6 +970,9 @@ class AbstractAbapConnection {
|
|
|
966
970
|
// transports serialise a query differently and both need the pairs.
|
|
967
971
|
params: params,
|
|
968
972
|
stateful: this.sessionMode === 'stateful',
|
|
973
|
+
// For the waits the wire makes on this request's behalf — over RFC, the
|
|
974
|
+
// logon and the open of a conversation of its own.
|
|
975
|
+
...(signal ? { signal } : {}),
|
|
969
976
|
};
|
|
970
977
|
if (data !== undefined) {
|
|
971
978
|
requestConfig.data = data;
|
|
@@ -986,14 +993,17 @@ class AbstractAbapConnection {
|
|
|
986
993
|
return response;
|
|
987
994
|
}
|
|
988
995
|
catch (error) {
|
|
996
|
+
// The wire ended one of its waits for this request: nothing to recover.
|
|
997
|
+
if ((0, requestAbort_js_1.isRequestAborted)(error))
|
|
998
|
+
throw error;
|
|
989
999
|
let survived;
|
|
990
1000
|
try {
|
|
991
|
-
return await this.recoverOnWire(error, requestConfig, requestHeaders, lease);
|
|
1001
|
+
return await this.recoverOnWire(error, requestConfig, requestHeaders, lease, signal);
|
|
992
1002
|
}
|
|
993
1003
|
catch (failure) {
|
|
994
1004
|
survived = failure;
|
|
995
1005
|
}
|
|
996
|
-
return await this.answerCredentialFailure(survived, requestConfig, requestHeaders, lease, renewal);
|
|
1006
|
+
return await this.answerCredentialFailure(survived, requestConfig, requestHeaders, lease, renewal, signal);
|
|
997
1007
|
}
|
|
998
1008
|
}
|
|
999
1009
|
/**
|
|
@@ -1009,6 +1019,10 @@ class AbstractAbapConnection {
|
|
|
1009
1019
|
if (!this.lifecycle.isCurrent(lease)) {
|
|
1010
1020
|
throw (0, SessionLifecycle_js_1.sessionError)(interfaces_adt_connection_1.ADT_SESSION_ERROR.NOT_CONNECTED, 'The session this request was admitted to is gone; nothing was sent');
|
|
1011
1021
|
}
|
|
1022
|
+
// The last point before the wire, for the same reason: a raced wait that
|
|
1023
|
+
// answered still leaves turns before this one, and an abort in any of
|
|
1024
|
+
// them must stop the send. Covers the first send and every resend.
|
|
1025
|
+
(0, requestAbort_js_1.throwIfAborted)(requestConfig.signal);
|
|
1012
1026
|
const response = await this.transport.send(requestConfig);
|
|
1013
1027
|
this.observeResponse(response.headers, lease.generation);
|
|
1014
1028
|
return response;
|
|
@@ -1029,9 +1043,11 @@ class AbstractAbapConnection {
|
|
|
1029
1043
|
* and `Accept`: those are put back from `base` whichever way the provider
|
|
1030
1044
|
* spelled them — as the wire's own token fetch already does.
|
|
1031
1045
|
*/
|
|
1032
|
-
async authorizedFrom(base) {
|
|
1046
|
+
async authorizedFrom(base, signal) {
|
|
1033
1047
|
const headers = { ...base };
|
|
1034
|
-
|
|
1048
|
+
// The provider's answer is waited for by this request alone: an abort
|
|
1049
|
+
// ends the wait at once, and the provider runs on for whoever shares it.
|
|
1050
|
+
await (0, requestAbort_js_1.untilAborted)(signal, this.credentialHeaders(headers));
|
|
1035
1051
|
for (const name of OUTRANK_THE_CREDENTIAL) {
|
|
1036
1052
|
const own = Object.keys(base).filter((key) => key.toLowerCase() === name);
|
|
1037
1053
|
if (own.length === 0)
|
|
@@ -1061,7 +1077,7 @@ class AbstractAbapConnection {
|
|
|
1061
1077
|
* the recovery adds — a new token, the jar's cookies — goes there, and each
|
|
1062
1078
|
* resend is authorized anew on top (`authorizedFrom`).
|
|
1063
1079
|
*/
|
|
1064
|
-
async recoverOnWire(error, requestConfig, requestHeaders, lease) {
|
|
1080
|
+
async recoverOnWire(error, requestConfig, requestHeaders, lease, signal) {
|
|
1065
1081
|
const requestUrl = requestConfig.url;
|
|
1066
1082
|
const normalizedMethod = requestConfig.method;
|
|
1067
1083
|
// FENCE FIRST, before anything reads or writes shared state.
|
|
@@ -1140,13 +1156,17 @@ class AbstractAbapConnection {
|
|
|
1140
1156
|
url: requestUrl,
|
|
1141
1157
|
method: normalizedMethod,
|
|
1142
1158
|
});
|
|
1159
|
+
// Before the CSRF recovery and its resend. The session's token and
|
|
1160
|
+
// cookies are every caller's: an aborted request neither discards them
|
|
1161
|
+
// nor earns new ones.
|
|
1162
|
+
(0, requestAbort_js_1.throwIfAborted)(signal);
|
|
1143
1163
|
if (isCachedTokenStale) {
|
|
1144
1164
|
this.invalidateSession();
|
|
1145
1165
|
delete requestHeaders.Cookie;
|
|
1146
1166
|
delete requestHeaders.cookie;
|
|
1147
1167
|
}
|
|
1148
1168
|
try {
|
|
1149
|
-
this.setCsrfToken(await this.fetchCsrfToken(requestUrl, 5, 2000, lease));
|
|
1169
|
+
this.setCsrfToken(await (0, requestAbort_js_1.untilAborted)(signal, this.fetchCsrfToken(requestUrl, 5, 2000, lease, signal)));
|
|
1150
1170
|
const refreshedToken = this.getCsrfToken();
|
|
1151
1171
|
if (refreshedToken) {
|
|
1152
1172
|
requestHeaders['x-csrf-token'] = refreshedToken;
|
|
@@ -1156,7 +1176,7 @@ class AbstractAbapConnection {
|
|
|
1156
1176
|
requestHeaders.Cookie = refreshedCookies;
|
|
1157
1177
|
}
|
|
1158
1178
|
// Re-authorized: a provider may have renewed since the first attempt.
|
|
1159
|
-
requestConfig.headers = await this.authorizedFrom(requestHeaders);
|
|
1179
|
+
requestConfig.headers = await this.authorizedFrom(requestHeaders, signal);
|
|
1160
1180
|
return await this.sendObserved(requestConfig, lease);
|
|
1161
1181
|
}
|
|
1162
1182
|
catch (retryError) {
|
|
@@ -1184,13 +1204,15 @@ class AbstractAbapConnection {
|
|
|
1184
1204
|
// on actually holding some, so a wire that issues no cookies — RFC —
|
|
1185
1205
|
// never takes it.
|
|
1186
1206
|
if ((0, IAdtTransport_js_1.refusalOf)(error)?.status === 401 && normalizedMethod === 'GET') {
|
|
1207
|
+
// Before the resend, and before the token fetch that would earn it.
|
|
1208
|
+
(0, requestAbort_js_1.throwIfAborted)(signal);
|
|
1187
1209
|
// If we already have cookies from error response, retry immediately
|
|
1188
1210
|
const afterError = this.transport.cookies();
|
|
1189
1211
|
if (afterError) {
|
|
1190
1212
|
this.logger?.debug(`401 on GET request, retrying with cookies from error response`);
|
|
1191
1213
|
requestHeaders.Cookie = afterError;
|
|
1192
1214
|
try {
|
|
1193
|
-
requestConfig.headers = await this.authorizedFrom(requestHeaders);
|
|
1215
|
+
requestConfig.headers = await this.authorizedFrom(requestHeaders, signal);
|
|
1194
1216
|
return await this.sendObserved(requestConfig, lease);
|
|
1195
1217
|
}
|
|
1196
1218
|
catch (resendError) {
|
|
@@ -1201,12 +1223,12 @@ class AbstractAbapConnection {
|
|
|
1201
1223
|
this.logger?.debug(`401 on GET request, attempting to get cookies via CSRF token fetch`);
|
|
1202
1224
|
try {
|
|
1203
1225
|
// Try to get CSRF token (this will also get cookies)
|
|
1204
|
-
this.setCsrfToken(await this.fetchCsrfToken(requestUrl, 3, 1000, lease));
|
|
1226
|
+
this.setCsrfToken(await (0, requestAbort_js_1.untilAborted)(signal, this.fetchCsrfToken(requestUrl, 3, 1000, lease, signal)));
|
|
1205
1227
|
const afterCsrf = this.transport.cookies();
|
|
1206
1228
|
if (afterCsrf) {
|
|
1207
1229
|
requestHeaders.Cookie = afterCsrf;
|
|
1208
1230
|
this.logger?.debug(`Retrying GET request with cookies from CSRF fetch`);
|
|
1209
|
-
requestConfig.headers = await this.authorizedFrom(requestHeaders);
|
|
1231
|
+
requestConfig.headers = await this.authorizedFrom(requestHeaders, signal);
|
|
1210
1232
|
return await this.sendObserved(requestConfig, lease);
|
|
1211
1233
|
}
|
|
1212
1234
|
}
|
|
@@ -1239,7 +1261,7 @@ class AbstractAbapConnection {
|
|
|
1239
1261
|
* credential failure in either is the verdict. As in `recoverOnWire`,
|
|
1240
1262
|
* `requestHeaders` are the request's own, and the resend is authorized anew.
|
|
1241
1263
|
*/
|
|
1242
|
-
async answerCredentialFailure(failure, requestConfig, requestHeaders, lease, renewal) {
|
|
1264
|
+
async answerCredentialFailure(failure, requestConfig, requestHeaders, lease, renewal, signal) {
|
|
1243
1265
|
// A resend inside the wire's recovery that met a dead session.
|
|
1244
1266
|
this.throwIfSessionDead(failure, lease);
|
|
1245
1267
|
const rejection = this.credentialRejection(failure);
|
|
@@ -1249,7 +1271,7 @@ class AbstractAbapConnection {
|
|
|
1249
1271
|
throw failure;
|
|
1250
1272
|
if (!this.lifecycle.isCurrent(lease))
|
|
1251
1273
|
throw this.staleVerdict(failure);
|
|
1252
|
-
await this.renewCredential(rejection, renewal).catch((error) => {
|
|
1274
|
+
await this.renewCredential(rejection, renewal, signal).catch((error) => {
|
|
1253
1275
|
throw this.staleOr(error, lease);
|
|
1254
1276
|
});
|
|
1255
1277
|
if (!this.lifecycle.isCurrent(lease))
|
|
@@ -1257,7 +1279,7 @@ class AbstractAbapConnection {
|
|
|
1257
1279
|
try {
|
|
1258
1280
|
if (rejection.at === 'logon') {
|
|
1259
1281
|
this.transport.adoptCsrfToken(null);
|
|
1260
|
-
await this.ensureWireReady(lease);
|
|
1282
|
+
await this.ensureWireReady(lease, signal);
|
|
1261
1283
|
const token = this.transport.csrfToken();
|
|
1262
1284
|
if (token && ['POST', 'PUT', 'DELETE'].includes(requestConfig.method)) {
|
|
1263
1285
|
requestHeaders['x-csrf-token'] = token;
|
|
@@ -1266,7 +1288,7 @@ class AbstractAbapConnection {
|
|
|
1266
1288
|
if (cookies)
|
|
1267
1289
|
requestHeaders.Cookie = cookies;
|
|
1268
1290
|
}
|
|
1269
|
-
requestConfig.headers = await this.authorizedFrom(requestHeaders);
|
|
1291
|
+
requestConfig.headers = await this.authorizedFrom(requestHeaders, signal);
|
|
1270
1292
|
return await this.sendObserved(requestConfig, lease);
|
|
1271
1293
|
}
|
|
1272
1294
|
catch (again) {
|
|
@@ -1318,7 +1340,8 @@ class AbstractAbapConnection {
|
|
|
1318
1340
|
* NOT_CONNECTED, because it is about a session the request no longer holds.
|
|
1319
1341
|
*/
|
|
1320
1342
|
staleVerdict(error) {
|
|
1321
|
-
|
|
1343
|
+
// The caller's abort is its own answer, whichever session is current.
|
|
1344
|
+
if (this.isSessionVerdict(error) || (0, requestAbort_js_1.isRequestAborted)(error))
|
|
1322
1345
|
return error;
|
|
1323
1346
|
return (0, SessionLifecycle_js_1.sessionError)(interfaces_adt_connection_1.ADT_SESSION_ERROR.NOT_CONNECTED, 'The session this request was admitted to is gone');
|
|
1324
1347
|
}
|
|
@@ -1334,12 +1357,18 @@ class AbstractAbapConnection {
|
|
|
1334
1357
|
* that throw. A refusal after the retry was spent is the verdict, and the
|
|
1335
1358
|
* provider is not asked again — asking would invite a second renewal.
|
|
1336
1359
|
*/
|
|
1337
|
-
async renewCredential(rejection, renewal
|
|
1360
|
+
async renewCredential(rejection, renewal,
|
|
1361
|
+
/** The request's; `connect()` has none. */
|
|
1362
|
+
signal) {
|
|
1338
1363
|
if (renewal.spent) {
|
|
1339
1364
|
throw new authErrors_js_1.AuthRefusedError((0, authErrors_js_1.refusedAgain)(rejection.at), rejection.at, rejection.error);
|
|
1340
1365
|
}
|
|
1366
|
+
// Before rejected(): an aborted request asks the provider nothing.
|
|
1367
|
+
(0, requestAbort_js_1.throwIfAborted)(signal);
|
|
1341
1368
|
renewal.spent = true;
|
|
1342
|
-
|
|
1369
|
+
// After it: the renewal is the provider's, shared with whoever else was
|
|
1370
|
+
// refused; this request stops waiting for it at its abort.
|
|
1371
|
+
const answer = await (0, requestAbort_js_1.untilAborted)(signal, this.credentialRejected(rejection));
|
|
1343
1372
|
if (!answer.outcome.ok) {
|
|
1344
1373
|
throw new authErrors_js_1.AuthRefusedError(answer.outcome.refusal, rejection.at, 'thrown' in answer ? answer.thrown : rejection.error);
|
|
1345
1374
|
}
|
|
@@ -1367,6 +1396,7 @@ class AbstractAbapConnection {
|
|
|
1367
1396
|
*/
|
|
1368
1397
|
outranksOriginal(retryError) {
|
|
1369
1398
|
return (this.isSessionVerdict(retryError) ||
|
|
1399
|
+
(0, requestAbort_js_1.isRequestAborted)(retryError) ||
|
|
1370
1400
|
retryError instanceof authErrors_js_1.AuthRefusedError ||
|
|
1371
1401
|
this.credentialRejection(retryError) !== null);
|
|
1372
1402
|
}
|
|
@@ -1378,13 +1408,16 @@ class AbstractAbapConnection {
|
|
|
1378
1408
|
* fetch within the request's one retry — unless the session the request
|
|
1379
1409
|
* was admitted to is gone by then, when nothing more is sent.
|
|
1380
1410
|
*/
|
|
1381
|
-
async readyWireUpfront(renewal, lease) {
|
|
1411
|
+
async readyWireUpfront(renewal, lease, signal) {
|
|
1382
1412
|
for (;;) {
|
|
1383
1413
|
try {
|
|
1384
|
-
await this.ensureWireReady(lease);
|
|
1414
|
+
await this.ensureWireReady(lease, signal);
|
|
1385
1415
|
return;
|
|
1386
1416
|
}
|
|
1387
1417
|
catch (error) {
|
|
1418
|
+
// The caller's abort is not a failed exchange to shrug off.
|
|
1419
|
+
if ((0, requestAbort_js_1.isRequestAborted)(error))
|
|
1420
|
+
throw error;
|
|
1388
1421
|
// The session the request was admitted to is gone: nothing more of it
|
|
1389
1422
|
// is sent, the provider is not asked, and what the caller gets is the
|
|
1390
1423
|
// session verdict — never the wire's error, nor the provider's, about
|
|
@@ -1398,7 +1431,7 @@ class AbstractAbapConnection {
|
|
|
1398
1431
|
return;
|
|
1399
1432
|
}
|
|
1400
1433
|
const rejection = this.credentialRejection(error);
|
|
1401
|
-
await this.renewCredential(rejection, renewal).catch((refused) => {
|
|
1434
|
+
await this.renewCredential(rejection, renewal, signal).catch((refused) => {
|
|
1402
1435
|
throw this.staleOr(refused, lease);
|
|
1403
1436
|
});
|
|
1404
1437
|
if (!this.lifecycle.isCurrent(lease)) {
|
|
@@ -1425,19 +1458,25 @@ class AbstractAbapConnection {
|
|
|
1425
1458
|
* wire's own ingest of it, and never stops the request being sent.
|
|
1426
1459
|
* Omitted during connect(), which has no lease.
|
|
1427
1460
|
*/
|
|
1428
|
-
fence
|
|
1461
|
+
fence,
|
|
1462
|
+
/**
|
|
1463
|
+
* The request's signal: the exchange's own attempts stop once it aborts.
|
|
1464
|
+
* Omitted during connect(), whose exchange is nobody's single request.
|
|
1465
|
+
*/
|
|
1466
|
+
signal) {
|
|
1429
1467
|
// Dropped first, because this is only ever reached to REPLACE one: the
|
|
1430
1468
|
// establishment is idempotent and would hand back the very token the
|
|
1431
1469
|
// caller has just been told is stale.
|
|
1432
1470
|
this.transport.adoptCsrfToken(null);
|
|
1433
1471
|
await this.transport.establish({
|
|
1434
1472
|
...(typeof fence === 'number'
|
|
1435
|
-
? this.leasedContext(undefined, fence)
|
|
1436
|
-
: this.leasedContext(fence)),
|
|
1473
|
+
? this.leasedContext(undefined, fence, signal)
|
|
1474
|
+
: this.leasedContext(fence, fence?.generation, signal)),
|
|
1437
1475
|
retries: retryCount,
|
|
1438
1476
|
retryDelayMs: retryDelay,
|
|
1439
1477
|
timeoutMs: (0, timeouts_js_1.getTimeout)('csrf'),
|
|
1440
1478
|
isFatal: (error) => this.endsTheExchange(error),
|
|
1479
|
+
...(signal ? { signal } : {}),
|
|
1441
1480
|
});
|
|
1442
1481
|
const token = this.transport.csrfToken();
|
|
1443
1482
|
if (!token)
|
|
@@ -1484,11 +1523,16 @@ class AbstractAbapConnection {
|
|
|
1484
1523
|
*/
|
|
1485
1524
|
async ensureWireReady(
|
|
1486
1525
|
/** The request's lease: fences what is sent and the response effects. */
|
|
1487
|
-
lease
|
|
1488
|
-
|
|
1489
|
-
|
|
1526
|
+
lease,
|
|
1527
|
+
/** The request's signal: its wait ends at the abort, the exchange runs on. */
|
|
1528
|
+
signal) {
|
|
1529
|
+
// Raced: an exchange already sent is not recalled, and what it earns is
|
|
1530
|
+
// the wire's, for every caller — but this request stops waiting for it.
|
|
1531
|
+
await (0, requestAbort_js_1.untilAborted)(signal, this.transport.establish({
|
|
1532
|
+
...this.leasedContext(lease, lease.generation, signal),
|
|
1490
1533
|
isFatal: (error) => this.endsTheExchange(error),
|
|
1491
|
-
|
|
1534
|
+
...(signal ? { signal } : {}),
|
|
1535
|
+
}));
|
|
1492
1536
|
}
|
|
1493
1537
|
/**
|
|
1494
1538
|
* The context for a token exchange a request makes on its own behalf — its
|
|
@@ -1506,16 +1550,24 @@ class AbstractAbapConnection {
|
|
|
1506
1550
|
* what the connection does with an answer, and nothing else: the request is
|
|
1507
1551
|
* sent, and the wire still folds the answer into its jar.
|
|
1508
1552
|
*/
|
|
1509
|
-
leasedContext(lease, generation = lease?.generation
|
|
1553
|
+
leasedContext(lease, generation = lease?.generation,
|
|
1554
|
+
/**
|
|
1555
|
+
* The request's signal. Each attempt of the exchange is authorized
|
|
1556
|
+
* raced against it, so an exchange whose request was aborted sends
|
|
1557
|
+
* nothing more: the abort ends the exchange (`endsTheExchange`).
|
|
1558
|
+
*/
|
|
1559
|
+
signal) {
|
|
1510
1560
|
return {
|
|
1511
1561
|
baseUrl: this.baseUrl,
|
|
1512
1562
|
authorize: async (headers) => {
|
|
1513
|
-
await this.credentialHeaders(headers);
|
|
1563
|
+
await (0, requestAbort_js_1.untilAborted)(signal, this.credentialHeaders(headers));
|
|
1514
1564
|
if (lease && !this.lifecycle.isCurrent(lease)) {
|
|
1515
1565
|
throw (0, SessionLifecycle_js_1.sessionError)(interfaces_adt_connection_1.ADT_SESSION_ERROR.NOT_CONNECTED, 'The session this request was admitted to is gone; nothing was sent');
|
|
1516
1566
|
}
|
|
1517
1567
|
},
|
|
1518
|
-
|
|
1568
|
+
// A wire that logs on inside a request's own exchange: the logon is
|
|
1569
|
+
// the request's wait like any other, and the exchange stops with it.
|
|
1570
|
+
logon: (target) => (0, requestAbort_js_1.untilAborted)(signal, this.logon(target)),
|
|
1519
1571
|
extraHeaders: { 'sap-adt-connection-id': this.sessionId ?? '' },
|
|
1520
1572
|
// An answer that arrives after the lease went stale belongs to a session
|
|
1521
1573
|
// that is gone. Refused with the session verdict, which every wire hands
|
|
@@ -1531,11 +1583,13 @@ class AbstractAbapConnection {
|
|
|
1531
1583
|
}
|
|
1532
1584
|
/**
|
|
1533
1585
|
* What stops a token exchange at once, past its retries: a session verdict,
|
|
1534
|
-
*
|
|
1535
|
-
* the provider again.
|
|
1586
|
+
* the provider's refusal to authorize it — asking again would only ask
|
|
1587
|
+
* the provider again — or the abort of the request it was made for.
|
|
1536
1588
|
*/
|
|
1537
1589
|
endsTheExchange(error) {
|
|
1538
|
-
return this.isSessionVerdict(error) ||
|
|
1590
|
+
return (this.isSessionVerdict(error) ||
|
|
1591
|
+
(0, requestAbort_js_1.isRequestAborted)(error) ||
|
|
1592
|
+
error instanceof authErrors_js_1.AuthRefusedError);
|
|
1539
1593
|
}
|
|
1540
1594
|
/**
|
|
1541
1595
|
* Clear SAP-side session state when SAP rejects the cached CSRF token + session
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpTransport.d.ts","sourceRoot":"","sources":["../../src/connection/HttpTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAS,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;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OG;IACH,OAAO,CAAC,mBAAmB;IAoE3B,0EAA0E;IAC1E,OAAO,CAAC,SAAS;IASjB,0EAA0E;IAC1E,OAAO,CAAC,OAAO;IAQf;;;;;;;OAOG;IACH,SAAS,CAAC,WAAW,IAAI,YAAY;IAoBrC,OAAO,CAAC,MAAM;IAuBd;;;;;;;OAOG;IACG,IAAI,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAItD;;;;;;OAMG;IACG,KAAK,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAExD;;;;;;;;;;;;;;OAcG;cACa,UAAU,CACxB,OAAO,EAAE,kBAAkB,EAC3B,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE;QACR,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACjC,GACA,OAAO,CAAC,IAAI,CAAC;IAiChB;;;;;OAKG;IACG,IAAI,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAKzE;;;;;;OAMG;IACH,OAAO,CAAC,GAAG;IAmBX;;;;;;;;;;;;;OAaG;cACa,YAAY,CAC1B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;YAInB,QAAQ;CA4BvB"}
|
|
@@ -32,6 +32,7 @@ const cookies_js_1 = require("../utils/cookies.js");
|
|
|
32
32
|
const authErrors_js_1 = require("./authErrors.js");
|
|
33
33
|
const csrfConfig_js_1 = require("./csrfConfig.js");
|
|
34
34
|
const IAdtTransport_js_1 = require("./IAdtTransport.js");
|
|
35
|
+
const requestAbort_js_1 = require("./requestAbort.js");
|
|
35
36
|
const statefulRequest_js_1 = require("./statefulRequest.js");
|
|
36
37
|
/** The cookie that names a stateful ABAP context. */
|
|
37
38
|
const CONTEXT_COOKIE = 'sap-contextid';
|
|
@@ -343,6 +344,11 @@ class HttpTransport {
|
|
|
343
344
|
// Authorized per attempt: a provider may renew behind the call.
|
|
344
345
|
const auth = {};
|
|
345
346
|
await context.authorize(auth);
|
|
347
|
+
// The last point before the wire: the exchange's request was
|
|
348
|
+
// aborted in a turn since its authorize answered. Fatal to the
|
|
349
|
+
// exchange through `isFatal`, like the abort `authorize` raises.
|
|
350
|
+
if (context.signal?.aborted)
|
|
351
|
+
throw (0, requestAbort_js_1.requestAborted)();
|
|
346
352
|
const response = await this.send({
|
|
347
353
|
method: 'GET',
|
|
348
354
|
url,
|
|
@@ -50,6 +50,14 @@ export interface IAdtTransportRequest {
|
|
|
50
50
|
* `HttpTransport.dress`.
|
|
51
51
|
*/
|
|
52
52
|
stateful?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* The caller's signal, for the waits a wire makes on this request's behalf
|
|
55
|
+
* before it sends — over RFC, the logon and the open of a conversation of
|
|
56
|
+
* its own. An abort ends such a wait for this request only; whatever it
|
|
57
|
+
* opened for this request alone is given back. Not a cancel: a request
|
|
58
|
+
* already sent is not recalled, so no wire hands it to its client.
|
|
59
|
+
*/
|
|
60
|
+
signal?: AbortSignal | undefined;
|
|
53
61
|
}
|
|
54
62
|
/** What came back, in the terms every transport can produce. */
|
|
55
63
|
export interface IAdtTransportResponse {
|
|
@@ -121,6 +129,16 @@ export interface IAdtEstablishContext extends IAdtSessionContext {
|
|
|
121
129
|
* apart, so it asks.
|
|
122
130
|
*/
|
|
123
131
|
isFatal?: (error: unknown) => boolean;
|
|
132
|
+
/**
|
|
133
|
+
* The signal of the one request this exchange is made for — its upfront
|
|
134
|
+
* token fetch, its CSRF recovery. Absent for `connect()`'s establishment,
|
|
135
|
+
* which is nobody's single request. A wire checks it immediately before
|
|
136
|
+
* each send of the exchange, in the same turn, and sends nothing once it
|
|
137
|
+
* has fired: the answer to an earlier `authorize` leaves turns in between.
|
|
138
|
+
* The exchange is that request's alone — no other request waits on it —
|
|
139
|
+
* so stopping it takes nothing from another caller.
|
|
140
|
+
*/
|
|
141
|
+
signal?: AbortSignal | undefined;
|
|
124
142
|
}
|
|
125
143
|
export interface IAdtTransport {
|
|
126
144
|
/** For logs, so which transport ran is never inferred from behaviour. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IAdtTransport.d.ts","sourceRoot":"","sources":["../../src/connection/IAdtTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE,4DAA4D;AAC5D,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IAC7C;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"IAdtTransport.d.ts","sourceRoot":"","sources":["../../src/connection/IAdtTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE,4DAA4D;AAC5D,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;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,IAAI,IAAI,CAAC;CACvB;AAED;;;;;;;;;;;;GAYG;AACH;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;CAC3B;AAED,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,qBAAqB,GAAG,IAAI,CAQtE"}
|
|
@@ -196,6 +196,12 @@ export declare class RfcTransport implements IOnPremTransport {
|
|
|
196
196
|
* A new conversation, logged on: the provider is asked what to open with,
|
|
197
197
|
* every time, and a failed open is a refused logon whose cause is the SDK's
|
|
198
198
|
* own error, untouched — a provider reads its `key` and message.
|
|
199
|
+
*
|
|
200
|
+
* With a request's signal — a call that opens a conversation of its own —
|
|
201
|
+
* both waits are that request's: the provider's logon and the open. An
|
|
202
|
+
* abort ends either for this request at once. A logon it stopped waiting
|
|
203
|
+
* for opens nothing; an open it stopped waiting for runs on, and the
|
|
204
|
+
* conversation it opens — this request's alone — is closed when it does.
|
|
199
205
|
*/
|
|
200
206
|
private loggedOn;
|
|
201
207
|
private closeQuietly;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RfcTransport.d.ts","sourceRoot":"","sources":["../../src/connection/RfcTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"RfcTransport.d.ts","sourceRoot":"","sources":["../../src/connection/RfcTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;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B"}
|
|
@@ -46,6 +46,7 @@ exports.RfcTransport = void 0;
|
|
|
46
46
|
const node_crypto_1 = require("node:crypto");
|
|
47
47
|
const auth_errors_1 = require("@mcp-abap-adt/auth-errors");
|
|
48
48
|
const authErrors_js_1 = require("./authErrors.js");
|
|
49
|
+
const requestAbort_js_1 = require("./requestAbort.js");
|
|
49
50
|
const statefulRequest_js_1 = require("./statefulRequest.js");
|
|
50
51
|
/**
|
|
51
52
|
* The SDK answers with untyped structures: each level is read as a record and
|
|
@@ -294,7 +295,7 @@ class RfcTransport {
|
|
|
294
295
|
const generation = this.generation;
|
|
295
296
|
return (0, statefulRequest_js_1.isStatefulRequest)(request)
|
|
296
297
|
? this.carry(request, this.conversation, generation)
|
|
297
|
-
: this.carryOnItsOwn(request, generation);
|
|
298
|
+
: this.carryOnItsOwn(request, generation, request.signal);
|
|
298
299
|
}
|
|
299
300
|
/**
|
|
300
301
|
* A request that is not stateful, in a fresh ABAP session.
|
|
@@ -310,17 +311,17 @@ class RfcTransport {
|
|
|
310
311
|
* package the first one saved would refuse the second one's write (PAK/058).
|
|
311
312
|
* So a concurrent call takes a conversation of its own instead of waiting.
|
|
312
313
|
*/
|
|
313
|
-
async carryOnItsOwn(request, generation) {
|
|
314
|
+
async carryOnItsOwn(request, generation, signal) {
|
|
314
315
|
if (this.canReset !== false && !this.statelessBusy) {
|
|
315
|
-
return this.carryOnKept(request, generation);
|
|
316
|
+
return this.carryOnKept(request, generation, signal);
|
|
316
317
|
}
|
|
317
|
-
return this.carryOnThrowaway(request, generation);
|
|
318
|
+
return this.carryOnThrowaway(request, generation, signal);
|
|
318
319
|
}
|
|
319
|
-
async carryOnKept(request, generation) {
|
|
320
|
+
async carryOnKept(request, generation, signal) {
|
|
320
321
|
this.statelessBusy = true;
|
|
321
322
|
try {
|
|
322
323
|
if (!this.stateless?.alive) {
|
|
323
|
-
const opened = await this.openOwn(generation);
|
|
324
|
+
const opened = await this.openOwn(generation, signal);
|
|
324
325
|
// Checked again after the await: close() may have run since openOwn()
|
|
325
326
|
// checked, and a conversation of a closed wire must not become the
|
|
326
327
|
// kept one of the next.
|
|
@@ -365,8 +366,8 @@ class RfcTransport {
|
|
|
365
366
|
}
|
|
366
367
|
}
|
|
367
368
|
/** A conversation opened for this one call, closed when it answers. */
|
|
368
|
-
async carryOnThrowaway(request, generation) {
|
|
369
|
-
const own = await this.openOwn(generation);
|
|
369
|
+
async carryOnThrowaway(request, generation, signal) {
|
|
370
|
+
const own = await this.openOwn(generation, signal);
|
|
370
371
|
this.logger?.debug('RFC conversation opened for one stateless call');
|
|
371
372
|
try {
|
|
372
373
|
return await this.carry(request, own, generation);
|
|
@@ -380,8 +381,8 @@ class RfcTransport {
|
|
|
380
381
|
* wire was closed meanwhile, the conversation is closed again and nothing is
|
|
381
382
|
* sent — not a PUT, not a DELETE — on a wire already given back.
|
|
382
383
|
*/
|
|
383
|
-
async openOwn(generation) {
|
|
384
|
-
const own = await this.loggedOn();
|
|
384
|
+
async openOwn(generation, signal) {
|
|
385
|
+
const own = await this.loggedOn(signal);
|
|
385
386
|
if (generation !== this.generation || !this.conversation?.alive) {
|
|
386
387
|
await this.closeQuietly(own);
|
|
387
388
|
throw new Error('RFC transport was closed while the call was being opened; nothing was sent.');
|
|
@@ -414,16 +415,42 @@ class RfcTransport {
|
|
|
414
415
|
* A new conversation, logged on: the provider is asked what to open with,
|
|
415
416
|
* every time, and a failed open is a refused logon whose cause is the SDK's
|
|
416
417
|
* own error, untouched — a provider reads its `key` and message.
|
|
418
|
+
*
|
|
419
|
+
* With a request's signal — a call that opens a conversation of its own —
|
|
420
|
+
* both waits are that request's: the provider's logon and the open. An
|
|
421
|
+
* abort ends either for this request at once. A logon it stopped waiting
|
|
422
|
+
* for opens nothing; an open it stopped waiting for runs on, and the
|
|
423
|
+
* conversation it opens — this request's alone — is closed when it does.
|
|
417
424
|
*/
|
|
418
|
-
async loggedOn() {
|
|
425
|
+
async loggedOn(signal) {
|
|
419
426
|
const parameters = {};
|
|
420
|
-
|
|
427
|
+
if (this.context) {
|
|
428
|
+
await (0, requestAbort_js_1.untilAborted)(signal, this.context.logon(this.logonTarget(parameters)));
|
|
429
|
+
}
|
|
421
430
|
const conversation = this.connect(parameters);
|
|
431
|
+
// An `open()` that throws instead of rejecting is a refused logon too.
|
|
432
|
+
let opened;
|
|
422
433
|
try {
|
|
423
|
-
|
|
434
|
+
opened = Promise.resolve(conversation.open());
|
|
424
435
|
}
|
|
425
436
|
catch (e) {
|
|
437
|
+
opened = Promise.reject(e);
|
|
438
|
+
}
|
|
439
|
+
const opening = opened.catch((e) => {
|
|
426
440
|
throw new authErrors_js_1.WireLogonError(e);
|
|
441
|
+
});
|
|
442
|
+
try {
|
|
443
|
+
await (0, requestAbort_js_1.untilAborted)(signal, opening);
|
|
444
|
+
}
|
|
445
|
+
catch (e) {
|
|
446
|
+
if ((0, requestAbort_js_1.isRequestAborted)(e)) {
|
|
447
|
+
// A failed open has nothing to close, and its failure is nobody's.
|
|
448
|
+
// What would have become the kept conversation is closed too, not
|
|
449
|
+
// kept: the next call pays a logon, and no session outlives a call
|
|
450
|
+
// its caller gave up on.
|
|
451
|
+
opening.then(() => this.closeQuietly(conversation), () => { });
|
|
452
|
+
}
|
|
453
|
+
throw e;
|
|
427
454
|
}
|
|
428
455
|
return conversation;
|
|
429
456
|
}
|
|
@@ -496,6 +523,12 @@ class RfcTransport {
|
|
|
496
523
|
if (generation !== this.generation) {
|
|
497
524
|
throw new Error('RFC transport was closed before the call was sent; nothing was sent.');
|
|
498
525
|
}
|
|
526
|
+
// And the caller's abort, here for the same reason: the logon and the
|
|
527
|
+
// open answered turns ago, and an abort since must stop the call. A
|
|
528
|
+
// conversation opened for this call alone is closed by its caller's
|
|
529
|
+
// `finally`; the kept one is reset and stays kept.
|
|
530
|
+
if (request.signal?.aborted)
|
|
531
|
+
throw (0, requestAbort_js_1.requestAborted)();
|
|
499
532
|
let raw;
|
|
500
533
|
try {
|
|
501
534
|
raw = await conversation.call('SADT_REST_RFC_ENDPOINT', {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a request's signal does to it: the error it ends with, the check made
|
|
3
|
+
* at each send boundary, and the race each of its waits runs against it.
|
|
4
|
+
*
|
|
5
|
+
* The signal belongs to ONE caller. A wait it ends — the provider's
|
|
6
|
+
* `authorize()` or `rejected()`, a logon, a conversation's `open()` — ends for
|
|
7
|
+
* that caller only: the work behind it runs on, because another caller may be
|
|
8
|
+
* waiting on the very same work (a provider shares one renewal among all who
|
|
9
|
+
* ask). Its late answer is handled here and dropped, never left unhandled.
|
|
10
|
+
*
|
|
11
|
+
* A request already sent is not recalled: nothing here reaches into the wire.
|
|
12
|
+
*/
|
|
13
|
+
import { type AdtRequestErrorCode } from '@mcp-abap-adt/interfaces-adt-connection';
|
|
14
|
+
export type RequestAbortedError = Error & {
|
|
15
|
+
code: AdtRequestErrorCode;
|
|
16
|
+
};
|
|
17
|
+
/** The error an aborted request rejects with: `ADT_REQUEST_ERROR.ABORTED`. */
|
|
18
|
+
export declare function requestAborted(): RequestAbortedError;
|
|
19
|
+
/** Whether an error is a request's abort. Read structurally, by its code. */
|
|
20
|
+
export declare function isRequestAborted(error: unknown): boolean;
|
|
21
|
+
/** A send boundary: an aborted request goes no further. */
|
|
22
|
+
export declare function throwIfAborted(signal: AbortSignal | undefined): void;
|
|
23
|
+
/**
|
|
24
|
+
* One wait of a request, raced against its signal.
|
|
25
|
+
*
|
|
26
|
+
* Settles as `work` does, or rejects with the abort the moment the signal
|
|
27
|
+
* fires — at once when it already has. `work` is never cancelled: it runs on
|
|
28
|
+
* for whoever else waits on it, and what it answers after the abort is
|
|
29
|
+
* handled and dropped. Without a signal, `work` itself.
|
|
30
|
+
*/
|
|
31
|
+
export declare function untilAborted<T>(signal: AbortSignal | undefined, work: Promise<T>): Promise<T>;
|
|
32
|
+
//# sourceMappingURL=requestAbort.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestAbort.d.ts","sourceRoot":"","sources":["../../src/connection/requestAbort.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,yCAAyC,CAAC;AASjD,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG;IAAE,IAAI,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAExE,8EAA8E;AAC9E,wBAAgB,cAAc,IAAI,mBAAmB,CAKpD;AAED,6EAA6E;AAC7E,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAKxD;AAED,2DAA2D;AAC3D,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,IAAI,CAEpE;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GACf,OAAO,CAAC,CAAC,CAAC,CAoBZ"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requestAborted = requestAborted;
|
|
4
|
+
exports.isRequestAborted = isRequestAborted;
|
|
5
|
+
exports.throwIfAborted = throwIfAborted;
|
|
6
|
+
exports.untilAborted = untilAborted;
|
|
7
|
+
/**
|
|
8
|
+
* What a request's signal does to it: the error it ends with, the check made
|
|
9
|
+
* at each send boundary, and the race each of its waits runs against it.
|
|
10
|
+
*
|
|
11
|
+
* The signal belongs to ONE caller. A wait it ends — the provider's
|
|
12
|
+
* `authorize()` or `rejected()`, a logon, a conversation's `open()` — ends for
|
|
13
|
+
* that caller only: the work behind it runs on, because another caller may be
|
|
14
|
+
* waiting on the very same work (a provider shares one renewal among all who
|
|
15
|
+
* ask). Its late answer is handled here and dropped, never left unhandled.
|
|
16
|
+
*
|
|
17
|
+
* A request already sent is not recalled: nothing here reaches into the wire.
|
|
18
|
+
*/
|
|
19
|
+
const interfaces_adt_connection_1 = require("@mcp-abap-adt/interfaces-adt-connection");
|
|
20
|
+
/**
|
|
21
|
+
* Fixed words: nothing of the request, the signal's reason or anything a
|
|
22
|
+
* server said reaches them.
|
|
23
|
+
*/
|
|
24
|
+
const ABORTED_WORDS = 'The request was aborted by its caller; nothing more of it was sent.';
|
|
25
|
+
/** The error an aborted request rejects with: `ADT_REQUEST_ERROR.ABORTED`. */
|
|
26
|
+
function requestAborted() {
|
|
27
|
+
const error = new Error(ABORTED_WORDS);
|
|
28
|
+
error.name = 'AdtRequestAbortedError';
|
|
29
|
+
error.code = interfaces_adt_connection_1.ADT_REQUEST_ERROR.ABORTED;
|
|
30
|
+
return error;
|
|
31
|
+
}
|
|
32
|
+
/** Whether an error is a request's abort. Read structurally, by its code. */
|
|
33
|
+
function isRequestAborted(error) {
|
|
34
|
+
return (error?.code ===
|
|
35
|
+
interfaces_adt_connection_1.ADT_REQUEST_ERROR.ABORTED);
|
|
36
|
+
}
|
|
37
|
+
/** A send boundary: an aborted request goes no further. */
|
|
38
|
+
function throwIfAborted(signal) {
|
|
39
|
+
if (signal?.aborted)
|
|
40
|
+
throw requestAborted();
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* One wait of a request, raced against its signal.
|
|
44
|
+
*
|
|
45
|
+
* Settles as `work` does, or rejects with the abort the moment the signal
|
|
46
|
+
* fires — at once when it already has. `work` is never cancelled: it runs on
|
|
47
|
+
* for whoever else waits on it, and what it answers after the abort is
|
|
48
|
+
* handled and dropped. Without a signal, `work` itself.
|
|
49
|
+
*/
|
|
50
|
+
function untilAborted(signal, work) {
|
|
51
|
+
if (!signal)
|
|
52
|
+
return work;
|
|
53
|
+
// Handled before anything else can happen: an answer that arrives after
|
|
54
|
+
// the abort is nobody's, and must not surface as an unhandled rejection.
|
|
55
|
+
work.catch(() => { });
|
|
56
|
+
if (signal.aborted)
|
|
57
|
+
return Promise.reject(requestAborted());
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
const onAbort = () => reject(requestAborted());
|
|
60
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
61
|
+
work.then((value) => {
|
|
62
|
+
signal.removeEventListener('abort', onAbort);
|
|
63
|
+
resolve(value);
|
|
64
|
+
}, (error) => {
|
|
65
|
+
signal.removeEventListener('abort', onAbort);
|
|
66
|
+
reject(error);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
package/docs/INSTALLATION.md
CHANGED
|
@@ -189,7 +189,7 @@ puts two copies of the same contract in your tree.
|
|
|
189
189
|
The credential providers (`BasicAuthProvider`, `TokenAuthProvider`,
|
|
190
190
|
`SamlAuthProvider`, `CertificateAuthProvider`) are no longer part of this
|
|
191
191
|
package as of 10.0.0; install `@mcp-abap-adt/auth-providers` for them —
|
|
192
|
-
connection 13.x
|
|
192
|
+
connection 13.x to 15.x work with auth-providers **6.0.0** (`^6.0.0`), built on
|
|
193
193
|
interfaces-auth 7 and auth-errors 2; the 5.x providers do not fit.
|
|
194
194
|
See [Migration to 10.0.0](./MIGRATION-10.0.md),
|
|
195
195
|
[Migration to 12.0.0](./MIGRATION-12.0.md) and
|
|
@@ -172,6 +172,15 @@ Every ADT request issued through `makeAdtRequest` automatically:
|
|
|
172
172
|
|
|
173
173
|
This logic is transparent to callers (Builders, handlers, CLI scripts).
|
|
174
174
|
|
|
175
|
+
A request carrying a `signal` stops at the first of these steps that would send
|
|
176
|
+
something after its caller aborted: the upfront token fetch, the send itself,
|
|
177
|
+
the CSRF retry, the cookie retry of a GET and the provider's renewal below. Each
|
|
178
|
+
wait in between — the provider's `authorize()` and `rejected()`, a logon, the
|
|
179
|
+
token exchange, an RFC conversation's `open()` — ends for that caller at the
|
|
180
|
+
abort, with `ADT_REQUEST_ABORTED`; the session's token and cookies are left as
|
|
181
|
+
they are, for the requests still running on them. A request already on the wire
|
|
182
|
+
is not recalled. See [USAGE.md — Cancelling a request](./USAGE.md#cancelling-a-request).
|
|
183
|
+
|
|
175
184
|
A 401 that survives the wire's own CSRF recovery is put to the provider (`rejected`). On Ok the
|
|
176
185
|
request is sent once more, always under the same lease and generation as the attempt it repeats,
|
|
177
186
|
so stale-request fencing applies. After a rejection at `'request'` that resend goes out on the
|
package/docs/USAGE.md
CHANGED
|
@@ -227,6 +227,52 @@ await connection.makeAdtRequest({
|
|
|
227
227
|
});
|
|
228
228
|
```
|
|
229
229
|
|
|
230
|
+
### Cancelling a request
|
|
231
|
+
|
|
232
|
+
A request takes the caller's `AbortSignal` as `signal`. It is checked at every
|
|
233
|
+
point where the request would send something — before the first send, before
|
|
234
|
+
every resend (the CSRF recovery's included) and before the provider is asked to
|
|
235
|
+
renew — and every wait the request makes races it: the provider's `authorize()`
|
|
236
|
+
and `rejected()`, a logon (`establish()`), the token exchange and, over RFC, the
|
|
237
|
+
`open()` of a conversation of its own. Once it aborts, nothing more of the
|
|
238
|
+
request is sent and the call rejects at once with `code: 'ADT_REQUEST_ABORTED'`
|
|
239
|
+
(`ADT_REQUEST_ERROR.ABORTED` from `@mcp-abap-adt/interfaces-adt-connection`),
|
|
240
|
+
in fixed words.
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
import { ADT_REQUEST_ERROR } from '@mcp-abap-adt/interfaces-adt-connection';
|
|
244
|
+
import { getTimeout } from '@mcp-abap-adt/connection';
|
|
245
|
+
const controller = new AbortController();
|
|
246
|
+
try {
|
|
247
|
+
await connection.makeAdtRequest<string>({
|
|
248
|
+
method: 'GET',
|
|
249
|
+
url: '/sap/bc/adt/repository/nodestructure',
|
|
250
|
+
timeout: getTimeout('default'),
|
|
251
|
+
signal: controller.signal,
|
|
252
|
+
});
|
|
253
|
+
} catch (error) {
|
|
254
|
+
if ((error as { code?: unknown }).code === ADT_REQUEST_ERROR.ABORTED) {
|
|
255
|
+
// Nothing more of it was sent. What was already sent may have been acted on.
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
What it does not do:
|
|
261
|
+
|
|
262
|
+
- **It does not recall a request already sent.** The server may act on it, and
|
|
263
|
+
its answer — success or failure — is still the caller's. Only what would
|
|
264
|
+
follow it (a resend, a renewal) is not sent.
|
|
265
|
+
- **It ends a wait for this caller only.** A provider's work behind it runs
|
|
266
|
+
on: a provider shares one renewal among every request it refused. Whatever
|
|
267
|
+
that work answers late is handled and dropped. A token exchange the request
|
|
268
|
+
started makes no further attempt once it aborts; one already on the wire is
|
|
269
|
+
not recalled, and the token it earns is the session's. A conversation an
|
|
270
|
+
RFC call opened for itself alone is closed when its `open()` answers.
|
|
271
|
+
- **It is not the deadline.** `timeout` still bounds a request on the HTTP wire;
|
|
272
|
+
the signal is the caller saying it no longer needs the answer.
|
|
273
|
+
|
|
274
|
+
Without a signal a request behaves exactly as before.
|
|
275
|
+
|
|
230
276
|
## Session Management
|
|
231
277
|
|
|
232
278
|
### Stateless Mode (Default)
|
|
@@ -933,7 +979,7 @@ export class CloudSdkAbapConnection {
|
|
|
933
979
|
### The credential, and how a refusal is classified
|
|
934
980
|
|
|
935
981
|
For SAP BTP cloud systems, hand `AdtCloudConnector` a token provider from
|
|
936
|
-
`@mcp-abap-adt/auth-providers` 6.0.0 (connection 13.x
|
|
982
|
+
`@mcp-abap-adt/auth-providers` 6.0.0 (connection 13.x to 15.x work with `^6.0.0`): `TokenAuthProvider.fixed(token)` is a token with
|
|
937
983
|
nothing behind it, `TokenAuthProvider.from(refresher)` takes an `ITokenRefresher`
|
|
938
984
|
and renews a token the system refused. Obtaining tokens in the first place is
|
|
939
985
|
`@mcp-abap-adt/auth-broker`'s job, not this package's.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-abap-adt/connection",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.1.0",
|
|
4
4
|
"description": "ABAP connection layer for MCP ABAP ADT server",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -50,20 +50,20 @@
|
|
|
50
50
|
"node": "^22 || ^24 || ^26"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@mcp-abap-adt/auth-errors": "^2.2.
|
|
54
|
-
"@mcp-abap-adt/interfaces-adt-connection": "^2.
|
|
53
|
+
"@mcp-abap-adt/auth-errors": "^2.2.1",
|
|
54
|
+
"@mcp-abap-adt/interfaces-adt-connection": "^2.1.0",
|
|
55
55
|
"@mcp-abap-adt/interfaces-auth": "^7.5.0",
|
|
56
56
|
"@mcp-abap-adt/interfaces-auth-sap": "^3.3.0",
|
|
57
|
-
"@mcp-abap-adt/interfaces-network": "^2.0.
|
|
58
|
-
"@mcp-abap-adt/interfaces-utils": "^1.1.
|
|
57
|
+
"@mcp-abap-adt/interfaces-network": "^2.0.1",
|
|
58
|
+
"@mcp-abap-adt/interfaces-utils": "^1.1.1",
|
|
59
59
|
"axios": "^1.16.0"
|
|
60
60
|
},
|
|
61
61
|
"optionalDependencies": {
|
|
62
|
-
"@mcp-abap-adt/sap-rfc-lite": "^0.2.
|
|
62
|
+
"@mcp-abap-adt/sap-rfc-lite": "^0.2.2"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@biomejs/biome": "^2.3.14",
|
|
66
|
-
"@mcp-abap-adt/auth-providers": "^6.0.
|
|
66
|
+
"@mcp-abap-adt/auth-providers": "^6.0.2",
|
|
67
67
|
"@types/jest": "^30.0.0",
|
|
68
68
|
"@types/node": "^25.2.3",
|
|
69
69
|
"dotenv": "^17.3.1",
|