@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.
Files changed (37) hide show
  1. package/LICENSE.md +35 -0
  2. package/README.md +121 -0
  3. package/dist/ai-hspmgr2c.js +3148 -0
  4. package/dist/fileFromPath-s6ap5vrh.js +128 -0
  5. package/dist/index-29n08mw7.js +95 -0
  6. package/dist/index-atgbxy7h.js +98603 -0
  7. package/dist/index-d6843g0v.js +372 -0
  8. package/dist/index-dcrjg3fk.js +207 -0
  9. package/dist/index-dxfb3krz.js +1489 -0
  10. package/dist/index-er0yspcy.js +918 -0
  11. package/dist/index-g8bgq79c.js +53 -0
  12. package/dist/index-p1pxtmwn.js +162 -0
  13. package/dist/index-qdth51hx.js +250 -0
  14. package/dist/index-tqba2rwh.js +603 -0
  15. package/dist/index-vrapm0b4.js +765 -0
  16. package/dist/index-vx54d05h.js +475 -0
  17. package/dist/sse-server-3343e7xh.js +117 -0
  18. package/dist/sse-server-36t17nga.js +12127 -0
  19. package/dist/sse-server-3e0efmg2.js +6276 -0
  20. package/dist/sse-server-4b60tg0c.js +136 -0
  21. package/dist/sse-server-4g9za0qq.js +89 -0
  22. package/dist/sse-server-4jjec4fz.js +9753 -0
  23. package/dist/sse-server-5tmgacdx.js +62 -0
  24. package/dist/sse-server-7wcvyxyj.js +31 -0
  25. package/dist/sse-server-brx9qtyd.js +2131 -0
  26. package/dist/sse-server-epd916s3.js +167 -0
  27. package/dist/sse-server-gt7tx6n2.js +2240 -0
  28. package/dist/sse-server-mkesh468.js +53 -0
  29. package/dist/sse-server-nwjjjz6x.js +113 -0
  30. package/dist/sse-server-qj4zxq0f.js +267 -0
  31. package/dist/sse-server-rr3dp62e.js +116721 -0
  32. package/dist/sse-server-ss0mydv4.js +3980 -0
  33. package/dist/sse-server-txz5g5t0.js +5328 -0
  34. package/dist/sse-server.js +30432 -0
  35. package/dist/view.html +3016 -0
  36. package/dist/widget-renderer-66ws3xtk.js +312 -0
  37. package/package.json +82 -0
