@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
@@ -25,6 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.HttpTransport = exports.isStatefulRequest = void 0;
27
27
  const node_https_1 = require("node:https");
28
+ const auth_errors_1 = require("@mcp-abap-adt/auth-errors");
28
29
  const axios_1 = __importDefault(require("axios"));
29
30
  const cookies_js_1 = require("../utils/cookies.js");
30
31
  const authErrors_js_1 = require("./authErrors.js");
@@ -158,10 +159,10 @@ class HttpTransport {
158
159
  token = null;
159
160
  constructor(agentOptions = () => ({}), logger = null,
160
161
  /**
161
- * `client` because SAP answers `sap-usercontext` with the system default
162
- * rather than the client that was asked for, and later requests then route
163
- * to a client the caller never named — on a read-only one, every write
164
- * comes back 403.
162
+ * The SAP client (mandant) every request on this wire addresses, from the
163
+ * first one on: the establishing call is where the session and its CSRF
164
+ * token are issued, so a client applied any later is applied to a session
165
+ * that already lives in another one. See `clientHeaders()`.
165
166
  */
166
167
  options = {}) {
167
168
  this.agentOptions = agentOptions;
@@ -199,6 +200,10 @@ class HttpTransport {
199
200
  continue;
200
201
  this.jar.set(trimmed, rest.join('=').trim());
201
202
  }
203
+ // SAP answers `sap-usercontext` with the system default rather than the
204
+ // client that was asked for; folded in as it came, later requests would
205
+ // route to a client the caller never named — on a read-only one, every
206
+ // write comes back 403.
202
207
  if (this.options.client) {
203
208
  this.jar.set('sap-usercontext', `sap-client=${this.options.client}`);
204
209
  }
@@ -254,6 +259,39 @@ class HttpTransport {
254
259
  : {}),
255
260
  };
256
261
  }
262
+ /**
263
+ * The client, said the way ABAP hears it: the `sap-client` header.
264
+ *
265
+ * ICF takes the client from the `sap-client` header or query parameter, or
266
+ * from the `sap-usercontext` cookie — and NOT from `X-SAP-Client`, which it
267
+ * ignores. Measured against an on-prem system (client 100 the default),
268
+ * plain curl with basic auth on `/sap/bc/adt/core/discovery`:
269
+ * `X-SAP-Client: 999` answers 200 from client 100, `sap-client: 999` answers
270
+ * 401. Before this, the client reached the system only through the cookie,
271
+ * which the wire holds from the first response on — so the first request,
272
+ * the one that opens the session and earns the CSRF token, always landed in
273
+ * the default client, and a wrong client failed one request late.
274
+ *
275
+ * The header rather than the query parameter: it addresses the client
276
+ * without rewriting a URL the caller built, and it rides on the detached
277
+ * goodbye the same way it rides on everything else.
278
+ */
279
+ clientHeaders() {
280
+ return this.options.client ? { 'sap-client': this.options.client } : {};
281
+ }
282
+ /**
283
+ * The `sap-usercontext` cookie the client is asserted with, from the first
284
+ * request on — before any response could have set one.
285
+ *
286
+ * Added when a request is dressed rather than put in the jar: the jar is
287
+ * what the server issued, and a jar that held something before the first
288
+ * answer would read as a connection that holds a session.
289
+ */
290
+ clientCookie() {
291
+ return this.options.client
292
+ ? `sap-usercontext=sap-client=${this.options.client}`
293
+ : undefined;
294
+ }
257
295
  /**
258
296
  * What this wire says about the session it is already in, on every request.
259
297
  *
@@ -418,6 +456,7 @@ class HttpTransport {
418
456
  * looking like it carried a session.
419
457
  */
