@ampless/mcp-server 0.2.0-alpha.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.
@@ -0,0 +1,243 @@
1
+ #!/usr/bin/env node
2
+
3
+ // ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/getProfileName.js
4
+ var ENV_PROFILE = "AWS_PROFILE";
5
+ var DEFAULT_PROFILE = "default";
6
+ var getProfileName = (init) => init.profile || process.env[ENV_PROFILE] || DEFAULT_PROFILE;
7
+
8
+ // ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/getConfigFilepath.js
9
+ import { join } from "path";
10
+
11
+ // ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/getHomeDir.js
12
+ import { homedir } from "os";
13
+ import { sep } from "path";
14
+ var homeDirCache = {};
15
+ var getHomeDirCacheKey = () => {
16
+ if (process && process.geteuid) {
17
+ return `${process.geteuid()}`;
18
+ }
19
+ return "DEFAULT";
20
+ };
21
+ var getHomeDir = () => {
22
+ const { HOME, USERPROFILE, HOMEPATH, HOMEDRIVE = `C:${sep}` } = process.env;
23
+ if (HOME)
24
+ return HOME;
25
+ if (USERPROFILE)
26
+ return USERPROFILE;
27
+ if (HOMEPATH)
28
+ return `${HOMEDRIVE}${HOMEPATH}`;
29
+ const homeDirCacheKey = getHomeDirCacheKey();
30
+ if (!homeDirCache[homeDirCacheKey])
31
+ homeDirCache[homeDirCacheKey] = homedir();
32
+ return homeDirCache[homeDirCacheKey];
33
+ };
34
+
35
+ // ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/getConfigFilepath.js
36
+ var ENV_CONFIG_PATH = "AWS_CONFIG_FILE";
37
+ var getConfigFilepath = () => process.env[ENV_CONFIG_PATH] || join(getHomeDir(), ".aws", "config");
38
+
39
+ // ../../node_modules/.pnpm/@smithy+types@4.14.1/node_modules/@smithy/types/dist-es/profile.js
40
+ var IniSectionType;
41
+ (function(IniSectionType2) {
42
+ IniSectionType2["PROFILE"] = "profile";
43
+ IniSectionType2["SSO_SESSION"] = "sso-session";
44
+ IniSectionType2["SERVICES"] = "services";
45
+ })(IniSectionType || (IniSectionType = {}));
46
+
47
+ // ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/loadSharedConfigFiles.js
48
+ import { join as join3 } from "path";
49
+
50
+ // ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/constants.js
51
+ var CONFIG_PREFIX_SEPARATOR = ".";
52
+
53
+ // ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/getConfigData.js
54
+ var getConfigData = (data) => Object.entries(data).filter(([key]) => {
55
+ const indexOfSeparator = key.indexOf(CONFIG_PREFIX_SEPARATOR);
56
+ if (indexOfSeparator === -1) {
57
+ return false;
58
+ }
59
+ return Object.values(IniSectionType).includes(key.substring(0, indexOfSeparator));
60
+ }).reduce((acc, [key, value]) => {
61
+ const indexOfSeparator = key.indexOf(CONFIG_PREFIX_SEPARATOR);
62
+ const updatedKey = key.substring(0, indexOfSeparator) === IniSectionType.PROFILE ? key.substring(indexOfSeparator + 1) : key;
63
+ acc[updatedKey] = value;
64
+ return acc;
65
+ }, {
66
+ ...data.default && { default: data.default }
67
+ });
68
+
69
+ // ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/getCredentialsFilepath.js
70
+ import { join as join2 } from "path";
71
+ var ENV_CREDENTIALS_PATH = "AWS_SHARED_CREDENTIALS_FILE";
72
+ var getCredentialsFilepath = () => process.env[ENV_CREDENTIALS_PATH] || join2(getHomeDir(), ".aws", "credentials");
73
+
74
+ // ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/parseIni.js
75
+ var prefixKeyRegex = /^([\w-]+)\s(["'])?([\w-@\+\.%:/]+)\2$/;
76
+ var profileNameBlockList = ["__proto__", "profile __proto__"];
77
+ var parseIni = (iniData) => {
78
+ const map = {};
79
+ let currentSection;
80
+ let currentSubSection;
81
+ for (const iniLine of iniData.split(/\r?\n/)) {
82
+ const trimmedLine = iniLine.split(/(^|\s)[;#]/)[0].trim();
83
+ const isSection = trimmedLine[0] === "[" && trimmedLine[trimmedLine.length - 1] === "]";
84
+ if (isSection) {
85
+ currentSection = void 0;
86
+ currentSubSection = void 0;
87
+ const sectionName = trimmedLine.substring(1, trimmedLine.length - 1);
88
+ const matches = prefixKeyRegex.exec(sectionName);
89
+ if (matches) {
90
+ const [, prefix, , name] = matches;
91
+ if (Object.values(IniSectionType).includes(prefix)) {
92
+ currentSection = [prefix, name].join(CONFIG_PREFIX_SEPARATOR);
93
+ }
94
+ } else {
95
+ currentSection = sectionName;
96
+ }
97
+ if (profileNameBlockList.includes(sectionName)) {
98
+ throw new Error(`Found invalid profile name "${sectionName}"`);
99
+ }
100
+ } else if (currentSection) {
101
+ const indexOfEqualsSign = trimmedLine.indexOf("=");
102
+ if (![0, -1].includes(indexOfEqualsSign)) {
103
+ const [name, value] = [
104
+ trimmedLine.substring(0, indexOfEqualsSign).trim(),
105
+ trimmedLine.substring(indexOfEqualsSign + 1).trim()
106
+ ];
107
+ if (value === "") {
108
+ currentSubSection = name;
109
+ } else {
110
+ if (currentSubSection && iniLine.trimStart() === iniLine) {
111
+ currentSubSection = void 0;
112
+ }
113
+ map[currentSection] = map[currentSection] || {};
114
+ const key = currentSubSection ? [currentSubSection, name].join(CONFIG_PREFIX_SEPARATOR) : name;
115
+ map[currentSection][key] = value;
116
+ }
117
+ }
118
+ }
119
+ }
120
+ return map;
121
+ };
122
+
123
+ // ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/readFile.js
124
+ import { readFile as fsReadFile } from "fs/promises";
125
+ var filePromises = {};
126
+ var fileIntercept = {};
127
+ var readFile = (path, options) => {
128
+ if (fileIntercept[path] !== void 0) {
129
+ return fileIntercept[path];
130
+ }
131
+ if (!filePromises[path] || options?.ignoreCache) {
132
+ filePromises[path] = fsReadFile(path, "utf8");
133
+ }
134
+ return filePromises[path];
135
+ };
136
+
137
+ // ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/loadSharedConfigFiles.js
138
+ var swallowError = () => ({});
139
+ var loadSharedConfigFiles = async (init = {}) => {
140
+ const { filepath = getCredentialsFilepath(), configFilepath = getConfigFilepath() } = init;
141
+ const homeDir = getHomeDir();
142
+ const relativeHomeDirPrefix = "~/";
143
+ let resolvedFilepath = filepath;
144
+ if (filepath.startsWith(relativeHomeDirPrefix)) {
145
+ resolvedFilepath = join3(homeDir, filepath.slice(2));
146
+ }
147
+ let resolvedConfigFilepath = configFilepath;
148
+ if (configFilepath.startsWith(relativeHomeDirPrefix)) {
149
+ resolvedConfigFilepath = join3(homeDir, configFilepath.slice(2));
150
+ }
151
+ const parsedFiles = await Promise.all([
152
+ readFile(resolvedConfigFilepath, {
153
+ ignoreCache: init.ignoreCache
154
+ }).then(parseIni).then(getConfigData).catch(swallowError),
155
+ readFile(resolvedFilepath, {
156
+ ignoreCache: init.ignoreCache
157
+ }).then(parseIni).catch(swallowError)
158
+ ]);
159
+ return {
160
+ configFile: parsedFiles[0],
161
+ credentialsFile: parsedFiles[1]
162
+ };
163
+ };
164
+
165
+ // ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/getSsoSessionData.js
166
+ var getSsoSessionData = (data) => Object.entries(data).filter(([key]) => key.startsWith(IniSectionType.SSO_SESSION + CONFIG_PREFIX_SEPARATOR)).reduce((acc, [key, value]) => ({ ...acc, [key.substring(key.indexOf(CONFIG_PREFIX_SEPARATOR) + 1)]: value }), {});
167
+
168
+ // ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/loadSsoSessionData.js
169
+ var swallowError2 = () => ({});
170
+ var loadSsoSessionData = async (init = {}) => readFile(init.configFilepath ?? getConfigFilepath()).then(parseIni).then(getSsoSessionData).catch(swallowError2);
171
+
172
+ // ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/mergeConfigFiles.js
173
+ var mergeConfigFiles = (...files) => {
174
+ const merged = {};
175
+ for (const file of files) {
176
+ for (const [key, values] of Object.entries(file)) {
177
+ if (merged[key] !== void 0) {
178
+ Object.assign(merged[key], values);
179
+ } else {
180
+ merged[key] = values;
181
+ }
182
+ }
183
+ }
184
+ return merged;
185
+ };
186
+
187
+ // ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/parseKnownFiles.js
188
+ var parseKnownFiles = async (init) => {
189
+ const parsedFiles = await loadSharedConfigFiles(init);
190
+ return mergeConfigFiles(parsedFiles.configFile, parsedFiles.credentialsFile);
191
+ };
192
+
193
+ // ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/getSSOTokenFromFile.js
194
+ import { readFile as readFile2 } from "fs/promises";
195
+
196
+ // ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/getSSOTokenFilepath.js
197
+ import { createHash } from "crypto";
198
+ import { join as join4 } from "path";
199
+ var getSSOTokenFilepath = (id) => {
200
+ const hasher = createHash("sha1");
201
+ const cacheName = hasher.update(id).digest("hex");
202
+ return join4(getHomeDir(), ".aws", "sso", "cache", `${cacheName}.json`);
203
+ };
204
+
205
+ // ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/getSSOTokenFromFile.js
206
+ var tokenIntercept = {};
207
+ var getSSOTokenFromFile = async (id) => {
208
+ if (tokenIntercept[id]) {
209
+ return tokenIntercept[id];
210
+ }
211
+ const ssoTokenFilepath = getSSOTokenFilepath(id);
212
+ const ssoTokenText = await readFile2(ssoTokenFilepath, "utf8");
213
+ return JSON.parse(ssoTokenText);
214
+ };
215
+
216
+ // ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/externalDataInterceptor.js
217
+ var externalDataInterceptor = {
218
+ getFileRecord() {
219
+ return fileIntercept;
220
+ },
221
+ interceptFile(path, contents) {
222
+ fileIntercept[path] = Promise.resolve(contents);
223
+ },
224
+ getTokenRecord() {
225
+ return tokenIntercept;
226
+ },
227
+ interceptToken(id, contents) {
228
+ tokenIntercept[id] = contents;
229
+ }
230
+ };
231
+
232
+ export {
233
+ ENV_PROFILE,
234
+ getProfileName,
235
+ getSSOTokenFilepath,
236
+ getSSOTokenFromFile,
237
+ CONFIG_PREFIX_SEPARATOR,
238
+ readFile,
239
+ loadSharedConfigFiles,
240
+ loadSsoSessionData,
241
+ parseKnownFiles,
242
+ externalDataInterceptor
243
+ };
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env node
2
+
3
+ // ../../node_modules/.pnpm/@smithy+property-provider@4.2.14/node_modules/@smithy/property-provider/dist-es/ProviderError.js
4
+ var ProviderError = class _ProviderError extends Error {
5
+ name = "ProviderError";
6
+ tryNextLink;
7
+ constructor(message, options = true) {
8
+ let logger;
9
+ let tryNextLink = true;
10
+ if (typeof options === "boolean") {
11
+ logger = void 0;
12
+ tryNextLink = options;
13
+ } else if (options != null && typeof options === "object") {
14
+ logger = options.logger;
15
+ tryNextLink = options.tryNextLink ?? true;
16
+ }
17
+ super(message);
18
+ this.tryNextLink = tryNextLink;
19
+ Object.setPrototypeOf(this, _ProviderError.prototype);
20
+ logger?.debug?.(`@smithy/property-provider ${tryNextLink ? "->" : "(!)"} ${message}`);
21
+ }
22
+ static from(error, options = true) {
23
+ return Object.assign(new this(error.message, options), error);
24
+ }
25
+ };
26
+
27
+ // ../../node_modules/.pnpm/@smithy+property-provider@4.2.14/node_modules/@smithy/property-provider/dist-es/CredentialsProviderError.js
28
+ var CredentialsProviderError = class _CredentialsProviderError extends ProviderError {
29
+ name = "CredentialsProviderError";
30
+ constructor(message, options = true) {
31
+ super(message, options);
32
+ Object.setPrototypeOf(this, _CredentialsProviderError.prototype);
33
+ }
34
+ };
35
+
36
+ export {
37
+ ProviderError,
38
+ CredentialsProviderError
39
+ };
@@ -0,0 +1,381 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ loadConfig,
4
+ parseUrl
5
+ } from "./chunk-GBNV7FEX.js";
6
+ import "./chunk-NZ2AQICN.js";
7
+ import "./chunk-YVOTBVHL.js";
8
+ import {
9
+ CredentialsProviderError,
10
+ ProviderError
11
+ } from "./chunk-ZB7FTU7J.js";
12
+ import "./chunk-LMMQX4CK.js";
13
+
14
+ // ../../node_modules/.pnpm/@smithy+credential-provider-imds@4.2.14/node_modules/@smithy/credential-provider-imds/dist-es/fromContainerMetadata.js
15
+ import { parse } from "url";
16
+
17
+ // ../../node_modules/.pnpm/@smithy+credential-provider-imds@4.2.14/node_modules/@smithy/credential-provider-imds/dist-es/remoteProvider/httpRequest.js
18
+ import { Buffer } from "buffer";
19
+ import { request } from "http";
20
+ function httpRequest(options) {
21
+ return new Promise((resolve, reject) => {
22
+ const req = request({
23
+ method: "GET",
24
+ ...options,
25
+ hostname: options.hostname?.replace(/^\[(.+)\]$/, "$1")
26
+ });
27
+ req.on("error", (err) => {
28
+ reject(Object.assign(new ProviderError("Unable to connect to instance metadata service"), err));
29
+ req.destroy();
30
+ });
31
+ req.on("timeout", () => {
32
+ reject(new ProviderError("TimeoutError from instance metadata service"));
33
+ req.destroy();
34
+ });
35
+ req.on("response", (res) => {
36
+ const { statusCode = 400 } = res;
37
+ if (statusCode < 200 || 300 <= statusCode) {
38
+ reject(Object.assign(new ProviderError("Error response received from instance metadata service"), { statusCode }));
39
+ req.destroy();
40
+ }
41
+ const chunks = [];
42
+ res.on("data", (chunk) => {
43
+ chunks.push(chunk);
44
+ });
45
+ res.on("end", () => {
46
+ resolve(Buffer.concat(chunks));
47
+ req.destroy();
48
+ });
49
+ });
50
+ req.end();
51
+ });
52
+ }
53
+
54
+ // ../../node_modules/.pnpm/@smithy+credential-provider-imds@4.2.14/node_modules/@smithy/credential-provider-imds/dist-es/remoteProvider/ImdsCredentials.js
55
+ var isImdsCredentials = (arg) => Boolean(arg) && typeof arg === "object" && typeof arg.AccessKeyId === "string" && typeof arg.SecretAccessKey === "string" && typeof arg.Token === "string" && typeof arg.Expiration === "string";
56
+ var fromImdsCredentials = (creds) => ({
57
+ accessKeyId: creds.AccessKeyId,
58
+ secretAccessKey: creds.SecretAccessKey,
59
+ sessionToken: creds.Token,
60
+ expiration: new Date(creds.Expiration),
61
+ ...creds.AccountId && { accountId: creds.AccountId }
62
+ });
63
+
64
+ // ../../node_modules/.pnpm/@smithy+credential-provider-imds@4.2.14/node_modules/@smithy/credential-provider-imds/dist-es/remoteProvider/RemoteProviderInit.js
65
+ var DEFAULT_TIMEOUT = 1e3;
66
+ var DEFAULT_MAX_RETRIES = 0;
67
+ var providerConfigFromInit = ({ maxRetries = DEFAULT_MAX_RETRIES, timeout = DEFAULT_TIMEOUT }) => ({ maxRetries, timeout });
68
+
69
+ // ../../node_modules/.pnpm/@smithy+credential-provider-imds@4.2.14/node_modules/@smithy/credential-provider-imds/dist-es/remoteProvider/retry.js
70
+ var retry = (toRetry, maxRetries) => {
71
+ let promise = toRetry();
72
+ for (let i = 0; i < maxRetries; i++) {
73
+ promise = promise.catch(toRetry);
74
+ }
75
+ return promise;
76
+ };
77
+
78
+ // ../../node_modules/.pnpm/@smithy+credential-provider-imds@4.2.14/node_modules/@smithy/credential-provider-imds/dist-es/fromContainerMetadata.js
79
+ var ENV_CMDS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI";
80
+ var ENV_CMDS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI";
81
+ var ENV_CMDS_AUTH_TOKEN = "AWS_CONTAINER_AUTHORIZATION_TOKEN";
82
+ var fromContainerMetadata = (init = {}) => {
83
+ const { timeout, maxRetries } = providerConfigFromInit(init);
84
+ return () => retry(async () => {
85
+ const requestOptions = await getCmdsUri({ logger: init.logger });
86
+ const credsResponse = JSON.parse(await requestFromEcsImds(timeout, requestOptions));
87
+ if (!isImdsCredentials(credsResponse)) {
88
+ throw new CredentialsProviderError("Invalid response received from instance metadata service.", {
89
+ logger: init.logger
90
+ });
91
+ }
92
+ return fromImdsCredentials(credsResponse);
93
+ }, maxRetries);
94
+ };
95
+ var requestFromEcsImds = async (timeout, options) => {
96
+ if (process.env[ENV_CMDS_AUTH_TOKEN]) {
97
+ options.headers = {
98
+ ...options.headers,
99
+ Authorization: process.env[ENV_CMDS_AUTH_TOKEN]
100
+ };
101
+ }
102
+ const buffer = await httpRequest({
103
+ ...options,
104
+ timeout
105
+ });
106
+ return buffer.toString();
107
+ };
108
+ var CMDS_IP = "169.254.170.2";
109
+ var GREENGRASS_HOSTS = {
110
+ localhost: true,
111
+ "127.0.0.1": true
112
+ };
113
+ var GREENGRASS_PROTOCOLS = {
114
+ "http:": true,
115
+ "https:": true
116
+ };
117
+ var getCmdsUri = async ({ logger }) => {
118
+ if (process.env[ENV_CMDS_RELATIVE_URI]) {
119
+ return {
120
+ hostname: CMDS_IP,
121
+ path: process.env[ENV_CMDS_RELATIVE_URI]
122
+ };
123
+ }
124
+ if (process.env[ENV_CMDS_FULL_URI]) {
125
+ const parsed = parse(process.env[ENV_CMDS_FULL_URI]);
126
+ if (!parsed.hostname || !(parsed.hostname in GREENGRASS_HOSTS)) {
127
+ throw new CredentialsProviderError(`${parsed.hostname} is not a valid container metadata service hostname`, {
128
+ tryNextLink: false,
129
+ logger
130
+ });
131
+ }
132
+ if (!parsed.protocol || !(parsed.protocol in GREENGRASS_PROTOCOLS)) {
133
+ throw new CredentialsProviderError(`${parsed.protocol} is not a valid container metadata service protocol`, {
134
+ tryNextLink: false,
135
+ logger
136
+ });
137
+ }
138
+ return {
139
+ ...parsed,
140
+ port: parsed.port ? parseInt(parsed.port, 10) : void 0
141
+ };
142
+ }
143
+ throw new CredentialsProviderError(`The container metadata credential provider cannot be used unless the ${ENV_CMDS_RELATIVE_URI} or ${ENV_CMDS_FULL_URI} environment variable is set`, {
144
+ tryNextLink: false,
145
+ logger
146
+ });
147
+ };
148
+
149
+ // ../../node_modules/.pnpm/@smithy+credential-provider-imds@4.2.14/node_modules/@smithy/credential-provider-imds/dist-es/error/InstanceMetadataV1FallbackError.js
150
+ var InstanceMetadataV1FallbackError = class _InstanceMetadataV1FallbackError extends CredentialsProviderError {
151
+ tryNextLink;
152
+ name = "InstanceMetadataV1FallbackError";
153
+ constructor(message, tryNextLink = true) {
154
+ super(message, tryNextLink);
155
+ this.tryNextLink = tryNextLink;
156
+ Object.setPrototypeOf(this, _InstanceMetadataV1FallbackError.prototype);
157
+ }
158
+ };
159
+
160
+ // ../../node_modules/.pnpm/@smithy+credential-provider-imds@4.2.14/node_modules/@smithy/credential-provider-imds/dist-es/config/Endpoint.js
161
+ var Endpoint;
162
+ (function(Endpoint2) {
163
+ Endpoint2["IPv4"] = "http://169.254.169.254";
164
+ Endpoint2["IPv6"] = "http://[fd00:ec2::254]";
165
+ })(Endpoint || (Endpoint = {}));
166
+
167
+ // ../../node_modules/.pnpm/@smithy+credential-provider-imds@4.2.14/node_modules/@smithy/credential-provider-imds/dist-es/config/EndpointConfigOptions.js
168
+ var ENV_ENDPOINT_NAME = "AWS_EC2_METADATA_SERVICE_ENDPOINT";
169
+ var CONFIG_ENDPOINT_NAME = "ec2_metadata_service_endpoint";
170
+ var ENDPOINT_CONFIG_OPTIONS = {
171
+ environmentVariableSelector: (env) => env[ENV_ENDPOINT_NAME],
172
+ configFileSelector: (profile) => profile[CONFIG_ENDPOINT_NAME],
173
+ default: void 0
174
+ };
175
+
176
+ // ../../node_modules/.pnpm/@smithy+credential-provider-imds@4.2.14/node_modules/@smithy/credential-provider-imds/dist-es/config/EndpointMode.js
177
+ var EndpointMode;
178
+ (function(EndpointMode2) {
179
+ EndpointMode2["IPv4"] = "IPv4";
180
+ EndpointMode2["IPv6"] = "IPv6";
181
+ })(EndpointMode || (EndpointMode = {}));
182
+
183
+ // ../../node_modules/.pnpm/@smithy+credential-provider-imds@4.2.14/node_modules/@smithy/credential-provider-imds/dist-es/config/EndpointModeConfigOptions.js
184
+ var ENV_ENDPOINT_MODE_NAME = "AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE";
185
+ var CONFIG_ENDPOINT_MODE_NAME = "ec2_metadata_service_endpoint_mode";
186
+ var ENDPOINT_MODE_CONFIG_OPTIONS = {
187
+ environmentVariableSelector: (env) => env[ENV_ENDPOINT_MODE_NAME],
188
+ configFileSelector: (profile) => profile[CONFIG_ENDPOINT_MODE_NAME],
189
+ default: EndpointMode.IPv4
190
+ };
191
+
192
+ // ../../node_modules/.pnpm/@smithy+credential-provider-imds@4.2.14/node_modules/@smithy/credential-provider-imds/dist-es/utils/getInstanceMetadataEndpoint.js
193
+ var getInstanceMetadataEndpoint = async () => parseUrl(await getFromEndpointConfig() || await getFromEndpointModeConfig());
194
+ var getFromEndpointConfig = async () => loadConfig(ENDPOINT_CONFIG_OPTIONS)();
195
+ var getFromEndpointModeConfig = async () => {
196
+ const endpointMode = await loadConfig(ENDPOINT_MODE_CONFIG_OPTIONS)();
197
+ switch (endpointMode) {
198
+ case EndpointMode.IPv4:
199
+ return Endpoint.IPv4;
200
+ case EndpointMode.IPv6:
201
+ return Endpoint.IPv6;
202
+ default:
203
+ throw new Error(`Unsupported endpoint mode: ${endpointMode}. Select from ${Object.values(EndpointMode)}`);
204
+ }
205
+ };
206
+
207
+ // ../../node_modules/.pnpm/@smithy+credential-provider-imds@4.2.14/node_modules/@smithy/credential-provider-imds/dist-es/utils/getExtendedInstanceMetadataCredentials.js
208
+ var STATIC_STABILITY_REFRESH_INTERVAL_SECONDS = 5 * 60;
209
+ var STATIC_STABILITY_REFRESH_INTERVAL_JITTER_WINDOW_SECONDS = 5 * 60;
210
+ var STATIC_STABILITY_DOC_URL = "https://docs.aws.amazon.com/sdkref/latest/guide/feature-static-credentials.html";
211
+ var getExtendedInstanceMetadataCredentials = (credentials, logger) => {
212
+ const refreshInterval = STATIC_STABILITY_REFRESH_INTERVAL_SECONDS + Math.floor(Math.random() * STATIC_STABILITY_REFRESH_INTERVAL_JITTER_WINDOW_SECONDS);
213
+ const newExpiration = new Date(Date.now() + refreshInterval * 1e3);
214
+ logger.warn(`Attempting credential expiration extension due to a credential service availability issue. A refresh of these credentials will be attempted after ${new Date(newExpiration)}.
215
+ For more information, please visit: ` + STATIC_STABILITY_DOC_URL);
216
+ const originalExpiration = credentials.originalExpiration ?? credentials.expiration;
217
+ return {
218
+ ...credentials,
219
+ ...originalExpiration ? { originalExpiration } : {},
220
+ expiration: newExpiration
221
+ };
222
+ };
223
+
224
+ // ../../node_modules/.pnpm/@smithy+credential-provider-imds@4.2.14/node_modules/@smithy/credential-provider-imds/dist-es/utils/staticStabilityProvider.js
225
+ var staticStabilityProvider = (provider, options = {}) => {
226
+ const logger = options?.logger || console;
227
+ let pastCredentials;
228
+ return async () => {
229
+ let credentials;
230
+ try {
231
+ credentials = await provider();
232
+ if (credentials.expiration && credentials.expiration.getTime() < Date.now()) {
233
+ credentials = getExtendedInstanceMetadataCredentials(credentials, logger);
234
+ }
235
+ } catch (e) {
236
+ if (pastCredentials) {
237
+ logger.warn("Credential renew failed: ", e);
238
+ credentials = getExtendedInstanceMetadataCredentials(pastCredentials, logger);
239
+ } else {
240
+ throw e;
241
+ }
242
+ }
243
+ pastCredentials = credentials;
244
+ return credentials;
245
+ };
246
+ };
247
+
248
+ // ../../node_modules/.pnpm/@smithy+credential-provider-imds@4.2.14/node_modules/@smithy/credential-provider-imds/dist-es/fromInstanceMetadata.js
249
+ var IMDS_PATH = "/latest/meta-data/iam/security-credentials/";
250
+ var IMDS_TOKEN_PATH = "/latest/api/token";
251
+ var AWS_EC2_METADATA_V1_DISABLED = "AWS_EC2_METADATA_V1_DISABLED";
252
+ var PROFILE_AWS_EC2_METADATA_V1_DISABLED = "ec2_metadata_v1_disabled";
253
+ var X_AWS_EC2_METADATA_TOKEN = "x-aws-ec2-metadata-token";
254
+ var fromInstanceMetadata = (init = {}) => staticStabilityProvider(getInstanceMetadataProvider(init), { logger: init.logger });
255
+ var getInstanceMetadataProvider = (init = {}) => {
256
+ let disableFetchToken = false;
257
+ const { logger, profile } = init;
258
+ const { timeout, maxRetries } = providerConfigFromInit(init);
259
+ const getCredentials = async (maxRetries2, options) => {
260
+ const isImdsV1Fallback = disableFetchToken || options.headers?.[X_AWS_EC2_METADATA_TOKEN] == null;
261
+ if (isImdsV1Fallback) {
262
+ let fallbackBlockedFromProfile = false;
263
+ let fallbackBlockedFromProcessEnv = false;
264
+ const configValue = await loadConfig({
265
+ environmentVariableSelector: (env) => {
266
+ const envValue = env[AWS_EC2_METADATA_V1_DISABLED];
267
+ fallbackBlockedFromProcessEnv = !!envValue && envValue !== "false";
268
+ if (envValue === void 0) {
269
+ throw new CredentialsProviderError(`${AWS_EC2_METADATA_V1_DISABLED} not set in env, checking config file next.`, { logger: init.logger });
270
+ }
271
+ return fallbackBlockedFromProcessEnv;
272
+ },
273
+ configFileSelector: (profile2) => {
274
+ const profileValue = profile2[PROFILE_AWS_EC2_METADATA_V1_DISABLED];
275
+ fallbackBlockedFromProfile = !!profileValue && profileValue !== "false";
276
+ return fallbackBlockedFromProfile;
277
+ },
278
+ default: false
279
+ }, {
280
+ profile
281
+ })();
282
+ if (init.ec2MetadataV1Disabled || configValue) {
283
+ const causes = [];
284
+ if (init.ec2MetadataV1Disabled)
285
+ causes.push("credential provider initialization (runtime option ec2MetadataV1Disabled)");
286
+ if (fallbackBlockedFromProfile)
287
+ causes.push(`config file profile (${PROFILE_AWS_EC2_METADATA_V1_DISABLED})`);
288
+ if (fallbackBlockedFromProcessEnv)
289
+ causes.push(`process environment variable (${AWS_EC2_METADATA_V1_DISABLED})`);
290
+ throw new InstanceMetadataV1FallbackError(`AWS EC2 Metadata v1 fallback has been blocked by AWS SDK configuration in the following: [${causes.join(", ")}].`);
291
+ }
292
+ }
293
+ const imdsProfile = (await retry(async () => {
294
+ let profile2;
295
+ try {
296
+ profile2 = await getProfile(options);
297
+ } catch (err) {
298
+ if (err.statusCode === 401) {
299
+ disableFetchToken = false;
300
+ }
301
+ throw err;
302
+ }
303
+ return profile2;
304
+ }, maxRetries2)).trim();
305
+ return retry(async () => {
306
+ let creds;
307
+ try {
308
+ creds = await getCredentialsFromProfile(imdsProfile, options, init);
309
+ } catch (err) {
310
+ if (err.statusCode === 401) {
311
+ disableFetchToken = false;
312
+ }
313
+ throw err;
314
+ }
315
+ return creds;
316
+ }, maxRetries2);
317
+ };
318
+ return async () => {
319
+ const endpoint = await getInstanceMetadataEndpoint();
320
+ if (disableFetchToken) {
321
+ logger?.debug("AWS SDK Instance Metadata", "using v1 fallback (no token fetch)");
322
+ return getCredentials(maxRetries, { ...endpoint, timeout });
323
+ } else {
324
+ let token;
325
+ try {
326
+ token = (await getMetadataToken({ ...endpoint, timeout })).toString();
327
+ } catch (error) {
328
+ if (error?.statusCode === 400) {
329
+ throw Object.assign(error, {
330
+ message: "EC2 Metadata token request returned error"
331
+ });
332
+ } else if (error.message === "TimeoutError" || [403, 404, 405].includes(error.statusCode)) {
333
+ disableFetchToken = true;
334
+ }
335
+ logger?.debug("AWS SDK Instance Metadata", "using v1 fallback (initial)");
336
+ return getCredentials(maxRetries, { ...endpoint, timeout });
337
+ }
338
+ return getCredentials(maxRetries, {
339
+ ...endpoint,
340
+ headers: {
341
+ [X_AWS_EC2_METADATA_TOKEN]: token
342
+ },
343
+ timeout
344
+ });
345
+ }
346
+ };
347
+ };
348
+ var getMetadataToken = async (options) => httpRequest({
349
+ ...options,
350
+ path: IMDS_TOKEN_PATH,
351
+ method: "PUT",
352
+ headers: {
353
+ "x-aws-ec2-metadata-token-ttl-seconds": "21600"
354
+ }
355
+ });
356
+ var getProfile = async (options) => (await httpRequest({ ...options, path: IMDS_PATH })).toString();
357
+ var getCredentialsFromProfile = async (profile, options, init) => {
358
+ const credentialsResponse = JSON.parse((await httpRequest({
359
+ ...options,
360
+ path: IMDS_PATH + profile
361
+ })).toString());
362
+ if (!isImdsCredentials(credentialsResponse)) {
363
+ throw new CredentialsProviderError("Invalid response received from instance metadata service.", {
364
+ logger: init.logger
365
+ });
366
+ }
367
+ return fromImdsCredentials(credentialsResponse);
368
+ };
369
+ export {
370
+ DEFAULT_MAX_RETRIES,
371
+ DEFAULT_TIMEOUT,
372
+ ENV_CMDS_AUTH_TOKEN,
373
+ ENV_CMDS_FULL_URI,
374
+ ENV_CMDS_RELATIVE_URI,
375
+ Endpoint,
376
+ fromContainerMetadata,
377
+ fromInstanceMetadata,
378
+ getInstanceMetadataEndpoint,
379
+ httpRequest,
380
+ providerConfigFromInit
381
+ };