@@ -0,0 +1,1489 @@
1
+ import {
2
+ require_dist_cjs as require_dist_cjs6,
3
+ require_dist_cjs1 as require_dist_cjs8,
4
+ require_dist_cjs10 as require_dist_cjs18,
5
+ require_dist_cjs11 as require_dist_cjs19,
6
+ require_dist_cjs12 as require_dist_cjs22,
7
+ require_dist_cjs13 as require_dist_cjs23,
8
+ require_dist_cjs14 as require_dist_cjs24,
9
+ require_dist_cjs15 as require_dist_cjs25,
10
+ require_dist_cjs16 as require_dist_cjs26,
11
+ require_dist_cjs17 as require_dist_cjs27,
12
+ require_dist_cjs18 as require_dist_cjs28,
13
+ require_dist_cjs19 as require_dist_cjs29,
14
+ require_dist_cjs2 as require_dist_cjs10,
15
+ require_dist_cjs3 as require_dist_cjs11,
16
+ require_dist_cjs4 as require_dist_cjs12,
17
+ require_dist_cjs5 as require_dist_cjs13,
18
+ require_dist_cjs7 as require_dist_cjs14,
19
+ require_dist_cjs8 as require_dist_cjs16,
20
+ require_dist_cjs9 as require_dist_cjs17,
21
+ require_protocols
22
+ } from "./sse-server-4jjec4fz.js";
23
+ import {
24
+ require_dist_cjs as require_dist_cjs15,
25
+ require_dist_cjs1 as require_dist_cjs21
26
+ } from "./sse-server-nwjjjz6x.js";
27
+ import {
28
+ require_dist_cjs as require_dist_cjs20
29
+ } from "./sse-server-qj4zxq0f.js";
30
+ import {
31
+ require_dist_cjs as require_dist_cjs2,
32
+ require_dist_cjs1 as require_dist_cjs4,
33
+ require_dist_cjs3 as require_dist_cjs5,
34
+ require_dist_cjs7 as require_dist_cjs9,
35
+ require_schema,
36
+ require_tslib
37
+ } from "./sse-server-txz5g5t0.js";
38
+ import {
39
+ require_dist_cjs
40
+ } from "./sse-server-epd916s3.js";
41
+ import {
42
+ require_dist_cjs2 as require_dist_cjs3
43
+ } from "./sse-server-5tmgacdx.js";
44
+ import"./sse-server-4g9za0qq.js";
45
+ import {
46
+ require_client
47
+ } from "./sse-server-mkesh468.js";
48
+ import {
49
+ require_dist_cjs as require_dist_cjs7
50
+ } from "./sse-server-3343e7xh.js";
51
+ import {
52
+ __commonJS,
53
+ __esm,
54
+ __require,
55
+ __toESM
56
+ } from "./sse-server-7wcvyxyj.js";
57
+
58
+ // node_modules/@aws-sdk/core/dist-cjs/submodules/httpAuthSchemes/index.js
59
+ var require_httpAuthSchemes = __commonJS((exports) => {
60
+ var protocolHttp = require_dist_cjs();
61
+ var core = require_dist_cjs6();
62
+ var propertyProvider = require_dist_cjs7();
63
+ var client = require_client();
64
+ var signatureV4 = require_dist_cjs8();
65
+ var getDateHeader = (response) => protocolHttp.HttpResponse.isInstance(response) ? response.headers?.date ?? response.headers?.Date : undefined;
66
+ var getSkewCorrectedDate = (systemClockOffset) => new Date(Date.now() + systemClockOffset);
67
+ var isClockSkewed = (clockTime, systemClockOffset) => Math.abs(getSkewCorrectedDate(systemClockOffset).getTime() - clockTime) >= 300000;
68
+ var getUpdatedSystemClockOffset = (clockTime, currentSystemClockOffset) => {
69
+ const clockTimeInMs = Date.parse(clockTime);
70
+ if (isClockSkewed(clockTimeInMs, currentSystemClockOffset)) {
71
+ return clockTimeInMs - Date.now();
72
+ }
73
+ return currentSystemClockOffset;
74
+ };
75
+ var throwSigningPropertyError = (name, property) => {
76
+ if (!property) {
77
+ throw new Error(`Property \`${name}\` is not resolved for AWS SDK SigV4Auth`);
78
+ }
79
+ return property;
80
+ };
81
+ var validateSigningProperties = async (signingProperties) => {
82
+ const context = throwSigningPropertyError("context", signingProperties.context);
83
+ const config = throwSigningPropertyError("config", signingProperties.config);
84
+ const authScheme = context.endpointV2?.properties?.authSchemes?.[0];
85
+ const signerFunction = throwSigningPropertyError("signer", config.signer);
86
+ const signer = await signerFunction(authScheme);
87
+ const signingRegion = signingProperties?.signingRegion;
88
+ const signingRegionSet = signingProperties?.signingRegionSet;
89
+ const signingName = signingProperties?.signingName;
90
+ return {
91
+ config,
92
+ signer,
93
+ signingRegion,
94
+ signingRegionSet,
95
+ signingName
96
+ };
97
+ };
98
+
99
+ class AwsSdkSigV4Signer {
100
+ async sign(httpRequest, identity, signingProperties) {
101
+ if (!protocolHttp.HttpRequest.isInstance(httpRequest)) {
102
+ throw new Error("The request is not an instance of `HttpRequest` and cannot be signed");
103
+ }
104
+ const validatedProps = await validateSigningProperties(signingProperties);
105
+ const { config, signer } = validatedProps;
106
+ let { signingRegion, signingName } = validatedProps;
107
+ const handlerExecutionContext = signingProperties.context;
108
+ if (handlerExecutionContext?.authSchemes?.length ?? 0 > 1) {
109
+ const [first, second] = handlerExecutionContext.authSchemes;
110
+ if (first?.name === "sigv4a" && second?.name === "sigv4") {
111
+ signingRegion = second?.signingRegion ?? signingRegion;
112
+ signingName = second?.signingName ?? signingName;
113
+ }
114
+ }
115
+ const signedRequest = await signer.sign(httpRequest, {
116
+ signingDate: getSkewCorrectedDate(config.systemClockOffset),
117
+ signingRegion,
118
+ signingService: signingName
119
+ });
120
+ return signedRequest;
121
+ }
122
+ errorHandler(signingProperties) {
123
+ return (error) => {
124
+ const serverTime = error.ServerTime ?? getDateHeader(error.$response);
125
+ if (serverTime) {
126
+ const config = throwSigningPropertyError("config", signingProperties.config);
127
+ const initialSystemClockOffset = config.systemClockOffset;
128
+ config.systemClockOffset = getUpdatedSystemClockOffset(serverTime, config.systemClockOffset);
129
+ const clockSkewCorrected = config.systemClockOffset !== initialSystemClockOffset;
130
+ if (clockSkewCorrected && error.$metadata) {
131
+ error.$metadata.clockSkewCorrected = true;
132
+ }
133
+ }
134
+ throw error;
135
+ };
136
+ }
137
+ successHandler(httpResponse, signingProperties) {
138
+ const dateHeader = getDateHeader(httpResponse);
139
+ if (dateHeader) {
140
+ const config = throwSigningPropertyError("config", signingProperties.config);
141
+ config.systemClockOffset = getUpdatedSystemClockOffset(dateHeader, config.systemClockOffset);
142
+ }
143
+ }
144
+ }
145
+ var AWSSDKSigV4Signer = AwsSdkSigV4Signer;
146
+
147
+ class AwsSdkSigV4ASigner extends AwsSdkSigV4Signer {
148
+ async sign(httpRequest, identity, signingProperties) {
149
+ if (!protocolHttp.HttpRequest.isInstance(httpRequest)) {
150
+ throw new Error("The request is not an instance of `HttpRequest` and cannot be signed");
151
+ }
152
+ const { config, signer, signingRegion, signingRegionSet, signingName } = await validateSigningProperties(signingProperties);
153
+ const configResolvedSigningRegionSet = await config.sigv4aSigningRegionSet?.();
154
+ const multiRegionOverride = (configResolvedSigningRegionSet ?? signingRegionSet ?? [signingRegion]).join(",");
155
+ const signedRequest = await signer.sign(httpRequest, {
156
+ signingDate: getSkewCorrectedDate(config.systemClockOffset),
157
+ signingRegion: multiRegionOverride,
158
+ signingService: signingName
159
+ });
160
+ return signedRequest;
161
+ }
162
+ }
163
+ var getArrayForCommaSeparatedString = (str) => typeof str === "string" && str.length > 0 ? str.split(",").map((item) => item.trim()) : [];
164
+ var getBearerTokenEnvKey = (signingName) => `AWS_BEARER_TOKEN_${signingName.replace(/[\s-]/g, "_").toUpperCase()}`;
165
+ var NODE_AUTH_SCHEME_PREFERENCE_ENV_KEY = "AWS_AUTH_SCHEME_PREFERENCE";
166
+ var NODE_AUTH_SCHEME_PREFERENCE_CONFIG_KEY = "auth_scheme_preference";
167
+ var NODE_AUTH_SCHEME_PREFERENCE_OPTIONS = {
168
+ environmentVariableSelector: (env, options) => {
169
+ if (options?.signingName) {
170
+ const bearerTokenKey = getBearerTokenEnvKey(options.signingName);
171
+ if (bearerTokenKey in env)
172
+ return ["httpBearerAuth"];
173
+ }
174
+ if (!(NODE_AUTH_SCHEME_PREFERENCE_ENV_KEY in env))
175
+ return;
176
+ return getArrayForCommaSeparatedString(env[NODE_AUTH_SCHEME_PREFERENCE_ENV_KEY]);
177
+ },
178
+ configFileSelector: (profile) => {
179
+ if (!(NODE_AUTH_SCHEME_PREFERENCE_CONFIG_KEY in profile))
180
+ return;
181
+ return getArrayForCommaSeparatedString(profile[NODE_AUTH_SCHEME_PREFERENCE_CONFIG_KEY]);
182
+ },
183
+ default: []
184
+ };
185
+ var resolveAwsSdkSigV4AConfig = (config) => {
186
+ config.sigv4aSigningRegionSet = core.normalizeProvider(config.sigv4aSigningRegionSet);
187
+ return config;
188
+ };
189
+ var NODE_SIGV4A_CONFIG_OPTIONS = {
190
+ environmentVariableSelector(env) {
191
+ if (env.AWS_SIGV4A_SIGNING_REGION_SET) {
192
+ return env.AWS_SIGV4A_SIGNING_REGION_SET.split(",").map((_) => _.trim());
193
+ }
194
+ throw new propertyProvider.ProviderError("AWS_SIGV4A_SIGNING_REGION_SET not set in env.", {
195
+ tryNextLink: true
196
+ });
197
+ },
198
+ configFileSelector(profile) {
199
+ if (profile.sigv4a_signing_region_set) {
200
+ return (profile.sigv4a_signing_region_set ?? "").split(",").map((_) => _.trim());
201
+ }
202
+ throw new propertyProvider.ProviderError("sigv4a_signing_region_set not set in profile.", {
203
+ tryNextLink: true
204
+ });
205
+ },
206
+ default: undefined
207
+ };
208
+ var resolveAwsSdkSigV4Config = (config) => {
209
+ let inputCredentials = config.credentials;
210
+ let isUserSupplied = !!config.credentials;
211
+ let resolvedCredentials = undefined;
212
+ Object.defineProperty(config, "credentials", {
213
+ set(credentials) {
214
+ if (credentials && credentials !== inputCredentials && credentials !== resolvedCredentials) {
215
+ isUserSupplied = true;
216
+ }
217
+ inputCredentials = credentials;
218
+ const memoizedProvider = normalizeCredentialProvider(config, {
219
+ credentials: inputCredentials,
220
+ credentialDefaultProvider: config.credentialDefaultProvider
221
+ });
222
+ const boundProvider = bindCallerConfig(config, memoizedProvider);
223
+ if (isUserSupplied && !boundProvider.attributed) {
224
+ resolvedCredentials = async (options) => boundProvider(options).then((creds) => client.setCredentialFeature(creds, "CREDENTIALS_CODE", "e"));
225
+ resolvedCredentials.memoized = boundProvider.memoized;
226
+ resolvedCredentials.configBound = boundProvider.configBound;
227
+ resolvedCredentials.attributed = true;
228
+ } else {
229
+ resolvedCredentials = boundProvider;
230
+ }
231
+ },
232
+ get() {
233
+ return resolvedCredentials;
234
+ },
235
+ enumerable: true,
236
+ configurable: true
237
+ });
238
+ config.credentials = inputCredentials;
239
+ const { signingEscapePath = true, systemClockOffset = config.systemClockOffset || 0, sha256 } = config;
240
+ let signer;
241
+ if (config.signer) {
242
+ signer = core.normalizeProvider(config.signer);
243
+ } else if (config.regionInfoProvider) {
244
+ signer = () => core.normalizeProvider(config.region)().then(async (region) => [
245
+ await config.regionInfoProvider(region, {
246
+ useFipsEndpoint: await config.useFipsEndpoint(),
247
+ useDualstackEndpoint: await config.useDualstackEndpoint()
248
+ }) || {},
249
+ region
250
+ ]).then(([regionInfo, region]) => {
251
+ const { signingRegion, signingService } = regionInfo;
252
+ config.signingRegion = config.signingRegion || signingRegion || region;
253
+ config.signingName = config.signingName || signingService || config.serviceId;
254
+ const params = {
255
+ ...config,
256
+ credentials: config.credentials,
257
+ region: config.signingRegion,
258
+ service: config.signingName,
259
+ sha256,
260
+ uriEscapePath: signingEscapePath
261
+ };
262
+ const SignerCtor = config.signerConstructor || signatureV4.SignatureV4;
263
+ return new SignerCtor(params);
264
+ });
265
+ } else {
266
+ signer = async (authScheme) => {
267
+ authScheme = Object.assign({}, {
268
+ name: "sigv4",
269
+ signingName: config.signingName || config.defaultSigningName,
270
+ signingRegion: await core.normalizeProvider(config.region)(),
271
+ properties: {}
272
+ }, authScheme);
273
+ const signingRegion = authScheme.signingRegion;
274
+ const signingService = authScheme.signingName;
275
+ config.signingRegion = config.signingRegion || signingRegion;
276
+ config.signingName = config.signingName || signingService || config.serviceId;
277
+ const params = {
278
+ ...config,
279
+ credentials: config.credentials,
280
+ region: config.signingRegion,
281
+ service: config.signingName,
282
+ sha256,
283
+ uriEscapePath: signingEscapePath
284
+ };
285
+ const SignerCtor = config.signerConstructor || signatureV4.SignatureV4;
286
+ return new SignerCtor(params);
287
+ };
288
+ }
289
+ const resolvedConfig = Object.assign(config, {
290
+ systemClockOffset,
291
+ signingEscapePath,
292
+ signer
293
+ });
294
+ return resolvedConfig;
295
+ };
296
+ var resolveAWSSDKSigV4Config = resolveAwsSdkSigV4Config;
297
+ function normalizeCredentialProvider(config, { credentials, credentialDefaultProvider }) {
298
+ let credentialsProvider;
299
+ if (credentials) {
300
+ if (!credentials?.memoized) {
301
+ credentialsProvider = core.memoizeIdentityProvider(credentials, core.isIdentityExpired, core.doesIdentityRequireRefresh);
302
+ } else {
303
+ credentialsProvider = credentials;
304
+ }
305
+ } else {
306
+ if (credentialDefaultProvider) {
307
+ credentialsProvider = core.normalizeProvider(credentialDefaultProvider(Object.assign({}, config, {
308
+ parentClientConfig: config
309
+ })));
310
+ } else {
311
+ credentialsProvider = async () => {
312
+ throw new Error("@aws-sdk/core::resolveAwsSdkSigV4Config - `credentials` not provided and no credentialDefaultProvider was configured.");
313
+ };
314
+ }
315
+ }
316
+ credentialsProvider.memoized = true;
317
+ return credentialsProvider;
318
+ }
319
+ function bindCallerConfig(config, credentialsProvider) {
320
+ if (credentialsProvider.configBound) {
321
+ return credentialsProvider;
322
+ }
323
+ const fn = async (options) => credentialsProvider({ ...options, callerClientConfig: config });
324
+ fn.memoized = credentialsProvider.memoized;
325
+ fn.configBound = true;
326
+ return fn;
327
+ }
328
+ exports.AWSSDKSigV4Signer = AWSSDKSigV4Signer;
329
+ exports.AwsSdkSigV4ASigner = AwsSdkSigV4ASigner;
330
+ exports.AwsSdkSigV4Signer = AwsSdkSigV4Signer;
331
+ exports.NODE_AUTH_SCHEME_PREFERENCE_OPTIONS = NODE_AUTH_SCHEME_PREFERENCE_OPTIONS;
332
+ exports.NODE_SIGV4A_CONFIG_OPTIONS = NODE_SIGV4A_CONFIG_OPTIONS;
333
+ exports.getBearerTokenEnvKey = getBearerTokenEnvKey;
334
+ exports.resolveAWSSDKSigV4Config = resolveAWSSDKSigV4Config;
335
+ exports.resolveAwsSdkSigV4AConfig = resolveAwsSdkSigV4AConfig;
336
+ exports.resolveAwsSdkSigV4Config = resolveAwsSdkSigV4Config;
337
+ exports.validateSigningProperties = validateSigningProperties;
338
+ });
339
+
340
+ // node_modules/@aws-sdk/token-providers/dist-cjs/index.js
341
+ var require_dist_cjs30 = __commonJS((exports) => {
342
+ var client = require_client();
343
+ var httpAuthSchemes = require_httpAuthSchemes();
344
+ var propertyProvider = require_dist_cjs7();
345
+ var sharedIniFileLoader = require_dist_cjs20();
346
+ var fs = __require("fs");
347
+ var fromEnvSigningName = ({ logger, signingName } = {}) => async () => {
348
+ logger?.debug?.("@aws-sdk/token-providers - fromEnvSigningName");
349
+ if (!signingName) {
350
+ throw new propertyProvider.TokenProviderError("Please pass 'signingName' to compute environment variable key", { logger });
351
+ }
352
+ const bearerTokenKey = httpAuthSchemes.getBearerTokenEnvKey(signingName);
353
+ if (!(bearerTokenKey in process.env)) {
354
+ throw new propertyProvider.TokenProviderError(`Token not present in '${bearerTokenKey}' environment variable`, { logger });
355
+ }
356
+ const token = { token: process.env[bearerTokenKey] };
357
+ client.setTokenFeature(token, "BEARER_SERVICE_ENV_VARS", "3");
358
+ return token;
359
+ };
360
+ var EXPIRE_WINDOW_MS = 5 * 60 * 1000;
361
+ var REFRESH_MESSAGE = `To refresh this SSO session run 'aws sso login' with the corresponding profile.`;
362
+ var getSsoOidcClient = async (ssoRegion, init = {}, callerClientConfig) => {
363
+ const { SSOOIDCClient } = await import("./index-vrapm0b4.js");
364
+ const coalesce = (prop) => init.clientConfig?.[prop] ?? init.parentClientConfig?.[prop] ?? callerClientConfig?.[prop];
365
+ const ssoOidcClient = new SSOOIDCClient(Object.assign({}, init.clientConfig ?? {}, {
366
+ region: ssoRegion ?? init.clientConfig?.region,
367
+ logger: coalesce("logger"),
368
+ userAgentAppId: coalesce("userAgentAppId")
369
+ }));
370
+ return ssoOidcClient;
371
+ };
372
+ var getNewSsoOidcToken = async (ssoToken, ssoRegion, init = {}, callerClientConfig) => {
373
+ const { CreateTokenCommand } = await import("./index-vrapm0b4.js");
374
+ const ssoOidcClient = await getSsoOidcClient(ssoRegion, init, callerClientConfig);
375
+ return ssoOidcClient.send(new CreateTokenCommand({
376
+ clientId: ssoToken.clientId,
377
+ clientSecret: ssoToken.clientSecret,
378
+ refreshToken: ssoToken.refreshToken,
379
+ grantType: "refresh_token"
380
+ }));
381
+ };
382
+ var validateTokenExpiry = (token) => {
383
+ if (token.expiration && token.expiration.getTime() < Date.now()) {
384
+ throw new propertyProvider.TokenProviderError(`Token is expired. ${REFRESH_MESSAGE}`, false);
385
+ }
386
+ };
387
+ var validateTokenKey = (key, value, forRefresh = false) => {
388
+ if (typeof value === "undefined") {
389
+ throw new propertyProvider.TokenProviderError(`Value not present for '${key}' in SSO Token${forRefresh ? ". Cannot refresh" : ""}. ${REFRESH_MESSAGE}`, false);
390
+ }
391
+ };
392
+ var { writeFile } = fs.promises;
393
+ var writeSSOTokenToFile = (id, ssoToken) => {
394
+ const tokenFilepath = sharedIniFileLoader.getSSOTokenFilepath(id);
395
+ const tokenString = JSON.stringify(ssoToken, null, 2);
396
+ return writeFile(tokenFilepath, tokenString);
397
+ };
398
+ var lastRefreshAttemptTime = new Date(0);
399
+ var fromSso = (init = {}) => async ({ callerClientConfig } = {}) => {
400
+ init.logger?.debug("@aws-sdk/token-providers - fromSso");
401
+ const profiles = await sharedIniFileLoader.parseKnownFiles(init);
402
+ const profileName = sharedIniFileLoader.getProfileName({
403
+ profile: init.profile ?? callerClientConfig?.profile
404
+ });
405
+ const profile = profiles[profileName];
406
+ if (!profile) {
407
+ throw new propertyProvider.TokenProviderError(`Profile '${profileName}' could not be found in shared credentials file.`, false);
408
+ } else if (!profile["sso_session"]) {
409
+ throw new propertyProvider.TokenProviderError(`Profile '${profileName}' is missing required property 'sso_session'.`);
410
+ }
411
+ const ssoSessionName = profile["sso_session"];
412
+ const ssoSessions = await sharedIniFileLoader.loadSsoSessionData(init);
413
+ const ssoSession = ssoSessions[ssoSessionName];
414
+ if (!ssoSession) {
415
+ throw new propertyProvider.TokenProviderError(`Sso session '${ssoSessionName}' could not be found in shared credentials file.`, false);
416
+ }
417
+ for (const ssoSessionRequiredKey of ["sso_start_url", "sso_region"]) {
418
+ if (!ssoSession[ssoSessionRequiredKey]) {
419
+ throw new propertyProvider.TokenProviderError(`Sso session '${ssoSessionName}' is missing required property '${ssoSessionRequiredKey}'.`, false);
420
+ }
421
+ }
422
+ ssoSession["sso_start_url"];
423
+ const ssoRegion = ssoSession["sso_region"];
424
+ let ssoToken;
425
+ try {
426
+ ssoToken = await sharedIniFileLoader.getSSOTokenFromFile(ssoSessionName);
427
+ } catch (e) {
428
+ throw new propertyProvider.TokenProviderError(`The SSO session token associated with profile=${profileName} was not found or is invalid. ${REFRESH_MESSAGE}`, false);
429
+ }
430
+ validateTokenKey("accessToken", ssoToken.accessToken);
431
+ validateTokenKey("expiresAt", ssoToken.expiresAt);
432
+ const { accessToken, expiresAt } = ssoToken;
433
+ const existingToken = { token: accessToken, expiration: new Date(expiresAt) };
434
+ if (existingToken.expiration.getTime() - Date.now() > EXPIRE_WINDOW_MS) {
435
+ return existingToken;
436
+ }
437
+ if (Date.now() - lastRefreshAttemptTime.getTime() < 30000) {
438
+ validateTokenExpiry(existingToken);
439
+ return existingToken;
440
+ }
441
+ validateTokenKey("clientId", ssoToken.clientId, true);
442
+ validateTokenKey("clientSecret", ssoToken.clientSecret, true);
443
+ validateTokenKey("refreshToken", ssoToken.refreshToken, true);
444
+ try {
445
+ lastRefreshAttemptTime.setTime(Date.now());
446
+ const newSsoOidcToken = await getNewSsoOidcToken(ssoToken, ssoRegion, init, callerClientConfig);
447
+ validateTokenKey("accessToken", newSsoOidcToken.accessToken);
448
+ validateTokenKey("expiresIn", newSsoOidcToken.expiresIn);
449
+ const newTokenExpiration = new Date(Date.now() + newSsoOidcToken.expiresIn * 1000);
450
+ try {
451
+ await writeSSOTokenToFile(ssoSessionName, {
452
+ ...ssoToken,
453
+ accessToken: newSsoOidcToken.accessToken,
454
+ expiresAt: newTokenExpiration.toISOString(),
455
+ refreshToken: newSsoOidcToken.refreshToken
456
+ });
457
+ } catch (error) {}
458
+ return {
459
+ token: newSsoOidcToken.accessToken,
460
+ expiration: newTokenExpiration
461
+ };
462
+ } catch (error) {
463
+ validateTokenExpiry(existingToken);
464
+ return existingToken;
465
+ }
466
+ };
467
+ var fromStatic = ({ token, logger }) => async () => {
468
+ logger?.debug("@aws-sdk/token-providers - fromStatic");
469
+ if (!token || !token.token) {
470
+ throw new propertyProvider.TokenProviderError(`Please pass a valid token to fromStatic`, false);
471
+ }
472
+ return token;
473
+ };
474
+ var nodeProvider = (init = {}) => propertyProvider.memoize(propertyProvider.chain(fromSso(init), async () => {
475
+ throw new propertyProvider.TokenProviderError("Could not load token from any providers", false);
476
+ }), (token) => token.expiration !== undefined && token.expiration.getTime() - Date.now() < 300000, (token) => token.expiration !== undefined);
477
+ exports.fromEnvSigningName = fromEnvSigningName;
478
+ exports.fromSso = fromSso;
479
+ exports.fromStatic = fromStatic;
480
+ exports.nodeProvider = nodeProvider;
481
+ });
482
+
483
+ // node_modules/@aws-sdk/client-sso/dist-cjs/auth/httpAuthSchemeProvider.js
484
+ var require_httpAuthSchemeProvider = __commonJS((exports) => {
485
+ Object.defineProperty(exports, "__esModule", { value: true });
486
+ exports.resolveHttpAuthSchemeConfig = exports.defaultSSOHttpAuthSchemeProvider = exports.defaultSSOHttpAuthSchemeParametersProvider = undefined;
487
+ var core_1 = require_dist_cjs10();
488
+ var util_middleware_1 = require_dist_cjs2();
489
+ var defaultSSOHttpAuthSchemeParametersProvider = async (config, context, input) => {
490
+ return {
491
+ operation: (0, util_middleware_1.getSmithyContext)(context).operation,
492
+ region: await (0, util_middleware_1.normalizeProvider)(config.region)() || (() => {
493
+ throw new Error("expected `region` to be configured for `aws.auth#sigv4`");
494
+ })()
495
+ };
496
+ };
497
+ exports.defaultSSOHttpAuthSchemeParametersProvider = defaultSSOHttpAuthSchemeParametersProvider;
498
+ function createAwsAuthSigv4HttpAuthOption(authParameters) {
499
+ return {
500
+ schemeId: "aws.auth#sigv4",
501
+ signingProperties: {
502
+ name: "awsssoportal",
503
+ region: authParameters.region
504
+ },
505
+ propertiesExtractor: (config, context) => ({
506
+ signingProperties: {
507
+ config,
508
+ context
509
+ }
510
+ })
511
+ };
512
+ }
513
+ function createSmithyApiNoAuthHttpAuthOption(authParameters) {
514
+ return {
515
+ schemeId: "smithy.api#noAuth"
516
+ };
517
+ }
518
+ var defaultSSOHttpAuthSchemeProvider = (authParameters) => {
519
+ const options = [];
520
+ switch (authParameters.operation) {
521
+ case "GetRoleCredentials":
522
+ {
523
+ options.push(createSmithyApiNoAuthHttpAuthOption(authParameters));
524
+ break;
525
+ }
526
+ ;
527
+ case "ListAccountRoles":
528
+ {
529
+ options.push(createSmithyApiNoAuthHttpAuthOption(authParameters));
530
+ break;
531
+ }
532
+ ;
533
+ case "ListAccounts":
534
+ {
535
+ options.push(createSmithyApiNoAuthHttpAuthOption(authParameters));
536
+ break;
537
+ }
538
+ ;
539
+ case "Logout":
540
+ {
541
+ options.push(createSmithyApiNoAuthHttpAuthOption(authParameters));
542
+ break;
543
+ }
544
+ ;
545
+ default: {
546
+ options.push(createAwsAuthSigv4HttpAuthOption(authParameters));
547
+ }
548
+ }
549
+ return options;
550
+ };
551
+ exports.defaultSSOHttpAuthSchemeProvider = defaultSSOHttpAuthSchemeProvider;
552
+ var resolveHttpAuthSchemeConfig = (config) => {
553
+ const config_0 = (0, core_1.resolveAwsSdkSigV4Config)(config);
554
+ return Object.assign(config_0, {
555
+ authSchemePreference: (0, util_middleware_1.normalizeProvider)(config.authSchemePreference ?? [])
556
+ });
557
+ };
558
+ exports.resolveHttpAuthSchemeConfig = resolveHttpAuthSchemeConfig;
559
+ });
560
+
561
+ // node_modules/@aws-sdk/client-sso/package.json
562
+ var require_package = __commonJS((exports, module) => {
563
+ module.exports = {
564
+ name: "@aws-sdk/client-sso",
565
+ description: "AWS SDK for JavaScript Sso Client for Node.js, Browser and React Native",
566
+ version: "3.958.0",
567
+ scripts: {
568
+ build: "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
569
+ "build:cjs": "node ../../scripts/compilation/inline client-sso",
570
+ "build:es": "tsc -p tsconfig.es.json",
571
+ "build:include:deps": 'yarn g:turbo run build -F="$npm_package_name"',
572
+ "build:types": "tsc -p tsconfig.types.json",
573
+ "build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
574
+ clean: "rimraf ./dist-* && rimraf *.tsbuildinfo",
575
+ "extract:docs": "api-extractor run --local",
576
+ "generate:client": "node ../../scripts/generate-clients/single-service --solo sso",
577
+ "test:index": "tsc --noEmit ./test/index-types.ts && node ./test/index-objects.spec.mjs"
578
+ },
579
+ main: "./dist-cjs/index.js",
580
+ types: "./dist-types/index.d.ts",
581
+ module: "./dist-es/index.js",
582
+ sideEffects: false,
583
+ dependencies: {
584
+ "@aws-crypto/sha256-browser": "5.2.0",
585
+ "@aws-crypto/sha256-js": "5.2.0",
586
+ "@aws-sdk/core": "3.957.0",
587
+ "@aws-sdk/middleware-host-header": "3.957.0",
588
+ "@aws-sdk/middleware-logger": "3.957.0",
589
+ "@aws-sdk/middleware-recursion-detection": "3.957.0",
590
+ "@aws-sdk/middleware-user-agent": "3.957.0",
591
+ "@aws-sdk/region-config-resolver": "3.957.0",
592
+ "@aws-sdk/types": "3.957.0",
593
+ "@aws-sdk/util-endpoints": "3.957.0",
594
+ "@aws-sdk/util-user-agent-browser": "3.957.0",
595
+ "@aws-sdk/util-user-agent-node": "3.957.0",
596
+ "@smithy/config-resolver": "^4.4.5",
597
+ "@smithy/core": "^3.20.0",
598
+ "@smithy/fetch-http-handler": "^5.3.8",
599
+ "@smithy/hash-node": "^4.2.7",
600
+ "@smithy/invalid-dependency": "^4.2.7",
601
+ "@smithy/middleware-content-length": "^4.2.7",
602
+ "@smithy/middleware-endpoint": "^4.4.1",
603
+ "@smithy/middleware-retry": "^4.4.17",
604
+ "@smithy/middleware-serde": "^4.2.8",
605
+ "@smithy/middleware-stack": "^4.2.7",
606
+ "@smithy/node-config-provider": "^4.3.7",
607
+ "@smithy/node-http-handler": "^4.4.7",
608
+ "@smithy/protocol-http": "^5.3.7",
609
+ "@smithy/smithy-client": "^4.10.2",
610
+ "@smithy/types": "^4.11.0",
611
+ "@smithy/url-parser": "^4.2.7",
612
+ "@smithy/util-base64": "^4.3.0",
613
+ "@smithy/util-body-length-browser": "^4.2.0",
614
+ "@smithy/util-body-length-node": "^4.2.1",
615
+ "@smithy/util-defaults-mode-browser": "^4.3.16",
616
+ "@smithy/util-defaults-mode-node": "^4.2.19",
617
+ "@smithy/util-endpoints": "^3.2.7",
618
+ "@smithy/util-middleware": "^4.2.7",
619
+ "@smithy/util-retry": "^4.2.7",
620
+ "@smithy/util-utf8": "^4.2.0",
621
+ tslib: "^2.6.2"
622
+ },
623
+ devDependencies: {
624
+ "@tsconfig/node18": "18.2.4",
625
+ "@types/node": "^18.19.69",
626
+ concurrently: "7.0.0",
627
+ "downlevel-dts": "0.10.1",
628
+ rimraf: "3.0.2",
629
+ typescript: "~5.8.3"
630
+ },
631
+ engines: {
632
+ node: ">=18.0.0"
633
+ },
634
+ typesVersions: {
635
+ "<4.0": {
636
+ "dist-types/*": [
637
+ "dist-types/ts3.4/*"
638
+ ]
639
+ }
640
+ },
641
+ files: [
642
+ "dist-*/**"
643
+ ],
644
+ author: {
645
+ name: "AWS SDK for JavaScript Team",
646
+ url: "https://aws.amazon.com/javascript/"
647
+ },
648
+ license: "Apache-2.0",
649
+ browser: {
650
+ "./dist-es/runtimeConfig": "./dist-es/runtimeConfig.browser"
651
+ },
652
+ "react-native": {
653
+ "./dist-es/runtimeConfig": "./dist-es/runtimeConfig.native"
654
+ },
655
+ homepage: "https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-sso",
656
+ repository: {
657
+ type: "git",
658
+ url: "https://github.com/aws/aws-sdk-js-v3.git",
659
+ directory: "clients/client-sso"
660
+ }
661
+ };
662
+ });
663
+
664
+ // node_modules/@aws-sdk/client-sso/dist-cjs/endpoint/ruleset.js
665
+ var require_ruleset = __commonJS((exports) => {
666
+ Object.defineProperty(exports, "__esModule", { value: true });
667
+ exports.ruleSet = undefined;
668
+ var u = "required";
669
+ var v = "fn";
670
+ var w = "argv";
671
+ var x = "ref";
672
+ var a = true;
673
+ var b = "isSet";
674
+ var c = "booleanEquals";
675
+ var d = "error";
676
+ var e = "endpoint";
677
+ var f = "tree";
678
+ var g = "PartitionResult";
679
+ var h = "getAttr";
680
+ var i = { [u]: false, type: "string" };
681
+ var j = { [u]: true, default: false, type: "boolean" };
682
+ var k = { [x]: "Endpoint" };
683
+ var l = { [v]: c, [w]: [{ [x]: "UseFIPS" }, true] };
684
+ var m = { [v]: c, [w]: [{ [x]: "UseDualStack" }, true] };
685
+ var n = {};
686
+ var o = { [v]: h, [w]: [{ [x]: g }, "supportsFIPS"] };
687
+ var p = { [x]: g };
688
+ var q = { [v]: c, [w]: [true, { [v]: h, [w]: [p, "supportsDualStack"] }] };
689
+ var r = [l];
690
+ var s = [m];
691
+ var t = [{ [x]: "Region" }];
692
+ var _data = { version: "1.0", parameters: { Region: i, UseDualStack: j, UseFIPS: j, Endpoint: i }, rules: [{ conditions: [{ [v]: b, [w]: [k] }], rules: [{ conditions: r, error: "Invalid Configuration: FIPS and custom endpoint are not supported", type: d }, { conditions: s, error: "Invalid Configuration: Dualstack and custom endpoint are not supported", type: d }, { endpoint: { url: k, properties: n, headers: n }, type: e }], type: f }, { conditions: [{ [v]: b, [w]: t }], rules: [{ conditions: [{ [v]: "aws.partition", [w]: t, assign: g }], rules: [{ conditions: [l, m], rules: [{ conditions: [{ [v]: c, [w]: [a, o] }, q], rules: [{ endpoint: { url: "https://portal.sso-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", properties: n, headers: n }, type: e }], type: f }, { error: "FIPS and DualStack are enabled, but this partition does not support one or both", type: d }], type: f }, { conditions: r, rules: [{ conditions: [{ [v]: c, [w]: [o, a] }], rules: [{ conditions: [{ [v]: "stringEquals", [w]: [{ [v]: h, [w]: [p, "name"] }, "aws-us-gov"] }], endpoint: { url: "https://portal.sso.{Region}.amazonaws.com", properties: n, headers: n }, type: e }, { endpoint: { url: "https://portal.sso-fips.{Region}.{PartitionResult#dnsSuffix}", properties: n, headers: n }, type: e }], type: f }, { error: "FIPS is enabled but this partition does not support FIPS", type: d }], type: f }, { conditions: s, rules: [{ conditions: [q], rules: [{ endpoint: { url: "https://portal.sso.{Region}.{PartitionResult#dualStackDnsSuffix}", properties: n, headers: n }, type: e }], type: f }, { error: "DualStack is enabled but this partition does not support DualStack", type: d }], type: f }, { endpoint: { url: "https://portal.sso.{Region}.{PartitionResult#dnsSuffix}", properties: n, headers: n }, type: e }], type: f }], type: f }, { error: "Invalid Configuration: Missing Region", type: d }] };
693
+ exports.ruleSet = _data;
694
+ });
695
+
696
+ // node_modules/@aws-sdk/client-sso/dist-cjs/endpoint/endpointResolver.js
697
+ var require_endpointResolver = __commonJS((exports) => {
698
+ Object.defineProperty(exports, "__esModule", { value: true });
699
+ exports.defaultEndpointResolver = undefined;
700
+ var util_endpoints_1 = require_dist_cjs16();
701
+ var util_endpoints_2 = require_dist_cjs14();
702
+ var ruleset_1 = require_ruleset();
703
+ var cache = new util_endpoints_2.EndpointCache({
704
+ size: 50,
705
+ params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"]
706
+ });
707
+ var defaultEndpointResolver = (endpointParams, context = {}) => {
708
+ return cache.get(endpointParams, () => (0, util_endpoints_2.resolveEndpoint)(ruleset_1.ruleSet, {
709
+ endpointParams,
710
+ logger: context.logger
711
+ }));
712
+ };
713
+ exports.defaultEndpointResolver = defaultEndpointResolver;
714
+ util_endpoints_2.customEndpointFunctions.aws = util_endpoints_1.awsEndpointFunctions;
715
+ });
716
+
717
+ // node_modules/@aws-sdk/client-sso/dist-cjs/runtimeConfig.shared.js
718
+ var require_runtimeConfig_shared = __commonJS((exports) => {
719
+ Object.defineProperty(exports, "__esModule", { value: true });
720
+ exports.getRuntimeConfig = undefined;
721
+ var core_1 = require_dist_cjs10();
722
+ var protocols_1 = require_protocols();
723
+ var core_2 = require_dist_cjs6();
724
+ var smithy_client_1 = require_dist_cjs9();
725
+ var url_parser_1 = require_dist_cjs15();
726
+ var util_base64_1 = require_dist_cjs4();
727
+ var util_utf8_1 = require_dist_cjs3();
728
+ var httpAuthSchemeProvider_1 = require_httpAuthSchemeProvider();
729
+ var endpointResolver_1 = require_endpointResolver();
730
+ var getRuntimeConfig = (config) => {
731
+ return {
732
+ apiVersion: "2019-06-10",
733
+ base64Decoder: config?.base64Decoder ?? util_base64_1.fromBase64,
734
+ base64Encoder: config?.base64Encoder ?? util_base64_1.toBase64,
735
+ disableHostPrefix: config?.disableHostPrefix ?? false,
736
+ endpointProvider: config?.endpointProvider ?? endpointResolver_1.defaultEndpointResolver,
737
+ extensions: config?.extensions ?? [],
738
+ httpAuthSchemeProvider: config?.httpAuthSchemeProvider ?? httpAuthSchemeProvider_1.defaultSSOHttpAuthSchemeProvider,
739
+ httpAuthSchemes: config?.httpAuthSchemes ?? [
740
+ {
741
+ schemeId: "aws.auth#sigv4",
742
+ identityProvider: (ipc) => ipc.getIdentityProvider("aws.auth#sigv4"),
743
+ signer: new core_1.AwsSdkSigV4Signer
744
+ },
745
+ {
746
+ schemeId: "smithy.api#noAuth",
747
+ identityProvider: (ipc) => ipc.getIdentityProvider("smithy.api#noAuth") || (async () => ({})),
748
+ signer: new core_2.NoAuthSigner
749
+ }
750
+ ],
751
+ logger: config?.logger ?? new smithy_client_1.NoOpLogger,
752
+ protocol: config?.protocol ?? protocols_1.AwsRestJsonProtocol,
753
+ protocolSettings: config?.protocolSettings ?? {
754
+ defaultNamespace: "com.amazonaws.sso",
755
+ version: "2019-06-10",
756
+ serviceTarget: "SWBPortalService"
757
+ },
758
+ serviceId: config?.serviceId ?? "SSO",
759
+ urlParser: config?.urlParser ?? url_parser_1.parseUrl,
760
+ utf8Decoder: config?.utf8Decoder ?? util_utf8_1.fromUtf8,
761
+ utf8Encoder: config?.utf8Encoder ?? util_utf8_1.toUtf8
762
+ };
763
+ };
764
+ exports.getRuntimeConfig = getRuntimeConfig;
765
+ });
766
+
767
+ // node_modules/@aws-sdk/client-sso/dist-cjs/runtimeConfig.js
768
+ var require_runtimeConfig = __commonJS((exports) => {
769
+ Object.defineProperty(exports, "__esModule", { value: true });
770
+ exports.getRuntimeConfig = undefined;
771
+ var tslib_1 = require_tslib();
772
+ var package_json_1 = tslib_1.__importDefault(require_package());
773
+ var core_1 = require_dist_cjs10();
774
+ var util_user_agent_node_1 = require_dist_cjs25();
775
+ var config_resolver_1 = require_dist_cjs18();
776
+ var hash_node_1 = require_dist_cjs26();
777
+ var middleware_retry_1 = require_dist_cjs24();
778
+ var node_config_provider_1 = require_dist_cjs21();
779
+ var node_http_handler_1 = require_dist_cjs5();
780
+ var smithy_client_1 = require_dist_cjs9();
781
+ var util_body_length_node_1 = require_dist_cjs27();
782
+ var util_defaults_mode_node_1 = require_dist_cjs28();
783
+ var util_retry_1 = require_dist_cjs23();
784
+ var runtimeConfig_shared_1 = require_runtimeConfig_shared();
785
+ var getRuntimeConfig = (config) => {
786
+ (0, smithy_client_1.emitWarningIfUnsupportedVersion)(process.version);
787
+ const defaultsMode = (0, util_defaults_mode_node_1.resolveDefaultsModeConfig)(config);
788
+ const defaultConfigProvider = () => defaultsMode().then(smithy_client_1.loadConfigsForDefaultMode);
789
+ const clientSharedValues = (0, runtimeConfig_shared_1.getRuntimeConfig)(config);
790
+ (0, core_1.emitWarningIfUnsupportedVersion)(process.version);
791
+ const loaderConfig = {
792
+ profile: config?.profile,
793
+ logger: clientSharedValues.logger
794
+ };
795
+ return {
796
+ ...clientSharedValues,
797
+ ...config,
798
+ runtime: "node",
799
+ defaultsMode,
800
+ authSchemePreference: config?.authSchemePreference ?? (0, node_config_provider_1.loadConfig)(core_1.NODE_AUTH_SCHEME_PREFERENCE_OPTIONS, loaderConfig),
801
+ bodyLengthChecker: config?.bodyLengthChecker ?? util_body_length_node_1.calculateBodyLength,
802
+ defaultUserAgentProvider: config?.defaultUserAgentProvider ?? (0, util_user_agent_node_1.createDefaultUserAgentProvider)({ serviceId: clientSharedValues.serviceId, clientVersion: package_json_1.default.version }),
803
+ maxAttempts: config?.maxAttempts ?? (0, node_config_provider_1.loadConfig)(middleware_retry_1.NODE_MAX_ATTEMPT_CONFIG_OPTIONS, config),
804
+ region: config?.region ?? (0, node_config_provider_1.loadConfig)(config_resolver_1.NODE_REGION_CONFIG_OPTIONS, { ...config_resolver_1.NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig }),
805
+ requestHandler: node_http_handler_1.NodeHttpHandler.create(config?.requestHandler ?? defaultConfigProvider),
806
+ retryMode: config?.retryMode ?? (0, node_config_provider_1.loadConfig)({
807
+ ...middleware_retry_1.NODE_RETRY_MODE_CONFIG_OPTIONS,
808
+ default: async () => (await defaultConfigProvider()).retryMode || util_retry_1.DEFAULT_RETRY_MODE
809
+ }, config),
810
+ sha256: config?.sha256 ?? hash_node_1.Hash.bind(null, "sha256"),
811
+ streamCollector: config?.streamCollector ?? node_http_handler_1.streamCollector,
812
+ useDualstackEndpoint: config?.useDualstackEndpoint ?? (0, node_config_provider_1.loadConfig)(config_resolver_1.NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
813
+ useFipsEndpoint: config?.useFipsEndpoint ?? (0, node_config_provider_1.loadConfig)(config_resolver_1.NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
814
+ userAgentAppId: config?.userAgentAppId ?? (0, node_config_provider_1.loadConfig)(util_user_agent_node_1.NODE_APP_ID_CONFIG_OPTIONS, loaderConfig)
815
+ };
816
+ };
817
+ exports.getRuntimeConfig = getRuntimeConfig;
818
+ });
819
+
820
+ // node_modules/@aws-sdk/client-sso/dist-cjs/index.js
821
+ var require_dist_cjs31 = __commonJS((exports) => {
822
+ var middlewareHostHeader = require_dist_cjs11();
823
+ var middlewareLogger = require_dist_cjs12();
824
+ var middlewareRecursionDetection = require_dist_cjs13();
825
+ var middlewareUserAgent = require_dist_cjs17();
826
+ var configResolver = require_dist_cjs18();
827
+ var core = require_dist_cjs6();
828
+ var schema = require_schema();
829
+ var middlewareContentLength = require_dist_cjs19();
830
+ var middlewareEndpoint = require_dist_cjs22();
831
+ var middlewareRetry = require_dist_cjs24();
832
+ var smithyClient = require_dist_cjs9();
833
+ var httpAuthSchemeProvider = require_httpAuthSchemeProvider();
834
+ var runtimeConfig = require_runtimeConfig();
835
+ var regionConfigResolver = require_dist_cjs29();
836
+ var protocolHttp = require_dist_cjs();
837
+ var resolveClientEndpointParameters = (options) => {
838
+ return Object.assign(options, {
839
+ useDualstackEndpoint: options.useDualstackEndpoint ?? false,
840
+ useFipsEndpoint: options.useFipsEndpoint ?? false,
841
+ defaultSigningName: "awsssoportal"
842
+ });
843
+ };
844
+ var commonParams = {
845
+ UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
846
+ Endpoint: { type: "builtInParams", name: "endpoint" },
847
+ Region: { type: "builtInParams", name: "region" },
848
+ UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }
849
+ };
850
+ var getHttpAuthExtensionConfiguration = (runtimeConfig2) => {
851
+ const _httpAuthSchemes = runtimeConfig2.httpAuthSchemes;
852
+ let _httpAuthSchemeProvider = runtimeConfig2.httpAuthSchemeProvider;
853
+ let _credentials = runtimeConfig2.credentials;
854
+ return {
855
+ setHttpAuthScheme(httpAuthScheme) {
856
+ const index = _httpAuthSchemes.findIndex((scheme) => scheme.schemeId === httpAuthScheme.schemeId);
857
+ if (index === -1) {
858
+ _httpAuthSchemes.push(httpAuthScheme);
859
+ } else {
860
+ _httpAuthSchemes.splice(index, 1, httpAuthScheme);
861
+ }
862
+ },
863
+ httpAuthSchemes() {
864
+ return _httpAuthSchemes;
865
+ },
866
+ setHttpAuthSchemeProvider(httpAuthSchemeProvider2) {
867
+ _httpAuthSchemeProvider = httpAuthSchemeProvider2;
868
+ },
869
+ httpAuthSchemeProvider() {
870
+ return _httpAuthSchemeProvider;
871
+ },
872
+ setCredentials(credentials) {
873
+ _credentials = credentials;
874
+ },
875
+ credentials() {
876
+ return _credentials;
877
+ }
878
+ };
879
+ };
880
+ var resolveHttpAuthRuntimeConfig = (config) => {
881
+ return {
882
+ httpAuthSchemes: config.httpAuthSchemes(),
883
+ httpAuthSchemeProvider: config.httpAuthSchemeProvider(),
884
+ credentials: config.credentials()
885
+ };
886
+ };
887
+ var resolveRuntimeExtensions = (runtimeConfig2, extensions) => {
888
+ const extensionConfiguration = Object.assign(regionConfigResolver.getAwsRegionExtensionConfiguration(runtimeConfig2), smithyClient.getDefaultExtensionConfiguration(runtimeConfig2), protocolHttp.getHttpHandlerExtensionConfiguration(runtimeConfig2), getHttpAuthExtensionConfiguration(runtimeConfig2));
889
+ extensions.forEach((extension) => extension.configure(extensionConfiguration));
890
+ return Object.assign(runtimeConfig2, regionConfigResolver.resolveAwsRegionExtensionConfiguration(extensionConfiguration), smithyClient.resolveDefaultRuntimeConfig(extensionConfiguration), protocolHttp.resolveHttpHandlerRuntimeConfig(extensionConfiguration), resolveHttpAuthRuntimeConfig(extensionConfiguration));
891
+ };
892
+
893
+ class SSOClient extends smithyClient.Client {
894
+ config;
895
+ constructor(...[configuration]) {
896
+ const _config_0 = runtimeConfig.getRuntimeConfig(configuration || {});
897
+ super(_config_0);
898
+ this.initConfig = _config_0;
899
+ const _config_1 = resolveClientEndpointParameters(_config_0);
900
+ const _config_2 = middlewareUserAgent.resolveUserAgentConfig(_config_1);
901
+ const _config_3 = middlewareRetry.resolveRetryConfig(_config_2);
902
+ const _config_4 = configResolver.resolveRegionConfig(_config_3);
903
+ const _config_5 = middlewareHostHeader.resolveHostHeaderConfig(_config_4);
904
+ const _config_6 = middlewareEndpoint.resolveEndpointConfig(_config_5);
905
+ const _config_7 = httpAuthSchemeProvider.resolveHttpAuthSchemeConfig(_config_6);
906
+ const _config_8 = resolveRuntimeExtensions(_config_7, configuration?.extensions || []);
907
+ this.config = _config_8;
908
+ this.middlewareStack.use(schema.getSchemaSerdePlugin(this.config));
909
+ this.middlewareStack.use(middlewareUserAgent.getUserAgentPlugin(this.config));
910
+ this.middlewareStack.use(middlewareRetry.getRetryPlugin(this.config));
911
+ this.middlewareStack.use(middlewareContentLength.getContentLengthPlugin(this.config));
912
+ this.middlewareStack.use(middlewareHostHeader.getHostHeaderPlugin(this.config));
913
+ this.middlewareStack.use(middlewareLogger.getLoggerPlugin(this.config));
914
+ this.middlewareStack.use(middlewareRecursionDetection.getRecursionDetectionPlugin(this.config));
915
+ this.middlewareStack.use(core.getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
916
+ httpAuthSchemeParametersProvider: httpAuthSchemeProvider.defaultSSOHttpAuthSchemeParametersProvider,
917
+ identityProviderConfigProvider: async (config) => new core.DefaultIdentityProviderConfig({
918
+ "aws.auth#sigv4": config.credentials
919
+ })
920
+ }));
921
+ this.middlewareStack.use(core.getHttpSigningPlugin(this.config));
922
+ }
923
+ destroy() {
924
+ super.destroy();
925
+ }
926
+ }
927
+
928
+ class SSOServiceException extends smithyClient.ServiceException {
929
+ constructor(options) {
930
+ super(options);
931
+ Object.setPrototypeOf(this, SSOServiceException.prototype);
932
+ }
933
+ }
934
+
935
+ class InvalidRequestException extends SSOServiceException {
936
+ name = "InvalidRequestException";
937
+ $fault = "client";
938
+ constructor(opts) {
939
+ super({
940
+ name: "InvalidRequestException",
941
+ $fault: "client",
942
+ ...opts
943
+ });
944
+ Object.setPrototypeOf(this, InvalidRequestException.prototype);
945
+ }
946
+ }
947
+
948
+ class ResourceNotFoundException extends SSOServiceException {
949
+ name = "ResourceNotFoundException";
950
+ $fault = "client";
951
+ constructor(opts) {
952
+ super({
953
+ name: "ResourceNotFoundException",
954
+ $fault: "client",
955
+ ...opts
956
+ });
957
+ Object.setPrototypeOf(this, ResourceNotFoundException.prototype);
958
+ }
959
+ }
960
+
961
+ class TooManyRequestsException extends SSOServiceException {
962
+ name = "TooManyRequestsException";
963
+ $fault = "client";
964
+ constructor(opts) {
965
+ super({
966
+ name: "TooManyRequestsException",
967
+ $fault: "client",
968
+ ...opts
969
+ });
970
+ Object.setPrototypeOf(this, TooManyRequestsException.prototype);
971
+ }
972
+ }
973
+
974
+ class UnauthorizedException extends SSOServiceException {
975
+ name = "UnauthorizedException";
976
+ $fault = "client";
977
+ constructor(opts) {
978
+ super({
979
+ name: "UnauthorizedException",
980
+ $fault: "client",
981
+ ...opts
982
+ });
983
+ Object.setPrototypeOf(this, UnauthorizedException.prototype);
984
+ }
985
+ }
986
+ var _AI = "AccountInfo";
987
+ var _ALT = "AccountListType";
988
+ var _ATT = "AccessTokenType";
989
+ var _GRC = "GetRoleCredentials";
990
+ var _GRCR = "GetRoleCredentialsRequest";
991
+ var _GRCRe = "GetRoleCredentialsResponse";
992
+ var _IRE = "InvalidRequestException";
993
+ var _L = "Logout";
994
+ var _LA = "ListAccounts";
995
+ var _LAR = "ListAccountsRequest";
996
+ var _LARR = "ListAccountRolesRequest";
997
+ var _LARRi = "ListAccountRolesResponse";
998
+ var _LARi = "ListAccountsResponse";
999
+ var _LARis = "ListAccountRoles";
1000
+ var _LR = "LogoutRequest";
1001
+ var _RC = "RoleCredentials";
1002
+ var _RI = "RoleInfo";
1003
+ var _RLT = "RoleListType";
1004
+ var _RNFE = "ResourceNotFoundException";
1005
+ var _SAKT = "SecretAccessKeyType";
1006
+ var _STT = "SessionTokenType";
1007
+ var _TMRE = "TooManyRequestsException";
1008
+ var _UE = "UnauthorizedException";
1009
+ var _aI = "accountId";
1010
+ var _aKI = "accessKeyId";
1011
+ var _aL = "accountList";
1012
+ var _aN = "accountName";
1013
+ var _aT = "accessToken";
1014
+ var _ai = "account_id";
1015
+ var _c = "client";
1016
+ var _e = "error";
1017
+ var _eA = "emailAddress";
1018
+ var _ex = "expiration";
1019
+ var _h = "http";
1020
+ var _hE = "httpError";
1021
+ var _hH = "httpHeader";
1022
+ var _hQ = "httpQuery";
1023
+ var _m = "message";
1024
+ var _mR = "maxResults";
1025
+ var _mr = "max_result";
1026
+ var _nT = "nextToken";
1027
+ var _nt = "next_token";
1028
+ var _rC = "roleCredentials";
1029
+ var _rL = "roleList";
1030
+ var _rN = "roleName";
1031
+ var _rn = "role_name";
1032
+ var _s = "smithy.ts.sdk.synthetic.com.amazonaws.sso";
1033
+ var _sAK = "secretAccessKey";
1034
+ var _sT = "sessionToken";
1035
+ var _xasbt = "x-amz-sso_bearer_token";
1036
+ var n0 = "com.amazonaws.sso";
1037
+ var AccessTokenType = [0, n0, _ATT, 8, 0];
1038
+ var SecretAccessKeyType = [0, n0, _SAKT, 8, 0];
1039
+ var SessionTokenType = [0, n0, _STT, 8, 0];
1040
+ var AccountInfo$ = [
1041
+ 3,
1042
+ n0,
1043
+ _AI,
1044
+ 0,
1045
+ [_aI, _aN, _eA],
1046
+ [0, 0, 0]
1047
+ ];
1048
+ var GetRoleCredentialsRequest$ = [
1049
+ 3,
1050
+ n0,
1051
+ _GRCR,
1052
+ 0,
1053
+ [_rN, _aI, _aT],
1054
+ [[0, { [_hQ]: _rn }], [0, { [_hQ]: _ai }], [() => AccessTokenType, { [_hH]: _xasbt }]]
1055
+ ];
1056
+ var GetRoleCredentialsResponse$ = [
1057
+ 3,
1058
+ n0,
1059
+ _GRCRe,
1060
+ 0,
1061
+ [_rC],
1062
+ [[() => RoleCredentials$, 0]]
1063
+ ];
1064
+ var InvalidRequestException$ = [
1065
+ -3,
1066
+ n0,
1067
+ _IRE,
1068
+ { [_e]: _c, [_hE]: 400 },
1069
+ [_m],
1070
+ [0]
1071
+ ];
1072
+ schema.TypeRegistry.for(n0).registerError(InvalidRequestException$, InvalidRequestException);
1073
+ var ListAccountRolesRequest$ = [
1074
+ 3,
1075
+ n0,
1076
+ _LARR,
1077
+ 0,
1078
+ [_nT, _mR, _aT, _aI],
1079
+ [[0, { [_hQ]: _nt }], [1, { [_hQ]: _mr }], [() => AccessTokenType, { [_hH]: _xasbt }], [0, { [_hQ]: _ai }]]
1080
+ ];
1081
+ var ListAccountRolesResponse$ = [
1082
+ 3,
1083
+ n0,
1084
+ _LARRi,
1085
+ 0,
1086
+ [_nT, _rL],
1087
+ [0, () => RoleListType]
1088
+ ];
1089
+ var ListAccountsRequest$ = [
1090
+ 3,
1091
+ n0,
1092
+ _LAR,
1093
+ 0,
1094
+ [_nT, _mR, _aT],
1095
+ [[0, { [_hQ]: _nt }], [1, { [_hQ]: _mr }], [() => AccessTokenType, { [_hH]: _xasbt }]]
1096
+ ];
1097
+ var ListAccountsResponse$ = [
1098
+ 3,
1099
+ n0,
1100
+ _LARi,
1101
+ 0,
1102
+ [_nT, _aL],
1103
+ [0, () => AccountListType]
1104
+ ];
1105
+ var LogoutRequest$ = [
1106
+ 3,
1107
+ n0,
1108
+ _LR,
1109
+ 0,
1110
+ [_aT],
1111
+ [[() => AccessTokenType, { [_hH]: _xasbt }]]
1112
+ ];
1113
+ var ResourceNotFoundException$ = [
1114
+ -3,
1115
+ n0,
1116
+ _RNFE,
1117
+ { [_e]: _c, [_hE]: 404 },
1118
+ [_m],
1119
+ [0]
1120
+ ];
1121
+ schema.TypeRegistry.for(n0).registerError(ResourceNotFoundException$, ResourceNotFoundException);
1122
+ var RoleCredentials$ = [
1123
+ 3,
1124
+ n0,
1125
+ _RC,
1126
+ 0,
1127
+ [_aKI, _sAK, _sT, _ex],
1128
+ [0, [() => SecretAccessKeyType, 0], [() => SessionTokenType, 0], 1]
1129
+ ];
1130
+ var RoleInfo$ = [
1131
+ 3,
1132
+ n0,
1133
+ _RI,
1134
+ 0,
1135
+ [_rN, _aI],
1136
+ [0, 0]
1137
+ ];
1138
+ var TooManyRequestsException$ = [
1139
+ -3,
1140
+ n0,
1141
+ _TMRE,
1142
+ { [_e]: _c, [_hE]: 429 },
1143
+ [_m],
1144
+ [0]
1145
+ ];
1146
+ schema.TypeRegistry.for(n0).registerError(TooManyRequestsException$, TooManyRequestsException);
1147
+ var UnauthorizedException$ = [
1148
+ -3,
1149
+ n0,
1150
+ _UE,
1151
+ { [_e]: _c, [_hE]: 401 },
1152
+ [_m],
1153
+ [0]
1154
+ ];
1155
+ schema.TypeRegistry.for(n0).registerError(UnauthorizedException$, UnauthorizedException);
1156
+ var __Unit = "unit";
1157
+ var SSOServiceException$ = [-3, _s, "SSOServiceException", 0, [], []];
1158
+ schema.TypeRegistry.for(_s).registerError(SSOServiceException$, SSOServiceException);
1159
+ var AccountListType = [
1160
+ 1,
1161
+ n0,
1162
+ _ALT,
1163
+ 0,
1164
+ () => AccountInfo$
1165
+ ];
1166
+ var RoleListType = [
1167
+ 1,
1168
+ n0,
1169
+ _RLT,
1170
+ 0,
1171
+ () => RoleInfo$
1172
+ ];
1173
+ var GetRoleCredentials$ = [
1174
+ 9,
1175
+ n0,
1176
+ _GRC,
1177
+ { [_h]: ["GET", "/federation/credentials", 200] },
1178
+ () => GetRoleCredentialsRequest$,
1179
+ () => GetRoleCredentialsResponse$
1180
+ ];
1181
+ var ListAccountRoles$ = [
1182
+ 9,
1183
+ n0,
1184
+ _LARis,
1185
+ { [_h]: ["GET", "/assignment/roles", 200] },
1186
+ () => ListAccountRolesRequest$,
1187
+ () => ListAccountRolesResponse$
1188
+ ];
1189
+ var ListAccounts$ = [
1190
+ 9,
1191
+ n0,
1192
+ _LA,
1193
+ { [_h]: ["GET", "/assignment/accounts", 200] },
1194
+ () => ListAccountsRequest$,
1195
+ () => ListAccountsResponse$
1196
+ ];
1197
+ var Logout$ = [
1198
+ 9,
1199
+ n0,
1200
+ _L,
1201
+ { [_h]: ["POST", "/logout", 200] },
1202
+ () => LogoutRequest$,
1203
+ () => __Unit
1204
+ ];
1205
+
1206
+ class GetRoleCredentialsCommand extends smithyClient.Command.classBuilder().ep(commonParams).m(function(Command, cs, config, o) {
1207
+ return [middlewareEndpoint.getEndpointPlugin(config, Command.getEndpointParameterInstructions())];
1208
+ }).s("SWBPortalService", "GetRoleCredentials", {}).n("SSOClient", "GetRoleCredentialsCommand").sc(GetRoleCredentials$).build() {
1209
+ }
1210
+
1211
+ class ListAccountRolesCommand extends smithyClient.Command.classBuilder().ep(commonParams).m(function(Command, cs, config, o) {
1212
+ return [middlewareEndpoint.getEndpointPlugin(config, Command.getEndpointParameterInstructions())];
1213
+ }).s("SWBPortalService", "ListAccountRoles", {}).n("SSOClient", "ListAccountRolesCommand").sc(ListAccountRoles$).build() {
1214
+ }
1215
+
1216
+ class ListAccountsCommand extends smithyClient.Command.classBuilder().ep(commonParams).m(function(Command, cs, config, o) {
1217
+ return [middlewareEndpoint.getEndpointPlugin(config, Command.getEndpointParameterInstructions())];
1218
+ }).s("SWBPortalService", "ListAccounts", {}).n("SSOClient", "ListAccountsCommand").sc(ListAccounts$).build() {
1219
+ }
1220
+
1221
+ class LogoutCommand extends smithyClient.Command.classBuilder().ep(commonParams).m(function(Command, cs, config, o) {
1222
+ return [middlewareEndpoint.getEndpointPlugin(config, Command.getEndpointParameterInstructions())];
1223
+ }).s("SWBPortalService", "Logout", {}).n("SSOClient", "LogoutCommand").sc(Logout$).build() {
1224
+ }
1225
+ var commands = {
1226
+ GetRoleCredentialsCommand,
1227
+ ListAccountRolesCommand,
1228
+ ListAccountsCommand,
1229
+ LogoutCommand
1230
+ };
1231
+
1232
+ class SSO extends SSOClient {
1233
+ }
1234
+ smithyClient.createAggregatedClient(commands, SSO);
1235
+ var paginateListAccountRoles = core.createPaginator(SSOClient, ListAccountRolesCommand, "nextToken", "nextToken", "maxResults");
1236
+ var paginateListAccounts = core.createPaginator(SSOClient, ListAccountsCommand, "nextToken", "nextToken", "maxResults");
1237
+ Object.defineProperty(exports, "$Command", {
1238
+ enumerable: true,
1239
+ get: function() {
1240
+ return smithyClient.Command;
1241
+ }
1242
+ });
1243
+ Object.defineProperty(exports, "__Client", {
1244
+ enumerable: true,
1245
+ get: function() {
1246
+ return smithyClient.Client;
1247
+ }
1248
+ });
1249
+ exports.AccountInfo$ = AccountInfo$;
1250
+ exports.GetRoleCredentials$ = GetRoleCredentials$;
1251
+ exports.GetRoleCredentialsCommand = GetRoleCredentialsCommand;
1252
+ exports.GetRoleCredentialsRequest$ = GetRoleCredentialsRequest$;
1253
+ exports.GetRoleCredentialsResponse$ = GetRoleCredentialsResponse$;
1254
+ exports.InvalidRequestException = InvalidRequestException;
1255
+ exports.InvalidRequestException$ = InvalidRequestException$;
1256
+ exports.ListAccountRoles$ = ListAccountRoles$;
1257
+ exports.ListAccountRolesCommand = ListAccountRolesCommand;
1258
+ exports.ListAccountRolesRequest$ = ListAccountRolesRequest$;
1259
+ exports.ListAccountRolesResponse$ = ListAccountRolesResponse$;
1260
+ exports.ListAccounts$ = ListAccounts$;
1261
+ exports.ListAccountsCommand = ListAccountsCommand;
1262
+ exports.ListAccountsRequest$ = ListAccountsRequest$;
1263
+ exports.ListAccountsResponse$ = ListAccountsResponse$;
1264
+ exports.Logout$ = Logout$;
1265
+ exports.LogoutCommand = LogoutCommand;
1266
+ exports.LogoutRequest$ = LogoutRequest$;
1267
+ exports.ResourceNotFoundException = ResourceNotFoundException;
1268
+ exports.ResourceNotFoundException$ = ResourceNotFoundException$;
1269
+ exports.RoleCredentials$ = RoleCredentials$;
1270
+ exports.RoleInfo$ = RoleInfo$;
1271
+ exports.SSO = SSO;
1272
+ exports.SSOClient = SSOClient;
1273
+ exports.SSOServiceException = SSOServiceException;
1274
+ exports.SSOServiceException$ = SSOServiceException$;
1275
+ exports.TooManyRequestsException = TooManyRequestsException;
1276
+ exports.TooManyRequestsException$ = TooManyRequestsException$;
1277
+ exports.UnauthorizedException = UnauthorizedException;
1278
+ exports.UnauthorizedException$ = UnauthorizedException$;
1279
+ exports.paginateListAccountRoles = paginateListAccountRoles;
1280
+ exports.paginateListAccounts = paginateListAccounts;
1281
+ });
1282
+
1283
+ // node_modules/@aws-sdk/credential-provider-sso/dist-cjs/loadSso-CVy8iqsZ.js
1284
+ var require_loadSso_CVy8iqsZ = __commonJS((exports) => {
1285
+ var clientSso = require_dist_cjs31();
1286
+ Object.defineProperty(exports, "GetRoleCredentialsCommand", {
1287
+ enumerable: true,
1288
+ get: function() {
1289
+ return clientSso.GetRoleCredentialsCommand;
1290
+ }
1291
+ });
1292
+ Object.defineProperty(exports, "SSOClient", {
1293
+ enumerable: true,
1294
+ get: function() {
1295
+ return clientSso.SSOClient;
1296
+ }
1297
+ });
1298
+ });
1299
+
1300
+ // node_modules/@aws-sdk/credential-provider-sso/dist-cjs/index.js
1301
+ var propertyProvider, sharedIniFileLoader, client, tokenProviders, 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"), SHOULD_FAIL_CREDENTIAL_CHAIN = false, resolveSSOCredentials = async ({ ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, clientConfig, parentClientConfig, callerClientConfig, profile, filepath, configFilepath, ignoreCache, logger }) => {
1302
+ let token;
1303
+ const refreshMessage = `To refresh this SSO session run aws sso login with the corresponding profile.`;
1304
+ if (ssoSession) {
1305
+ try {
1306
+ const _token = await tokenProviders.fromSso({
1307
+ profile,
1308
+ filepath,
1309
+ configFilepath,
1310
+ ignoreCache
1311
+ })();
1312
+ token = {
1313
+ accessToken: _token.token,
1314
+ expiresAt: new Date(_token.expiration).toISOString()
1315
+ };
1316
+ } catch (e) {
1317
+ throw new propertyProvider.CredentialsProviderError(e.message, {
1318
+ tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
1319
+ logger
1320
+ });
1321
+ }
1322
+ } else {
1323
+ try {
1324
+ token = await sharedIniFileLoader.getSSOTokenFromFile(ssoStartUrl);
1325
+ } catch (e) {
1326
+ throw new propertyProvider.CredentialsProviderError(`The SSO session associated with this profile is invalid. ${refreshMessage}`, {
1327
+ tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
1328
+ logger
1329
+ });
1330
+ }
1331
+ }
1332
+ if (new Date(token.expiresAt).getTime() - Date.now() <= 0) {
1333
+ throw new propertyProvider.CredentialsProviderError(`The SSO session associated with this profile has expired. ${refreshMessage}`, {
1334
+ tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
1335
+ logger
1336
+ });
1337
+ }
1338
+ const { accessToken } = token;
1339
+ const { SSOClient, GetRoleCredentialsCommand } = await Promise.resolve().then(function() {
1340
+ return require_loadSso_CVy8iqsZ();
1341
+ });
1342
+ const sso = ssoClient || new SSOClient(Object.assign({}, clientConfig ?? {}, {
1343
+ logger: clientConfig?.logger ?? callerClientConfig?.logger ?? parentClientConfig?.logger,
1344
+ region: clientConfig?.region ?? ssoRegion,
1345
+ userAgentAppId: clientConfig?.userAgentAppId ?? callerClientConfig?.userAgentAppId ?? parentClientConfig?.userAgentAppId
1346
+ }));
1347
+ let ssoResp;
1348
+ try {
1349
+ ssoResp = await sso.send(new GetRoleCredentialsCommand({
1350
+ accountId: ssoAccountId,
1351
+ roleName: ssoRoleName,
1352
+ accessToken
1353
+ }));
1354
+ } catch (e) {
1355
+ throw new propertyProvider.CredentialsProviderError(e, {
1356
+ tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
1357
+ logger
1358
+ });
1359
+ }
1360
+ const { roleCredentials: { accessKeyId, secretAccessKey, sessionToken, expiration, credentialScope, accountId } = {} } = ssoResp;
1361
+ if (!accessKeyId || !secretAccessKey || !sessionToken || !expiration) {
1362
+ throw new propertyProvider.CredentialsProviderError("SSO returns an invalid temporary credential.", {
1363
+ tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
1364
+ logger
1365
+ });
1366
+ }
1367
+ const credentials = {
1368
+ accessKeyId,
1369
+ secretAccessKey,
1370
+ sessionToken,
1371
+ expiration: new Date(expiration),
1372
+ ...credentialScope && { credentialScope },
1373
+ ...accountId && { accountId }
1374
+ };
1375
+ if (ssoSession) {
1376
+ client.setCredentialFeature(credentials, "CREDENTIALS_SSO", "s");
1377
+ } else {
1378
+ client.setCredentialFeature(credentials, "CREDENTIALS_SSO_LEGACY", "u");
1379
+ }
1380
+ return credentials;
1381
+ }, validateSsoProfile = (profile, logger) => {
1382
+ const { sso_start_url, sso_account_id, sso_region, sso_role_name } = profile;
1383
+ if (!sso_start_url || !sso_account_id || !sso_region || !sso_role_name) {
1384
+ throw new propertyProvider.CredentialsProviderError(`Profile is configured with invalid SSO credentials. Required parameters "sso_account_id", ` + `"sso_region", "sso_role_name", "sso_start_url". Got ${Object.keys(profile).join(", ")}
1385
+ Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html`, { tryNextLink: false, logger });
1386
+ }
1387
+ return profile;
1388
+ }, fromSSO = (init = {}) => async ({ callerClientConfig } = {}) => {
1389
+ init.logger?.debug("@aws-sdk/credential-provider-sso - fromSSO");
1390
+ const { ssoStartUrl, ssoAccountId, ssoRegion, ssoRoleName, ssoSession } = init;
1391
+ const { ssoClient } = init;
1392
+ const profileName = sharedIniFileLoader.getProfileName({
1393
+ profile: init.profile ?? callerClientConfig?.profile
1394
+ });
1395
+ if (!ssoStartUrl && !ssoAccountId && !ssoRegion && !ssoRoleName && !ssoSession) {
1396
+ const profiles = await sharedIniFileLoader.parseKnownFiles(init);
1397
+ const profile = profiles[profileName];
1398
+ if (!profile) {
1399
+ throw new propertyProvider.CredentialsProviderError(`Profile ${profileName} was not found.`, { logger: init.logger });
1400
+ }
1401
+ if (!isSsoProfile(profile)) {
1402
+ throw new propertyProvider.CredentialsProviderError(`Profile ${profileName} is not configured with SSO credentials.`, {
1403
+ logger: init.logger
1404
+ });
1405
+ }
1406
+ if (profile?.sso_session) {
1407
+ const ssoSessions = await sharedIniFileLoader.loadSsoSessionData(init);
1408
+ const session = ssoSessions[profile.sso_session];
1409
+ const conflictMsg = ` configurations in profile ${profileName} and sso-session ${profile.sso_session}`;
1410
+ if (ssoRegion && ssoRegion !== session.sso_region) {
1411
+ throw new propertyProvider.CredentialsProviderError(`Conflicting SSO region` + conflictMsg, {
1412
+ tryNextLink: false,
1413
+ logger: init.logger
1414
+ });
1415
+ }
1416
+ if (ssoStartUrl && ssoStartUrl !== session.sso_start_url) {
1417
+ throw new propertyProvider.CredentialsProviderError(`Conflicting SSO start_url` + conflictMsg, {
1418
+ tryNextLink: false,
1419
+ logger: init.logger
1420
+ });
1421
+ }
1422
+ profile.sso_region = session.sso_region;
1423
+ profile.sso_start_url = session.sso_start_url;
1424
+ }
1425
+ const { sso_start_url, sso_account_id, sso_region, sso_role_name, sso_session } = validateSsoProfile(profile, init.logger);
1426
+ return resolveSSOCredentials({
1427
+ ssoStartUrl: sso_start_url,
1428
+ ssoSession: sso_session,
1429
+ ssoAccountId: sso_account_id,
1430
+ ssoRegion: sso_region,
1431
+ ssoRoleName: sso_role_name,
1432
+ ssoClient,
1433
+ clientConfig: init.clientConfig,
1434
+ parentClientConfig: init.parentClientConfig,
1435
+ callerClientConfig: init.callerClientConfig,
1436
+ profile: profileName,
1437
+ filepath: init.filepath,
1438
+ configFilepath: init.configFilepath,
1439
+ ignoreCache: init.ignoreCache,
1440
+ logger: init.logger
1441
+ });
1442
+ } else if (!ssoStartUrl || !ssoAccountId || !ssoRegion || !ssoRoleName) {
1443
+ throw new propertyProvider.CredentialsProviderError("Incomplete configuration. The fromSSO() argument hash must include " + '"ssoStartUrl", "ssoAccountId", "ssoRegion", "ssoRoleName"', { tryNextLink: false, logger: init.logger });
1444
+ } else {
1445
+ return resolveSSOCredentials({
1446
+ ssoStartUrl,
1447
+ ssoSession,
1448
+ ssoAccountId,
1449
+ ssoRegion,
1450
+ ssoRoleName,
1451
+ ssoClient,
1452
+ clientConfig: init.clientConfig,
1453
+ parentClientConfig: init.parentClientConfig,
1454
+ callerClientConfig: init.callerClientConfig,
1455
+ profile: profileName,
1456
+ filepath: init.filepath,
1457
+ configFilepath: init.configFilepath,
1458
+ ignoreCache: init.ignoreCache,
1459
+ logger: init.logger
1460
+ });
1461
+ }
1462
+ }, $fromSSO, $isSsoProfile, $validateSsoProfile;
1463
+ var init_dist_cjs = __esm(() => {
1464
+ propertyProvider = require_dist_cjs7();
1465
+ sharedIniFileLoader = require_dist_cjs20();
1466
+ client = require_client();
1467
+ tokenProviders = require_dist_cjs30();
1468
+ $fromSSO = fromSSO;
1469
+ $isSsoProfile = isSsoProfile;
1470
+ $validateSsoProfile = validateSsoProfile;
1471
+ });
1472
+ init_dist_cjs();
1473
+
1474
+ export {
1475
+ $validateSsoProfile as validateSsoProfile,
1476
+ $isSsoProfile as isSsoProfile,
1477
+ $fromSSO as fromSSO
1478
+ };
1479
+ export default {
1480
+ get validateSsoProfile() {
1481
+ return $validateSsoProfile;
1482
+ },
1483
+ get isSsoProfile() {
1484
+ return $isSsoProfile;
1485
+ },
1486
+ get fromSSO() {
1487
+ return $fromSSO;
1488
+ }
1489
+ };