@mcp-abap-adt/core 19.1.0 → 20.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 (107) hide show
  1. package/README.md +17 -4
  2. package/bin/mcp-abap-adt.js +7 -2
  3. package/dist/auth/index.d.ts +5 -12
  4. package/dist/auth/index.d.ts.map +1 -1
  5. package/dist/auth/index.js +20 -34
  6. package/dist/auth/index.js.map +1 -1
  7. package/dist/coreVersion.d.ts +2 -12
  8. package/dist/coreVersion.d.ts.map +1 -1
  9. package/dist/coreVersion.js +5 -2
  10. package/dist/coreVersion.js.map +1 -1
  11. package/dist/index.d.ts +14 -6
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +33 -17
  14. package/dist/index.js.map +1 -1
  15. package/dist/launcher.d.ts +18 -134
  16. package/dist/launcher.d.ts.map +1 -1
  17. package/dist/launcher.js +32 -689
  18. package/dist/launcher.js.map +1 -1
  19. package/package.json +9 -19
  20. package/dist/StdioServer.d.ts +0 -87
  21. package/dist/StdioServer.d.ts.map +0 -1
  22. package/dist/StdioServer.js +0 -132
  23. package/dist/StdioServer.js.map +0 -1
  24. package/dist/auth/IAuthBrokerFactory.d.ts +0 -62
  25. package/dist/auth/IAuthBrokerFactory.d.ts.map +0 -1
  26. package/dist/auth/IAuthBrokerFactory.js +0 -8
  27. package/dist/auth/IAuthBrokerFactory.js.map +0 -1
  28. package/dist/auth/IAuthBrokerFactoryConfig.d.ts +0 -90
  29. package/dist/auth/IAuthBrokerFactoryConfig.d.ts.map +0 -1
  30. package/dist/auth/IAuthBrokerFactoryConfig.js +0 -8
  31. package/dist/auth/IAuthBrokerFactoryConfig.js.map +0 -1
  32. package/dist/auth/brokerFactory.d.ts +0 -93
  33. package/dist/auth/brokerFactory.d.ts.map +0 -1
  34. package/dist/auth/brokerFactory.js +0 -341
  35. package/dist/auth/brokerFactory.js.map +0 -1
  36. package/dist/auth/browser.d.ts +0 -60
  37. package/dist/auth/browser.d.ts.map +0 -1
  38. package/dist/auth/browser.js +0 -116
  39. package/dist/auth/browser.js.map +0 -1
  40. package/dist/auth/countedProvider.d.ts +0 -43
  41. package/dist/auth/countedProvider.d.ts.map +0 -1
  42. package/dist/auth/countedProvider.js +0 -105
  43. package/dist/auth/countedProvider.js.map +0 -1
  44. package/dist/auth/destinationFailure.d.ts +0 -69
  45. package/dist/auth/destinationFailure.d.ts.map +0 -1
  46. package/dist/auth/destinationFailure.js +0 -183
  47. package/dist/auth/destinationFailure.js.map +0 -1
  48. package/dist/auth/destinationStores.d.ts +0 -55
  49. package/dist/auth/destinationStores.d.ts.map +0 -1
  50. package/dist/auth/destinationStores.js +0 -158
  51. package/dist/auth/destinationStores.js.map +0 -1
  52. package/dist/auth/handlers/basic.d.ts +0 -3
  53. package/dist/auth/handlers/basic.d.ts.map +0 -1
  54. package/dist/auth/handlers/basic.js +0 -8
  55. package/dist/auth/handlers/basic.js.map +0 -1
  56. package/dist/auth/handlers/index.d.ts +0 -15
  57. package/dist/auth/handlers/index.d.ts.map +0 -1
  58. package/dist/auth/handlers/index.js +0 -32
  59. package/dist/auth/handlers/index.js.map +0 -1
  60. package/dist/auth/handlers/jwtAuthorizationCode.d.ts +0 -8
  61. package/dist/auth/handlers/jwtAuthorizationCode.d.ts.map +0 -1
  62. package/dist/auth/handlers/jwtAuthorizationCode.js +0 -32
  63. package/dist/auth/handlers/jwtAuthorizationCode.js.map +0 -1
  64. package/dist/auth/handlers/snc.d.ts +0 -3
  65. package/dist/auth/handlers/snc.d.ts.map +0 -1
  66. package/dist/auth/handlers/snc.js +0 -14
  67. package/dist/auth/handlers/snc.js.map +0 -1
  68. package/dist/auth/handlers/types.d.ts +0 -30
  69. package/dist/auth/handlers/types.d.ts.map +0 -1
  70. package/dist/auth/handlers/types.js +0 -3
  71. package/dist/auth/handlers/types.js.map +0 -1
  72. package/dist/auth/serverLogin.d.ts +0 -75
  73. package/dist/auth/serverLogin.d.ts.map +0 -1
  74. package/dist/auth/serverLogin.js +0 -138
  75. package/dist/auth/serverLogin.js.map +0 -1
  76. package/dist/auth/serverSentences.d.ts +0 -39
  77. package/dist/auth/serverSentences.d.ts.map +0 -1
  78. package/dist/auth/serverSentences.js +0 -49
  79. package/dist/auth/serverSentences.js.map +0 -1
  80. package/dist/auth/vocabulary.d.ts +0 -28
  81. package/dist/auth/vocabulary.d.ts.map +0 -1
  82. package/dist/auth/vocabulary.js +0 -67
  83. package/dist/auth/vocabulary.js.map +0 -1
  84. package/dist/config/coreParameters.d.ts +0 -125
  85. package/dist/config/coreParameters.d.ts.map +0 -1
  86. package/dist/config/coreParameters.js +0 -331
  87. package/dist/config/coreParameters.js.map +0 -1
  88. package/dist/config/envFileContext.d.ts +0 -26
  89. package/dist/config/envFileContext.d.ts.map +0 -1
  90. package/dist/config/envFileContext.js +0 -90
  91. package/dist/config/envFileContext.js.map +0 -1
  92. package/dist/config/envResolver.d.ts +0 -6
  93. package/dist/config/envResolver.d.ts.map +0 -1
  94. package/dist/config/envResolver.js +0 -81
  95. package/dist/config/envResolver.js.map +0 -1
  96. package/dist/config/platformPaths.d.ts +0 -28
  97. package/dist/config/platformPaths.d.ts.map +0 -1
  98. package/dist/config/platformPaths.js +0 -152
  99. package/dist/config/platformPaths.js.map +0 -1
  100. package/dist/destinationSource.d.ts +0 -26
  101. package/dist/destinationSource.d.ts.map +0 -1
  102. package/dist/destinationSource.js +0 -43
  103. package/dist/destinationSource.js.map +0 -1
  104. package/dist/shutdown.d.ts +0 -97
  105. package/dist/shutdown.d.ts.map +0 -1
  106. package/dist/shutdown.js +0 -136
  107. package/dist/shutdown.js.map +0 -1
