@mcp-abap-adt/connection 9.4.2 → 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 +175 -1
  2. package/README.md +77 -36
  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 +30 -10
  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 +4 -3
  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
@@ -8,6 +8,7 @@ This directory contains example code demonstrating how to use the `@mcp-abap-adt
8
8
  # Install dependencies
9
9
  cd packages/connection
10
10
  npm install
11
+ npm install @mcp-abap-adt/auth-providers # the credential providers the examples use
11
12
 
12
13
  # Build the package
13
14
  npm run build
@@ -42,9 +43,9 @@ node examples/jwt-with-token-refresh.js
42
43
  ```
43
44
 
44
45
  **What it demonstrates:**
45
- - Creating connection with token refresher injection
46
- - Automatic token refresh on 401 errors
47
- - Retry logic with refreshed token
46
+ - Creating connection with `TokenAuthProvider.from(refresher)` (from `@mcp-abap-adt/auth-providers`)
47
+ - A 401 put to the provider, which renews the token
48
+ - Exactly one more attempt with the renewed token
48
49
  - A 403 propagating untouched, with its status and body intact
49
50
 
50
51
  ### saml-connection.js
@@ -56,7 +57,7 @@ node examples/saml-connection.js
56
57
  ```
57
58
 
58
59
  **What it demonstrates:**
59
- - Creating SAML connection via factory (`authType: "saml"`)
60
+ - Creating a SAML connection with `SamlAuthProvider` (from `@mcp-abap-adt/auth-providers`)
60
61
  - Using `sessionCookies` from environment
61
62
  - Fetching CSRF token and making ADT request with cookie auth
62
63
 
@@ -7,8 +7,8 @@
7
7
  const {
8
8
  OnPremHttpTransport,
9
9
  AdtOnPremConnector,
10
- BasicAuthProvider,
11
10
  } = require('@mcp-abap-adt/connection');
11
+ const { BasicAuthProvider } = require('@mcp-abap-adt/auth-providers');
12
12
 
13
13
  async function main() {
14
14
  // Configuration from environment or hardcoded
@@ -4,11 +4,12 @@
4
4
  * This example demonstrates how to create a cloud connection with
5
5
  * automatic token refresh using ITokenRefresher from auth-broker.
6
6
  *
7
- * When a **401** occurs, the connection automatically:
7
+ * When a **401** survives the wire's own session recovery, the connection
8
+ * puts it to the provider (`rejected`). `TokenAuthProvider.from` then:
8
9
  * 1. Calls tokenRefresher.refreshToken() to get a new token
9
- * 2. Updates internal token state
10
- * 3. Re-establishes the SAP session, which the new credential cannot inherit
11
- * 4. Retries the failed request
10
+ * 2. Answers Ok, so the connection authorizes the request again
11
+ * 3. The request is sent exactly once more; a second refusal is an
12
+ * AuthRefusedError carrying the provider's words
12
13
  *
13
14
  * A **403** is left alone. It means the server authenticated you and refused
14
15
  * the action anyway — an authorization gap, not an expired credential — so it
@@ -19,8 +20,8 @@
19
20
  const {
20
21
  CloudHttpTransport,
21
22
  AdtCloudConnector,
22
- TokenAuthProvider,
23
23
  } = require('@mcp-abap-adt/connection');
24
+ const { TokenAuthProvider } = require('@mcp-abap-adt/auth-providers');
24
25
  // const { AuthBroker } = require('@mcp-abap-adt/auth-broker');
25
26
 
26
27
  // Simple logger
@@ -66,12 +67,12 @@ async function main() {
66
67
  jwtToken: initialToken,
67
68
  };
68
69
 
69
- // The refresher IS the credential: `TokenAuthProvider` asks it for a token on
70
- // every request, so a provider that renews on expiry renews without anyone
71
- // here deciding to. A bare string would be a token with nothing behind it.
70
+ // The refresher IS the credential: the provider asks it for a token before
71
+ // every attempt and renews when the system refuses one. `.fixed(token)` would
72
+ // be a token with nothing behind it.
72
73
  const connection = new AdtCloudConnector(
73
74
  config,
74
- new TokenAuthProvider(tokenRefresher),
75
+ TokenAuthProvider.from(tokenRefresher),
75
76
  new CloudHttpTransport(() => ({}), console, {
76
77
  client: config.client,
77
78
  baseUrl: config.url,
@@ -82,12 +83,10 @@ async function main() {
82
83
  try {
83
84
  await connection.connect();
84
85
 
85
- // This request will automatically refresh the token if a 401 occurs. A
86
- // 403 arrives as-is — read err.response.status and err.response.data to
87
- // see which authorization object the server named. Note
88
- // that a refresh replaces the SAP session: with a lock window open the
89
- // request would fail with ADT_SESSION_REPLACED rather than continue on a
90
- // session your lock is not in.
86
+ // If a 401 survives the session recovery, the provider is asked once and
87
+ // the request is retried once. A 403 arrives as-is — read
88
+ // err.response.status and err.response.data to see which authorization
89
+ // object the server named.
91
90
  const response = await connection.makeAdtRequest({
92
91
  method: 'GET',
93
92
  url: '/sap/bc/adt/discovery',
@@ -8,8 +8,8 @@
8
8
  const {
9
9
  OnPremHttpTransport,
10
10
  AdtOnPremConnector,
11
- SamlAuthProvider,
12
11
  } = require('@mcp-abap-adt/connection');
12
+ const { SamlAuthProvider } = require('@mcp-abap-adt/auth-providers');
13
13
 
14
14
  async function main() {
15
15
  const config = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-abap-adt/connection",
3
- "version": "9.4.2",
3
+ "version": "10.0.1",
4
4
  "description": "ABAP connection layer for MCP ABAP ADT server",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -54,8 +54,8 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@mcp-abap-adt/interfaces-adt-connection": "^1.0.0",
57
- "@mcp-abap-adt/interfaces-auth": "^2.0.1",
58
- "@mcp-abap-adt/interfaces-auth-sap": "^1.0.1",
57
+ "@mcp-abap-adt/interfaces-auth": "^3.0.0",
58
+ "@mcp-abap-adt/interfaces-auth-sap": "^1.1.0",
59
59
  "@mcp-abap-adt/interfaces-network": "^2.0.0",
60
60
  "@mcp-abap-adt/interfaces-utils": "^1.1.0",
61
61
  "axios": "^1.16.0",
@@ -67,6 +67,7 @@
67
67
  },
68
68
  "devDependencies": {
69
69
  "@biomejs/biome": "^2.3.14",
70
+ "@mcp-abap-adt/auth-providers": "^5.0.1",
70
71
  "@types/jest": "^30.0.0",
71
72
  "@types/node": "^25.2.3",
72
73
  "dotenv": "^17.3.1",
@@ -1,6 +0,0 @@
1
- import type { ICertificateMaterial } from '@mcp-abap-adt/interfaces-auth';
2
- import type { ICertificateMaterialLoader, ISapConfig } from '@mcp-abap-adt/interfaces-auth-sap';
3
- export declare class FileCertificateMaterialLoader implements ICertificateMaterialLoader {
4
- load(config: ISapConfig): Promise<ICertificateMaterial>;
5
- }
6
- //# sourceMappingURL=FileCertificateMaterialLoader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileCertificateMaterialLoader.d.ts","sourceRoot":"","sources":["../../src/auth/FileCertificateMaterialLoader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,KAAK,EACV,0BAA0B,EAC1B,UAAU,EACX,MAAM,mCAAmC,CAAC;AAE3C,qBAAa,6BACX,YAAW,0BAA0B;IAE/B,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAyB9D"}
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileCertificateMaterialLoader = void 0;
4
- const promises_1 = require("node:fs/promises");
5
- class FileCertificateMaterialLoader {
6
- async load(config) {
7
- const hasPem = !!(config.certPath || config.certKeyPath); // any PEM-style field present
8
- const hasPfx = !!config.certPfxPath;
9
- if (hasPem && hasPfx) {
10
- throw new Error('Certificate auth: provide either PEM (certPath+certKeyPath) OR certPfxPath, not both.');
11
- }
12
- if (hasPfx) {
13
- return {
14
- pfx: await (0, promises_1.readFile)(config.certPfxPath),
15
- passphrase: config.certPassphrase,
16
- };
17
- }
18
- if (config.certPath && config.certKeyPath) {
19
- return {
20
- cert: await (0, promises_1.readFile)(config.certPath),
21
- key: await (0, promises_1.readFile)(config.certKeyPath),
22
- passphrase: config.certPassphrase,
23
- };
24
- }
25
- throw new Error('Certificate auth requires certPfxPath OR (certPath AND certKeyPath).');
26
- }
27
- }
28
- exports.FileCertificateMaterialLoader = FileCertificateMaterialLoader;
@@ -1,26 +0,0 @@
1
- /**
2
- * Detect whether a WWW-Authenticate header (or a Negotiate challenge token) indicates NTLM.
3
- * NTLM is rejected: only Kerberos/SPNEGO Negotiate is acceptable.
4
- *
5
- * Two cases:
6
- * - the header offers the NTLM scheme directly: `WWW-Authenticate: NTLM`
7
- * - an NTLM token tunneled via Negotiate: `Negotiate <base64>` where the base64 decodes to
8
- * bytes starting with the NTLM signature "NTLMSSP\0" (base64 prefix "TlRMTVNTUAA").
9
- */
10
- export declare function isNtlmChallenge(wwwAuthenticate: string | undefined): boolean;
11
- /**
12
- * `Negotiate <gssapi-data>` — the server has handed back a token for the client
13
- * to feed into its GSS context and retry (RFC 4559 continuation).
14
- */
15
- export declare function isNegotiateContinuation(wwwAuthenticate: string | undefined): boolean;
16
- /**
17
- * A bare `Negotiate`, with no token.
18
- *
19
- * Told apart from a continuation deliberately: once the client has ALREADY sent
20
- * its initial Authorization, a bare challenge is the server declining it — the
21
- * credentials were not accepted. There is no server token here, so nothing
22
- * could be stepped even by a client that supports multi-leg. Diagnosing the two
23
- * alike sends the reader after the wrong problem.
24
- */
25
- export declare function isBareNegotiateChallenge(wwwAuthenticate: string | undefined): boolean;
26
- //# sourceMappingURL=ntlm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ntlm.d.ts","sourceRoot":"","sources":["../../src/auth/ntlm.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAiB5E;AAcD;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,eAAe,EAAE,MAAM,GAAG,SAAS,GAClC,OAAO,CAKT;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,MAAM,GAAG,SAAS,GAClC,OAAO,CAIT"}
package/dist/auth/ntlm.js DELETED
@@ -1,72 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isNtlmChallenge = isNtlmChallenge;
4
- exports.isNegotiateContinuation = isNegotiateContinuation;
5
- exports.isBareNegotiateChallenge = isBareNegotiateChallenge;
6
- /**
7
- * Detect whether a WWW-Authenticate header (or a Negotiate challenge token) indicates NTLM.
8
- * NTLM is rejected: only Kerberos/SPNEGO Negotiate is acceptable.
9
- *
10
- * Two cases:
11
- * - the header offers the NTLM scheme directly: `WWW-Authenticate: NTLM`
12
- * - an NTLM token tunneled via Negotiate: `Negotiate <base64>` where the base64 decodes to
13
- * bytes starting with the NTLM signature "NTLMSSP\0" (base64 prefix "TlRMTVNTUAA").
14
- */
15
- function isNtlmChallenge(wwwAuthenticate) {
16
- if (!wwwAuthenticate)
17
- return false;
18
- const value = wwwAuthenticate.trim();
19
- if (!value)
20
- return false;
21
- // Split on commas to handle multiple offered schemes, e.g. "Negotiate, NTLM"
22
- const parts = value.split(',').map((p) => p.trim());
23
- for (const part of parts) {
24
- const lower = part.toLowerCase();
25
- // direct NTLM scheme offer (word-boundary, not e.g. "Negotiate")
26
- if (/^ntlm\b/i.test(part))
27
- return true;
28
- // NTLM tunneled inside a Negotiate token
29
- if (lower.startsWith('negotiate ')) {
30
- const token = part.slice('negotiate '.length).trim();
31
- if (token.startsWith('TlRMTVNTUAA'))
32
- return true; // base64("NTLMSSP\0")
33
- }
34
- }
35
- return false;
36
- }
37
- /**
38
- * A `Negotiate` challenge that is not NTLM in disguise. Says nothing about
39
- * whether it carries a token — callers that care must ask which kind it is.
40
- */
41
- function isNegotiate(wwwAuthenticate) {
42
- if (!wwwAuthenticate)
43
- return false;
44
- if (isNtlmChallenge(wwwAuthenticate))
45
- return false;
46
- return wwwAuthenticate
47
- .split(',')
48
- .some((part) => /^negotiate\b/i.test(part.trim()));
49
- }
50
- /**
51
- * `Negotiate <gssapi-data>` — the server has handed back a token for the client
52
- * to feed into its GSS context and retry (RFC 4559 continuation).
53
- */
54
- function isNegotiateContinuation(wwwAuthenticate) {
55
- if (!isNegotiate(wwwAuthenticate))
56
- return false;
57
- return wwwAuthenticate
58
- .split(',')
59
- .some((part) => /^negotiate\s+\S/i.test(part.trim()));
60
- }
61
- /**
62
- * A bare `Negotiate`, with no token.
63
- *
64
- * Told apart from a continuation deliberately: once the client has ALREADY sent
65
- * its initial Authorization, a bare challenge is the server declining it — the
66
- * credentials were not accepted. There is no server token here, so nothing
67
- * could be stepped even by a client that supports multi-leg. Diagnosing the two
68
- * alike sends the reader after the wrong problem.
69
- */
70
- function isBareNegotiateChallenge(wwwAuthenticate) {
71
- return (isNegotiate(wwwAuthenticate) && !isNegotiateContinuation(wwwAuthenticate));
72
- }
@@ -1,125 +0,0 @@
1
- /**
2
- * The credentials a connector can be handed.
3
- *
4
- * Each is the authentication half of one of the connection classes that used to
5
- * carry both halves, lifted out unchanged — the header a `BasicAuthProvider`
6
- * builds is byte for byte what `BaseAbapConnection` built, and the TLS options a
7
- * `CertificateAuthProvider` returns are what `CertificateAbapConnection`
8
- * returned. Nothing about how a credential works changed; only who owns it.
9
- */
10
- import type { IAuthProvider, ICertificateMaterial, IRenewableCredential, ITokenRefresher } from '@mcp-abap-adt/interfaces-auth';
11
- import type { ICertificateMaterialLoader, ISapConfig } from '@mcp-abap-adt/interfaces-auth-sap';
12
- /** Username and password, as `Basic base64(user:pass)`. */
13
- export declare class BasicAuthProvider implements IAuthProvider {
14
- private readonly username;
15
- private readonly password;
16
- readonly kind = "basic";
17
- /** Nothing to get ready: this credential is complete as constructed. */
18
- prepare(): Promise<void>;
19
- /** Not cookies. This one authenticates with a header. */
20
- cookies(): string | null;
21
- /** No TLS material: this credential lives in a header, not in the transport. */
22
- transportMaterial(): ICertificateMaterial;
23
- constructor(username: string, password: string);
24
- authorizationHeader(): Promise<string | null>;
25
- }
26
- /**
27
- * A bearer token, kept current by whoever issued it.
28
- *
29
- * Takes an `ITokenRefresher` — the contract `@mcp-abap-adt/auth-broker` already
30
- * produces and `@mcp-abap-adt/auth-providers` already implements twelve ways.
31
- * This package depends on neither: it speaks the contract, and the consumer
32
- * brings the implementation, exactly as it does for `IAbapConnection`.
33
- *
34
- * **This carries no session recovery.** What happens to a session when the
35
- * credential behind it is renewed mid-flight is the connection's business and
36
- * stays there; see `JwtAbapConnection`, which still owns that machinery.
37
- */
38
- export declare class TokenAuthProvider implements IRenewableCredential {
39
- private readonly source;
40
- readonly kind = "token";
41
- /** Nothing to get ready: this credential is complete as constructed. */
42
- prepare(): Promise<void>;
43
- /** Not cookies. This one authenticates with a header. */
44
- cookies(): string | null;
45
- /** No TLS material: this credential lives in a header, not in the transport. */
46
- transportMaterial(): ICertificateMaterial;
47
- /**
48
- * A token, or something that can produce one.
49
- *
50
- * A bare string is a token with no renewal behind it — honest, and fine for a
51
- * short task. An `ITokenRefresher` or a function is a provider that checks
52
- * expiry and renews on its own, which is where this belongs in a long-lived
53
- * process.
54
- */
55
- constructor(source: string | ITokenRefresher | (() => Promise<string>));
56
- /**
57
- * Asked every time, and nothing kept.
58
- *
59
- * The provider behind this already caches the token, knows when it expires,
60
- * and renews before handing one back. A second cache here would serve the
61
- * stale one and hide exactly the renewal the provider exists to do — which
62
- * is what the first version of this class did.
63
- */
64
- authorizationHeader(): Promise<string | null>;
65
- /**
66
- * The token was refused, so force a new one.
67
- *
68
- * Declared through `IRenewableCredential` rather than as an optional member
69
- * of every credential, so a consumer narrows to it: a password has nothing
70
- * behind it to ask again, and a SAML session was negotiated elsewhere.
71
- *
72
- * **Nothing in this package calls it.** A token that EXPIRED is replaced
73
- * inside `authorizationHeader()` above, which is asked per request — nobody
74
- * decides anything. This is the other case, a token the source still believes
75
- * in and the server refuses, and whether a refusal meant that is a judgement
76
- * made with what the caller knows. So the refusal surfaces, and this is the
77
- * seam the caller decides with.
78
- *
79
- * `getToken()` is documented to return the cached token while it believes it
80
- * is still valid — which is exactly the situation after a 401 on a token the
81
- * provider has not yet noticed is dead. `refreshToken()` is the contract's
82
- * answer for that, and this is the only place it is called.
83
- */
84
- renew(): Promise<void>;
85
- }
86
- /**
87
- * A SAML session, already negotiated, presented as cookies.
88
- *
89
- * No `Authorization` header at all — the cookies are the credential, and they
90
- * are added by the connection alongside its own.
91
- */
92
- export declare class SamlAuthProvider implements IAuthProvider {
93
- private readonly sessionCookies;
94
- readonly kind = "saml";
95
- /** Nothing to get ready: this credential is complete as constructed. */
96
- prepare(): Promise<void>;
97
- /** No TLS material: this credential lives in a header, not in the transport. */
98
- transportMaterial(): ICertificateMaterial;
99
- constructor(sessionCookies: string);
100
- /** Not a header: this credential authenticates with the cookies below. */
101
- authorizationHeader(): Promise<string | null>;
102
- /** The cookies to present. */
103
- cookies(): string;
104
- }
105
- /**
106
- * Client certificate: the credential lives in the TLS handshake.
107
- *
108
- * `prepare()` is where the material is read, which is why it exists at all —
109
- * building an agent before it is loaded is what used to reject a connect
110
- * before a single request went out.
111
- */
112
- export declare class CertificateAuthProvider implements IAuthProvider {
113
- private readonly loader;
114
- private readonly config;
115
- readonly kind = "certificate";
116
- /** Not cookies. This one authenticates with a header. */
117
- cookies(): string | null;
118
- private material;
119
- constructor(loader: ICertificateMaterialLoader, config: ISapConfig);
120
- prepare(): Promise<void>;
121
- /** Not a header: this credential authenticates through TLS. */
122
- authorizationHeader(): Promise<string | null>;
123
- transportMaterial(): ICertificateMaterial;
124
- }
125
- //# sourceMappingURL=providers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/auth/providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EAChB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EACV,0BAA0B,EAC1B,UAAU,EACX,MAAM,mCAAmC,CAAC;AAE3C,2DAA2D;AAC3D,qBAAa,iBAAkB,YAAW,aAAa;IAiBnD,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAjB3B,QAAQ,CAAC,IAAI,WAAW;IAExB,wEAAwE;IAClE,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B,yDAAyD;IACzD,OAAO,IAAI,MAAM,GAAG,IAAI;IAIxB,gFAAgF;IAChF,iBAAiB,IAAI,oBAAoB;gBAKtB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM;IAG7B,mBAAmB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAGpD;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,iBAAkB,YAAW,oBAAoB;IAyB1D,OAAO,CAAC,QAAQ,CAAC,MAAM;IAxBzB,QAAQ,CAAC,IAAI,WAAW;IAExB,wEAAwE;IAClE,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B,yDAAyD;IACzD,OAAO,IAAI,MAAM,GAAG,IAAI;IAIxB,gFAAgF;IAChF,iBAAiB,IAAI,oBAAoB;IAIzC;;;;;;;OAOG;gBAEgB,MAAM,EAAE,MAAM,GAAG,eAAe,GAAG,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAG7E;;;;;;;OAOG;IACG,mBAAmB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAUnD;;;;;;;;;;;;;;;;;;OAkBG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ7B;AAED;;;;;GAKG;AACH,qBAAa,gBAAiB,YAAW,aAAa;IAWxC,OAAO,CAAC,QAAQ,CAAC,cAAc;IAV3C,QAAQ,CAAC,IAAI,UAAU;IAEvB,wEAAwE;IAClE,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B,gFAAgF;IAChF,iBAAiB,IAAI,oBAAoB;gBAIZ,cAAc,EAAE,MAAM;IAEnD,0EAA0E;IACpE,mBAAmB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAInD,8BAA8B;IAC9B,OAAO,IAAI,MAAM;CAGlB;AAED;;;;;;GAMG;AACH,qBAAa,uBAAwB,YAAW,aAAa;IAWzD,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAXzB,QAAQ,CAAC,IAAI,iBAAiB;IAE9B,yDAAyD;IACzD,OAAO,IAAI,MAAM,GAAG,IAAI;IAIxB,OAAO,CAAC,QAAQ,CAAqC;gBAGlC,MAAM,EAAE,0BAA0B,EAClC,MAAM,EAAE,UAAU;IAG/B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAM9B,+DAA+D;IACzD,mBAAmB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAInD,iBAAiB,IAAI,oBAAoB;CAS1C"}
@@ -1,183 +0,0 @@
1
- "use strict";
2
- /**
3
- * The credentials a connector can be handed.
4
- *
5
- * Each is the authentication half of one of the connection classes that used to
6
- * carry both halves, lifted out unchanged — the header a `BasicAuthProvider`
7
- * builds is byte for byte what `BaseAbapConnection` built, and the TLS options a
8
- * `CertificateAuthProvider` returns are what `CertificateAbapConnection`
9
- * returned. Nothing about how a credential works changed; only who owns it.
10
- */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.CertificateAuthProvider = exports.SamlAuthProvider = exports.TokenAuthProvider = exports.BasicAuthProvider = void 0;
13
- /** Username and password, as `Basic base64(user:pass)`. */
14
- class BasicAuthProvider {
15
- username;
16
- password;
17
- kind = 'basic';
18
- /** Nothing to get ready: this credential is complete as constructed. */
19
- async prepare() { }
20
- /** Not cookies. This one authenticates with a header. */
21
- cookies() {
22
- return null;
23
- }
24
- /** No TLS material: this credential lives in a header, not in the transport. */
25
- transportMaterial() {
26
- return {};
27
- }
28
- constructor(username, password) {
29
- this.username = username;
30
- this.password = password;
31
- }
32
- async authorizationHeader() {
33
- return `Basic ${Buffer.from(`${this.username ?? ''}:${this.password ?? ''}`).toString('base64')}`;
34
- }
35
- }
36
- exports.BasicAuthProvider = BasicAuthProvider;
37
- /**
38
- * A bearer token, kept current by whoever issued it.
39
- *
40
- * Takes an `ITokenRefresher` — the contract `@mcp-abap-adt/auth-broker` already
41
- * produces and `@mcp-abap-adt/auth-providers` already implements twelve ways.
42
- * This package depends on neither: it speaks the contract, and the consumer
43
- * brings the implementation, exactly as it does for `IAbapConnection`.
44
- *
45
- * **This carries no session recovery.** What happens to a session when the
46
- * credential behind it is renewed mid-flight is the connection's business and
47
- * stays there; see `JwtAbapConnection`, which still owns that machinery.
48
- */
49
- class TokenAuthProvider {
50
- source;
51
- kind = 'token';
52
- /** Nothing to get ready: this credential is complete as constructed. */
53
- async prepare() { }
54
- /** Not cookies. This one authenticates with a header. */
55
- cookies() {
56
- return null;
57
- }
58
- /** No TLS material: this credential lives in a header, not in the transport. */
59
- transportMaterial() {
60
- return {};
61
- }
62
- /**
63
- * A token, or something that can produce one.
64
- *
65
- * A bare string is a token with no renewal behind it — honest, and fine for a
66
- * short task. An `ITokenRefresher` or a function is a provider that checks
67
- * expiry and renews on its own, which is where this belongs in a long-lived
68
- * process.
69
- */
70
- constructor(source) {
71
- this.source = source;
72
- }
73
- /**
74
- * Asked every time, and nothing kept.
75
- *
76
- * The provider behind this already caches the token, knows when it expires,
77
- * and renews before handing one back. A second cache here would serve the
78
- * stale one and hide exactly the renewal the provider exists to do — which
79
- * is what the first version of this class did.
80
- */
81
- async authorizationHeader() {
82
- const token = typeof this.source === 'string'
83
- ? this.source
84
- : typeof this.source === 'function'
85
- ? await this.source()
86
- : await this.source.getToken();
87
- return token ? `Bearer ${token}` : '';
88
- }
89
- /**
90
- * The token was refused, so force a new one.
91
- *
92
- * Declared through `IRenewableCredential` rather than as an optional member
93
- * of every credential, so a consumer narrows to it: a password has nothing
94
- * behind it to ask again, and a SAML session was negotiated elsewhere.
95
- *
96
- * **Nothing in this package calls it.** A token that EXPIRED is replaced
97
- * inside `authorizationHeader()` above, which is asked per request — nobody
98
- * decides anything. This is the other case, a token the source still believes
99
- * in and the server refuses, and whether a refusal meant that is a judgement
100
- * made with what the caller knows. So the refusal surfaces, and this is the
101
- * seam the caller decides with.
102
- *
103
- * `getToken()` is documented to return the cached token while it believes it
104
- * is still valid — which is exactly the situation after a 401 on a token the
105
- * provider has not yet noticed is dead. `refreshToken()` is the contract's
106
- * answer for that, and this is the only place it is called.
107
- */
108
- async renew() {
109
- if (typeof this.source === 'string' || typeof this.source === 'function') {
110
- // Nothing to force: a fixed token has no source, and a function is asked
111
- // afresh every time anyway.
112
- return;
113
- }
114
- await this.source.refreshToken();
115
- }
116
- }
117
- exports.TokenAuthProvider = TokenAuthProvider;
118
- /**
119
- * A SAML session, already negotiated, presented as cookies.
120
- *
121
- * No `Authorization` header at all — the cookies are the credential, and they
122
- * are added by the connection alongside its own.
123
- */
124
- class SamlAuthProvider {
125
- sessionCookies;
126
- kind = 'saml';
127
- /** Nothing to get ready: this credential is complete as constructed. */
128
- async prepare() { }
129
- /** No TLS material: this credential lives in a header, not in the transport. */
130
- transportMaterial() {
131
- return {};
132
- }
133
- constructor(sessionCookies) {
134
- this.sessionCookies = sessionCookies;
135
- }
136
- /** Not a header: this credential authenticates with the cookies below. */
137
- async authorizationHeader() {
138
- return null;
139
- }
140
- /** The cookies to present. */
141
- cookies() {
142
- return this.sessionCookies;
143
- }
144
- }
145
- exports.SamlAuthProvider = SamlAuthProvider;
146
- /**
147
- * Client certificate: the credential lives in the TLS handshake.
148
- *
149
- * `prepare()` is where the material is read, which is why it exists at all —
150
- * building an agent before it is loaded is what used to reject a connect
151
- * before a single request went out.
152
- */
153
- class CertificateAuthProvider {
154
- loader;
155
- config;
156
- kind = 'certificate';
157
- /** Not cookies. This one authenticates with a header. */
158
- cookies() {
159
- return null;
160
- }
161
- material = null;
162
- constructor(loader, config) {
163
- this.loader = loader;
164
- this.config = config;
165
- }
166
- async prepare() {
167
- if (!this.material) {
168
- this.material = await this.loader.load(this.config);
169
- }
170
- }
171
- /** Not a header: this credential authenticates through TLS. */
172
- async authorizationHeader() {
173
- return null;
174
- }
175
- transportMaterial() {
176
- if (!this.material) {
177
- throw new Error('CertificateAuthProvider: certificate material not loaded. connect() prepares it; a request before that has nothing to present.');
178
- }
179
- const { cert, key, pfx, passphrase } = this.material;
180
- return { cert, key, pfx, passphrase };
181
- }
182
- }
183
- exports.CertificateAuthProvider = CertificateAuthProvider;
@@ -1,15 +0,0 @@
1
- /**
2
- * Token refresh utilities for JWT authentication
3
- */
4
- import type { ITokenRefreshResult } from '@mcp-abap-adt/interfaces-auth';
5
- export type TokenRefreshResult = ITokenRefreshResult;
6
- /**
7
- * Refreshes the access token using refresh token
8
- * @param refreshToken Refresh token
9
- * @param uaaUrl UAA URL (e.g., https://your-account.authentication.eu10.hana.ondemand.com)
10
- * @param clientId UAA client ID
11
- * @param clientSecret UAA client secret
12
- * @returns Promise that resolves to new tokens
13
- */
14
- export declare function refreshJwtToken(refreshToken: string, uaaUrl: string, clientId: string, clientSecret: string): Promise<ITokenRefreshResult>;
15
- //# sourceMappingURL=tokenRefresh.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tokenRefresh.d.ts","sourceRoot":"","sources":["../../src/utils/tokenRefresh.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAIzE,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AAErD;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,mBAAmB,CAAC,CA0C9B"}