skill-tree 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/bowser-XBWM4HVL.mjs +2821 -0
  2. package/dist/chunk-3MV4GQ3N.mjs +19 -0
  3. package/dist/chunk-6AZMD3Q3.mjs +1243 -0
  4. package/dist/chunk-7IHYDFWW.mjs +163 -0
  5. package/dist/chunk-GBIK7WMX.mjs +9293 -0
  6. package/dist/chunk-GFK5SZRJ.mjs +580 -0
  7. package/dist/chunk-GPN6UQVR.mjs +9238 -0
  8. package/dist/chunk-M4RPUUZT.mjs +3156 -0
  9. package/dist/chunk-MBF2MJS5.mjs +1230 -0
  10. package/dist/chunk-MR4TVINH.mjs +1234 -0
  11. package/dist/chunk-OOECXYLU.mjs +1379 -0
  12. package/dist/chunk-PJJJQXJL.mjs +1174 -0
  13. package/dist/chunk-PK3BAIFW.mjs +9294 -0
  14. package/dist/chunk-TENXZJB3.mjs +349 -0
  15. package/dist/chunk-VNZSS2WY.mjs +1057 -0
  16. package/dist/chunk-WJP5XYS7.mjs +2102 -0
  17. package/dist/chunk-WX6N7KNO.mjs +1239 -0
  18. package/dist/chunk-YDNGMDXC.mjs +9294 -0
  19. package/dist/chunk-YJ6NZQLT.mjs +9237 -0
  20. package/dist/chunk-YWRKGXK4.mjs +9300 -0
  21. package/dist/chunk-ZI4AIAWQ.mjs +46 -0
  22. package/dist/cli/index.js +6 -1
  23. package/dist/cli/index.mjs +2 -2
  24. package/dist/dist-es-27NPMXP7.mjs +22 -0
  25. package/dist/dist-es-5QD5QJS2.mjs +495 -0
  26. package/dist/dist-es-5ZD454R2.mjs +317 -0
  27. package/dist/dist-es-DYHMPEKZ.mjs +170 -0
  28. package/dist/dist-es-L5AMJHSY.mjs +935 -0
  29. package/dist/dist-es-OK2J7EV3.mjs +378 -0
  30. package/dist/dist-es-XFAHNA2L.mjs +69 -0
  31. package/dist/dist-es-XPNJAJI7.mjs +4437 -0
  32. package/dist/dist-es-Y4JPNLF3.mjs +6077 -0
  33. package/dist/dist-es-ZGPJUGVW.mjs +87 -0
  34. package/dist/event-streams-6MFHPNRF.mjs +42 -0
  35. package/dist/index.d.mts +116 -2
  36. package/dist/index.d.ts +116 -2
  37. package/dist/index.js +8 -1
  38. package/dist/index.mjs +4 -2
  39. package/dist/lib-B245IUXF.mjs +778 -0
  40. package/dist/loadSso-CAWKILED.mjs +579 -0
  41. package/dist/signin-KUENA7ZD.mjs +743 -0
  42. package/dist/sqlite-5LHEQTBD.mjs +7 -0
  43. package/dist/sqlite-BZK5GF76.mjs +7 -0
  44. package/dist/sqlite-V6GFGHTD.mjs +7 -0
  45. package/dist/sqlite-ZKQKQKPT.mjs +7 -0
  46. package/dist/sso-oidc-3VGFPMFD.mjs +832 -0
  47. package/dist/sts-QGXULWRT.mjs +6290 -0
  48. package/dist/sync-4DCV43GA.mjs +15 -0
  49. package/package.json +1 -1
