@mcp-abap-adt/connection 11.0.0 → 12.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +125 -1
  2. package/README.md +39 -5
  3. package/dist/connection/AbstractAbapConnection.d.ts +7 -2
  4. package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
  5. package/dist/connection/AbstractAbapConnection.js +17 -16
  6. package/dist/connection/CloudHttpTransport.d.ts.map +1 -1
  7. package/dist/connection/CloudHttpTransport.js +3 -0
  8. package/dist/connection/CredentialAbapConnection.d.ts.map +1 -1
  9. package/dist/connection/CredentialAbapConnection.js +4 -4
  10. package/dist/connection/HttpTransport.d.ts +54 -8
  11. package/dist/connection/HttpTransport.d.ts.map +1 -1
  12. package/dist/connection/HttpTransport.js +168 -8
  13. package/dist/connection/OnPremHttpTransport.d.ts.map +1 -1
  14. package/dist/connection/OnPremHttpTransport.js +3 -0
  15. package/dist/connection/RfcTransport.d.ts +1 -1
  16. package/dist/connection/RfcTransport.d.ts.map +1 -1
  17. package/dist/connection/RfcTransport.js +32 -12
  18. package/dist/connection/authErrors.d.ts +20 -7
  19. package/dist/connection/authErrors.d.ts.map +1 -1
  20. package/dist/connection/authErrors.js +50 -19
  21. package/dist/connection/rfcConversation.d.ts.map +1 -1
  22. package/dist/connection/rfcConversation.js +0 -1
  23. package/docs/INDEX.md +3 -1
  24. package/docs/INSTALLATION.md +6 -3
  25. package/docs/MIGRATION-10.0.md +8 -1
  26. package/docs/MIGRATION-12.0.md +159 -0
  27. package/docs/SCOPE.md +2 -1
  28. package/docs/STATEFUL_SESSION_GUIDE.md +2 -1
  29. package/docs/USAGE.md +28 -4
  30. package/examples/README.md +1 -1
  31. package/examples/jwt-with-token-refresh.js +2 -1
  32. package/package.json +6 -5
