@granite-js/pulumi-aws 0.1.34 → 1.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 (82) hide show
  1. package/CHANGELOG.md +4 -116
  2. package/dist/chunk-23MVQUOJ.js +1630 -0
  3. package/dist/chunk-24XYHOWM.js +171 -0
  4. package/dist/chunk-3AVBP57V.js +1598 -0
  5. package/dist/chunk-3JKQPIJ2.js +460 -0
  6. package/dist/{chunk-ITI6QA2Q.js → chunk-3OYGHA4S.js} +1 -1
  7. package/dist/{chunk-IEZY5C3G.js → chunk-46DIC54Q.js} +49 -37
  8. package/dist/chunk-57WYIP4I.js +808 -0
  9. package/dist/{chunk-WCHHWTND.js → chunk-63Q3RLAK.js} +93 -59
  10. package/dist/chunk-6KRYZP6R.js +28 -0
  11. package/dist/{chunk-QAE2S7MG.js → chunk-7NN7DVGK.js} +2050 -552
  12. package/dist/{chunk-5W7B34BN.js → chunk-ASGFIK4A.js} +2231 -464
  13. package/dist/chunk-BTBQTDRJ.js +174 -0
  14. package/dist/chunk-DDZTWBHZ.js +154 -0
  15. package/dist/chunk-G3FWLTNJ.js +10 -0
  16. package/dist/{chunk-TJ744C2T.js → chunk-GJFKL6XM.js} +43 -38
  17. package/dist/chunk-H4QJ5O4E.js +36 -0
  18. package/dist/{chunk-X6XO7USX.js → chunk-LCO5F3JB.js} +109 -56
  19. package/dist/chunk-NDDYFDCU.js +60 -0
  20. package/dist/chunk-OCHPLE5N.js +28 -0
  21. package/dist/chunk-OSJA4YYQ.js +846 -0
  22. package/dist/chunk-PIT3K3NC.js +464 -0
  23. package/dist/chunk-QCKAO4UT.js +476 -0
  24. package/dist/{chunk-64IS37V6.js → chunk-RYIGWCGK.js} +1 -6
  25. package/dist/chunk-S4LJWEXU.js +37 -0
  26. package/dist/chunk-SJ26Y3GW.js +472 -0
  27. package/dist/chunk-TDZTH7TL.js +60 -0
  28. package/dist/chunk-THUA35UY.js +35 -0
  29. package/dist/{chunk-IUKLHJNE.js → chunk-V7TRGEV6.js} +4 -7
  30. package/dist/{chunk-KGNTV362.js → chunk-WDFKVCPC.js} +66 -34
  31. package/dist/{chunk-B7OAPHPY.js → chunk-YWWEFWFD.js} +3 -3
  32. package/dist/chunk-Z4UYYQ4J.js +42 -0
  33. package/dist/chunk-ZBT5SDIQ.js +16528 -0
  34. package/dist/chunk-ZIHRRTTA.js +24 -0
  35. package/dist/{dist-es-CDFIYJVE.js → dist-es-3VZ2IGGJ.js} +18 -15
  36. package/dist/{dist-es-SUPEA6VE-3B5JSW5C.js → dist-es-BQW4ETQH-C7ZSD5EG.js} +8 -25
  37. package/dist/{dist-es-GHYMLBON.js → dist-es-HSWXMGNC.js} +21 -21
  38. package/dist/{dist-es-OCQVKISC-TNAJ62WG.js → dist-es-IDBNBAO5-H3TO63FG.js} +15 -18
  39. package/dist/{dist-es-S75EKWRJ.js → dist-es-KPJNIAPT.js} +9 -10
  40. package/dist/{dist-es-PRWCVZGQ-HTTVI42T.js → dist-es-LZDRG6RP-SP2FWWEO.js} +3 -4
  41. package/dist/{dist-es-OZGLUDWT.js → dist-es-PIWY5TOR.js} +49 -26
  42. package/dist/{dist-es-ADTONJUN-RVFWNZHO.js → dist-es-R4LD2OHZ-B5MB6BR2.js} +11 -13
  43. package/dist/dist-es-S2KJK4L2-5GDBXJIO.js +470 -0
  44. package/dist/{dist-es-XQME5F6W.js → dist-es-THYWPEKB.js} +12 -10
  45. package/dist/{dist-es-HJVOMDYC-PIAMWMAL.js → dist-es-TIYLKN6W-BAHZRZH5.js} +7 -13
  46. package/dist/{dist-es-IDBDK36G-Y6TQMRO5.js → dist-es-VORPMM2F-WOMP2FYQ.js} +37 -30
  47. package/dist/{dist-es-WQHDOVD7.js → dist-es-WESJCADT.js} +3 -4
  48. package/dist/dist-es-XMOG24OT.js +490 -0
  49. package/dist/event-streams-L7RH32OW-AFMBEYJJ.js +237 -0
  50. package/dist/event-streams-NGUY2RWE.js +237 -0
  51. package/dist/index.cjs +2 -2
  52. package/dist/index.js +2 -2
  53. package/dist/lambda/auto-cache-removal.cjs +28894 -16488
  54. package/dist/lambda/auto-cache-removal.js +11574 -2713
  55. package/dist/lambda/origin-request.cjs +22351 -17619
  56. package/dist/lambda/origin-request.js +21 -17
  57. package/dist/lambda/origin-response.cjs +22219 -17387
  58. package/dist/lambda/origin-response.js +17 -13
  59. package/dist/{loadSso-CZSSLFH6-SA5HOQAX.js → loadSso-F4PTCHDN-YR3RRUYW.js} +330 -227
  60. package/dist/{loadSso-T7GJVVO2.js → loadSso-LG7MFP7N.js} +344 -223
  61. package/dist/signin-P7DNG43W.js +658 -0
  62. package/dist/signin-XWTOVLF3-4ENWNEF7.js +630 -0
  63. package/dist/{sso-oidc-PKO5GYK5-LC65L46O.js → sso-oidc-FQQGUOJL.js} +293 -332
  64. package/dist/{sso-oidc-55SJ27II.js → sso-oidc-RRDYLOJY-FK3AUTOI.js} +263 -337
  65. package/dist/{sts-OPF4H3GL.js → sts-7FBOVTCN.js} +674 -601
  66. package/dist/{sts-P7Q3MYTS-BKGWHQE4.js → sts-TBWJ374A-DHXXCVJJ.js} +651 -608
  67. package/package.json +5 -5
  68. package/dist/chunk-AEOST5WF.js +0 -63
  69. package/dist/chunk-FO7L563E.js +0 -13695
  70. package/dist/chunk-FRWSD3YQ.js +0 -1722
  71. package/dist/chunk-JBVMOFGH.js +0 -152
  72. package/dist/chunk-JSBRDJBE.js +0 -30
  73. package/dist/chunk-KRJS4RAS.js +0 -1732
  74. package/dist/chunk-M5GUUX64.js +0 -63
  75. package/dist/chunk-SX6SVQKS.js +0 -67
  76. package/dist/chunk-UNXXS5FM.js +0 -120
  77. package/dist/chunk-UT2RMOJS.js +0 -2447
  78. package/dist/chunk-VOTRVWIB.js +0 -1965
  79. package/dist/chunk-W3VXP3A3.js +0 -119
  80. package/dist/chunk-XLUI7RQ4.js +0 -115
  81. package/dist/dist-es-2M7RLZ5O.js +0 -200
  82. package/dist/dist-es-Y7VN37H5-WQ3GYROF.js +0 -196
