skill-tree 0.3.0 → 0.3.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 (90) hide show
  1. package/package.json +1 -1
  2. package/dist/bowser-XBWM4HVL.mjs +0 -2821
  3. package/dist/chunk-3MV4GQ3N.mjs +0 -19
  4. package/dist/chunk-3SRB47JW.mjs +0 -8344
  5. package/dist/chunk-43YOKLZP.mjs +0 -6081
  6. package/dist/chunk-4AGZU52D.mjs +0 -7918
  7. package/dist/chunk-4HXHCEFH.mjs +0 -9157
  8. package/dist/chunk-4OC5QFIF.mjs +0 -11267
  9. package/dist/chunk-4TFMKAVC.mjs +0 -1225
  10. package/dist/chunk-55SMGVTP.mjs +0 -7126
  11. package/dist/chunk-6AZMD3Q3.mjs +0 -1243
  12. package/dist/chunk-6FX4IK4Z.mjs +0 -5368
  13. package/dist/chunk-6UPDN5QM.mjs +0 -163
  14. package/dist/chunk-7EGDKOHV.mjs +0 -9439
  15. package/dist/chunk-7IHYDFWW.mjs +0 -163
  16. package/dist/chunk-7LMOQW5H.mjs +0 -4893
  17. package/dist/chunk-7QIQJVNP.mjs +0 -14206
  18. package/dist/chunk-7VB4ZRZO.mjs +0 -7127
  19. package/dist/chunk-A3SILZYX.mjs +0 -8360
  20. package/dist/chunk-BPVRW25O.mjs +0 -6089
  21. package/dist/chunk-CI4476KM.mjs +0 -6607
  22. package/dist/chunk-DDXYQ74I.mjs +0 -13969
  23. package/dist/chunk-DQOFJXBX.mjs +0 -6595
  24. package/dist/chunk-E2CVK23F.mjs +0 -8751
  25. package/dist/chunk-F3YEUQAP.mjs +0 -654
  26. package/dist/chunk-FKJJ4RJG.mjs +0 -13874
  27. package/dist/chunk-GBIK7WMX.mjs +0 -9293
  28. package/dist/chunk-GFK5SZRJ.mjs +0 -580
  29. package/dist/chunk-II7DECZQ.mjs +0 -9111
  30. package/dist/chunk-INKVOZXK.mjs +0 -15898
  31. package/dist/chunk-J2JM7HAK.mjs +0 -8787
  32. package/dist/chunk-K6NRCSAZ.mjs +0 -4355
  33. package/dist/chunk-M4RPUUZT.mjs +0 -3156
  34. package/dist/chunk-MR4TVINH.mjs +0 -1234
  35. package/dist/chunk-OOECXYLU.mjs +0 -1379
  36. package/dist/chunk-OYHYXKXO.mjs +0 -7297
  37. package/dist/chunk-P5GJJ4JB.mjs +0 -9237
  38. package/dist/chunk-PDPN7FW7.mjs +0 -1045
  39. package/dist/chunk-PJJJQXJL.mjs +0 -1174
  40. package/dist/chunk-PK3BAIFW.mjs +0 -9294
  41. package/dist/chunk-QNK3WYNA.mjs +0 -8971
  42. package/dist/chunk-T4PVQW5O.mjs +0 -124
  43. package/dist/chunk-TENXZJB3.mjs +0 -349
  44. package/dist/chunk-TEUB6DZR.mjs +0 -6453
  45. package/dist/chunk-TWPEHDW4.mjs +0 -1067
  46. package/dist/chunk-VHFTX33A.mjs +0 -6724
  47. package/dist/chunk-VNZSS2WY.mjs +0 -1057
  48. package/dist/chunk-WJP5XYS7.mjs +0 -2102
  49. package/dist/chunk-WX6N7KNO.mjs +0 -1239
  50. package/dist/chunk-Y54UK2J3.mjs +0 -13071
  51. package/dist/chunk-YDNGMDXC.mjs +0 -9294
  52. package/dist/chunk-YJ6NZQLT.mjs +0 -9237
  53. package/dist/chunk-YWRKGXK4.mjs +0 -9300
  54. package/dist/chunk-ZI4AIAWQ.mjs +0 -46
  55. package/dist/chunk-ZQVS7MQK.mjs +0 -6081
  56. package/dist/dist-es-27NPMXP7.mjs +0 -22
  57. package/dist/dist-es-2JG6ZWFR.mjs +0 -69
  58. package/dist/dist-es-5QD5QJS2.mjs +0 -495
  59. package/dist/dist-es-5ZD454R2.mjs +0 -317
  60. package/dist/dist-es-DYHMPEKZ.mjs +0 -170
  61. package/dist/dist-es-FIVW7BUZ.mjs +0 -317
  62. package/dist/dist-es-HRBPKDMR.mjs +0 -935
  63. package/dist/dist-es-L5AMJHSY.mjs +0 -935
  64. package/dist/dist-es-LHPJ63IO.mjs +0 -4437
  65. package/dist/dist-es-OK2J7EV3.mjs +0 -378
  66. package/dist/dist-es-XFAHNA2L.mjs +0 -69
  67. package/dist/dist-es-XPNJAJI7.mjs +0 -4437
  68. package/dist/dist-es-Y4JPNLF3.mjs +0 -6077
  69. package/dist/dist-es-ZGPJUGVW.mjs +0 -87
  70. package/dist/dist-es-ZYHLY2E6.mjs +0 -487
  71. package/dist/event-streams-6MFHPNRF.mjs +0 -42
  72. package/dist/lib-B245IUXF.mjs +0 -778
  73. package/dist/loadSso-CAWKILED.mjs +0 -579
  74. package/dist/loadSso-OYKG6ZRE.mjs +0 -579
  75. package/dist/signin-KUENA7ZD.mjs +0 -743
  76. package/dist/signin-LMFNL434.mjs +0 -665
  77. package/dist/sqlite-5LHEQTBD.mjs +0 -7
  78. package/dist/sqlite-BZK5GF76.mjs +0 -7
  79. package/dist/sqlite-MG45OOTV.mjs +0 -6
  80. package/dist/sqlite-OLU72GHB.mjs +0 -6
  81. package/dist/sqlite-RR2SJ3SR.mjs +0 -7
  82. package/dist/sqlite-XJRPMNAJ.mjs +0 -6
  83. package/dist/sqlite-ZKQKQKPT.mjs +0 -7
  84. package/dist/sso-oidc-3VGFPMFD.mjs +0 -832
  85. package/dist/sso-oidc-NNH6SQIH.mjs +0 -832
  86. package/dist/sts-EF755UBF.mjs +0 -6290
  87. package/dist/sts-QGXULWRT.mjs +0 -6290
  88. package/dist/sync-4DCV43GA.mjs +0 -15
  89. package/dist/sync-BSWMMDA6.mjs +0 -14
  90. package/dist/sync-WHIIDHML.mjs +0 -14
