terratest 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -0
- package/dist/action/136.index.js +990 -0
- package/dist/action/360.index.js +92 -0
- package/dist/action/443.index.js +724 -0
- package/dist/action/449.index.js +13 -0
- package/dist/action/566.index.js +385 -0
- package/dist/action/605.index.js +241 -0
- package/dist/action/762.index.js +583 -0
- package/dist/action/869.index.js +529 -0
- package/dist/action/956.index.js +117 -0
- package/dist/action/998.index.js +894 -0
- package/dist/action/index.js +18 -0
- package/dist/cli/136.index.js +990 -0
- package/dist/cli/360.index.js +92 -0
- package/dist/cli/443.index.js +724 -0
- package/dist/cli/449.index.js +13 -0
- package/dist/cli/566.index.js +385 -0
- package/dist/cli/605.index.js +241 -0
- package/dist/cli/762.index.js +583 -0
- package/dist/cli/869.index.js +529 -0
- package/dist/cli/956.index.js +117 -0
- package/dist/cli/998.index.js +894 -0
- package/dist/cli/index.js +17 -0
- package/package.json +36 -0
|
@@ -0,0 +1,894 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.id = 998;
|
|
3
|
+
exports.ids = [998];
|
|
4
|
+
exports.modules = {
|
|
5
|
+
|
|
6
|
+
/***/ 60998:
|
|
7
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
8
|
+
|
|
9
|
+
var __webpack_unused_export__;
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var config = __webpack_require__(47291);
|
|
13
|
+
var client = __webpack_require__(5152);
|
|
14
|
+
var tokenProviders = __webpack_require__(75433);
|
|
15
|
+
|
|
16
|
+
const isSsoProfile = (arg) => arg &&
|
|
17
|
+
(typeof arg.sso_start_url === "string" ||
|
|
18
|
+
typeof arg.sso_account_id === "string" ||
|
|
19
|
+
typeof arg.sso_session === "string" ||
|
|
20
|
+
typeof arg.sso_region === "string" ||
|
|
21
|
+
typeof arg.sso_role_name === "string");
|
|
22
|
+
|
|
23
|
+
const SHOULD_FAIL_CREDENTIAL_CHAIN = false;
|
|
24
|
+
const resolveSSOCredentials = async ({ ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, clientConfig, parentClientConfig, callerClientConfig, profile, filepath, configFilepath, ignoreCache, logger, }) => {
|
|
25
|
+
let token;
|
|
26
|
+
const refreshMessage = `To refresh this SSO session run aws sso login with the corresponding profile.`;
|
|
27
|
+
if (ssoSession) {
|
|
28
|
+
try {
|
|
29
|
+
const _token = await tokenProviders.fromSso({
|
|
30
|
+
profile,
|
|
31
|
+
filepath,
|
|
32
|
+
configFilepath,
|
|
33
|
+
ignoreCache,
|
|
34
|
+
})();
|
|
35
|
+
token = {
|
|
36
|
+
accessToken: _token.token,
|
|
37
|
+
expiresAt: new Date(_token.expiration).toISOString(),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
throw new config.CredentialsProviderError(e.message, {
|
|
42
|
+
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
43
|
+
logger,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
try {
|
|
49
|
+
token = await config.getSSOTokenFromFile(ssoStartUrl);
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
throw new config.CredentialsProviderError(`The SSO session associated with this profile is invalid. ${refreshMessage}`, {
|
|
53
|
+
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
54
|
+
logger,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (new Date(token.expiresAt).getTime() - Date.now() <= 0) {
|
|
59
|
+
throw new config.CredentialsProviderError(`The SSO session associated with this profile has expired. ${refreshMessage}`, {
|
|
60
|
+
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
61
|
+
logger,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const { accessToken } = token;
|
|
65
|
+
const { SSOClient, GetRoleCredentialsCommand } = await Promise.resolve().then(function () { return __webpack_require__(91853); });
|
|
66
|
+
const sso = ssoClient ||
|
|
67
|
+
new SSOClient(Object.assign({}, clientConfig ?? {}, {
|
|
68
|
+
logger: clientConfig?.logger ?? callerClientConfig?.logger ?? parentClientConfig?.logger,
|
|
69
|
+
region: clientConfig?.region ?? ssoRegion,
|
|
70
|
+
userAgentAppId: clientConfig?.userAgentAppId ?? callerClientConfig?.userAgentAppId ?? parentClientConfig?.userAgentAppId,
|
|
71
|
+
}));
|
|
72
|
+
let ssoResp;
|
|
73
|
+
try {
|
|
74
|
+
ssoResp = await sso.send(new GetRoleCredentialsCommand({
|
|
75
|
+
accountId: ssoAccountId,
|
|
76
|
+
roleName: ssoRoleName,
|
|
77
|
+
accessToken,
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
throw new config.CredentialsProviderError(e, {
|
|
82
|
+
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
83
|
+
logger,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const { roleCredentials: { accessKeyId, secretAccessKey, sessionToken, expiration, credentialScope, accountId } = {}, } = ssoResp;
|
|
87
|
+
if (!accessKeyId || !secretAccessKey || !sessionToken || !expiration) {
|
|
88
|
+
throw new config.CredentialsProviderError("SSO returns an invalid temporary credential.", {
|
|
89
|
+
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
90
|
+
logger,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const credentials = {
|
|
94
|
+
accessKeyId,
|
|
95
|
+
secretAccessKey,
|
|
96
|
+
sessionToken,
|
|
97
|
+
expiration: new Date(expiration),
|
|
98
|
+
...(credentialScope && { credentialScope }),
|
|
99
|
+
...(accountId && { accountId }),
|
|
100
|
+
};
|
|
101
|
+
if (ssoSession) {
|
|
102
|
+
client.setCredentialFeature(credentials, "CREDENTIALS_SSO", "s");
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
client.setCredentialFeature(credentials, "CREDENTIALS_SSO_LEGACY", "u");
|
|
106
|
+
}
|
|
107
|
+
return credentials;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const validateSsoProfile = (profile, logger) => {
|
|
111
|
+
const { sso_start_url, sso_account_id, sso_region, sso_role_name } = profile;
|
|
112
|
+
if (!sso_start_url || !sso_account_id || !sso_region || !sso_role_name) {
|
|
113
|
+
throw new config.CredentialsProviderError(`Profile is configured with invalid SSO credentials. Required parameters "sso_account_id", ` +
|
|
114
|
+
`"sso_region", "sso_role_name", "sso_start_url". Got ${Object.keys(profile).join(", ")}\nReference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html`, { tryNextLink: false, logger });
|
|
115
|
+
}
|
|
116
|
+
return profile;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const fromSSO = (init = {}) => async ({ callerClientConfig } = {}) => {
|
|
120
|
+
init.logger?.debug("@aws-sdk/credential-provider-sso - fromSSO");
|
|
121
|
+
const { ssoStartUrl, ssoAccountId, ssoRegion, ssoRoleName, ssoSession } = init;
|
|
122
|
+
const { ssoClient } = init;
|
|
123
|
+
const profileName = config.getProfileName({
|
|
124
|
+
profile: init.profile ?? callerClientConfig?.profile,
|
|
125
|
+
});
|
|
126
|
+
if (!ssoStartUrl && !ssoAccountId && !ssoRegion && !ssoRoleName && !ssoSession) {
|
|
127
|
+
const profiles = await config.parseKnownFiles(init);
|
|
128
|
+
const profile = profiles[profileName];
|
|
129
|
+
if (!profile) {
|
|
130
|
+
throw new config.CredentialsProviderError(`Profile ${profileName} was not found.`, { logger: init.logger });
|
|
131
|
+
}
|
|
132
|
+
if (!isSsoProfile(profile)) {
|
|
133
|
+
throw new config.CredentialsProviderError(`Profile ${profileName} is not configured with SSO credentials.`, {
|
|
134
|
+
logger: init.logger,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
if (profile?.sso_session) {
|
|
138
|
+
const ssoSessions = await config.loadSsoSessionData(init);
|
|
139
|
+
const session = ssoSessions[profile.sso_session];
|
|
140
|
+
const conflictMsg = ` configurations in profile ${profileName} and sso-session ${profile.sso_session}`;
|
|
141
|
+
if (ssoRegion && ssoRegion !== session.sso_region) {
|
|
142
|
+
throw new config.CredentialsProviderError(`Conflicting SSO region` + conflictMsg, {
|
|
143
|
+
tryNextLink: false,
|
|
144
|
+
logger: init.logger,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
if (ssoStartUrl && ssoStartUrl !== session.sso_start_url) {
|
|
148
|
+
throw new config.CredentialsProviderError(`Conflicting SSO start_url` + conflictMsg, {
|
|
149
|
+
tryNextLink: false,
|
|
150
|
+
logger: init.logger,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
profile.sso_region = session.sso_region;
|
|
154
|
+
profile.sso_start_url = session.sso_start_url;
|
|
155
|
+
}
|
|
156
|
+
const { sso_start_url, sso_account_id, sso_region, sso_role_name, sso_session } = validateSsoProfile(profile, init.logger);
|
|
157
|
+
return resolveSSOCredentials({
|
|
158
|
+
ssoStartUrl: sso_start_url,
|
|
159
|
+
ssoSession: sso_session,
|
|
160
|
+
ssoAccountId: sso_account_id,
|
|
161
|
+
ssoRegion: sso_region,
|
|
162
|
+
ssoRoleName: sso_role_name,
|
|
163
|
+
ssoClient: ssoClient,
|
|
164
|
+
clientConfig: init.clientConfig,
|
|
165
|
+
parentClientConfig: init.parentClientConfig,
|
|
166
|
+
callerClientConfig: init.callerClientConfig,
|
|
167
|
+
profile: profileName,
|
|
168
|
+
filepath: init.filepath,
|
|
169
|
+
configFilepath: init.configFilepath,
|
|
170
|
+
ignoreCache: init.ignoreCache,
|
|
171
|
+
logger: init.logger,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
else if (!ssoStartUrl || !ssoAccountId || !ssoRegion || !ssoRoleName) {
|
|
175
|
+
throw new config.CredentialsProviderError("Incomplete configuration. The fromSSO() argument hash must include " +
|
|
176
|
+
'"ssoStartUrl", "ssoAccountId", "ssoRegion", "ssoRoleName"', { tryNextLink: false, logger: init.logger });
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
return resolveSSOCredentials({
|
|
180
|
+
ssoStartUrl,
|
|
181
|
+
ssoSession,
|
|
182
|
+
ssoAccountId,
|
|
183
|
+
ssoRegion,
|
|
184
|
+
ssoRoleName,
|
|
185
|
+
ssoClient,
|
|
186
|
+
clientConfig: init.clientConfig,
|
|
187
|
+
parentClientConfig: init.parentClientConfig,
|
|
188
|
+
callerClientConfig: init.callerClientConfig,
|
|
189
|
+
profile: profileName,
|
|
190
|
+
filepath: init.filepath,
|
|
191
|
+
configFilepath: init.configFilepath,
|
|
192
|
+
ignoreCache: init.ignoreCache,
|
|
193
|
+
logger: init.logger,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
exports.fromSSO = fromSSO;
|
|
199
|
+
__webpack_unused_export__ = isSsoProfile;
|
|
200
|
+
__webpack_unused_export__ = validateSsoProfile;
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
/***/ }),
|
|
204
|
+
|
|
205
|
+
/***/ 91853:
|
|
206
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
var sso = __webpack_require__(32579);
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
exports.GetRoleCredentialsCommand = sso.GetRoleCredentialsCommand;
|
|
215
|
+
exports.SSOClient = sso.SSOClient;
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
/***/ }),
|
|
219
|
+
|
|
220
|
+
/***/ 32579:
|
|
221
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
var client$1 = __webpack_require__(5152);
|
|
226
|
+
var core = __webpack_require__(90402);
|
|
227
|
+
var client = __webpack_require__(92658);
|
|
228
|
+
var config = __webpack_require__(47291);
|
|
229
|
+
var endpoints = __webpack_require__(62085);
|
|
230
|
+
var protocols = __webpack_require__(93422);
|
|
231
|
+
var retry = __webpack_require__(23609);
|
|
232
|
+
var schema = __webpack_require__(26890);
|
|
233
|
+
var httpAuthSchemes = __webpack_require__(97523);
|
|
234
|
+
var serde = __webpack_require__(92430);
|
|
235
|
+
var nodeHttpHandler = __webpack_require__(61279);
|
|
236
|
+
var protocols$1 = __webpack_require__(37288);
|
|
237
|
+
|
|
238
|
+
const defaultSSOHttpAuthSchemeParametersProvider = async (config, context, input) => {
|
|
239
|
+
return {
|
|
240
|
+
operation: client.getSmithyContext(context).operation,
|
|
241
|
+
region: (await client.normalizeProvider(config.region)()) ||
|
|
242
|
+
(() => {
|
|
243
|
+
throw new Error("expected `region` to be configured for `aws.auth#sigv4`");
|
|
244
|
+
})(),
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
function createAwsAuthSigv4HttpAuthOption(authParameters) {
|
|
248
|
+
return {
|
|
249
|
+
schemeId: "aws.auth#sigv4",
|
|
250
|
+
signingProperties: {
|
|
251
|
+
name: "awsssoportal",
|
|
252
|
+
region: authParameters.region,
|
|
253
|
+
},
|
|
254
|
+
propertiesExtractor: (config, context) => ({
|
|
255
|
+
signingProperties: {
|
|
256
|
+
config,
|
|
257
|
+
context,
|
|
258
|
+
},
|
|
259
|
+
}),
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
function createSmithyApiNoAuthHttpAuthOption(authParameters) {
|
|
263
|
+
return {
|
|
264
|
+
schemeId: "smithy.api#noAuth",
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
const defaultSSOHttpAuthSchemeProvider = (authParameters) => {
|
|
268
|
+
const options = [];
|
|
269
|
+
switch (authParameters.operation) {
|
|
270
|
+
case "GetRoleCredentials": {
|
|
271
|
+
options.push(createSmithyApiNoAuthHttpAuthOption());
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
default: {
|
|
275
|
+
options.push(createAwsAuthSigv4HttpAuthOption(authParameters));
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return options;
|
|
279
|
+
};
|
|
280
|
+
const resolveHttpAuthSchemeConfig = (config) => {
|
|
281
|
+
const config_0 = httpAuthSchemes.resolveAwsSdkSigV4Config(config);
|
|
282
|
+
return Object.assign(config_0, {
|
|
283
|
+
authSchemePreference: client.normalizeProvider(config.authSchemePreference ?? []),
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
const resolveClientEndpointParameters = (options) => {
|
|
288
|
+
return Object.assign(options, {
|
|
289
|
+
useDualstackEndpoint: options.useDualstackEndpoint ?? false,
|
|
290
|
+
useFipsEndpoint: options.useFipsEndpoint ?? false,
|
|
291
|
+
defaultSigningName: "awsssoportal",
|
|
292
|
+
});
|
|
293
|
+
};
|
|
294
|
+
const commonParams = {
|
|
295
|
+
UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
|
|
296
|
+
Endpoint: { type: "builtInParams", name: "endpoint" },
|
|
297
|
+
Region: { type: "builtInParams", name: "region" },
|
|
298
|
+
UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" },
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
var version = "3.997.11";
|
|
302
|
+
var packageInfo = {
|
|
303
|
+
version: version};
|
|
304
|
+
|
|
305
|
+
const k = "ref";
|
|
306
|
+
const a = -1, b = true, c = "isSet", d = "PartitionResult", e = "booleanEquals", f = "getAttr", g = { [k]: "Endpoint" }, h = { [k]: d }, i = {}, j = [{ [k]: "Region" }];
|
|
307
|
+
const _data = {
|
|
308
|
+
conditions: [
|
|
309
|
+
[c, [g]],
|
|
310
|
+
[c, j],
|
|
311
|
+
["aws.partition", j, d],
|
|
312
|
+
[e, [{ [k]: "UseFIPS" }, b]],
|
|
313
|
+
[e, [{ [k]: "UseDualStack" }, b]],
|
|
314
|
+
[e, [{ fn: f, argv: [h, "supportsDualStack"] }, b]],
|
|
315
|
+
[e, [{ fn: f, argv: [h, "supportsFIPS"] }, b]],
|
|
316
|
+
["stringEquals", [{ fn: f, argv: [h, "name"] }, "aws-us-gov"]],
|
|
317
|
+
],
|
|
318
|
+
results: [
|
|
319
|
+
[a],
|
|
320
|
+
[a, "Invalid Configuration: FIPS and custom endpoint are not supported"],
|
|
321
|
+
[a, "Invalid Configuration: Dualstack and custom endpoint are not supported"],
|
|
322
|
+
[g, i],
|
|
323
|
+
["https://portal.sso-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", i],
|
|
324
|
+
[a, "FIPS and DualStack are enabled, but this partition does not support one or both"],
|
|
325
|
+
["https://portal.sso.{Region}.amazonaws.com", i],
|
|
326
|
+
["https://portal.sso-fips.{Region}.{PartitionResult#dnsSuffix}", i],
|
|
327
|
+
[a, "FIPS is enabled but this partition does not support FIPS"],
|
|
328
|
+
["https://portal.sso.{Region}.{PartitionResult#dualStackDnsSuffix}", i],
|
|
329
|
+
[a, "DualStack is enabled but this partition does not support DualStack"],
|
|
330
|
+
["https://portal.sso.{Region}.{PartitionResult#dnsSuffix}", i],
|
|
331
|
+
[a, "Invalid Configuration: Missing Region"],
|
|
332
|
+
],
|
|
333
|
+
};
|
|
334
|
+
const root = 2;
|
|
335
|
+
const r = 100_000_000;
|
|
336
|
+
const nodes = new Int32Array([
|
|
337
|
+
-1,
|
|
338
|
+
1,
|
|
339
|
+
-1,
|
|
340
|
+
0,
|
|
341
|
+
13,
|
|
342
|
+
3,
|
|
343
|
+
1,
|
|
344
|
+
4,
|
|
345
|
+
r + 12,
|
|
346
|
+
2,
|
|
347
|
+
5,
|
|
348
|
+
r + 12,
|
|
349
|
+
3,
|
|
350
|
+
8,
|
|
351
|
+
6,
|
|
352
|
+
4,
|
|
353
|
+
7,
|
|
354
|
+
r + 11,
|
|
355
|
+
5,
|
|
356
|
+
r + 9,
|
|
357
|
+
r + 10,
|
|
358
|
+
4,
|
|
359
|
+
11,
|
|
360
|
+
9,
|
|
361
|
+
6,
|
|
362
|
+
10,
|
|
363
|
+
r + 8,
|
|
364
|
+
7,
|
|
365
|
+
r + 6,
|
|
366
|
+
r + 7,
|
|
367
|
+
5,
|
|
368
|
+
12,
|
|
369
|
+
r + 5,
|
|
370
|
+
6,
|
|
371
|
+
r + 4,
|
|
372
|
+
r + 5,
|
|
373
|
+
3,
|
|
374
|
+
r + 1,
|
|
375
|
+
14,
|
|
376
|
+
4,
|
|
377
|
+
r + 2,
|
|
378
|
+
r + 3,
|
|
379
|
+
]);
|
|
380
|
+
const bdd = endpoints.BinaryDecisionDiagram.from(nodes, root, _data.conditions, _data.results);
|
|
381
|
+
|
|
382
|
+
const cache = new endpoints.EndpointCache({
|
|
383
|
+
size: 50,
|
|
384
|
+
params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"],
|
|
385
|
+
});
|
|
386
|
+
const defaultEndpointResolver = (endpointParams, context = {}) => {
|
|
387
|
+
return cache.get(endpointParams, () => endpoints.decideEndpoint(bdd, {
|
|
388
|
+
endpointParams: endpointParams,
|
|
389
|
+
logger: context.logger,
|
|
390
|
+
}));
|
|
391
|
+
};
|
|
392
|
+
endpoints.customEndpointFunctions.aws = client$1.awsEndpointFunctions;
|
|
393
|
+
|
|
394
|
+
class SSOServiceException extends client.ServiceException {
|
|
395
|
+
constructor(options) {
|
|
396
|
+
super(options);
|
|
397
|
+
Object.setPrototypeOf(this, SSOServiceException.prototype);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
class InvalidRequestException extends SSOServiceException {
|
|
402
|
+
name = "InvalidRequestException";
|
|
403
|
+
$fault = "client";
|
|
404
|
+
constructor(opts) {
|
|
405
|
+
super({
|
|
406
|
+
name: "InvalidRequestException",
|
|
407
|
+
$fault: "client",
|
|
408
|
+
...opts,
|
|
409
|
+
});
|
|
410
|
+
Object.setPrototypeOf(this, InvalidRequestException.prototype);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
class ResourceNotFoundException extends SSOServiceException {
|
|
414
|
+
name = "ResourceNotFoundException";
|
|
415
|
+
$fault = "client";
|
|
416
|
+
constructor(opts) {
|
|
417
|
+
super({
|
|
418
|
+
name: "ResourceNotFoundException",
|
|
419
|
+
$fault: "client",
|
|
420
|
+
...opts,
|
|
421
|
+
});
|
|
422
|
+
Object.setPrototypeOf(this, ResourceNotFoundException.prototype);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
class TooManyRequestsException extends SSOServiceException {
|
|
426
|
+
name = "TooManyRequestsException";
|
|
427
|
+
$fault = "client";
|
|
428
|
+
constructor(opts) {
|
|
429
|
+
super({
|
|
430
|
+
name: "TooManyRequestsException",
|
|
431
|
+
$fault: "client",
|
|
432
|
+
...opts,
|
|
433
|
+
});
|
|
434
|
+
Object.setPrototypeOf(this, TooManyRequestsException.prototype);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
class UnauthorizedException extends SSOServiceException {
|
|
438
|
+
name = "UnauthorizedException";
|
|
439
|
+
$fault = "client";
|
|
440
|
+
constructor(opts) {
|
|
441
|
+
super({
|
|
442
|
+
name: "UnauthorizedException",
|
|
443
|
+
$fault: "client",
|
|
444
|
+
...opts,
|
|
445
|
+
});
|
|
446
|
+
Object.setPrototypeOf(this, UnauthorizedException.prototype);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
const _ATT = "AccessTokenType";
|
|
451
|
+
const _GRC = "GetRoleCredentials";
|
|
452
|
+
const _GRCR = "GetRoleCredentialsRequest";
|
|
453
|
+
const _GRCRe = "GetRoleCredentialsResponse";
|
|
454
|
+
const _IRE = "InvalidRequestException";
|
|
455
|
+
const _RC = "RoleCredentials";
|
|
456
|
+
const _RNFE = "ResourceNotFoundException";
|
|
457
|
+
const _SAKT = "SecretAccessKeyType";
|
|
458
|
+
const _STT = "SessionTokenType";
|
|
459
|
+
const _TMRE = "TooManyRequestsException";
|
|
460
|
+
const _UE = "UnauthorizedException";
|
|
461
|
+
const _aI = "accountId";
|
|
462
|
+
const _aKI = "accessKeyId";
|
|
463
|
+
const _aT = "accessToken";
|
|
464
|
+
const _ai = "account_id";
|
|
465
|
+
const _c = "client";
|
|
466
|
+
const _e = "error";
|
|
467
|
+
const _ex = "expiration";
|
|
468
|
+
const _h = "http";
|
|
469
|
+
const _hE = "httpError";
|
|
470
|
+
const _hH = "httpHeader";
|
|
471
|
+
const _hQ = "httpQuery";
|
|
472
|
+
const _m = "message";
|
|
473
|
+
const _rC = "roleCredentials";
|
|
474
|
+
const _rN = "roleName";
|
|
475
|
+
const _rn = "role_name";
|
|
476
|
+
const _s = "smithy.ts.sdk.synthetic.com.amazonaws.sso";
|
|
477
|
+
const _sAK = "secretAccessKey";
|
|
478
|
+
const _sT = "sessionToken";
|
|
479
|
+
const _xasbt = "x-amz-sso_bearer_token";
|
|
480
|
+
const n0 = "com.amazonaws.sso";
|
|
481
|
+
const _s_registry = schema.TypeRegistry.for(_s);
|
|
482
|
+
var SSOServiceException$ = [-3, _s, "SSOServiceException", 0, [], []];
|
|
483
|
+
_s_registry.registerError(SSOServiceException$, SSOServiceException);
|
|
484
|
+
const n0_registry = schema.TypeRegistry.for(n0);
|
|
485
|
+
var InvalidRequestException$ = [-3, n0, _IRE, { [_e]: _c, [_hE]: 400 }, [_m], [0]];
|
|
486
|
+
n0_registry.registerError(InvalidRequestException$, InvalidRequestException);
|
|
487
|
+
var ResourceNotFoundException$ = [-3, n0, _RNFE, { [_e]: _c, [_hE]: 404 }, [_m], [0]];
|
|
488
|
+
n0_registry.registerError(ResourceNotFoundException$, ResourceNotFoundException);
|
|
489
|
+
var TooManyRequestsException$ = [-3, n0, _TMRE, { [_e]: _c, [_hE]: 429 }, [_m], [0]];
|
|
490
|
+
n0_registry.registerError(TooManyRequestsException$, TooManyRequestsException);
|
|
491
|
+
var UnauthorizedException$ = [-3, n0, _UE, { [_e]: _c, [_hE]: 401 }, [_m], [0]];
|
|
492
|
+
n0_registry.registerError(UnauthorizedException$, UnauthorizedException);
|
|
493
|
+
const errorTypeRegistries = [_s_registry, n0_registry];
|
|
494
|
+
var AccessTokenType = [0, n0, _ATT, 8, 0];
|
|
495
|
+
var SecretAccessKeyType = [0, n0, _SAKT, 8, 0];
|
|
496
|
+
var SessionTokenType = [0, n0, _STT, 8, 0];
|
|
497
|
+
var GetRoleCredentialsRequest$ = [
|
|
498
|
+
3,
|
|
499
|
+
n0,
|
|
500
|
+
_GRCR,
|
|
501
|
+
0,
|
|
502
|
+
[_rN, _aI, _aT],
|
|
503
|
+
[
|
|
504
|
+
[0, { [_hQ]: _rn }],
|
|
505
|
+
[0, { [_hQ]: _ai }],
|
|
506
|
+
[() => AccessTokenType, { [_hH]: _xasbt }],
|
|
507
|
+
],
|
|
508
|
+
3,
|
|
509
|
+
];
|
|
510
|
+
var GetRoleCredentialsResponse$ = [
|
|
511
|
+
3,
|
|
512
|
+
n0,
|
|
513
|
+
_GRCRe,
|
|
514
|
+
0,
|
|
515
|
+
[_rC],
|
|
516
|
+
[[() => RoleCredentials$, 0]],
|
|
517
|
+
];
|
|
518
|
+
var RoleCredentials$ = [
|
|
519
|
+
3,
|
|
520
|
+
n0,
|
|
521
|
+
_RC,
|
|
522
|
+
0,
|
|
523
|
+
[_aKI, _sAK, _sT, _ex],
|
|
524
|
+
[0, [() => SecretAccessKeyType, 0], [() => SessionTokenType, 0], 1],
|
|
525
|
+
];
|
|
526
|
+
var GetRoleCredentials$ = [
|
|
527
|
+
9,
|
|
528
|
+
n0,
|
|
529
|
+
_GRC,
|
|
530
|
+
{ [_h]: ["GET", "/federation/credentials", 200] },
|
|
531
|
+
() => GetRoleCredentialsRequest$,
|
|
532
|
+
() => GetRoleCredentialsResponse$,
|
|
533
|
+
];
|
|
534
|
+
|
|
535
|
+
const getRuntimeConfig$1 = (config) => {
|
|
536
|
+
return {
|
|
537
|
+
apiVersion: "2019-06-10",
|
|
538
|
+
base64Decoder: config?.base64Decoder ?? serde.fromBase64,
|
|
539
|
+
base64Encoder: config?.base64Encoder ?? serde.toBase64,
|
|
540
|
+
disableHostPrefix: config?.disableHostPrefix ?? false,
|
|
541
|
+
endpointProvider: config?.endpointProvider ?? defaultEndpointResolver,
|
|
542
|
+
extensions: config?.extensions ?? [],
|
|
543
|
+
httpAuthSchemeProvider: config?.httpAuthSchemeProvider ?? defaultSSOHttpAuthSchemeProvider,
|
|
544
|
+
httpAuthSchemes: config?.httpAuthSchemes ?? [
|
|
545
|
+
{
|
|
546
|
+
schemeId: "aws.auth#sigv4",
|
|
547
|
+
identityProvider: (ipc) => ipc.getIdentityProvider("aws.auth#sigv4"),
|
|
548
|
+
signer: new httpAuthSchemes.AwsSdkSigV4Signer(),
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
schemeId: "smithy.api#noAuth",
|
|
552
|
+
identityProvider: (ipc) => ipc.getIdentityProvider("smithy.api#noAuth") || (async () => ({})),
|
|
553
|
+
signer: new core.NoAuthSigner(),
|
|
554
|
+
},
|
|
555
|
+
],
|
|
556
|
+
logger: config?.logger ?? new client.NoOpLogger(),
|
|
557
|
+
protocol: config?.protocol ?? protocols$1.AwsRestJsonProtocol,
|
|
558
|
+
protocolSettings: config?.protocolSettings ?? {
|
|
559
|
+
defaultNamespace: "com.amazonaws.sso",
|
|
560
|
+
errorTypeRegistries,
|
|
561
|
+
version: "2019-06-10",
|
|
562
|
+
serviceTarget: "SWBPortalService",
|
|
563
|
+
},
|
|
564
|
+
serviceId: config?.serviceId ?? "SSO",
|
|
565
|
+
urlParser: config?.urlParser ?? protocols.parseUrl,
|
|
566
|
+
utf8Decoder: config?.utf8Decoder ?? serde.fromUtf8,
|
|
567
|
+
utf8Encoder: config?.utf8Encoder ?? serde.toUtf8,
|
|
568
|
+
};
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
const getRuntimeConfig = (config$1) => {
|
|
572
|
+
client.emitWarningIfUnsupportedVersion(process.version);
|
|
573
|
+
const defaultsMode = config.resolveDefaultsModeConfig(config$1);
|
|
574
|
+
const defaultConfigProvider = () => defaultsMode().then(client.loadConfigsForDefaultMode);
|
|
575
|
+
const clientSharedValues = getRuntimeConfig$1(config$1);
|
|
576
|
+
client$1.emitWarningIfUnsupportedVersion(process.version);
|
|
577
|
+
const loaderConfig = {
|
|
578
|
+
profile: config$1?.profile,
|
|
579
|
+
logger: clientSharedValues.logger,
|
|
580
|
+
};
|
|
581
|
+
return {
|
|
582
|
+
...clientSharedValues,
|
|
583
|
+
...config$1,
|
|
584
|
+
runtime: "node",
|
|
585
|
+
defaultsMode,
|
|
586
|
+
authSchemePreference: config$1?.authSchemePreference ?? config.loadConfig(httpAuthSchemes.NODE_AUTH_SCHEME_PREFERENCE_OPTIONS, loaderConfig),
|
|
587
|
+
bodyLengthChecker: config$1?.bodyLengthChecker ?? serde.calculateBodyLength,
|
|
588
|
+
defaultUserAgentProvider: config$1?.defaultUserAgentProvider ??
|
|
589
|
+
client$1.createDefaultUserAgentProvider({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
|
|
590
|
+
maxAttempts: config$1?.maxAttempts ?? config.loadConfig(retry.NODE_MAX_ATTEMPT_CONFIG_OPTIONS, config$1),
|
|
591
|
+
region: config$1?.region ??
|
|
592
|
+
config.loadConfig(config.NODE_REGION_CONFIG_OPTIONS, { ...config.NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig }),
|
|
593
|
+
requestHandler: nodeHttpHandler.NodeHttpHandler.create(config$1?.requestHandler ?? defaultConfigProvider),
|
|
594
|
+
retryMode: config$1?.retryMode ??
|
|
595
|
+
config.loadConfig({
|
|
596
|
+
...retry.NODE_RETRY_MODE_CONFIG_OPTIONS,
|
|
597
|
+
default: async () => (await defaultConfigProvider()).retryMode || retry.DEFAULT_RETRY_MODE,
|
|
598
|
+
}, config$1),
|
|
599
|
+
sha256: config$1?.sha256 ?? serde.Hash.bind(null, "sha256"),
|
|
600
|
+
streamCollector: config$1?.streamCollector ?? nodeHttpHandler.streamCollector,
|
|
601
|
+
useDualstackEndpoint: config$1?.useDualstackEndpoint ?? config.loadConfig(config.NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
|
|
602
|
+
useFipsEndpoint: config$1?.useFipsEndpoint ?? config.loadConfig(config.NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
|
|
603
|
+
userAgentAppId: config$1?.userAgentAppId ?? config.loadConfig(client$1.NODE_APP_ID_CONFIG_OPTIONS, loaderConfig),
|
|
604
|
+
};
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
const getHttpAuthExtensionConfiguration = (runtimeConfig) => {
|
|
608
|
+
const _httpAuthSchemes = runtimeConfig.httpAuthSchemes;
|
|
609
|
+
let _httpAuthSchemeProvider = runtimeConfig.httpAuthSchemeProvider;
|
|
610
|
+
let _credentials = runtimeConfig.credentials;
|
|
611
|
+
return {
|
|
612
|
+
setHttpAuthScheme(httpAuthScheme) {
|
|
613
|
+
const index = _httpAuthSchemes.findIndex((scheme) => scheme.schemeId === httpAuthScheme.schemeId);
|
|
614
|
+
if (index === -1) {
|
|
615
|
+
_httpAuthSchemes.push(httpAuthScheme);
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
_httpAuthSchemes.splice(index, 1, httpAuthScheme);
|
|
619
|
+
}
|
|
620
|
+
},
|
|
621
|
+
httpAuthSchemes() {
|
|
622
|
+
return _httpAuthSchemes;
|
|
623
|
+
},
|
|
624
|
+
setHttpAuthSchemeProvider(httpAuthSchemeProvider) {
|
|
625
|
+
_httpAuthSchemeProvider = httpAuthSchemeProvider;
|
|
626
|
+
},
|
|
627
|
+
httpAuthSchemeProvider() {
|
|
628
|
+
return _httpAuthSchemeProvider;
|
|
629
|
+
},
|
|
630
|
+
setCredentials(credentials) {
|
|
631
|
+
_credentials = credentials;
|
|
632
|
+
},
|
|
633
|
+
credentials() {
|
|
634
|
+
return _credentials;
|
|
635
|
+
},
|
|
636
|
+
};
|
|
637
|
+
};
|
|
638
|
+
const resolveHttpAuthRuntimeConfig = (config) => {
|
|
639
|
+
return {
|
|
640
|
+
httpAuthSchemes: config.httpAuthSchemes(),
|
|
641
|
+
httpAuthSchemeProvider: config.httpAuthSchemeProvider(),
|
|
642
|
+
credentials: config.credentials(),
|
|
643
|
+
};
|
|
644
|
+
};
|
|
645
|
+
|
|
646
|
+
const resolveRuntimeExtensions = (runtimeConfig, extensions) => {
|
|
647
|
+
const extensionConfiguration = Object.assign(client$1.getAwsRegionExtensionConfiguration(runtimeConfig), client.getDefaultExtensionConfiguration(runtimeConfig), protocols.getHttpHandlerExtensionConfiguration(runtimeConfig), getHttpAuthExtensionConfiguration(runtimeConfig));
|
|
648
|
+
extensions.forEach((extension) => extension.configure(extensionConfiguration));
|
|
649
|
+
return Object.assign(runtimeConfig, client$1.resolveAwsRegionExtensionConfiguration(extensionConfiguration), client.resolveDefaultRuntimeConfig(extensionConfiguration), protocols.resolveHttpHandlerRuntimeConfig(extensionConfiguration), resolveHttpAuthRuntimeConfig(extensionConfiguration));
|
|
650
|
+
};
|
|
651
|
+
|
|
652
|
+
class SSOClient extends client.Client {
|
|
653
|
+
config;
|
|
654
|
+
constructor(...[configuration]) {
|
|
655
|
+
const _config_0 = getRuntimeConfig(configuration || {});
|
|
656
|
+
super(_config_0);
|
|
657
|
+
this.initConfig = _config_0;
|
|
658
|
+
const _config_1 = resolveClientEndpointParameters(_config_0);
|
|
659
|
+
const _config_2 = client$1.resolveUserAgentConfig(_config_1);
|
|
660
|
+
const _config_3 = retry.resolveRetryConfig(_config_2);
|
|
661
|
+
const _config_4 = config.resolveRegionConfig(_config_3);
|
|
662
|
+
const _config_5 = client$1.resolveHostHeaderConfig(_config_4);
|
|
663
|
+
const _config_6 = endpoints.resolveEndpointConfig(_config_5);
|
|
664
|
+
const _config_7 = resolveHttpAuthSchemeConfig(_config_6);
|
|
665
|
+
const _config_8 = resolveRuntimeExtensions(_config_7, configuration?.extensions || []);
|
|
666
|
+
this.config = _config_8;
|
|
667
|
+
this.middlewareStack.use(schema.getSchemaSerdePlugin(this.config));
|
|
668
|
+
this.middlewareStack.use(client$1.getUserAgentPlugin(this.config));
|
|
669
|
+
this.middlewareStack.use(retry.getRetryPlugin(this.config));
|
|
670
|
+
this.middlewareStack.use(protocols.getContentLengthPlugin(this.config));
|
|
671
|
+
this.middlewareStack.use(client$1.getHostHeaderPlugin(this.config));
|
|
672
|
+
this.middlewareStack.use(client$1.getLoggerPlugin(this.config));
|
|
673
|
+
this.middlewareStack.use(client$1.getRecursionDetectionPlugin(this.config));
|
|
674
|
+
this.middlewareStack.use(core.getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
|
|
675
|
+
httpAuthSchemeParametersProvider: defaultSSOHttpAuthSchemeParametersProvider,
|
|
676
|
+
identityProviderConfigProvider: async (config) => new core.DefaultIdentityProviderConfig({
|
|
677
|
+
"aws.auth#sigv4": config.credentials,
|
|
678
|
+
}),
|
|
679
|
+
}));
|
|
680
|
+
this.middlewareStack.use(core.getHttpSigningPlugin(this.config));
|
|
681
|
+
}
|
|
682
|
+
destroy() {
|
|
683
|
+
super.destroy();
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
class GetRoleCredentialsCommand extends client.Command
|
|
688
|
+
.classBuilder()
|
|
689
|
+
.ep(commonParams)
|
|
690
|
+
.m(function (Command, cs, config, o) {
|
|
691
|
+
return [endpoints.getEndpointPlugin(config, Command.getEndpointParameterInstructions())];
|
|
692
|
+
})
|
|
693
|
+
.s("SWBPortalService", "GetRoleCredentials", {})
|
|
694
|
+
.n("SSOClient", "GetRoleCredentialsCommand")
|
|
695
|
+
.sc(GetRoleCredentials$)
|
|
696
|
+
.build() {
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
const commands = {
|
|
700
|
+
GetRoleCredentialsCommand,
|
|
701
|
+
};
|
|
702
|
+
class SSO extends SSOClient {
|
|
703
|
+
}
|
|
704
|
+
client.createAggregatedClient(commands, SSO);
|
|
705
|
+
|
|
706
|
+
exports.$Command = client.Command;
|
|
707
|
+
exports.__Client = client.Client;
|
|
708
|
+
exports.GetRoleCredentials$ = GetRoleCredentials$;
|
|
709
|
+
exports.GetRoleCredentialsCommand = GetRoleCredentialsCommand;
|
|
710
|
+
exports.GetRoleCredentialsRequest$ = GetRoleCredentialsRequest$;
|
|
711
|
+
exports.GetRoleCredentialsResponse$ = GetRoleCredentialsResponse$;
|
|
712
|
+
exports.InvalidRequestException = InvalidRequestException;
|
|
713
|
+
exports.InvalidRequestException$ = InvalidRequestException$;
|
|
714
|
+
exports.ResourceNotFoundException = ResourceNotFoundException;
|
|
715
|
+
exports.ResourceNotFoundException$ = ResourceNotFoundException$;
|
|
716
|
+
exports.RoleCredentials$ = RoleCredentials$;
|
|
717
|
+
exports.SSO = SSO;
|
|
718
|
+
exports.SSOClient = SSOClient;
|
|
719
|
+
exports.SSOServiceException = SSOServiceException;
|
|
720
|
+
exports.SSOServiceException$ = SSOServiceException$;
|
|
721
|
+
exports.TooManyRequestsException = TooManyRequestsException;
|
|
722
|
+
exports.TooManyRequestsException$ = TooManyRequestsException$;
|
|
723
|
+
exports.UnauthorizedException = UnauthorizedException;
|
|
724
|
+
exports.UnauthorizedException$ = UnauthorizedException$;
|
|
725
|
+
exports.errorTypeRegistries = errorTypeRegistries;
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
/***/ }),
|
|
729
|
+
|
|
730
|
+
/***/ 75433:
|
|
731
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
var client = __webpack_require__(5152);
|
|
736
|
+
var httpAuthSchemes = __webpack_require__(97523);
|
|
737
|
+
var config = __webpack_require__(47291);
|
|
738
|
+
var node_fs = __webpack_require__(73024);
|
|
739
|
+
|
|
740
|
+
const fromEnvSigningName = ({ logger, signingName } = {}) => async () => {
|
|
741
|
+
logger?.debug?.("@aws-sdk/token-providers - fromEnvSigningName");
|
|
742
|
+
if (!signingName) {
|
|
743
|
+
throw new config.TokenProviderError("Please pass 'signingName' to compute environment variable key", { logger });
|
|
744
|
+
}
|
|
745
|
+
const bearerTokenKey = httpAuthSchemes.getBearerTokenEnvKey(signingName);
|
|
746
|
+
if (!(bearerTokenKey in process.env)) {
|
|
747
|
+
throw new config.TokenProviderError(`Token not present in '${bearerTokenKey}' environment variable`, { logger });
|
|
748
|
+
}
|
|
749
|
+
const token = { token: process.env[bearerTokenKey] };
|
|
750
|
+
client.setTokenFeature(token, "BEARER_SERVICE_ENV_VARS", "3");
|
|
751
|
+
return token;
|
|
752
|
+
};
|
|
753
|
+
|
|
754
|
+
const EXPIRE_WINDOW_MS = 5 * 60 * 1000;
|
|
755
|
+
const REFRESH_MESSAGE = `To refresh this SSO session run 'aws sso login' with the corresponding profile.`;
|
|
756
|
+
|
|
757
|
+
const getSsoOidcClient = async (ssoRegion, init = {}, callerClientConfig) => {
|
|
758
|
+
const { SSOOIDCClient } = await __webpack_require__.e(/* import() */ 443).then(__webpack_require__.t.bind(__webpack_require__, 89443, 19));
|
|
759
|
+
const coalesce = (prop) => init.clientConfig?.[prop] ?? init.parentClientConfig?.[prop] ?? callerClientConfig?.[prop];
|
|
760
|
+
const ssoOidcClient = new SSOOIDCClient(Object.assign({}, init.clientConfig ?? {}, {
|
|
761
|
+
region: ssoRegion ?? init.clientConfig?.region,
|
|
762
|
+
logger: coalesce("logger"),
|
|
763
|
+
userAgentAppId: coalesce("userAgentAppId"),
|
|
764
|
+
}));
|
|
765
|
+
return ssoOidcClient;
|
|
766
|
+
};
|
|
767
|
+
|
|
768
|
+
const getNewSsoOidcToken = async (ssoToken, ssoRegion, init = {}, callerClientConfig) => {
|
|
769
|
+
const { CreateTokenCommand } = await __webpack_require__.e(/* import() */ 443).then(__webpack_require__.t.bind(__webpack_require__, 89443, 19));
|
|
770
|
+
const ssoOidcClient = await getSsoOidcClient(ssoRegion, init, callerClientConfig);
|
|
771
|
+
return ssoOidcClient.send(new CreateTokenCommand({
|
|
772
|
+
clientId: ssoToken.clientId,
|
|
773
|
+
clientSecret: ssoToken.clientSecret,
|
|
774
|
+
refreshToken: ssoToken.refreshToken,
|
|
775
|
+
grantType: "refresh_token",
|
|
776
|
+
}));
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
const validateTokenExpiry = (token) => {
|
|
780
|
+
if (token.expiration && token.expiration.getTime() < Date.now()) {
|
|
781
|
+
throw new config.TokenProviderError(`Token is expired. ${REFRESH_MESSAGE}`, false);
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
|
|
785
|
+
const validateTokenKey = (key, value, forRefresh = false) => {
|
|
786
|
+
if (typeof value === "undefined") {
|
|
787
|
+
throw new config.TokenProviderError(`Value not present for '${key}' in SSO Token${forRefresh ? ". Cannot refresh" : ""}. ${REFRESH_MESSAGE}`, false);
|
|
788
|
+
}
|
|
789
|
+
};
|
|
790
|
+
|
|
791
|
+
const { writeFile } = node_fs.promises;
|
|
792
|
+
const writeSSOTokenToFile = (id, ssoToken) => {
|
|
793
|
+
const tokenFilepath = config.getSSOTokenFilepath(id);
|
|
794
|
+
const tokenString = JSON.stringify(ssoToken, null, 2);
|
|
795
|
+
return writeFile(tokenFilepath, tokenString);
|
|
796
|
+
};
|
|
797
|
+
|
|
798
|
+
const lastRefreshAttemptTime = new Date(0);
|
|
799
|
+
const fromSso = (init = {}) => async ({ callerClientConfig } = {}) => {
|
|
800
|
+
init.logger?.debug("@aws-sdk/token-providers - fromSso");
|
|
801
|
+
const profiles = await config.parseKnownFiles(init);
|
|
802
|
+
const profileName = config.getProfileName({
|
|
803
|
+
profile: init.profile ?? callerClientConfig?.profile,
|
|
804
|
+
});
|
|
805
|
+
const profile = profiles[profileName];
|
|
806
|
+
if (!profile) {
|
|
807
|
+
throw new config.TokenProviderError(`Profile '${profileName}' could not be found in shared credentials file.`, false);
|
|
808
|
+
}
|
|
809
|
+
else if (!profile["sso_session"]) {
|
|
810
|
+
throw new config.TokenProviderError(`Profile '${profileName}' is missing required property 'sso_session'.`);
|
|
811
|
+
}
|
|
812
|
+
const ssoSessionName = profile["sso_session"];
|
|
813
|
+
const ssoSessions = await config.loadSsoSessionData(init);
|
|
814
|
+
const ssoSession = ssoSessions[ssoSessionName];
|
|
815
|
+
if (!ssoSession) {
|
|
816
|
+
throw new config.TokenProviderError(`Sso session '${ssoSessionName}' could not be found in shared credentials file.`, false);
|
|
817
|
+
}
|
|
818
|
+
for (const ssoSessionRequiredKey of ["sso_start_url", "sso_region"]) {
|
|
819
|
+
if (!ssoSession[ssoSessionRequiredKey]) {
|
|
820
|
+
throw new config.TokenProviderError(`Sso session '${ssoSessionName}' is missing required property '${ssoSessionRequiredKey}'.`, false);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
ssoSession["sso_start_url"];
|
|
824
|
+
const ssoRegion = ssoSession["sso_region"];
|
|
825
|
+
let ssoToken;
|
|
826
|
+
try {
|
|
827
|
+
ssoToken = await config.getSSOTokenFromFile(ssoSessionName);
|
|
828
|
+
}
|
|
829
|
+
catch (e) {
|
|
830
|
+
throw new config.TokenProviderError(`The SSO session token associated with profile=${profileName} was not found or is invalid. ${REFRESH_MESSAGE}`, false);
|
|
831
|
+
}
|
|
832
|
+
validateTokenKey("accessToken", ssoToken.accessToken);
|
|
833
|
+
validateTokenKey("expiresAt", ssoToken.expiresAt);
|
|
834
|
+
const { accessToken, expiresAt } = ssoToken;
|
|
835
|
+
const existingToken = { token: accessToken, expiration: new Date(expiresAt) };
|
|
836
|
+
if (existingToken.expiration.getTime() - Date.now() > EXPIRE_WINDOW_MS) {
|
|
837
|
+
return existingToken;
|
|
838
|
+
}
|
|
839
|
+
if (Date.now() - lastRefreshAttemptTime.getTime() < 30 * 1000) {
|
|
840
|
+
validateTokenExpiry(existingToken);
|
|
841
|
+
return existingToken;
|
|
842
|
+
}
|
|
843
|
+
validateTokenKey("clientId", ssoToken.clientId, true);
|
|
844
|
+
validateTokenKey("clientSecret", ssoToken.clientSecret, true);
|
|
845
|
+
validateTokenKey("refreshToken", ssoToken.refreshToken, true);
|
|
846
|
+
try {
|
|
847
|
+
lastRefreshAttemptTime.setTime(Date.now());
|
|
848
|
+
const newSsoOidcToken = await getNewSsoOidcToken(ssoToken, ssoRegion, init, callerClientConfig);
|
|
849
|
+
validateTokenKey("accessToken", newSsoOidcToken.accessToken);
|
|
850
|
+
validateTokenKey("expiresIn", newSsoOidcToken.expiresIn);
|
|
851
|
+
const newTokenExpiration = new Date(Date.now() + newSsoOidcToken.expiresIn * 1000);
|
|
852
|
+
try {
|
|
853
|
+
await writeSSOTokenToFile(ssoSessionName, {
|
|
854
|
+
...ssoToken,
|
|
855
|
+
accessToken: newSsoOidcToken.accessToken,
|
|
856
|
+
expiresAt: newTokenExpiration.toISOString(),
|
|
857
|
+
refreshToken: newSsoOidcToken.refreshToken,
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
catch (error) {
|
|
861
|
+
}
|
|
862
|
+
return {
|
|
863
|
+
token: newSsoOidcToken.accessToken,
|
|
864
|
+
expiration: newTokenExpiration,
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
catch (error) {
|
|
868
|
+
validateTokenExpiry(existingToken);
|
|
869
|
+
return existingToken;
|
|
870
|
+
}
|
|
871
|
+
};
|
|
872
|
+
|
|
873
|
+
const fromStatic = ({ token, logger }) => async () => {
|
|
874
|
+
logger?.debug("@aws-sdk/token-providers - fromStatic");
|
|
875
|
+
if (!token || !token.token) {
|
|
876
|
+
throw new config.TokenProviderError(`Please pass a valid token to fromStatic`, false);
|
|
877
|
+
}
|
|
878
|
+
return token;
|
|
879
|
+
};
|
|
880
|
+
|
|
881
|
+
const nodeProvider = (init = {}) => config.memoize(config.chain(fromSso(init), async () => {
|
|
882
|
+
throw new config.TokenProviderError("Could not load token from any providers", false);
|
|
883
|
+
}), (token) => token.expiration !== undefined && token.expiration.getTime() - Date.now() < 300000, (token) => token.expiration !== undefined);
|
|
884
|
+
|
|
885
|
+
exports.fromEnvSigningName = fromEnvSigningName;
|
|
886
|
+
exports.fromSso = fromSso;
|
|
887
|
+
exports.fromStatic = fromStatic;
|
|
888
|
+
exports.nodeProvider = nodeProvider;
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
/***/ })
|
|
892
|
+
|
|
893
|
+
};
|
|
894
|
+
;
|