@aws-sdk/credential-provider-sso 3.582.0 → 3.587.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 +43 -21
- package/dist-es/fromSSO.js +15 -7
- package/dist-es/resolveSSOCredentials.js +21 -6
- package/dist-es/validateSsoProfile.js +2 -2
- package/dist-types/resolveSSOCredentials.d.ts +1 -1
- package/dist-types/ts3.4/resolveSSOCredentials.d.ts +1 -0
- package/dist-types/ts3.4/validateSsoProfile.d.ts +3 -1
- package/dist-types/validateSsoProfile.d.ts +2 -1
- package/package.json +5 -5
package/dist-cjs/index.js
CHANGED
|
@@ -64,7 +64,8 @@ var resolveSSOCredentials = /* @__PURE__ */ __name(async ({
|
|
|
64
64
|
ssoRoleName,
|
|
65
65
|
ssoClient,
|
|
66
66
|
clientConfig,
|
|
67
|
-
profile
|
|
67
|
+
profile,
|
|
68
|
+
logger
|
|
68
69
|
}) => {
|
|
69
70
|
let token;
|
|
70
71
|
const refreshMessage = `To refresh this SSO session run aws sso login with the corresponding profile.`;
|
|
@@ -76,23 +77,26 @@ var resolveSSOCredentials = /* @__PURE__ */ __name(async ({
|
|
|
76
77
|
expiresAt: new Date(_token.expiration).toISOString()
|
|
77
78
|
};
|
|
78
79
|
} catch (e) {
|
|
79
|
-
throw new import_property_provider.CredentialsProviderError(e.message,
|
|
80
|
+
throw new import_property_provider.CredentialsProviderError(e.message, {
|
|
81
|
+
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
82
|
+
logger
|
|
83
|
+
});
|
|
80
84
|
}
|
|
81
85
|
} else {
|
|
82
86
|
try {
|
|
83
87
|
token = await (0, import_shared_ini_file_loader.getSSOTokenFromFile)(ssoStartUrl);
|
|
84
88
|
} catch (e) {
|
|
85
|
-
throw new import_property_provider.CredentialsProviderError(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
);
|
|
89
|
+
throw new import_property_provider.CredentialsProviderError(`The SSO session associated with this profile is invalid. ${refreshMessage}`, {
|
|
90
|
+
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
91
|
+
logger
|
|
92
|
+
});
|
|
89
93
|
}
|
|
90
94
|
}
|
|
91
95
|
if (new Date(token.expiresAt).getTime() - Date.now() <= 0) {
|
|
92
|
-
throw new import_property_provider.CredentialsProviderError(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
);
|
|
96
|
+
throw new import_property_provider.CredentialsProviderError(`The SSO session associated with this profile has expired. ${refreshMessage}`, {
|
|
97
|
+
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
98
|
+
logger
|
|
99
|
+
});
|
|
96
100
|
}
|
|
97
101
|
const { accessToken } = token;
|
|
98
102
|
const { SSOClient: SSOClient2, GetRoleCredentialsCommand: GetRoleCredentialsCommand2 } = await Promise.resolve().then(() => (init_loadSso(), loadSso_exports));
|
|
@@ -111,18 +115,24 @@ var resolveSSOCredentials = /* @__PURE__ */ __name(async ({
|
|
|
111
115
|
})
|
|
112
116
|
);
|
|
113
117
|
} catch (e) {
|
|
114
|
-
throw import_property_provider.CredentialsProviderError
|
|
118
|
+
throw new import_property_provider.CredentialsProviderError(e, {
|
|
119
|
+
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
120
|
+
logger
|
|
121
|
+
});
|
|
115
122
|
}
|
|
116
123
|
const { roleCredentials: { accessKeyId, secretAccessKey, sessionToken, expiration, credentialScope } = {} } = ssoResp;
|
|
117
124
|
if (!accessKeyId || !secretAccessKey || !sessionToken || !expiration) {
|
|
118
|
-
throw new import_property_provider.CredentialsProviderError("SSO returns an invalid temporary credential.",
|
|
125
|
+
throw new import_property_provider.CredentialsProviderError("SSO returns an invalid temporary credential.", {
|
|
126
|
+
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
127
|
+
logger
|
|
128
|
+
});
|
|
119
129
|
}
|
|
120
130
|
return { accessKeyId, secretAccessKey, sessionToken, expiration: new Date(expiration), credentialScope };
|
|
121
131
|
}, "resolveSSOCredentials");
|
|
122
132
|
|
|
123
133
|
// src/validateSsoProfile.ts
|
|
124
134
|
|
|
125
|
-
var validateSsoProfile = /* @__PURE__ */ __name((profile) => {
|
|
135
|
+
var validateSsoProfile = /* @__PURE__ */ __name((profile, logger) => {
|
|
126
136
|
const { sso_start_url, sso_account_id, sso_region, sso_role_name } = profile;
|
|
127
137
|
if (!sso_start_url || !sso_account_id || !sso_region || !sso_role_name) {
|
|
128
138
|
throw new import_property_provider.CredentialsProviderError(
|
|
@@ -130,7 +140,7 @@ var validateSsoProfile = /* @__PURE__ */ __name((profile) => {
|
|
|
130
140
|
", "
|
|
131
141
|
)}
|
|
132
142
|
Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html`,
|
|
133
|
-
false
|
|
143
|
+
{ tryNextLink: false, logger }
|
|
134
144
|
);
|
|
135
145
|
}
|
|
136
146
|
return profile;
|
|
@@ -139,7 +149,7 @@ Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.ht
|
|
|
139
149
|
// src/fromSSO.ts
|
|
140
150
|
var fromSSO = /* @__PURE__ */ __name((init = {}) => async () => {
|
|
141
151
|
var _a;
|
|
142
|
-
(_a = init.logger) == null ? void 0 : _a.debug("@aws-sdk/credential-provider-sso
|
|
152
|
+
(_a = init.logger) == null ? void 0 : _a.debug("@aws-sdk/credential-provider-sso - fromSSO");
|
|
143
153
|
const { ssoStartUrl, ssoAccountId, ssoRegion, ssoRoleName, ssoSession } = init;
|
|
144
154
|
const { ssoClient } = init;
|
|
145
155
|
const profileName = (0, import_shared_ini_file_loader.getProfileName)(init);
|
|
@@ -147,25 +157,36 @@ var fromSSO = /* @__PURE__ */ __name((init = {}) => async () => {
|
|
|
147
157
|
const profiles = await (0, import_shared_ini_file_loader.parseKnownFiles)(init);
|
|
148
158
|
const profile = profiles[profileName];
|
|
149
159
|
if (!profile) {
|
|
150
|
-
throw new import_property_provider.CredentialsProviderError(`Profile ${profileName} was not found
|
|
160
|
+
throw new import_property_provider.CredentialsProviderError(`Profile ${profileName} was not found.`, { logger: init.logger });
|
|
151
161
|
}
|
|
152
162
|
if (!isSsoProfile(profile)) {
|
|
153
|
-
throw new import_property_provider.CredentialsProviderError(`Profile ${profileName} is not configured with SSO credentials
|
|
163
|
+
throw new import_property_provider.CredentialsProviderError(`Profile ${profileName} is not configured with SSO credentials.`, {
|
|
164
|
+
logger: init.logger
|
|
165
|
+
});
|
|
154
166
|
}
|
|
155
167
|
if (profile == null ? void 0 : profile.sso_session) {
|
|
156
168
|
const ssoSessions = await (0, import_shared_ini_file_loader.loadSsoSessionData)(init);
|
|
157
169
|
const session = ssoSessions[profile.sso_session];
|
|
158
170
|
const conflictMsg = ` configurations in profile ${profileName} and sso-session ${profile.sso_session}`;
|
|
159
171
|
if (ssoRegion && ssoRegion !== session.sso_region) {
|
|
160
|
-
throw new import_property_provider.CredentialsProviderError(`Conflicting SSO region` + conflictMsg,
|
|
172
|
+
throw new import_property_provider.CredentialsProviderError(`Conflicting SSO region` + conflictMsg, {
|
|
173
|
+
tryNextLink: false,
|
|
174
|
+
logger: init.logger
|
|
175
|
+
});
|
|
161
176
|
}
|
|
162
177
|
if (ssoStartUrl && ssoStartUrl !== session.sso_start_url) {
|
|
163
|
-
throw new import_property_provider.CredentialsProviderError(`Conflicting SSO start_url` + conflictMsg,
|
|
178
|
+
throw new import_property_provider.CredentialsProviderError(`Conflicting SSO start_url` + conflictMsg, {
|
|
179
|
+
tryNextLink: false,
|
|
180
|
+
logger: init.logger
|
|
181
|
+
});
|
|
164
182
|
}
|
|
165
183
|
profile.sso_region = session.sso_region;
|
|
166
184
|
profile.sso_start_url = session.sso_start_url;
|
|
167
185
|
}
|
|
168
|
-
const { sso_start_url, sso_account_id, sso_region, sso_role_name, sso_session } = validateSsoProfile(
|
|
186
|
+
const { sso_start_url, sso_account_id, sso_region, sso_role_name, sso_session } = validateSsoProfile(
|
|
187
|
+
profile,
|
|
188
|
+
init.logger
|
|
189
|
+
);
|
|
169
190
|
return resolveSSOCredentials({
|
|
170
191
|
ssoStartUrl: sso_start_url,
|
|
171
192
|
ssoSession: sso_session,
|
|
@@ -178,7 +199,8 @@ var fromSSO = /* @__PURE__ */ __name((init = {}) => async () => {
|
|
|
178
199
|
});
|
|
179
200
|
} else if (!ssoStartUrl || !ssoAccountId || !ssoRegion || !ssoRoleName) {
|
|
180
201
|
throw new import_property_provider.CredentialsProviderError(
|
|
181
|
-
'Incomplete configuration. The fromSSO() argument hash must include "ssoStartUrl", "ssoAccountId", "ssoRegion", "ssoRoleName"'
|
|
202
|
+
'Incomplete configuration. The fromSSO() argument hash must include "ssoStartUrl", "ssoAccountId", "ssoRegion", "ssoRoleName"',
|
|
203
|
+
{ tryNextLink: false, logger: init.logger }
|
|
182
204
|
);
|
|
183
205
|
} else {
|
|
184
206
|
return resolveSSOCredentials({
|
package/dist-es/fromSSO.js
CHANGED
|
@@ -4,7 +4,7 @@ import { isSsoProfile } from "./isSsoProfile";
|
|
|
4
4
|
import { resolveSSOCredentials } from "./resolveSSOCredentials";
|
|
5
5
|
import { validateSsoProfile } from "./validateSsoProfile";
|
|
6
6
|
export const fromSSO = (init = {}) => async () => {
|
|
7
|
-
init.logger?.debug("@aws-sdk/credential-provider-sso
|
|
7
|
+
init.logger?.debug("@aws-sdk/credential-provider-sso - fromSSO");
|
|
8
8
|
const { ssoStartUrl, ssoAccountId, ssoRegion, ssoRoleName, ssoSession } = init;
|
|
9
9
|
const { ssoClient } = init;
|
|
10
10
|
const profileName = getProfileName(init);
|
|
@@ -12,25 +12,33 @@ export const fromSSO = (init = {}) => async () => {
|
|
|
12
12
|
const profiles = await parseKnownFiles(init);
|
|
13
13
|
const profile = profiles[profileName];
|
|
14
14
|
if (!profile) {
|
|
15
|
-
throw new CredentialsProviderError(`Profile ${profileName} was not found
|
|
15
|
+
throw new CredentialsProviderError(`Profile ${profileName} was not found.`, { logger: init.logger });
|
|
16
16
|
}
|
|
17
17
|
if (!isSsoProfile(profile)) {
|
|
18
|
-
throw new CredentialsProviderError(`Profile ${profileName} is not configured with SSO credentials
|
|
18
|
+
throw new CredentialsProviderError(`Profile ${profileName} is not configured with SSO credentials.`, {
|
|
19
|
+
logger: init.logger,
|
|
20
|
+
});
|
|
19
21
|
}
|
|
20
22
|
if (profile?.sso_session) {
|
|
21
23
|
const ssoSessions = await loadSsoSessionData(init);
|
|
22
24
|
const session = ssoSessions[profile.sso_session];
|
|
23
25
|
const conflictMsg = ` configurations in profile ${profileName} and sso-session ${profile.sso_session}`;
|
|
24
26
|
if (ssoRegion && ssoRegion !== session.sso_region) {
|
|
25
|
-
throw new CredentialsProviderError(`Conflicting SSO region` + conflictMsg,
|
|
27
|
+
throw new CredentialsProviderError(`Conflicting SSO region` + conflictMsg, {
|
|
28
|
+
tryNextLink: false,
|
|
29
|
+
logger: init.logger,
|
|
30
|
+
});
|
|
26
31
|
}
|
|
27
32
|
if (ssoStartUrl && ssoStartUrl !== session.sso_start_url) {
|
|
28
|
-
throw new CredentialsProviderError(`Conflicting SSO start_url` + conflictMsg,
|
|
33
|
+
throw new CredentialsProviderError(`Conflicting SSO start_url` + conflictMsg, {
|
|
34
|
+
tryNextLink: false,
|
|
35
|
+
logger: init.logger,
|
|
36
|
+
});
|
|
29
37
|
}
|
|
30
38
|
profile.sso_region = session.sso_region;
|
|
31
39
|
profile.sso_start_url = session.sso_start_url;
|
|
32
40
|
}
|
|
33
|
-
const { sso_start_url, sso_account_id, sso_region, sso_role_name, sso_session } = validateSsoProfile(profile);
|
|
41
|
+
const { sso_start_url, sso_account_id, sso_region, sso_role_name, sso_session } = validateSsoProfile(profile, init.logger);
|
|
34
42
|
return resolveSSOCredentials({
|
|
35
43
|
ssoStartUrl: sso_start_url,
|
|
36
44
|
ssoSession: sso_session,
|
|
@@ -44,7 +52,7 @@ export const fromSSO = (init = {}) => async () => {
|
|
|
44
52
|
}
|
|
45
53
|
else if (!ssoStartUrl || !ssoAccountId || !ssoRegion || !ssoRoleName) {
|
|
46
54
|
throw new CredentialsProviderError("Incomplete configuration. The fromSSO() argument hash must include " +
|
|
47
|
-
'"ssoStartUrl", "ssoAccountId", "ssoRegion", "ssoRoleName"');
|
|
55
|
+
'"ssoStartUrl", "ssoAccountId", "ssoRegion", "ssoRoleName"', { tryNextLink: false, logger: init.logger });
|
|
48
56
|
}
|
|
49
57
|
else {
|
|
50
58
|
return resolveSSOCredentials({
|
|
@@ -2,7 +2,7 @@ import { fromSso as getSsoTokenProvider } from "@aws-sdk/token-providers";
|
|
|
2
2
|
import { CredentialsProviderError } from "@smithy/property-provider";
|
|
3
3
|
import { getSSOTokenFromFile } from "@smithy/shared-ini-file-loader";
|
|
4
4
|
const SHOULD_FAIL_CREDENTIAL_CHAIN = false;
|
|
5
|
-
export const resolveSSOCredentials = async ({ ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, clientConfig, profile, }) => {
|
|
5
|
+
export const resolveSSOCredentials = async ({ ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, clientConfig, profile, logger, }) => {
|
|
6
6
|
let token;
|
|
7
7
|
const refreshMessage = `To refresh this SSO session run aws sso login with the corresponding profile.`;
|
|
8
8
|
if (ssoSession) {
|
|
@@ -14,7 +14,10 @@ export const resolveSSOCredentials = async ({ ssoStartUrl, ssoSession, ssoAccoun
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
catch (e) {
|
|
17
|
-
throw new CredentialsProviderError(e.message,
|
|
17
|
+
throw new CredentialsProviderError(e.message, {
|
|
18
|
+
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
19
|
+
logger,
|
|
20
|
+
});
|
|
18
21
|
}
|
|
19
22
|
}
|
|
20
23
|
else {
|
|
@@ -22,11 +25,17 @@ export const resolveSSOCredentials = async ({ ssoStartUrl, ssoSession, ssoAccoun
|
|
|
22
25
|
token = await getSSOTokenFromFile(ssoStartUrl);
|
|
23
26
|
}
|
|
24
27
|
catch (e) {
|
|
25
|
-
throw new CredentialsProviderError(`The SSO session associated with this profile is invalid. ${refreshMessage}`,
|
|
28
|
+
throw new CredentialsProviderError(`The SSO session associated with this profile is invalid. ${refreshMessage}`, {
|
|
29
|
+
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
30
|
+
logger,
|
|
31
|
+
});
|
|
26
32
|
}
|
|
27
33
|
}
|
|
28
34
|
if (new Date(token.expiresAt).getTime() - Date.now() <= 0) {
|
|
29
|
-
throw new CredentialsProviderError(`The SSO session associated with this profile has expired. ${refreshMessage}`,
|
|
35
|
+
throw new CredentialsProviderError(`The SSO session associated with this profile has expired. ${refreshMessage}`, {
|
|
36
|
+
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
37
|
+
logger,
|
|
38
|
+
});
|
|
30
39
|
}
|
|
31
40
|
const { accessToken } = token;
|
|
32
41
|
const { SSOClient, GetRoleCredentialsCommand } = await import("./loadSso");
|
|
@@ -43,11 +52,17 @@ export const resolveSSOCredentials = async ({ ssoStartUrl, ssoSession, ssoAccoun
|
|
|
43
52
|
}));
|
|
44
53
|
}
|
|
45
54
|
catch (e) {
|
|
46
|
-
throw CredentialsProviderError
|
|
55
|
+
throw new CredentialsProviderError(e, {
|
|
56
|
+
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
57
|
+
logger,
|
|
58
|
+
});
|
|
47
59
|
}
|
|
48
60
|
const { roleCredentials: { accessKeyId, secretAccessKey, sessionToken, expiration, credentialScope } = {} } = ssoResp;
|
|
49
61
|
if (!accessKeyId || !secretAccessKey || !sessionToken || !expiration) {
|
|
50
|
-
throw new CredentialsProviderError("SSO returns an invalid temporary credential.",
|
|
62
|
+
throw new CredentialsProviderError("SSO returns an invalid temporary credential.", {
|
|
63
|
+
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
64
|
+
logger,
|
|
65
|
+
});
|
|
51
66
|
}
|
|
52
67
|
return { accessKeyId, secretAccessKey, sessionToken, expiration: new Date(expiration), credentialScope };
|
|
53
68
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CredentialsProviderError } from "@smithy/property-provider";
|
|
2
|
-
export const validateSsoProfile = (profile) => {
|
|
2
|
+
export const validateSsoProfile = (profile, logger) => {
|
|
3
3
|
const { sso_start_url, sso_account_id, sso_region, sso_role_name } = profile;
|
|
4
4
|
if (!sso_start_url || !sso_account_id || !sso_region || !sso_role_name) {
|
|
5
5
|
throw new CredentialsProviderError(`Profile is configured with invalid SSO credentials. Required parameters "sso_account_id", ` +
|
|
6
|
-
`"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`, false);
|
|
6
|
+
`"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 });
|
|
7
7
|
}
|
|
8
8
|
return profile;
|
|
9
9
|
};
|
|
@@ -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, clientConfig, profile, }: FromSSOInit & SsoCredentialsParameters) => Promise<AwsCredentialIdentity>;
|
|
6
|
+
export declare const resolveSSOCredentials: ({ ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, clientConfig, profile, logger, }: FromSSOInit & SsoCredentialsParameters) => Promise<AwsCredentialIdentity>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { Logger } from "@smithy/types";
|
|
1
2
|
import { SsoProfile } from "./types";
|
|
2
3
|
/**
|
|
3
4
|
* @internal
|
|
4
5
|
*/
|
|
5
|
-
export declare const validateSsoProfile: (profile: Partial<SsoProfile
|
|
6
|
+
export declare const validateSsoProfile: (profile: Partial<SsoProfile>, logger?: Logger) => SsoProfile;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/credential-provider-sso",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.587.0",
|
|
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,11 +24,11 @@
|
|
|
24
24
|
},
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@aws-sdk/client-sso": "3.
|
|
28
|
-
"@aws-sdk/token-providers": "3.
|
|
27
|
+
"@aws-sdk/client-sso": "3.587.0",
|
|
28
|
+
"@aws-sdk/token-providers": "3.587.0",
|
|
29
29
|
"@aws-sdk/types": "3.577.0",
|
|
30
|
-
"@smithy/property-provider": "^3.
|
|
31
|
-
"@smithy/shared-ini-file-loader": "^3.
|
|
30
|
+
"@smithy/property-provider": "^3.1.0",
|
|
31
|
+
"@smithy/shared-ini-file-loader": "^3.1.0",
|
|
32
32
|
"@smithy/types": "^3.0.0",
|
|
33
33
|
"tslib": "^2.6.2"
|
|
34
34
|
},
|