@aws-sdk/client-sts 3.504.0 → 3.511.0

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/dist-cjs/index.js CHANGED
@@ -340,7 +340,7 @@ var se_GetSessionTokenCommand = /* @__PURE__ */ __name(async (input, context) =>
340
340
  }, "se_GetSessionTokenCommand");
341
341
  var de_AssumeRoleCommand = /* @__PURE__ */ __name(async (output, context) => {
342
342
  if (output.statusCode >= 300) {
343
- return de_AssumeRoleCommandError(output, context);
343
+ return de_CommandError(output, context);
344
344
  }
345
345
  const data = await parseBody(output.body, context);
346
346
  let contents = {};
@@ -351,37 +351,9 @@ var de_AssumeRoleCommand = /* @__PURE__ */ __name(async (output, context) => {
351
351
  };
352
352
  return response;
353
353
  }, "de_AssumeRoleCommand");
354
- var de_AssumeRoleCommandError = /* @__PURE__ */ __name(async (output, context) => {
355
- const parsedOutput = {
356
- ...output,
357
- body: await parseErrorBody(output.body, context)
358
- };
359
- const errorCode = loadQueryErrorCode(output, parsedOutput.body);
360
- switch (errorCode) {
361
- case "ExpiredTokenException":
362
- case "com.amazonaws.sts#ExpiredTokenException":
363
- throw await de_ExpiredTokenExceptionRes(parsedOutput, context);
364
- case "MalformedPolicyDocument":
365
- case "com.amazonaws.sts#MalformedPolicyDocumentException":
366
- throw await de_MalformedPolicyDocumentExceptionRes(parsedOutput, context);
367
- case "PackedPolicyTooLarge":
368
- case "com.amazonaws.sts#PackedPolicyTooLargeException":
369
- throw await de_PackedPolicyTooLargeExceptionRes(parsedOutput, context);
370
- case "RegionDisabledException":
371
- case "com.amazonaws.sts#RegionDisabledException":
372
- throw await de_RegionDisabledExceptionRes(parsedOutput, context);
373
- default:
374
- const parsedBody = parsedOutput.body;
375
- return throwDefaultError({
376
- output,
377
- parsedBody: parsedBody.Error,
378
- errorCode
379
- });
380
- }
381
- }, "de_AssumeRoleCommandError");
382
354
  var de_AssumeRoleWithSAMLCommand = /* @__PURE__ */ __name(async (output, context) => {
383
355
  if (output.statusCode >= 300) {
384
- return de_AssumeRoleWithSAMLCommandError(output, context);
356
+ return de_CommandError(output, context);
385
357
  }
386
358
  const data = await parseBody(output.body, context);
387
359
  let contents = {};
@@ -392,43 +364,9 @@ var de_AssumeRoleWithSAMLCommand = /* @__PURE__ */ __name(async (output, context
392
364
  };
393
365
  return response;
394
366
  }, "de_AssumeRoleWithSAMLCommand");
395
- var de_AssumeRoleWithSAMLCommandError = /* @__PURE__ */ __name(async (output, context) => {
396
- const parsedOutput = {
397
- ...output,
398
- body: await parseErrorBody(output.body, context)
399
- };
400
- const errorCode = loadQueryErrorCode(output, parsedOutput.body);
401
- switch (errorCode) {
402
- case "ExpiredTokenException":
403
- case "com.amazonaws.sts#ExpiredTokenException":
404
- throw await de_ExpiredTokenExceptionRes(parsedOutput, context);
405
- case "IDPRejectedClaim":
406
- case "com.amazonaws.sts#IDPRejectedClaimException":
407
- throw await de_IDPRejectedClaimExceptionRes(parsedOutput, context);
408
- case "InvalidIdentityToken":
409
- case "com.amazonaws.sts#InvalidIdentityTokenException":
410
- throw await de_InvalidIdentityTokenExceptionRes(parsedOutput, context);
411
- case "MalformedPolicyDocument":
412
- case "com.amazonaws.sts#MalformedPolicyDocumentException":
413
- throw await de_MalformedPolicyDocumentExceptionRes(parsedOutput, context);
414
- case "PackedPolicyTooLarge":
415
- case "com.amazonaws.sts#PackedPolicyTooLargeException":
416
- throw await de_PackedPolicyTooLargeExceptionRes(parsedOutput, context);
417
- case "RegionDisabledException":
418
- case "com.amazonaws.sts#RegionDisabledException":
419
- throw await de_RegionDisabledExceptionRes(parsedOutput, context);
420
- default:
421
- const parsedBody = parsedOutput.body;
422
- return throwDefaultError({
423
- output,
424
- parsedBody: parsedBody.Error,
425
- errorCode
426
- });
427
- }
428
- }, "de_AssumeRoleWithSAMLCommandError");
429
367
  var de_AssumeRoleWithWebIdentityCommand = /* @__PURE__ */ __name(async (output, context) => {
430
368
  if (output.statusCode >= 300) {
431
- return de_AssumeRoleWithWebIdentityCommandError(output, context);
369
+ return de_CommandError(output, context);
432
370
  }
433
371
  const data = await parseBody(output.body, context);
434
372
  let contents = {};
@@ -439,46 +377,9 @@ var de_AssumeRoleWithWebIdentityCommand = /* @__PURE__ */ __name(async (output,
439
377
  };
440
378
  return response;
441
379
  }, "de_AssumeRoleWithWebIdentityCommand");
442
- var de_AssumeRoleWithWebIdentityCommandError = /* @__PURE__ */ __name(async (output, context) => {
443
- const parsedOutput = {
444
- ...output,
445
- body: await parseErrorBody(output.body, context)
446
- };
447
- const errorCode = loadQueryErrorCode(output, parsedOutput.body);
448
- switch (errorCode) {
449
- case "ExpiredTokenException":
450
- case "com.amazonaws.sts#ExpiredTokenException":
451
- throw await de_ExpiredTokenExceptionRes(parsedOutput, context);
452
- case "IDPCommunicationError":
453
- case "com.amazonaws.sts#IDPCommunicationErrorException":
454
- throw await de_IDPCommunicationErrorExceptionRes(parsedOutput, context);
455
- case "IDPRejectedClaim":
456
- case "com.amazonaws.sts#IDPRejectedClaimException":
457
- throw await de_IDPRejectedClaimExceptionRes(parsedOutput, context);
458
- case "InvalidIdentityToken":
459
- case "com.amazonaws.sts#InvalidIdentityTokenException":
460
- throw await de_InvalidIdentityTokenExceptionRes(parsedOutput, context);
461
- case "MalformedPolicyDocument":
462
- case "com.amazonaws.sts#MalformedPolicyDocumentException":
463
- throw await de_MalformedPolicyDocumentExceptionRes(parsedOutput, context);
464
- case "PackedPolicyTooLarge":
465
- case "com.amazonaws.sts#PackedPolicyTooLargeException":
466
- throw await de_PackedPolicyTooLargeExceptionRes(parsedOutput, context);
467
- case "RegionDisabledException":
468
- case "com.amazonaws.sts#RegionDisabledException":
469
- throw await de_RegionDisabledExceptionRes(parsedOutput, context);
470
- default:
471
- const parsedBody = parsedOutput.body;
472
- return throwDefaultError({
473
- output,
474
- parsedBody: parsedBody.Error,
475
- errorCode
476
- });
477
- }
478
- }, "de_AssumeRoleWithWebIdentityCommandError");
479
380
  var de_DecodeAuthorizationMessageCommand = /* @__PURE__ */ __name(async (output, context) => {
480
381
  if (output.statusCode >= 300) {
481
- return de_DecodeAuthorizationMessageCommandError(output, context);
382
+ return de_CommandError(output, context);
482
383
  }
483
384
  const data = await parseBody(output.body, context);
484
385
  let contents = {};
@@ -489,28 +390,9 @@ var de_DecodeAuthorizationMessageCommand = /* @__PURE__ */ __name(async (output,
489
390
  };
490
391
  return response;
491
392
  }, "de_DecodeAuthorizationMessageCommand");
492
- var de_DecodeAuthorizationMessageCommandError = /* @__PURE__ */ __name(async (output, context) => {
493
- const parsedOutput = {
494
- ...output,
495
- body: await parseErrorBody(output.body, context)
496
- };
497
- const errorCode = loadQueryErrorCode(output, parsedOutput.body);
498
- switch (errorCode) {
499
- case "InvalidAuthorizationMessageException":
500
- case "com.amazonaws.sts#InvalidAuthorizationMessageException":
501
- throw await de_InvalidAuthorizationMessageExceptionRes(parsedOutput, context);
502
- default:
503
- const parsedBody = parsedOutput.body;
504
- return throwDefaultError({
505
- output,
506
- parsedBody: parsedBody.Error,
507
- errorCode
508
- });
509
- }
510
- }, "de_DecodeAuthorizationMessageCommandError");
511
393
  var de_GetAccessKeyInfoCommand = /* @__PURE__ */ __name(async (output, context) => {
512
394
  if (output.statusCode >= 300) {
513
- return de_GetAccessKeyInfoCommandError(output, context);
395
+ return de_CommandError(output, context);
514
396
  }
515
397
  const data = await parseBody(output.body, context);
516
398
  let contents = {};
@@ -521,22 +403,9 @@ var de_GetAccessKeyInfoCommand = /* @__PURE__ */ __name(async (output, context)
521
403
  };
522
404
  return response;
523
405
  }, "de_GetAccessKeyInfoCommand");
524
- var de_GetAccessKeyInfoCommandError = /* @__PURE__ */ __name(async (output, context) => {
525
- const parsedOutput = {
526
- ...output,
527
- body: await parseErrorBody(output.body, context)
528
- };
529
- const errorCode = loadQueryErrorCode(output, parsedOutput.body);
530
- const parsedBody = parsedOutput.body;
531
- return throwDefaultError({
532
- output,
533
- parsedBody: parsedBody.Error,
534
- errorCode
535
- });
536
- }, "de_GetAccessKeyInfoCommandError");
537
406
  var de_GetCallerIdentityCommand = /* @__PURE__ */ __name(async (output, context) => {
538
407
  if (output.statusCode >= 300) {
539
- return de_GetCallerIdentityCommandError(output, context);
408
+ return de_CommandError(output, context);
540
409
  }
541
410
  const data = await parseBody(output.body, context);
542
411
  let contents = {};
@@ -547,22 +416,9 @@ var de_GetCallerIdentityCommand = /* @__PURE__ */ __name(async (output, context)
547
416
  };
548
417
  return response;
549
418
  }, "de_GetCallerIdentityCommand");
550
- var de_GetCallerIdentityCommandError = /* @__PURE__ */ __name(async (output, context) => {
551
- const parsedOutput = {
552
- ...output,
553
- body: await parseErrorBody(output.body, context)
554
- };
555
- const errorCode = loadQueryErrorCode(output, parsedOutput.body);
556
- const parsedBody = parsedOutput.body;
557
- return throwDefaultError({
558
- output,
559
- parsedBody: parsedBody.Error,
560
- errorCode
561
- });
562
- }, "de_GetCallerIdentityCommandError");
563
419
  var de_GetFederationTokenCommand = /* @__PURE__ */ __name(async (output, context) => {
564
420
  if (output.statusCode >= 300) {
565
- return de_GetFederationTokenCommandError(output, context);
421
+ return de_CommandError(output, context);
566
422
  }
567
423
  const data = await parseBody(output.body, context);
568
424
  let contents = {};
@@ -573,34 +429,9 @@ var de_GetFederationTokenCommand = /* @__PURE__ */ __name(async (output, context
573
429
  };
574
430
  return response;
575
431
  }, "de_GetFederationTokenCommand");
576
- var de_GetFederationTokenCommandError = /* @__PURE__ */ __name(async (output, context) => {
577
- const parsedOutput = {
578
- ...output,
579
- body: await parseErrorBody(output.body, context)
580
- };
581
- const errorCode = loadQueryErrorCode(output, parsedOutput.body);
582
- switch (errorCode) {
583
- case "MalformedPolicyDocument":
584
- case "com.amazonaws.sts#MalformedPolicyDocumentException":
585
- throw await de_MalformedPolicyDocumentExceptionRes(parsedOutput, context);
586
- case "PackedPolicyTooLarge":
587
- case "com.amazonaws.sts#PackedPolicyTooLargeException":
588
- throw await de_PackedPolicyTooLargeExceptionRes(parsedOutput, context);
589
- case "RegionDisabledException":
590
- case "com.amazonaws.sts#RegionDisabledException":
591
- throw await de_RegionDisabledExceptionRes(parsedOutput, context);
592
- default:
593
- const parsedBody = parsedOutput.body;
594
- return throwDefaultError({
595
- output,
596
- parsedBody: parsedBody.Error,
597
- errorCode
598
- });
599
- }
600
- }, "de_GetFederationTokenCommandError");
601
432
  var de_GetSessionTokenCommand = /* @__PURE__ */ __name(async (output, context) => {
602
433
  if (output.statusCode >= 300) {
603
- return de_GetSessionTokenCommandError(output, context);
434
+ return de_CommandError(output, context);
604
435
  }
605
436
  const data = await parseBody(output.body, context);
606
437
  let contents = {};
@@ -611,16 +442,37 @@ var de_GetSessionTokenCommand = /* @__PURE__ */ __name(async (output, context) =
611
442
  };
612
443
  return response;
613
444
  }, "de_GetSessionTokenCommand");
614
- var de_GetSessionTokenCommandError = /* @__PURE__ */ __name(async (output, context) => {
445
+ var de_CommandError = /* @__PURE__ */ __name(async (output, context) => {
615
446
  const parsedOutput = {
616
447
  ...output,
617
448
  body: await parseErrorBody(output.body, context)
618
449
  };
619
450
  const errorCode = loadQueryErrorCode(output, parsedOutput.body);
620
451
  switch (errorCode) {
452
+ case "ExpiredTokenException":
453
+ case "com.amazonaws.sts#ExpiredTokenException":
454
+ throw await de_ExpiredTokenExceptionRes(parsedOutput, context);
455
+ case "MalformedPolicyDocument":
456
+ case "com.amazonaws.sts#MalformedPolicyDocumentException":
457
+ throw await de_MalformedPolicyDocumentExceptionRes(parsedOutput, context);
458
+ case "PackedPolicyTooLarge":
459
+ case "com.amazonaws.sts#PackedPolicyTooLargeException":
460
+ throw await de_PackedPolicyTooLargeExceptionRes(parsedOutput, context);
621
461
  case "RegionDisabledException":
622
462
  case "com.amazonaws.sts#RegionDisabledException":
623
463
  throw await de_RegionDisabledExceptionRes(parsedOutput, context);
464
+ case "IDPRejectedClaim":
465
+ case "com.amazonaws.sts#IDPRejectedClaimException":
466
+ throw await de_IDPRejectedClaimExceptionRes(parsedOutput, context);
467
+ case "InvalidIdentityToken":
468
+ case "com.amazonaws.sts#InvalidIdentityTokenException":
469
+ throw await de_InvalidIdentityTokenExceptionRes(parsedOutput, context);
470
+ case "IDPCommunicationError":
471
+ case "com.amazonaws.sts#IDPCommunicationErrorException":
472
+ throw await de_IDPCommunicationErrorExceptionRes(parsedOutput, context);
473
+ case "InvalidAuthorizationMessageException":
474
+ case "com.amazonaws.sts#InvalidAuthorizationMessageException":
475
+ throw await de_InvalidAuthorizationMessageExceptionRes(parsedOutput, context);
624
476
  default:
625
477
  const parsedBody = parsedOutput.body;
626
478
  return throwDefaultError({
@@ -629,7 +481,7 @@ var de_GetSessionTokenCommandError = /* @__PURE__ */ __name(async (output, conte
629
481
  errorCode
630
482
  });
631
483
  }
632
- }, "de_GetSessionTokenCommandError");
484
+ }, "de_CommandError");
633
485
  var de_ExpiredTokenExceptionRes = /* @__PURE__ */ __name(async (parsedOutput, context) => {
634
486
  const body = parsedOutput.body;
635
487
  const deserialized = de_ExpiredTokenException(body.Error, context);
@@ -1482,34 +1334,54 @@ var STS = _STS;
1482
1334
  // src/index.ts
1483
1335
  var import_EndpointParameters9 = require("./endpoint/EndpointParameters");
1484
1336
  var import_runtimeExtensions = require("././runtimeExtensions");
1485
- var import_util_endpoints = require("@aws-sdk/util-endpoints");
1337
+
1486
1338
 
1487
1339
  // src/defaultStsRoleAssumers.ts
1340
+ var import_util_endpoints = require("@aws-sdk/util-endpoints");
1488
1341
  var ASSUME_ROLE_DEFAULT_REGION = "us-east-1";
1489
- var decorateDefaultRegion = /* @__PURE__ */ __name((region) => {
1490
- if (typeof region !== "function") {
1491
- return region === void 0 ? ASSUME_ROLE_DEFAULT_REGION : region;
1492
- }
1493
- return async () => {
1494
- try {
1495
- return await region();
1496
- } catch (e) {
1497
- return ASSUME_ROLE_DEFAULT_REGION;
1498
- }
1499
- };
1500
- }, "decorateDefaultRegion");
1342
+ var resolveRegion = /* @__PURE__ */ __name(async (_region, _parentRegion, credentialProviderLogger) => {
1343
+ var _a2, _b;
1344
+ const region = typeof _region === "function" ? await _region() : _region;
1345
+ const parentRegion = typeof _parentRegion === "function" ? await _parentRegion() : _parentRegion;
1346
+ if (!parentRegion || (0, import_util_endpoints.partition)(parentRegion).name === "aws") {
1347
+ (_a2 = credentialProviderLogger == null ? void 0 : credentialProviderLogger.debug) == null ? void 0 : _a2.call(
1348
+ credentialProviderLogger,
1349
+ "@aws-sdk/client-sts::resolveRegion",
1350
+ "accepting first of:",
1351
+ `${region} (provider)`,
1352
+ `${ASSUME_ROLE_DEFAULT_REGION} (STS default)`
1353
+ );
1354
+ return region ?? ASSUME_ROLE_DEFAULT_REGION;
1355
+ } else {
1356
+ (_b = credentialProviderLogger == null ? void 0 : credentialProviderLogger.debug) == null ? void 0 : _b.call(
1357
+ credentialProviderLogger,
1358
+ "@aws-sdk/client-sts::resolveRegion",
1359
+ "accepting first of:",
1360
+ `${region} (provider)`,
1361
+ `${parentRegion} (parent client)`,
1362
+ `${ASSUME_ROLE_DEFAULT_REGION} (STS default)`
1363
+ );
1364
+ return region ?? parentRegion ?? ASSUME_ROLE_DEFAULT_REGION;
1365
+ }
1366
+ }, "resolveRegion");
1501
1367
  var getDefaultRoleAssumer = /* @__PURE__ */ __name((stsOptions, stsClientCtor) => {
1502
1368
  let stsClient;
1503
1369
  let closureSourceCreds;
1504
1370
  return async (sourceCreds, params) => {
1371
+ var _a2;
1505
1372
  closureSourceCreds = sourceCreds;
1506
1373
  if (!stsClient) {
1507
- const { logger, region, requestHandler } = stsOptions;
1374
+ const { logger, region, requestHandler, credentialProviderLogger } = stsOptions;
1375
+ const resolvedRegion = await resolveRegion(
1376
+ region,
1377
+ (_a2 = stsOptions == null ? void 0 : stsOptions.parentClientConfig) == null ? void 0 : _a2.region,
1378
+ credentialProviderLogger
1379
+ );
1508
1380
  stsClient = new stsClientCtor({
1509
1381
  logger,
1510
1382
  // A hack to make sts client uses the credential in current closure.
1511
1383
  credentialDefaultProvider: () => async () => closureSourceCreds,
1512
- region: decorateDefaultRegion(region || stsOptions.region),
1384
+ region: resolvedRegion,
1513
1385
  ...requestHandler ? { requestHandler } : {}
1514
1386
  });
1515
1387
  }
@@ -1530,11 +1402,17 @@ var getDefaultRoleAssumer = /* @__PURE__ */ __name((stsOptions, stsClientCtor) =
1530
1402
  var getDefaultRoleAssumerWithWebIdentity = /* @__PURE__ */ __name((stsOptions, stsClientCtor) => {
1531
1403
  let stsClient;
1532
1404
  return async (params) => {
1405
+ var _a2;
1533
1406
  if (!stsClient) {
1534
- const { logger, region, requestHandler } = stsOptions;
1407
+ const { logger, region, requestHandler, credentialProviderLogger } = stsOptions;
1408
+ const resolvedRegion = await resolveRegion(
1409
+ region,
1410
+ (_a2 = stsOptions == null ? void 0 : stsOptions.parentClientConfig) == null ? void 0 : _a2.region,
1411
+ credentialProviderLogger
1412
+ );
1535
1413
  stsClient = new stsClientCtor({
1536
1414
  logger,
1537
- region: decorateDefaultRegion(region || stsOptions.region),
1415
+ region: resolvedRegion,
1538
1416
  ...requestHandler ? { requestHandler } : {}
1539
1417
  });
1540
1418
  }
@@ -1,18 +1,18 @@
1
+ import { partition } from "@aws-sdk/util-endpoints";
1
2
  import { AssumeRoleCommand } from "./commands/AssumeRoleCommand";
2
3
  import { AssumeRoleWithWebIdentityCommand, } from "./commands/AssumeRoleWithWebIdentityCommand";
3
4
  const ASSUME_ROLE_DEFAULT_REGION = "us-east-1";
4
- const decorateDefaultRegion = (region) => {
5
- if (typeof region !== "function") {
6
- return region === undefined ? ASSUME_ROLE_DEFAULT_REGION : region;
5
+ const resolveRegion = async (_region, _parentRegion, credentialProviderLogger) => {
6
+ const region = typeof _region === "function" ? await _region() : _region;
7
+ const parentRegion = typeof _parentRegion === "function" ? await _parentRegion() : _parentRegion;
8
+ if (!parentRegion || partition(parentRegion).name === "aws") {
9
+ credentialProviderLogger?.debug?.("@aws-sdk/client-sts::resolveRegion", "accepting first of:", `${region} (provider)`, `${ASSUME_ROLE_DEFAULT_REGION} (STS default)`);
10
+ return region ?? ASSUME_ROLE_DEFAULT_REGION;
11
+ }
12
+ else {
13
+ credentialProviderLogger?.debug?.("@aws-sdk/client-sts::resolveRegion", "accepting first of:", `${region} (provider)`, `${parentRegion} (parent client)`, `${ASSUME_ROLE_DEFAULT_REGION} (STS default)`);
14
+ return region ?? parentRegion ?? ASSUME_ROLE_DEFAULT_REGION;
7
15
  }
8
- return async () => {
9
- try {
10
- return await region();
11
- }
12
- catch (e) {
13
- return ASSUME_ROLE_DEFAULT_REGION;
14
- }
15
- };
16
16
  };
17
17
  export const getDefaultRoleAssumer = (stsOptions, stsClientCtor) => {
18
18
  let stsClient;
@@ -20,11 +20,12 @@ export const getDefaultRoleAssumer = (stsOptions, stsClientCtor) => {
20
20
  return async (sourceCreds, params) => {
21
21
  closureSourceCreds = sourceCreds;
22
22
  if (!stsClient) {
23
- const { logger, region, requestHandler } = stsOptions;
23
+ const { logger, region, requestHandler, credentialProviderLogger } = stsOptions;
24
+ const resolvedRegion = await resolveRegion(region, stsOptions?.parentClientConfig?.region, credentialProviderLogger);
24
25
  stsClient = new stsClientCtor({
25
26
  logger,
26
27
  credentialDefaultProvider: () => async () => closureSourceCreds,
27
- region: decorateDefaultRegion(region || stsOptions.region),
28
+ region: resolvedRegion,
28
29
  ...(requestHandler ? { requestHandler } : {}),
29
30
  });
30
31
  }
@@ -45,10 +46,11 @@ export const getDefaultRoleAssumerWithWebIdentity = (stsOptions, stsClientCtor)
45
46
  let stsClient;
46
47
  return async (params) => {
47
48
  if (!stsClient) {
48
- const { logger, region, requestHandler } = stsOptions;
49
+ const { logger, region, requestHandler, credentialProviderLogger } = stsOptions;
50
+ const resolvedRegion = await resolveRegion(region, stsOptions?.parentClientConfig?.region, credentialProviderLogger);
49
51
  stsClient = new stsClientCtor({
50
52
  logger,
51
- region: decorateDefaultRegion(region || stsOptions.region),
53
+ region: resolvedRegion,
52
54
  ...(requestHandler ? { requestHandler } : {}),
53
55
  });
54
56
  }
@@ -85,7 +85,7 @@ export const se_GetSessionTokenCommand = async (input, context) => {
85
85
  };
86
86
  export const de_AssumeRoleCommand = async (output, context) => {
87
87
  if (output.statusCode >= 300) {
88
- return de_AssumeRoleCommandError(output, context);
88
+ return de_CommandError(output, context);
89
89
  }
90
90
  const data = await parseBody(output.body, context);
91
91
  let contents = {};
@@ -96,37 +96,9 @@ export const de_AssumeRoleCommand = async (output, context) => {
96
96
  };
97
97
  return response;
98
98
  };
99
- const de_AssumeRoleCommandError = async (output, context) => {
100
- const parsedOutput = {
101
- ...output,
102
- body: await parseErrorBody(output.body, context),
103
- };
104
- const errorCode = loadQueryErrorCode(output, parsedOutput.body);
105
- switch (errorCode) {
106
- case "ExpiredTokenException":
107
- case "com.amazonaws.sts#ExpiredTokenException":
108
- throw await de_ExpiredTokenExceptionRes(parsedOutput, context);
109
- case "MalformedPolicyDocument":
110
- case "com.amazonaws.sts#MalformedPolicyDocumentException":
111
- throw await de_MalformedPolicyDocumentExceptionRes(parsedOutput, context);
112
- case "PackedPolicyTooLarge":
113
- case "com.amazonaws.sts#PackedPolicyTooLargeException":
114
- throw await de_PackedPolicyTooLargeExceptionRes(parsedOutput, context);
115
- case "RegionDisabledException":
116
- case "com.amazonaws.sts#RegionDisabledException":
117
- throw await de_RegionDisabledExceptionRes(parsedOutput, context);
118
- default:
119
- const parsedBody = parsedOutput.body;
120
- return throwDefaultError({
121
- output,
122
- parsedBody: parsedBody.Error,
123
- errorCode,
124
- });
125
- }
126
- };
127
99
  export const de_AssumeRoleWithSAMLCommand = async (output, context) => {
128
100
  if (output.statusCode >= 300) {
129
- return de_AssumeRoleWithSAMLCommandError(output, context);
101
+ return de_CommandError(output, context);
130
102
  }
131
103
  const data = await parseBody(output.body, context);
132
104
  let contents = {};
@@ -137,43 +109,9 @@ export const de_AssumeRoleWithSAMLCommand = async (output, context) => {
137
109
  };
138
110
  return response;
139
111
  };
140
- const de_AssumeRoleWithSAMLCommandError = async (output, context) => {
141
- const parsedOutput = {
142
- ...output,
143
- body: await parseErrorBody(output.body, context),
144
- };
145
- const errorCode = loadQueryErrorCode(output, parsedOutput.body);
146
- switch (errorCode) {
147
- case "ExpiredTokenException":
148
- case "com.amazonaws.sts#ExpiredTokenException":
149
- throw await de_ExpiredTokenExceptionRes(parsedOutput, context);
150
- case "IDPRejectedClaim":
151
- case "com.amazonaws.sts#IDPRejectedClaimException":
152
- throw await de_IDPRejectedClaimExceptionRes(parsedOutput, context);
153
- case "InvalidIdentityToken":
154
- case "com.amazonaws.sts#InvalidIdentityTokenException":
155
- throw await de_InvalidIdentityTokenExceptionRes(parsedOutput, context);
156
- case "MalformedPolicyDocument":
157
- case "com.amazonaws.sts#MalformedPolicyDocumentException":
158
- throw await de_MalformedPolicyDocumentExceptionRes(parsedOutput, context);
159
- case "PackedPolicyTooLarge":
160
- case "com.amazonaws.sts#PackedPolicyTooLargeException":
161
- throw await de_PackedPolicyTooLargeExceptionRes(parsedOutput, context);
162
- case "RegionDisabledException":
163
- case "com.amazonaws.sts#RegionDisabledException":
164
- throw await de_RegionDisabledExceptionRes(parsedOutput, context);
165
- default:
166
- const parsedBody = parsedOutput.body;
167
- return throwDefaultError({
168
- output,
169
- parsedBody: parsedBody.Error,
170
- errorCode,
171
- });
172
- }
173
- };
174
112
  export const de_AssumeRoleWithWebIdentityCommand = async (output, context) => {
175
113
  if (output.statusCode >= 300) {
176
- return de_AssumeRoleWithWebIdentityCommandError(output, context);
114
+ return de_CommandError(output, context);
177
115
  }
178
116
  const data = await parseBody(output.body, context);
179
117
  let contents = {};
@@ -184,46 +122,9 @@ export const de_AssumeRoleWithWebIdentityCommand = async (output, context) => {
184
122
  };
185
123
  return response;
186
124
  };
187
- const de_AssumeRoleWithWebIdentityCommandError = async (output, context) => {
188
- const parsedOutput = {
189
- ...output,
190
- body: await parseErrorBody(output.body, context),
191
- };
192
- const errorCode = loadQueryErrorCode(output, parsedOutput.body);
193
- switch (errorCode) {
194
- case "ExpiredTokenException":
195
- case "com.amazonaws.sts#ExpiredTokenException":
196
- throw await de_ExpiredTokenExceptionRes(parsedOutput, context);
197
- case "IDPCommunicationError":
198
- case "com.amazonaws.sts#IDPCommunicationErrorException":
199
- throw await de_IDPCommunicationErrorExceptionRes(parsedOutput, context);
200
- case "IDPRejectedClaim":
201
- case "com.amazonaws.sts#IDPRejectedClaimException":
202
- throw await de_IDPRejectedClaimExceptionRes(parsedOutput, context);
203
- case "InvalidIdentityToken":
204
- case "com.amazonaws.sts#InvalidIdentityTokenException":
205
- throw await de_InvalidIdentityTokenExceptionRes(parsedOutput, context);
206
- case "MalformedPolicyDocument":
207
- case "com.amazonaws.sts#MalformedPolicyDocumentException":
208
- throw await de_MalformedPolicyDocumentExceptionRes(parsedOutput, context);
209
- case "PackedPolicyTooLarge":
210
- case "com.amazonaws.sts#PackedPolicyTooLargeException":
211
- throw await de_PackedPolicyTooLargeExceptionRes(parsedOutput, context);
212
- case "RegionDisabledException":
213
- case "com.amazonaws.sts#RegionDisabledException":
214
- throw await de_RegionDisabledExceptionRes(parsedOutput, context);
215
- default:
216
- const parsedBody = parsedOutput.body;
217
- return throwDefaultError({
218
- output,
219
- parsedBody: parsedBody.Error,
220
- errorCode,
221
- });
222
- }
223
- };
224
125
  export const de_DecodeAuthorizationMessageCommand = async (output, context) => {
225
126
  if (output.statusCode >= 300) {
226
- return de_DecodeAuthorizationMessageCommandError(output, context);
127
+ return de_CommandError(output, context);
227
128
  }
228
129
  const data = await parseBody(output.body, context);
229
130
  let contents = {};
@@ -234,28 +135,9 @@ export const de_DecodeAuthorizationMessageCommand = async (output, context) => {
234
135
  };
235
136
  return response;
236
137
  };
237
- const de_DecodeAuthorizationMessageCommandError = async (output, context) => {
238
- const parsedOutput = {
239
- ...output,
240
- body: await parseErrorBody(output.body, context),
241
- };
242
- const errorCode = loadQueryErrorCode(output, parsedOutput.body);
243
- switch (errorCode) {
244
- case "InvalidAuthorizationMessageException":
245
- case "com.amazonaws.sts#InvalidAuthorizationMessageException":
246
- throw await de_InvalidAuthorizationMessageExceptionRes(parsedOutput, context);
247
- default:
248
- const parsedBody = parsedOutput.body;
249
- return throwDefaultError({
250
- output,
251
- parsedBody: parsedBody.Error,
252
- errorCode,
253
- });
254
- }
255
- };
256
138
  export const de_GetAccessKeyInfoCommand = async (output, context) => {
257
139
  if (output.statusCode >= 300) {
258
- return de_GetAccessKeyInfoCommandError(output, context);
140
+ return de_CommandError(output, context);
259
141
  }
260
142
  const data = await parseBody(output.body, context);
261
143
  let contents = {};
@@ -266,22 +148,9 @@ export const de_GetAccessKeyInfoCommand = async (output, context) => {
266
148
  };
267
149
  return response;
268
150
  };
269
- const de_GetAccessKeyInfoCommandError = async (output, context) => {
270
- const parsedOutput = {
271
- ...output,
272
- body: await parseErrorBody(output.body, context),
273
- };
274
- const errorCode = loadQueryErrorCode(output, parsedOutput.body);
275
- const parsedBody = parsedOutput.body;
276
- return throwDefaultError({
277
- output,
278
- parsedBody: parsedBody.Error,
279
- errorCode,
280
- });
281
- };
282
151
  export const de_GetCallerIdentityCommand = async (output, context) => {
283
152
  if (output.statusCode >= 300) {
284
- return de_GetCallerIdentityCommandError(output, context);
153
+ return de_CommandError(output, context);
285
154
  }
286
155
  const data = await parseBody(output.body, context);
287
156
  let contents = {};
@@ -292,22 +161,9 @@ export const de_GetCallerIdentityCommand = async (output, context) => {
292
161
  };
293
162
  return response;
294
163
  };
295
- const de_GetCallerIdentityCommandError = async (output, context) => {
296
- const parsedOutput = {
297
- ...output,
298
- body: await parseErrorBody(output.body, context),
299
- };
300
- const errorCode = loadQueryErrorCode(output, parsedOutput.body);
301
- const parsedBody = parsedOutput.body;
302
- return throwDefaultError({
303
- output,
304
- parsedBody: parsedBody.Error,
305
- errorCode,
306
- });
307
- };
308
164
  export const de_GetFederationTokenCommand = async (output, context) => {
309
165
  if (output.statusCode >= 300) {
310
- return de_GetFederationTokenCommandError(output, context);
166
+ return de_CommandError(output, context);
311
167
  }
312
168
  const data = await parseBody(output.body, context);
313
169
  let contents = {};
@@ -318,34 +174,9 @@ export const de_GetFederationTokenCommand = async (output, context) => {
318
174
  };
319
175
  return response;
320
176
  };
321
- const de_GetFederationTokenCommandError = async (output, context) => {
322
- const parsedOutput = {
323
- ...output,
324
- body: await parseErrorBody(output.body, context),
325
- };
326
- const errorCode = loadQueryErrorCode(output, parsedOutput.body);
327
- switch (errorCode) {
328
- case "MalformedPolicyDocument":
329
- case "com.amazonaws.sts#MalformedPolicyDocumentException":
330
- throw await de_MalformedPolicyDocumentExceptionRes(parsedOutput, context);
331
- case "PackedPolicyTooLarge":
332
- case "com.amazonaws.sts#PackedPolicyTooLargeException":
333
- throw await de_PackedPolicyTooLargeExceptionRes(parsedOutput, context);
334
- case "RegionDisabledException":
335
- case "com.amazonaws.sts#RegionDisabledException":
336
- throw await de_RegionDisabledExceptionRes(parsedOutput, context);
337
- default:
338
- const parsedBody = parsedOutput.body;
339
- return throwDefaultError({
340
- output,
341
- parsedBody: parsedBody.Error,
342
- errorCode,
343
- });
344
- }
345
- };
346
177
  export const de_GetSessionTokenCommand = async (output, context) => {
347
178
  if (output.statusCode >= 300) {
348
- return de_GetSessionTokenCommandError(output, context);
179
+ return de_CommandError(output, context);
349
180
  }
350
181
  const data = await parseBody(output.body, context);
351
182
  let contents = {};
@@ -356,16 +187,37 @@ export const de_GetSessionTokenCommand = async (output, context) => {
356
187
  };
357
188
  return response;
358
189
  };
359
- const de_GetSessionTokenCommandError = async (output, context) => {
190
+ const de_CommandError = async (output, context) => {
360
191
  const parsedOutput = {
361
192
  ...output,
362
193
  body: await parseErrorBody(output.body, context),
363
194
  };
364
195
  const errorCode = loadQueryErrorCode(output, parsedOutput.body);
365
196
  switch (errorCode) {
197
+ case "ExpiredTokenException":
198
+ case "com.amazonaws.sts#ExpiredTokenException":
199
+ throw await de_ExpiredTokenExceptionRes(parsedOutput, context);
200
+ case "MalformedPolicyDocument":
201
+ case "com.amazonaws.sts#MalformedPolicyDocumentException":
202
+ throw await de_MalformedPolicyDocumentExceptionRes(parsedOutput, context);
203
+ case "PackedPolicyTooLarge":
204
+ case "com.amazonaws.sts#PackedPolicyTooLargeException":
205
+ throw await de_PackedPolicyTooLargeExceptionRes(parsedOutput, context);
366
206
  case "RegionDisabledException":
367
207
  case "com.amazonaws.sts#RegionDisabledException":
368
208
  throw await de_RegionDisabledExceptionRes(parsedOutput, context);
209
+ case "IDPRejectedClaim":
210
+ case "com.amazonaws.sts#IDPRejectedClaimException":
211
+ throw await de_IDPRejectedClaimExceptionRes(parsedOutput, context);
212
+ case "InvalidIdentityToken":
213
+ case "com.amazonaws.sts#InvalidIdentityTokenException":
214
+ throw await de_InvalidIdentityTokenExceptionRes(parsedOutput, context);
215
+ case "IDPCommunicationError":
216
+ case "com.amazonaws.sts#IDPCommunicationErrorException":
217
+ throw await de_IDPCommunicationErrorExceptionRes(parsedOutput, context);
218
+ case "InvalidAuthorizationMessageException":
219
+ case "com.amazonaws.sts#InvalidAuthorizationMessageException":
220
+ throw await de_InvalidAuthorizationMessageExceptionRes(parsedOutput, context);
369
221
  default:
370
222
  const parsedBody = parsedOutput.body;
371
223
  return throwDefaultError({
@@ -1,14 +1,14 @@
1
1
  import { Pluggable } from "@smithy/types";
2
- import { DefaultCredentialProvider, RoleAssumer, RoleAssumerWithWebIdentity } from "./defaultStsRoleAssumers";
3
- import { ServiceInputTypes, ServiceOutputTypes, STSClientConfig } from "./STSClient";
2
+ import { DefaultCredentialProvider, RoleAssumer, RoleAssumerWithWebIdentity, STSRoleAssumerOptions } from "./defaultStsRoleAssumers";
3
+ import { ServiceInputTypes, ServiceOutputTypes } from "./STSClient";
4
4
  /**
5
5
  * The default role assumer that used by credential providers when sts:AssumeRole API is needed.
6
6
  */
7
- export declare const getDefaultRoleAssumer: (stsOptions?: Pick<STSClientConfig, "logger" | "region" | "requestHandler">, stsPlugins?: Pluggable<ServiceInputTypes, ServiceOutputTypes>[]) => RoleAssumer;
7
+ export declare const getDefaultRoleAssumer: (stsOptions?: STSRoleAssumerOptions, stsPlugins?: Pluggable<ServiceInputTypes, ServiceOutputTypes>[]) => RoleAssumer;
8
8
  /**
9
9
  * The default role assumer that used by credential providers when sts:AssumeRoleWithWebIdentity API is needed.
10
10
  */
11
- export declare const getDefaultRoleAssumerWithWebIdentity: (stsOptions?: Pick<STSClientConfig, "logger" | "region" | "requestHandler">, stsPlugins?: Pluggable<ServiceInputTypes, ServiceOutputTypes>[]) => RoleAssumerWithWebIdentity;
11
+ export declare const getDefaultRoleAssumerWithWebIdentity: (stsOptions?: STSRoleAssumerOptions, stsPlugins?: Pluggable<ServiceInputTypes, ServiceOutputTypes>[]) => RoleAssumerWithWebIdentity;
12
12
  /**
13
13
  * The default credential providers depend STS client to assume role with desired API: sts:assumeRole,
14
14
  * sts:assumeRoleWithWebIdentity, etc. This function decorates the default credential provider with role assumers which
@@ -1,7 +1,15 @@
1
- import { AwsCredentialIdentity, Provider } from "@smithy/types";
1
+ import type { CredentialProviderOptions } from "@aws-sdk/types";
2
+ import { AwsCredentialIdentity, Logger, Provider } from "@smithy/types";
2
3
  import { AssumeRoleCommandInput } from "./commands/AssumeRoleCommand";
3
4
  import { AssumeRoleWithWebIdentityCommandInput } from "./commands/AssumeRoleWithWebIdentityCommand";
4
5
  import type { STSClient, STSClientConfig } from "./STSClient";
6
+ /**
7
+ * @public
8
+ */
9
+ export type STSRoleAssumerOptions = Pick<STSClientConfig, "logger" | "region" | "requestHandler"> & {
10
+ credentialProviderLogger?: Logger;
11
+ parentClientConfig?: CredentialProviderOptions["parentClientConfig"];
12
+ };
5
13
  /**
6
14
  * @internal
7
15
  */
@@ -10,7 +18,7 @@ export type RoleAssumer = (sourceCreds: AwsCredentialIdentity, params: AssumeRol
10
18
  * The default role assumer that used by credential providers when sts:AssumeRole API is needed.
11
19
  * @internal
12
20
  */
13
- export declare const getDefaultRoleAssumer: (stsOptions: Pick<STSClientConfig, "logger" | "region" | "requestHandler">, stsClientCtor: new (options: STSClientConfig) => STSClient) => RoleAssumer;
21
+ export declare const getDefaultRoleAssumer: (stsOptions: STSRoleAssumerOptions, stsClientCtor: new (options: STSClientConfig) => STSClient) => RoleAssumer;
14
22
  /**
15
23
  * @internal
16
24
  */
@@ -19,7 +27,7 @@ export type RoleAssumerWithWebIdentity = (params: AssumeRoleWithWebIdentityComma
19
27
  * The default role assumer that used by credential providers when sts:AssumeRoleWithWebIdentity API is needed.
20
28
  * @internal
21
29
  */
22
- export declare const getDefaultRoleAssumerWithWebIdentity: (stsOptions: Pick<STSClientConfig, "logger" | "region" | "requestHandler">, stsClientCtor: new (options: STSClientConfig) => STSClient) => RoleAssumerWithWebIdentity;
30
+ export declare const getDefaultRoleAssumerWithWebIdentity: (stsOptions: STSRoleAssumerOptions, stsClientCtor: new (options: STSClientConfig) => STSClient) => RoleAssumerWithWebIdentity;
23
31
  /**
24
32
  * @internal
25
33
  */
@@ -3,18 +3,15 @@ import {
3
3
  DefaultCredentialProvider,
4
4
  RoleAssumer,
5
5
  RoleAssumerWithWebIdentity,
6
+ STSRoleAssumerOptions,
6
7
  } from "./defaultStsRoleAssumers";
7
- import {
8
- ServiceInputTypes,
9
- ServiceOutputTypes,
10
- STSClientConfig,
11
- } from "./STSClient";
8
+ import { ServiceInputTypes, ServiceOutputTypes } from "./STSClient";
12
9
  export declare const getDefaultRoleAssumer: (
13
- stsOptions?: Pick<STSClientConfig, "logger" | "region" | "requestHandler">,
10
+ stsOptions?: STSRoleAssumerOptions,
14
11
  stsPlugins?: Pluggable<ServiceInputTypes, ServiceOutputTypes>[]
15
12
  ) => RoleAssumer;
16
13
  export declare const getDefaultRoleAssumerWithWebIdentity: (
17
- stsOptions?: Pick<STSClientConfig, "logger" | "region" | "requestHandler">,
14
+ stsOptions?: STSRoleAssumerOptions,
18
15
  stsPlugins?: Pluggable<ServiceInputTypes, ServiceOutputTypes>[]
19
16
  ) => RoleAssumerWithWebIdentity;
20
17
  export declare const decorateDefaultCredentialProvider: (
@@ -1,20 +1,28 @@
1
- import { AwsCredentialIdentity, Provider } from "@smithy/types";
1
+ import { CredentialProviderOptions } from "@aws-sdk/types";
2
+ import { AwsCredentialIdentity, Logger, Provider } from "@smithy/types";
2
3
  import { AssumeRoleCommandInput } from "./commands/AssumeRoleCommand";
3
4
  import { AssumeRoleWithWebIdentityCommandInput } from "./commands/AssumeRoleWithWebIdentityCommand";
4
5
  import { STSClient, STSClientConfig } from "./STSClient";
6
+ export type STSRoleAssumerOptions = Pick<
7
+ STSClientConfig,
8
+ "logger" | "region" | "requestHandler"
9
+ > & {
10
+ credentialProviderLogger?: Logger;
11
+ parentClientConfig?: CredentialProviderOptions["parentClientConfig"];
12
+ };
5
13
  export type RoleAssumer = (
6
14
  sourceCreds: AwsCredentialIdentity,
7
15
  params: AssumeRoleCommandInput
8
16
  ) => Promise<AwsCredentialIdentity>;
9
17
  export declare const getDefaultRoleAssumer: (
10
- stsOptions: Pick<STSClientConfig, "logger" | "region" | "requestHandler">,
18
+ stsOptions: STSRoleAssumerOptions,
11
19
  stsClientCtor: new (options: STSClientConfig) => STSClient
12
20
  ) => RoleAssumer;
13
21
  export type RoleAssumerWithWebIdentity = (
14
22
  params: AssumeRoleWithWebIdentityCommandInput
15
23
  ) => Promise<AwsCredentialIdentity>;
16
24
  export declare const getDefaultRoleAssumerWithWebIdentity: (
17
- stsOptions: Pick<STSClientConfig, "logger" | "region" | "requestHandler">,
25
+ stsOptions: STSRoleAssumerOptions,
18
26
  stsClientCtor: new (options: STSClientConfig) => STSClient
19
27
  ) => RoleAssumerWithWebIdentity;
20
28
  export type DefaultCredentialProvider = (
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aws-sdk/client-sts",
3
3
  "description": "AWS SDK for JavaScript Sts Client for Node.js, Browser and React Native",
4
- "version": "3.504.0",
4
+ "version": "3.511.0",
5
5
  "scripts": {
6
6
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
7
7
  "build:cjs": "node ../../scripts/compilation/inline client-sts",
@@ -22,16 +22,16 @@
22
22
  "dependencies": {
23
23
  "@aws-crypto/sha256-browser": "3.0.0",
24
24
  "@aws-crypto/sha256-js": "3.0.0",
25
- "@aws-sdk/core": "3.496.0",
26
- "@aws-sdk/middleware-host-header": "3.502.0",
27
- "@aws-sdk/middleware-logger": "3.502.0",
28
- "@aws-sdk/middleware-recursion-detection": "3.502.0",
29
- "@aws-sdk/middleware-user-agent": "3.502.0",
30
- "@aws-sdk/region-config-resolver": "3.502.0",
31
- "@aws-sdk/types": "3.502.0",
32
- "@aws-sdk/util-endpoints": "3.502.0",
33
- "@aws-sdk/util-user-agent-browser": "3.502.0",
34
- "@aws-sdk/util-user-agent-node": "3.502.0",
25
+ "@aws-sdk/core": "3.511.0",
26
+ "@aws-sdk/middleware-host-header": "3.511.0",
27
+ "@aws-sdk/middleware-logger": "3.511.0",
28
+ "@aws-sdk/middleware-recursion-detection": "3.511.0",
29
+ "@aws-sdk/middleware-user-agent": "3.511.0",
30
+ "@aws-sdk/region-config-resolver": "3.511.0",
31
+ "@aws-sdk/types": "3.511.0",
32
+ "@aws-sdk/util-endpoints": "3.511.0",
33
+ "@aws-sdk/util-user-agent-browser": "3.511.0",
34
+ "@aws-sdk/util-user-agent-node": "3.511.0",
35
35
  "@smithy/config-resolver": "^2.1.1",
36
36
  "@smithy/core": "^1.3.1",
37
37
  "@smithy/fetch-http-handler": "^2.4.1",
@@ -88,7 +88,7 @@
88
88
  },
89
89
  "license": "Apache-2.0",
90
90
  "peerDependencies": {
91
- "@aws-sdk/credential-provider-node": "^3.504.0"
91
+ "@aws-sdk/credential-provider-node": "^3.511.0"
92
92
  },
93
93
  "browser": {
94
94
  "./dist-es/runtimeConfig": "./dist-es/runtimeConfig.browser"