@mcp-abap-adt/connection 9.4.1 → 10.0.1

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 (58) hide show
  1. package/CHANGELOG.md +187 -1
  2. package/README.md +80 -38
  3. package/dist/connection/AbstractAbapConnection.d.ts +211 -56
  4. package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
  5. package/dist/connection/AbstractAbapConnection.js +622 -255
  6. package/dist/connection/CloudHttpTransport.d.ts.map +1 -1
  7. package/dist/connection/CloudHttpTransport.js +15 -5
  8. package/dist/connection/CredentialAbapConnection.d.ts +21 -20
  9. package/dist/connection/CredentialAbapConnection.d.ts.map +1 -1
  10. package/dist/connection/CredentialAbapConnection.js +39 -46
  11. package/dist/connection/HttpTransport.d.ts +30 -14
  12. package/dist/connection/HttpTransport.d.ts.map +1 -1
  13. package/dist/connection/HttpTransport.js +99 -19
  14. package/dist/connection/IAdtTransport.d.ts +19 -2
  15. package/dist/connection/IAdtTransport.d.ts.map +1 -1
  16. package/dist/connection/OnPremHttpTransport.d.ts.map +1 -1
  17. package/dist/connection/OnPremHttpTransport.js +4 -3
  18. package/dist/connection/RfcTransport.d.ts +23 -3
  19. package/dist/connection/RfcTransport.d.ts.map +1 -1
  20. package/dist/connection/RfcTransport.js +48 -15
  21. package/dist/connection/authErrors.d.ts +61 -0
  22. package/dist/connection/authErrors.d.ts.map +1 -0
  23. package/dist/connection/authErrors.js +78 -0
  24. package/dist/connection/requestTarget.d.ts +12 -0
  25. package/dist/connection/requestTarget.d.ts.map +1 -0
  26. package/dist/connection/requestTarget.js +23 -0
  27. package/dist/connection/rfcConversation.d.ts +10 -5
  28. package/dist/connection/rfcConversation.d.ts.map +1 -1
  29. package/dist/connection/rfcConversation.js +6 -8
  30. package/dist/index.d.ts +1 -2
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +4 -12
  33. package/dist/session/SessionLifecycle.d.ts +1 -1
  34. package/dist/session/SessionLifecycle.d.ts.map +1 -1
  35. package/docs/INDEX.md +4 -1
  36. package/docs/INSTALLATION.md +12 -5
  37. package/docs/JWT_AUTH_TOOLS.md +2 -2
  38. package/docs/MIGRATION-10.0.md +284 -0
  39. package/docs/SCOPE.md +2 -2
  40. package/docs/STATEFUL_SESSION_GUIDE.md +34 -13
  41. package/docs/USAGE.md +118 -35
  42. package/examples/README.md +5 -4
  43. package/examples/basic-connection.js +1 -1
  44. package/examples/jwt-with-token-refresh.js +14 -15
  45. package/examples/saml-connection.js +1 -1
  46. package/package.json +5 -4
  47. package/dist/auth/FileCertificateMaterialLoader.d.ts +0 -6
  48. package/dist/auth/FileCertificateMaterialLoader.d.ts.map +0 -1
  49. package/dist/auth/FileCertificateMaterialLoader.js +0 -28
  50. package/dist/auth/ntlm.d.ts +0 -26
  51. package/dist/auth/ntlm.d.ts.map +0 -1
  52. package/dist/auth/ntlm.js +0 -72
  53. package/dist/auth/providers.d.ts +0 -125
  54. package/dist/auth/providers.d.ts.map +0 -1
  55. package/dist/auth/providers.js +0 -183
  56. package/dist/utils/tokenRefresh.d.ts +0 -15
  57. package/dist/utils/tokenRefresh.d.ts.map +0 -1
  58. package/dist/utils/tokenRefresh.js +0 -55
@@ -41,7 +41,7 @@
41
41
  * would disagree the first time one of them was cleared.
42
42
  */
43
43
  import type { ILogger } from '../logger.js';
44
- import type { IAdtEstablishContext, IAdtTransportRequest, IAdtTransportResponse, IOnPremTransport } from './IAdtTransport.js';
44
+ import type { IAdtEstablishContext, IAdtSessionContext, IAdtTransportRequest, IAdtTransportResponse, IOnPremTransport } from './IAdtTransport.js';
45
45
  /** The slice of the native client this needs, so the SDK is not a hard dependency. */