@@ -1,105 +0,0 @@
1
- "use strict";
2
- /**
3
- * Work in progress, counted at the provider.
4
- *
5
- * `countedProvider` forwards each of the four `IAuthProvider` calls unchanged
6
- * and counts the ones not yet answered. A renewal happens inside one of those
7
- * calls and its `onTokens` write is submitted before the call answers
8
- * (broker 4), so once the count is zero every renewal has reached the
9
- * broker's writer and `flush()` covers it.
10
- *
11
- * Behind a closed gate no call starts: each answers the shutdown refusal
12
- * (`interactive-login` `aborted`, minted) at once, without reaching the inner provider — Oops, never a throw. A call
13
- * admitted before the gate closed runs to its answer and is waited for.
14
- * Nothing opens the gate again.
15
- */
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.ProviderGate = exports.SHUTDOWN_REFUSAL = void 0;
18
- exports.countedProvider = countedProvider;
19
- const auth_errors_1 = require("@mcp-abap-adt/auth-errors");
20
- /**
21
- * The closed gate's answer: auth-errors' `interactive-login` `aborted`,
22
- * minted — the server's shutdown sentence goes beside it (`serverSentence`),
23
- * never into the refusal.
24
- */
25
- exports.SHUTDOWN_REFUSAL = Object.freeze({
26
- ok: false,
27
- refusal: auth_errors_1.authError['interactive-login']({ outcome: 'aborted' }),
28
- });
29
- class ProviderGate {
30
- isClosed = false;
31
- count = 0;
32
- waiters = [];
33
- /** Closes the gate for good: no provider call starts after this. */
34
- close() {
35
- this.isClosed = true;
36
- }
37
- get closed() {
38
- return this.isClosed;
39
- }
40
- /** Provider calls admitted and not yet answered. */
41
- get inFlight() {
42
- return this.count;
43
- }
44
- /** @internal Admits one call; `false` behind a closed gate. */
45
- enter() {
46
- if (this.isClosed)
47
- return false;
48
- this.count += 1;
49
- return true;
50
- }
51
- /** @internal One admitted call answered (or threw). */
52
- leave() {
53
- this.count -= 1;
54
- if (this.count === 0) {
55
- const waiters = this.waiters;
56
- this.waiters = [];
57
- for (const wake of waiters)
58
- wake();
59
- }
60
- }
61
- /**
62
- * Resolves when no call is in flight — no deadline, no timer: a
63
- * shutdown's forced close is what ends this waiting early, and it does not
64
- * await it. `signal` (the shutdown's) releases this wait when it aborts.
65
- */
66
- drained(signal) {
67
- if (this.count === 0 || signal?.aborted)
68
- return Promise.resolve();
69
- return new Promise((resolve) => {
70
- const wake = () => {
71
- signal?.removeEventListener('abort', onAbort);
72
- resolve();
73
- };
74
- const onAbort = () => {
75
- this.waiters = this.waiters.filter((w) => w !== wake);
76
- resolve();
77
- };
78
- signal?.addEventListener('abort', onAbort, { once: true });
79
- this.waiters.push(wake);
80
- });
81
- }
82
- }
83
- exports.ProviderGate = ProviderGate;
84
- function countedProvider(inner, gate) {
85
- const counted = async (run) => {
86
- if (!gate.enter())
87
- return exports.SHUTDOWN_REFUSAL;
88
- try {
89
- return await run();
90
- }
91
- finally {
92
- gate.leave();
93
- }
94
- };
95
- return {
96
- get kind() {
97
- return inner.kind;
98
- },
99
- prepare: () => counted(() => inner.prepare()),
100
- establish: (logon) => counted(() => inner.establish(logon)),
101
- authorize: (request) => counted(() => inner.authorize(request)),
102
- rejected: (rejection) => counted(() => inner.rejected(rejection)),
103
- };
104
- }
105
- //# sourceMappingURL=countedProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"countedProvider.js","sourceRoot":"","sources":["../../src/auth/countedProvider.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AA+EH,0CAyBC;AAtGD,2DAAsD;AAStD;;;;GAIG;AACU,QAAA,gBAAgB,GAAgB,MAAM,CAAC,MAAM,CAAC;IACzD,EAAE,EAAE,KAAK;IACT,OAAO,EAAE,uBAAS,CAAC,mBAAmB,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;CAChE,CAAC,CAAC;AAEH,MAAa,YAAY;IACf,QAAQ,GAAG,KAAK,CAAC;IACjB,KAAK,GAAG,CAAC,CAAC;IACV,OAAO,GAAsB,EAAE,CAAC;IAExC,oEAAoE;IACpE,KAAK;QACH,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,oDAAoD;IACpD,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,+DAA+D;IAC/D,KAAK;QACH,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO,KAAK,CAAC;QAChC,IAAI,CAAC,KA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CAAC,IAAI,CAAC,KAAK,EAAE;YAAE,OAAO,wBAAgB,CAAC;QAC3C,IAAI,CAAC;YACH,OAAO,MAAM,GAAG,EAAE,CAAC;QACrB,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC;IACH,CAAC,CAAC;IACF,OAAO;QACL,IAAI,IAAI;YACN,OAAO,KAAK,CAAC,IAAI,CAAC;QACpB,CAAC;QACD,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QAC7C,SAAS,EAAE,CAAC,KAAmB,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACzE,SAAS,EAAE,CAAC,OAAuB,EAAE,EAAE,CACrC,OAAO,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACzC,QAAQ,EAAE,CAAC,SAAyB,EAAE,EAAE,CACtC,OAAO,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;KAC3C,CAAC;AACJ,CAAC"}
@@ -1,69 +0,0 @@
1
- /**
2
- * The destination layer's failures, as the client's answer.
3
- *
4
- * core reads first what only core knows — a `DestinationConfigError`
5
- * (auth-broker's `isDestinationConfigError`, structural): its destination,
6
- * the fields it names and the error it carries; then a session record the
7
- * store refused as not of its format (auth-stores 5's `StorageError`,
8
- * `reason: 'record-format'`, read by its own `code` and `reason`) —
9
- * then lib's `failureOf`.
10
- * Built from field names, vetted vocabulary and auth-errors' words only,
11
- * never a message or a stored value.
12
- */
13
- import type { IAuthProviderError } from '@mcp-abap-adt/interfaces-auth';
14
- import type { DestinationGrant } from '@mcp-abap-adt/interfaces-auth-broker';
15
- import { type ReadFailure, ServerRefusal } from '@mcp-abap-adt/lib/auth';
16
- import type { AuthType } from './vocabulary';
17
- /**
18
- * A refusal whose words are vetted: built from a parameter label and the
19
- * user's own input (a path they gave), never from a file's content. Answered
20
- * `destination_refused`.
21
- */
22
- export declare class DestinationRefusal extends ServerRefusal {
23
- constructor(words: string);
24
- }
25
- /**
26
- * Where a token you hold went: the hint of a `jwt` / `none`
27
- * destination's refusal.
28
- */
29
- export declare const JWT_NONE_HINT = "a token you hold is sent in the x-sap-jwt-token header to mcp-abap-adt-http or mcp-abap-adt-sse; for stdio, create the session with mcp-auth";
30
- /**
31
- * The hint of a session record the store refused as not of its format.
32
- */
33
- export declare const RECORD_FORMAT_HINT = "regenerate the session with mcp-auth: `mcp-auth --destination <name> --type abap|xsuaa`, or `mcp-auth --service-key <file> --output <file> --type abap|xsuaa` (from @mcp-abap-adt/auth-broker-cli)";
34
- /**
35
- * A well-formed authentication this server does not serve. `authType` and
36
- * `grantType` are already vetted names, so quoting them leaks nothing.
37
- * Answered `destination_refused`; `jwt` / `none` with the hint saying where it
38
- * went (`JWT_NONE_HINT`).
39
- */
40
- export declare class UnsupportedAuthenticationError extends ServerRefusal {
41
- readonly code: "UNSUPPORTED_AUTHENTICATION";
42
- readonly destination: string;
43
- readonly authType: AuthType;
44
- readonly grantType?: DestinationGrant;
45
- constructor(destination: string, authType: AuthType, grantType?: DestinationGrant);
46
- }
47
- /** One fixed remedy per field the server knows how to fix. */
48
- export declare const HINTS: Readonly<Record<string, string>>;
49
- export interface DestinationFailureOptions {
50
- /** The destination the server serves: named by a refusal whose error does not carry it. */
51
- readonly destination?: string;
52
- /** The platform a browser login found no browser on (default `process.platform`). */
53
- readonly platform?: string;
54
- /** The server's own sentence beside a chain failure. */
55
- readonly sentenceFor?: (error: IAuthProviderError) => string | undefined;
56
- }
57
- /**
58
- * What `thrown` is, as the client's answer: a `DestinationConfigError`
59
- * first, then a record the store refused, then lib's `failureOf`;
60
- * `undefined` when none knows it. Total.
61
- */
62
- export declare function destinationFailureOf(thrown: unknown, options?: DestinationFailureOptions): ReadFailure | undefined;
63
- /**
64
- * The words a failure is reported in on stderr at the start: the answer's
65
- * message, then its hint and the server's sentence, each on its own line;
66
- * else the destination and the error's class — never its message.
67
- */
68
- export declare function destinationFailureWords(thrown: unknown, destination: string, options?: DestinationFailureOptions): string;
69
- //# sourceMappingURL=destinationFailure.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"destinationFailure.d.ts","sourceRoot":"","sources":["../../src/auth/destinationFailure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAGL,KAAK,WAAW,EAEhB,aAAa,EACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,aAAa;gBACvC,KAAK,EAAE,MAAM;CAI1B;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,iJACsH,CAAC;AAEjJ;;GAEG;AACH,eAAO,MAAM,kBAAkB,uMACuK,CAAC;AAKvM;;;;;GAKG;AACH,qBAAa,8BAA+B,SAAQ,aAAa;IAC/D,QAAQ,CAAC,IAAI,EAAG,4BAA4B,CAAU;IACtD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC;gBAGpC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,QAAQ,EAClB,SAAS,CAAC,EAAE,gBAAgB;CAe/B;AAED,8DAA8D;AAC9D,eAAO,MAAM,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CASlD,CAAC;AAEF,MAAM,WAAW,yBAAyB;IACxC,2FAA2F;IAC3F,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,qFAAqF;IACrF,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,wDAAwD;IACxD,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,MAAM,GAAG,SAAS,CAAC;CAC1E;AA0ED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,OAAO,EACf,OAAO,GAAE,yBAA8B,GACtC,WAAW,GAAG,SAAS,CAwBzB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,OAAO,EACf,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,yBAA8B,GACtC,MAAM,CAQR"}
@@ -1,183 +0,0 @@
1
- "use strict";
2
- /**
3
- * The destination layer's failures, as the client's answer.
4
- *
5
- * core reads first what only core knows — a `DestinationConfigError`
6
- * (auth-broker's `isDestinationConfigError`, structural): its destination,
7
- * the fields it names and the error it carries; then a session record the
8
- * store refused as not of its format (auth-stores 5's `StorageError`,
9
- * `reason: 'record-format'`, read by its own `code` and `reason`) —
10
- * then lib's `failureOf`.
11
- * Built from field names, vetted vocabulary and auth-errors' words only,
12
- * never a message or a stored value.
13
- */
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.HINTS = exports.UnsupportedAuthenticationError = exports.RECORD_FORMAT_HINT = exports.JWT_NONE_HINT = exports.DestinationRefusal = void 0;
16
- exports.destinationFailureOf = destinationFailureOf;
17
- exports.destinationFailureWords = destinationFailureWords;
18
- const auth_broker_1 = require("@mcp-abap-adt/auth-broker");
19
- const auth_errors_1 = require("@mcp-abap-adt/auth-errors");
20
- const auth_1 = require("@mcp-abap-adt/lib/auth");
21
- /**
22
- * A refusal whose words are vetted: built from a parameter label and the
23
- * user's own input (a path they gave), never from a file's content. Answered
24
- * `destination_refused`.
25
- */
26
- class DestinationRefusal extends auth_1.ServerRefusal {
27
- constructor(words) {
28
- super('destination_refused', words);
29
- this.name = 'DestinationRefusal';
30
- }
31
- }
32
- exports.DestinationRefusal = DestinationRefusal;
33
- /**
34
- * Where a token you hold went: the hint of a `jwt` / `none`
35
- * destination's refusal.
36
- */
37
- exports.JWT_NONE_HINT = 'a token you hold is sent in the x-sap-jwt-token header to mcp-abap-adt-http or mcp-abap-adt-sse; for stdio, create the session with mcp-auth';
38
- /**
39
- * The hint of a session record the store refused as not of its format.
40
- */
41
- exports.RECORD_FORMAT_HINT = 'regenerate the session with mcp-auth: `mcp-auth --destination <name> --type abap|xsuaa`, or `mcp-auth --service-key <file> --output <file> --type abap|xsuaa` (from @mcp-abap-adt/auth-broker-cli)';
42
- /** The hint of each refusal that has one, recorded when it is built (never read off the value). */
43
- const UNSUPPORTED_HINTS = new WeakMap();
44
- /**
45
- * A well-formed authentication this server does not serve. `authType` and
46
- * `grantType` are already vetted names, so quoting them leaks nothing.
47
- * Answered `destination_refused`; `jwt` / `none` with the hint saying where it
48
- * went (`JWT_NONE_HINT`).
49
- */
50
- class UnsupportedAuthenticationError extends auth_1.ServerRefusal {
51
- code = 'UNSUPPORTED_AUTHENTICATION';
52
- destination;
53
- authType;
54
- grantType;
55
- constructor(destination, authType, grantType) {
56
- const which = grantType ? `${authType} / ${grantType}` : authType;
57
- super('destination_refused', `Destination "${destination}" uses ${which}, which this server does not support`);
58
- this.name = 'UnsupportedAuthenticationError';
59
- this.destination = destination;
60
- this.authType = authType;
61
- if (grantType)
62
- this.grantType = grantType;
63
- if (authType === 'jwt' && grantType === 'none') {
64
- UNSUPPORTED_HINTS.set(this, exports.JWT_NONE_HINT);
65
- }
66
- }
67
- }
68
- exports.UnsupportedAuthenticationError = UnsupportedAuthenticationError;
69
- /** One fixed remedy per field the server knows how to fix. */
70
- exports.HINTS = {
71
- grantType: 'Write the destination again with `mcp-auth --destination <name> --type abap|xsuaa` or `mcp-auth --service-key <file> --output <file> --type abap|xsuaa` (from @mcp-abap-adt/auth-broker-cli), or add SAP_GRANT_TYPE to its .env.',
72
- SAP_URL: "Set SAP_URL to the system's URL.",
73
- XSUAA_MCP_URL: "Set XSUAA_MCP_URL in the destination's sessions/<destination>.env to the system's URL.",
74
- 'connection-type': 'SNC logs on over RFC: set --connection-type=rfc.',
75
- browser: 'Start with --browser=none and open the URL the login prints on stderr, or give --browser-program=<program>.',
76
- };
77
- /** The headline of a destination refused for `fields`. */
78
- function headline(destination, fields, platform) {
79
- if (fields.length === 1 && fields[0] === 'browser') {
80
- return `Destination "${destination}" logs in through a browser, and none is known on this platform (${platform})`;
81
- }
82
- return `Destination "${destination}" cannot be used: ${fields.join(', ')}`;
83
- }
84
- /** A `DestinationConfigError` as the answer; `undefined` for anything else. */
85
- function destinationConfigFailure(thrown, platform) {
86
- if (!(0, auth_broker_1.isDestinationConfigError)(thrown))
87
- return undefined;
88
- // Each read once, as own data, and only the copies rendered: a value that
89
- // answers differently on a second read cannot change what was checked.
90
- const destination = (0, auth_1.readOwn)(thrown, 'destination');
91
- const listed = (0, auth_1.readOwn)(thrown, 'missingFields');
92
- if (typeof destination !== 'string' || !Array.isArray(listed)) {
93
- return undefined;
94
- }
95
- const copied = Array.from(listed);
96
- if (!copied.every((field) => typeof field === 'string'))
97
- return undefined;
98
- const fields = copied;
99
- const carried = (0, auth_1.readOwn)(thrown, 'error');
100
- const cause = carried === undefined ? undefined : (0, auth_errors_1.classify)(carried, 'unfamiliar-error');
101
- const hints = [];
102
- if (cause?.hint !== undefined)
103
- hints.push(cause.hint);
104
- for (const field of fields) {
105
- const hint = Object.hasOwn(exports.HINTS, field) ? exports.HINTS[field] : undefined;
106
- if (hint !== undefined && !hints.includes(hint))
107
- hints.push(hint);
108
- }
109
- return {
110
- error: 'destination_refused',
111
- message: headline(destination, fields, platform),
112
- ...(hints.length > 0 ? { hint: hints.join('\n') } : {}),
113
- ...(cause !== undefined ? { causeKind: cause.kind, authError: cause } : {}),
114
- };
115
- }
116
- /**
117
- * A session record the store refused as not of its format: the
118
- * server's own fixed words with the destination it serves — never the
119
- * store's message, never a value of the record. Read by structure: an own
120
- * `code` `STORAGE_ERROR` and an own `reason` `'record-format'`.
121
- */
122
- function recordFormatFailure(thrown, destination) {
123
- if ((0, auth_1.readOwn)(thrown, 'code') !== 'STORAGE_ERROR' ||
124
- (0, auth_1.readOwn)(thrown, 'reason') !== 'record-format') {
125
- return undefined;
126
- }
127
- const subject = destination === undefined
128
- ? 'The destination'
129
- : `Destination "${destination}"`;
130
- return {
131
- error: 'destination_refused',
132
- message: `${subject} cannot be used: its session record is not in the store's format`,
133
- hint: exports.RECORD_FORMAT_HINT,
134
- };
135
- }
136
- /**
137
- * What `thrown` is, as the client's answer: a `DestinationConfigError`
138
- * first, then a record the store refused, then lib's `failureOf`;
139
- * `undefined` when none knows it. Total.
140
- */
141
- function destinationFailureOf(thrown, options = {}) {
142
- try {
143
- const platform = options.platform ?? process.platform;
144
- const destination = destinationConfigFailure(thrown, platform);
145
- if (destination !== undefined)
146
- return destination;
147
- const record = recordFormatFailure(thrown, options.destination);
148
- if (record !== undefined)
149
- return record;
150
- const read = (0, auth_1.failureOf)(thrown);
151
- const moved = typeof thrown === 'object' && thrown !== null
152
- ? UNSUPPORTED_HINTS.get(thrown)
153
- : undefined;
154
- if (read !== undefined && moved !== undefined) {
155
- return { ...read, hint: moved };
156
- }
157
- if (read?.authError === undefined || read.error !== 'authentication_failed')
158
- return read;
159
- // A sentence the reader already gave (the shutdown refusal's) stays.
160
- if (read.server !== undefined)
161
- return read;
162
- const server = options.sentenceFor?.(read.authError);
163
- return server === undefined ? read : { ...read, server };
164
- }
165
- catch {
166
- return undefined;
167
- }
168
- }
169
- /**
170
- * The words a failure is reported in on stderr at the start: the answer's
171
- * message, then its hint and the server's sentence, each on its own line;
172
- * else the destination and the error's class — never its message.
173
- */
174
- function destinationFailureWords(thrown, destination, options = {}) {
175
- const read = destinationFailureOf(thrown, { ...options, destination });
176
- if (read === undefined) {
177
- return `Destination "${destination}" cannot be read: ${(0, auth_1.errorClassOf)(thrown)}`;
178
- }
179
- return [read.message, read.hint, read.server]
180
- .filter((line) => line !== undefined)
181
- .join('\n');
182
- }
183
- //# sourceMappingURL=destinationFailure.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"destinationFailure.js","sourceRoot":"","sources":["../../src/auth/destinationFailure.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AA6KH,oDA2BC;AAOD,0DAYC;AAzND,2DAAqE;AACrE,2DAAqD;AAGrD,iDAMgC;AAGhC;;;;GAIG;AACH,MAAa,kBAAmB,SAAQ,oBAAa;IACnD,YAAY,KAAa;QACvB,KAAK,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AALD,gDAKC;AAED;;;GAGG;AACU,QAAA,aAAa,GACxB,8IAA8I,CAAC;AAEjJ;;GAEG;AACU,QAAA,kBAAkB,GAC7B,oMAAoM,CAAC;AAEvM,mGAAmG;AACnG,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAAkB,CAAC;AAExD;;;;;GAKG;AACH,MAAa,8BAA+B,SAAQ,oBAAa;IACtD,IAAI,GAAG,4BAAqC,CAAC;IAC7C,WAAW,CAAS;IACpB,QAAQ,CAAW;IACnB,SAAS,CAAoB;IAEtC,YACE,WAAmB,EACnB,QAAkB,EAClB,SAA4B;QAE5B,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,QAAQ,MAAM,SAAS,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;QAClE,KAAK,CACH,qBAAqB,EACrB,gBAAgB,WAAW,UAAU,KAAK,sCAAsC,CACjF,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAC;QAC7C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,SAAS;YAAE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QA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AG,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAClC,CAAC;QACD,IAAI,IAAI,EAAE,SAAS,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,KAAK,uBAAuB;YACzE,OAAO,IAAI,CAAC;QACd,qEAAqE;QACrE,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC;QAC3C,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACrD,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC;IAC3D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,uBAAuB,CACrC,MAAe,EACf,WAAmB,EACnB,UAAqC,EAAE;IAEvC,MAAM,IAAI,GAAG,oBAAoB,CAAC,MAAM,EAAE,EAAE,GAAG,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;IACvE,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,gBAAgB,WAAW,qBAAqB,IAAA,mBAAY,EAAC,MAAM,CAAC,EAAE,CAAC;IAChF,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;SAC1C,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC;SACpD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
@@ -1,55 +0,0 @@
1
- /**
2
- * The stores of one destination: where its means (`serviceKeyStore`) and its
3
- * secret (`sessionStore`) live. See the migration design, "Where a
4
- * destination lives".
5
- */
6
- import type { IServiceKeyStore, ISessionStore } from '@mcp-abap-adt/interfaces-auth-broker';
7
- import type { ILogger } from '@mcp-abap-adt/interfaces-utils';
8
- import { type DestinationSystemContext } from '@mcp-abap-adt/lib/auth';
9
- export type DestinationMode = {
10
- kind: 'envFile';
11
- path: string;
12
- /** The parameter as the user gave it, for the refusal. */
13
- source: string;
14
- } | {
15
- kind: 'named';
16
- name: string;
17
- keysDir: string;
18
- sessionsDir: string;
19
- unsafe: boolean;
20
- };
21
- export interface DestinationStores {
22
- serviceKeyStore: IServiceKeyStore;
23
- sessionStore: ISessionStore;
24
- /**
25
- * Where the connector's URL is read. An XSUAA destination's URL comes only
26
- * from `XSUAA_MCP_URL` in `sessions/<name>.env`, never from the key: the
27
- * key's root `url` is the UAA, which XsuaaServiceKeyStore may answer as
28
- * `serviceUrl`. Every other mode reads it from `serviceKeyStore`.
29
- */
30
- urlStore: IServiceKeyStore;
31
- /** The key the user sets the URL with, for the refusal. */
32
- urlKey: 'SAP_URL' | 'XSUAA_MCP_URL';
33
- /**
34
- * The destination's own `.env`: the `--env` file, or
35
- * `sessions/<name>.env` — the file its means store reads. Its
36
- * `SAP_RESPONSIBLE` / `SAP_USERNAME` / `SAP_MASTER_SYSTEM` are read from here
37
- * (`readDestinationSystemContext`).
38
- */
39
- destinationFile: string;
40
- }
41
- /**
42
- * `SAP_RESPONSIBLE`, `SAP_USERNAME` (the login), `SAP_MASTER_SYSTEM`,
43
- * `SAP_DEBUG_TERMINAL_ID`, `SAP_DEBUG_IDE_ID` and
44
- * `SAP_DEBUG_BREAKPOINT_CONFLICT` of a
45
- * destination's own `.env`; a key not stated, or a file that is absent or
46
- * unreadable, is absent from the answer. Nothing else in the file is kept.
47
- */
48
- export declare function readDestinationSystemContext(file: string): DestinationSystemContext;
49
- /**
50
- * The shape of `keysDir/<name>.json`: `url` + `clientid` + `clientsecret` at
51
- * the root is an XSUAA key; anything else, or no readable key, is ABAP.
52
- */
53
- export declare function keyShapeOf(keysDir: string, name: string): 'abap' | 'xsuaa';
54
- export declare function storesFor(mode: DestinationMode, logger?: ILogger): DestinationStores;
55
- //# sourceMappingURL=destinationStores.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"destinationStores.d.ts","sourceRoot":"","sources":["../../src/auth/destinationStores.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAeH,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACd,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,wBAAwB,CAAC;AAIhC,MAAM,MAAM,eAAe,GACvB;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,MAAM,EAAE,MAAM,CAAC;CAChB,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEN,MAAM,WAAW,iBAAiB;IAChC,eAAe,EAAE,gBAAgB,CAAC;IAClC,YAAY,EAAE,aAAa,CAAC;IAC5B;;;;;OAKG;IACH,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,2DAA2D;IAC3D,MAAM,EAAE,SAAS,GAAG,eAAe,CAAC;IACpC;;;;;OAKG;IACH,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,MAAM,GACX,wBAAwB,CAqB1B;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAoB1E;AAED,wBAAgB,SAAS,CACvB,IAAI,EAAE,eAAe,EACrB,MAAM,CAAC,EAAE,OAAO,GACf,iBAAiB,CA0DnB"}
@@ -1,158 +0,0 @@
1
- "use strict";
2
- /**
3
- * The stores of one destination: where its means (`serviceKeyStore`) and its
4
- * secret (`sessionStore`) live. See the migration design, "Where a
5
- * destination lives".
6
- */
7
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
- if (k2 === undefined) k2 = k;
9
- var desc = Object.getOwnPropertyDescriptor(m, k);
10
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
- desc = { enumerable: true, get: function() { return m[k]; } };
12
- }
13
- Object.defineProperty(o, k2, desc);
14
- }) : (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- o[k2] = m[k];
17
- }));
18
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
- Object.defineProperty(o, "default", { enumerable: true, value: v });
20
- }) : function(o, v) {
21
- o["default"] = v;
22
- });
23
- var __importStar = (this && this.__importStar) || (function () {
24
- var ownKeys = function(o) {
25
- ownKeys = Object.getOwnPropertyNames || function (o) {
26
- var ar = [];
27
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
- return ar;
29
- };
30
- return ownKeys(o);
31
- };
32
- return function (mod) {
33
- if (mod && mod.__esModule) return mod;
34
- var result = {};
35
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
- __setModuleDefault(result, mod);
37
- return result;
38
- };
39
- })();
40
- Object.defineProperty(exports, "__esModule", { value: true });
41
- exports.readDestinationSystemContext = readDestinationSystemContext;
42
- exports.keyShapeOf = keyShapeOf;
43
- exports.storesFor = storesFor;
44
- const fs = __importStar(require("node:fs"));
45
- const path = __importStar(require("node:path"));
46
- const auth_stores_1 = require("@mcp-abap-adt/auth-stores");
47
- const auth_1 = require("@mcp-abap-adt/lib/auth");
48
- const dotenv = __importStar(require("dotenv"));
49
- const destinationFailure_1 = require("./destinationFailure");
50
- /**
51
- * `SAP_RESPONSIBLE`, `SAP_USERNAME` (the login), `SAP_MASTER_SYSTEM`,
52
- * `SAP_DEBUG_TERMINAL_ID`, `SAP_DEBUG_IDE_ID` and
53
- * `SAP_DEBUG_BREAKPOINT_CONFLICT` of a
54
- * destination's own `.env`; a key not stated, or a file that is absent or
55
- * unreadable, is absent from the answer. Nothing else in the file is kept.
56
- */
57
- function readDestinationSystemContext(file) {
58
- let parsed;
59
- try {
60
- parsed = dotenv.parse(fs.readFileSync(file, 'utf8'));
61
- }
62
- catch {
63
- return {};
64
- }
65
- const responsible = parsed.SAP_RESPONSIBLE;
66
- const login = parsed.SAP_USERNAME;
67
- const masterSystem = parsed.SAP_MASTER_SYSTEM;
68
- const debugTerminalId = parsed.SAP_DEBUG_TERMINAL_ID;
69
- const debugIdeId = parsed.SAP_DEBUG_IDE_ID;
70
- const debugBreakpointConflict = parsed.SAP_DEBUG_BREAKPOINT_CONFLICT;
71
- return {
72
- ...(responsible ? { responsible } : {}),
73
- ...(login ? { login } : {}),
74
- ...(masterSystem ? { masterSystem } : {}),
75
- ...(debugTerminalId ? { debugTerminalId } : {}),
76
- ...(debugIdeId ? { debugIdeId } : {}),
77
- ...(debugBreakpointConflict ? { debugBreakpointConflict } : {}),
78
- };
79
- }
80
- /**
81
- * The shape of `keysDir/<name>.json`: `url` + `clientid` + `clientsecret` at
82
- * the root is an XSUAA key; anything else, or no readable key, is ABAP.
83
- */
84
- function keyShapeOf(keysDir, name) {
85
- (0, auth_1.assertDestinationName)(name, 'destination');
86
- try {
87
- const raw = JSON.parse(fs.readFileSync(path.join(keysDir, `${name}.json`), 'utf8'));
88
- if (raw &&
89
- typeof raw === 'object' &&
90
- !(raw.uaa && typeof raw.uaa === 'object') &&
91
- raw.url &&
92
- raw.clientid &&
93
- raw.clientsecret) {
94
- return 'xsuaa';
95
- }
96
- }
97
- catch {
98
- // no key, or not readable: read as ABAP
99
- }
100
- return 'abap';
101
- }
102
- function storesFor(mode, logger) {
103
- if (mode.kind === 'envFile') {
104
- if (!fs.existsSync(mode.path)) {
105
- throw new destinationFailure_1.DestinationRefusal(`${mode.source}: the file does not exist: ${mode.path}`);
106
- }
107
- const serviceKeyStore = auth_stores_1.EnvDestinationStore.forFile(mode.path, {
108
- log: logger,
109
- });
110
- return {
111
- serviceKeyStore,
112
- sessionStore: new auth_stores_1.EnvFileSessionStore(mode.path, logger),
113
- urlStore: serviceKeyStore,
114
- urlKey: 'SAP_URL',
115
- destinationFile: path.resolve(mode.path),
116
- };
117
- }
118
- (0, auth_1.assertDestinationName)(mode.name, 'destination');
119
- const destinationFile = path.join(mode.sessionsDir, `${mode.name}.env`);
120
- if (keyShapeOf(mode.keysDir, mode.name) === 'xsuaa') {
121
- return {
122
- serviceKeyStore: new auth_stores_1.EnvDestinationStore(mode.sessionsDir, {
123
- variables: auth_stores_1.XSUAA_DESTINATION_VARS,
124
- fallback: new auth_stores_1.XsuaaServiceKeyStore(mode.keysDir, {
125
- grantType: 'authorization_code',
126
- log: logger,
127
- }),
128
- log: logger,
129
- }),
130
- sessionStore: mode.unsafe
131
- ? new auth_stores_1.XsuaaSessionStore(mode.sessionsDir, logger)
132
- : new auth_stores_1.SafeXsuaaSessionStore(logger),
133
- urlStore: new auth_stores_1.EnvDestinationStore(mode.sessionsDir, {
134
- variables: auth_stores_1.XSUAA_DESTINATION_VARS,
135
- log: logger,
136
- }),
137
- urlKey: 'XSUAA_MCP_URL',
138
- destinationFile,
139
- };
140
- }
141
- const serviceKeyStore = new auth_stores_1.EnvDestinationStore(mode.sessionsDir, {
142
- fallback: new auth_stores_1.AbapServiceKeyStore(mode.keysDir, {
143
- grantType: 'authorization_code',
144
- log: logger,
145
- }),
146
- log: logger,
147
- });
148
- return {
149
- serviceKeyStore,
150
- sessionStore: mode.unsafe
151
- ? new auth_stores_1.AbapSessionStore(mode.sessionsDir, logger)
152
- : new auth_stores_1.SafeAbapSessionStore(logger),
153
- urlStore: serviceKeyStore,
154
- urlKey: 'SAP_URL',
155
- destinationFile,
156
- };
157
- }
158
- //# sourceMappingURL=destinationStores.js.map
@@ -1 +0,0 @@
1
- {"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AAI,CAAC,OAAO,EAAE;YAC9C,SAAS,EAAE,oBAAoB;YAC/B,GAAG,EAAE,MAAM;SACZ,CAAC;QACF,GAAG,EAAE,MAAM;KACZ,CAAC,CAAC;IACH,OAAO;QACL,eAAe;QACf,YAAY,EAAE,IAAI,CAAC,MAAM;YACvB,CAAC,CAAC,IAAI,8BAAgB,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC;YAChD,CAAC,CAAC,IAAI,kCAAoB,CAAC,MAAM,CAAC;QACpC,QAAQ,EAAE,eAAe;QACzB,MAAM,EAAE,SAAS;QACjB,eAAe;KAChB,CAAC;AACJ,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { AuthenticationHandler } from './types.js';
2
- export declare const basicHandler: AuthenticationHandler;
3
- //# sourceMappingURL=basic.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"basic.d.ts","sourceRoot":"","sources":["../../../src/auth/handlers/basic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,eAAO,MAAM,YAAY,EAAE,qBAG1B,CAAC"}
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.basicHandler = void 0;
4
- exports.basicHandler = {
5
- authType: 'basic',
6
- brokerOptions: () => ({}),
7
- };
8
- //# sourceMappingURL=basic.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"basic.js","sourceRoot":"","sources":["../../../src/auth/handlers/basic.ts"],"names":[],"mappings":";;;AAEa,QAAA,YAAY,GAA0B;IACjD,QAAQ,EAAE,OAAO;IACjB,aAAa,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;CAC1B,CAAC"}
@@ -1,15 +0,0 @@
1
- /**
2
- * The authentications this server supports — exactly these three: `basic`,
3
- * `snc` and `jwt` / `authorization_code`. Adding one means a handler here, the
4
- * docs' table and a test; nothing else. `jwt` / `none` (a token you hold) is
5
- * not one: it is refused like any authentication not here, and the
6
- * refusal says where it went — the `x-sap-jwt-token` header of
7
- * `mcp-abap-adt-http` / `mcp-abap-adt-sse`.
8
- */
9
- import type { VettedAuthentication } from '../vocabulary';
10
- import type { AuthenticationHandler } from './types.js';
11
- export type { AuthenticationHandler, AuthHandlerContext } from './types.js';
12
- export declare const HANDLERS: readonly AuthenticationHandler[];
13
- /** The handler for a vetted authentication; throws `UnsupportedAuthenticationError`. */
14
- export declare function handlerFor(destination: string, vetted: VettedAuthentication): AuthenticationHandler;
15
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/handlers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAI1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,YAAY,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAE5E,eAAO,MAAM,QAAQ,EAAE,SAAS,qBAAqB,EAIpD,CAAC;AASF,wFAAwF;AACxF,wBAAgB,UAAU,CACxB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,oBAAoB,GAC3B,qBAAqB,CAUvB"}