package/CHANGELOG.md CHANGED
@@ -7,6 +7,128 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [12.0.0] - 2026-10-06
11
+
12
+ ### Breaking
13
+
14
+ - **Refusals follow the authentication error contract.** connection moves to
15
+ `@mcp-abap-adt/interfaces-auth` `^6.0.0` (from `^3.0.0`) and
16
+ `@mcp-abap-adt/interfaces-auth-sap` `^3.2.0` (from `^2.0.0`), and depends on
17
+ `@mcp-abap-adt/auth-errors` `^1.0.0`. A refusal is now an
18
+ `IAuthProviderError`: a deep-frozen object with a `kind`, `facts` from
19
+ closed allowlists, and `reason` / `hint` rendered from them, minted only by
20
+ `auth-errors`. See [MIGRATION-12.0.md](./docs/MIGRATION-12.0.md).
21
+ - **`AuthRefusedError.refusal` is an `IAuthProviderError`.** Decide on
22
+ `refusal.kind` and `refusal.facts`. `reason`, `hint`, `at`, `cause` and the
23
+ `reason — hint` message are unchanged.
24
+ - **The constructor classifies the refusal it is given.**
25
+ - A refusal minted by this copy of `auth-errors` is kept as the same object.
26
+ - A `structuredClone`, or a refusal from another copy, is rebuilt from its
27
+ kind and facts, with its words rendered anew and no diagnostics.
28
+ - Anything else is `provider-threw` at `at`.
29
+ - Text written into a clone's `reason`, `hint` or `diagnostics` therefore
30
+ reaches neither `refusal` nor `message`.
31
+ - **A custom `ILogonTarget` builds its refusal through `auth-errors`**
32
+ (`authError['logon-target']({ wire, refused })`). An object literal no
33
+ longer compiles. A custom `IAuthProvider` answers minted refusals too.
34
+ - **The providers of `@mcp-abap-adt/auth-providers` 5.x do not fit
35
+ interfaces-auth 6.0.0's `IAuthProvider`.** Use auth-providers 6.0.0 when it
36
+ is published.
37
+
38
+ ### Changed
39
+
40
+ - connection's own refusals keep their words and gain a kind:
41
+ - the RFC wire's `this wire carries no TLS material (RFC)` is `logon-target`
42
+ `{ wire: 'rfc', refused: 'tls-material' }`
43
+ - the HTTP wire's `this wire takes no logon parameters (HTTP)` is
44
+ `logon-target` `{ wire: 'http', refused: 'logon-parameters' }`
45
+ - `the credential provider failed` is `connection` `provider-threw`
46
+ - `the credential was refused again after the provider renewed it` is
47
+ `connection` `refused-after-renewal`
48
+ - `this connection has no credential to renew` is `connection`
49
+ `no-credential`
50
+ - `facts.at` of the first two `connection` refusals is the moment of the
51
+ error that carries them
52
+ - **The connection re-checks every provider answer** with `classifyOutcome`:
53
+ - a refusal minted by the same `auth-errors` passes as the same object
54
+ - one from another copy is rebuilt from its kind and facts
55
+ - anything else (a plain `{ reason }` from a JavaScript provider, a
56
+ non-outcome) is `provider-threw`, and its text reaches no message
57
+ - **11.0.1 exported none of the refusal constants from its index.** Only
58
+ `AuthRefusedError`, `AuthRefusalMoment` and `WireLogonError` were exported,
59
+ and all three are unchanged. There is no `exports` map, so a deep import of
60
+ `dist/connection/authErrors.js` was possible. Such an import loses
61
+ `PROVIDER_FAILED` and `REFUSED_AGAIN`, which are now internal
62
+ `providerFailed(at)` / `refusedAgain(at)`; `NO_CREDENTIAL_TO_RENEW` is a
63
+ minted error; and `guarded(call, at)` takes the moment.
64
+ - `lint:check` also runs the contract's shape check
65
+ (`tools/check-provider-shape.mjs --rules 4,5,6`, a byte-identical copy of
66
+ the one `auth-errors` publishes): no type assertion to a contract type, no
67
+ spread of an error, no diagnostics outside a listed site.
68
+
69
+ ### Unchanged
70
+
71
+ - The lifecycle, the one credential retry per request, `WireLogonError`, and
72
+ 11.0.1's guard against a request naming another SAP client.
73
+
74
+ ### Development
75
+
76
+ - auth-providers 6.0.0 is not published yet, so the tests keep the
77
+ devDependency `@mcp-abap-adt/auth-providers` `^5.2.0`.
78
+ - They run its providers through a test-only adapter
79
+ (`src/__tests__/helpers/legacyProvider.ts`, never shipped). A closed table
80
+ translates each 5.x refusal the suites produce to its builder call, and a
81
+ test that meets any other 5.x refusal fails.
82
+ - Until the move to auth-providers 6.0.0, the dev tree holds a second,
83
+ nested `@mcp-abap-adt/interfaces-auth` 3.2.0 under auth-providers 5.2.0.
84
+ The production tree holds only 6.0.0.
85
+ - **Lint warnings are errors now.** `lint:check` runs Biome with
86
+ `--error-on-warnings`, and the tests are checked for unused imports and
87
+ variables too. The 25 warnings it had are gone, each fixed rather than
88
+ silenced:
89
+ - Unused suppressions, imports and two dead test helpers are removed.
90
+ - The session id `disconnect()` captured for a release record removed long
91
+ ago is removed.
92
+ - The RFC transport reads `SADT_REST_RFC_ENDPOINT`'s answer field by field
93
+ with type checks instead of as `any`.
94
+ - One suppression stays, explained: `makeAdtRequest<T = any, D = any>`
95
+ mirrors `IAbapConnection` in `@mcp-abap-adt/interfaces-adt-connection`,
96
+ whose defaults change there first.
97
+
98
+ ## [11.0.1] - 2026-10-06
99
+
100
+ ### Fixed
101
+
102
+ - **The SAP client is addressed from the first request on.** An HTTP wire
103
+ given a `client` applied it only through the `sap-usercontext` cookie, which
104
+ it held only once a response had set one — so the first request, the one
105
+ that opens the session and earns the CSRF token, always landed in the
106
+ system's DEFAULT client, and a wrong client failed one request late. Every
107
+ request of `OnPremHttpTransport`, `LegacyOnPremHttpTransport` and
108
+ `CloudHttpTransport` now carries the `sap-client` header and the
109
+ `sap-usercontext=sap-client=<n>` cookie, the establishing call, the cloud
110
+ session preflight and the goodbye included. Measured on an on-prem system:
111
+ with client `999` the first request is now refused (`401`); before, it
112
+ answered `200` from the default client.
113
+
114
+ ### Changed
115
+
116
+ - **`X-SAP-Client` is no longer sent**, and `getAuthHeaders()` no longer
117
+ returns it: ABAP ignores that header (`X-SAP-Client: 999` answers `200` from
118
+ the default client; `sap-client: 999` answers `401`). The client is the
119
+ wire's to address — `sap-client` over HTTP, the logon over RFC. A consumer
120
+ that put `config.client` on the connection but not on the transport was
121
+ never addressing the client over HTTP; pass it to the transport's `client`
122
+ option.
123
+ - **A request cannot name another client.** A `sap-client` header, query
124
+ parameter, `params` entry or `sap-usercontext` cookie, in any case, that differs from the transport's `client` — or
125
+ names one when the transport was given none — is refused with an error
126
+ before anything is sent; naming the same client passes, and the header goes
127
+ out once. Another client is another logon (its own user, password, session
128
+ and CSRF token), so it is another connection: sending it would have landed
129
+ the request in that client with this one's session cookie and credential.
130
+ Over RFC the client is fixed by the logon and nothing changes.
131
+
10
132
  ## [11.0.0] - 2026-10-04
