@awsless/cli 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.MD +487 -0
  2. package/dist/app.json +1 -0
  3. package/dist/app.stage.json +1 -0
  4. package/dist/bin.d.ts +1 -0
  5. package/dist/bin.js +49025 -0
  6. package/dist/build-json-schema.js +1925 -0
  7. package/dist/chunk-2TBBLACH.js +37 -0
  8. package/dist/chunk-3YEPERYO.js +1021 -0
  9. package/dist/chunk-4JFIJMQ6.js +46 -0
  10. package/dist/chunk-5TWBDDXS.js +60 -0
  11. package/dist/chunk-7NRPMOO4.js +876 -0
  12. package/dist/chunk-7XIGSOF4.js +100 -0
  13. package/dist/chunk-DSXFE5X2.js +174 -0
  14. package/dist/chunk-E7FQOYML.js +12 -0
  15. package/dist/chunk-GH475CSF.js +5005 -0
  16. package/dist/chunk-JHYKYQ5P.js +163 -0
  17. package/dist/chunk-LBISIOIM.js +28 -0
  18. package/dist/chunk-RCNT4C4P.js +50 -0
  19. package/dist/chunk-SIAA4J6H.js +21 -0
  20. package/dist/chunk-XNYTWFP6.js +241 -0
  21. package/dist/chunk-Z37AK4IA.js +546 -0
  22. package/dist/chunk-ZKH7AMP3.js +42 -0
  23. package/dist/dist-es-GXHCNXAC.js +489 -0
  24. package/dist/dist-es-J7SL4PXO.js +88 -0
  25. package/dist/dist-es-LL3VAI2X.js +70 -0
  26. package/dist/dist-es-QND3CYLI.js +380 -0
  27. package/dist/dist-es-STVZUSZG.js +21 -0
  28. package/dist/dist-es-TCFHB4OF.js +324 -0
  29. package/dist/dist-es-YFQTZTNE.js +167 -0
  30. package/dist/event-streams-74K5M656.js +244 -0
  31. package/dist/layers/sharp-arm.zip +0 -0
  32. package/dist/loadSso-O7PM54HL.js +592 -0
  33. package/dist/prebuild/icon/HASH +1 -0
  34. package/dist/prebuild/icon/bundle.zip +0 -0
  35. package/dist/prebuild/image/HASH +1 -0
  36. package/dist/prebuild/image/bundle.zip +0 -0
  37. package/dist/prebuild/on-error-log/HASH +1 -0
  38. package/dist/prebuild/on-error-log/bundle.zip +0 -0
  39. package/dist/prebuild/on-failure/HASH +1 -0
  40. package/dist/prebuild/on-failure/bundle.zip +0 -0
  41. package/dist/prebuild/rpc/HASH +1 -0
  42. package/dist/prebuild/rpc/bundle.zip +0 -0
  43. package/dist/prebuild.js +159 -0
  44. package/dist/signin-6SPMGGJN.js +704 -0
  45. package/dist/sso-oidc-5IIWGKXY.js +829 -0
  46. package/dist/stack.json +1 -0
  47. package/dist/stack.stage.json +1 -0
  48. package/dist/sts-6SQWH4BL.js +3788 -0
  49. package/dist/test-global-setup.js +22 -0
  50. package/package.json +120 -0
