@mcp-abap-adt/connection 9.4.1 → 10.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +187 -1
- package/README.md +80 -38
- package/dist/connection/AbstractAbapConnection.d.ts +211 -56
- package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
- package/dist/connection/AbstractAbapConnection.js +622 -255
- package/dist/connection/CloudHttpTransport.d.ts.map +1 -1
- package/dist/connection/CloudHttpTransport.js +15 -5
- package/dist/connection/CredentialAbapConnection.d.ts +21 -20
- package/dist/connection/CredentialAbapConnection.d.ts.map +1 -1
- package/dist/connection/CredentialAbapConnection.js +39 -46
- package/dist/connection/HttpTransport.d.ts +30 -14
- package/dist/connection/HttpTransport.d.ts.map +1 -1
- package/dist/connection/HttpTransport.js +99 -19
- package/dist/connection/IAdtTransport.d.ts +19 -2
- package/dist/connection/IAdtTransport.d.ts.map +1 -1
- package/dist/connection/OnPremHttpTransport.d.ts.map +1 -1
- package/dist/connection/OnPremHttpTransport.js +4 -3
- package/dist/connection/RfcTransport.d.ts +23 -3
- package/dist/connection/RfcTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.js +48 -15
- package/dist/connection/authErrors.d.ts +61 -0
- package/dist/connection/authErrors.d.ts.map +1 -0
- package/dist/connection/authErrors.js +78 -0
- package/dist/connection/requestTarget.d.ts +12 -0
- package/dist/connection/requestTarget.d.ts.map +1 -0
- package/dist/connection/requestTarget.js +23 -0
- package/dist/connection/rfcConversation.d.ts +10 -5
- package/dist/connection/rfcConversation.d.ts.map +1 -1
- package/dist/connection/rfcConversation.js +6 -8
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -12
- package/dist/session/SessionLifecycle.d.ts +1 -1
- package/dist/session/SessionLifecycle.d.ts.map +1 -1
- package/docs/INDEX.md +4 -1
- package/docs/INSTALLATION.md +12 -5
- package/docs/JWT_AUTH_TOOLS.md +2 -2
- package/docs/MIGRATION-10.0.md +284 -0
- package/docs/SCOPE.md +2 -2
- package/docs/STATEFUL_SESSION_GUIDE.md +34 -13
- package/docs/USAGE.md +118 -35
- package/examples/README.md +5 -4
- package/examples/basic-connection.js +1 -1
- package/examples/jwt-with-token-refresh.js +14 -15
- package/examples/saml-connection.js +1 -1
- package/package.json +5 -4
- package/dist/auth/FileCertificateMaterialLoader.d.ts +0 -6
- package/dist/auth/FileCertificateMaterialLoader.d.ts.map +0 -1
- package/dist/auth/FileCertificateMaterialLoader.js +0 -28
- package/dist/auth/ntlm.d.ts +0 -26
- package/dist/auth/ntlm.d.ts.map +0 -1
- package/dist/auth/ntlm.js +0 -72
- package/dist/auth/providers.d.ts +0 -125
- package/dist/auth/providers.d.ts.map +0 -1
- package/dist/auth/providers.js +0 -183
- package/dist/utils/tokenRefresh.d.ts +0 -15
- package/dist/utils/tokenRefresh.d.ts.map +0 -1
- package/dist/utils/tokenRefresh.js +0 -55
package/dist/auth/providers.d.ts
DELETED
|
@@ -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"}
|
package/dist/auth/providers.js
DELETED
|
@@ -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"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Token refresh utilities for JWT authentication
|
|
4
|
-
*/
|
|
5
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.refreshJwtToken = refreshJwtToken;
|
|
10
|
-
const axios_1 = __importDefault(require("axios"));
|
|
11
|
-
/**
|
|
12
|
-
* Refreshes the access token using refresh token
|
|
13
|
-
* @param refreshToken Refresh token
|
|
14
|
-
* @param uaaUrl UAA URL (e.g., https://your-account.authentication.eu10.hana.ondemand.com)
|
|
15
|
-
* @param clientId UAA client ID
|
|
16
|
-
* @param clientSecret UAA client secret
|
|
17
|
-
* @returns Promise that resolves to new tokens
|
|
18
|
-
*/
|
|
19
|
-
async function refreshJwtToken(refreshToken, uaaUrl, clientId, clientSecret) {
|
|
20
|
-
try {
|
|
21
|
-
const tokenUrl = `${uaaUrl}/oauth/token`;
|
|
22
|
-
const params = new URLSearchParams();
|
|
23
|
-
params.append('grant_type', 'refresh_token');
|
|
24
|
-
params.append('refresh_token', refreshToken);
|
|
25
|
-
const authString = Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
|
|
26
|
-
const response = await (0, axios_1.default)({
|
|
27
|
-
method: 'post',
|
|
28
|
-
url: tokenUrl,
|
|
29
|
-
headers: {
|
|
30
|
-
Authorization: `Basic ${authString}`,
|
|
31
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
32
|
-
},
|
|
33
|
-
data: params.toString(),
|
|
34
|
-
});
|
|
35
|
-
if (response.data?.access_token) {
|
|
36
|
-
return {
|
|
37
|
-
accessToken: response.data.access_token,
|
|
38
|
-
refreshToken: response.data.refresh_token || refreshToken, // Use new refresh token if provided, otherwise keep old one
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
throw new Error('Response does not contain access_token');
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
const err = error;
|
|
47
|
-
if (err.response) {
|
|
48
|
-
throw new Error(`Token refresh failed (${err.response.status}): ${JSON.stringify(err.response.data)}`);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
52
|
-
throw new Error(`Token refresh failed: ${errorMessage}`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|