@@ -0,0 +1,46 @@
1
+ import {
2
+ setCredentialFeature
3
+ } from "./chunk-M4RPUUZT.mjs";
4
+ import {
5
+ CredentialsProviderError
6
+ } from "./chunk-WJP5XYS7.mjs";
7
+
8
+ // node_modules/@aws-sdk/credential-provider-env/dist-es/fromEnv.js
9
+ var ENV_KEY = "AWS_ACCESS_KEY_ID";
10
+ var ENV_SECRET = "AWS_SECRET_ACCESS_KEY";
11
+ var ENV_SESSION = "AWS_SESSION_TOKEN";
12
+ var ENV_EXPIRATION = "AWS_CREDENTIAL_EXPIRATION";
13
+ var ENV_CREDENTIAL_SCOPE = "AWS_CREDENTIAL_SCOPE";
14
+ var ENV_ACCOUNT_ID = "AWS_ACCOUNT_ID";
15
+ var fromEnv = (init) => async () => {
16
+ init?.logger?.debug("@aws-sdk/credential-provider-env - fromEnv");
17
+ const accessKeyId = process.env[ENV_KEY];
18
+ const secretAccessKey = process.env[ENV_SECRET];
19
+ const sessionToken = process.env[ENV_SESSION];
20
+ const expiry = process.env[ENV_EXPIRATION];
21
+ const credentialScope = process.env[ENV_CREDENTIAL_SCOPE];
22
+ const accountId = process.env[ENV_ACCOUNT_ID];
23
+ if (accessKeyId && secretAccessKey) {
24
+ const credentials = {
25
+ accessKeyId,
26
+ secretAccessKey,
27
+ ...sessionToken && { sessionToken },
28
+ ...expiry && { expiration: new Date(expiry) },
29
+ ...credentialScope && { credentialScope },
30
+ ...accountId && { accountId }
31
+ };
32
+ setCredentialFeature(credentials, "CREDENTIALS_ENV_VARS", "g");
33
+ return credentials;
34
+ }
35
+ throw new CredentialsProviderError("Unable to find environment variable credentials.", { logger: init?.logger });
36
+ };
37
+
38
+ export {
39
+ ENV_KEY,
40
+ ENV_SECRET,
41
+ ENV_SESSION,
42
+ ENV_EXPIRATION,
43
+ ENV_CREDENTIAL_SCOPE,
44
+ ENV_ACCOUNT_ID,
45
+ fromEnv
46
+ };
package/dist/cli/index.js CHANGED
@@ -146,12 +146,17 @@ var init_base = __esm({
146
146
  df.set(t, (df.get(t) ?? 0) + 1);
147
147
  }
148
148
  }
149
+ const requiredTerms = [...new Set(queryTerms)].filter((qt) => (df.get(qt) ?? 0) > 0);
149
150
  const scored = docs.map((doc) => {
150
151
  let score = 0;
151
152
  const tf = /* @__PURE__ */ new Map();
152
153
  for (const t of doc.terms) {
153
154
  tf.set(t, (tf.get(t) ?? 0) + 1);
154
155
  }
156
+ const matchesAll = requiredTerms.every((qt) => (tf.get(qt) ?? 0) > 0);
157
+ if (!matchesAll) {
158
+ return { skill: doc.skill, score: 0 };
159
+ }
155
160
  for (const qt of queryTerms) {
156
161
  const termDf = df.get(qt) ?? 0;
157
162
  if (termDf === 0) continue;
@@ -9844,7 +9849,7 @@ async function importLocalSkillDir(dirPath, bank, options = {}) {
9844
9849
  }
9845
9850
 
9846
9851
  // src/index.ts
9847
- var VERSION = "0.2.0";
9852
+ var VERSION = "0.3.0";
9848
9853
 
9849
9854
  // src/cli/commands/list.ts
9850
9855
  var import_commander = require("commander");
@@ -17,8 +17,8 @@ import {
17
17
  importSkillMdFile,
18
18
  loadConfig,
19
19
  parseIndexerExport
20
- } from "../chunk-P5GJJ4JB.mjs";
21
- import "../chunk-4TFMKAVC.mjs";
20
+ } from "../chunk-GPN6UQVR.mjs";
21
+ import "../chunk-MBF2MJS5.mjs";
22
22
  import "../chunk-MBIGW6KU.mjs";
23
23
  import "../chunk-QZ7TP4HQ.mjs";
24
24
 
@@ -0,0 +1,22 @@
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
+ };
@@ -0,0 +1,495 @@
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
+ };