@mcp-abap-adt/connection 20.1.0 → 22.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +91 -1
- package/README.md +119 -35
- package/dist/connection/AbstractAbapConnection.d.ts +17 -8
- package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
- package/dist/connection/AbstractAbapConnection.js +46 -26
- package/dist/connection/CredentialAbapConnection.d.ts.map +1 -1
- package/dist/connection/CredentialAbapConnection.js +1 -4
- package/dist/connection/HttpTransport.d.ts.map +1 -1
- package/dist/connection/HttpTransport.js +97 -72
- package/dist/connection/IAdtTransport.d.ts +11 -14
- package/dist/connection/IAdtTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.d.ts +21 -1
- package/dist/connection/RfcTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.js +292 -51
- package/dist/connection/authErrors.d.ts +14 -0
- package/dist/connection/authErrors.d.ts.map +1 -1
- package/dist/connection/authErrors.js +19 -1
- package/dist/connection/csrfConfig.d.ts +4 -10
- package/dist/connection/csrfConfig.d.ts.map +1 -1
- package/dist/connection/csrfConfig.js +4 -10
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/docs/INDEX.md +3 -0
- package/docs/MIGRATION-21.0.md +87 -0
- package/docs/MIGRATION-22.0.md +78 -0
- package/docs/USAGE.md +83 -39
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,94 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [22.0.0] - 2026-11-12
|
|
11
|
+
|
|
12
|
+
Over RFC, a request carries its passport and a failure names its error by fields, and an RFC
|
|
13
|
+
error that ends the stateful conversation ends the instance's session: the connection does not
|
|
14
|
+
open a new one on its own. Breaking for code that went on with an instance after such an error,
|
|
15
|
+
and for code that read the passport from the endpoint's header fields. See
|
|
16
|
+
[docs/MIGRATION-22.0.md](docs/MIGRATION-22.0.md).
|
|
17
|
+
|
|
18
|
+
### Changed — breaking
|
|
19
|
+
|
|
20
|
+
- **An RFC error that ends the stateful conversation is the session lost.** When sap-rfc-lite
|
|
21
|
+
releases the stateful conversation after a failed call (`alive` false, and not a close of
|
|
22
|
+
ours), the request rejects `ADT_SESSION_REPLACED` with the call's `rfc`, the instance is
|
|
23
|
+
spent, and every later request and `connect()` reject `ADT_NOT_CONNECTED` with nothing sent.
|
|
24
|
+
Nothing opens a new session: with sap-rfc-lite 0.3.x the next request went on, silently, on a
|
|
25
|
+
new one, its locks gone. A new session is a new connection.
|
|
26
|
+
- **The `SAP-PASSPORT` header is no longer a header field over RFC.** It becomes the RFC call's
|
|
27
|
+
passport (below); `SADT_REST_RFC_ENDPOINT` never read it as a field.
|
|
28
|
+
- **`@mcp-abap-adt/sap-rfc-lite` ^0.4.0** (optional, as before), whose minor is itself breaking;
|
|
29
|
+
**`@mcp-abap-adt/interfaces-adt-connection` ^4.1.0**.
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
|
|
33
|
+
- **A failed RFC call carries `rfc: { key, group, code, codeString }`** (`IRfcErrorInfo`;
|
|
34
|
+
`codeString` one of `RFC_RCS`), checked once where the wire receives the SDK's error: own
|
|
35
|
+
data properties only, no getter run, nothing read out of a message. `rfc` is carried on every
|
|
36
|
+
conversation, stateful or not. The message is the call's (`RFC call to SADT_REST_RFC_ENDPOINT
|
|
37
|
+
failed: …`, ending in fixed words when the thrown value cannot be described) and the top-level
|
|
38
|
+
`code` is not set — except when the error ended the stateful conversation: then the message is
|
|
39
|
+
the session-lost one and `code` is `ADT_SESSION_REPLACED` (above). Neither describing the
|
|
40
|
+
thrown value nor a logger that throws — the wire's or the connection's — can replace that
|
|
41
|
+
verdict or the call's `rfc`.
|
|
42
|
+
- **The passport over RFC.** A request's `SAP-PASSPORT` header (name read without case) is
|
|
43
|
+
hex-decoded and handed to sap-rfc-lite as the call's own passport, for that call only, so a
|
|
44
|
+
program started over RFC is caught by a terminal-mode external debugger listening for the
|
|
45
|
+
passport's ids. A value that is not hex, or the header named twice, is refused before
|
|
46
|
+
anything is sent, the value never quoted. No header: no passport. `IRfcConversation.call`
|
|
47
|
+
takes an optional third parameter, `{ passport? }`.
|
|
48
|
+
- **`WireSessionLostError`**, exported beside `WireLogonError`: a wire's mark that the session
|
|
49
|
+
it carries has ended. The connection acts on the class, never on the wire's kind.
|
|
50
|
+
|
|
51
|
+
### Changed
|
|
52
|
+
|
|
53
|
+
- **A non-stateful RFC conversation an RFC error ended is dropped**, not reset or closed (both
|
|
54
|
+
would reject); the next call opens another, and the instance goes on.
|
|
55
|
+
- **An ADT exception type that is not an own key of the status table** (`toString`,
|
|
56
|
+
`constructor`, `__proto__`) reads as `500`; it fell through to `200 OK` before.
|
|
57
|
+
- **No regular expression in the RFC wire:** the exception type and the header names redacted
|
|
58
|
+
in the wire log are read by plain code, with the same results; the exception type in one
|
|
59
|
+
linear scan.
|
|
60
|
+
|
|
61
|
+
## [21.0.0] - 2026-11-11
|
|
62
|
+
|
|
63
|
+
The CSRF token fetch asks once. Breaking for code that reads `CSRF_CONFIG.RETRY_COUNT` /
|
|
64
|
+
`RETRY_DELAY`, for a wire of its own that reads the establish context's `retries`,
|
|
65
|
+
`retryDelayMs` or `isFatal`, and for a subclass that calls `fetchCsrfToken` with retry numbers or
|
|
66
|
+
overrides `endsTheExchange`; a caller of `createConnection`, the connectors and `makeAdtRequest`
|
|
67
|
+
changes nothing. See [docs/MIGRATION-21.0.md](docs/MIGRATION-21.0.md).
|
|
68
|
+
|
|
69
|
+
### Changed — breaking
|
|
70
|
+
|
|
71
|
+
- **The CSRF token fetch is one request per endpoint, with no retry and no delay.** A logon
|
|
72
|
+
against a closed port made four requests about a second apart and reported its failure some
|
|
73
|
+
three seconds later; the recovery after a `403` "CSRF token validation failed" asked up to six
|
|
74
|
+
times, two seconds apart. A failed request is its own error now: `connect()` rejects with it at
|
|
75
|
+
once. The fallback endpoint `/sap/bc/adt/discovery` is still asked, once, only after
|
|
76
|
+
`/sap/bc/adt/core/discovery` answered `404` or `501` (BASIS < 7.52) — it is not a retry. The
|
|
77
|
+
named resend on a pooled socket that ended before any answer byte (#314) is unchanged.
|
|
78
|
+
- **Removed:** `CSRF_CONFIG.RETRY_COUNT`, `CSRF_CONFIG.RETRY_DELAY`;
|
|
79
|
+
`IAdtEstablishContext.retries`, `.retryDelayMs` and `.isFatal` (with nothing retried it decides
|
|
80
|
+
nothing: a session verdict carries no response, so the wire neither folds it in nor reads it as
|
|
81
|
+
an absent endpoint); the `retryCount` / `retryDelay` parameters of the protected
|
|
82
|
+
`fetchCsrfToken`, now `fetchCsrfToken(url, fence?)`; the protected `endsTheExchange`.
|
|
83
|
+
|
|
84
|
+
### Fixed
|
|
85
|
+
|
|
86
|
+
- **A CSRF token is read as one non-empty string.** Response headers come from outside the type
|
|
87
|
+
system: an `x-csrf-token` that arrived as an array (the header twice), a number or an empty
|
|
88
|
+
value was stored as the token; it is now no token — on a success the fetch fails
|
|
89
|
+
`NOT_IN_HEADERS`, on a refusal nothing is kept.
|
|
90
|
+
|
|
91
|
+
### Documentation
|
|
92
|
+
|
|
93
|
+
- **The two other resends are named beside the #314 one**, in the README and USAGE ("Two more
|
|
94
|
+
named resends"): the CSRF recovery (a token fetched in the same session and one resend after a
|
|
95
|
+
refusal over the token) and the credential's renewal (one more attempt after `rejected()`
|
|
96
|
+
answers Ok). Both are unchanged; each happens at most once for a request.
|
|
97
|
+
|
|
10
98
|
## [20.1.0] - 2026-11-09
|
|
11
99
|
|
|
12
100
|
A request runs in its `sap-language` over RFC as it does over HTTP.
|
|
@@ -2870,7 +2958,9 @@ const connection = createAbapConnection(config, logger);
|
|
|
2870
2958
|
- JWT token refresh now properly handles connection errors (401/403 during initial connect)
|
|
2871
2959
|
- Permission errors (403 with "ExceptionResourceNoAccess") no longer trigger JWT refresh loops
|
|
2872
2960
|
- Proper separation: base class handles HTTP/session, concrete classes handle auth-specific errors
|
|
2873
|
-
[Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/
|
|
2961
|
+
[Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/v22.0.0...HEAD
|
|
2962
|
+
[22.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v21.0.0...v22.0.0
|
|
2963
|
+
[21.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v20.1.0...v21.0.0
|
|
2874
2964
|
[20.1.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v20.0.0...v20.1.0
|
|
2875
2965
|
[20.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v19.1.0...v20.0.0
|
|
2876
2966
|
[19.1.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v19.0.0...v19.1.0
|
package/README.md
CHANGED
|
@@ -162,6 +162,8 @@ the packages above. See [Migration to 9.0.0](./docs/MIGRATION-9.0.md).
|
|
|
162
162
|
|
|
163
163
|
- 📦 **[Installation Guide](./docs/INSTALLATION.md)** - Setup and installation instructions
|
|
164
164
|
- 📚 **[Usage Guide](./docs/USAGE.md)** - Detailed usage examples and API documentation
|
|
165
|
+
- 🚚 **[Migration to 22.0.0](./docs/MIGRATION-22.0.md)** - over RFC: a connection-ending RFC error on the stateful conversation is `ADT_SESSION_REPLACED` and spends the instance (no silent reconnect); a failed RFC call carries `rfc: { key, group, code, codeString }`; the `SAP-PASSPORT` header becomes the RFC call's passport; `@mcp-abap-adt/sap-rfc-lite` ^0.4.0
|
|
166
|
+
- 🚚 **[Migration to 21.0.0](./docs/MIGRATION-21.0.md)** - the CSRF token fetch asks once: no retry, no delay; `CSRF_CONFIG.RETRY_COUNT` / `RETRY_DELAY`, the establish context's `retries` / `retryDelayMs` / `isFatal`, `fetchCsrfToken`'s retry parameters and `endsTheExchange` are removed
|
|
165
167
|
- 🚚 **[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`
|
|
166
168
|
- 🚚 **[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
|
|
167
169
|
- 🚚 **[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`)
|
|
@@ -301,6 +303,31 @@ answer would run it twice; for a socket the server closed while it was idle,
|
|
|
301
303
|
that does not happen. Without the resend, a cleanup `UNLOCK` died so and the
|
|
302
304
|
enqueue lock stayed until SM12 (mcp-abap-adt#314).
|
|
303
305
|
|
|
306
|
+
**Two more named resends** (named in 21.0.0; the behaviour is older). Beside
|
|
307
|
+
the one above, a request is sent once more in exactly two cases — each at most
|
|
308
|
+
once for a request, never a second time:
|
|
309
|
+
|
|
310
|
+
- **The CSRF recovery.** SAP refused the request over its CSRF token — a `403`
|
|
311
|
+
"CSRF token validation failed", or an answer whose body names the CSRF token
|
|
312
|
+
— or answered `401` to a `POST`, `PUT` or `DELETE` sent while the wire held
|
|
313
|
+
no token. The wire fetches a token in the same session (its cookies kept; one
|
|
314
|
+
fetch, no retry) and sends the request once more, authorized anew. Not a plain
|
|
315
|
+
retry: the request was refused for what it carried — a stale or missing token
|
|
316
|
+
— and goes again carrying something different, the fresh token; sent as it
|
|
317
|
+
was, it would only be refused again. A resend that fails ends the request: a
|
|
318
|
+
session verdict or the credential's refusal is thrown, anything else rethrows
|
|
319
|
+
the error the recovery started from.
|
|
320
|
+
- **The credential's renewal.** A `401`, or a logon the system refused, goes to
|
|
321
|
+
the provider (`rejected()`); when it answers Ok, the request — or the logon —
|
|
322
|
+
is authorized again and sent once more, in the same session. Not a plain retry
|
|
323
|
+
either: the provider renewed what the attempt carries, and the attempt carries
|
|
324
|
+
the new credential. One per request: a second refusal is `AuthRefusedError`
|
|
325
|
+
(refused again), and the provider is not asked twice. A `403` never goes to
|
|
326
|
+
the provider.
|
|
327
|
+
|
|
328
|
+
Nothing else is sent again: a failed request — the CSRF token fetch included
|
|
329
|
+
(21.0.0) — is its own error.
|
|
330
|
+
|
|
304
331
|
### An instance on an existing session
|
|
305
332
|
|
|
306
333
|
An instance may be built on a session that already exists, instead of logging
|
|
@@ -475,7 +502,7 @@ package state from causing PAK/058 on later writes or SADT_RESOURCE/007 on a
|
|
|
475
502
|
read after create. Concurrent calls use a separate conversation. See
|
|
476
503
|
[RFC conversation isolation](./docs/STATEFUL_SESSION_GUIDE.md#rfc-conversation-isolation-932-and-933).
|
|
477
504
|
|
|
478
|
-
Needs `npm install @mcp-abap-adt/sap-rfc-lite` (0.
|
|
505
|
+
Needs `npm install @mcp-abap-adt/sap-rfc-lite` (0.4.0 or newer: it installs with no install
|
|
479
506
|
script and carries prebuilt bindings for linux-x64 glibc, win32-x64 and darwin-arm64; elsewhere,
|
|
480
507
|
build one from its repository) and the SAP NetWeaver RFC library at run time: on Windows, the
|
|
481
508
|
64-bit `sapnwrfc.dll` SAP GUI installs into `System32` is enough; otherwise the SAP NW RFC SDK, its
|
|
@@ -515,6 +542,77 @@ await connection.connect();
|
|
|
515
542
|
// disconnect. What differs is where the session lives — see below.
|
|
516
543
|
```
|
|
517
544
|
|
|
545
|
+
**The passport travels as the call's own** (22.0.0). A request that carries a
|
|
546
|
+
`SAP-PASSPORT` header (its name read without case) is sent over RFC with that
|
|
547
|
+
passport as the RFC call's passport, for that call only — so an ABAP program
|
|
548
|
+
started over RFC is caught by an external debugger listening in terminal mode
|
|
549
|
+
for the passport's ids, as it is over HTTP. `SADT_REST_RFC_ENDPOINT` reads no
|
|
550
|
+
passport from a header field, so the header is not sent as one. Its value must
|
|
551
|
+
be the passport in hex (non-empty, even length, `0`–`9` / `a`–`f` / `A`–`F`);
|
|
552
|
+
anything else, or the header named twice, is refused before anything is sent,
|
|
553
|
+
the header named and its value never quoted. The passport's structure is
|
|
554
|
+
sap-rfc-lite's to check. A request without the header carries no passport, as
|
|
555
|
+
before: the wire invents, derives and keeps none. Over HTTP the header goes as
|
|
556
|
+
it always went.
|
|
557
|
+
|
|
558
|
+
**A caught session stays caught.** sap-rfc-lite does not reset a stateful
|
|
559
|
+
session: once a listener has caught a call on it, later calls on the same
|
|
560
|
+
session are caught too, with or without a passport, until the session ends.
|
|
561
|
+
The connection does not reset it either — that would drop its locks. A run
|
|
562
|
+
meant to be caught belongs on a non-stateful request (the kept conversation is
|
|
563
|
+
reset after every call), or on a connection of its own.
|
|
564
|
+
|
|
565
|
+
**A failed RFC call names its error by fields** (22.0.0). When the SDK
|
|
566
|
+
reports the failure, the `Error` the caller receives carries it as
|
|
567
|
+
`rfc: { key, group, code, codeString }` (`IRfcErrorInfo`, typed by
|
|
568
|
+
`IAbapConnectionError` in `@mcp-abap-adt/interfaces-adt-connection`;
|
|
569
|
+
`codeString` is one of `RFC_RCS`). Read the failure from those, never from the
|
|
570
|
+
message: a call's failure says `RFC call to SADT_REST_RFC_ENDPOINT failed: …`
|
|
571
|
+
and sets no top-level `code`; when the error ended the stateful conversation,
|
|
572
|
+
the message is the session-lost one and `code` is `ADT_SESSION_REPLACED`
|
|
573
|
+
(below). `rfc` is carried either way, on every conversation. An error the SDK
|
|
574
|
+
did not name — the closed-connection error, a refused passport — carries no
|
|
575
|
+
`rfc`.
|
|
576
|
+
|
|
577
|
+
```typescript
|
|
578
|
+
import type { RfcReturnCodeName } from "@mcp-abap-adt/interfaces-adt-connection";
|
|
579
|
+
|
|
580
|
+
/** The RFC return code a caught value names in `rfc`, or undefined. */
|
|
581
|
+
function rfcCodeOf(error: unknown): string | undefined {
|
|
582
|
+
if (typeof error !== "object" || error === null || !("rfc" in error)) {
|
|
583
|
+
return undefined;
|
|
584
|
+
}
|
|
585
|
+
const { rfc } = error;
|
|
586
|
+
return typeof rfc === "object" && rfc !== null && "codeString" in rfc &&
|
|
587
|
+
typeof rfc.codeString === "string"
|
|
588
|
+
? rfc.codeString
|
|
589
|
+
: undefined;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
try {
|
|
593
|
+
await connection.makeAdtRequest({ url: "/sap/bc/adt/discovery", method: "GET", timeout: 0 });
|
|
594
|
+
} catch (error) {
|
|
595
|
+
const closed: RfcReturnCodeName = "RFC_CLOSED";
|
|
596
|
+
if (rfcCodeOf(error) === closed) {
|
|
597
|
+
// the other side closed the conversation
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
**An RFC error that ends the session ends the instance** (22.0.0). When an RFC
|
|
603
|
+
error ends the stateful conversation — the one that carries the instance's
|
|
604
|
+
session and its locks (sap-rfc-lite releases it: `alive` is `false`) — the
|
|
605
|
+
request rejects with `code` `ADT_SESSION_REPLACED` and the call's `rfc`; the
|
|
606
|
+
instance is spent, and every later request and `connect()` reject
|
|
607
|
+
`ADT_NOT_CONNECTED` with nothing sent. The connection does not open a new
|
|
608
|
+
session on its own: a lock held in the old one is gone and is never presented
|
|
609
|
+
as still held. A new session is a new connection, which only you create.
|
|
610
|
+
(`terminateDebugger` on the debugger's stateful session ends it this way:
|
|
611
|
+
`RFC_CLOSED`.) A non-stateful conversation an RFC error ends carries no session
|
|
612
|
+
of the instance: it is replaced as a reset replaces it, and the request's error
|
|
613
|
+
still carries its `rfc`. A wire of your own says the same with
|
|
614
|
+
`WireSessionLostError`, exported beside `WireLogonError`.
|
|
615
|
+
|
|
518
616
|
**Where to look for it.** An HTTP session is an ICF session and appears in
|
|
519
617
|
**SM05**. An RFC conversation is a gateway client: it appears in **SMGW → Logged
|
|
520
618
|
on Clients** as `NWRFC`, and never in SM05, because there is no ICM in that
|
|
@@ -988,9 +1086,8 @@ own in that language, and every stateful one naming it is refused.
|
|
|
988
1086
|
import { CSRF_CONFIG, CSRF_ERROR_MESSAGES } from '@mcp-abap-adt/connection';
|
|
989
1087
|
|
|
990
1088
|
// CSRF_CONFIG contains:
|
|
991
|
-
// - RETRY_COUNT: number (default: 3)
|
|
992
|
-
// - RETRY_DELAY: number (default: 1000ms)
|
|
993
1089
|
// - ENDPOINT: string (default: '/sap/bc/adt/core/discovery')
|
|
1090
|
+
// - FALLBACK_ENDPOINT: string (default: '/sap/bc/adt/discovery', BASIS < 7.52)
|
|
994
1091
|
// - REQUIRED_HEADERS: { 'x-csrf-token': 'fetch', 'Accept': 'application/atomsvc+xml' }
|
|
995
1092
|
|
|
996
1093
|
// CSRF_ERROR_MESSAGES contains:
|
|
@@ -1010,41 +1107,28 @@ const yourHttpClient = {
|
|
|
1010
1107
|
({ headers: {} as Record<string, string> }),
|
|
1011
1108
|
};
|
|
1012
1109
|
|
|
1110
|
+
// One request, and the fallback endpoint only when the first answers 404 or 501 —
|
|
1111
|
+
// the way this package fetches its own: no retry, no delay. A failed request
|
|
1112
|
+
// is its own error, and the caller decides what to do about it.
|
|
1013
1113
|
async function fetchCsrfToken(baseUrl: string): Promise<string> {
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
}
|
|
1028
|
-
throw new Error(CSRF_ERROR_MESSAGES.NOT_IN_HEADERS);
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
return token;
|
|
1032
|
-
} catch (error) {
|
|
1033
|
-
if (attempt >= CSRF_CONFIG.RETRY_COUNT) {
|
|
1034
|
-
throw new Error(
|
|
1035
|
-
CSRF_ERROR_MESSAGES.FETCH_FAILED(
|
|
1036
|
-
CSRF_CONFIG.RETRY_COUNT + 1,
|
|
1037
|
-
error instanceof Error ? error.message : String(error)
|
|
1038
|
-
)
|
|
1039
|
-
);
|
|
1040
|
-
}
|
|
1041
|
-
await new Promise(resolve => setTimeout(resolve, CSRF_CONFIG.RETRY_DELAY));
|
|
1042
|
-
}
|
|
1114
|
+
let response: { headers: Record<string, string> };
|
|
1115
|
+
try {
|
|
1116
|
+
response = await yourHttpClient.get(`${baseUrl}${CSRF_CONFIG.ENDPOINT}`, {
|
|
1117
|
+
headers: CSRF_CONFIG.REQUIRED_HEADERS,
|
|
1118
|
+
});
|
|
1119
|
+
} catch (error) {
|
|
1120
|
+
const status = (error as { response?: { status?: number } }).response
|
|
1121
|
+
?.status;
|
|
1122
|
+
if (status !== 404 && status !== 501) throw error;
|
|
1123
|
+
response = await yourHttpClient.get(
|
|
1124
|
+
`${baseUrl}${CSRF_CONFIG.FALLBACK_ENDPOINT}`,
|
|
1125
|
+
{ headers: CSRF_CONFIG.REQUIRED_HEADERS },
|
|
1126
|
+
);
|
|
1043
1127
|
}
|
|
1044
1128
|
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1129
|
+
const token = response.headers['x-csrf-token'];
|
|
1130
|
+
if (!token) throw new Error(CSRF_ERROR_MESSAGES.NOT_IN_HEADERS);
|
|
1131
|
+
return token;
|
|
1048
1132
|
}
|
|
1049
1133
|
```
|
|
1050
1134
|
|
|
@@ -464,6 +464,12 @@ declare abstract class AbstractAbapConnection implements AbapConnection, ISessio
|
|
|
464
464
|
* wait for the very request that raised it.
|
|
465
465
|
*/
|
|
466
466
|
protected raiseSessionLost(reason: string): void;
|
|
467
|
+
/**
|
|
468
|
+
* A log line on a failure path: a logger that throws must not replace the
|
|
469
|
+
* failure being reported — a session verdict, the wire's error with its
|
|
470
|
+
* `rfc` — so its throw is dropped. There is nowhere left to say so.
|
|
471
|
+
*/
|
|
472
|
+
private logQuietly;
|
|
467
473
|
/**
|
|
468
474
|
* Whether an error is this connection's own verdict about the session rather
|
|
469
475
|
* than something the server said about a request.
|
|
@@ -632,6 +638,15 @@ declare abstract class AbstractAbapConnection implements AbapConnection, ISessio
|
|
|
632
638
|
* current one, so its answer is not acted on.
|
|
633
639
|
*/
|
|
634
640
|
private throwIfSessionDead;
|
|
641
|
+
/**
|
|
642
|
+
* The wire saying the session it carried has ended — over RFC, an RFC error
|
|
643
|
+
* ended the stateful conversation — is the same verdict: SESSION_REPLACED,
|
|
644
|
+
* the instance spent, the call's `rfc` kept on the error. Acted on by the
|
|
645
|
+
* class of the mark, never by which wire raised it. Nothing opens a new
|
|
646
|
+
* session: that is a new instance, the caller's to create. A mark from a
|
|
647
|
+
* previous session says nothing about the current one and is not acted on.
|
|
648
|
+
*/
|
|
649
|
+
private throwWireSessionLost;
|
|
635
650
|
/**
|
|
636
651
|
* What a request whose lease went stale gets: a session verdict as it is,
|
|
637
652
|
* anything else — the wire's error, the provider's refusal — replaced by
|
|
@@ -681,7 +696,7 @@ declare abstract class AbstractAbapConnection implements AbapConnection, ISessio
|
|
|
681
696
|
* the wire: fencing the answer by generation, and letting the identity policy
|
|
682
697
|
* read what it means.
|
|
683
698
|
*/
|
|
684
|
-
protected fetchCsrfToken(_url: string,
|
|
699
|
+
protected fetchCsrfToken(_url: string,
|
|
685
700
|
/**
|
|
686
701
|
* The request's lease: fences what is sent and the response effects.
|
|
687
702
|
* A plain session generation — what this parameter took before 10.0.1,
|
|
@@ -727,7 +742,7 @@ declare abstract class AbstractAbapConnection implements AbapConnection, ISessio
|
|
|
727
742
|
* written: that is the last await before the wire sends, and a provider may
|
|
728
743
|
* take long enough for the caller to disconnect and connect again — sent
|
|
729
744
|
* then, the request would carry the new session's cookies. The throw is a
|
|
730
|
-
* session verdict, so the exchange stops at once
|
|
745
|
+
* session verdict, so the exchange stops at once.
|
|
731
746
|
*
|
|
732
747
|
* Without one — connect()'s own establishment, which is making the session
|
|
733
748
|
* rather than working in it — nothing is fenced. `generation` alone fences
|
|
@@ -735,12 +750,6 @@ declare abstract class AbstractAbapConnection implements AbapConnection, ISessio
|
|
|
735
750
|
* sent, and the wire still folds the answer into its jar.
|
|
736
751
|
*/
|
|
737
752
|
private leasedContext;
|
|
738
|
-
/**
|
|
739
|
-
* What stops a token exchange at once, past its retries: a session verdict,
|
|
740
|
-
* or the provider's refusal to authorize it — asking again would only ask
|
|
741
|
-
* the provider again.
|
|
742
|
-
*/
|
|
743
|
-
protected endsTheExchange(error: unknown): boolean;
|
|
744
753
|
/**
|
|
745
754
|
* Clear SAP-side session state when SAP rejects the cached CSRF token + session
|
|
746
755
|
* cookies (HTTP 401 on a mutation while a cached token exists). This forces 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,
|
|
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,MA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E,MAAM;IACZ;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,GAChD,OAAO,CAAC,MAAM,CAAC;IAelB,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;IAO7B;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,aAAa;IAgCrB;;;;;;;;OAQG;IACH,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,eAAe;CA6BxB;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -938,15 +938,29 @@ class AbstractAbapConnection {
|
|
|
938
938
|
* wait for the very request that raised it.
|
|
939
939
|
*/
|
|
940
940
|
raiseSessionLost(reason) {
|
|
941
|
-
this.logger?.warn(`Session lost: ${reason}`);
|
|
942
941
|
// The instance's one session is gone: it is spent, as after disconnect().
|
|
943
|
-
// Nothing else is decided here — the caller is told, and decides.
|
|
942
|
+
// Nothing else is decided here — the caller is told, and decides. The
|
|
943
|
+
// verdict first, then the word: a logger that throws cannot undo it.
|
|
944
944
|
this.spent = true;
|
|
945
945
|
this.lifecycle.beginTeardown({ origin: 'internal', sessionLost: true });
|
|
946
946
|
void this.lifecycle.transition('cleanup', async () => {
|
|
947
947
|
this.clearSessionState();
|
|
948
948
|
this.lifecycle.markDisconnected();
|
|
949
949
|
});
|
|
950
|
+
this.logQuietly(() => this.logger?.warn(`Session lost: ${reason}`));
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
953
|
+
* A log line on a failure path: a logger that throws must not replace the
|
|
954
|
+
* failure being reported — a session verdict, the wire's error with its
|
|
955
|
+
* `rfc` — so its throw is dropped. There is nowhere left to say so.
|
|
956
|
+
*/
|
|
957
|
+
logQuietly(write) {
|
|
958
|
+
try {
|
|
959
|
+
write();
|
|
960
|
+
}
|
|
961
|
+
catch {
|
|
962
|
+
// The failure being reported outranks the logger's.
|
|
963
|
+
}
|
|
950
964
|
}
|
|
951
965
|
/**
|
|
952
966
|
* Whether an error is this connection's own verdict about the session rather
|
|
@@ -1363,7 +1377,7 @@ class AbstractAbapConnection {
|
|
|
1363
1377
|
//
|
|
1364
1378
|
// A stale request gets its error back and nothing else happens.
|
|
1365
1379
|
if (!this.lifecycle.isCurrent(lease)) {
|
|
1366
|
-
this.logger?.debug('A request from a previous session failed; its recovery is fenced');
|
|
1380
|
+
this.logQuietly(() => this.logger?.debug('A request from a previous session failed; its recovery is fenced'));
|
|
1367
1381
|
throw error;
|
|
1368
1382
|
}
|
|
1369
1383
|
const errorDetails = {
|
|
@@ -1389,15 +1403,15 @@ class AbstractAbapConnection {
|
|
|
1389
1403
|
// Don't retry for network errors - these indicate infrastructure/VPN issues
|
|
1390
1404
|
const networkError = (0, networkErrors_js_1.isNetworkError)(error);
|
|
1391
1405
|
if (networkError) {
|
|
1392
|
-
this.logger?.error(`Network error - cannot connect to SAP system: ${errorDetails.message}`, errorDetails);
|
|
1406
|
+
this.logQuietly(() => this.logger?.error(`Network error - cannot connect to SAP system: ${errorDetails.message}`, errorDetails));
|
|
1393
1407
|
throw error;
|
|
1394
1408
|
}
|
|
1395
1409
|
// Log 404 as debug (common for existence checks), other errors as error
|
|
1396
1410
|
if (errorDetails.status === 404) {
|
|
1397
|
-
this.logger?.debug(errorDetails.message, errorDetails);
|
|
1411
|
+
this.logQuietly(() => this.logger?.debug(errorDetails.message, errorDetails));
|
|
1398
1412
|
}
|
|
1399
1413
|
else {
|
|
1400
|
-
this.logger?.error(errorDetails.message, errorDetails);
|
|
1414
|
+
this.logQuietly(() => this.logger?.error(errorDetails.message, errorDetails));
|
|
1401
1415
|
}
|
|
1402
1416
|
// No session is discarded and reopened on this instance to retry a
|
|
1403
1417
|
// request: one instance is one session. A 401 on a mutation that holds a
|
|
@@ -1412,7 +1426,7 @@ class AbstractAbapConnection {
|
|
|
1412
1426
|
method: normalizedMethod,
|
|
1413
1427
|
});
|
|
1414
1428
|
try {
|
|
1415
|
-
this.setCsrfToken(await this.fetchCsrfToken(requestUrl,
|
|
1429
|
+
this.setCsrfToken(await this.fetchCsrfToken(requestUrl, lease));
|
|
1416
1430
|
const refreshedToken = this.getCsrfToken();
|
|
1417
1431
|
if (refreshedToken) {
|
|
1418
1432
|
requestHeaders['x-csrf-token'] = refreshedToken;
|
|
@@ -1439,9 +1453,9 @@ class AbstractAbapConnection {
|
|
|
1439
1453
|
if (this.outranksOriginal(retryError)) {
|
|
1440
1454
|
throw retryError;
|
|
1441
1455
|
}
|
|
1442
|
-
this.logger?.debug(`CSRF retry failed; rethrowing original error: ${retryError instanceof Error
|
|
1456
|
+
this.logQuietly(() => this.logger?.debug(`CSRF retry failed; rethrowing original error: ${retryError instanceof Error
|
|
1443
1457
|
? retryError.message
|
|
1444
|
-
: String(retryError)}`);
|
|
1458
|
+
: String(retryError)}`));
|
|
1445
1459
|
throw error;
|
|
1446
1460
|
}
|
|
1447
1461
|
}
|
|
@@ -1523,6 +1537,9 @@ class AbstractAbapConnection {
|
|
|
1523
1537
|
* current one, so its answer is not acted on.
|
|
1524
1538
|
*/
|
|
1525
1539
|
throwIfSessionDead(error, lease) {
|
|
1540
|
+
if (error instanceof authErrors_js_1.WireSessionLostError) {
|
|
1541
|
+
this.throwWireSessionLost(error, lease);
|
|
1542
|
+
}
|
|
1526
1543
|
if (!this.isDeadSessionResponse(error))
|
|
1527
1544
|
return;
|
|
1528
1545
|
if (!this.lifecycle.isCurrent(lease))
|
|
@@ -1532,6 +1549,23 @@ class AbstractAbapConnection {
|
|
|
1532
1549
|
// in the field. The caller decides.
|
|
1533
1550
|
throw (0, SessionLifecycle_js_1.sessionError)(interfaces_adt_connection_1.ADT_SESSION_ERROR.SESSION_REPLACED, 'The SAP session no longer exists; any lock handle from it is dead');
|
|
1534
1551
|
}
|
|
1552
|
+
/**
|
|
1553
|
+
* The wire saying the session it carried has ended — over RFC, an RFC error
|
|
1554
|
+
* ended the stateful conversation — is the same verdict: SESSION_REPLACED,
|
|
1555
|
+
* the instance spent, the call's `rfc` kept on the error. Acted on by the
|
|
1556
|
+
* class of the mark, never by which wire raised it. Nothing opens a new
|
|
1557
|
+
* session: that is a new instance, the caller's to create. A mark from a
|
|
1558
|
+
* previous session says nothing about the current one and is not acted on.
|
|
1559
|
+
*/
|
|
1560
|
+
throwWireSessionLost(error, lease) {
|
|
1561
|
+
if (!this.lifecycle.isCurrent(lease))
|
|
1562
|
+
return;
|
|
1563
|
+
this.raiseSessionLost('the wire reports the session ended');
|
|
1564
|
+
const verdict = (0, SessionLifecycle_js_1.sessionError)(interfaces_adt_connection_1.ADT_SESSION_ERROR.SESSION_REPLACED, "The RFC conversation that carried this connection's SAP session has ended; any lock held in it is gone. Create a new connection for a new session.");
|
|
1565
|
+
throw error.rfc === undefined
|
|
1566
|
+
? verdict
|
|
1567
|
+
: Object.assign(verdict, { rfc: error.rfc });
|
|
1568
|
+
}
|
|
1535
1569
|
/**
|
|
1536
1570
|
* What a request whose lease went stale gets: a session verdict as it is,
|
|
1537
1571
|
* anything else — the wire's error, the provider's refusal — replaced by
|
|
@@ -1636,7 +1670,7 @@ class AbstractAbapConnection {
|
|
|
1636
1670
|
* the wire: fencing the answer by generation, and letting the identity policy
|
|
1637
1671
|
* read what it means.
|
|
1638
1672
|
*/
|
|
1639
|
-
async fetchCsrfToken(_url,
|
|
1673
|
+
async fetchCsrfToken(_url,
|
|
1640
1674
|
/**
|
|
1641
1675
|
* The request's lease: fences what is sent and the response effects.
|
|
1642
1676
|
* A plain session generation — what this parameter took before 10.0.1,
|
|
@@ -1654,9 +1688,6 @@ class AbstractAbapConnection {
|
|
|
1654
1688
|
...(typeof fence === 'number'
|
|
1655
1689
|
? this.leasedContext(undefined, fence)
|
|
1656
1690
|
: this.leasedContext(fence)),
|
|
1657
|
-
retries: retryCount,
|
|
1658
|
-
retryDelayMs: retryDelay,
|
|
1659
|
-
isFatal: (error) => this.endsTheExchange(error),
|
|
1660
1691
|
});
|
|
1661
1692
|
const token = this.transport.csrfToken();
|
|
1662
1693
|
if (!token)
|
|
@@ -1704,10 +1735,7 @@ class AbstractAbapConnection {
|
|
|
1704
1735
|
async ensureWireReady(
|
|
1705
1736
|
/** The request's lease: fences what is sent and the response effects. */
|
|
1706
1737
|
lease) {
|
|
1707
|
-
await this.transport.establish(
|
|
1708
|
-
...this.leasedContext(lease),
|
|
1709
|
-
isFatal: (error) => this.endsTheExchange(error),
|
|
1710
|
-
});
|
|
1738
|
+
await this.transport.establish(this.leasedContext(lease));
|
|
1711
1739
|
}
|
|
1712
1740
|
/**
|
|
1713
1741
|
* The context for a token exchange a request makes on its own behalf — its
|
|
@@ -1718,7 +1746,7 @@ class AbstractAbapConnection {
|
|
|
1718
1746
|
* written: that is the last await before the wire sends, and a provider may
|
|
1719
1747
|
* take long enough for the caller to disconnect and connect again — sent
|
|
1720
1748
|
* then, the request would carry the new session's cookies. The throw is a
|
|
1721
|
-
* session verdict, so the exchange stops at once
|
|
1749
|
+
* session verdict, so the exchange stops at once.
|
|
1722
1750
|
*
|
|
1723
1751
|
* Without one — connect()'s own establishment, which is making the session
|
|
1724
1752
|
* rather than working in it — nothing is fenced. `generation` alone fences
|
|
@@ -1747,14 +1775,6 @@ class AbstractAbapConnection {
|
|
|
1747
1775
|
},
|
|
1748
1776
|
};
|
|
1749
1777
|
}
|
|
1750
|
-
/**
|
|
1751
|
-
* What stops a token exchange at once, past its retries: a session verdict,
|
|
1752
|
-
* or the provider's refusal to authorize it — asking again would only ask
|
|
1753
|
-
* the provider again.
|
|
1754
|
-
*/
|
|
1755
|
-
endsTheExchange(error) {
|
|
1756
|
-
return this.isSessionVerdict(error) || error instanceof authErrors_js_1.AuthRefusedError;
|
|
1757
|
-
}
|
|
1758
1778
|
/**
|
|
1759
1779
|
* Clear SAP-side session state when SAP rejects the cached CSRF token + session
|
|
1760
1780
|
* cookies (HTTP 401 on a mutation while a cached token exists). This forces the
|
|
@@ -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,GAAG,IAAW,EAC7B,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,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AAE,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;CA2ClD"}
|
|
@@ -87,10 +87,7 @@ class CredentialAbapConnection extends AbstractAbapConnection_js_1.AbstractAbapC
|
|
|
87
87
|
// does not need one: the wire authorizes PER ATTEMPT, so a one-shot token
|
|
88
88
|
// is offered on the establishing call and withheld afterwards by the
|
|
89
89
|
// credential itself, with nobody deciding anything.
|
|
90
|
-
await this.transport.establish(
|
|
91
|
-
...this.sessionContext(),
|
|
92
|
-
isFatal: (error) => this.endsTheExchange(error),
|
|
93
|
-
});
|
|
90
|
+
await this.transport.establish(this.sessionContext());
|
|
94
91
|
this.logger?.debug('Connected', {
|
|
95
92
|
credential: this.credential.kind,
|
|
96
93
|
hasCsrfToken: !!this.getCsrfToken(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpTransport.d.ts","sourceRoot":"","sources":["../../src/connection/HttpTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,IAAI,SAAS,EAGlB,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAA2B,MAAM,YAAY,CAAC;AAG/E,OAAO,KAAK,EAGV,YAAY,EACb,MAAM,+BAA+B,CAAC;AACvC,OAAc,EACZ,KAAK,aAAa,EAGnB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAI5C,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAE3B,MAAM,oBAAoB,CA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