46
46
  export interface IRfcConversation {
47
47
  open(): Promise<void>;
@@ -102,6 +102,12 @@ export declare class RfcTransport implements IOnPremTransport {
102
102
  private canReset;
103
103
  /** Names the conversation, and so the ABAP session it carries. */
104
104
  private conversationId;
105
+ /**
106
+ * Where each logon asks the provider what to open with. Kept from `open()`;
107
+ * `null` when the wire is driven without a lifecycle, and then a conversation
108
+ * opens with the address alone.
109
+ */
110
+ private context;
105
111
  /**
106
112
  * Nothing to fold in. `SADT_REST_RFC_ENDPOINT` answers with two header
107
113
  * fields — `~server_protocol` and `content-type` — on every call, including
@@ -147,10 +153,10 @@ export declare class RfcTransport implements IOnPremTransport {
147
153
  * that reached for it in its constructor could not be built at all on a
148
154
  * machine without it.
149
155
  */
150
- constructor(connect: () => IRfcConversation, logger?: ILogger | null, options?: IRfcTransportOptions);
156
+ constructor(connect: (logon: Readonly<Record<string, string>>) => IRfcConversation, logger?: ILogger | null, options?: IRfcTransportOptions);
151
157
  /** Cut a body down to what a log line may carry. */
152
158
  private clipped;
153
- open(): Promise<void>;
159
+ open(context?: IAdtSessionContext): Promise<void>;
154
160
  /** Never throws, and a repeat call finds nothing owed. */
155
161
  close(): Promise<void>;
156
162
  send(request: IAdtTransportRequest): Promise<IAdtTransportResponse>;
@@ -178,6 +184,20 @@ export declare class RfcTransport implements IOnPremTransport {
178
184
  * sent — not a PUT, not a DELETE — on a wire already given back.
179
185
  */
180
186
  private openOwn;
187
+ /**
188
+ * The target a provider writes its logon into.
189
+ *
190
+ * Parameters accumulate over the calls of one logon and go into this open
191
+ * alone. TLS material is refused: there is no TLS to configure on this wire,
192
+ * and whether that matters is the provider's call.
193
+ */
194
+ private logonTarget;
195
+ /**
196
+ * A new conversation, logged on: the provider is asked what to open with,
197
+ * every time, and a failed open is a refused logon whose cause is the SDK's
198
+ * own error, untouched — a provider reads its `key` and message.
199
+ */
200
+ private loggedOn;
181
201
  private closeQuietly;
182
202
  private carry;
183
203
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RfcTransport.d.ts","sourceRoot":"","sources":["../../src/connection/RfcTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAA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,OAAO,CAAC,IAAI,CAAC;IAE9D,+BAA+B;IAC/B,SAAS,IAAI,IAAI;IAIjB;;;OAGG;IACH,cAAc,IAAI,IAAI;IAEtB;;;OAGG;IACH,6EAA6E;IAC7E,kBAAkB,IAAI,OAAO;IAI7B,kBAAkB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAQzC,2EAA2E;IAC3E,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIzC;;;;OAIG;IACH,aAAa,IAAI,IAAI;IAErB;;;;;OAKG;gBAEgB,OAAO,EAAE,CACxB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KACpC,gBAAgB,EACJ,MAAM,GAAE,OAAO,GAAG,IAAW,EAC7B,OAAO,GAAE,oBAAyB;IAGrD,oDAAoD;IACpD,OAAO,CAAC,OAAO;IAcT,IAAI,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBvD,0DAA0D;IACpD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAwBtB,IAAI,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAezE;;;;;;;;;;;;;OAaG;YACW,aAAa;YAUb,WAAW;IAqDzB,uEAAuE;YACzD,gBAAgB;IAa9B;;;;OAIG;YACW,OAAO;IAWrB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAanB;;;;OAIG;YACW,QAAQ;YAYR,YAAY;YAQZ,KAAK;CAyKpB"}
@@ -44,6 +44,7 @@
44
44
  Object.defineProperty(exports, "__esModule", { value: true });
45
45
  exports.RfcTransport = void 0;
46
46
  const node_crypto_1 = require("node:crypto");
47
+ const authErrors_js_1 = require("./authErrors.js");
47
48
  const statefulRequest_js_1 = require("./statefulRequest.js");
48
49
  /**
49
50
  * ADT exception types, mapped to what they would have been over HTTP. Standard
@@ -141,6 +142,12 @@ class RfcTransport {
141
142
  canReset;
142
143
  /** Names the conversation, and so the ABAP session it carries. */
143
144
  conversationId = '';
145
+ /**
146
+ * Where each logon asks the provider what to open with. Kept from `open()`;
147
+ * `null` when the wire is driven without a lifecycle, and then a conversation
148
+ * opens with the address alone.
149
+ */
150
+ context = null;
144
151
  /**
145
152
  * Nothing to fold in. `SADT_REST_RFC_ENDPOINT` answers with two header
146
153
  * fields — `~server_protocol` and `content-type` — on every call, including
@@ -217,17 +224,13 @@ class RfcTransport {
217
224
  const ceiling = asked >= 0 ? Math.floor(asked) : DEFAULT_MAX_LOGGED_BODY_CHARS;
218
225
  return clip(text, ceiling);
219
226
  }
220
- async open() {
227
+ async open(context) {
228
+ if (context)
229
+ this.context = context;
221
230
  if (this.conversation?.alive)
222
231
  return;
223
232
  const generation = this.generation;
224
- const conversation = this.connect();
225
- try {
226
- await conversation.open();
227
- }
228
- catch (e) {
229
- throw new Error(`Failed to open RFC connection: ${message(e)}`);
230
- }
233
+ const conversation = await this.loggedOn();
231
234
  // close() ran while this logged on: the session it would have handed out
232
235
  // belongs to a wire already given back, so it is closed, not kept.
233
236
  if (generation !== this.generation) {
@@ -368,19 +371,49 @@ class RfcTransport {
368
371
  * sent — not a PUT, not a DELETE — on a wire already given back.
369
372
  */
370
373
  async openOwn(generation) {
371
- const own = this.connect();
372
- try {
373
- await own.open();
374
- }
375
- catch (e) {
376
- throw new Error(`Failed to open RFC connection: ${message(e)}`);
377
- }
374
+ const own = await this.loggedOn();
378
375
  if (generation !== this.generation || !this.conversation?.alive) {
379
376
  await this.closeQuietly(own);
380
377
  throw new Error('RFC transport was closed while the call was being opened; nothing was sent.');
381
378
  }
382
379
  return own;
383
380
  }
381
+ /**
382
+ * The target a provider writes its logon into.
383
+ *
384
+ * Parameters accumulate over the calls of one logon and go into this open
385
+ * alone. TLS material is refused: there is no TLS to configure on this wire,
386
+ * and whether that matters is the provider's call.
387
+ */
388
+ logonTarget(parameters) {
389
+ return {
390
+ tlsMaterial: () => ({
391
+ ok: false,
392
+ refusal: { reason: 'this wire carries no TLS material (RFC)' },
393
+ }),
394
+ logonParameters: (written) => {
395
+ Object.assign(parameters, written);
396
+ return { ok: true };
397
+ },
398
+ };
399
+ }
400
+ /**
401
+ * A new conversation, logged on: the provider is asked what to open with,
402
+ * every time, and a failed open is a refused logon whose cause is the SDK's
403
+ * own error, untouched — a provider reads its `key` and message.
404
+ */
405
+ async loggedOn() {
406
+ const parameters = {};
407
+ await this.context?.logon(this.logonTarget(parameters));
408
+ const conversation = this.connect(parameters);
409
+ try {
410
+ await conversation.open();
411
+ }
412
+ catch (e) {
413
+ throw new authErrors_js_1.WireLogonError(e);
414
+ }
415
+ return conversation;
416
+ }
384
417
  async closeQuietly(conversation) {
385
418
  try {
386
419
  await conversation.close();
@@ -0,0 +1,61 @@
1
+ /**
2
+ * What the connection raises when the credential says no, and the mark a wire
3
+ * puts on a failure that is a refused logon.
4
+ */
5
+ import type { AuthOutcome, IAuthRefusal } from '@mcp-abap-adt/interfaces-auth';
6
+ /** When in the connection's life the credential refused. */
7
+ export type AuthRefusalMoment = 'prepare' | 'logon' | 'request';
8
+ /**
9
+ * The credential said no, or the system refused it and the provider's answer
10
+ * is final.
11
+ *
12
+ * `refusal` is the provider's own words; `cause` keeps the wire's error as it
13
+ * arrived, so a network failure stays visible even when a provider words it as
14
+ * a credential problem — unless the provider threw instead of answering, when
15
+ * it is that throw.
16
+ */
17
+ export declare class AuthRefusedError extends Error {
18
+ readonly refusal: IAuthRefusal;
19
+ readonly at: AuthRefusalMoment;
20
+ readonly cause?: unknown;
21
+ constructor(refusal: IAuthRefusal, at: AuthRefusalMoment, cause?: unknown);
22
+ }
23
+ /**
24
+ * A wire's mark: this failure is a refused logon. It decides nothing — what to
25
+ * do about it is the provider's answer, not the wire's.
26
+ *
27
+ * Exported so a consumer's own wire can say the same thing. `cause` is the raw
28
+ * error, the same object, never re-wrapped.
29
+ */
30
+ export declare class WireLogonError extends Error {
31
+ readonly status?: number;
32
+ readonly cause: unknown;
33
+ constructor(cause: unknown, status?: number);
34
+ }
35
+ /** A provider threw instead of answering: a bug in the provider, not an answer. */
36
+ export declare const PROVIDER_FAILED: IAuthRefusal;
37
+ /**
38
+ * The provider said Ok to a rejection and the retry was refused too. The one
39
+ * refusal the connection words itself, because the provider's last word was Ok.
40
+ */
41
+ export declare const REFUSED_AGAIN: IAuthRefusal;
42
+ /** A connection built without a credential has nothing to renew. */
43
+ export declare const NO_CREDENTIAL_TO_RENEW: IAuthRefusal;
44
+ /**
45
+ * A provider's answer, and what it threw when the answer is a throw. `thrown`
46
+ * is present only then, so a provider that threw `undefined` is still told
47
+ * apart from one that answered.
48
+ */
49
+ export interface GuardedAnswer {
50
+ outcome: AuthOutcome;
51
+ thrown?: unknown;
52
+ }
53
+ /**
54
+ * Run one provider call so that a throw is an answer too.
55
+ *
56
+ * A consumer's provider may be buggy; the connection must not let that surface
57
+ * as an unhandled rejection. The throw is kept beside the outcome, to become
58
+ * the cause of whatever the caller then raises.
59
+ */
60
+ export declare function guarded(call: () => Promise<AuthOutcome>): Promise<GuardedAnswer>;
61
+ //# sourceMappingURL=authErrors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authErrors.d.ts","sourceRoot":"","sources":["../../src/connection/authErrors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE/E,4DAA4D;AAC5D,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAEhE;;;;;;;;GAQG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,EAAE,EAAE,iBAAiB,CAAC;IAC/B,SAAkB,KAAK,CAAC,EAAE,OAAO,CAAC;gBAEtB,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,OAAO;CAS1E;AAED;;;;;;GAMG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,SAAkB,KAAK,EAAE,OAAO,CAAC;gBAErB,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM;CAM5C;AAED,mFAAmF;AACnF,eAAO,MAAM,eAAe,EAAE,YAE7B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,YAE3B,CAAC;AAEF,oEAAoE;AACpE,eAAO,MAAM,sBAAsB,EAAE,YAEpC,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAsB,OAAO,CAC3B,IAAI,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,GAC/B,OAAO,CAAC,aAAa,CAAC,CAMxB"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ /**
3
+ * What the connection raises when the credential says no, and the mark a wire
4
+ * puts on a failure that is a refused logon.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.NO_CREDENTIAL_TO_RENEW = exports.REFUSED_AGAIN = exports.PROVIDER_FAILED = exports.WireLogonError = exports.AuthRefusedError = void 0;
8
+ exports.guarded = guarded;
9
+ /**
10
+ * The credential said no, or the system refused it and the provider's answer
11
+ * is final.
12
+ *
13
+ * `refusal` is the provider's own words; `cause` keeps the wire's error as it
14
+ * arrived, so a network failure stays visible even when a provider words it as
15
+ * a credential problem — unless the provider threw instead of answering, when
16
+ * it is that throw.
17
+ */
18
+ class AuthRefusedError extends Error {
19
+ refusal;
20
+ at;
21
+ cause;
22
+ constructor(refusal, at, cause) {
23
+ super(refusal.hint ? `${refusal.reason} — ${refusal.hint}` : refusal.reason);
24
+ this.name = 'AuthRefusedError';
25
+ this.refusal = refusal;
26
+ this.at = at;
27
+ this.cause = cause;
28
+ }
29
+ }
30
+ exports.AuthRefusedError = AuthRefusedError;
31
+ /**
32
+ * A wire's mark: this failure is a refused logon. It decides nothing — what to
33
+ * do about it is the provider's answer, not the wire's.
34
+ *
35
+ * Exported so a consumer's own wire can say the same thing. `cause` is the raw
36
+ * error, the same object, never re-wrapped.
37
+ */
38
+ class WireLogonError extends Error {
39
+ status;
40
+ cause;
41
+ constructor(cause, status) {
42
+ super(cause instanceof Error ? cause.message : String(cause));
43
+ this.name = 'WireLogonError';
44
+ this.cause = cause;
45
+ this.status = status;
46
+ }
47
+ }
48
+ exports.WireLogonError = WireLogonError;
49
+ /** A provider threw instead of answering: a bug in the provider, not an answer. */
50
+ exports.PROVIDER_FAILED = {
51
+ reason: 'the credential provider failed',
52
+ };
53
+ /**
54
+ * The provider said Ok to a rejection and the retry was refused too. The one
55
+ * refusal the connection words itself, because the provider's last word was Ok.
56
+ */
57
+ exports.REFUSED_AGAIN = {
58
+ reason: 'the credential was refused again after the provider renewed it',
59
+ };
60
+ /** A connection built without a credential has nothing to renew. */
61
+ exports.NO_CREDENTIAL_TO_RENEW = {
62
+ reason: 'this connection has no credential to renew',
63
+ };
64
+ /**
65
+ * Run one provider call so that a throw is an answer too.
66
+ *
67
+ * A consumer's provider may be buggy; the connection must not let that surface
68
+ * as an unhandled rejection. The throw is kept beside the outcome, to become
69
+ * the cause of whatever the caller then raises.
70
+ */
71
+ async function guarded(call) {
72
+ try {
73
+ return { outcome: await call() };
74
+ }
75
+ catch (thrown) {
76
+ return { outcome: { ok: false, refusal: exports.PROVIDER_FAILED }, thrown };
77
+ }
78
+ }
@@ -0,0 +1,12 @@
1
+ import type { IRequestTarget } from '@mcp-abap-adt/interfaces-auth';
2
+ /**
3
+ * The request target every wire shares: it writes into the headers the request
4
+ * is about to carry.
5
+ *
6
+ * The wires already put request headers where they go — HTTP merges `Cookie`
7
+ * with its jar, RFC forwards every header as an endpoint header field — so no
8
+ * wire needs a target of its own. A cookie the credential names wins over one
9
+ * already on the request, as `mergeCookieHeaders` orders it.
10
+ */
11
+ export declare function requestTargetOn(headers: Record<string, string>): IRequestTarget;
12
+ //# sourceMappingURL=requestTarget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestTarget.d.ts","sourceRoot":"","sources":["../../src/connection/requestTarget.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAGpE;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,cAAc,CAShB"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.requestTargetOn = requestTargetOn;
4
+ const cookies_js_1 = require("../utils/cookies.js");
5
+ /**
6
+ * The request target every wire shares: it writes into the headers the request
7
+ * is about to carry.
8
+ *
9
+ * The wires already put request headers where they go — HTTP merges `Cookie`
10
+ * with its jar, RFC forwards every header as an endpoint header field — so no
11
+ * wire needs a target of its own. A cookie the credential names wins over one
12
+ * already on the request, as `mergeCookieHeaders` orders it.
13
+ */
14
+ function requestTargetOn(headers) {
15
+ return {
16
+ header(name, value) {
17
+ headers[name] = value;
18
+ },
19
+ cookies(value) {
20
+ headers.Cookie = (0, cookies_js_1.mergeCookieHeaders)(headers.Cookie, value);
21
+ },
22
+ };
23
+ }
@@ -14,13 +14,15 @@
14
14
  */
15
15
  import type { SapConfig } from '../config/sapConfig.js';
16
16
  import type { IRfcConversation } from './RfcTransport.js';
17
- /** What the native client is constructed with. */
17
+ /**
18
+ * Where the native client dials. What it logs on with is not here: the
19
+ * provider writes that at each logon (`user`/`passwd`, or the SNC keys), and
20
+ * the factory spreads it over these.
21
+ */
18
22
  export interface RfcConnectionParams {
19
23
  ashost: string;
20
24
  sysnr: string;
21
25
  client: string;
22
- user: string;
23
- passwd: string;
24
26
  lang: string;
25
27
  }
26
28
  /**
@@ -30,15 +32,18 @@ export interface RfcConnectionParams {
30
32
  * the ICM port for system XX — the convention the port itself follows, not a
31
33
  * guess about the deployment. `SAP_SYSNR` overrides it for a port that follows
32
34
  * no convention, which is the case on a system reached through 50400.
35
+ *
36
+ * The address only: no username or password is read from the config.
33
37
  */
34
38
  export declare function rfcParamsFrom(config: SapConfig): RfcConnectionParams;
35
39
  /**
36
- * The factory `RfcTransport` asks for.
40
+ * The factory `RfcTransport` asks for: the logon parameters the provider wrote
41
+ * for this open go in, spread over the address from the config.
37
42
  *
38
43
  * The SDK is loaded when a conversation is opened, not when this is called, so
39
44
  * a consumer can build the transport on a machine that has no SDK and find out
40
45
  * at `connect()` rather than at construction — with a message that says what to
41
46
  * install.
42
47
  */
43
- export declare function rfcConversationFrom(config: SapConfig): () => IRfcConversation;
48
+ export declare function rfcConversationFrom(config: SapConfig): (logon: Readonly<Record<string, string>>) => IRfcConversation;
44
49
  //# sourceMappingURL=rfcConversation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rfcConversation.d.ts","sourceRoot":"","sources":["../../src/connection/rfcConversation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,kDAAkD;AAClD,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,mBAAmB,CAoBpE;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,gBAAgB,CAmB7E"}
1
+ {"version":3,"file":"rfcConversation.d.ts","sourceRoot":"","sources":["../../src/connection/rfcConversation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,mBAAmB,CAepE;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,GAChB,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KAAK,gBAAgB,CAqB/D"}
@@ -23,14 +23,13 @@ exports.rfcConversationFrom = rfcConversationFrom;
23
23
  * the ICM port for system XX — the convention the port itself follows, not a
24
24
  * guess about the deployment. `SAP_SYSNR` overrides it for a port that follows
25
25
  * no convention, which is the case on a system reached through 50400.
26
+ *
27
+ * The address only: no username or password is read from the config.
26
28
  */
27
29
  function rfcParamsFrom(config) {
28
30
  if (!config.url) {
29
31
  throw new Error('An RFC conversation needs a url to take its host from');
30
32
  }
31
- if (!config.username || !config.password) {
32
- throw new Error('An RFC conversation needs both a username and a password');
33
- }
34
33
  const parsed = new URL(config.url);
35
34
  const port = Number.parseInt(parsed.port || '8000', 10);
36
35
  const derived = String(port - 8000).padStart(2, '0');
@@ -38,13 +37,12 @@ function rfcParamsFrom(config) {
38
37
  ashost: parsed.hostname,
39
38
  sysnr: process.env.SAP_SYSNR?.trim() || derived,
40
39
  client: config.client || '000',
41
- user: config.username,
42
- passwd: config.password,
43
40
  lang: 'EN',
44
41
  };
45
42
  }
46
43
  /**
47
- * The factory `RfcTransport` asks for.
44
+ * The factory `RfcTransport` asks for: the logon parameters the provider wrote
45
+ * for this open go in, spread over the address from the config.
48
46
  *
49
47
  * The SDK is loaded when a conversation is opened, not when this is called, so
50
48
  * a consumer can build the transport on a machine that has no SDK and find out
@@ -53,7 +51,7 @@ function rfcParamsFrom(config) {
53
51
  */
54
52
  function rfcConversationFrom(config) {
55
53
  const params = rfcParamsFrom(config);
56
- return () => {
54
+ return (logon) => {
57
55
  let Client;
58
56
  try {
59
57
  // Dynamic, because the SDK is an optional peer: it needs the SAP NW RFC
@@ -66,6 +64,6 @@ function rfcConversationFrom(config) {
66
64
  'install the SAP NW RFC SDK and run: npm install @mcp-abap-adt/sap-rfc-lite. ' +
67
65
  `Details: ${error instanceof Error ? error.message : String(error)}`);
68
66
  }
69
- return new Client(params);
67
+ return new Client({ ...params, ...logon });
70
68
  };
71
69
  }
package/dist/index.d.ts CHANGED
@@ -1,11 +1,10 @@
1
1
  export type { IWebSocketCloseInfo, IWebSocketConnectOptions, IWebSocketMessageEnvelope, IWebSocketMessageHandler, IWebSocketTransport, } from '@mcp-abap-adt/interfaces-network';
2
- export { FileCertificateMaterialLoader } from './auth/FileCertificateMaterialLoader.js';
3
- export { BasicAuthProvider, CertificateAuthProvider, SamlAuthProvider, TokenAuthProvider, } from './auth/providers.js';
4
2
  export type { SapAuthType, SapConfig, SapConnectionType, } from './config/sapConfig.js';
5
3
  export { sapConfigSignature } from './config/sapConfig.js';
6
4
  export type { AbapConnection, AbapRequestOptions, } from './connection/AbapConnection.js';
7
5
  export { AdtCloudConnector } from './connection/AdtCloudConnector.js';
8
6
  export { AdtOnPremConnector } from './connection/AdtOnPremConnector.js';
7
+ export { type AuthRefusalMoment, AuthRefusedError, WireLogonError, } from './connection/authErrors.js';
9
8
  export { CloudHttpTransport } from './connection/CloudHttpTransport.js';
10
9
  export { CSRF_CONFIG, CSRF_ERROR_MESSAGES } from './connection/csrfConfig.js';
11
10
  export { GenericWebSocketTransport, type IWebSocketFactory, type IWebSocketLike, } from './connection/GenericWebSocketTransport.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EACV,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AAKxF,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,WAAW,EACX,SAAS,EACT,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,YAAY,EACV,cAAc,EACd,kBAAkB,GACnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAQxE,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EACL,yBAAyB,EACzB,KAAK,iBAAiB,EACtB,KAAK,cAAc,GACpB,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,YAAY,EACV,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,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AM,+BAA+B,CAAC;AACvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,YAAY,GACb,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACL,KAAK,mBAAmB,EACxB,mBAAmB,EACnB,aAAa,GACd,MAAM,iCAAiC,CAAC;AACzC,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,KAAK,aAAa,GACnB,MAAM,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -2,18 +2,7 @@
2
2
  // Types - re-exported from the contract packages, under the names this
3
3
  // package has always published them by.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.getTimeoutConfig = exports.getTimeout = exports.rfcParamsFrom = exports.rfcConversationFrom = exports.RfcTransport = exports.OnPremHttpTransport = exports.LegacyOnPremHttpTransport = exports.HttpTransport = exports.GenericWebSocketTransport = exports.CSRF_ERROR_MESSAGES = exports.CSRF_CONFIG = exports.CloudHttpTransport = exports.AdtOnPremConnector = exports.AdtCloudConnector = exports.sapConfigSignature = exports.TokenAuthProvider = exports.SamlAuthProvider = exports.CertificateAuthProvider = exports.BasicAuthProvider = exports.FileCertificateMaterialLoader = void 0;
6
- var FileCertificateMaterialLoader_js_1 = require("./auth/FileCertificateMaterialLoader.js");
7
- Object.defineProperty(exports, "FileCertificateMaterialLoader", { enumerable: true, get: function () { return FileCertificateMaterialLoader_js_1.FileCertificateMaterialLoader; } });
8
- // IAuthProvider is deliberately NOT re-exported. It lives in
9
- // @mcp-abap-adt/interfaces-auth and a consumer imports it from there — the same rule
10
- // the session-lifecycle vocabulary follows below, and for the same reason: two
11
- // names for one contract let the two drift.
12
- var providers_js_1 = require("./auth/providers.js");
13
- Object.defineProperty(exports, "BasicAuthProvider", { enumerable: true, get: function () { return providers_js_1.BasicAuthProvider; } });
14
- Object.defineProperty(exports, "CertificateAuthProvider", { enumerable: true, get: function () { return providers_js_1.CertificateAuthProvider; } });
15
- Object.defineProperty(exports, "SamlAuthProvider", { enumerable: true, get: function () { return providers_js_1.SamlAuthProvider; } });
16
- Object.defineProperty(exports, "TokenAuthProvider", { enumerable: true, get: function () { return providers_js_1.TokenAuthProvider; } });
5
+ exports.getTimeoutConfig = exports.getTimeout = exports.rfcParamsFrom = exports.rfcConversationFrom = exports.RfcTransport = exports.OnPremHttpTransport = exports.LegacyOnPremHttpTransport = exports.HttpTransport = exports.GenericWebSocketTransport = exports.CSRF_ERROR_MESSAGES = exports.CSRF_CONFIG = exports.CloudHttpTransport = exports.WireLogonError = exports.AuthRefusedError = exports.AdtOnPremConnector = exports.AdtCloudConnector = exports.sapConfigSignature = void 0;
17
6
  // Config utilities
18
7
  var sapConfig_js_1 = require("./config/sapConfig.js");
19
8
  Object.defineProperty(exports, "sapConfigSignature", { enumerable: true, get: function () { return sapConfig_js_1.sapConfigSignature; } });
@@ -21,6 +10,9 @@ var AdtCloudConnector_js_1 = require("./connection/AdtCloudConnector.js");
21
10
  Object.defineProperty(exports, "AdtCloudConnector", { enumerable: true, get: function () { return AdtCloudConnector_js_1.AdtCloudConnector; } });
22
11
  var AdtOnPremConnector_js_1 = require("./connection/AdtOnPremConnector.js");
23
12
  Object.defineProperty(exports, "AdtOnPremConnector", { enumerable: true, get: function () { return AdtOnPremConnector_js_1.AdtOnPremConnector; } });
13
+ var authErrors_js_1 = require("./connection/authErrors.js");
14
+ Object.defineProperty(exports, "AuthRefusedError", { enumerable: true, get: function () { return authErrors_js_1.AuthRefusedError; } });
15
+ Object.defineProperty(exports, "WireLogonError", { enumerable: true, get: function () { return authErrors_js_1.WireLogonError; } });
24
16
  var CloudHttpTransport_js_1 = require("./connection/CloudHttpTransport.js");
25
17
  Object.defineProperty(exports, "CloudHttpTransport", { enumerable: true, get: function () { return CloudHttpTransport_js_1.CloudHttpTransport; } });
26
18
  // The session lifecycle vocabulary — ISessionLifecycleAware, ADT_SESSION_ERROR —
@@ -26,7 +26,7 @@
26
26
  * an unchanged one says nothing about whether the server still has it.
27
27
  */
28
28
  import type { AdtSessionErrorCode } from '@mcp-abap-adt/interfaces-adt-connection';
29
- export type TransitionKind = 'connect' | 'disconnect' | 'recover' | 'cleanup';
29
+ export type TransitionKind = 'connect' | 'disconnect' | 'cleanup';
30
30
  export interface RequestLease {
31
31
  /** Teardown epoch at admission — the baseline a recovery compares against. */
32
32
  readonly epoch: number;
@@ -1 +1 @@
1
- {"version":3,"file":"SessionLifecycle.d.ts","sourceRoot":"","sources":["../../src/session/SessionLifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAGnF,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,GAAG,SAAS,CAAC;AAE9E,MAAM,WAAW,YAAY;IAC3B,8EAA8E;IAC9E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,yDAAyD;IACzD,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,0FAA0F;IAC1F,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC9B,iFAAiF;IACjF,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,mBAAmB,EACzB,OAAO,CAAC,EAAE,MAAM,GACf,KAAK,GAAG;IAAE,IAAI,EAAE,mBAAmB,CAAA;CAAE,CAMvC;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,KAAK,CAAgD;IAC7D,OAAO,CAAC,WAAW,CAA6B;IAChD,OAAO,CAAC,KAAK,CAAK;IAClB,OAA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AW,CAAC,MAAM,EAAE,MAAM,CAAa,GAAG,IAAI;IAOzE;;;;;;OAMG;IACH,cAAc,IAAI,IAAI;IAItB,gBAAgB,IAAI,IAAI;IAKxB;;;;;;OAMG;IACH,OAAO,CACL,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACvC,WAAW,GAAG,aAAa,GAAG,UAAU;IAiB3C,YAAY,IAAI,IAAI;IAMpB,4EAA4E;IAC5E,YAAY,IAAI,YAAY;IAiB5B,2FAA2F;IAC3F,IAAI,gBAAgB,IAAI,MAAM,CAE7B;IAED;;;;;;;OAOG;IACH,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,GAAG,OAAO;IAM3D,aAAa,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,oBAAoB,GAAG,IAAI;IAelE,IAAI,iBAAiB,IAAI,OAAO,CAE/B;IAID;;;;;;;;;OASG;IACH,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAuBvE"}
package/docs/INDEX.md CHANGED
@@ -15,6 +15,7 @@ mcp-abap-connection/
15
15
  │ ├── INSTALLATION.md # Setup and installation guide
16
16
  │ ├── USAGE.md # API documentation and examples
17
17
  │ ├── MIGRATION-2.0.md # Moving to the explicit session lifecycle
18
+ │ ├── MIGRATION-10.0.md # providers move to auth-providers; IAuthProvider 3.0; AuthRefusedError
18
19
  │ ├── MIGRATION-9.0.md # the contracts split out of @mcp-abap-adt/interfaces
19
20
  │ ├── MIGRATION-8.0.md # request headers leave the stateful branch; onto interfaces 39; flushGoodbye
20
21
  │ ├── MIGRATION-6.0.md # the factory and the per-credential classes go; RFC is a transport
@@ -46,6 +47,7 @@ mcp-abap-connection/
46
47
  - 🔑 [JWT Auth Tools](./JWT_AUTH_TOOLS.md) - CLI tool for browser-based authentication
47
48
 
48
49
  ### Upgrading
50
+ - 🚚 [Migrating to 10.0.0](./MIGRATION-10.0.md) - the credential providers moved to `@mcp-abap-adt/auth-providers`; the connection speaks `IAuthProvider` 3.0 and raises `AuthRefusedError`; the RFC factory takes the logon parameters
49
51
  - 🚚 [Migrating to 9.0.0](./MIGRATION-9.0.md) - the contracts split into `interfaces-adt`, `-auth`, `-network` and `-utils`, and this package stopped depending on the umbrella; `interfaces-auth-sap` joined them in the release after, when authentication split into what is SAP's and what is not
50
52
  - 🚚 [Migrating to 7.0.0 and 8.0.0](./MIGRATION-8.0.md) - `sap-adt-request-id` and `X-sap-adt-profiling` on every request, `x-sap-security-session: use` on cloud, the contracts floor at 39, and `flushGoodbye()`
51
53
  - 🚚 [Migrating to 6.0.0](./MIGRATION-6.0.md) - the factory and the per-credential classes are removed; the RFC wire is a transport you hand to the on-prem connector
@@ -79,7 +81,8 @@ mcp-abap-connection/
79
81
  - **Connection Interface**: [USAGE.md - API Reference](./USAGE.md#api-reference)
80
82
  - **Configuration Types**: [USAGE.md - Configuration Types](./USAGE.md#configuration-types)
81
83
  - **Connectors**: `AdtOnPremConnector`, `AdtCloudConnector`
82
- - **Credentials**: `BasicAuthProvider`, `TokenAuthProvider`, `SamlAuthProvider`, `CertificateAuthProvider`
84
+ - **Credentials**: an `IAuthProvider` (`@mcp-abap-adt/interfaces-auth`); the ready-made providers live in `@mcp-abap-adt/auth-providers`
85
+ - **Errors**: `AuthRefusedError`, `WireLogonError`
83
86
  - **Transports**: `HttpTransport`, `RfcTransport` (+ `rfcConversationFrom()`)
84
87
 
85
88
  ## Version Highlights
@@ -83,7 +83,8 @@ In your code:
83
83
 
84
84
  ```typescript
85
85
  import 'dotenv/config'; // or require('dotenv').config();
86
- import { AdtOnPremConnector, BasicAuthProvider } from '@mcp-abap-adt/connection';
86
+ import { AdtOnPremConnector } from '@mcp-abap-adt/connection';
87
+ import { BasicAuthProvider } from '@mcp-abap-adt/auth-providers';
87
88
 
88
89
  const config = {
89
90
  url: process.env.SAP_URL!,
@@ -146,7 +147,8 @@ node -e "const { AdtOnPremConnector } = require('@mcp-abap-adt/connection'); con
146
147
  Create `test-connection.js`:
147
148
 
148
149
  ```javascript
149
- const { AdtOnPremConnector, BasicAuthProvider } = require('@mcp-abap-adt/connection');
150
+ const { AdtOnPremConnector, OnPremHttpTransport } = require('@mcp-abap-adt/connection');
151
+ const { BasicAuthProvider } = require('@mcp-abap-adt/auth-providers');
150
152
 
151
153
  const config = {
152
154
  url: 'https://your-sap-server.com',
@@ -165,7 +167,7 @@ const logger = {
165
167
 
166
168
  const connection = new AdtOnPremConnector(
167
169
  config,
168
- new BasicAuthProvider(config.username!, config.password!),
170
+ new BasicAuthProvider(config.username, config.password),
169
171
  new OnPremHttpTransport(() => ({}), logger, {
170
172
  client: config.client,
171
173
  baseUrl: config.url,
@@ -206,7 +208,7 @@ actually use:
206
208
 
207
209
  ```bash
208
210
  npm install @mcp-abap-adt/interfaces-adt-connection # IAbapConnection, ITimeoutConfig, ADT_SESSION_ERROR
209
- npm install @mcp-abap-adt/interfaces-auth # IAuthProvider, IRenewableCredential, ITokenRefresher
211
+ npm install @mcp-abap-adt/interfaces-auth # IAuthProvider, AuthOutcome, ITokenRefresher
210
212
  npm install @mcp-abap-adt/interfaces-auth-sap # ISapConfig, SapAuthType, ICertificateMaterialLoader
211
213
  npm install @mcp-abap-adt/interfaces-network # NETWORK_ERROR_CODES, the WebSocket contracts
212
214
  npm install @mcp-abap-adt/interfaces-utils # ILogger
@@ -219,6 +221,11 @@ deprecated, and installing that alongside a contract package at a different majo
219
221
  puts two copies of the same contract in your tree.
220
222
  [Migration to 9.0.0](./MIGRATION-9.0.md) has the details.
221
223
 
224
+ The credential providers (`BasicAuthProvider`, `TokenAuthProvider`,
225
+ `SamlAuthProvider`, `CertificateAuthProvider`) are no longer part of this
226
+ package as of 10.0.0; install `@mcp-abap-adt/auth-providers` for them. See
227
+ [Migration to 10.0.0](./MIGRATION-10.0.md).
228
+
222
229
  ### Create `tsconfig.json`
223
230
 
224
231
  ```json
@@ -245,11 +252,11 @@ puts two copies of the same contract in your tree.
245
252
  ```typescript
246
253
  import {
247
254
  AdtOnPremConnector,
248
- BasicAuthProvider,
249
255
  ILogger,
250
256
  OnPremHttpTransport,
251
257
  SapConfig,
252
258
  } from '@mcp-abap-adt/connection';
259
+ import { BasicAuthProvider } from '@mcp-abap-adt/auth-providers';
253
260
 
254
261
  const config: SapConfig = {
255
262
  url: 'https://your-sap-server.com',
@@ -126,8 +126,8 @@ Or configure `SapConfig` directly:
126
126
  import {
127
127
  AdtCloudConnector,
128
128
  CloudHttpTransport,
129
- TokenAuthProvider,
130
129
  } from "@mcp-abap-adt/connection";
130
+ import { TokenAuthProvider } from "@mcp-abap-adt/auth-providers";
131
131
  import type { SapConfig } from "@mcp-abap-adt/connection";
132
132
 
133
133
  const config: SapConfig = {
@@ -139,7 +139,7 @@ const logger = console;
139
139
 
140
140
  const connection = new AdtCloudConnector(
141
141
  config,
142
- new TokenAuthProvider(config.jwtToken!),
142
+ TokenAuthProvider.fixed(config.jwtToken!),
143
143
  new CloudHttpTransport(() => ({}), logger, {
144
144
  client: config.client,
145
145
  baseUrl: config.url,