11
133
 
12
134
  ### Breaking
@@ -2138,7 +2260,9 @@ const connection = createAbapConnection(config, logger);
2138
2260
  - JWT token refresh now properly handles connection errors (401/403 during initial connect)
2139
2261
  - Permission errors (403 with "ExceptionResourceNoAccess") no longer trigger JWT refresh loops
2140
2262
  - Proper separation: base class handles HTTP/session, concrete classes handle auth-specific errors
2141
- [Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/v11.0.0...HEAD
2263
+ [Unreleased]: https://github.com/fr0ster/mcp-abap-connection/compare/v12.0.0...HEAD
2264
+ [12.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v11.0.1...v12.0.0
2265
+ [11.0.1]: https://github.com/fr0ster/mcp-abap-connection/compare/v11.0.0...v11.0.1
2142
2266
  [11.0.0]: https://github.com/fr0ster/mcp-abap-connection/compare/v10.0.3...v11.0.0
2143
2267
  [10.0.3]: https://github.com/fr0ster/mcp-abap-connection/compare/v10.0.2...v10.0.3
2144
2268
  [10.0.2]: https://github.com/fr0ster/mcp-abap-connection/compare/v10.0.1...v10.0.2
package/README.md CHANGED
@@ -66,7 +66,12 @@ The package uses a clean separation of concerns:
66
66
  - A `401` that survives the wire's own session recovery, or a refused logon, is
67
67
  put to the provider through `rejected`. If it answers Ok (a renewed token, say)
68
68
  the request gets exactly one more attempt; if it says no, or the retry is
69
- refused too, you get an `AuthRefusedError` carrying the provider's own words
69
+ refused too, you get an `AuthRefusedError` carrying the provider's refusal —
70
+ an `IAuthProviderError` minted by `@mcp-abap-adt/auth-errors`, with a `kind`
71
+ to decide on and the `reason` / `hint` words to show
72
+ - Every answer is re-checked: a refusal that is not a minted error (a plain
73
+ `{ reason }` from a JavaScript provider) becomes "the credential provider
74
+ failed" (`connection` / `provider-threw`), and its text reaches no message
70
75
 
71
76
  - **Transports** (`OnPremHttpTransport`, `CloudHttpTransport`, `RfcTransport`):
72
77
  - What a request travels over, and everything that is true of that wire.
@@ -133,16 +138,18 @@ This package interacts with external packages **ONLY through interfaces**:
133
138
  - **Logger interface**: Uses `ILogger` interface for logging - does not know about concrete logger implementation
134
139
  - **No direct dependencies on auth packages**: All token-related operations are handled through configuration (`SapConfig`) passed by consumers
135
140
 
136
- The contracts themselves come from five packages, and are the only runtime
141
+ The contracts themselves come from five packages, and with `@mcp-abap-adt/auth-errors`
142
+ — the runtime that mints and classifies the auth errors — are the only runtime
137
143
  dependencies of this one besides `axios`, `commander` and `open`:
138
144
 
139
145
  | Package | What this package takes from it |
140
146
  |---|---|
141
147
  | `@mcp-abap-adt/interfaces-adt-connection` | `IAbapConnection`, `IAbapRequestOptions`, `IAdtWireResponse`, `ITimeoutConfig`, the capability atoms, `ADT_SESSION_ERROR` |
142
- | `@mcp-abap-adt/interfaces-auth` | `IAuthProvider`, `AuthOutcome`, `IAuthRefusal`, `IAuthRejection`, `ILogonTarget`, `IRequestTarget`, `ICertificateMaterial`, `ITokenRefresher`, `ITokenRefreshResult` |
148
+ | `@mcp-abap-adt/interfaces-auth` (6.x) | `IAuthProvider`, `AuthOutcome`, `IAuthRefusal` (= `IAuthProviderError`), `IAuthRejection`, `ILogonTarget`, `IRequestTarget`, `ICertificateMaterial`, `ITokenRefresher`, `ITokenRefreshResult` |
143
149
  | `@mcp-abap-adt/interfaces-auth-sap` | `ISapConfig`, `SapAuthType`, `SapConnectionType`, `ICertificateMaterialLoader` |
144
150
  | `@mcp-abap-adt/interfaces-network` | `NETWORK_ERROR_CODES`, the WebSocket contracts |
145
151
  | `@mcp-abap-adt/interfaces-utils` | `ILogger` |
152
+ | `@mcp-abap-adt/auth-errors` | `authError` (the builders: every refusal is minted here), `classifyOutcome` |
146
153
 
147
154
  Not `@mcp-abap-adt/interfaces`. That package is **deleted** as of its 52.0.0,
148
155
  which was never published: npm still serves 51.0.0 — every symbol re-exported and
@@ -154,6 +161,7 @@ the packages above. See [Migration to 9.0.0](./docs/MIGRATION-9.0.md).
154
161
 
155
162
  - 📦 **[Installation Guide](./docs/INSTALLATION.md)** - Setup and installation instructions
156
163
  - 📚 **[Usage Guide](./docs/USAGE.md)** - Detailed usage examples and API documentation
164
+ - 🚚 **[Migration to 12.0.0](./docs/MIGRATION-12.0.md)** - refusals follow the auth error contract (interfaces-auth 6, auth-errors): `AuthRefusedError.refusal` is an `IAuthProviderError` — read its `kind`; a custom `ILogonTarget` mints its refusal; needs auth-providers 6.0.0
157
165
  - 🚚 **[Migration to 11.0.0](./docs/MIGRATION-11.0.md)** - the server certificate is verified by default; trust a self-signed system with `agentOptions.ca`, or opt out explicitly
158
166
  - 🚚 **[Migration to 10.0.0](./docs/MIGRATION-10.0.md)** - the credential providers moved to `@mcp-abap-adt/auth-providers`; the connection speaks `IAuthProvider` 3.0; `AuthRefusedError`; the RFC factory takes the logon parameters
159
167
  - 🚚 **[Migration to 9.0.0](./docs/MIGRATION-9.0.md)** - the contracts split out of `@mcp-abap-adt/interfaces`; which package each one moved to
@@ -187,6 +195,11 @@ longer brings them along:
187
195
  npm install @mcp-abap-adt/interfaces-adt-connection @mcp-abap-adt/interfaces-auth @mcp-abap-adt/interfaces-auth-sap
188
196
  ```
189
197
 
198
+ A provider or a logon target of your own answers refusals minted by
199
+ `@mcp-abap-adt/auth-errors` (`authError[kind](facts)`); install it too. Keep one
200
+ `@mcp-abap-adt/interfaces-auth` major in the process (`npm ls
201
+ @mcp-abap-adt/interfaces-auth`).
202
+
190
203
  The credential providers (`BasicAuthProvider`, `TokenAuthProvider`,
191
204
  `SamlAuthProvider`, `CertificateAuthProvider`) are not part of this package
192
205
  since 10.0.0. Install them from where they live:
@@ -195,6 +208,10 @@ since 10.0.0. Install them from where they live:
195
208
  npm install @mcp-abap-adt/auth-providers
196
209
  ```
197
210
 
211
+ connection 12.x speaks interfaces-auth 6, so it needs auth-providers **6.0.0 or
212
+ later**: the 5.x providers answer unbranded refusals and do not fit. See
213
+ [Migration to 12.0.0](./docs/MIGRATION-12.0.md).
214
+
198
215
  For detailed installation instructions, see [Installation Guide](./docs/INSTALLATION.md).
199
216
 
200
217
  ## Quick Start
@@ -247,6 +264,18 @@ const response = await connection.makeAdtRequest({
247
264
  });
248
265
  ```
249
266
 
267
+ **The client is the wire's.** The transport's `client` option is what addresses
268
+ the SAP client (mandant): an HTTP wire sends it as the `sap-client` header and
269
+ the `sap-usercontext=sap-client=<n>` cookie on every request, the first one —
270
+ which opens the session and earns the CSRF token — included. `config.client`
271
+ alone does not reach the system over HTTP; pass the same value to the
272
+ transport, as above. `X-SAP-Client` is not sent: ABAP ignores it. A request
273
+ cannot name another client: a `sap-client` header, query parameter, `params`
274
+ entry or `sap-usercontext` cookie (in any case) that differs from the connection's — or names one when the connection was
275
+ given none — is refused before anything is sent. Another client is another
276
+ logon, with its own user, password, session and CSRF token, so it is another
277
+ connection.
278
+
250
279
  ### Cloud Usage (JWT/OAuth2)
251
280
 
252
281
  ```typescript
@@ -457,8 +486,10 @@ See [MIGRATION-4.0.md](./docs/MIGRATION-4.0.md).
457
486
  Every request asks the provider first (`authorize`). A `401` that survives the
458
487
  wire's own session recovery, or a logon the system refused, is put to the
459
488
  provider (`rejected`); on Ok the request is sent once more, otherwise it fails
460
- with an `AuthRefusedError` carrying the provider's own words. A `403` is never
461
- put to the provider.
489
+ with an `AuthRefusedError` carrying the provider's refusal. A `403` is never
490
+ put to the provider. The refusal is an `IAuthProviderError`: decide on its
491
+ `kind` and `facts`; `reason` and `hint` are the words to show, and the error's
492
+ message is `reason — hint`. It is frozen — relay it, never copy it.
462
493
 
463
494
  ```typescript
464
495
  import { AuthRefusedError } from "@mcp-abap-adt/connection";
@@ -467,6 +498,9 @@ try {
467
498
  await connection.connect();
468
499
  } catch (error) {
469
500
  if (error instanceof AuthRefusedError) {
501
+ if (error.refusal.kind === "credential-refused") {
502
+ // the credential itself was refused: renew it, or ask the user
503
+ }
470
504
  console.error(error.refusal.reason, error.refusal.hint, error.at);
471
505
  }
472
506
  throw error;
@@ -426,8 +426,13 @@ declare abstract class AbstractAbapConnection implements AbapConnection, ISessio
426
426
  getBaseUrl(): Promise<string>;
427
427
  getAuthHeaders(): Promise<Record<string, string>>;
428
428
  /**
429
- * What every request carries: the client, then whatever the credential
430
- * writes. On every path, the establishing call included.
429
+ * What every request carries from the credential. On every path, the
430
+ * establishing call included.
431
+ *
432
+ * Not the client. It used to be written here as `X-SAP-Client`, a header
433
+ * ABAP ignores; the client is the wire's to address — the HTTP wire with the
434
+ * `sap-client` header and the `sap-usercontext` cookie, the RFC wire at its
435
+ * logon — because how a system is told its client is a fact about the wire.
431
436
  */
432
437
  protected credentialHeaders(headers: Record<string, string>): Promise<void>;
433
438
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractAbapConnection.d.ts","sourceRoot":"","sources":["../../src/connection/AbstractAbapConnection.ts"],"names":[],"mappings":"AAEA,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;AAMvC,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;AAgD5B,uBAAe,sBACb,YACE,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB;IAuGjB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,SA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of authErrors_js_1.WireLogonError))
325
325
  throw again;
326
- throw new authErrors_js_1.AuthRefusedError(authErrors_js_1.REFUSED_AGAIN, 'logon', again.cause);
326
+ throw new authErrors_js_1.AuthRefusedError((0, authErrors_js_1.refusedAgain)('logon'), 'logon', again.cause);
327
327
  }
328
328
  }
329
329
  });
@@ -371,11 +371,6 @@ class AbstractAbapConnection {
371
371
  // anything is queued, so a caller who has asked to disconnect cannot have
372
372
  // requests still going through while this waits its turn.
373
373
  this.lifecycle.beginTeardown({ origin: 'caller', sessionLost: false });
374
- // Captured before the transition and before anything is cleared: a
375
- // concurrent disconnect JOINS the transition and its callback is never run
376
- // for the joiner, so a joiner would otherwise learn nothing about what it
377
- // asked to release.
378
- const session = this.getSessionIdentity();
379
374
  await this.lifecycle.transition('disconnect', async () => {
380
375
  // DISPATCHED, not awaited. The goodbye carries no request timeout by
381
376
  // design — a server that never answers must not hold a teardown open —
@@ -811,13 +806,15 @@ class AbstractAbapConnection {
811
806
  return headers;
812
807
  }
813
808
  /**
814
- * What every request carries: the client, then whatever the credential
815
- * writes. On every path, the establishing call included.
809
+ * What every request carries from the credential. On every path, the
810
+ * establishing call included.
811
+ *
812
+ * Not the client. It used to be written here as `X-SAP-Client`, a header
813
+ * ABAP ignores; the client is the wire's to address — the HTTP wire with the
814
+ * `sap-client` header and the `sap-usercontext` cookie, the RFC wire at its
815
+ * logon — because how a system is told its client is a fact about the wire.
816
816
  */
817
817
  async credentialHeaders(headers) {
818
- if (this.config.client) {
819
- headers['X-SAP-Client'] = this.config.client;
820
- }
821
818
  await this.authorizeRequest(headers);
822
819
  }
823
820
  /**
@@ -840,6 +837,10 @@ class AbstractAbapConnection {
840
837
  async credentialRejected(_rejection) {
841
838
  return { outcome: { ok: false, refusal: authErrors_js_1.NO_CREDENTIAL_TO_RENEW } };
842
839
  }
840
+ // The defaults are IAbapConnection's (interfaces-adt-connection), which this
841
+ // implements: changing them here alone would type every caller's response
842
+ // differently from the contract it codes against. They change there first.
843
+ // biome-ignore lint/suspicious/noExplicitAny: mirrors IAbapConnection.makeAdtRequest
843
844
  async makeAdtRequest(options) {
844
845
  // Admission first, synchronously, before any await: the check and the
845
846
  // count must happen in one step, or a request could be admitted and still
@@ -876,7 +877,7 @@ class AbstractAbapConnection {
876
877
  // The request's own headers: everything but the credential's, which is
877
878
  // written fresh onto a copy of these for every attempt (`authorizedFrom`).
878
879
  const requestHeaders = {};
879
- if (!customHeaders || !customHeaders.Accept) {
880
+ if (!customHeaders?.Accept) {
880
881
  requestHeaders.Accept =
881
882
  'application/xml, application/json, text/plain, */*';
882
883
  }
@@ -1286,10 +1287,10 @@ class AbstractAbapConnection {
1286
1287
  this.observeResponse(refusal.headers, lease.generation);
1287
1288
  }
1288
1289
  this.throwIfSessionDead(again, lease);
1289
- const refusedAgain = this.credentialRejection(again);
1290
- if (!refusedAgain)
1290
+ const secondRejection = this.credentialRejection(again);
1291
+ if (!secondRejection)
1291
1292
  throw again;
1292
- throw new authErrors_js_1.AuthRefusedError(authErrors_js_1.REFUSED_AGAIN, refusedAgain.at, refusedAgain.error);
1293
+ throw new authErrors_js_1.AuthRefusedError((0, authErrors_js_1.refusedAgain)(secondRejection.at), secondRejection.at, secondRejection.error);
1293
1294
  }
1294
1295
  }
1295
1296
  /**
@@ -1336,7 +1337,7 @@ class AbstractAbapConnection {
1336
1337
  */
1337
1338
  async renewCredential(rejection, renewal) {
1338
1339
  if (renewal.spent) {
1339
- throw new authErrors_js_1.AuthRefusedError(authErrors_js_1.REFUSED_AGAIN, rejection.at, rejection.error);
1340
+ throw new authErrors_js_1.AuthRefusedError((0, authErrors_js_1.refusedAgain)(rejection.at), rejection.at, rejection.error);
1340
1341
  }
1341
1342
  renewal.spent = true;
1342
1343
  const answer = await this.credentialRejected(rejection);
@@ -1 +1 @@
1
- {"version":3,"file":"CloudHttpTransport.d.ts","sourceRoot":"","sources":["../../src/connection/CloudHttpTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;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AAC;IAgDhE;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;CAW5B"}
@@ -135,6 +135,9 @@ class CloudHttpTransport extends HttpTransport_js_1.HttpTransport {
135
135
  url: new URL(resource, context.baseUrl).toString(),
136
136
  headers: {
137
137
  ...affinity,
138
+ // Detached, so not dressed: the client is said here in so many
139
+ // words, as on every other request of this wire.
140
+ ...this.clientHeaders(),
138
141
  ...auth,
139
142
  ...context.extraHeaders,
140
143
  Cookie: (0, cookies_js_1.mergeCookieHeaders)(auth.Cookie, cookies),
@@ -1 +1 @@
1
- {"version":3,"file":"CredentialAbapConnection.d.ts","sourceRoot":"","sources":["../../src/connection/CredentialAbapConnection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,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;IAKpB;;;;;;;;;;OAUG;cACsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAO3D;;;;;;;OAOG;cACsB,gBAAgB,CACvC,OAAO,EAA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IAAI,CAAC;IAYhB,6EAA6E;cACpD,KAAK,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAUnE;;;OAGG;cACsB,kBAAkB,CACzC,SAAS,EAAE,cAAc,GACxB,OAAO,CAAC,aAAa,CAAC;cAIT,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;CA+ClD"}
@@ -38,7 +38,7 @@ class CredentialAbapConnection extends AbstractAbapConnection_js_1.AbstractAbapC
38
38
  * unhandled rejection.
39
39
  */
40
40
  async prepareCredential() {
41
- const { outcome, thrown } = await (0, authErrors_js_1.guarded)(() => this.credential.prepare());
41
+ const { outcome, thrown } = await (0, authErrors_js_1.guarded)(() => this.credential.prepare(), 'prepare');
42
42
  if (!outcome.ok) {
43
43
  throw new authErrors_js_1.AuthRefusedError(outcome.refusal, 'prepare', thrown);
44
44
  }
@@ -54,14 +54,14 @@ class CredentialAbapConnection extends AbstractAbapConnection_js_1.AbstractAbapC
54
54
  async authorizeRequest(headers) {
55
55
  // Asked per request, never held: a provider renews behind this call, and a
56
56
  // value kept here would be the stale one.
57
- const { outcome, thrown } = await (0, authErrors_js_1.guarded)(() => this.credential.authorize((0, requestTarget_js_1.requestTargetOn)(headers)));
57
+ const { outcome, thrown } = await (0, authErrors_js_1.guarded)(() => this.credential.authorize((0, requestTarget_js_1.requestTargetOn)(headers)), 'request');
58
58
  if (!outcome.ok) {
59
59
  throw new authErrors_js_1.AuthRefusedError(outcome.refusal, 'request', thrown);
60
60
  }
61
61
  }
62
62
  /** What the credential brings to a logon: TLS material, logon parameters. */
63
63
  async logon(target) {
64
- const { outcome, thrown } = await (0, authErrors_js_1.guarded)(() => this.credential.establish(target));
64
+ const { outcome, thrown } = await (0, authErrors_js_1.guarded)(() => this.credential.establish(target), 'logon');
65
65
  if (!outcome.ok) {
66
66
  throw new authErrors_js_1.AuthRefusedError(outcome.refusal, 'logon', thrown);
67
67
  }
@@ -71,7 +71,7 @@ class CredentialAbapConnection extends AbstractAbapConnection_js_1.AbstractAbapC
71
71
  * is kept beside it to become the cause of the refusal.
72
72
  */
73
73
  async credentialRejected(rejection) {
74
- return (0, authErrors_js_1.guarded)(() => this.credential.rejected(rejection));
74
+ return (0, authErrors_js_1.guarded)(() => this.credential.rejected(rejection), rejection.at);
75
75
  }
76
76
  async establishSession() {
77
77
  try {
@@ -27,10 +27,10 @@ export declare class HttpTransport implements IAdtTransport {
27
27
  private readonly agentOptions;
28
28
  protected readonly logger: ILogger | null;
29
29
  /**
30
- * `client` because SAP answers `sap-usercontext` with the system default
31
- * rather than the client that was asked for, and later requests then route
32
- * to a client the caller never named — on a read-only one, every write
33
- * comes back 403.
30
+ * The SAP client (mandant) every request on this wire addresses, from the
31
+ * first one on: the establishing call is where the session and its CSRF
32
+ * token are issued, so a client applied any later is applied to a session
33
+ * that already lives in another one. See `clientHeaders()`.
34
34
  */
35
35
  private readonly options;
36
36
  /**
@@ -66,10 +66,10 @@ export declare class HttpTransport implements IAdtTransport {
66
66
  private token;
67
67
  constructor(agentOptions?: () => AgentOptions, logger?: ILogger | null,
68
68
  /**
69
- * `client` because SAP answers `sap-usercontext` with the system default
70
- * rather than the client that was asked for, and later requests then route
71
- * to a client the caller never named — on a read-only one, every write
72
- * comes back 403.
69
+ * The SAP client (mandant) every request on this wire addresses, from the
70
+ * first one on: the establishing call is where the session and its CSRF
71
+ * token are issued, so a client applied any later is applied to a session
72
+ * that already lives in another one. See `clientHeaders()`.
73
73
  */
74
74
  options?: {
75
75
  client?: string;
@@ -109,6 +109,33 @@ export declare class HttpTransport implements IAdtTransport {
109
109
  * server is going down, send us elsewhere rather than fail.
110
110
  */
111
111
  affinityHeaders(): Record<string, string>;
112
+ /**
113
+ * The client, said the way ABAP hears it: the `sap-client` header.
114
+ *
115
+ * ICF takes the client from the `sap-client` header or query parameter, or
116
+ * from the `sap-usercontext` cookie — and NOT from `X-SAP-Client`, which it
117
+ * ignores. Measured against an on-prem system (client 100 the default),
118
+ * plain curl with basic auth on `/sap/bc/adt/core/discovery`:
119
+ * `X-SAP-Client: 999` answers 200 from client 100, `sap-client: 999` answers
120
+ * 401. Before this, the client reached the system only through the cookie,
121
+ * which the wire holds from the first response on — so the first request,
122
+ * the one that opens the session and earns the CSRF token, always landed in
123
+ * the default client, and a wrong client failed one request late.
124
+ *
125
+ * The header rather than the query parameter: it addresses the client
126
+ * without rewriting a URL the caller built, and it rides on the detached
127
+ * goodbye the same way it rides on everything else.
128
+ */
129
+ protected clientHeaders(): Record<string, string>;
130
+ /**
131
+ * The `sap-usercontext` cookie the client is asserted with, from the first
132
+ * request on — before any response could have set one.
133
+ *
134
+ * Added when a request is dressed rather than put in the jar: the jar is
135
+ * what the server issued, and a jar that held something before the first
136
+ * answer would read as a connection that holds a session.
137
+ */
138
+ private clientCookie;
112
139
  /**
113
140
  * What this wire says about the session it is already in, on every request.
114
141
  *
@@ -157,6 +184,17 @@ export declare class HttpTransport implements IAdtTransport {
157
184
  * `LegacyOnPremHttpTransport`).
158
185
  */
159
186
  protected sessionTypeHeaders(): Record<string, string>;
187
+ /**
188
+ * The client belongs to the connection. Another client is another logon —
189
+ * its own user and password, its own session and CSRF token — so a caller
190
+ * that names one in a `sap-client` header, query string or `params` entry, in
191
+ * any case, or in a `sap-usercontext` cookie, is refused before anything is sent: sending it would land the request in
192
+ * that client with the session and credential of this one. Naming the
193
+ * connection's own client is harmless and passes.
194
+ */
195
+ private refuseAnotherClient;
196
+ /** The client the jar's `sap-usercontext` names, as the system set it. */
197
+ private jarClient;
160
198
  /** A path becomes an address; anything already absolute is left alone. */
161
199
  private address;
162
200
  /**
@@ -193,6 +231,14 @@ export declare class HttpTransport implements IAdtTransport {
193
231
  * to add it.
194
232
  */
195
233
  send(request: IAdtTransportRequest): Promise<IAdtTransportResponse>;
234
+ /**
235
+ * The request read once, into plain values: what the client guard checks is
236
+ * then exactly what goes out. The headers are copied, and the URL and
237
+ * `params` are serialised here, once, by axios — the dispatch sends that URL
238
+ * and no `params`, so nothing the caller handed over is read a second time
239
+ * (a getter that answers differently on its second read changes nothing).
240
+ */
241
+ private fix;
196
242
  /**
197
243
  * Send EXACTLY these headers, with nothing of the wire's live state mixed in.
198
244
  *
@@ -1 +1 @@
1
- {"version":3,"file":"HttpTransport.d.ts","sourceRoot":"","sources":["../../src/connection/HttpTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAS,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAGV,YAAY,EACb,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAI5C,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAE3B,MAAM,oBAAoB,CAAC;AAuC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AA6DzD,qBAAa,aAAc,YAAW,aAAa;IAsC/C,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IACzC;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,CAAC,OAAO;IA7C1B;;;;;;;;;OASG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAU;IAE/B,OAAO,CAAC,QAAQ,CAA8B;IAE9C;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAqC;IAErD,iFAAiF;IACjF,OAAO,CAAC,cAAc,CAAS;IAE/B;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA6B;IACjD,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,KAAK,CAAuB;gBAGjB,YAAY,GAAE,MAAM,YAAyB,EAC3C,MAAM,GAAE,OAAO,GAAG,IAAW;IAChD;;;;;OAKG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