@@ -0,0 +1,489 @@
1
+ import {
2
+ chain
3
+ } from "./chunk-LBISIOIM.js";
4
+ import {
5
+ HttpRequest
6
+ } from "./chunk-5TWBDDXS.js";
7
+ import {
8
+ getProfileName,
9
+ parseKnownFiles,
10
+ readFile
11
+ } from "./chunk-XNYTWFP6.js";
12
+ import {
13
+ setCredentialFeature
14
+ } from "./chunk-E7FQOYML.js";
15
+ import {
16
+ CredentialsProviderError
17
+ } from "./chunk-2TBBLACH.js";
18
+ import "./chunk-SIAA4J6H.js";
19
+
20
+ // ../../node_modules/.pnpm/@aws-sdk+credential-provider-ini@3.972.28_aws-crt@1.30.0/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveCredentialSource.js
21
+ var resolveCredentialSource = (credentialSource, profileName, logger) => {
22
+ const sourceProvidersMap = {
23
+ EcsContainer: async (options) => {
24
+ const { fromHttp } = await import("./dist-es-YFQTZTNE.js");
25
+ const { fromContainerMetadata } = await import("./dist-es-QND3CYLI.js");
26
+ logger?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer");
27
+ return async () => chain(fromHttp(options ?? {}), fromContainerMetadata(options))().then(setNamedProvider);
28
+ },
29
+ Ec2InstanceMetadata: async (options) => {
30
+ logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");
31
+ const { fromInstanceMetadata } = await import("./dist-es-QND3CYLI.js");
32
+ return async () => fromInstanceMetadata(options)().then(setNamedProvider);
33
+ },
34
+ Environment: async (options) => {
35
+ logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");
36
+ const { fromEnv } = await import("./dist-es-STVZUSZG.js");
37
+ return async () => fromEnv(options)().then(setNamedProvider);
38
+ }
39
+ };
40
+ if (credentialSource in sourceProvidersMap) {
41
+ return sourceProvidersMap[credentialSource];
42
+ } else {
43
+ throw new CredentialsProviderError(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, expected EcsContainer or Ec2InstanceMetadata or Environment.`, { logger });
44
+ }
45
+ };
46
+ var setNamedProvider = (creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_NAMED_PROVIDER", "p");
47
+
48
+ // ../../node_modules/.pnpm/@aws-sdk+credential-provider-ini@3.972.28_aws-crt@1.30.0/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveAssumeRoleCredentials.js
49
+ var isAssumeRoleProfile = (arg, { profile = "default", logger } = {}) => {
50
+ return Boolean(arg) && typeof arg === "object" && typeof arg.role_arn === "string" && ["undefined", "string"].indexOf(typeof arg.role_session_name) > -1 && ["undefined", "string"].indexOf(typeof arg.external_id) > -1 && ["undefined", "string"].indexOf(typeof arg.mfa_serial) > -1 && (isAssumeRoleWithSourceProfile(arg, { profile, logger }) || isCredentialSourceProfile(arg, { profile, logger }));
51
+ };
52
+ var isAssumeRoleWithSourceProfile = (arg, { profile, logger }) => {
53
+ const withSourceProfile = typeof arg.source_profile === "string" && typeof arg.credential_source === "undefined";
54
+ if (withSourceProfile) {
55
+ logger?.debug?.(` ${profile} isAssumeRoleWithSourceProfile source_profile=${arg.source_profile}`);
56
+ }
57
+ return withSourceProfile;
58
+ };
59
+ var isCredentialSourceProfile = (arg, { profile, logger }) => {
60
+ const withProviderProfile = typeof arg.credential_source === "string" && typeof arg.source_profile === "undefined";
61
+ if (withProviderProfile) {
62
+ logger?.debug?.(` ${profile} isCredentialSourceProfile credential_source=${arg.credential_source}`);
63
+ }
64
+ return withProviderProfile;
65
+ };
66
+ var resolveAssumeRoleCredentials = async (profileName, profiles, options, callerClientConfig, visitedProfiles = {}, resolveProfileData2) => {
67
+ options.logger?.debug("@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)");
68
+ const profileData = profiles[profileName];
69
+ const { source_profile, region } = profileData;
70
+ if (!options.roleAssumer) {
71
+ const { getDefaultRoleAssumer } = await import("./sts-6SQWH4BL.js");
72
+ options.roleAssumer = getDefaultRoleAssumer({
73
+ ...options.clientConfig,
74
+ credentialProviderLogger: options.logger,
75
+ parentClientConfig: {
76
+ ...callerClientConfig,
77
+ ...options?.parentClientConfig,
78
+ region: region ?? options?.parentClientConfig?.region ?? callerClientConfig?.region
79
+ }
80
+ }, options.clientPlugins);
81
+ }
82
+ if (source_profile && source_profile in visitedProfiles) {
83
+ throw new CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile ${getProfileName(options)}. Profiles visited: ` + Object.keys(visitedProfiles).join(", "), { logger: options.logger });
84
+ }
85
+ options.logger?.debug(`@aws-sdk/credential-provider-ini - finding credential resolver using ${source_profile ? `source_profile=[${source_profile}]` : `profile=[${profileName}]`}`);
86
+ const sourceCredsProvider = source_profile ? resolveProfileData2(source_profile, profiles, options, callerClientConfig, {
87
+ ...visitedProfiles,
88
+ [source_profile]: true
89
+ }, isCredentialSourceWithoutRoleArn(profiles[source_profile] ?? {})) : (await resolveCredentialSource(profileData.credential_source, profileName, options.logger)(options))();
90
+ if (isCredentialSourceWithoutRoleArn(profileData)) {
91
+ return sourceCredsProvider.then((creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
92
+ } else {
93
+ const params = {
94
+ RoleArn: profileData.role_arn,
95
+ RoleSessionName: profileData.role_session_name || `aws-sdk-js-${Date.now()}`,
96
+ ExternalId: profileData.external_id,
97
+ DurationSeconds: parseInt(profileData.duration_seconds || "3600", 10)
98
+ };
99
+ const { mfa_serial } = profileData;
100
+ if (mfa_serial) {
101
+ if (!options.mfaCodeProvider) {
102
+ throw new CredentialsProviderError(`Profile ${profileName} requires multi-factor authentication, but no MFA code callback was provided.`, { logger: options.logger, tryNextLink: false });
103
+ }
104
+ params.SerialNumber = mfa_serial;
105
+ params.TokenCode = await options.mfaCodeProvider(mfa_serial);
106
+ }
107
+ const sourceCreds = await sourceCredsProvider;
108
+ return options.roleAssumer(sourceCreds, params).then((creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
109
+ }
110
+ };
111
+ var isCredentialSourceWithoutRoleArn = (section) => {
112
+ return !section.role_arn && !!section.credential_source;
113
+ };
114
+
115
+ // ../../node_modules/.pnpm/@aws-sdk+credential-provider-login@3.972.28_aws-crt@1.30.0/node_modules/@aws-sdk/credential-provider-login/dist-es/LoginCredentialsFetcher.js
116
+ import { createHash, createPrivateKey, createPublicKey, sign } from "crypto";
117
+ import { promises as fs } from "fs";
118
+ import { homedir } from "os";
119
+ import { dirname, join } from "path";
120
+ var LoginCredentialsFetcher = class _LoginCredentialsFetcher {
121
+ profileData;
122
+ init;
123
+ callerClientConfig;
124
+ static REFRESH_THRESHOLD = 5 * 60 * 1e3;
125
+ constructor(profileData, init, callerClientConfig) {
126
+ this.profileData = profileData;
127
+ this.init = init;
128
+ this.callerClientConfig = callerClientConfig;
129
+ }
130
+ async loadCredentials() {
131
+ const token = await this.loadToken();
132
+ if (!token) {
133
+ throw new CredentialsProviderError(`Failed to load a token for session ${this.loginSession}, please re-authenticate using aws login`, { tryNextLink: false, logger: this.logger });
134
+ }
135
+ const accessToken = token.accessToken;
136
+ const now = Date.now();
137
+ const expiryTime = new Date(accessToken.expiresAt).getTime();
138
+ const timeUntilExpiry = expiryTime - now;
139
+ if (timeUntilExpiry <= _LoginCredentialsFetcher.REFRESH_THRESHOLD) {
140
+ return this.refresh(token);
141
+ }
142
+ return {
143
+ accessKeyId: accessToken.accessKeyId,
144
+ secretAccessKey: accessToken.secretAccessKey,
145
+ sessionToken: accessToken.sessionToken,
146
+ accountId: accessToken.accountId,
147
+ expiration: new Date(accessToken.expiresAt)
148
+ };
149
+ }
150
+ get logger() {
151
+ return this.init?.logger;
152
+ }
153
+ get loginSession() {
154
+ return this.profileData.login_session;
155
+ }
156
+ async refresh(token) {
157
+ const { SigninClient, CreateOAuth2TokenCommand } = await import("./signin-6SPMGGJN.js");
158
+ const { logger, userAgentAppId } = this.callerClientConfig ?? {};
159
+ const isH2 = (requestHandler2) => {
160
+ return requestHandler2?.metadata?.handlerProtocol === "h2";
161
+ };
162
+ const requestHandler = isH2(this.callerClientConfig?.requestHandler) ? void 0 : this.callerClientConfig?.requestHandler;
163
+ const region = this.profileData.region ?? await this.callerClientConfig?.region?.() ?? process.env.AWS_REGION;
164
+ const client = new SigninClient({
165
+ credentials: {
166
+ accessKeyId: "",
167
+ secretAccessKey: ""
168
+ },
169
+ region,
170
+ requestHandler,
171
+ logger,
172
+ userAgentAppId,
173
+ ...this.init?.clientConfig
174
+ });
175
+ this.createDPoPInterceptor(client.middlewareStack);
176
+ const commandInput = {
177
+ tokenInput: {
178
+ clientId: token.clientId,
179
+ refreshToken: token.refreshToken,
180
+ grantType: "refresh_token"
181
+ }
182
+ };
183
+ try {
184
+ const response = await client.send(new CreateOAuth2TokenCommand(commandInput));
185
+ const { accessKeyId, secretAccessKey, sessionToken } = response.tokenOutput?.accessToken ?? {};
186
+ const { refreshToken, expiresIn } = response.tokenOutput ?? {};
187
+ if (!accessKeyId || !secretAccessKey || !sessionToken || !refreshToken) {
188
+ throw new CredentialsProviderError("Token refresh response missing required fields", {
189
+ logger: this.logger,
190
+ tryNextLink: false
191
+ });
192
+ }
193
+ const expiresInMs = (expiresIn ?? 900) * 1e3;
194
+ const expiration = new Date(Date.now() + expiresInMs);
195
+ const updatedToken = {
196
+ ...token,
197
+ accessToken: {
198
+ ...token.accessToken,
199
+ accessKeyId,
200
+ secretAccessKey,
201
+ sessionToken,
202
+ expiresAt: expiration.toISOString()
203
+ },
204
+ refreshToken
205
+ };
206
+ await this.saveToken(updatedToken);
207
+ const newAccessToken = updatedToken.accessToken;
208
+ return {
209
+ accessKeyId: newAccessToken.accessKeyId,
210
+ secretAccessKey: newAccessToken.secretAccessKey,
211
+ sessionToken: newAccessToken.sessionToken,
212
+ accountId: newAccessToken.accountId,
213
+ expiration
214
+ };
215
+ } catch (error) {
216
+ if (error.name === "AccessDeniedException") {
217
+ const errorType = error.error;
218
+ let message;
219
+ switch (errorType) {
220
+ case "TOKEN_EXPIRED":
221
+ message = "Your session has expired. Please reauthenticate.";
222
+ break;
223
+ case "USER_CREDENTIALS_CHANGED":
224
+ message = "Unable to refresh credentials because of a change in your password. Please reauthenticate with your new password.";
225
+ break;
226
+ case "INSUFFICIENT_PERMISSIONS":
227
+ message = "Unable to refresh credentials due to insufficient permissions. You may be missing permission for the 'CreateOAuth2Token' action.";
228
+ break;
229
+ default:
230
+ message = `Failed to refresh token: ${String(error)}. Please re-authenticate using \`aws login\``;
231
+ }
232
+ throw new CredentialsProviderError(message, { logger: this.logger, tryNextLink: false });
233
+ }
234
+ throw new CredentialsProviderError(`Failed to refresh token: ${String(error)}. Please re-authenticate using aws login`, { logger: this.logger });
235
+ }
236
+ }
237
+ async loadToken() {
238
+ const tokenFilePath = this.getTokenFilePath();
239
+ try {
240
+ let tokenData;
241
+ try {
242
+ tokenData = await readFile(tokenFilePath, { ignoreCache: this.init?.ignoreCache });
243
+ } catch {
244
+ tokenData = await fs.readFile(tokenFilePath, "utf8");
245
+ }
246
+ const token = JSON.parse(tokenData);
247
+ const missingFields = ["accessToken", "clientId", "refreshToken", "dpopKey"].filter((k) => !token[k]);
248
+ if (!token.accessToken?.accountId) {
249
+ missingFields.push("accountId");
250
+ }
251
+ if (missingFields.length > 0) {
252
+ throw new CredentialsProviderError(`Token validation failed, missing fields: ${missingFields.join(", ")}`, {
253
+ logger: this.logger,
254
+ tryNextLink: false
255
+ });
256
+ }
257
+ return token;
258
+ } catch (error) {
259
+ throw new CredentialsProviderError(`Failed to load token from ${tokenFilePath}: ${String(error)}`, {
260
+ logger: this.logger,
261
+ tryNextLink: false
262
+ });
263
+ }
264
+ }
265
+ async saveToken(token) {
266
+ const tokenFilePath = this.getTokenFilePath();
267
+ const directory = dirname(tokenFilePath);
268
+ try {
269
+ await fs.mkdir(directory, { recursive: true });
270
+ } catch (error) {
271
+ }
272
+ await fs.writeFile(tokenFilePath, JSON.stringify(token, null, 2), "utf8");
273
+ }
274
+ getTokenFilePath() {
275
+ const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ?? join(homedir(), ".aws", "login", "cache");
276
+ const loginSessionBytes = Buffer.from(this.loginSession, "utf8");
277
+ const loginSessionSha256 = createHash("sha256").update(loginSessionBytes).digest("hex");
278
+ return join(directory, `${loginSessionSha256}.json`);
279
+ }
280
+ derToRawSignature(derSignature) {
281
+ let offset = 2;
282
+ if (derSignature[offset] !== 2) {
283
+ throw new Error("Invalid DER signature");
284
+ }
285
+ offset++;
286
+ const rLength = derSignature[offset++];
287
+ let r = derSignature.subarray(offset, offset + rLength);
288
+ offset += rLength;
289
+ if (derSignature[offset] !== 2) {
290
+ throw new Error("Invalid DER signature");
291
+ }
292
+ offset++;
293
+ const sLength = derSignature[offset++];
294
+ let s = derSignature.subarray(offset, offset + sLength);
295
+ r = r[0] === 0 ? r.subarray(1) : r;
296
+ s = s[0] === 0 ? s.subarray(1) : s;
297
+ const rPadded = Buffer.concat([Buffer.alloc(32 - r.length), r]);
298
+ const sPadded = Buffer.concat([Buffer.alloc(32 - s.length), s]);
299
+ return Buffer.concat([rPadded, sPadded]);
300
+ }
301
+ createDPoPInterceptor(middlewareStack) {
302
+ middlewareStack.add((next) => async (args) => {
303
+ if (HttpRequest.isInstance(args.request)) {
304
+ const request = args.request;
305
+ const actualEndpoint = `${request.protocol}//${request.hostname}${request.port ? `:${request.port}` : ""}${request.path}`;
306
+ const dpop = await this.generateDpop(request.method, actualEndpoint);
307
+ request.headers = {
308
+ ...request.headers,
309
+ DPoP: dpop
310
+ };
311
+ }
312
+ return next(args);
313
+ }, {
314
+ step: "finalizeRequest",
315
+ name: "dpopInterceptor",
316
+ override: true
317
+ });
318
+ }
319
+ async generateDpop(method = "POST", endpoint) {
320
+ const token = await this.loadToken();
321
+ try {
322
+ const privateKey = createPrivateKey({
323
+ key: token.dpopKey,
324
+ format: "pem",
325
+ type: "sec1"
326
+ });
327
+ const publicKey = createPublicKey(privateKey);
328
+ const publicDer = publicKey.export({ format: "der", type: "spki" });
329
+ let pointStart = -1;
330
+ for (let i = 0; i < publicDer.length; i++) {
331
+ if (publicDer[i] === 4) {
332
+ pointStart = i;
333
+ break;
334
+ }
335
+ }
336
+ const x = publicDer.slice(pointStart + 1, pointStart + 33);
337
+ const y = publicDer.slice(pointStart + 33, pointStart + 65);
338
+ const header = {
339
+ alg: "ES256",
340
+ typ: "dpop+jwt",
341
+ jwk: {
342
+ kty: "EC",
343
+ crv: "P-256",
344
+ x: x.toString("base64url"),
345
+ y: y.toString("base64url")
346
+ }
347
+ };
348
+ const payload = {
349
+ jti: crypto.randomUUID(),
350
+ htm: method,
351
+ htu: endpoint,
352
+ iat: Math.floor(Date.now() / 1e3)
353
+ };
354
+ const headerB64 = Buffer.from(JSON.stringify(header)).toString("base64url");
355
+ const payloadB64 = Buffer.from(JSON.stringify(payload)).toString("base64url");
356
+ const message = `${headerB64}.${payloadB64}`;
357
+ const asn1Signature = sign("sha256", Buffer.from(message), privateKey);
358
+ const rawSignature = this.derToRawSignature(asn1Signature);
359
+ const signatureB64 = rawSignature.toString("base64url");
360
+ return `${message}.${signatureB64}`;
361
+ } catch (error) {
362
+ throw new CredentialsProviderError(`Failed to generate Dpop proof: ${error instanceof Error ? error.message : String(error)}`, { logger: this.logger, tryNextLink: false });
363
+ }
364
+ }
365
+ };
366
+
367
+ // ../../node_modules/.pnpm/@aws-sdk+credential-provider-login@3.972.28_aws-crt@1.30.0/node_modules/@aws-sdk/credential-provider-login/dist-es/fromLoginCredentials.js
368
+ var fromLoginCredentials = (init) => async ({ callerClientConfig } = {}) => {
369
+ init?.logger?.debug?.("@aws-sdk/credential-providers - fromLoginCredentials");
370
+ const profiles = await parseKnownFiles(init || {});
371
+ const profileName = getProfileName({
372
+ profile: init?.profile ?? callerClientConfig?.profile
373
+ });
374
+ const profile = profiles[profileName];
375
+ if (!profile?.login_session) {
376
+ throw new CredentialsProviderError(`Profile ${profileName} does not contain login_session.`, {
377
+ tryNextLink: true,
378
+ logger: init?.logger
379
+ });
380
+ }
381
+ const fetcher = new LoginCredentialsFetcher(profile, init, callerClientConfig);
382
+ const credentials = await fetcher.loadCredentials();
383
+ return setCredentialFeature(credentials, "CREDENTIALS_LOGIN", "AD");
384
+ };
385
+
386
+ // ../../node_modules/.pnpm/@aws-sdk+credential-provider-ini@3.972.28_aws-crt@1.30.0/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveLoginCredentials.js
387
+ var isLoginProfile = (data) => {
388
+ return Boolean(data && data.login_session);
389
+ };
390
+ var resolveLoginCredentials = async (profileName, options, callerClientConfig) => {
391
+ const credentials = await fromLoginCredentials({
392
+ ...options,
393
+ profile: profileName
394
+ })({ callerClientConfig });
395
+ return setCredentialFeature(credentials, "CREDENTIALS_PROFILE_LOGIN", "AC");
396
+ };
397
+
398
+ // ../../node_modules/.pnpm/@aws-sdk+credential-provider-ini@3.972.28_aws-crt@1.30.0/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveProcessCredentials.js
399
+ var isProcessProfile = (arg) => Boolean(arg) && typeof arg === "object" && typeof arg.credential_process === "string";
400
+ var resolveProcessCredentials = async (options, profile) => import("./dist-es-J7SL4PXO.js").then(({ fromProcess }) => fromProcess({
401
+ ...options,
402
+ profile
403
+ })().then((creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_PROCESS", "v")));
404
+
405
+ // ../../node_modules/.pnpm/@aws-sdk+credential-provider-ini@3.972.28_aws-crt@1.30.0/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveSsoCredentials.js
406
+ var resolveSsoCredentials = async (profile, profileData, options = {}, callerClientConfig) => {
407
+ const { fromSSO } = await import("./dist-es-TCFHB4OF.js");
408
+ return fromSSO({
409
+ profile,
410
+ logger: options.logger,
411
+ parentClientConfig: options.parentClientConfig,
412
+ clientConfig: options.clientConfig
413
+ })({
414
+ callerClientConfig
415
+ }).then((creds) => {
416
+ if (profileData.sso_session) {
417
+ return setCredentialFeature(creds, "CREDENTIALS_PROFILE_SSO", "r");
418
+ } else {
419
+ return setCredentialFeature(creds, "CREDENTIALS_PROFILE_SSO_LEGACY", "t");
420
+ }
421
+ });
422
+ };
423
+ 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");
424
+
425
+ // ../../node_modules/.pnpm/@aws-sdk+credential-provider-ini@3.972.28_aws-crt@1.30.0/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveStaticCredentials.js
426
+ var isStaticCredsProfile = (arg) => Boolean(arg) && typeof arg === "object" && typeof arg.aws_access_key_id === "string" && typeof arg.aws_secret_access_key === "string" && ["undefined", "string"].indexOf(typeof arg.aws_session_token) > -1 && ["undefined", "string"].indexOf(typeof arg.aws_account_id) > -1;
427
+ var resolveStaticCredentials = async (profile, options) => {
428
+ options?.logger?.debug("@aws-sdk/credential-provider-ini - resolveStaticCredentials");
429
+ const credentials = {
430
+ accessKeyId: profile.aws_access_key_id,
431
+ secretAccessKey: profile.aws_secret_access_key,
432
+ sessionToken: profile.aws_session_token,
433
+ ...profile.aws_credential_scope && { credentialScope: profile.aws_credential_scope },
434
+ ...profile.aws_account_id && { accountId: profile.aws_account_id }
435
+ };
436
+ return setCredentialFeature(credentials, "CREDENTIALS_PROFILE", "n");
437
+ };
438
+
439
+ // ../../node_modules/.pnpm/@aws-sdk+credential-provider-ini@3.972.28_aws-crt@1.30.0/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveWebIdentityCredentials.js
440
+ var isWebIdentityProfile = (arg) => Boolean(arg) && typeof arg === "object" && typeof arg.web_identity_token_file === "string" && typeof arg.role_arn === "string" && ["undefined", "string"].indexOf(typeof arg.role_session_name) > -1;
441
+ var resolveWebIdentityCredentials = async (profile, options, callerClientConfig) => import("./dist-es-LL3VAI2X.js").then(({ fromTokenFile }) => fromTokenFile({
442
+ webIdentityTokenFile: profile.web_identity_token_file,
443
+ roleArn: profile.role_arn,
444
+ roleSessionName: profile.role_session_name,
445
+ roleAssumerWithWebIdentity: options.roleAssumerWithWebIdentity,
446
+ logger: options.logger,
447
+ parentClientConfig: options.parentClientConfig
448
+ })({
449
+ callerClientConfig
450
+ }).then((creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN", "q")));
451
+
452
+ // ../../node_modules/.pnpm/@aws-sdk+credential-provider-ini@3.972.28_aws-crt@1.30.0/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveProfileData.js
453
+ var resolveProfileData = async (profileName, profiles, options, callerClientConfig, visitedProfiles = {}, isAssumeRoleRecursiveCall = false) => {
454
+ const data = profiles[profileName];
455
+ if (Object.keys(visitedProfiles).length > 0 && isStaticCredsProfile(data)) {
456
+ return resolveStaticCredentials(data, options);
457
+ }
458
+ if (isAssumeRoleRecursiveCall || isAssumeRoleProfile(data, { profile: profileName, logger: options.logger })) {
459
+ return resolveAssumeRoleCredentials(profileName, profiles, options, callerClientConfig, visitedProfiles, resolveProfileData);
460
+ }
461
+ if (isStaticCredsProfile(data)) {
462
+ return resolveStaticCredentials(data, options);
463
+ }
464
+ if (isWebIdentityProfile(data)) {
465
+ return resolveWebIdentityCredentials(data, options, callerClientConfig);
466
+ }
467
+ if (isProcessProfile(data)) {
468
+ return resolveProcessCredentials(options, profileName);
469
+ }
470
+ if (isSsoProfile(data)) {
471
+ return await resolveSsoCredentials(profileName, data, options, callerClientConfig);
472
+ }
473
+ if (isLoginProfile(data)) {
474
+ return resolveLoginCredentials(profileName, options, callerClientConfig);
475
+ }
476
+ throw new CredentialsProviderError(`Could not resolve credentials using profile: [${profileName}] in configuration/credentials file(s).`, { logger: options.logger });
477
+ };
478
+
479
+ // ../../node_modules/.pnpm/@aws-sdk+credential-provider-ini@3.972.28_aws-crt@1.30.0/node_modules/@aws-sdk/credential-provider-ini/dist-es/fromIni.js
480
+ var fromIni = (init = {}) => async ({ callerClientConfig } = {}) => {
481
+ init.logger?.debug("@aws-sdk/credential-provider-ini - fromIni");
482
+ const profiles = await parseKnownFiles(init);
483
+ return resolveProfileData(getProfileName({
484
+ profile: init.profile ?? callerClientConfig?.profile
485
+ }), profiles, init, callerClientConfig);
486
+ };
487
+ export {
488
+ fromIni
489
+ };
@@ -0,0 +1,88 @@
1
+ import {
2
+ externalDataInterceptor,
3
+ getProfileName,
4
+ parseKnownFiles
5
+ } from "./chunk-XNYTWFP6.js";
6
+ import {
7
+ setCredentialFeature
8
+ } from "./chunk-E7FQOYML.js";
9
+ import {
10
+ CredentialsProviderError
11
+ } from "./chunk-2TBBLACH.js";
12
+ import "./chunk-SIAA4J6H.js";
13
+
14
+ // ../../node_modules/.pnpm/@aws-sdk+credential-provider-process@3.972.24/node_modules/@aws-sdk/credential-provider-process/dist-es/resolveProcessCredentials.js
15
+ import { exec } from "child_process";
16
+ import { promisify } from "util";
17
+
18
+ // ../../node_modules/.pnpm/@aws-sdk+credential-provider-process@3.972.24/node_modules/@aws-sdk/credential-provider-process/dist-es/getValidatedProcessCredentials.js
19
+ var getValidatedProcessCredentials = (profileName, data, profiles) => {
20
+ if (data.Version !== 1) {
21
+ throw Error(`Profile ${profileName} credential_process did not return Version 1.`);
22
+ }
23
+ if (data.AccessKeyId === void 0 || data.SecretAccessKey === void 0) {
24
+ throw Error(`Profile ${profileName} credential_process returned invalid credentials.`);
25
+ }
26
+ if (data.Expiration) {
27
+ const currentTime = /* @__PURE__ */ new Date();
28
+ const expireTime = new Date(data.Expiration);
29
+ if (expireTime < currentTime) {
30
+ throw Error(`Profile ${profileName} credential_process returned expired credentials.`);
31
+ }
32
+ }
33
+ let accountId = data.AccountId;
34
+ if (!accountId && profiles?.[profileName]?.aws_account_id) {
35
+ accountId = profiles[profileName].aws_account_id;
36
+ }
37
+ const credentials = {
38
+ accessKeyId: data.AccessKeyId,
39
+ secretAccessKey: data.SecretAccessKey,
40
+ ...data.SessionToken && { sessionToken: data.SessionToken },
41
+ ...data.Expiration && { expiration: new Date(data.Expiration) },
42
+ ...data.CredentialScope && { credentialScope: data.CredentialScope },
43
+ ...accountId && { accountId }
44
+ };
45
+ setCredentialFeature(credentials, "CREDENTIALS_PROCESS", "w");
46
+ return credentials;
47
+ };
48
+
49
+ // ../../node_modules/.pnpm/@aws-sdk+credential-provider-process@3.972.24/node_modules/@aws-sdk/credential-provider-process/dist-es/resolveProcessCredentials.js
50
+ var resolveProcessCredentials = async (profileName, profiles, logger) => {
51
+ const profile = profiles[profileName];
52
+ if (profiles[profileName]) {
53
+ const credentialProcess = profile["credential_process"];
54
+ if (credentialProcess !== void 0) {
55
+ const execPromise = promisify(externalDataInterceptor?.getTokenRecord?.().exec ?? exec);
56
+ try {
57
+ const { stdout } = await execPromise(credentialProcess);
58
+ let data;
59
+ try {
60
+ data = JSON.parse(stdout.trim());
61
+ } catch {
62
+ throw Error(`Profile ${profileName} credential_process returned invalid JSON.`);
63
+ }
64
+ return getValidatedProcessCredentials(profileName, data, profiles);
65
+ } catch (error) {
66
+ throw new CredentialsProviderError(error.message, { logger });
67
+ }
68
+ } else {
69
+ throw new CredentialsProviderError(`Profile ${profileName} did not contain credential_process.`, { logger });
70
+ }
71
+ } else {
72
+ throw new CredentialsProviderError(`Profile ${profileName} could not be found in shared credentials file.`, {
73
+ logger
74
+ });
75
+ }
76
+ };
77
+
78
+ // ../../node_modules/.pnpm/@aws-sdk+credential-provider-process@3.972.24/node_modules/@aws-sdk/credential-provider-process/dist-es/fromProcess.js
79
+ var fromProcess = (init = {}) => async ({ callerClientConfig } = {}) => {
80
+ init.logger?.debug("@aws-sdk/credential-provider-process - fromProcess");
81
+ const profiles = await parseKnownFiles(init);
82
+ return resolveProcessCredentials(getProfileName({
83
+ profile: init.profile ?? callerClientConfig?.profile
84
+ }), profiles, init.logger);
85
+ };
86
+ export {
87
+ fromProcess
88
+ };
@@ -0,0 +1,70 @@
1
+ import {
2
+ externalDataInterceptor
3
+ } from "./chunk-XNYTWFP6.js";
4
+ import {
5
+ setCredentialFeature
6
+ } from "./chunk-E7FQOYML.js";
7
+ import {
8
+ CredentialsProviderError
9
+ } from "./chunk-2TBBLACH.js";
10
+ import "./chunk-SIAA4J6H.js";
11
+
12
+ // ../../node_modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.972.28_aws-crt@1.30.0/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.28_aws-crt@1.30.0/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-6SQWH4BL.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.28_aws-crt@1.30.0/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
+ };