@sisense/mcp-server 0.2.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/LICENSE.md +35 -0
- package/README.md +121 -0
- package/dist/ai-hspmgr2c.js +3148 -0
- package/dist/fileFromPath-s6ap5vrh.js +128 -0
- package/dist/index-29n08mw7.js +95 -0
- package/dist/index-atgbxy7h.js +98603 -0
- package/dist/index-d6843g0v.js +372 -0
- package/dist/index-dcrjg3fk.js +207 -0
- package/dist/index-dxfb3krz.js +1489 -0
- package/dist/index-er0yspcy.js +918 -0
- package/dist/index-g8bgq79c.js +53 -0
- package/dist/index-p1pxtmwn.js +162 -0
- package/dist/index-qdth51hx.js +250 -0
- package/dist/index-tqba2rwh.js +603 -0
- package/dist/index-vrapm0b4.js +765 -0
- package/dist/index-vx54d05h.js +475 -0
- package/dist/sse-server-3343e7xh.js +117 -0
- package/dist/sse-server-36t17nga.js +12127 -0
- package/dist/sse-server-3e0efmg2.js +6276 -0
- package/dist/sse-server-4b60tg0c.js +136 -0
- package/dist/sse-server-4g9za0qq.js +89 -0
- package/dist/sse-server-4jjec4fz.js +9753 -0
- package/dist/sse-server-5tmgacdx.js +62 -0
- package/dist/sse-server-7wcvyxyj.js +31 -0
- package/dist/sse-server-brx9qtyd.js +2131 -0
- package/dist/sse-server-epd916s3.js +167 -0
- package/dist/sse-server-gt7tx6n2.js +2240 -0
- package/dist/sse-server-mkesh468.js +53 -0
- package/dist/sse-server-nwjjjz6x.js +113 -0
- package/dist/sse-server-qj4zxq0f.js +267 -0
- package/dist/sse-server-rr3dp62e.js +116721 -0
- package/dist/sse-server-ss0mydv4.js +3980 -0
- package/dist/sse-server-txz5g5t0.js +5328 -0
- package/dist/sse-server.js +30432 -0
- package/dist/view.html +3016 -0
- package/dist/widget-renderer-66ws3xtk.js +312 -0
- package/package.json +82 -0
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
import {
|
|
2
|
+
require_dist_cjs as require_dist_cjs3
|
|
3
|
+
} from "./sse-server-qj4zxq0f.js";
|
|
4
|
+
import {
|
|
5
|
+
require_dist_cjs
|
|
6
|
+
} from "./sse-server-epd916s3.js";
|
|
7
|
+
import"./sse-server-4g9za0qq.js";
|
|
8
|
+
import {
|
|
9
|
+
require_client
|
|
10
|
+
} from "./sse-server-mkesh468.js";
|
|
11
|
+
import {
|
|
12
|
+
require_dist_cjs as require_dist_cjs2
|
|
13
|
+
} from "./sse-server-3343e7xh.js";
|
|
14
|
+
import {
|
|
15
|
+
__commonJS,
|
|
16
|
+
__esm,
|
|
17
|
+
__require,
|
|
18
|
+
__toESM
|
|
19
|
+
} from "./sse-server-7wcvyxyj.js";
|
|
20
|
+
|
|
21
|
+
// node_modules/@aws-sdk/credential-provider-login/dist-cjs/index.js
|
|
22
|
+
var require_dist_cjs4 = __commonJS((exports) => {
|
|
23
|
+
var client = require_client();
|
|
24
|
+
var propertyProvider = require_dist_cjs2();
|
|
25
|
+
var sharedIniFileLoader = require_dist_cjs3();
|
|
26
|
+
var protocolHttp = require_dist_cjs();
|
|
27
|
+
var node_crypto = __require("node:crypto");
|
|
28
|
+
var node_fs = __require("node:fs");
|
|
29
|
+
var node_os = __require("node:os");
|
|
30
|
+
var node_path = __require("node:path");
|
|
31
|
+
|
|
32
|
+
class LoginCredentialsFetcher {
|
|
33
|
+
profileData;
|
|
34
|
+
init;
|
|
35
|
+
callerClientConfig;
|
|
36
|
+
static REFRESH_THRESHOLD = 5 * 60 * 1000;
|
|
37
|
+
constructor(profileData, init, callerClientConfig) {
|
|
38
|
+
this.profileData = profileData;
|
|
39
|
+
this.init = init;
|
|
40
|
+
this.callerClientConfig = callerClientConfig;
|
|
41
|
+
}
|
|
42
|
+
async loadCredentials() {
|
|
43
|
+
const token = await this.loadToken();
|
|
44
|
+
if (!token) {
|
|
45
|
+
throw new propertyProvider.CredentialsProviderError(`Failed to load a token for session ${this.loginSession}, please re-authenticate using aws login`, { tryNextLink: false, logger: this.logger });
|
|
46
|
+
}
|
|
47
|
+
const accessToken = token.accessToken;
|
|
48
|
+
const now = Date.now();
|
|
49
|
+
const expiryTime = new Date(accessToken.expiresAt).getTime();
|
|
50
|
+
const timeUntilExpiry = expiryTime - now;
|
|
51
|
+
if (timeUntilExpiry <= LoginCredentialsFetcher.REFRESH_THRESHOLD) {
|
|
52
|
+
return this.refresh(token);
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
accessKeyId: accessToken.accessKeyId,
|
|
56
|
+
secretAccessKey: accessToken.secretAccessKey,
|
|
57
|
+
sessionToken: accessToken.sessionToken,
|
|
58
|
+
accountId: accessToken.accountId,
|
|
59
|
+
expiration: new Date(accessToken.expiresAt)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
get logger() {
|
|
63
|
+
return this.init?.logger;
|
|
64
|
+
}
|
|
65
|
+
get loginSession() {
|
|
66
|
+
return this.profileData.login_session;
|
|
67
|
+
}
|
|
68
|
+
async refresh(token) {
|
|
69
|
+
const { SigninClient, CreateOAuth2TokenCommand } = await import("./index-tqba2rwh.js");
|
|
70
|
+
const { logger, userAgentAppId } = this.callerClientConfig ?? {};
|
|
71
|
+
const isH2 = (requestHandler2) => {
|
|
72
|
+
return requestHandler2?.metadata?.handlerProtocol === "h2";
|
|
73
|
+
};
|
|
74
|
+
const requestHandler = isH2(this.callerClientConfig?.requestHandler) ? undefined : this.callerClientConfig?.requestHandler;
|
|
75
|
+
const region = this.profileData.region ?? await this.callerClientConfig?.region?.() ?? process.env.AWS_REGION;
|
|
76
|
+
const client2 = new SigninClient({
|
|
77
|
+
credentials: {
|
|
78
|
+
accessKeyId: "",
|
|
79
|
+
secretAccessKey: ""
|
|
80
|
+
},
|
|
81
|
+
region,
|
|
82
|
+
requestHandler,
|
|
83
|
+
logger,
|
|
84
|
+
userAgentAppId,
|
|
85
|
+
...this.init?.clientConfig
|
|
86
|
+
});
|
|
87
|
+
this.createDPoPInterceptor(client2.middlewareStack);
|
|
88
|
+
const commandInput = {
|
|
89
|
+
tokenInput: {
|
|
90
|
+
clientId: token.clientId,
|
|
91
|
+
refreshToken: token.refreshToken,
|
|
92
|
+
grantType: "refresh_token"
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
try {
|
|
96
|
+
const response = await client2.send(new CreateOAuth2TokenCommand(commandInput));
|
|
97
|
+
const { accessKeyId, secretAccessKey, sessionToken } = response.tokenOutput?.accessToken ?? {};
|
|
98
|
+
const { refreshToken, expiresIn } = response.tokenOutput ?? {};
|
|
99
|
+
if (!accessKeyId || !secretAccessKey || !sessionToken || !refreshToken) {
|
|
100
|
+
throw new propertyProvider.CredentialsProviderError("Token refresh response missing required fields", {
|
|
101
|
+
logger: this.logger,
|
|
102
|
+
tryNextLink: false
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const expiresInMs = (expiresIn ?? 900) * 1000;
|
|
106
|
+
const expiration = new Date(Date.now() + expiresInMs);
|
|
107
|
+
const updatedToken = {
|
|
108
|
+
...token,
|
|
109
|
+
accessToken: {
|
|
110
|
+
...token.accessToken,
|
|
111
|
+
accessKeyId,
|
|
112
|
+
secretAccessKey,
|
|
113
|
+
sessionToken,
|
|
114
|
+
expiresAt: expiration.toISOString()
|
|
115
|
+
},
|
|
116
|
+
refreshToken
|
|
117
|
+
};
|
|
118
|
+
await this.saveToken(updatedToken);
|
|
119
|
+
const newAccessToken = updatedToken.accessToken;
|
|
120
|
+
return {
|
|
121
|
+
accessKeyId: newAccessToken.accessKeyId,
|
|
122
|
+
secretAccessKey: newAccessToken.secretAccessKey,
|
|
123
|
+
sessionToken: newAccessToken.sessionToken,
|
|
124
|
+
accountId: newAccessToken.accountId,
|
|
125
|
+
expiration
|
|
126
|
+
};
|
|
127
|
+
} catch (error) {
|
|
128
|
+
if (error.name === "AccessDeniedException") {
|
|
129
|
+
const errorType = error.error;
|
|
130
|
+
let message;
|
|
131
|
+
switch (errorType) {
|
|
132
|
+
case "TOKEN_EXPIRED":
|
|
133
|
+
message = "Your session has expired. Please reauthenticate.";
|
|
134
|
+
break;
|
|
135
|
+
case "USER_CREDENTIALS_CHANGED":
|
|
136
|
+
message = "Unable to refresh credentials because of a change in your password. Please reauthenticate with your new password.";
|
|
137
|
+
break;
|
|
138
|
+
case "INSUFFICIENT_PERMISSIONS":
|
|
139
|
+
message = "Unable to refresh credentials due to insufficient permissions. You may be missing permission for the 'CreateOAuth2Token' action.";
|
|
140
|
+
break;
|
|
141
|
+
default:
|
|
142
|
+
message = `Failed to refresh token: ${String(error)}. Please re-authenticate using \`aws login\``;
|
|
143
|
+
}
|
|
144
|
+
throw new propertyProvider.CredentialsProviderError(message, { logger: this.logger, tryNextLink: false });
|
|
145
|
+
}
|
|
146
|
+
throw new propertyProvider.CredentialsProviderError(`Failed to refresh token: ${String(error)}. Please re-authenticate using aws login`, { logger: this.logger });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
async loadToken() {
|
|
150
|
+
const tokenFilePath = this.getTokenFilePath();
|
|
151
|
+
try {
|
|
152
|
+
let tokenData;
|
|
153
|
+
try {
|
|
154
|
+
tokenData = await sharedIniFileLoader.readFile(tokenFilePath, { ignoreCache: this.init?.ignoreCache });
|
|
155
|
+
} catch {
|
|
156
|
+
tokenData = await node_fs.promises.readFile(tokenFilePath, "utf8");
|
|
157
|
+
}
|
|
158
|
+
const token = JSON.parse(tokenData);
|
|
159
|
+
const missingFields = ["accessToken", "clientId", "refreshToken", "dpopKey"].filter((k) => !token[k]);
|
|
160
|
+
if (!token.accessToken?.accountId) {
|
|
161
|
+
missingFields.push("accountId");
|
|
162
|
+
}
|
|
163
|
+
if (missingFields.length > 0) {
|
|
164
|
+
throw new propertyProvider.CredentialsProviderError(`Token validation failed, missing fields: ${missingFields.join(", ")}`, {
|
|
165
|
+
logger: this.logger,
|
|
166
|
+
tryNextLink: false
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
return token;
|
|
170
|
+
} catch (error) {
|
|
171
|
+
throw new propertyProvider.CredentialsProviderError(`Failed to load token from ${tokenFilePath}: ${String(error)}`, {
|
|
172
|
+
logger: this.logger,
|
|
173
|
+
tryNextLink: false
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
async saveToken(token) {
|
|
178
|
+
const tokenFilePath = this.getTokenFilePath();
|
|
179
|
+
const directory = node_path.dirname(tokenFilePath);
|
|
180
|
+
try {
|
|
181
|
+
await node_fs.promises.mkdir(directory, { recursive: true });
|
|
182
|
+
} catch (error) {}
|
|
183
|
+
await node_fs.promises.writeFile(tokenFilePath, JSON.stringify(token, null, 2), "utf8");
|
|
184
|
+
}
|
|
185
|
+
getTokenFilePath() {
|
|
186
|
+
const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ?? node_path.join(node_os.homedir(), ".aws", "login", "cache");
|
|
187
|
+
const loginSessionBytes = Buffer.from(this.loginSession, "utf8");
|
|
188
|
+
const loginSessionSha256 = node_crypto.createHash("sha256").update(loginSessionBytes).digest("hex");
|
|
189
|
+
return node_path.join(directory, `${loginSessionSha256}.json`);
|
|
190
|
+
}
|
|
191
|
+
derToRawSignature(derSignature) {
|
|
192
|
+
let offset = 2;
|
|
193
|
+
if (derSignature[offset] !== 2) {
|
|
194
|
+
throw new Error("Invalid DER signature");
|
|
195
|
+
}
|
|
196
|
+
offset++;
|
|
197
|
+
const rLength = derSignature[offset++];
|
|
198
|
+
let r = derSignature.subarray(offset, offset + rLength);
|
|
199
|
+
offset += rLength;
|
|
200
|
+
if (derSignature[offset] !== 2) {
|
|
201
|
+
throw new Error("Invalid DER signature");
|
|
202
|
+
}
|
|
203
|
+
offset++;
|
|
204
|
+
const sLength = derSignature[offset++];
|
|
205
|
+
let s = derSignature.subarray(offset, offset + sLength);
|
|
206
|
+
r = r[0] === 0 ? r.subarray(1) : r;
|
|
207
|
+
s = s[0] === 0 ? s.subarray(1) : s;
|
|
208
|
+
const rPadded = Buffer.concat([Buffer.alloc(32 - r.length), r]);
|
|
209
|
+
const sPadded = Buffer.concat([Buffer.alloc(32 - s.length), s]);
|
|
210
|
+
return Buffer.concat([rPadded, sPadded]);
|
|
211
|
+
}
|
|
212
|
+
createDPoPInterceptor(middlewareStack) {
|
|
213
|
+
middlewareStack.add((next) => async (args) => {
|
|
214
|
+
if (protocolHttp.HttpRequest.isInstance(args.request)) {
|
|
215
|
+
const request = args.request;
|
|
216
|
+
const actualEndpoint = `${request.protocol}//${request.hostname}${request.port ? `:${request.port}` : ""}${request.path}`;
|
|
217
|
+
const dpop = await this.generateDpop(request.method, actualEndpoint);
|
|
218
|
+
request.headers = {
|
|
219
|
+
...request.headers,
|
|
220
|
+
DPoP: dpop
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
return next(args);
|
|
224
|
+
}, {
|
|
225
|
+
step: "finalizeRequest",
|
|
226
|
+
name: "dpopInterceptor",
|
|
227
|
+
override: true
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
async generateDpop(method = "POST", endpoint) {
|
|
231
|
+
const token = await this.loadToken();
|
|
232
|
+
try {
|
|
233
|
+
const privateKey = node_crypto.createPrivateKey({
|
|
234
|
+
key: token.dpopKey,
|
|
235
|
+
format: "pem",
|
|
236
|
+
type: "sec1"
|
|
237
|
+
});
|
|
238
|
+
const publicKey = node_crypto.createPublicKey(privateKey);
|
|
239
|
+
const publicDer = publicKey.export({ format: "der", type: "spki" });
|
|
240
|
+
let pointStart = -1;
|
|
241
|
+
for (let i = 0;i < publicDer.length; i++) {
|
|
242
|
+
if (publicDer[i] === 4) {
|
|
243
|
+
pointStart = i;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
const x = publicDer.slice(pointStart + 1, pointStart + 33);
|
|
248
|
+
const y = publicDer.slice(pointStart + 33, pointStart + 65);
|
|
249
|
+
const header = {
|
|
250
|
+
alg: "ES256",
|
|
251
|
+
typ: "dpop+jwt",
|
|
252
|
+
jwk: {
|
|
253
|
+
kty: "EC",
|
|
254
|
+
crv: "P-256",
|
|
255
|
+
x: x.toString("base64url"),
|
|
256
|
+
y: y.toString("base64url")
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
const payload = {
|
|
260
|
+
jti: crypto.randomUUID(),
|
|
261
|
+
htm: method,
|
|
262
|
+
htu: endpoint,
|
|
263
|
+
iat: Math.floor(Date.now() / 1000)
|
|
264
|
+
};
|
|
265
|
+
const headerB64 = Buffer.from(JSON.stringify(header)).toString("base64url");
|
|
266
|
+
const payloadB64 = Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
267
|
+
const message = `${headerB64}.${payloadB64}`;
|
|
268
|
+
const asn1Signature = node_crypto.sign("sha256", Buffer.from(message), privateKey);
|
|
269
|
+
const rawSignature = this.derToRawSignature(asn1Signature);
|
|
270
|
+
const signatureB64 = rawSignature.toString("base64url");
|
|
271
|
+
return `${message}.${signatureB64}`;
|
|
272
|
+
} catch (error) {
|
|
273
|
+
throw new propertyProvider.CredentialsProviderError(`Failed to generate Dpop proof: ${error instanceof Error ? error.message : String(error)}`, { logger: this.logger, tryNextLink: false });
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
var fromLoginCredentials = (init) => async ({ callerClientConfig } = {}) => {
|
|
278
|
+
init?.logger?.debug?.("@aws-sdk/credential-providers - fromLoginCredentials");
|
|
279
|
+
const profiles = await sharedIniFileLoader.parseKnownFiles(init || {});
|
|
280
|
+
const profileName = sharedIniFileLoader.getProfileName({
|
|
281
|
+
profile: init?.profile ?? callerClientConfig?.profile
|
|
282
|
+
});
|
|
283
|
+
const profile = profiles[profileName];
|
|
284
|
+
if (!profile?.login_session) {
|
|
285
|
+
throw new propertyProvider.CredentialsProviderError(`Profile ${profileName} does not contain login_session.`, {
|
|
286
|
+
tryNextLink: true,
|
|
287
|
+
logger: init?.logger
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
const fetcher = new LoginCredentialsFetcher(profile, init, callerClientConfig);
|
|
291
|
+
const credentials = await fetcher.loadCredentials();
|
|
292
|
+
return client.setCredentialFeature(credentials, "CREDENTIALS_LOGIN", "AD");
|
|
293
|
+
};
|
|
294
|
+
exports.fromLoginCredentials = fromLoginCredentials;
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
// node_modules/@aws-sdk/credential-provider-ini/dist-cjs/index.js
|
|
298
|
+
var sharedIniFileLoader, propertyProvider, client, credentialProviderLogin, resolveCredentialSource = (credentialSource, profileName, logger) => {
|
|
299
|
+
const sourceProvidersMap = {
|
|
300
|
+
EcsContainer: async (options) => {
|
|
301
|
+
const { fromHttp } = await import("./index-dcrjg3fk.js");
|
|
302
|
+
const { fromContainerMetadata } = await import("./index-d6843g0v.js");
|
|
303
|
+
logger?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer");
|
|
304
|
+
return async () => propertyProvider.chain(fromHttp(options ?? {}), fromContainerMetadata(options))().then(setNamedProvider);
|
|
305
|
+
},
|
|
306
|
+
Ec2InstanceMetadata: async (options) => {
|
|
307
|
+
logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");
|
|
308
|
+
const { fromInstanceMetadata } = await import("./index-d6843g0v.js");
|
|
309
|
+
return async () => fromInstanceMetadata(options)().then(setNamedProvider);
|
|
310
|
+
},
|
|
311
|
+
Environment: async (options) => {
|
|
312
|
+
logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");
|
|
313
|
+
const { fromEnv } = await import("./index-g8bgq79c.js");
|
|
314
|
+
return async () => fromEnv(options)().then(setNamedProvider);
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
if (credentialSource in sourceProvidersMap) {
|
|
318
|
+
return sourceProvidersMap[credentialSource];
|
|
319
|
+
} else {
|
|
320
|
+
throw new propertyProvider.CredentialsProviderError(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, expected EcsContainer or Ec2InstanceMetadata or Environment.`, { logger });
|
|
321
|
+
}
|
|
322
|
+
}, setNamedProvider = (creds) => client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_NAMED_PROVIDER", "p"), isAssumeRoleProfile = (arg, { profile = "default", logger } = {}) => {
|
|
323
|
+
return Boolean(arg) && typeof arg === "object" && typeof arg.role_arn === "string" && ["undefined", "string"].indexOf(typeof arg.role_session_name) > -1 && ["undefined", "string"].indexOf(typeof arg.external_id) > -1 && ["undefined", "string"].indexOf(typeof arg.mfa_serial) > -1 && (isAssumeRoleWithSourceProfile(arg, { profile, logger }) || isCredentialSourceProfile(arg, { profile, logger }));
|
|
324
|
+
}, isAssumeRoleWithSourceProfile = (arg, { profile, logger }) => {
|
|
325
|
+
const withSourceProfile = typeof arg.source_profile === "string" && typeof arg.credential_source === "undefined";
|
|
326
|
+
if (withSourceProfile) {
|
|
327
|
+
logger?.debug?.(` ${profile} isAssumeRoleWithSourceProfile source_profile=${arg.source_profile}`);
|
|
328
|
+
}
|
|
329
|
+
return withSourceProfile;
|
|
330
|
+
}, isCredentialSourceProfile = (arg, { profile, logger }) => {
|
|
331
|
+
const withProviderProfile = typeof arg.credential_source === "string" && typeof arg.source_profile === "undefined";
|
|
332
|
+
if (withProviderProfile) {
|
|
333
|
+
logger?.debug?.(` ${profile} isCredentialSourceProfile credential_source=${arg.credential_source}`);
|
|
334
|
+
}
|
|
335
|
+
return withProviderProfile;
|
|
336
|
+
}, resolveAssumeRoleCredentials = async (profileName, profiles, options, callerClientConfig, visitedProfiles = {}, resolveProfileData) => {
|
|
337
|
+
options.logger?.debug("@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)");
|
|
338
|
+
const profileData = profiles[profileName];
|
|
339
|
+
const { source_profile, region } = profileData;
|
|
340
|
+
if (!options.roleAssumer) {
|
|
341
|
+
const { getDefaultRoleAssumer } = await import("./index-er0yspcy.js");
|
|
342
|
+
options.roleAssumer = getDefaultRoleAssumer({
|
|
343
|
+
...options.clientConfig,
|
|
344
|
+
credentialProviderLogger: options.logger,
|
|
345
|
+
parentClientConfig: {
|
|
346
|
+
...callerClientConfig,
|
|
347
|
+
...options?.parentClientConfig,
|
|
348
|
+
region: region ?? options?.parentClientConfig?.region ?? callerClientConfig?.region
|
|
349
|
+
}
|
|
350
|
+
}, options.clientPlugins);
|
|
351
|
+
}
|
|
352
|
+
if (source_profile && source_profile in visitedProfiles) {
|
|
353
|
+
throw new propertyProvider.CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile ${sharedIniFileLoader.getProfileName(options)}. Profiles visited: ` + Object.keys(visitedProfiles).join(", "), { logger: options.logger });
|
|
354
|
+
}
|
|
355
|
+
options.logger?.debug(`@aws-sdk/credential-provider-ini - finding credential resolver using ${source_profile ? `source_profile=[${source_profile}]` : `profile=[${profileName}]`}`);
|
|
356
|
+
const sourceCredsProvider = source_profile ? resolveProfileData(source_profile, profiles, options, callerClientConfig, {
|
|
357
|
+
...visitedProfiles,
|
|
358
|
+
[source_profile]: true
|
|
359
|
+
}, isCredentialSourceWithoutRoleArn(profiles[source_profile] ?? {})) : (await resolveCredentialSource(profileData.credential_source, profileName, options.logger)(options))();
|
|
360
|
+
if (isCredentialSourceWithoutRoleArn(profileData)) {
|
|
361
|
+
return sourceCredsProvider.then((creds) => client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
|
|
362
|
+
} else {
|
|
363
|
+
const params = {
|
|
364
|
+
RoleArn: profileData.role_arn,
|
|
365
|
+
RoleSessionName: profileData.role_session_name || `aws-sdk-js-${Date.now()}`,
|
|
366
|
+
ExternalId: profileData.external_id,
|
|
367
|
+
DurationSeconds: parseInt(profileData.duration_seconds || "3600", 10)
|
|
368
|
+
};
|
|
369
|
+
const { mfa_serial } = profileData;
|
|
370
|
+
if (mfa_serial) {
|
|
371
|
+
if (!options.mfaCodeProvider) {
|
|
372
|
+
throw new propertyProvider.CredentialsProviderError(`Profile ${profileName} requires multi-factor authentication, but no MFA code callback was provided.`, { logger: options.logger, tryNextLink: false });
|
|
373
|
+
}
|
|
374
|
+
params.SerialNumber = mfa_serial;
|
|
375
|
+
params.TokenCode = await options.mfaCodeProvider(mfa_serial);
|
|
376
|
+
}
|
|
377
|
+
const sourceCreds = await sourceCredsProvider;
|
|
378
|
+
return options.roleAssumer(sourceCreds, params).then((creds) => client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
|
|
379
|
+
}
|
|
380
|
+
}, isCredentialSourceWithoutRoleArn = (section) => {
|
|
381
|
+
return !section.role_arn && !!section.credential_source;
|
|
382
|
+
}, isLoginProfile = (data) => {
|
|
383
|
+
return Boolean(data && data.login_session);
|
|
384
|
+
}, resolveLoginCredentials = async (profileName, options, callerClientConfig) => {
|
|
385
|
+
const credentials = await credentialProviderLogin.fromLoginCredentials({
|
|
386
|
+
...options,
|
|
387
|
+
profile: profileName
|
|
388
|
+
})({ callerClientConfig });
|
|
389
|
+
return client.setCredentialFeature(credentials, "CREDENTIALS_PROFILE_LOGIN", "AC");
|
|
390
|
+
}, isProcessProfile = (arg) => Boolean(arg) && typeof arg === "object" && typeof arg.credential_process === "string", resolveProcessCredentials = async (options, profile) => import("./index-29n08mw7.js").then(({ fromProcess }) => fromProcess({
|
|
391
|
+
...options,
|
|
392
|
+
profile
|
|
393
|
+
})().then((creds) => client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_PROCESS", "v"))), resolveSsoCredentials = async (profile, profileData, options = {}, callerClientConfig) => {
|
|
394
|
+
const { fromSSO } = await import("./index-dxfb3krz.js");
|
|
395
|
+
return fromSSO({
|
|
396
|
+
profile,
|
|
397
|
+
logger: options.logger,
|
|
398
|
+
parentClientConfig: options.parentClientConfig,
|
|
399
|
+
clientConfig: options.clientConfig
|
|
400
|
+
})({
|
|
401
|
+
callerClientConfig
|
|
402
|
+
}).then((creds) => {
|
|
403
|
+
if (profileData.sso_session) {
|
|
404
|
+
return client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_SSO", "r");
|
|
405
|
+
} else {
|
|
406
|
+
return client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_SSO_LEGACY", "t");
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
}, isSsoProfile = (arg) => arg && (typeof arg.sso_start_url === "string" || typeof arg.sso_account_id === "string" || typeof arg.sso_session === "string" || typeof arg.sso_region === "string" || typeof arg.sso_role_name === "string"), isStaticCredsProfile = (arg) => Boolean(arg) && typeof arg === "object" && typeof arg.aws_access_key_id === "string" && typeof arg.aws_secret_access_key === "string" && ["undefined", "string"].indexOf(typeof arg.aws_session_token) > -1 && ["undefined", "string"].indexOf(typeof arg.aws_account_id) > -1, resolveStaticCredentials = async (profile, options) => {
|
|
410
|
+
options?.logger?.debug("@aws-sdk/credential-provider-ini - resolveStaticCredentials");
|
|
411
|
+
const credentials = {
|
|
412
|
+
accessKeyId: profile.aws_access_key_id,
|
|
413
|
+
secretAccessKey: profile.aws_secret_access_key,
|
|
414
|
+
sessionToken: profile.aws_session_token,
|
|
415
|
+
...profile.aws_credential_scope && { credentialScope: profile.aws_credential_scope },
|
|
416
|
+
...profile.aws_account_id && { accountId: profile.aws_account_id }
|
|
417
|
+
};
|
|
418
|
+
return client.setCredentialFeature(credentials, "CREDENTIALS_PROFILE", "n");
|
|
419
|
+
}, isWebIdentityProfile = (arg) => Boolean(arg) && typeof arg === "object" && typeof arg.web_identity_token_file === "string" && typeof arg.role_arn === "string" && ["undefined", "string"].indexOf(typeof arg.role_session_name) > -1, resolveWebIdentityCredentials = async (profile, options, callerClientConfig) => import("./index-p1pxtmwn.js").then(({ fromTokenFile }) => fromTokenFile({
|
|
420
|
+
webIdentityTokenFile: profile.web_identity_token_file,
|
|
421
|
+
roleArn: profile.role_arn,
|
|
422
|
+
roleSessionName: profile.role_session_name,
|
|
423
|
+
roleAssumerWithWebIdentity: options.roleAssumerWithWebIdentity,
|
|
424
|
+
logger: options.logger,
|
|
425
|
+
parentClientConfig: options.parentClientConfig
|
|
426
|
+
})({
|
|
427
|
+
callerClientConfig
|
|
428
|
+
}).then((creds) => client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN", "q"))), resolveProfileData = async (profileName, profiles, options, callerClientConfig, visitedProfiles = {}, isAssumeRoleRecursiveCall = false) => {
|
|
429
|
+
const data = profiles[profileName];
|
|
430
|
+
if (Object.keys(visitedProfiles).length > 0 && isStaticCredsProfile(data)) {
|
|
431
|
+
return resolveStaticCredentials(data, options);
|
|
432
|
+
}
|
|
433
|
+
if (isAssumeRoleRecursiveCall || isAssumeRoleProfile(data, { profile: profileName, logger: options.logger })) {
|
|
434
|
+
return resolveAssumeRoleCredentials(profileName, profiles, options, callerClientConfig, visitedProfiles, resolveProfileData);
|
|
435
|
+
}
|
|
436
|
+
if (isStaticCredsProfile(data)) {
|
|
437
|
+
return resolveStaticCredentials(data, options);
|
|
438
|
+
}
|
|
439
|
+
if (isWebIdentityProfile(data)) {
|
|
440
|
+
return resolveWebIdentityCredentials(data, options, callerClientConfig);
|
|
441
|
+
}
|
|
442
|
+
if (isProcessProfile(data)) {
|
|
443
|
+
return resolveProcessCredentials(options, profileName);
|
|
444
|
+
}
|
|
445
|
+
if (isSsoProfile(data)) {
|
|
446
|
+
return await resolveSsoCredentials(profileName, data, options, callerClientConfig);
|
|
447
|
+
}
|
|
448
|
+
if (isLoginProfile(data)) {
|
|
449
|
+
return resolveLoginCredentials(profileName, options, callerClientConfig);
|
|
450
|
+
}
|
|
451
|
+
throw new propertyProvider.CredentialsProviderError(`Could not resolve credentials using profile: [${profileName}] in configuration/credentials file(s).`, { logger: options.logger });
|
|
452
|
+
}, fromIni = (init = {}) => async ({ callerClientConfig } = {}) => {
|
|
453
|
+
init.logger?.debug("@aws-sdk/credential-provider-ini - fromIni");
|
|
454
|
+
const profiles = await sharedIniFileLoader.parseKnownFiles(init);
|
|
455
|
+
return resolveProfileData(sharedIniFileLoader.getProfileName({
|
|
456
|
+
profile: init.profile ?? callerClientConfig?.profile
|
|
457
|
+
}), profiles, init, callerClientConfig);
|
|
458
|
+
}, $fromIni;
|
|
459
|
+
var init_dist_cjs = __esm(() => {
|
|
460
|
+
sharedIniFileLoader = require_dist_cjs3();
|
|
461
|
+
propertyProvider = require_dist_cjs2();
|
|
462
|
+
client = require_client();
|
|
463
|
+
credentialProviderLogin = require_dist_cjs4();
|
|
464
|
+
$fromIni = fromIni;
|
|
465
|
+
});
|
|
466
|
+
init_dist_cjs();
|
|
467
|
+
|
|
468
|
+
export {
|
|
469
|
+
$fromIni as fromIni
|
|
470
|
+
};
|
|
471
|
+
export default {
|
|
472
|
+
get fromIni() {
|
|
473
|
+
return $fromIni;
|
|
474
|
+
}
|
|
475
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__commonJS
|
|
3
|
+
} from "./sse-server-7wcvyxyj.js";
|
|
4
|
+
|
|
5
|
+
// node_modules/@smithy/property-provider/dist-cjs/index.js
|
|
6
|
+
var require_dist_cjs = __commonJS((exports) => {
|
|
7
|
+
class ProviderError extends Error {
|
|
8
|
+
name = "ProviderError";
|
|
9
|
+
tryNextLink;
|
|
10
|
+
constructor(message, options = true) {
|
|
11
|
+
let logger;
|
|
12
|
+
let tryNextLink = true;
|
|
13
|
+
if (typeof options === "boolean") {
|
|
14
|
+
logger = undefined;
|
|
15
|
+
tryNextLink = options;
|
|
16
|
+
} else if (options != null && typeof options === "object") {
|
|
17
|
+
logger = options.logger;
|
|
18
|
+
tryNextLink = options.tryNextLink ?? true;
|
|
19
|
+
}
|
|
20
|
+
super(message);
|
|
21
|
+
this.tryNextLink = tryNextLink;
|
|
22
|
+
Object.setPrototypeOf(this, ProviderError.prototype);
|
|
23
|
+
logger?.debug?.(`@smithy/property-provider ${tryNextLink ? "->" : "(!)"} ${message}`);
|
|
24
|
+
}
|
|
25
|
+
static from(error, options = true) {
|
|
26
|
+
return Object.assign(new this(error.message, options), error);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
class CredentialsProviderError extends ProviderError {
|
|
31
|
+
name = "CredentialsProviderError";
|
|
32
|
+
constructor(message, options = true) {
|
|
33
|
+
super(message, options);
|
|
34
|
+
Object.setPrototypeOf(this, CredentialsProviderError.prototype);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
class TokenProviderError extends ProviderError {
|
|
39
|
+
name = "TokenProviderError";
|
|
40
|
+
constructor(message, options = true) {
|
|
41
|
+
super(message, options);
|
|
42
|
+
Object.setPrototypeOf(this, TokenProviderError.prototype);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
var chain = (...providers) => async () => {
|
|
46
|
+
if (providers.length === 0) {
|
|
47
|
+
throw new ProviderError("No providers in chain");
|
|
48
|
+
}
|
|
49
|
+
let lastProviderError;
|
|
50
|
+
for (const provider of providers) {
|
|
51
|
+
try {
|
|
52
|
+
const credentials = await provider();
|
|
53
|
+
return credentials;
|
|
54
|
+
} catch (err) {
|
|
55
|
+
lastProviderError = err;
|
|
56
|
+
if (err?.tryNextLink) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
throw err;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
throw lastProviderError;
|
|
63
|
+
};
|
|
64
|
+
var fromStatic = (staticValue) => () => Promise.resolve(staticValue);
|
|
65
|
+
var memoize = (provider, isExpired, requiresRefresh) => {
|
|
66
|
+
let resolved;
|
|
67
|
+
let pending;
|
|
68
|
+
let hasResult;
|
|
69
|
+
let isConstant = false;
|
|
70
|
+
const coalesceProvider = async () => {
|
|
71
|
+
if (!pending) {
|
|
72
|
+
pending = provider();
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
resolved = await pending;
|
|
76
|
+
hasResult = true;
|
|
77
|
+
isConstant = false;
|
|
78
|
+
} finally {
|
|
79
|
+
pending = undefined;
|
|
80
|
+
}
|
|
81
|
+
return resolved;
|
|
82
|
+
};
|
|
83
|
+
if (isExpired === undefined) {
|
|
84
|
+
return async (options) => {
|
|
85
|
+
if (!hasResult || options?.forceRefresh) {
|
|
86
|
+
resolved = await coalesceProvider();
|
|
87
|
+
}
|
|
88
|
+
return resolved;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return async (options) => {
|
|
92
|
+
if (!hasResult || options?.forceRefresh) {
|
|
93
|
+
resolved = await coalesceProvider();
|
|
94
|
+
}
|
|
95
|
+
if (isConstant) {
|
|
96
|
+
return resolved;
|
|
97
|
+
}
|
|
98
|
+
if (requiresRefresh && !requiresRefresh(resolved)) {
|
|
99
|
+
isConstant = true;
|
|
100
|
+
return resolved;
|
|
101
|
+
}
|
|
102
|
+
if (isExpired(resolved)) {
|
|
103
|
+
await coalesceProvider();
|
|
104
|
+
return resolved;
|
|
105
|
+
}
|
|
106
|
+
return resolved;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
exports.CredentialsProviderError = CredentialsProviderError;
|
|
110
|
+
exports.ProviderError = ProviderError;
|
|
111
|
+
exports.TokenProviderError = TokenProviderError;
|
|
112
|
+
exports.chain = chain;
|
|
113
|
+
exports.fromStatic = fromStatic;
|
|
114
|
+
exports.memoize = memoize;
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
export { require_dist_cjs };
|