@@ -4,41 +4,39 @@ import {
4
4
  getSSOTokenFromFile,
5
5
  loadSsoSessionData,
6
6
  parseKnownFiles
7
- } from "./chunk-TJ744C2T.js";
7
+ } from "./chunk-GJFKL6XM.js";
8
8
  import {
9
9
  setCredentialFeature
10
- } from "./chunk-64IS37V6.js";
11
- import "./chunk-XLUI7RQ4.js";
10
+ } from "./chunk-RYIGWCGK.js";
12
11
  import {
13
12
  CredentialsProviderError,
14
- TokenProviderError,
15
- init_esm_shims
16
- } from "./chunk-JBVMOFGH.js";
17
- import "./chunk-JSBRDJBE.js";
13
+ ProviderError
14
+ } from "./chunk-THUA35UY.js";
18
15
 
19
- // ../deployment-manager/dist/dist-es-IDBDK36G.js
16
+ // ../deployment-manager/dist/dist-es-VORPMM2F.js
20
17
  import { promises as fsPromises } from "fs";
21
- init_esm_shims();
22
- init_esm_shims();
23
- init_esm_shims();
18
+ var TokenProviderError = class _TokenProviderError extends ProviderError {
19
+ name = "TokenProviderError";
20
+ constructor(message, options = true) {
21
+ super(message, options);
22
+ Object.setPrototypeOf(this, _TokenProviderError.prototype);
23
+ }
24
+ };
24
25
  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");
25
- init_esm_shims();
26
- init_esm_shims();
27
- init_esm_shims();
28
26
  var EXPIRE_WINDOW_MS = 5 * 60 * 1e3;
29
27
  var REFRESH_MESSAGE = `To refresh this SSO session run 'aws sso login' with the corresponding profile.`;
30
- init_esm_shims();
31
- init_esm_shims();
32
28
  var getSsoOidcClient = async (ssoRegion, init = {}) => {
33
- const { SSOOIDCClient } = await import("./sso-oidc-PKO5GYK5-LC65L46O.js");
29
+ const { SSOOIDCClient } = await import("./sso-oidc-RRDYLOJY-FK3AUTOI.js");
30
+ const coalesce = (prop) => init.clientConfig?.[prop] ?? init.parentClientConfig?.[prop];
34
31
  const ssoOidcClient = new SSOOIDCClient(Object.assign({}, init.clientConfig ?? {}, {
35
32
  region: ssoRegion ?? init.clientConfig?.region,
36
- logger: init.clientConfig?.logger ?? init.parentClientConfig?.logger
33
+ logger: coalesce("logger"),
34
+ userAgentAppId: coalesce("userAgentAppId")
37
35
  }));
38
36
  return ssoOidcClient;
39
37
  };
