@ampless/mcp-server 1.0.0-alpha.17 → 1.0.0-alpha.19

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.
@@ -1,165 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- NodeHttpHandler
4
- } from "./chunk-SPCUAJQT.js";
5
- import {
6
- setCredentialFeature
7
- } from "./chunk-OBZN5IWW.js";
8
- import {
9
- CredentialsProviderError,
10
- HttpRequest
11
- } from "./chunk-FM7TW5TD.js";
12
- import {
13
- parseRfc3339DateTime,
14
- sdkStreamMixin
15
- } from "./chunk-IKXKDSVH.js";
16
- import "./chunk-LMMQX4CK.js";
17
-
18
- // ../../node_modules/.pnpm/@aws-sdk+credential-provider-http@3.972.41/node_modules/@aws-sdk/credential-provider-http/dist-es/fromHttp/fromHttp.js
19
- import fs from "fs/promises";
20
-
21
- // ../../node_modules/.pnpm/@aws-sdk+credential-provider-http@3.972.41/node_modules/@aws-sdk/credential-provider-http/dist-es/fromHttp/checkUrl.js
22
- var ECS_CONTAINER_HOST = "169.254.170.2";
23
- var EKS_CONTAINER_HOST_IPv4 = "169.254.170.23";
24
- var EKS_CONTAINER_HOST_IPv6 = "[fd00:ec2::23]";
25
- var checkUrl = (url, logger) => {
26
- if (url.protocol === "https:") {
27
- return;
28
- }
29
- if (url.hostname === ECS_CONTAINER_HOST || url.hostname === EKS_CONTAINER_HOST_IPv4 || url.hostname === EKS_CONTAINER_HOST_IPv6) {
30
- return;
31
- }
32
- if (url.hostname.includes("[")) {
33
- if (url.hostname === "[::1]" || url.hostname === "[0000:0000:0000:0000:0000:0000:0000:0001]") {
34
- return;
35
- }
36
- } else {
37
- if (url.hostname === "localhost") {
38
- return;
39
- }
40
- const ipComponents = url.hostname.split(".");
41
- const inRange = (component) => {
42
- const num = parseInt(component, 10);
43
- return 0 <= num && num <= 255;
44
- };
45
- if (ipComponents[0] === "127" && inRange(ipComponents[1]) && inRange(ipComponents[2]) && inRange(ipComponents[3]) && ipComponents.length === 4) {
46
- return;
47
- }
48
- }
49
- throw new CredentialsProviderError(`URL not accepted. It must either be HTTPS or match one of the following:
50
- - loopback CIDR 127.0.0.0/8 or [::1/128]
51
- - ECS container host 169.254.170.2
52
- - EKS container host 169.254.170.23 or [fd00:ec2::23]`, { logger });
53
- };
54
-
55
- // ../../node_modules/.pnpm/@aws-sdk+credential-provider-http@3.972.41/node_modules/@aws-sdk/credential-provider-http/dist-es/fromHttp/requestHelpers.js
56
- function createGetRequest(url) {
57
- return new HttpRequest({
58
- protocol: url.protocol,
59
- hostname: url.hostname,
60
- port: Number(url.port),
61
- path: url.pathname,
62
- query: Array.from(url.searchParams.entries()).reduce((acc, [k, v]) => {
63
- acc[k] = v;
64
- return acc;
65
- }, {}),
66
- fragment: url.hash
67
- });
68
- }
69
- async function getCredentials(response, logger) {
70
- const stream = sdkStreamMixin(response.body);
71
- const str = await stream.transformToString();
72
- if (response.statusCode === 200) {
73
- const parsed = JSON.parse(str);
74
- if (typeof parsed.AccessKeyId !== "string" || typeof parsed.SecretAccessKey !== "string" || typeof parsed.Token !== "string" || typeof parsed.Expiration !== "string") {
75
- throw new CredentialsProviderError("HTTP credential provider response not of the required format, an object matching: { AccessKeyId: string, SecretAccessKey: string, Token: string, Expiration: string(rfc3339) }", { logger });
76
- }
77
- return {
78
- accessKeyId: parsed.AccessKeyId,
79
- secretAccessKey: parsed.SecretAccessKey,
80
- sessionToken: parsed.Token,
81
- expiration: parseRfc3339DateTime(parsed.Expiration)
82
- };
83
- }
84
- if (response.statusCode >= 400 && response.statusCode < 500) {
85
- let parsedBody = {};
86
- try {
87
- parsedBody = JSON.parse(str);
88
- } catch (e) {
89
- }
90
- throw Object.assign(new CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger }), {
91
- Code: parsedBody.Code,
92
- Message: parsedBody.Message
93
- });
94
- }
95
- throw new CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger });
96
- }
97
-
98
- // ../../node_modules/.pnpm/@aws-sdk+credential-provider-http@3.972.41/node_modules/@aws-sdk/credential-provider-http/dist-es/fromHttp/retry-wrapper.js
99
- var retryWrapper = (toRetry, maxRetries, delayMs) => {
100
- return async () => {
101
- for (let i = 0; i < maxRetries; ++i) {
102
- try {
103
- return await toRetry();
104
- } catch (e) {
105
- await new Promise((resolve) => setTimeout(resolve, delayMs));
106
- }
107
- }
108
- return await toRetry();
109
- };
110
- };
111
-
112
- // ../../node_modules/.pnpm/@aws-sdk+credential-provider-http@3.972.41/node_modules/@aws-sdk/credential-provider-http/dist-es/fromHttp/fromHttp.js
113
- var AWS_CONTAINER_CREDENTIALS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI";
114
- var DEFAULT_LINK_LOCAL_HOST = "http://169.254.170.2";
115
- var AWS_CONTAINER_CREDENTIALS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI";
116
- var AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE = "AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE";
117
- var AWS_CONTAINER_AUTHORIZATION_TOKEN = "AWS_CONTAINER_AUTHORIZATION_TOKEN";
118
- var fromHttp = (options = {}) => {
119
- options.logger?.debug("@aws-sdk/credential-provider-http - fromHttp");
120
- let host;
121
- const relative = options.awsContainerCredentialsRelativeUri ?? process.env[AWS_CONTAINER_CREDENTIALS_RELATIVE_URI];
122
- const full = options.awsContainerCredentialsFullUri ?? process.env[AWS_CONTAINER_CREDENTIALS_FULL_URI];
123
- const token = options.awsContainerAuthorizationToken ?? process.env[AWS_CONTAINER_AUTHORIZATION_TOKEN];
124
- const tokenFile = options.awsContainerAuthorizationTokenFile ?? process.env[AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE];
125
- const warn = options.logger?.constructor?.name === "NoOpLogger" || !options.logger?.warn ? console.warn : options.logger.warn.bind(options.logger);
126
- if (relative && full) {
127
- warn("@aws-sdk/credential-provider-http: you have set both awsContainerCredentialsRelativeUri and awsContainerCredentialsFullUri.");
128
- warn("awsContainerCredentialsFullUri will take precedence.");
129
- }
130
- if (token && tokenFile) {
131
- warn("@aws-sdk/credential-provider-http: you have set both awsContainerAuthorizationToken and awsContainerAuthorizationTokenFile.");
132
- warn("awsContainerAuthorizationToken will take precedence.");
133
- }
134
- if (full) {
135
- host = full;
136
- } else if (relative) {
137
- host = `${DEFAULT_LINK_LOCAL_HOST}${relative}`;
138
- } else {
139
- throw new CredentialsProviderError(`No HTTP credential provider host provided.
140
- Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.`, { logger: options.logger });
141
- }
142
- const url = new URL(host);
143
- checkUrl(url, options.logger);
144
- const requestHandler = NodeHttpHandler.create({
145
- requestTimeout: options.timeout ?? 1e3,
146
- connectionTimeout: options.timeout ?? 1e3
147
- });
148
- return retryWrapper(async () => {
149
- const request = createGetRequest(url);
150
- if (token) {
151
- request.headers.Authorization = token;
152
- } else if (tokenFile) {
153
- request.headers.Authorization = (await fs.readFile(tokenFile)).toString();
154
- }
155
- try {
156
- const result = await requestHandler.handle(request);
157
- return getCredentials(result.response).then((creds) => setCredentialFeature(creds, "CREDENTIALS_HTTP", "z"));
158
- } catch (e) {
159
- throw new CredentialsProviderError(String(e), { logger: options.logger });
160
- }
161
- }, options.maxRetries ?? 3, options.timeout ?? 1e3);
162
- };
163
- export {
164
- fromHttp
165
- };
@@ -1,70 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- setCredentialFeature
4
- } from "./chunk-OBZN5IWW.js";
5
- import {
6
- CredentialsProviderError,
7
- externalDataInterceptor
8
- } from "./chunk-FM7TW5TD.js";
9
- import "./chunk-IKXKDSVH.js";
10
- import "./chunk-LMMQX4CK.js";
11
-
12
- // ../../node_modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.972.43/node_modules/@aws-sdk/credential-provider-web-identity/dist-es/fromTokenFile.js
13
- import { readFileSync } from "fs";
14
-
15
- // ../../node_modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.972.43/node_modules/@aws-sdk/credential-provider-web-identity/dist-es/fromWebToken.js
16
- var fromWebToken = (init) => async (awsIdentityProperties) => {
17
- init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromWebToken");
18
- const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy, durationSeconds } = init;
19
- let { roleAssumerWithWebIdentity } = init;
20
- if (!roleAssumerWithWebIdentity) {
21
- const { getDefaultRoleAssumerWithWebIdentity } = await import("./sts-3BBU2O3O.js");
22
- roleAssumerWithWebIdentity = getDefaultRoleAssumerWithWebIdentity({
23
- ...init.clientConfig,
24
- credentialProviderLogger: init.logger,
25
- parentClientConfig: {
26
- ...awsIdentityProperties?.callerClientConfig,
27
- ...init.parentClientConfig
28
- }
29
- }, init.clientPlugins);
30
- }
31
- return roleAssumerWithWebIdentity({
32
- RoleArn: roleArn,
33
- RoleSessionName: roleSessionName ?? `aws-sdk-js-session-${Date.now()}`,
34
- WebIdentityToken: webIdentityToken,
35
- ProviderId: providerId,
36
- PolicyArns: policyArns,
37
- Policy: policy,
38
- DurationSeconds: durationSeconds
39
- });
40
- };
41
-
42
- // ../../node_modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.972.43/node_modules/@aws-sdk/credential-provider-web-identity/dist-es/fromTokenFile.js
43
- var ENV_TOKEN_FILE = "AWS_WEB_IDENTITY_TOKEN_FILE";
44
- var ENV_ROLE_ARN = "AWS_ROLE_ARN";
45
- var ENV_ROLE_SESSION_NAME = "AWS_ROLE_SESSION_NAME";
46
- var fromTokenFile = (init = {}) => async (awsIdentityProperties) => {
47
- init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromTokenFile");
48
- const webIdentityTokenFile = init?.webIdentityTokenFile ?? process.env[ENV_TOKEN_FILE];
49
- const roleArn = init?.roleArn ?? process.env[ENV_ROLE_ARN];
50
- const roleSessionName = init?.roleSessionName ?? process.env[ENV_ROLE_SESSION_NAME];
51
- if (!webIdentityTokenFile || !roleArn) {
52
- throw new CredentialsProviderError("Web identity configuration not specified", {
53
- logger: init.logger
54
- });
55
- }
56
- const credentials = await fromWebToken({
57
- ...init,
58
- webIdentityToken: externalDataInterceptor?.getTokenRecord?.()[webIdentityTokenFile] ?? readFileSync(webIdentityTokenFile, { encoding: "ascii" }),
59
- roleArn,
60
- roleSessionName
61
- })(awsIdentityProperties);
62
- if (webIdentityTokenFile === process.env[ENV_TOKEN_FILE]) {
63
- setCredentialFeature(credentials, "CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN", "h");
64
- }
65
- return credentials;
66
- };
67
- export {
68
- fromTokenFile,
69
- fromWebToken
70
- };
@@ -1,315 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- setCredentialFeature
4
- } from "./chunk-OBZN5IWW.js";
5
- import {
6
- CredentialsProviderError,
7
- TokenProviderError,
8
- getProfileName,
9
- getSSOTokenFilepath,
10
- getSSOTokenFromFile,
11
- loadSsoSessionData,
12
- parseKnownFiles
13
- } from "./chunk-FM7TW5TD.js";
14
- import "./chunk-IKXKDSVH.js";
15
- import "./chunk-LMMQX4CK.js";
16
-
17
- // ../../node_modules/.pnpm/@aws-sdk+credential-provider-sso@3.972.43/node_modules/@aws-sdk/credential-provider-sso/dist-es/isSsoProfile.js
18
- var isSsoProfile = (arg) => arg && (typeof arg.sso_start_url === "string" || typeof arg.sso_account_id === "string" || typeof arg.sso_session === "string" || typeof arg.sso_region === "string" || typeof arg.sso_role_name === "string");
19
-
20
- // ../../node_modules/.pnpm/@aws-sdk+token-providers@3.1052.0/node_modules/@aws-sdk/token-providers/dist-es/constants.js
21
- var EXPIRE_WINDOW_MS = 5 * 60 * 1e3;
22
- var REFRESH_MESSAGE = `To refresh this SSO session run 'aws sso login' with the corresponding profile.`;
23
-
24
- // ../../node_modules/.pnpm/@aws-sdk+token-providers@3.1052.0/node_modules/@aws-sdk/token-providers/dist-es/getSsoOidcClient.js
25
- var getSsoOidcClient = async (ssoRegion, init = {}, callerClientConfig) => {
26
- const { SSOOIDCClient } = await import("./sso-oidc-UXLRODTA.js");
27
- const coalesce = (prop) => init.clientConfig?.[prop] ?? init.parentClientConfig?.[prop] ?? callerClientConfig?.[prop];
28
- const ssoOidcClient = new SSOOIDCClient(Object.assign({}, init.clientConfig ?? {}, {
29
- region: ssoRegion ?? init.clientConfig?.region,
30
- logger: coalesce("logger"),
31
- userAgentAppId: coalesce("userAgentAppId")
32
- }));
33
- return ssoOidcClient;
34
- };
35
-
36
- // ../../node_modules/.pnpm/@aws-sdk+token-providers@3.1052.0/node_modules/@aws-sdk/token-providers/dist-es/getNewSsoOidcToken.js
37
- var getNewSsoOidcToken = async (ssoToken, ssoRegion, init = {}, callerClientConfig) => {
38
- const { CreateTokenCommand } = await import("./sso-oidc-UXLRODTA.js");
39
- const ssoOidcClient = await getSsoOidcClient(ssoRegion, init, callerClientConfig);
40
- return ssoOidcClient.send(new CreateTokenCommand({
41
- clientId: ssoToken.clientId,
42
- clientSecret: ssoToken.clientSecret,
43
- refreshToken: ssoToken.refreshToken,
44
- grantType: "refresh_token"
45
- }));
46
- };
47
-
48
- // ../../node_modules/.pnpm/@aws-sdk+token-providers@3.1052.0/node_modules/@aws-sdk/token-providers/dist-es/validateTokenExpiry.js
49
- var validateTokenExpiry = (token) => {
50
- if (token.expiration && token.expiration.getTime() < Date.now()) {
51
- throw new TokenProviderError(`Token is expired. ${REFRESH_MESSAGE}`, false);
52
- }
53
- };
54
-
55
- // ../../node_modules/.pnpm/@aws-sdk+token-providers@3.1052.0/node_modules/@aws-sdk/token-providers/dist-es/validateTokenKey.js
56
- var validateTokenKey = (key, value, forRefresh = false) => {
57
- if (typeof value === "undefined") {
58
- throw new TokenProviderError(`Value not present for '${key}' in SSO Token${forRefresh ? ". Cannot refresh" : ""}. ${REFRESH_MESSAGE}`, false);
59
- }
60
- };
61
-
62
- // ../../node_modules/.pnpm/@aws-sdk+token-providers@3.1052.0/node_modules/@aws-sdk/token-providers/dist-es/writeSSOTokenToFile.js
63
- import { promises as fsPromises } from "fs";
64
- var { writeFile } = fsPromises;
65
- var writeSSOTokenToFile = (id, ssoToken) => {
66
- const tokenFilepath = getSSOTokenFilepath(id);
67
- const tokenString = JSON.stringify(ssoToken, null, 2);
68
- return writeFile(tokenFilepath, tokenString);
69
- };
70
-
71
- // ../../node_modules/.pnpm/@aws-sdk+token-providers@3.1052.0/node_modules/@aws-sdk/token-providers/dist-es/fromSso.js
72
- var lastRefreshAttemptTime = /* @__PURE__ */ new Date(0);
73
- var fromSso = (init = {}) => async ({ callerClientConfig } = {}) => {
74
- init.logger?.debug("@aws-sdk/token-providers - fromSso");
75
- const profiles = await parseKnownFiles(init);
76
- const profileName = getProfileName({
77
- profile: init.profile ?? callerClientConfig?.profile
78
- });
79
- const profile = profiles[profileName];
80
- if (!profile) {
81
- throw new TokenProviderError(`Profile '${profileName}' could not be found in shared credentials file.`, false);
82
- } else if (!profile["sso_session"]) {
83
- throw new TokenProviderError(`Profile '${profileName}' is missing required property 'sso_session'.`);
84
- }
85
- const ssoSessionName = profile["sso_session"];
86
- const ssoSessions = await loadSsoSessionData(init);
87
- const ssoSession = ssoSessions[ssoSessionName];
88
- if (!ssoSession) {
89
- throw new TokenProviderError(`Sso session '${ssoSessionName}' could not be found in shared credentials file.`, false);
90
- }
91
- for (const ssoSessionRequiredKey of ["sso_start_url", "sso_region"]) {
92
- if (!ssoSession[ssoSessionRequiredKey]) {
93
- throw new TokenProviderError(`Sso session '${ssoSessionName}' is missing required property '${ssoSessionRequiredKey}'.`, false);
94
- }
95
- }
96
- const ssoStartUrl = ssoSession["sso_start_url"];
97
- const ssoRegion = ssoSession["sso_region"];
98
- let ssoToken;
99
- try {
100
- ssoToken = await getSSOTokenFromFile(ssoSessionName);
101
- } catch (e) {
102
- throw new TokenProviderError(`The SSO session token associated with profile=${profileName} was not found or is invalid. ${REFRESH_MESSAGE}`, false);
103
- }
104
- validateTokenKey("accessToken", ssoToken.accessToken);
105
- validateTokenKey("expiresAt", ssoToken.expiresAt);
106
- const { accessToken, expiresAt } = ssoToken;
107
- const existingToken = { token: accessToken, expiration: new Date(expiresAt) };
108
- if (existingToken.expiration.getTime() - Date.now() > EXPIRE_WINDOW_MS) {
109
- return existingToken;
110
- }
111
- if (Date.now() - lastRefreshAttemptTime.getTime() < 30 * 1e3) {
112
- validateTokenExpiry(existingToken);
113
- return existingToken;
114
- }
115
- validateTokenKey("clientId", ssoToken.clientId, true);
116
- validateTokenKey("clientSecret", ssoToken.clientSecret, true);
117
- validateTokenKey("refreshToken", ssoToken.refreshToken, true);
118
- try {
119
- lastRefreshAttemptTime.setTime(Date.now());
120
- const newSsoOidcToken = await getNewSsoOidcToken(ssoToken, ssoRegion, init, callerClientConfig);
121
- validateTokenKey("accessToken", newSsoOidcToken.accessToken);
122
- validateTokenKey("expiresIn", newSsoOidcToken.expiresIn);
123
- const newTokenExpiration = new Date(Date.now() + newSsoOidcToken.expiresIn * 1e3);
124
- try {
125
- await writeSSOTokenToFile(ssoSessionName, {
126
- ...ssoToken,
127
- accessToken: newSsoOidcToken.accessToken,
128
- expiresAt: newTokenExpiration.toISOString(),
129
- refreshToken: newSsoOidcToken.refreshToken
130
- });
131
- } catch (error) {
132
- }
133
- return {
134
- token: newSsoOidcToken.accessToken,
135
- expiration: newTokenExpiration
136
- };
137
- } catch (error) {
138
- validateTokenExpiry(existingToken);
139
- return existingToken;
140
- }
141
- };
142
-
143
- // ../../node_modules/.pnpm/@aws-sdk+credential-provider-sso@3.972.43/node_modules/@aws-sdk/credential-provider-sso/dist-es/resolveSSOCredentials.js
144
- var SHOULD_FAIL_CREDENTIAL_CHAIN = false;
145
- var resolveSSOCredentials = async ({ ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, clientConfig, parentClientConfig, callerClientConfig, profile, filepath, configFilepath, ignoreCache, logger }) => {
146
- let token;
147
- const refreshMessage = `To refresh this SSO session run aws sso login with the corresponding profile.`;
148
- if (ssoSession) {
149
- try {
150
- const _token = await fromSso({
151
- profile,
152
- filepath,
153
- configFilepath,
154
- ignoreCache
155
- })();
156
- token = {
157
- accessToken: _token.token,
158
- expiresAt: new Date(_token.expiration).toISOString()
159
- };
160
- } catch (e) {
161
- throw new CredentialsProviderError(e.message, {
162
- tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
163
- logger
164
- });
165
- }
166
- } else {
167
- try {
168
- token = await getSSOTokenFromFile(ssoStartUrl);
169
- } catch (e) {
170
- throw new CredentialsProviderError(`The SSO session associated with this profile is invalid. ${refreshMessage}`, {
171
- tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
172
- logger
173
- });
174
- }
175
- }
176
- if (new Date(token.expiresAt).getTime() - Date.now() <= 0) {
177
- throw new CredentialsProviderError(`The SSO session associated with this profile has expired. ${refreshMessage}`, {
178
- tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
179
- logger
180
- });
181
- }
182
- const { accessToken } = token;
183
- const { SSOClient, GetRoleCredentialsCommand } = await import("./loadSso-B4NUZPX5.js");
184
- const sso = ssoClient || new SSOClient(Object.assign({}, clientConfig ?? {}, {
185
- logger: clientConfig?.logger ?? callerClientConfig?.logger ?? parentClientConfig?.logger,
186
- region: clientConfig?.region ?? ssoRegion,
187
- userAgentAppId: clientConfig?.userAgentAppId ?? callerClientConfig?.userAgentAppId ?? parentClientConfig?.userAgentAppId
188
- }));
189
- let ssoResp;
190
- try {
191
- ssoResp = await sso.send(new GetRoleCredentialsCommand({
192
- accountId: ssoAccountId,
193
- roleName: ssoRoleName,
194
- accessToken
195
- }));
196
- } catch (e) {
197
- throw new CredentialsProviderError(e, {
198
- tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
199
- logger
200
- });
201
- }
202
- const { roleCredentials: { accessKeyId, secretAccessKey, sessionToken, expiration, credentialScope, accountId } = {} } = ssoResp;
203
- if (!accessKeyId || !secretAccessKey || !sessionToken || !expiration) {
204
- throw new CredentialsProviderError("SSO returns an invalid temporary credential.", {
205
- tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
206
- logger
207
- });
208
- }
209
- const credentials = {
210
- accessKeyId,
211
- secretAccessKey,
212
- sessionToken,
213
- expiration: new Date(expiration),
214
- ...credentialScope && { credentialScope },
215
- ...accountId && { accountId }
216
- };
217
- if (ssoSession) {
218
- setCredentialFeature(credentials, "CREDENTIALS_SSO", "s");
219
- } else {
220
- setCredentialFeature(credentials, "CREDENTIALS_SSO_LEGACY", "u");
221
- }
222
- return credentials;
223
- };
224
-
225
- // ../../node_modules/.pnpm/@aws-sdk+credential-provider-sso@3.972.43/node_modules/@aws-sdk/credential-provider-sso/dist-es/validateSsoProfile.js
226
- var validateSsoProfile = (profile, logger) => {
227
- const { sso_start_url, sso_account_id, sso_region, sso_role_name } = profile;
228
- if (!sso_start_url || !sso_account_id || !sso_region || !sso_role_name) {
229
- throw new CredentialsProviderError(`Profile is configured with invalid SSO credentials. Required parameters "sso_account_id", "sso_region", "sso_role_name", "sso_start_url". Got ${Object.keys(profile).join(", ")}
230
- Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html`, { tryNextLink: false, logger });
231
- }
232
- return profile;
233
- };
234
-
235
- // ../../node_modules/.pnpm/@aws-sdk+credential-provider-sso@3.972.43/node_modules/@aws-sdk/credential-provider-sso/dist-es/fromSSO.js
236
- var fromSSO = (init = {}) => async ({ callerClientConfig } = {}) => {
237
- init.logger?.debug("@aws-sdk/credential-provider-sso - fromSSO");
238
- const { ssoStartUrl, ssoAccountId, ssoRegion, ssoRoleName, ssoSession } = init;
239
- const { ssoClient } = init;
240
- const profileName = getProfileName({
241
- profile: init.profile ?? callerClientConfig?.profile
242
- });
243
- if (!ssoStartUrl && !ssoAccountId && !ssoRegion && !ssoRoleName && !ssoSession) {
244
- const profiles = await parseKnownFiles(init);
245
- const profile = profiles[profileName];
246
- if (!profile) {
247
- throw new CredentialsProviderError(`Profile ${profileName} was not found.`, { logger: init.logger });
248
- }
249
- if (!isSsoProfile(profile)) {
250
- throw new CredentialsProviderError(`Profile ${profileName} is not configured with SSO credentials.`, {
251
- logger: init.logger
252
- });
253
- }
254
- if (profile?.sso_session) {
255
- const ssoSessions = await loadSsoSessionData(init);
256
- const session = ssoSessions[profile.sso_session];
257
- const conflictMsg = ` configurations in profile ${profileName} and sso-session ${profile.sso_session}`;
258
- if (ssoRegion && ssoRegion !== session.sso_region) {
259
- throw new CredentialsProviderError(`Conflicting SSO region` + conflictMsg, {
260
- tryNextLink: false,
261
- logger: init.logger
262
- });
263
- }
264
- if (ssoStartUrl && ssoStartUrl !== session.sso_start_url) {
265
- throw new CredentialsProviderError(`Conflicting SSO start_url` + conflictMsg, {
266
- tryNextLink: false,
267
- logger: init.logger
268
- });
269
- }
270
- profile.sso_region = session.sso_region;
271
- profile.sso_start_url = session.sso_start_url;
272
- }
273
- const { sso_start_url, sso_account_id, sso_region, sso_role_name, sso_session } = validateSsoProfile(profile, init.logger);
274
- return resolveSSOCredentials({
275
- ssoStartUrl: sso_start_url,
276
- ssoSession: sso_session,
277
- ssoAccountId: sso_account_id,
278
- ssoRegion: sso_region,
279
- ssoRoleName: sso_role_name,
280
- ssoClient,
281
- clientConfig: init.clientConfig,
282
- parentClientConfig: init.parentClientConfig,
283
- callerClientConfig: init.callerClientConfig,
284
- profile: profileName,
285
- filepath: init.filepath,
286
- configFilepath: init.configFilepath,
287
- ignoreCache: init.ignoreCache,
288
- logger: init.logger
289
- });
290
- } else if (!ssoStartUrl || !ssoAccountId || !ssoRegion || !ssoRoleName) {
291
- throw new CredentialsProviderError('Incomplete configuration. The fromSSO() argument hash must include "ssoStartUrl", "ssoAccountId", "ssoRegion", "ssoRoleName"', { tryNextLink: false, logger: init.logger });
292
- } else {
293
- return resolveSSOCredentials({
294
- ssoStartUrl,
295
- ssoSession,
296
- ssoAccountId,
297
- ssoRegion,
298
- ssoRoleName,
299
- ssoClient,
300
- clientConfig: init.clientConfig,
301
- parentClientConfig: init.parentClientConfig,
302
- callerClientConfig: init.callerClientConfig,
303
- profile: profileName,
304
- filepath: init.filepath,
305
- configFilepath: init.configFilepath,
306
- ignoreCache: init.ignoreCache,
307
- logger: init.logger
308
- });
309
- }
310
- };
311
- export {
312
- fromSSO,
313
- isSsoProfile,
314
- validateSsoProfile
315
- };