@@ -1,22 +0,0 @@
1
- import {
2
- ENV_ACCOUNT_ID,
3
- ENV_CREDENTIAL_SCOPE,
4
- ENV_EXPIRATION,
5
- ENV_KEY,
6
- ENV_SECRET,
7
- ENV_SESSION,
8
- fromEnv
9
- } from "./chunk-ZI4AIAWQ.mjs";
10
- import "./chunk-M4RPUUZT.mjs";
11
- import "./chunk-WJP5XYS7.mjs";
12
- import "./chunk-VNZSS2WY.mjs";
13
- import "./chunk-3MV4GQ3N.mjs";
14
- export {
15
- ENV_ACCOUNT_ID,
16
- ENV_CREDENTIAL_SCOPE,
17
- ENV_EXPIRATION,
18
- ENV_KEY,
19
- ENV_SECRET,
20
- ENV_SESSION,
21
- fromEnv
22
- };
@@ -1,69 +0,0 @@
1
- import {
2
- setCredentialFeature
3
- } from "./chunk-2NL4MXNX.mjs";
4
- import {
5
- CredentialsProviderError,
6
- externalDataInterceptor
7
- } from "./chunk-YDVZIFIU.mjs";
8
- import "./chunk-BZ2JKJ54.mjs";
9
- import "./chunk-QZ7TP4HQ.mjs";
10
-
11
- // node_modules/@aws-sdk/credential-provider-web-identity/dist-es/fromTokenFile.js
12
- import { readFileSync } from "fs";
13
-
14
- // node_modules/@aws-sdk/credential-provider-web-identity/dist-es/fromWebToken.js
15
- var fromWebToken = (init) => async (awsIdentityProperties) => {
16
- init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromWebToken");
17
- const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy, durationSeconds } = init;
18
- let { roleAssumerWithWebIdentity } = init;
19
- if (!roleAssumerWithWebIdentity) {
20
- const { getDefaultRoleAssumerWithWebIdentity } = await import("./sts-EF755UBF.mjs");
21
- roleAssumerWithWebIdentity = getDefaultRoleAssumerWithWebIdentity({
22
- ...init.clientConfig,
23
- credentialProviderLogger: init.logger,
24
- parentClientConfig: {
25
- ...awsIdentityProperties?.callerClientConfig,
26
- ...init.parentClientConfig
27
- }
28
- }, init.clientPlugins);
29
- }
30
- return roleAssumerWithWebIdentity({
31
- RoleArn: roleArn,
32
- RoleSessionName: roleSessionName ?? `aws-sdk-js-session-${Date.now()}`,
33
- WebIdentityToken: webIdentityToken,
34
- ProviderId: providerId,
35
- PolicyArns: policyArns,
36
- Policy: policy,
37
- DurationSeconds: durationSeconds
38
- });
39
- };
40
-
41
- // node_modules/@aws-sdk/credential-provider-web-identity/dist-es/fromTokenFile.js
42
- var ENV_TOKEN_FILE = "AWS_WEB_IDENTITY_TOKEN_FILE";
43
- var ENV_ROLE_ARN = "AWS_ROLE_ARN";
44
- var ENV_ROLE_SESSION_NAME = "AWS_ROLE_SESSION_NAME";
45
- var fromTokenFile = (init = {}) => async (awsIdentityProperties) => {
46
- init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromTokenFile");
47
- const webIdentityTokenFile = init?.webIdentityTokenFile ?? process.env[ENV_TOKEN_FILE];
48
- const roleArn = init?.roleArn ?? process.env[ENV_ROLE_ARN];
49
- const roleSessionName = init?.roleSessionName ?? process.env[ENV_ROLE_SESSION_NAME];
50
- if (!webIdentityTokenFile || !roleArn) {
51
- throw new CredentialsProviderError("Web identity configuration not specified", {
52
- logger: init.logger
53
- });
54
- }
55
- const credentials = await fromWebToken({
56
- ...init,
57
- webIdentityToken: externalDataInterceptor?.getTokenRecord?.()[webIdentityTokenFile] ?? readFileSync(webIdentityTokenFile, { encoding: "ascii" }),
58
- roleArn,
59
- roleSessionName
60
- })(awsIdentityProperties);
61
- if (webIdentityTokenFile === process.env[ENV_TOKEN_FILE]) {
62
- setCredentialFeature(credentials, "CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN", "h");
63
- }
64
- return credentials;
65
- };
66
- export {
67
- fromTokenFile,
68
- fromWebToken
69
- };
@@ -1,495 +0,0 @@
1
- import {
2
- setCredentialFeature
3
- } from "./chunk-M4RPUUZT.mjs";
4
- import {
5
- CredentialsProviderError,
6
- HttpRequest,
7
- chain,
8
- getProfileName,
9
- parseKnownFiles,
10
- readFile
11
- } from "./chunk-WJP5XYS7.mjs";
12
- import "./chunk-VNZSS2WY.mjs";
13
- import {
14
- __publicField
15
- } from "./chunk-3MV4GQ3N.mjs";
16
-
17
- // node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveCredentialSource.js
18
- var resolveCredentialSource = (credentialSource, profileName, logger) => {
19
- const sourceProvidersMap = {
20
- EcsContainer: async (options) => {
21
- const { fromHttp } = await import("./dist-es-DYHMPEKZ.mjs");
22
- const { fromContainerMetadata } = await import("./dist-es-OK2J7EV3.mjs");
23
- logger?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer");
24
- return async () => chain(fromHttp(options ?? {}), fromContainerMetadata(options))().then(setNamedProvider);
25
- },
26
- Ec2InstanceMetadata: async (options) => {
27
- logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");
28
- const { fromInstanceMetadata } = await import("./dist-es-OK2J7EV3.mjs");
29
- return async () => fromInstanceMetadata(options)().then(setNamedProvider);
30
- },
31
- Environment: async (options) => {
32
- logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");
33
- const { fromEnv } = await import("./dist-es-27NPMXP7.mjs");
34
- return async () => fromEnv(options)().then(setNamedProvider);
35
- }
36
- };
37
- if (credentialSource in sourceProvidersMap) {
38
- return sourceProvidersMap[credentialSource];
39
- } else {
40
- throw new CredentialsProviderError(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, expected EcsContainer or Ec2InstanceMetadata or Environment.`, { logger });
41
- }
42
- };
43
- var setNamedProvider = (creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_NAMED_PROVIDER", "p");
44
-
45
- // node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveAssumeRoleCredentials.js
46
- var isAssumeRoleProfile = (arg, { profile = "default", logger } = {}) => {
47
- 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 }));
48
- };
49
- var isAssumeRoleWithSourceProfile = (arg, { profile, logger }) => {
50
- const withSourceProfile = typeof arg.source_profile === "string" && typeof arg.credential_source === "undefined";
51
- if (withSourceProfile) {
52
- logger?.debug?.(` ${profile} isAssumeRoleWithSourceProfile source_profile=${arg.source_profile}`);
53
- }
54
- return withSourceProfile;
55
- };
56
- var isCredentialSourceProfile = (arg, { profile, logger }) => {
57
- const withProviderProfile = typeof arg.credential_source === "string" && typeof arg.source_profile === "undefined";
58
- if (withProviderProfile) {
59
- logger?.debug?.(` ${profile} isCredentialSourceProfile credential_source=${arg.credential_source}`);
60
- }
61
- return withProviderProfile;
62
- };
63
- var resolveAssumeRoleCredentials = async (profileName, profiles, options, callerClientConfig, visitedProfiles = {}, resolveProfileData2) => {
64
- options.logger?.debug("@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)");
65
- const profileData = profiles[profileName];
66
- const { source_profile, region } = profileData;
67
- if (!options.roleAssumer) {
68
- const { getDefaultRoleAssumer } = await import("./sts-QGXULWRT.mjs");
69
- options.roleAssumer = getDefaultRoleAssumer({
70
- ...options.clientConfig,
71
- credentialProviderLogger: options.logger,
72
- parentClientConfig: {
73
- ...callerClientConfig,
74
- ...options?.parentClientConfig,
75
- region: region ?? options?.parentClientConfig?.region ?? callerClientConfig?.region
76
- }
77
- }, options.clientPlugins);
78
- }
79
- if (source_profile && source_profile in visitedProfiles) {
80
- throw new CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile ${getProfileName(options)}. Profiles visited: ` + Object.keys(visitedProfiles).join(", "), { logger: options.logger });
81
- }
82
- options.logger?.debug(`@aws-sdk/credential-provider-ini - finding credential resolver using ${source_profile ? `source_profile=[${source_profile}]` : `profile=[${profileName}]`}`);
83
- const sourceCredsProvider = source_profile ? resolveProfileData2(source_profile, profiles, options, callerClientConfig, {
84
- ...visitedProfiles,
85
- [source_profile]: true
86
- }, isCredentialSourceWithoutRoleArn(profiles[source_profile] ?? {})) : (await resolveCredentialSource(profileData.credential_source, profileName, options.logger)(options))();
87
- if (isCredentialSourceWithoutRoleArn(profileData)) {
88
- return sourceCredsProvider.then((creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
89
- } else {
90
- const params = {
91
- RoleArn: profileData.role_arn,
92
- RoleSessionName: profileData.role_session_name || `aws-sdk-js-${Date.now()}`,
93
- ExternalId: profileData.external_id,
94
- DurationSeconds: parseInt(profileData.duration_seconds || "3600", 10)
95
- };
96
- const { mfa_serial } = profileData;
97
- if (mfa_serial) {
98
- if (!options.mfaCodeProvider) {
99
- throw new CredentialsProviderError(`Profile ${profileName} requires multi-factor authentication, but no MFA code callback was provided.`, { logger: options.logger, tryNextLink: false });
100
- }
101
- params.SerialNumber = mfa_serial;
102
- params.TokenCode = await options.mfaCodeProvider(mfa_serial);
103
- }
104
- const sourceCreds = await sourceCredsProvider;
105
- return options.roleAssumer(sourceCreds, params).then((creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
106
- }
107
- };
108
- var isCredentialSourceWithoutRoleArn = (section) => {
109
- return !section.role_arn && !!section.credential_source;
110
- };
111
-
112
- // node_modules/@aws-sdk/credential-provider-login/dist-es/LoginCredentialsFetcher.js
113
- import { createHash, createPrivateKey, createPublicKey, sign } from "crypto";
114
- import { promises as fs } from "fs";
115
- import { homedir } from "os";
116
- import { dirname, join } from "path";
117
- var _LoginCredentialsFetcher = class _LoginCredentialsFetcher {
118
- constructor(profileData, init, callerClientConfig) {
119
- __publicField(this, "profileData");
120
- __publicField(this, "init");
121
- __publicField(this, "callerClientConfig");
122
- this.profileData = profileData;
123
- this.init = init;
124
- this.callerClientConfig = callerClientConfig;
125
- }
126
- async loadCredentials() {
127
- const token = await this.loadToken();
128
- if (!token) {
129
- throw new CredentialsProviderError(`Failed to load a token for session ${this.loginSession}, please re-authenticate using aws login`, { tryNextLink: false, logger: this.logger });
130
- }
131
- const accessToken = token.accessToken;
132
- const now = Date.now();
133
- const expiryTime = new Date(accessToken.expiresAt).getTime();
134
- const timeUntilExpiry = expiryTime - now;
135
- if (timeUntilExpiry <= _LoginCredentialsFetcher.REFRESH_THRESHOLD) {
136
- return this.refresh(token);
137
- }
138
- return {
139
- accessKeyId: accessToken.accessKeyId,
140
- secretAccessKey: accessToken.secretAccessKey,
141
- sessionToken: accessToken.sessionToken,
142
- accountId: accessToken.accountId,
143
- expiration: new Date(accessToken.expiresAt)
144
- };
145
- }
146
- get logger() {
147
- return this.init?.logger;
148
- }
149
- get loginSession() {
150
- return this.profileData.login_session;
151
- }
152
- async refresh(token) {
153
- const { SigninClient, CreateOAuth2TokenCommand } = await import("./signin-KUENA7ZD.mjs");
154
- const { logger, userAgentAppId } = this.callerClientConfig ?? {};
155
- const isH2 = (requestHandler2) => {
156
- return requestHandler2?.metadata?.handlerProtocol === "h2";
157
- };
158
- const requestHandler = isH2(this.callerClientConfig?.requestHandler) ? void 0 : this.callerClientConfig?.requestHandler;
159
- const region = this.profileData.region ?? await this.callerClientConfig?.region?.() ?? process.env.AWS_REGION;
160
- const client = new SigninClient({
161
- credentials: {
162
- accessKeyId: "",
163
- secretAccessKey: ""
164
- },
165
- region,
166
- requestHandler,
167
- logger,
168
- userAgentAppId,
169
- ...this.init?.clientConfig
170
- });
171
- this.createDPoPInterceptor(client.middlewareStack);
172
- const commandInput = {
173
- tokenInput: {
174
- clientId: token.clientId,
175
- refreshToken: token.refreshToken,
176
- grantType: "refresh_token"
177
- }
178
- };
179
- try {
180
- const response = await client.send(new CreateOAuth2TokenCommand(commandInput));
181
- const { accessKeyId, secretAccessKey, sessionToken } = response.tokenOutput?.accessToken ?? {};
182
- const { refreshToken, expiresIn } = response.tokenOutput ?? {};
183
- if (!accessKeyId || !secretAccessKey || !sessionToken || !refreshToken) {
184
- throw new CredentialsProviderError("Token refresh response missing required fields", {
185
- logger: this.logger,
186
- tryNextLink: false
187
- });
188
- }
189
- const expiresInMs = (expiresIn ?? 900) * 1e3;
190
- const expiration = new Date(Date.now() + expiresInMs);
191
- const updatedToken = {
192
- ...token,
193
- accessToken: {
194
- ...token.accessToken,
195
- accessKeyId,
196
- secretAccessKey,
197
- sessionToken,
198
- expiresAt: expiration.toISOString()
199
- },
200
- refreshToken
201
- };
202
- await this.saveToken(updatedToken);
203
- const newAccessToken = updatedToken.accessToken;
204
- return {
205
- accessKeyId: newAccessToken.accessKeyId,
206
- secretAccessKey: newAccessToken.secretAccessKey,
207
- sessionToken: newAccessToken.sessionToken,
208
- accountId: newAccessToken.accountId,
209
- expiration
210
- };
211
- } catch (error) {
212
- if (error.name === "AccessDeniedException") {
213
- const errorType = error.error;
214
- let message;
215
- switch (errorType) {
216
- case "TOKEN_EXPIRED":
217
- message = "Your session has expired. Please reauthenticate.";
218
- break;
219
- case "USER_CREDENTIALS_CHANGED":
220
- message = "Unable to refresh credentials because of a change in your password. Please reauthenticate with your new password.";
221
- break;
222
- case "INSUFFICIENT_PERMISSIONS":
223
- message = "Unable to refresh credentials due to insufficient permissions. You may be missing permission for the 'CreateOAuth2Token' action.";
224
- break;
225
- default:
226
- message = `Failed to refresh token: ${String(error)}. Please re-authenticate using \`aws login\``;
227
- }
228
- throw new CredentialsProviderError(message, { logger: this.logger, tryNextLink: false });
229
- }
230
- throw new CredentialsProviderError(`Failed to refresh token: ${String(error)}. Please re-authenticate using aws login`, { logger: this.logger });
231
- }
232
- }
233
- async loadToken() {
234
- const tokenFilePath = this.getTokenFilePath();
235
- try {
236
- let tokenData;
237
- try {
238
- tokenData = await readFile(tokenFilePath, { ignoreCache: this.init?.ignoreCache });
239
- } catch {
240
- tokenData = await fs.readFile(tokenFilePath, "utf8");
241
- }
242
- const token = JSON.parse(tokenData);
243
- const missingFields = ["accessToken", "clientId", "refreshToken", "dpopKey"].filter((k) => !token[k]);
244
- if (!token.accessToken?.accountId) {
245
- missingFields.push("accountId");
246
- }
247
- if (missingFields.length > 0) {
248
- throw new CredentialsProviderError(`Token validation failed, missing fields: ${missingFields.join(", ")}`, {
249
- logger: this.logger,
250
- tryNextLink: false
251
- });
252
- }
253
- return token;
254
- } catch (error) {
255
- throw new CredentialsProviderError(`Failed to load token from ${tokenFilePath}: ${String(error)}`, {
256
- logger: this.logger,
257
- tryNextLink: false
258
- });
259
- }
260
- }
261
- async saveToken(token) {
262
- const tokenFilePath = this.getTokenFilePath();
263
- const directory = dirname(tokenFilePath);
264
- try {
265
- await fs.mkdir(directory, { recursive: true });
266
- } catch (error) {
267
- }
268
- await fs.writeFile(tokenFilePath, JSON.stringify(token, null, 2), "utf8");
269
- }
270
- getTokenFilePath() {
271
- const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ?? join(homedir(), ".aws", "login", "cache");
272
- const loginSessionBytes = Buffer.from(this.loginSession, "utf8");
273
- const loginSessionSha256 = createHash("sha256").update(loginSessionBytes).digest("hex");
274
- return join(directory, `${loginSessionSha256}.json`);
275
- }
276
- derToRawSignature(derSignature) {
277
- let offset = 2;
278
- if (derSignature[offset] !== 2) {
279
- throw new Error("Invalid DER signature");
280
- }
281
- offset++;
282
- const rLength = derSignature[offset++];
283
- let r = derSignature.subarray(offset, offset + rLength);
284
- offset += rLength;
285
- if (derSignature[offset] !== 2) {
286
- throw new Error("Invalid DER signature");
287
- }
288
- offset++;
289
- const sLength = derSignature[offset++];
290
- let s = derSignature.subarray(offset, offset + sLength);
291
- r = r[0] === 0 ? r.subarray(1) : r;
292
- s = s[0] === 0 ? s.subarray(1) : s;
293
- const rPadded = Buffer.concat([Buffer.alloc(32 - r.length), r]);
294
- const sPadded = Buffer.concat([Buffer.alloc(32 - s.length), s]);
295
- return Buffer.concat([rPadded, sPadded]);
296
- }
297
- createDPoPInterceptor(middlewareStack) {
298
- middlewareStack.add((next) => async (args) => {
299
- if (HttpRequest.isInstance(args.request)) {
300
- const request = args.request;
301
- const actualEndpoint = `${request.protocol}//${request.hostname}${request.port ? `:${request.port}` : ""}${request.path}`;
302
- const dpop = await this.generateDpop(request.method, actualEndpoint);
303
- request.headers = {
304
- ...request.headers,
305
- DPoP: dpop
306
- };
307
- }
308
- return next(args);
309
- }, {
310
- step: "finalizeRequest",
311
- name: "dpopInterceptor",
312
- override: true
313
- });
314
- }
315
- async generateDpop(method = "POST", endpoint) {
316
- const token = await this.loadToken();
317
- try {
318
- const privateKey = createPrivateKey({
319
- key: token.dpopKey,
320
- format: "pem",
321
- type: "sec1"
322
- });
323
- const publicKey = createPublicKey(privateKey);
324
- const publicDer = publicKey.export({ format: "der", type: "spki" });
325
- let pointStart = -1;
326
- for (let i = 0; i < publicDer.length; i++) {
327
- if (publicDer[i] === 4) {
328
- pointStart = i;
329
- break;
330
- }
331
- }
332
- const x = publicDer.slice(pointStart + 1, pointStart + 33);
333
- const y = publicDer.slice(pointStart + 33, pointStart + 65);
334
- const header = {
335
- alg: "ES256",
336
- typ: "dpop+jwt",
337
- jwk: {
338
- kty: "EC",
339
- crv: "P-256",
340
- x: x.toString("base64url"),
341
- y: y.toString("base64url")
342
- }
343
- };
344
- const payload = {
345
- jti: crypto.randomUUID(),
346
- htm: method,
347
- htu: endpoint,
348
- iat: Math.floor(Date.now() / 1e3)
349
- };
350
- const headerB64 = Buffer.from(JSON.stringify(header)).toString("base64url");
351
- const payloadB64 = Buffer.from(JSON.stringify(payload)).toString("base64url");
352
- const message = `${headerB64}.${payloadB64}`;
353
- const asn1Signature = sign("sha256", Buffer.from(message), privateKey);
354
- const rawSignature = this.derToRawSignature(asn1Signature);
355
- const signatureB64 = rawSignature.toString("base64url");
356
- return `${message}.${signatureB64}`;
357
- } catch (error) {
358
- throw new CredentialsProviderError(`Failed to generate Dpop proof: ${error instanceof Error ? error.message : String(error)}`, { logger: this.logger, tryNextLink: false });
359
- }
360
- }
361
- };
362
- __publicField(_LoginCredentialsFetcher, "REFRESH_THRESHOLD", 5 * 60 * 1e3);
363
- var LoginCredentialsFetcher = _LoginCredentialsFetcher;
364
-
365
- // 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
- // 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, callerClientConfig) => {
389
- const credentials = await fromLoginCredentials({
390
- ...options,
391
- profile: profileName
392
- })({ callerClientConfig });
393
- return setCredentialFeature(credentials, "CREDENTIALS_PROFILE_LOGIN", "AC");
394
- };
395
-
396
- // 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) => {
399
- const { fromProcess } = await import("./dist-es-ZGPJUGVW.mjs");
400
- const credentials = await fromProcess({
401
- ...options,
402
- profile
403
- })();
404
- return setCredentialFeature(credentials, "CREDENTIALS_PROFILE_PROCESS", "v");
405
- };
406
-
407
- // node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveSsoCredentials.js
408
- var resolveSsoCredentials = async (profile, profileData, options = {}, callerClientConfig) => {
409
- const { fromSSO } = await import("./dist-es-5ZD454R2.mjs");
410
- return fromSSO({
411
- profile,
412
- logger: options.logger,
413
- parentClientConfig: options.parentClientConfig,
414
- clientConfig: options.clientConfig
415
- })({
416
- callerClientConfig
417
- }).then((creds) => {
418
- if (profileData.sso_session) {
419
- return setCredentialFeature(creds, "CREDENTIALS_PROFILE_SSO", "r");
420
- } else {
421
- return setCredentialFeature(creds, "CREDENTIALS_PROFILE_SSO_LEGACY", "t");
422
- }
423
- });
424
- };
425
- 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");
426
-
427
- // node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveStaticCredentials.js
428
- 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;
429
- var resolveStaticCredentials = async (profile, options) => {
430
- options?.logger?.debug("@aws-sdk/credential-provider-ini - resolveStaticCredentials");
431
- const credentials = {
432
- accessKeyId: profile.aws_access_key_id,
433
- secretAccessKey: profile.aws_secret_access_key,
434
- sessionToken: profile.aws_session_token,
435
- ...profile.aws_credential_scope && { credentialScope: profile.aws_credential_scope },
436
- ...profile.aws_account_id && { accountId: profile.aws_account_id }
437
- };
438
- return setCredentialFeature(credentials, "CREDENTIALS_PROFILE", "n");
439
- };
440
-
441
- // node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveWebIdentityCredentials.js
442
- 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;
443
- var resolveWebIdentityCredentials = async (profile, options, callerClientConfig) => {
444
- const { fromTokenFile } = await import("./dist-es-XFAHNA2L.mjs");
445
- const credentials = await fromTokenFile({
446
- webIdentityTokenFile: profile.web_identity_token_file,
447
- roleArn: profile.role_arn,
448
- roleSessionName: profile.role_session_name,
449
- roleAssumerWithWebIdentity: options.roleAssumerWithWebIdentity,
450
- logger: options.logger,
451
- parentClientConfig: options.parentClientConfig
452
- })({
453
- callerClientConfig
454
- });
455
- return setCredentialFeature(credentials, "CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN", "q");
456
- };
457
-
458
- // node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveProfileData.js
459
- var resolveProfileData = async (profileName, profiles, options, callerClientConfig, visitedProfiles = {}, isAssumeRoleRecursiveCall = false) => {
460
- const data = profiles[profileName];
461
- if (Object.keys(visitedProfiles).length > 0 && isStaticCredsProfile(data)) {
462
- return resolveStaticCredentials(data, options);
463
- }
464
- if (isAssumeRoleRecursiveCall || isAssumeRoleProfile(data, { profile: profileName, logger: options.logger })) {
465
- return resolveAssumeRoleCredentials(profileName, profiles, options, callerClientConfig, visitedProfiles, resolveProfileData);
466
- }
467
- if (isStaticCredsProfile(data)) {
468
- return resolveStaticCredentials(data, options);
469
- }
470
- if (isWebIdentityProfile(data)) {
471
- return resolveWebIdentityCredentials(data, options, callerClientConfig);
472
- }
473
- if (isProcessProfile(data)) {
474
- return resolveProcessCredentials(options, profileName);
475
- }
476
- if (isSsoProfile(data)) {
477
- return await resolveSsoCredentials(profileName, data, options, callerClientConfig);
478
- }
479
- if (isLoginProfile(data)) {
480
- return resolveLoginCredentials(profileName, options, callerClientConfig);
481
- }
482
- throw new CredentialsProviderError(`Could not resolve credentials using profile: [${profileName}] in configuration/credentials file(s).`, { logger: options.logger });
483
- };
484
-
485
- // node_modules/@aws-sdk/credential-provider-ini/dist-es/fromIni.js
486
- var fromIni = (init = {}) => async ({ callerClientConfig } = {}) => {
487
- init.logger?.debug("@aws-sdk/credential-provider-ini - fromIni");
488
- const profiles = await parseKnownFiles(init);
489
- return resolveProfileData(getProfileName({
490
- profile: init.profile ?? callerClientConfig?.profile
491
- }), profiles, init, callerClientConfig);
492
- };
493
- export {
494
- fromIni
495
- };