40
38
  var getNewSsoOidcToken = async (ssoToken, ssoRegion, init = {}) => {
41
- const { CreateTokenCommand } = await import("./sso-oidc-PKO5GYK5-LC65L46O.js");
39
+ const { CreateTokenCommand } = await import("./sso-oidc-RRDYLOJY-FK3AUTOI.js");
42
40
  const ssoOidcClient = await getSsoOidcClient(ssoRegion, init);
43
41
  return ssoOidcClient.send(new CreateTokenCommand({
44
42
  clientId: ssoToken.clientId,
@@ -47,19 +45,16 @@ var getNewSsoOidcToken = async (ssoToken, ssoRegion, init = {}) => {
47
45
  grantType: "refresh_token"
48
46
  }));
49
47
  };
50
- init_esm_shims();
51
48
  var validateTokenExpiry = (token) => {
52
49
  if (token.expiration && token.expiration.getTime() < Date.now()) {
53
50
  throw new TokenProviderError(`Token is expired. ${REFRESH_MESSAGE}`, false);
54
51
  }
55
52
  };
56
- init_esm_shims();
57
53
  var validateTokenKey = (key, value, forRefresh = false) => {
58
54
  if (typeof value === "undefined") {
59
55
  throw new TokenProviderError(`Value not present for '${key}' in SSO Token${forRefresh ? ". Cannot refresh" : ""}. ${REFRESH_MESSAGE}`, false);
60
56
  }
61
57
  };
62
- init_esm_shims();
63
58
  var { writeFile } = fsPromises;
64
59
  var writeSSOTokenToFile = (id, ssoToken) => {
65
60
  const tokenFilepath = getSSOTokenFilepath(id);
@@ -144,12 +139,17 @@ var fromSso = (_init = {}) => async ({ callerClientConfig } = {}) => {
144
139
  }
145
140
  };
146
141
  var SHOULD_FAIL_CREDENTIAL_CHAIN = false;
147
- var resolveSSOCredentials = async ({ ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, clientConfig, parentClientConfig, profile, logger }) => {
142
+ var resolveSSOCredentials = async ({ ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, clientConfig, parentClientConfig, profile, filepath, configFilepath, ignoreCache, logger }) => {
148
143
  let token;
149
144
  const refreshMessage = `To refresh this SSO session run aws sso login with the corresponding profile.`;
150
145
  if (ssoSession) {
151
146
  try {
152
- const _token = await fromSso({ profile })();
147
+ const _token = await fromSso({
148
+ profile,
149
+ filepath,
150
+ configFilepath,
151
+ ignoreCache
152
+ })();
153
153
  token = {
154
154
  accessToken: _token.token,
155
155
  expiresAt: new Date(_token.expiration).toISOString()
@@ -177,10 +177,11 @@ var resolveSSOCredentials = async ({ ssoStartUrl, ssoSession, ssoAccountId, ssoR
177
177
  });
178
178
  }
179
179
  const { accessToken } = token;
180
- const { SSOClient, GetRoleCredentialsCommand } = await import("./loadSso-CZSSLFH6-SA5HOQAX.js");
180
+ const { SSOClient, GetRoleCredentialsCommand } = await import("./loadSso-F4PTCHDN-YR3RRUYW.js");
181
181
  const sso = ssoClient || new SSOClient(Object.assign({}, clientConfig ?? {}, {
182
182
  logger: clientConfig?.logger ?? parentClientConfig?.logger,
183
- region: clientConfig?.region ?? ssoRegion
183
+ region: clientConfig?.region ?? ssoRegion,
184
+ userAgentAppId: clientConfig?.userAgentAppId ?? parentClientConfig?.userAgentAppId
184
185
  }));
185
186
  let ssoResp;
186
187
  try {
@@ -217,7 +218,6 @@ var resolveSSOCredentials = async ({ ssoStartUrl, ssoSession, ssoAccountId, ssoR
217
218
  }
218
219
  return credentials;
219
220
  };
220
- init_esm_shims();
221
221
  var validateSsoProfile = (profile, logger) => {
222
222
  const { sso_start_url, sso_account_id, sso_region, sso_role_name } = profile;
223
223
  if (!sso_start_url || !sso_account_id || !sso_region || !sso_role_name) {
@@ -273,7 +273,11 @@ var fromSSO = (init = {}) => async ({ callerClientConfig } = {}) => {
273
273
  ssoClient,
274
274
  clientConfig: init.clientConfig,
275
275
  parentClientConfig: init.parentClientConfig,
276
- profile: profileName
276
+ profile: profileName,
277
+ filepath: init.filepath,
278
+ configFilepath: init.configFilepath,
279
+ ignoreCache: init.ignoreCache,
280
+ logger: init.logger
277
281
  });
278
282
  } else if (!ssoStartUrl || !ssoAccountId || !ssoRegion || !ssoRoleName) {
279
283
  throw new CredentialsProviderError('Incomplete configuration. The fromSSO() argument hash must include "ssoStartUrl", "ssoAccountId", "ssoRegion", "ssoRoleName"', { tryNextLink: false, logger: init.logger });
@@ -287,11 +291,14 @@ var fromSSO = (init = {}) => async ({ callerClientConfig } = {}) => {
287
291
  ssoClient,
288
292
  clientConfig: init.clientConfig,
289
293
  parentClientConfig: init.parentClientConfig,
290
- profile: profileName
294
+ profile: profileName,
295
+ filepath: init.filepath,
296
+ configFilepath: init.configFilepath,
297
+ ignoreCache: init.ignoreCache,
298
+ logger: init.logger
291
299
  });
292
300
  }
293
301
  };
294
- init_esm_shims();
295
302
  export {
296
303
  fromSSO,
297
304
  isSsoProfile,
@@ -6,10 +6,9 @@ import {
6
6
  ENV_SECRET,
7
7
  ENV_SESSION,
8
8
  fromEnv
9
- } from "./chunk-B7OAPHPY.js";
10
- import "./chunk-ITI6QA2Q.js";
11
- import "./chunk-W3VXP3A3.js";
12
- import "./chunk-JSBRDJBE.js";
9
+ } from "./chunk-YWWEFWFD.js";
10
+ import "./chunk-3OYGHA4S.js";
11
+ import "./chunk-S4LJWEXU.js";
13
12
  export {
14
13
  ENV_ACCOUNT_ID,
15
14
  ENV_CREDENTIAL_SCOPE,
@@ -0,0 +1,490 @@
1
+ import {
2
+ chain
3
+ } from "./chunk-6KRYZP6R.js";
4
+ import {
5
+ HttpRequest
6
+ } from "./chunk-NDDYFDCU.js";
7
+ import {
8
+ getProfileName,
9
+ parseKnownFiles,
10
+ readFile
11
+ } from "./chunk-WDFKVCPC.js";
12
+ import {
13
+ setCredentialFeature
14
+ } from "./chunk-3OYGHA4S.js";
15
+ import {
16
+ CredentialsProviderError
17
+ } from "./chunk-S4LJWEXU.js";
18
+
19
+ // ../../.yarn/cache/@aws-sdk-credential-provider-ini-npm-3.940.0-a050e65f44-28b78575da.zip/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveCredentialSource.js
20
+ var resolveCredentialSource = (credentialSource, profileName, logger) => {
21
+ const sourceProvidersMap = {
22
+ EcsContainer: async (options) => {
23
+ const { fromHttp } = await import("./dist-es-3VZ2IGGJ.js");
24
+ const { fromContainerMetadata } = await import("./dist-es-HSWXMGNC.js");
25
+ logger?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer");
26
+ return async () => chain(fromHttp(options ?? {}), fromContainerMetadata(options))().then(setNamedProvider);
27
+ },
28
+ Ec2InstanceMetadata: async (options) => {
29
+ logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");
30
+ const { fromInstanceMetadata } = await import("./dist-es-HSWXMGNC.js");
31
+ return async () => fromInstanceMetadata(options)().then(setNamedProvider);
32
+ },
33
+ Environment: async (options) => {
34
+ logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");
35
+ const { fromEnv } = await import("./dist-es-WESJCADT.js");
36
+ return async () => fromEnv(options)().then(setNamedProvider);
37
+ }
38
+ };
39
+ if (credentialSource in sourceProvidersMap) {
40
+ return sourceProvidersMap[credentialSource];
41
+ } else {
42
+ throw new CredentialsProviderError(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, expected EcsContainer or Ec2InstanceMetadata or Environment.`, { logger });
43
+ }
44
+ };
45
+ var setNamedProvider = (creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_NAMED_PROVIDER", "p");
46
+
47
+ // ../../.yarn/cache/@aws-sdk-credential-provider-ini-npm-3.940.0-a050e65f44-28b78575da.zip/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveAssumeRoleCredentials.js
48
+ var isAssumeRoleProfile = (arg, { profile = "default", logger } = {}) => {
49
+ 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 }));
50
+ };
51
+ var isAssumeRoleWithSourceProfile = (arg, { profile, logger }) => {
52
+ const withSourceProfile = typeof arg.source_profile === "string" && typeof arg.credential_source === "undefined";
53
+ if (withSourceProfile) {
54
+ logger?.debug?.(` ${profile} isAssumeRoleWithSourceProfile source_profile=${arg.source_profile}`);
55
+ }
56
+ return withSourceProfile;
57
+ };
58
+ var isCredentialSourceProfile = (arg, { profile, logger }) => {
59
+ const withProviderProfile = typeof arg.credential_source === "string" && typeof arg.source_profile === "undefined";
60
+ if (withProviderProfile) {
61
+ logger?.debug?.(` ${profile} isCredentialSourceProfile credential_source=${arg.credential_source}`);
62
+ }
63
+ return withProviderProfile;
64
+ };
65
+ var resolveAssumeRoleCredentials = async (profileName, profiles, options, visitedProfiles = {}, resolveProfileData2) => {
66
+ options.logger?.debug("@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)");
67
+ const profileData = profiles[profileName];
68
+ const { source_profile, region } = profileData;
69
+ if (!options.roleAssumer) {
70
+ const { getDefaultRoleAssumer } = await import("./sts-7FBOVTCN.js");
71
+ options.roleAssumer = getDefaultRoleAssumer({
72
+ ...options.clientConfig,
73
+ credentialProviderLogger: options.logger,
74
+ parentClientConfig: {
75
+ ...options?.parentClientConfig,
76
+ region: region ?? options?.parentClientConfig?.region
77
+ }
78
+ }, options.clientPlugins);
79
+ }
80
+ if (source_profile && source_profile in visitedProfiles) {
81
+ throw new CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile ${getProfileName(options)}. Profiles visited: ` + Object.keys(visitedProfiles).join(", "), { logger: options.logger });
82
+ }
83
+ options.logger?.debug(`@aws-sdk/credential-provider-ini - finding credential resolver using ${source_profile ? `source_profile=[${source_profile}]` : `profile=[${profileName}]`}`);
84
+ const sourceCredsProvider = source_profile ? resolveProfileData2(source_profile, profiles, options, {
85
+ ...visitedProfiles,
86
+ [source_profile]: true
87
+ }, isCredentialSourceWithoutRoleArn(profiles[source_profile] ?? {})) : (await resolveCredentialSource(profileData.credential_source, profileName, options.logger)(options))();
88
+ if (isCredentialSourceWithoutRoleArn(profileData)) {
89
+ return sourceCredsProvider.then((creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
90
+ } else {
91
+ const params = {
92
+ RoleArn: profileData.role_arn,
93
+ RoleSessionName: profileData.role_session_name || `aws-sdk-js-${Date.now()}`,
94
+ ExternalId: profileData.external_id,
95
+ DurationSeconds: parseInt(profileData.duration_seconds || "3600", 10)
96
+ };
97
+ const { mfa_serial } = profileData;
98
+ if (mfa_serial) {
99
+ if (!options.mfaCodeProvider) {
100
+ throw new CredentialsProviderError(`Profile ${profileName} requires multi-factor authentication, but no MFA code callback was provided.`, { logger: options.logger, tryNextLink: false });
101
+ }
102
+ params.SerialNumber = mfa_serial;
103
+ params.TokenCode = await options.mfaCodeProvider(mfa_serial);
104
+ }
105
+ const sourceCreds = await sourceCredsProvider;
106
+ return options.roleAssumer(sourceCreds, params).then((creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
107
+ }
108
+ };
109
+ var isCredentialSourceWithoutRoleArn = (section) => {
110
+ return !section.role_arn && !!section.credential_source;
111
+ };
112
+
113
+ // ../../.yarn/cache/@aws-sdk-credential-provider-login-npm-3.940.0-fcfee76762-a408b413bf.zip/node_modules/@aws-sdk/credential-provider-login/dist-es/LoginCredentialsFetcher.js
114
+ import { createHash, createPrivateKey, createPublicKey, sign } from "crypto";
115
+ import { promises as fs } from "fs";
116
+ import { homedir } from "os";
117
+ import { dirname, join } from "path";
118
+ var LoginCredentialsFetcher = class _LoginCredentialsFetcher {
119
+ profileData;
120
+ init;
121
+ callerClientConfig;
122
+ static REFRESH_THRESHOLD = 5 * 60 * 1e3;
123
+ constructor(profileData, init, callerClientConfig) {
124
+ this.profileData = profileData;
125
+ this.init = init;
126
+ this.callerClientConfig = callerClientConfig;
127
+ }
128
+ async loadCredentials() {
129
+ const token = await this.loadToken();
130
+ if (!token) {
131
+ throw new CredentialsProviderError(`Failed to load a token for session ${this.loginSession}, please re-authenticate using aws login`, { tryNextLink: false, logger: this.logger });
132
+ }
133
+ const accessToken = token.accessToken;
134
+ const now = Date.now();
135
+ const expiryTime = new Date(accessToken.expiresAt).getTime();
136
+ const timeUntilExpiry = expiryTime - now;
137
+ if (timeUntilExpiry <= _LoginCredentialsFetcher.REFRESH_THRESHOLD) {
138
+ return this.refresh(token);
139
+ }
140
+ return {
141
+ accessKeyId: accessToken.accessKeyId,
142
+ secretAccessKey: accessToken.secretAccessKey,
143
+ sessionToken: accessToken.sessionToken,
144
+ accountId: accessToken.accountId,
145
+ expiration: new Date(accessToken.expiresAt)
146
+ };
147
+ }
148
+ get logger() {
149
+ return this.init?.logger;
150
+ }
151
+ get loginSession() {
152
+ return this.profileData.login_session;
153
+ }
154
+ async refresh(token) {
155
+ const { SigninClient, CreateOAuth2TokenCommand } = await import("./signin-P7DNG43W.js");
156
+ const { logger, userAgentAppId } = this.callerClientConfig ?? {};
157
+ const isH2 = (requestHandler2) => {
158
+ return requestHandler2?.metadata?.handlerProtocol === "h2";
159
+ };
160
+ const requestHandler = isH2(this.callerClientConfig?.requestHandler) ? void 0 : this.callerClientConfig?.requestHandler;
161
+ const region = this.profileData.region ?? await this.callerClientConfig?.region?.() ?? process.env.AWS_REGION;
162
+ const client = new SigninClient({
163
+ credentials: {
164
+ accessKeyId: "",
165
+ secretAccessKey: ""
166
+ },
167
+ region,
168
+ requestHandler,
169
+ logger,
170
+ userAgentAppId,
171
+ ...this.init?.clientConfig
172
+ });
173
+ this.createDPoPInterceptor(client.middlewareStack);
174
+ const commandInput = {
175
+ tokenInput: {
176
+ clientId: token.clientId,
177
+ refreshToken: token.refreshToken,
178
+ grantType: "refresh_token"
179
+ }
180
+ };
181
+ try {
182
+ const response = await client.send(new CreateOAuth2TokenCommand(commandInput));
183
+ const { accessKeyId, secretAccessKey, sessionToken } = response.tokenOutput?.accessToken ?? {};
184
+ const { refreshToken, expiresIn } = response.tokenOutput ?? {};
185
+ if (!accessKeyId || !secretAccessKey || !sessionToken || !refreshToken) {
186
+ throw new CredentialsProviderError("Token refresh response missing required fields", {
187
+ logger: this.logger,
188
+ tryNextLink: false
189
+ });
190
+ }
191
+ const expiresInMs = (expiresIn ?? 900) * 1e3;
192
+ const expiration = new Date(Date.now() + expiresInMs);
193
+ const updatedToken = {
194
+ ...token,
195
+ accessToken: {
196
+ ...token.accessToken,
197
+ accessKeyId,
198
+ secretAccessKey,
199
+ sessionToken,
200
+ expiresAt: expiration.toISOString()
201
+ },
202
+ refreshToken
203
+ };
204
+ await this.saveToken(updatedToken);
205
+ const newAccessToken = updatedToken.accessToken;
206
+ return {
207
+ accessKeyId: newAccessToken.accessKeyId,
208
+ secretAccessKey: newAccessToken.secretAccessKey,
209
+ sessionToken: newAccessToken.sessionToken,
210
+ accountId: newAccessToken.accountId,
211
+ expiration
212
+ };
213
+ } catch (error) {
214
+ if (error.name === "AccessDeniedException") {
215
+ const errorType = error.error;
216
+ let message;
217
+ switch (errorType) {
218
+ case "TOKEN_EXPIRED":
219
+ message = "Your session has expired. Please reauthenticate.";
220
+ break;
221
+ case "USER_CREDENTIALS_CHANGED":
222
+ message = "Unable to refresh credentials because of a change in your password. Please reauthenticate with your new password.";
223
+ break;
224
+ case "INSUFFICIENT_PERMISSIONS":
225
+ message = "Unable to refresh credentials due to insufficient permissions. You may be missing permission for the 'CreateOAuth2Token' action.";
226
+ break;
227
+ default:
228
+ message = `Failed to refresh token: ${String(error)}. Please re-authenticate using \`aws login\``;
229
+ }
230
+ throw new CredentialsProviderError(message, { logger: this.logger, tryNextLink: false });
231
+ }
232
+ throw new CredentialsProviderError(`Failed to refresh token: ${String(error)}. Please re-authenticate using aws login`, { logger: this.logger });
233
+ }
234
+ }
235
+ async loadToken() {
236
+ const tokenFilePath = this.getTokenFilePath();
237
+ try {
238
+ let tokenData;
239
+ try {
240
+ tokenData = await readFile(tokenFilePath, { ignoreCache: this.init?.ignoreCache });
241
+ } catch {
242
+ tokenData = await fs.readFile(tokenFilePath, "utf8");
243
+ }
244
+ const token = JSON.parse(tokenData);
245
+ const missingFields = ["accessToken", "clientId", "refreshToken", "dpopKey"].filter((k) => !token[k]);
246
+ if (!token.accessToken?.accountId) {
247
+ missingFields.push("accountId");
248
+ }
249
+ if (missingFields.length > 0) {
250
+ throw new CredentialsProviderError(`Token validation failed, missing fields: ${missingFields.join(", ")}`, {
251
+ logger: this.logger,
252
+ tryNextLink: false
253
+ });
254
+ }
255
+ return token;
256
+ } catch (error) {
257
+ throw new CredentialsProviderError(`Failed to load token from ${tokenFilePath}: ${String(error)}`, {
258
+ logger: this.logger,
259
+ tryNextLink: false
260
+ });
261
+ }
262
+ }
263
+ async saveToken(token) {
264
+ const tokenFilePath = this.getTokenFilePath();
265
+ const directory = dirname(tokenFilePath);
266
+ try {
267
+ await fs.mkdir(directory, { recursive: true });
268
+ } catch (error) {
269
+ }
270
+ await fs.writeFile(tokenFilePath, JSON.stringify(token, null, 2), "utf8");
271
+ }
272
+ getTokenFilePath() {
273
+ const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ?? join(homedir(), ".aws", "login", "cache");
274
+ const loginSessionBytes = Buffer.from(this.loginSession, "utf8");
275
+ const loginSessionSha256 = createHash("sha256").update(loginSessionBytes).digest("hex");
276
+ return join(directory, `${loginSessionSha256}.json`);
277
+ }
278
+ derToRawSignature(derSignature) {
279
+ let offset = 2;
280
+ if (derSignature[offset] !== 2) {
281
+ throw new Error("Invalid DER signature");
282
+ }
283
+ offset++;
284
+ const rLength = derSignature[offset++];
285
+ let r = derSignature.subarray(offset, offset + rLength);
286
+ offset += rLength;
287
+ if (derSignature[offset] !== 2) {
288
+ throw new Error("Invalid DER signature");
289
+ }
290
+ offset++;
291
+ const sLength = derSignature[offset++];
292
+ let s = derSignature.subarray(offset, offset + sLength);
293
+ r = r[0] === 0 ? r.subarray(1) : r;
294
+ s = s[0] === 0 ? s.subarray(1) : s;
295
+ const rPadded = Buffer.concat([Buffer.alloc(32 - r.length), r]);
296
+ const sPadded = Buffer.concat([Buffer.alloc(32 - s.length), s]);
297
+ return Buffer.concat([rPadded, sPadded]);
298
+ }
299
+ createDPoPInterceptor(middlewareStack) {
300
+ middlewareStack.add((next) => async (args) => {
301
+ if (HttpRequest.isInstance(args.request)) {
302
+ const request = args.request;
303
+ const actualEndpoint = `${request.protocol}//${request.hostname}${request.port ? `:${request.port}` : ""}${request.path}`;
304
+ const dpop = await this.generateDpop(request.method, actualEndpoint);
305
+ request.headers = {
306
+ ...request.headers,
307
+ DPoP: dpop
308
+ };
309
+ }
310
+ return next(args);
311
+ }, {
312
+ step: "finalizeRequest",
313
+ name: "dpopInterceptor",
314
+ override: true
315
+ });
316
+ }
317
+ async generateDpop(method = "POST", endpoint) {
318
+ const token = await this.loadToken();
319
+ try {
320
+ const privateKey = createPrivateKey({
321
+ key: token.dpopKey,
322
+ format: "pem",
323
+ type: "sec1"
324
+ });
325
+ const publicKey = createPublicKey(privateKey);
326
+ const publicDer = publicKey.export({ format: "der", type: "spki" });
327
+ let pointStart = -1;
328
+ for (let i = 0; i < publicDer.length; i++) {
329
+ if (publicDer[i] === 4) {
330
+ pointStart = i;
331
+ break;
332
+ }
333
+ }
334
+ const x = publicDer.slice(pointStart + 1, pointStart + 33);
335
+ const y = publicDer.slice(pointStart + 33, pointStart + 65);
336
+ const header = {
337
+ alg: "ES256",
338
+ typ: "dpop+jwt",
339
+ jwk: {
340
+ kty: "EC",
341
+ crv: "P-256",
342
+ x: x.toString("base64url"),
343
+ y: y.toString("base64url")
344
+ }
345
+ };
346
+ const payload = {
347
+ jti: crypto.randomUUID(),
348
+ htm: method,
349
+ htu: endpoint,
350
+ iat: Math.floor(Date.now() / 1e3)
351
+ };
352
+ const headerB64 = Buffer.from(JSON.stringify(header)).toString("base64url");
353
+ const payloadB64 = Buffer.from(JSON.stringify(payload)).toString("base64url");
354
+ const message = `${headerB64}.${payloadB64}`;
355
+ const asn1Signature = sign("sha256", Buffer.from(message), privateKey);
356
+ const rawSignature = this.derToRawSignature(asn1Signature);
357
+ const signatureB64 = rawSignature.toString("base64url");
358
+ return `${message}.${signatureB64}`;
359
+ } catch (error) {
360
+ throw new CredentialsProviderError(`Failed to generate Dpop proof: ${error instanceof Error ? error.message : String(error)}`, { logger: this.logger, tryNextLink: false });
361
+ }
362
+ }
363
+ };
364
+
365
+ // ../../.yarn/cache/@aws-sdk-credential-provider-login-npm-3.940.0-fcfee76762-a408b413bf.zip/node_modules/@aws-sdk/credential-provider-login/dist-es/fromLoginCredentials.js
366
+ var fromLoginCredentials = (init) => async ({ callerClientConfig } = {}) => {
367
+ init?.logger?.debug?.("@aws-sdk/credential-providers - fromLoginCredentials");
368
+ const profiles = await parseKnownFiles(init || {});
369
+ const profileName = getProfileName({
370
+ profile: init?.profile ?? callerClientConfig?.profile
371
+ });
372
+ const profile = profiles[profileName];
373
+ if (!profile?.login_session) {
374
+ throw new CredentialsProviderError(`Profile ${profileName} does not contain login_session.`, {
375
+ tryNextLink: true,
376
+ logger: init?.logger
377
+ });
378
+ }
379
+ const fetcher = new LoginCredentialsFetcher(profile, init, callerClientConfig);
380
+ const credentials = await fetcher.loadCredentials();
381
+ return setCredentialFeature(credentials, "CREDENTIALS_LOGIN", "AD");
382
+ };
383
+
384
+ // ../../.yarn/cache/@aws-sdk-credential-provider-ini-npm-3.940.0-a050e65f44-28b78575da.zip/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveLoginCredentials.js
385
+ var isLoginProfile = (data) => {
386
+ return Boolean(data && data.login_session);
387
+ };
388
+ var resolveLoginCredentials = async (profileName, options) => {
389
+ const credentials = await fromLoginCredentials({
390
+ ...options,
391
+ profile: profileName
392
+ })();
393
+ return setCredentialFeature(credentials, "CREDENTIALS_PROFILE_LOGIN", "AC");
394
+ };
395
+
396
+ // ../../.yarn/cache/@aws-sdk-credential-provider-ini-npm-3.940.0-a050e65f44-28b78575da.zip/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveProcessCredentials.js
397
+ var isProcessProfile = (arg) => Boolean(arg) && typeof arg === "object" && typeof arg.credential_process === "string";
398
+ var resolveProcessCredentials = async (options, profile) => import("./dist-es-KPJNIAPT.js").then(({ fromProcess }) => fromProcess({
399
+ ...options,
400
+ profile
401
+ })().then((creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_PROCESS", "v")));
402
+
403
+ // ../../.yarn/cache/@aws-sdk-credential-provider-ini-npm-3.940.0-a050e65f44-28b78575da.zip/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveSsoCredentials.js
404
+ var resolveSsoCredentials = async (profile, profileData, options = {}) => {
405
+ const { fromSSO } = await import("./dist-es-PIWY5TOR.js");
406
+ return fromSSO({
407
+ profile,
408
+ logger: options.logger,
409
+ parentClientConfig: options.parentClientConfig,
410
+ clientConfig: options.clientConfig
411
+ })().then((creds) => {
412
+ if (profileData.sso_session) {
413
+ return setCredentialFeature(creds, "CREDENTIALS_PROFILE_SSO", "r");
414
+ } else {
415
+ return setCredentialFeature(creds, "CREDENTIALS_PROFILE_SSO_LEGACY", "t");
416
+ }
417
+ });
418
+ };
419
+ 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");
420
+
421
+ // ../../.yarn/cache/@aws-sdk-credential-provider-ini-npm-3.940.0-a050e65f44-28b78575da.zip/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveStaticCredentials.js
422
+ 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;
423
+ var resolveStaticCredentials = async (profile, options) => {
424
+ options?.logger?.debug("@aws-sdk/credential-provider-ini - resolveStaticCredentials");
425
+ const credentials = {
426
+ accessKeyId: profile.aws_access_key_id,
427
+ secretAccessKey: profile.aws_secret_access_key,
428
+ sessionToken: profile.aws_session_token,
429
+ ...profile.aws_credential_scope && { credentialScope: profile.aws_credential_scope },
430
+ ...profile.aws_account_id && { accountId: profile.aws_account_id }
431
+ };
432
+ return setCredentialFeature(credentials, "CREDENTIALS_PROFILE", "n");
433
+ };
434
+
435
+ // ../../.yarn/cache/@aws-sdk-credential-provider-ini-npm-3.940.0-a050e65f44-28b78575da.zip/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveWebIdentityCredentials.js
436
+ 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;
437
+ var resolveWebIdentityCredentials = async (profile, options) => import("./dist-es-THYWPEKB.js").then(({ fromTokenFile }) => fromTokenFile({
438
+ webIdentityTokenFile: profile.web_identity_token_file,
439
+ roleArn: profile.role_arn,
440
+ roleSessionName: profile.role_session_name,
441
+ roleAssumerWithWebIdentity: options.roleAssumerWithWebIdentity,
442
+ logger: options.logger,
443
+ parentClientConfig: options.parentClientConfig
444
+ })().then((creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN", "q")));
445
+
446
+ // ../../.yarn/cache/@aws-sdk-credential-provider-ini-npm-3.940.0-a050e65f44-28b78575da.zip/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveProfileData.js
447
+ var resolveProfileData = async (profileName, profiles, options, visitedProfiles = {}, isAssumeRoleRecursiveCall = false) => {
448
+ const data = profiles[profileName];
449
+ if (Object.keys(visitedProfiles).length > 0 && isStaticCredsProfile(data)) {
450
+ return resolveStaticCredentials(data, options);
451
+ }
452
+ if (isAssumeRoleRecursiveCall || isAssumeRoleProfile(data, { profile: profileName, logger: options.logger })) {
453
+ return resolveAssumeRoleCredentials(profileName, profiles, options, visitedProfiles, resolveProfileData);
454
+ }
455
+ if (isStaticCredsProfile(data)) {
456
+ return resolveStaticCredentials(data, options);
457
+ }
458
+ if (isWebIdentityProfile(data)) {
459
+ return resolveWebIdentityCredentials(data, options);
460
+ }
461
+ if (isProcessProfile(data)) {
462
+ return resolveProcessCredentials(options, profileName);
463
+ }
464
+ if (isSsoProfile(data)) {
465
+ return await resolveSsoCredentials(profileName, data, options);
466
+ }
467
+ if (isLoginProfile(data)) {
468
+ return resolveLoginCredentials(profileName, options);
469
+ }
470
+ throw new CredentialsProviderError(`Could not resolve credentials using profile: [${profileName}] in configuration/credentials file(s).`, { logger: options.logger });
471
+ };
472
+
473
+ // ../../.yarn/cache/@aws-sdk-credential-provider-ini-npm-3.940.0-a050e65f44-28b78575da.zip/node_modules/@aws-sdk/credential-provider-ini/dist-es/fromIni.js
474
+ var fromIni = (_init = {}) => async ({ callerClientConfig } = {}) => {
475
+ const init = {
476
+ ..._init,
477
+ parentClientConfig: {
478
+ ...callerClientConfig,
479
+ ..._init.parentClientConfig
480
+ }
481
+ };
482
+ init.logger?.debug("@aws-sdk/credential-provider-ini - fromIni");
483
+ const profiles = await parseKnownFiles(init);
484
+ return resolveProfileData(getProfileName({
485
+ profile: _init.profile ?? callerClientConfig?.profile
486
+ }), profiles, init);
487
+ };
488
+ export {
489
+ fromIni
490
+ };