420
458
  dress(request) {
459
+ this.refuseAnotherClient(request);
421
460
  const headers = request.headers;
422
461
  const stateful = (0, statefulRequest_js_1.isStatefulRequest)(request);
423
462
  const dressed = {
@@ -426,17 +465,27 @@ class HttpTransport {
426
465
  ...(stateful ? this.sessionTypeHeaders() : {}),
427
466
  ...headers,
428
467
  };
468
+ // The caller's spelling of the client goes; the wire's goes in last. It is
469
+ // the same value — refuseAnotherClient saw to that — said once.
470
+ for (const name of Object.keys(dressed)) {
471
+ if (name.trim().toLowerCase() === 'sap-client')
472
+ delete dressed[name];
473
+ }
474
+ Object.assign(dressed, this.clientHeaders());
429
475
  // Whatever the caller spelled the header as: HTTP does not tell `Cookie`
430
476
  // from `cookie`, and a lowercase one spread in above would bypass the
431
477
  // filter below.
432
478
  let callerCookie;
433
479
  for (const name of Object.keys(dressed)) {
434
- if (name.toLowerCase() !== 'cookie')
480
+ if (name.trim().toLowerCase() !== 'cookie')
435
481
  continue;
436
482
  callerCookie = (0, cookies_js_1.mergeCookieHeaders)(callerCookie, dressed[name]);
437
483
  delete dressed[name];
438
484
  }
439
- const merged = (0, cookies_js_1.mergeCookieHeaders)(callerCookie, this.combined ?? undefined);
485
+ // The client cookie last, so it wins: on the first request it is the only
486
+ // thing that names the client, and later the jar already holds the same
487
+ // value.
488
+ const merged = (0, cookies_js_1.mergeCookieHeaders)((0, cookies_js_1.mergeCookieHeaders)(callerCookie, this.combined ?? undefined), this.clientCookie());
440
489
  // Filtered on the merged header, not only on the jar: a caller's own
441
490
  // `Cookie` can carry the context too — the connection's CSRF and 401
442
491
  // retries put the whole jar there — and a non-stateful request must not
@@ -457,6 +506,88 @@ class HttpTransport {
457
506
  sessionTypeHeaders() {
458
507
  return { [statefulRequest_js_1.SESSION_TYPE_HEADER]: 'stateful' };
459
508
  }
509
+ /**
510
+ * The client belongs to the connection. Another client is another logon —
511
+ * its own user and password, its own session and CSRF token — so a caller
512
+ * that names one in a `sap-client` header, query string or `params` entry, in
513
+ * any case, or in a `sap-usercontext` cookie, is refused before anything is sent: sending it would land the request in
514
+ * that client with the session and credential of this one. Naming the
515
+ * connection's own client is harmless and passes.
516
+ */
517
+ refuseAnotherClient(request) {
518
+ const own = this.options.client || undefined;
519
+ const named = [];
520
+ for (const [name, value] of Object.entries(request.headers ?? {})) {
521
+ if (name.trim().toLowerCase() === 'sap-client')
522
+ named.push(String(value));
523
+ }
524
+ // The query as axios will send it — the URL's own and the structured
525
+ // `params`, serialised by axios itself (which trims and encodes names), so
526
+ // what is checked is what goes out. A name is compared trimmed and in any
527
+ // case, as ICF reads it.
528
+ // The request is fixed by now (`fix`): its URL already holds the `params`,
529
+ // serialised once by axios.
530
+ const sent = axios_1.default.getUri({
531
+ url: request.url ?? '',
532
+ ...(request.params !== undefined ? { params: request.params } : {}),
533
+ });
534
+ // Then read the way Node's adapter addresses it: through a WHATWG URL,
535
+ // which drops tabs and line breaks anywhere in it — `sap-cl\nient` goes
536
+ // out as `sap-client`. A URL that does not parse is not sent either.
537
+ let search;
538
+ try {
539
+ search = new URL(sent, 'http://client.check.invalid').searchParams;
540
+ }
541
+ catch {
542
+ search = new URLSearchParams();
543
+ }
544
+ for (const [name, value] of search) {
545
+ // A list goes out as `sap-client[]=…`; refused all the same.
546
+ if (/^sap-client(\[\])?$/.test(name.trim().toLowerCase())) {
547
+ named.push(value);
548
+ }
549
+ }
550
+ // And the cookie ICF also reads: `sap-usercontext=sap-client=<n>` in a
551
+ // caller's `Cookie`. The connection's own CSRF and 401 retries put the
552
+ // whole jar there, so a wire given no client admits the client its jar
553
+ // holds — the one the system answered with — and nothing else.
554
+ const cookieOwn = own ?? this.jarClient();
555
+ const cookieNamed = [];
556
+ for (const [name, value] of Object.entries(request.headers ?? {})) {
557
+ if (name.trim().toLowerCase() !== 'cookie')
558
+ continue;
559
+ for (const pair of String(value).split(';')) {
560
+ const [cookieName, ...rest] = pair.split('=');
561
+ if (cookieName?.trim().toLowerCase() !== 'sap-usercontext')
562
+ continue;
563
+ for (const [key, client] of new URLSearchParams(rest.join('=').trim())) {
564
+ if (key.trim().toLowerCase() === 'sap-client')
565
+ cookieNamed.push(client);
566
+ }
567
+ }
568
+ }
569
+ for (const client of cookieNamed) {
570
+ if (client === cookieOwn)
571
+ continue;
572
+ throw new Error(`the request names client ${client}, but the connection is ${own ? `for client ${own}` : 'given no client'}: the client belongs to the connection — another client is another connection, with its own credential`);
573
+ }
574
+ for (const client of named) {
575
+ if (client === own)
576
+ continue;
577
+ throw new Error(`the request names client ${client}, but the connection is ${own ? `for client ${own}` : 'given no client'}: the client belongs to the connection — another client is another connection, with its own credential`);
578
+ }
579
+ }
580
+ /** The client the jar's `sap-usercontext` names, as the system set it. */
581
+ jarClient() {
582
+ const context = this.jar.get('sap-usercontext');
583
+ if (context === undefined)
584
+ return undefined;
585
+ for (const [key, client] of new URLSearchParams(context)) {
586
+ if (key.toLowerCase() === 'sap-client')
587
+ return client;
588
+ }
589
+ return undefined;
590
+ }
460
591
  /** A path becomes an address; anything already absolute is left alone. */
461
592
  address(url) {
462
593
  if (!url.startsWith('/') || !this.options.baseUrl)
@@ -486,7 +617,10 @@ class HttpTransport {
486
617
  },
487
618
  logonParameters: () => ({
488
619
  ok: false,
489
- refusal: { reason: 'this wire takes no logon parameters (HTTP)' },
620
+ refusal: auth_errors_1.authError['logon-target']({
621
+ wire: 'http',
622
+ refused: 'logon-parameters',
623
+ }),
490
624
  }),
491
625
  };
492
626
  }
@@ -534,7 +668,33 @@ class HttpTransport {
534
668
  * to add it.
535
669
  */
536
670
  async send(request) {
537
- return this.dispatch(request, this.dress(request));
671
+ const fixed = this.fix(request);
672
+ return this.dispatch(fixed, this.dress(fixed));
673
+ }
674
+ /**
675
+ * The request read once, into plain values: what the client guard checks is
676
+ * then exactly what goes out. The headers are copied, and the URL and
677
+ * `params` are serialised here, once, by axios — the dispatch sends that URL
678
+ * and no `params`, so nothing the caller handed over is read a second time
679
+ * (a getter that answers differently on its second read changes nothing).
680
+ */
681
+ fix(request) {
682
+ const { headers, params, url, ...rest } = request;
683
+ const fixed = {
684
+ ...rest,
685
+ url: axios_1.default.getUri({
686
+ url: url ?? '',
687
+ ...(params !== undefined ? { params } : {}),
688
+ }),
689
+ };
690
+ if (headers !== undefined) {
691
+ const copied = {};
692
+ for (const [name, value] of Object.entries(headers)) {
693
+ copied[name] = value;
694
+ }
695
+ fixed.headers = copied;
696
+ }
697
+ return fixed;
538
698
  }
539
699
  /**
540
700
  * Send EXACTLY these headers, with nothing of the wire's live state mixed in.
@@ -1 +1 @@
1
- {"version":3,"file":"OnPremHttpTransport.d.ts","sourceRoot":"","sources":["../../src/connection/OnPremHttpTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAI5B,qBAAa,mBACX,SAAQ,aACR,YAAW,gBAAgB;IAE3B,SAAkB,IAAI,EAAE,MAAM,CAAiB;IAE/C,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAG,QAAQ,CAAU;IAEpC;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW,CAAS;IAEb,SAAS,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7D,aAAa,IAAI,IAAI;IAK9B;;;;;;;OAOG;IAEY,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;CAwCjE"}
1
+ {"version":3,"file":"OnPremHttpTransport.d.ts","sourceRoot":"","sources":["../../src/connection/OnPremHttpTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAI5B,qBAAa,mBACX,SAAQ,aACR,YAAW,gBAAgB;IAE3B,SAAkB,IAAI,EAAE,MAAM,CAAiB;IAE/C,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAG,QAAQ,CAAU;IAEpC;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW,CAAS;IAEb,SAAS,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7D,aAAa,IAAI,IAAI;IAK9B;;;;;;;OAOG;IAEY,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;CA2CjE"}
@@ -77,6 +77,9 @@ class OnPremHttpTransport extends HttpTransport_js_1.HttpTransport {
77
77
  url: `${context.baseUrl}${ICF_LOGOFF_PATH}`,
78
78
  headers: {
79
79
  ...affinity,
80
+ // Detached, so not dressed: the client is said here in so many
81
+ // words, as on every other request of this wire.
82
+ ...this.clientHeaders(),
80
83
  ...auth,
81
84
  ...context.extraHeaders,
82
85
  Cookie: (0, cookies_js_1.mergeCookieHeaders)(auth.Cookie, cookies),
@@ -46,7 +46,7 @@ import type { IAdtEstablishContext, IAdtSessionContext, IAdtTransportRequest, IA
46
46
  export interface IRfcConversation {
47
47
  open(): Promise<void>;
48
48
  close(): Promise<void>;
49
- call(fm: string, params: Record<string, unknown>): Promise<Record<string, any>>;
49
+ call(fm: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
50
50
  readonly alive: boolean;
51
51
  /**
52
52
  * Ends the ABAP session context and keeps the connection open
@@ -1 +1 @@
1
- {"version":3,"file":"RfcTransport.d.ts","sourceRoot":"","sources":["../../src/connection/RfcTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAElB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAG5B,sFAAsF;AACtF,MAAM,WAAW,gBAAgB;IAC/B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,CACF,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB;;;;;OAKG;IACH,kBAAkB,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAgFD,uDAAuD;AACvD,MAAM,WAAW,oBAAoB;IACnC;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAKD,qBAAa,YAAa,YAAW,gBAAgB;IAuGjD,OAAO,CAAC,QAAQ,CAAC,OAAO;IAGxB,OAAO,CAAC,QAAQ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,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;IAgBnB;;;;OAIG;YACW,QAAQ;YAYR,YAAY;YAQZ,KAAK;CA+KpB"}
@@ -44,8 +44,18 @@
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 auth_errors_1 = require("@mcp-abap-adt/auth-errors");
47
48
  const authErrors_js_1 = require("./authErrors.js");
48
49
  const statefulRequest_js_1 = require("./statefulRequest.js");
50
+ /**
51
+ * The SDK answers with untyped structures: each level is read as a record and
52
+ * each field checked before use, rather than trusted as `any`.
53
+ */
54
+ function record(value) {
55
+ return typeof value === 'object' && value !== null
56
+ ? value
57
+ : undefined;
58
+ }
49
59
  /**
50
60
  * ADT exception types, mapped to what they would have been over HTTP. Standard
51
61
  * types, returned in `<exc:exception>` XML.
@@ -389,7 +399,10 @@ class RfcTransport {
389
399
  return {
390
400
  tlsMaterial: () => ({
391
401
  ok: false,
392
- refusal: { reason: 'this wire carries no TLS material (RFC)' },
402
+ refusal: auth_errors_1.authError['logon-target']({
403
+ wire: 'rfc',
404
+ refused: 'tls-material',
405
+ }),
393
406
  }),
394
407
  logonParameters: (written) => {
395
408
  Object.assign(parameters, written);
@@ -503,21 +516,28 @@ class RfcTransport {
503
516
  this.logger?.error(`RFC call failed: ${msg}`);
504
517
  throw new Error(`RFC call to SADT_REST_RFC_ENDPOINT failed: ${msg}`);
505
518
  }
506
- const answer = raw.RESPONSE ?? raw;
507
- const rawCode = answer.STATUS_LINE?.STATUS_CODE ?? answer.STATUS_LINE?.CODE;
519
+ const answer = record(raw.RESPONSE) ?? raw;
520
+ const statusLine = record(answer.STATUS_LINE);
521
+ const rawCode = statusLine?.STATUS_CODE ?? statusLine?.CODE;
508
522
  let status = typeof rawCode === 'string'
509
523
  ? Number.parseInt(rawCode, 10)
510
- : (rawCode ?? 0);
511
- let statusText = answer.STATUS_LINE?.REASON_PHRASE ?? answer.STATUS_LINE?.REASON ?? '';
512
- const data = answer.MESSAGE_BODY
513
- ? Buffer.isBuffer(answer.MESSAGE_BODY)
514
- ? answer.MESSAGE_BODY.toString('utf-8')
515
- : String(answer.MESSAGE_BODY)
524
+ : typeof rawCode === 'number'
525
+ ? rawCode
526
+ : 0;
527
+ const reason = statusLine?.REASON_PHRASE ?? statusLine?.REASON;
528
+ let statusText = typeof reason === 'string' ? reason : '';
529
+ const answered = answer.MESSAGE_BODY;
530
+ const data = answered
531
+ ? Buffer.isBuffer(answered)
532
+ ? answered.toString('utf-8')
533
+ : String(answered)
516
534
  : '';
517
535
  const headers = {};
518
- for (const field of answer.HEADER_FIELDS ?? []) {
519
- if (field.NAME && field.VALUE !== undefined) {
520
- headers[String(field.NAME).toLowerCase()] = field.VALUE;
536
+ const fields = answer.HEADER_FIELDS;
537
+ for (const field of Array.isArray(fields) ? fields : []) {
538
+ const entry = record(field);
539
+ if (entry?.NAME && entry.VALUE !== undefined) {
540
+ headers[String(entry.NAME).toLowerCase()] = entry.VALUE;
521
541
  }
522
542
  }
523
543
  // BASIS < 7.50 answers without populating STATUS_LINE. Left alone, a
@@ -9,8 +9,11 @@ export type AuthRefusalMoment = 'prepare' | 'logon' | 'request';
9
9
  * The credential said no, or the system refused it and the provider's answer
10
10
  * is final.
11
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
12
+ * `refusal` is the provider's error as `@mcp-abap-adt/auth-errors` minted it
13
+ * (or the connection's own), classified on the way in: a refusal that is not
14
+ * this copy's minted error is rebuilt from its kind and facts, or else is
15
+ * `provider-threw` — decide on its `kind` and `facts`; the message is its
16
+ * `reason — hint`. `cause` keeps the wire's error as it arrived, so a network failure stays visible even when a provider words it as
14
17
  * a credential problem — unless the provider threw instead of answering, when
15
18
  * it is that throw.
16
19
  */
@@ -32,13 +35,16 @@ export declare class WireLogonError extends Error {
32
35
  readonly cause: unknown;
33
36
  constructor(cause: unknown, status?: number);
34
37
  }
35
- /** A provider threw instead of answering: a bug in the provider, not an answer. */
36
- export declare const PROVIDER_FAILED: IAuthRefusal;
38
+ /**
39
+ * A provider threw instead of answering, or answered something that is not an
40
+ * outcome: a bug in the provider, not an answer.
41
+ */
42
+ export declare function providerFailed(at: AuthRefusalMoment): IAuthRefusal;
37
43
  /**
38
44
  * The provider said Ok to a rejection and the retry was refused too. The one
39
45
  * refusal the connection words itself, because the provider's last word was Ok.
40
46
  */
41
- export declare const REFUSED_AGAIN: IAuthRefusal;
47
+ export declare function refusedAgain(at: AuthRefusalMoment): IAuthRefusal;
42
48
  /** A connection built without a credential has nothing to renew. */
43
49
  export declare const NO_CREDENTIAL_TO_RENEW: IAuthRefusal;
44
50
  /**
@@ -51,11 +57,18 @@ export interface GuardedAnswer {
51
57
  thrown?: unknown;
52
58
  }
53
59
  /**
54
- * Run one provider call so that a throw is an answer too.
60
+ * Run one provider call so that a throw is an answer too, and so that what
61
+ * the provider answered is an outcome the connection can trust.
55
62
  *
56
63
  * A consumer's provider may be buggy; the connection must not let that surface
57
64
  * as an unhandled rejection. The throw is kept beside the outcome, to become
58
65
  * the cause of whatever the caller then raises.
66
+ *
67
+ * A provider written in JavaScript can answer any object, and an
68
+ * `AuthRefusedError` built from it would carry its free text. So every answer
69
+ * goes through `classifyOutcome`: a refusal minted by this copy of
70
+ * `auth-errors` passes as the same object, another copy's is rebuilt from its
71
+ * kind and facts, and anything else is `provider-threw` at `at`.
59
72
  */
60
- export declare function guarded(call: () => Promise<AuthOutcome>): Promise<GuardedAnswer>;
73
+ export declare function guarded(call: () => Promise<AuthOutcome>, at: AuthRefusalMoment): Promise<GuardedAnswer>;
61
74
  //# sourceMappingURL=authErrors.d.ts.map
@@ -1 +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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,EAChC,EAAE,EAAE,iBAAiB,GACpB,OAAO,CAAC,aAAa,CAAC,CAOxB"}
@@ -4,14 +4,20 @@
4
4
  * puts on a failure that is a refused logon.
5
5
  */
6
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;
7
+ exports.NO_CREDENTIAL_TO_RENEW = exports.WireLogonError = exports.AuthRefusedError = void 0;
8
+ exports.providerFailed = providerFailed;
9
+ exports.refusedAgain = refusedAgain;
8
10
  exports.guarded = guarded;
11
+ const auth_errors_1 = require("@mcp-abap-adt/auth-errors");
9
12
  /**
10
13
  * The credential said no, or the system refused it and the provider's answer
11
14
  * is final.
12
15
  *
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
16
+ * `refusal` is the provider's error as `@mcp-abap-adt/auth-errors` minted it
17
+ * (or the connection's own), classified on the way in: a refusal that is not
18
+ * this copy's minted error is rebuilt from its kind and facts, or else is
19
+ * `provider-threw` — decide on its `kind` and `facts`; the message is its
20
+ * `reason — hint`. `cause` keeps the wire's error as it arrived, so a network failure stays visible even when a provider words it as
15
21
  * a credential problem — unless the provider threw instead of answering, when
16
22
  * it is that throw.
17
23
  */
@@ -20,14 +26,28 @@ class AuthRefusedError extends Error {
20
26
  at;
21
27
  cause;
22
28
  constructor(refusal, at, cause) {
23
- super(refusal.hint ? `${refusal.reason} — ${refusal.hint}` : refusal.reason);
29
+ const checked = checkedRefusal(refusal, at);
30
+ super(checked.hint ? `${checked.reason} — ${checked.hint}` : checked.reason);
24
31
  this.name = 'AuthRefusedError';
25
- this.refusal = refusal;
32
+ this.refusal = checked;
26
33
  this.at = at;
27
34
  this.cause = cause;
28
35
  }
29
36
  }
30
37
  exports.AuthRefusedError = AuthRefusedError;
38
+ /**
39
+ * The refusal an `AuthRefusedError` carries, never the object as given unread:
40
+ * anyone may build one — over a `structuredClone`, say — and its words reach
41
+ * the message. A refusal this copy of `auth-errors` minted is kept as the same
42
+ * object; one that rebuilds from its kind and facts (a clone, another copy's)
43
+ * is rebuilt, its words rendered anew and its diagnostics dropped; anything
44
+ * else is `provider-threw` at the moment.
45
+ */
46
+ function checkedRefusal(refusal, at) {
47
+ const fallback = providerFailed(at);
48
+ const outcome = (0, auth_errors_1.classifyOutcome)({ ok: false, refusal }, fallback);
49
+ return outcome.ok ? fallback : outcome.refusal;
50
+ }
31
51
  /**
32
52
  * A wire's mark: this failure is a refused logon. It decides nothing — what to
33
53
  * do about it is the provider's answer, not the wire's.
@@ -46,33 +66,44 @@ class WireLogonError extends Error {
46
66
  }
47
67
  }
48
68
  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
- };
69
+ /**
70
+ * A provider threw instead of answering, or answered something that is not an
71
+ * outcome: a bug in the provider, not an answer.
72
+ */
73
+ function providerFailed(at) {
74
+ return auth_errors_1.authError.connection({ problem: 'provider-threw', at });
75
+ }
53
76
  /**
54
77
  * The provider said Ok to a rejection and the retry was refused too. The one
55
78
  * refusal the connection words itself, because the provider's last word was Ok.
56
79
  */
57
- exports.REFUSED_AGAIN = {
58
- reason: 'the credential was refused again after the provider renewed it',
59
- };
80
+ function refusedAgain(at) {
81
+ return auth_errors_1.authError.connection({ problem: 'refused-after-renewal', at });
82
+ }
60
83
  /** 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
- };
84
+ exports.NO_CREDENTIAL_TO_RENEW = auth_errors_1.authError.connection({
85
+ problem: 'no-credential',
86
+ });
64
87
  /**
65
- * Run one provider call so that a throw is an answer too.
88
+ * Run one provider call so that a throw is an answer too, and so that what
89
+ * the provider answered is an outcome the connection can trust.
66
90
  *
67
91
  * A consumer's provider may be buggy; the connection must not let that surface
68
92
  * as an unhandled rejection. The throw is kept beside the outcome, to become
69
93
  * the cause of whatever the caller then raises.
94
+ *
95
+ * A provider written in JavaScript can answer any object, and an
96
+ * `AuthRefusedError` built from it would carry its free text. So every answer
97
+ * goes through `classifyOutcome`: a refusal minted by this copy of
98
+ * `auth-errors` passes as the same object, another copy's is rebuilt from its
99
+ * kind and facts, and anything else is `provider-threw` at `at`.
70
100
  */
71
- async function guarded(call) {
101
+ async function guarded(call, at) {
102
+ const fallback = providerFailed(at);
72
103
  try {
73
- return { outcome: await call() };
104
+ return { outcome: (0, auth_errors_1.classifyOutcome)(await call(), fallback) };
74
105
  }
75
106
  catch (thrown) {
76
- return { outcome: { ok: false, refusal: exports.PROVIDER_FAILED }, thrown };
107
+ return { outcome: { ok: false, refusal: fallback }, thrown };
77
108
  }
78
109
  }
@@ -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;;;;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"}
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,CAoB/D"}
@@ -56,7 +56,6 @@ function rfcConversationFrom(config) {
56
56
  try {
57
57
  // Dynamic, because the SDK is an optional peer: it needs the SAP NW RFC
58
58
  // SDK installed on the machine, and most consumers travel over HTTP.
59
- // biome-ignore lint/correctness/noNodejsModules: optional by design
60
59
  Client = require('@mcp-abap-adt/sap-rfc-lite').Client;
61
60
  }
62
61
  catch (error) {
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-12.0.md # refusals follow the auth error contract (interfaces-auth 6, auth-errors)
18
19
  │ ├── MIGRATION-11.0.md # the server certificate is verified by default
19
20
  │ ├── MIGRATION-10.0.md # providers move to auth-providers; IAuthProvider 3.0; AuthRefusedError
20
21
  │ ├── MIGRATION-9.0.md # the contracts split out of @mcp-abap-adt/interfaces
@@ -48,6 +49,7 @@ mcp-abap-connection/
48
49
  - 🔑 [JWT Auth Tools](./JWT_AUTH_TOOLS.md) - CLI tool for browser-based authentication
49
50
 
50
51
  ### Upgrading
52
+ - 🚚 [Migrating to 12.0.0](./MIGRATION-12.0.md) - refusals follow the auth error contract: `AuthRefusedError.refusal` is an `IAuthProviderError` (read its `kind`), a custom `ILogonTarget` mints its refusal through `@mcp-abap-adt/auth-errors`, and the providers come from auth-providers 6.0.0
51
53
  - 🚚 [Migrating to 11.0.0](./MIGRATION-11.0.md) - the server certificate is verified by default; trust a self-signed system with `agentOptions.ca`, or opt out explicitly with `TLS_REJECT_UNAUTHORIZED=0`
52
54
  - 🚚 [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
53
55
  - 🚚 [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
@@ -84,7 +86,7 @@ mcp-abap-connection/
84
86
  - **Configuration Types**: [USAGE.md - Configuration Types](./USAGE.md#configuration-types)
85
87
  - **Connectors**: `AdtOnPremConnector`, `AdtCloudConnector`
86
88
  - **Credentials**: an `IAuthProvider` (`@mcp-abap-adt/interfaces-auth`); the ready-made providers live in `@mcp-abap-adt/auth-providers`
87
- - **Errors**: `AuthRefusedError`, `WireLogonError`
89
+ - **Errors**: `AuthRefusedError` (its `refusal` an `IAuthProviderError` minted by `@mcp-abap-adt/auth-errors`), `WireLogonError`
88
90
  - **Transports**: `HttpTransport`, `RfcTransport` (+ `rfcConversationFrom()`)
89
91
 
90
92
  ## Version Highlights
@@ -208,7 +208,8 @@ actually use:
208
208
 
209
209
  ```bash
210
210
  npm install @mcp-abap-adt/interfaces-adt-connection # IAbapConnection, ITimeoutConfig, ADT_SESSION_ERROR
211
- npm install @mcp-abap-adt/interfaces-auth # IAuthProvider, AuthOutcome, ITokenRefresher
211
+ npm install @mcp-abap-adt/interfaces-auth # IAuthProvider, AuthOutcome, IAuthProviderError, ITokenRefresher (6.x)
212
+ npm install @mcp-abap-adt/auth-errors # authError builders, classify — to mint a refusal of your own
212
213
  npm install @mcp-abap-adt/interfaces-auth-sap # ISapConfig, SapAuthType, ICertificateMaterialLoader
213
214
  npm install @mcp-abap-adt/interfaces-network # NETWORK_ERROR_CODES, the WebSocket contracts
214
215
  npm install @mcp-abap-adt/interfaces-utils # ILogger
@@ -223,8 +224,10 @@ puts two copies of the same contract in your tree.
223
224
 
224
225
  The credential providers (`BasicAuthProvider`, `TokenAuthProvider`,
225
226
  `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).
227
+ package as of 10.0.0; install `@mcp-abap-adt/auth-providers` for them — 6.0.0
228
+ or later with connection 12.x, whose interfaces-auth 6 the 5.x providers do not
229
+ fit. See [Migration to 10.0.0](./MIGRATION-10.0.md) and
230
+ [Migration to 12.0.0](./MIGRATION-12.0.md).
228
231
 
229
232
  ### Create `tsconfig.json`
230
233
 
@@ -222,6 +222,7 @@ provider refuses, so a goodbye that authorizes catches it; the connection absorb
222
222
  a rejected close it dispatched, but a close that never throws is the contract.
223
223
 
224
224
  ```ts
225
+ import { authError } from '@mcp-abap-adt/auth-errors';
225
226
  import type {
226
227
  AuthOutcome,
227
228
  ILogonTarget,
@@ -239,7 +240,13 @@ async function logOn(
239
240
  const target: ILogonTarget = {
240
241
  tlsMaterial: (): AuthOutcome => ({
241
242
  ok: false,
242
- refusal: { reason: 'this wire carries no TLS material (example wire)' },
243
+ // Since 12.0.0 a refusal is minted by @mcp-abap-adt/auth-errors. A wire of
244
+ // your own is neither of connection's two, so `wire` is 'unknown' — 'http'
245
+ // and 'rfc' carry the words of connection's own wires. See MIGRATION-12.0.md.
246
+ refusal: authError['logon-target']({
247
+ wire: 'unknown',
248
+ refused: 'tls-material',
249
+ }),
243
250
  }),
244
251
  logonParameters: (offered): AuthOutcome => {
245
252
  parameters = { ...offered };