@aws-sdk/credential-provider-sso 3.501.0 → 3.503.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/dist-cjs/index.js CHANGED
@@ -3,6 +3,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __esm = (fn, res) => function __init() {
7
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
8
+ };
6
9
  var __export = (target, all) => {
7
10
  for (var name in all)
8
11
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -17,6 +20,19 @@ var __copyProps = (to, from, except, desc) => {
17
20
  };
18
21
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
22
 
23
+ // src/loadSso.ts
24
+ var loadSso_exports = {};
25
+ __export(loadSso_exports, {
26
+ GetRoleCredentialsCommand: () => import_client_sso.GetRoleCredentialsCommand,
27
+ SSOClient: () => import_client_sso.SSOClient
28
+ });
29
+ var import_client_sso;
30
+ var init_loadSso = __esm({
31
+ "src/loadSso.ts"() {
32
+ import_client_sso = require("@aws-sdk/client-sso");
33
+ }
34
+ });
35
+
20
36
  // src/index.ts
21
37
  var src_exports = {};
22
38
  __export(src_exports, {
@@ -34,7 +50,6 @@ module.exports = __toCommonJS(src_exports);
34
50
  var isSsoProfile = /* @__PURE__ */ __name((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"), "isSsoProfile");
35
51
 
36
52
  // src/resolveSSOCredentials.ts
37
- var import_client_sso = require("@aws-sdk/client-sso");
38
53
  var import_token_providers = require("@aws-sdk/token-providers");
39
54
  var import_property_provider = require("@smithy/property-provider");
40
55
  var import_shared_ini_file_loader = require("@smithy/shared-ini-file-loader");
@@ -46,9 +61,9 @@ var resolveSSOCredentials = /* @__PURE__ */ __name(async ({
46
61
  ssoRegion,
47
62
  ssoRoleName,
48
63
  ssoClient,
64
+ clientConfig,
49
65
  profile
50
66
  }) => {
51
- var _a;
52
67
  let token;
53
68
  const refreshMessage = `To refresh this SSO session run aws sso login with the corresponding profile.`;
54
69
  if (ssoSession) {
@@ -78,11 +93,16 @@ var resolveSSOCredentials = /* @__PURE__ */ __name(async ({
78
93
  );
79
94
  }
80
95
  const { accessToken } = token;
81
- const sso = ssoClient || new import_client_sso.SSOClient({ region: ssoRegion });
96
+ const { SSOClient: SSOClient2, GetRoleCredentialsCommand: GetRoleCredentialsCommand2 } = await Promise.resolve().then(() => (init_loadSso(), loadSso_exports));
97
+ const sso = ssoClient || new SSOClient2(
98
+ Object.assign({}, clientConfig ?? {}, {
99
+ region: (clientConfig == null ? void 0 : clientConfig.region) ?? ssoRegion
100
+ })
101
+ );
82
102
  let ssoResp;
83
103
  try {
84
104
  ssoResp = await sso.send(
85
- new import_client_sso.GetRoleCredentialsCommand({
105
+ new GetRoleCredentialsCommand2({
86
106
  accountId: ssoAccountId,
87
107
  roleName: ssoRoleName,
88
108
  accessToken
@@ -91,8 +111,7 @@ var resolveSSOCredentials = /* @__PURE__ */ __name(async ({
91
111
  } catch (e) {
92
112
  throw import_property_provider.CredentialsProviderError.from(e, SHOULD_FAIL_CREDENTIAL_CHAIN);
93
113
  }
94
- const { roleCredentials: { accessKeyId, secretAccessKey, sessionToken, expiration } = {} } = ssoResp;
95
- const credentialScope = (_a = ssoResp == null ? void 0 : ssoResp.roleCredentials) == null ? void 0 : _a.credentialScope;
114
+ const { roleCredentials: { accessKeyId, secretAccessKey, sessionToken, expiration, credentialScope } = {} } = ssoResp;
96
115
  if (!accessKeyId || !secretAccessKey || !sessionToken || !expiration) {
97
116
  throw new import_property_provider.CredentialsProviderError("SSO returns an invalid temporary credential.", SHOULD_FAIL_CREDENTIAL_CHAIN);
98
117
  }
@@ -117,7 +136,10 @@ Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.ht
117
136
 
118
137
  // src/fromSSO.ts
119
138
  var fromSSO = /* @__PURE__ */ __name((init = {}) => async () => {
120
- const { ssoStartUrl, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, ssoSession } = init;
139
+ var _a;
140
+ (_a = init.logger) == null ? void 0 : _a.debug("@aws-sdk/credential-provider-sso", "fromSSO");
141
+ const { ssoStartUrl, ssoAccountId, ssoRegion, ssoRoleName, ssoSession } = init;
142
+ const { ssoClient } = init;
121
143
  const profileName = (0, import_shared_ini_file_loader.getProfileName)(init);
122
144
  if (!ssoStartUrl && !ssoAccountId && !ssoRegion && !ssoRoleName && !ssoSession) {
123
145
  const profiles = await (0, import_shared_ini_file_loader.parseKnownFiles)(init);
@@ -149,6 +171,7 @@ var fromSSO = /* @__PURE__ */ __name((init = {}) => async () => {
149
171
  ssoRegion: sso_region,
150
172
  ssoRoleName: sso_role_name,
151
173
  ssoClient,
174
+ clientConfig: init.clientConfig,
152
175
  profile: profileName
153
176
  });
154
177
  } else if (!ssoStartUrl || !ssoAccountId || !ssoRegion || !ssoRoleName) {
@@ -163,6 +186,7 @@ var fromSSO = /* @__PURE__ */ __name((init = {}) => async () => {
163
186
  ssoRegion,
164
187
  ssoRoleName,
165
188
  ssoClient,
189
+ clientConfig: init.clientConfig,
166
190
  profile: profileName
167
191
  });
168
192
  }
@@ -0,0 +1 @@
1
+ module.exports = require("./index.js");
@@ -4,7 +4,9 @@ import { isSsoProfile } from "./isSsoProfile";
4
4
  import { resolveSSOCredentials } from "./resolveSSOCredentials";
5
5
  import { validateSsoProfile } from "./validateSsoProfile";
6
6
  export const fromSSO = (init = {}) => async () => {
7
- const { ssoStartUrl, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, ssoSession } = init;
7
+ init.logger?.debug("@aws-sdk/credential-provider-sso", "fromSSO");
8
+ const { ssoStartUrl, ssoAccountId, ssoRegion, ssoRoleName, ssoSession } = init;
9
+ const { ssoClient } = init;
8
10
  const profileName = getProfileName(init);
9
11
  if (!ssoStartUrl && !ssoAccountId && !ssoRegion && !ssoRoleName && !ssoSession) {
10
12
  const profiles = await parseKnownFiles(init);
@@ -36,6 +38,7 @@ export const fromSSO = (init = {}) => async () => {
36
38
  ssoRegion: sso_region,
37
39
  ssoRoleName: sso_role_name,
38
40
  ssoClient: ssoClient,
41
+ clientConfig: init.clientConfig,
39
42
  profile: profileName,
40
43
  });
41
44
  }
@@ -51,6 +54,7 @@ export const fromSSO = (init = {}) => async () => {
51
54
  ssoRegion,
52
55
  ssoRoleName,
53
56
  ssoClient,
57
+ clientConfig: init.clientConfig,
54
58
  profile: profileName,
55
59
  });
56
60
  }
@@ -0,0 +1,2 @@
1
+ import { GetRoleCredentialsCommand, SSOClient } from "@aws-sdk/client-sso";
2
+ export { GetRoleCredentialsCommand, SSOClient };
@@ -1,9 +1,8 @@
1
- import { GetRoleCredentialsCommand, SSOClient } from "@aws-sdk/client-sso";
2
1
  import { fromSso as getSsoTokenProvider } from "@aws-sdk/token-providers";
3
2
  import { CredentialsProviderError } from "@smithy/property-provider";
4
3
  import { getSSOTokenFromFile } from "@smithy/shared-ini-file-loader";
5
4
  const SHOULD_FAIL_CREDENTIAL_CHAIN = false;
6
- export const resolveSSOCredentials = async ({ ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, profile, }) => {
5
+ export const resolveSSOCredentials = async ({ ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, clientConfig, profile, }) => {
7
6
  let token;
8
7
  const refreshMessage = `To refresh this SSO session run aws sso login with the corresponding profile.`;
9
8
  if (ssoSession) {
@@ -30,7 +29,11 @@ export const resolveSSOCredentials = async ({ ssoStartUrl, ssoSession, ssoAccoun
30
29
  throw new CredentialsProviderError(`The SSO session associated with this profile has expired. ${refreshMessage}`, SHOULD_FAIL_CREDENTIAL_CHAIN);
31
30
  }
32
31
  const { accessToken } = token;
33
- const sso = ssoClient || new SSOClient({ region: ssoRegion });
32
+ const { SSOClient, GetRoleCredentialsCommand } = await import("./loadSso");
33
+ const sso = ssoClient ||
34
+ new SSOClient(Object.assign({}, clientConfig ?? {}, {
35
+ region: clientConfig?.region ?? ssoRegion,
36
+ }));
34
37
  let ssoResp;
35
38
  try {
36
39
  ssoResp = await sso.send(new GetRoleCredentialsCommand({
@@ -42,8 +45,7 @@ export const resolveSSOCredentials = async ({ ssoStartUrl, ssoSession, ssoAccoun
42
45
  catch (e) {
43
46
  throw CredentialsProviderError.from(e, SHOULD_FAIL_CREDENTIAL_CHAIN);
44
47
  }
45
- const { roleCredentials: { accessKeyId, secretAccessKey, sessionToken, expiration } = {} } = ssoResp;
46
- const credentialScope = ssoResp?.roleCredentials?.credentialScope;
48
+ const { roleCredentials: { accessKeyId, secretAccessKey, sessionToken, expiration, credentialScope } = {} } = ssoResp;
47
49
  if (!accessKeyId || !secretAccessKey || !sessionToken || !expiration) {
48
50
  throw new CredentialsProviderError("SSO returns an invalid temporary credential.", SHOULD_FAIL_CREDENTIAL_CHAIN);
49
51
  }
@@ -1,6 +1,7 @@
1
- import { SSOClient } from "@aws-sdk/client-sso";
1
+ import type { CredentialProviderOptions } from "@aws-sdk/types";
2
2
  import { SourceProfileInit } from "@smithy/shared-ini-file-loader";
3
3
  import { AwsCredentialIdentityProvider } from "@smithy/types";
4
+ import type { SSOClient, SSOClientConfig } from "./loadSso";
4
5
  /**
5
6
  * @internal
6
7
  */
@@ -30,8 +31,9 @@ export interface SsoCredentialsParameters {
30
31
  /**
31
32
  * @internal
32
33
  */
33
- export interface FromSSOInit extends SourceProfileInit {
34
+ export interface FromSSOInit extends SourceProfileInit, CredentialProviderOptions {
34
35
  ssoClient?: SSOClient;
36
+ clientConfig?: SSOClientConfig;
35
37
  }
36
38
  /**
37
39
  * @internal
@@ -0,0 +1,3 @@
1
+ import { GetRoleCredentialsCommand, SSOClient } from "@aws-sdk/client-sso";
2
+ export { GetRoleCredentialsCommand, SSOClient };
3
+ export type { SSOClientConfig, GetRoleCredentialsCommandOutput } from "@aws-sdk/client-sso";
@@ -3,4 +3,4 @@ import { FromSSOInit, SsoCredentialsParameters } from "./fromSSO";
3
3
  /**
4
4
  * @internal
5
5
  */
6
- export declare const resolveSSOCredentials: ({ ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, profile, }: FromSSOInit & SsoCredentialsParameters) => Promise<AwsCredentialIdentity>;
6
+ export declare const resolveSSOCredentials: ({ ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, clientConfig, profile, }: FromSSOInit & SsoCredentialsParameters) => Promise<AwsCredentialIdentity>;
@@ -1,6 +1,7 @@
1
- import { SSOClient } from "@aws-sdk/client-sso";
1
+ import { CredentialProviderOptions } from "@aws-sdk/types";
2
2
  import { SourceProfileInit } from "@smithy/shared-ini-file-loader";
3
3
  import { AwsCredentialIdentityProvider } from "@smithy/types";
4
+ import { SSOClient, SSOClientConfig } from "./loadSso";
4
5
  export interface SsoCredentialsParameters {
5
6
  ssoStartUrl: string;
6
7
  ssoSession?: string;
@@ -8,8 +9,11 @@ export interface SsoCredentialsParameters {
8
9
  ssoRegion: string;
9
10
  ssoRoleName: string;
10
11
  }
11
- export interface FromSSOInit extends SourceProfileInit {
12
+ export interface FromSSOInit
13
+ extends SourceProfileInit,
14
+ CredentialProviderOptions {
12
15
  ssoClient?: SSOClient;
16
+ clientConfig?: SSOClientConfig;
13
17
  }
14
18
  export declare const fromSSO: (
15
19
  init?: FromSSOInit & Partial<SsoCredentialsParameters>
@@ -0,0 +1,6 @@
1
+ import { GetRoleCredentialsCommand, SSOClient } from "@aws-sdk/client-sso";
2
+ export { GetRoleCredentialsCommand, SSOClient };
3
+ export {
4
+ SSOClientConfig,
5
+ GetRoleCredentialsCommandOutput,
6
+ } from "@aws-sdk/client-sso";
@@ -7,5 +7,6 @@ export declare const resolveSSOCredentials: ({
7
7
  ssoRegion,
8
8
  ssoRoleName,
9
9
  ssoClient,
10
+ clientConfig,
10
11
  profile,
11
12
  }: FromSSOInit & SsoCredentialsParameters) => Promise<AwsCredentialIdentity>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/credential-provider-sso",
3
- "version": "3.501.0",
3
+ "version": "3.503.1",
4
4
  "description": "AWS credential provider that exchanges a resolved SSO login token file for temporary AWS credentials",
5
5
  "main": "./dist-cjs/index.js",
6
6
  "module": "./dist-es/index.js",
@@ -24,9 +24,9 @@
24
24
  },
25
25
  "license": "Apache-2.0",
26
26
  "dependencies": {
27
- "@aws-sdk/client-sso": "3.496.0",
28
- "@aws-sdk/token-providers": "3.501.0",
29
- "@aws-sdk/types": "3.496.0",
27
+ "@aws-sdk/client-sso": "3.502.0",
28
+ "@aws-sdk/token-providers": "3.502.0",
29
+ "@aws-sdk/types": "3.502.0",
30
30
  "@smithy/property-provider": "^2.1.1",
31
31
  "@smithy/shared-ini-file-loader": "^2.3.1",
32
32
  "@smithy/types": "^2.9.1",