@aws-sdk/ec2-metadata-service 3.721.0 → 3.726.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.
- package/dist-cjs/index.js +15 -13
- package/dist-es/MetadataService.js +2 -0
- package/package.json +11 -11
package/dist-cjs/index.js
CHANGED
|
@@ -55,29 +55,33 @@ var IMDSv1_DISABLED_SELECTORS = {
|
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
// src/MetadataService.ts
|
|
58
|
-
var
|
|
58
|
+
var MetadataService = class {
|
|
59
|
+
static {
|
|
60
|
+
__name(this, "MetadataService");
|
|
61
|
+
}
|
|
62
|
+
disableFetchToken;
|
|
63
|
+
config;
|
|
59
64
|
/**
|
|
60
65
|
* Creates a new MetadataService object with a given set of options.
|
|
61
66
|
*/
|
|
62
67
|
constructor(options = {}) {
|
|
63
68
|
this.config = (async () => {
|
|
64
|
-
|
|
65
|
-
const profile = (options == null ? void 0 : options.profile) || process.env.AWS_PROFILE;
|
|
69
|
+
const profile = options?.profile || process.env.AWS_PROFILE;
|
|
66
70
|
return {
|
|
67
71
|
endpoint: options.endpoint ?? await (0, import_node_config_provider.loadConfig)(ENDPOINT_SELECTORS, { profile })(),
|
|
68
72
|
httpOptions: {
|
|
69
|
-
timeout:
|
|
73
|
+
timeout: options?.httpOptions?.timeout || 0
|
|
70
74
|
},
|
|
71
|
-
ec2MetadataV1Disabled:
|
|
75
|
+
ec2MetadataV1Disabled: options?.ec2MetadataV1Disabled ?? await (0, import_node_config_provider.loadConfig)(IMDSv1_DISABLED_SELECTORS, { profile })()
|
|
72
76
|
};
|
|
73
77
|
})();
|
|
74
|
-
this.disableFetchToken =
|
|
78
|
+
this.disableFetchToken = options?.disableFetchToken || false;
|
|
75
79
|
}
|
|
76
80
|
async request(path, options) {
|
|
77
81
|
const { endpoint, ec2MetadataV1Disabled, httpOptions } = await this.config;
|
|
78
82
|
const handler = new import_node_http_handler.NodeHttpHandler({
|
|
79
|
-
requestTimeout: httpOptions
|
|
80
|
-
connectionTimeout: httpOptions
|
|
83
|
+
requestTimeout: httpOptions?.timeout,
|
|
84
|
+
connectionTimeout: httpOptions?.timeout
|
|
81
85
|
});
|
|
82
86
|
const endpointUrl = new URL(endpoint);
|
|
83
87
|
const headers = options.headers || {};
|
|
@@ -115,8 +119,8 @@ var _MetadataService = class _MetadataService {
|
|
|
115
119
|
async fetchMetadataToken() {
|
|
116
120
|
const { endpoint, httpOptions } = await this.config;
|
|
117
121
|
const handler = new import_node_http_handler.NodeHttpHandler({
|
|
118
|
-
requestTimeout: httpOptions
|
|
119
|
-
connectionTimeout: httpOptions
|
|
122
|
+
requestTimeout: httpOptions?.timeout,
|
|
123
|
+
connectionTimeout: httpOptions?.timeout
|
|
120
124
|
});
|
|
121
125
|
const endpointUrl = new URL(endpoint);
|
|
122
126
|
const tokenRequest = new import_protocol_http.HttpRequest({
|
|
@@ -137,7 +141,7 @@ var _MetadataService = class _MetadataService {
|
|
|
137
141
|
throw new Error(`Failed to fetch metadata token with status code ${response.statusCode}`);
|
|
138
142
|
}
|
|
139
143
|
} catch (error) {
|
|
140
|
-
if (
|
|
144
|
+
if (error?.statusCode === 400) {
|
|
141
145
|
throw new Error(`Error fetching metadata token: ${error}`);
|
|
142
146
|
} else if (error.message === "TimeoutError" || [403, 404, 405].includes(error.statusCode)) {
|
|
143
147
|
this.disableFetchToken = true;
|
|
@@ -147,8 +151,6 @@ var _MetadataService = class _MetadataService {
|
|
|
147
151
|
}
|
|
148
152
|
}
|
|
149
153
|
};
|
|
150
|
-
__name(_MetadataService, "MetadataService");
|
|
151
|
-
var MetadataService = _MetadataService;
|
|
152
154
|
// Annotate the CommonJS export names for ESM import in node:
|
|
153
155
|
|
|
154
156
|
0 && (module.exports = {
|
|
@@ -4,6 +4,8 @@ import { HttpRequest } from "@smithy/protocol-http";
|
|
|
4
4
|
import { sdkStreamMixin } from "@smithy/util-stream";
|
|
5
5
|
import { ENDPOINT_SELECTORS, IMDSv1_DISABLED_SELECTORS } from "./ConfigLoaders";
|
|
6
6
|
export class MetadataService {
|
|
7
|
+
disableFetchToken;
|
|
8
|
+
config;
|
|
7
9
|
constructor(options = {}) {
|
|
8
10
|
this.config = (async () => {
|
|
9
11
|
const profile = options?.profile || process.env.AWS_PROFILE;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/ec2-metadata-service",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.726.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
6
6
|
"build:cjs": "node ../../scripts/compilation/inline ec2-metadata-service",
|
|
@@ -23,25 +23,25 @@
|
|
|
23
23
|
"module": "./dist-es/index.js",
|
|
24
24
|
"types": "./dist-types/index.d.ts",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@aws-sdk/types": "3.
|
|
27
|
-
"@smithy/node-config-provider": "^
|
|
28
|
-
"@smithy/node-http-handler": "^
|
|
29
|
-
"@smithy/protocol-http": "^
|
|
30
|
-
"@smithy/types": "^
|
|
31
|
-
"@smithy/util-stream": "^
|
|
26
|
+
"@aws-sdk/types": "3.723.0",
|
|
27
|
+
"@smithy/node-config-provider": "^4.0.0",
|
|
28
|
+
"@smithy/node-http-handler": "^4.0.0",
|
|
29
|
+
"@smithy/protocol-http": "^5.0.0",
|
|
30
|
+
"@smithy/types": "^4.0.0",
|
|
31
|
+
"@smithy/util-stream": "^4.0.0",
|
|
32
32
|
"tslib": "^2.6.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@aws-sdk/credential-providers": "3.
|
|
35
|
+
"@aws-sdk/credential-providers": "3.726.0",
|
|
36
36
|
"@tsconfig/recommended": "1.0.1",
|
|
37
|
-
"@types/node": "^
|
|
37
|
+
"@types/node": "^18.19.69",
|
|
38
38
|
"concurrently": "7.0.0",
|
|
39
39
|
"downlevel-dts": "0.10.1",
|
|
40
40
|
"rimraf": "3.0.2",
|
|
41
|
-
"typescript": "~
|
|
41
|
+
"typescript": "~5.2.2"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|
|
44
|
-
"node": ">=
|
|
44
|
+
"node": ">=18.0.0"
|
|
45
45
|
},
|
|
46
46
|
"typesVersions": {
|
|
47
47
|
"<4.0": {
|