@smithy/credential-provider-imds 4.3.5 → 4.3.7
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 +14 -13
- package/dist-es/fromContainerMetadata.js +14 -13
- package/package.json +3 -3
package/dist-cjs/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var node_url = require('node:url');
|
|
4
3
|
var config = require('@smithy/core/config');
|
|
5
4
|
var node_http = require('node:http');
|
|
6
5
|
var protocols = require('@smithy/core/protocols');
|
|
@@ -95,14 +94,8 @@ const requestFromEcsImds = async (timeout, options) => {
|
|
|
95
94
|
return buffer.toString();
|
|
96
95
|
};
|
|
97
96
|
const CMDS_IP = "169.254.170.2";
|
|
98
|
-
const GREENGRASS_HOSTS =
|
|
99
|
-
|
|
100
|
-
"127.0.0.1": true,
|
|
101
|
-
};
|
|
102
|
-
const GREENGRASS_PROTOCOLS = {
|
|
103
|
-
"http:": true,
|
|
104
|
-
"https:": true,
|
|
105
|
-
};
|
|
97
|
+
const GREENGRASS_HOSTS = new Set(["localhost", "127.0.0.1"]);
|
|
98
|
+
const GREENGRASS_PROTOCOLS = new Set(["http:", "https:"]);
|
|
106
99
|
const getCmdsUri = async ({ logger }) => {
|
|
107
100
|
if (process.env[ENV_CMDS_RELATIVE_URI]) {
|
|
108
101
|
return {
|
|
@@ -111,21 +104,29 @@ const getCmdsUri = async ({ logger }) => {
|
|
|
111
104
|
};
|
|
112
105
|
}
|
|
113
106
|
if (process.env[ENV_CMDS_FULL_URI]) {
|
|
114
|
-
|
|
115
|
-
|
|
107
|
+
let parsed;
|
|
108
|
+
try {
|
|
109
|
+
parsed = new URL(process.env[ENV_CMDS_FULL_URI]);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
throw new config.CredentialsProviderError(`${process.env[ENV_CMDS_FULL_URI]} is not a valid container metadata service URL`, { tryNextLink: false, logger });
|
|
113
|
+
}
|
|
114
|
+
if (!parsed.hostname || !GREENGRASS_HOSTS.has(parsed.hostname)) {
|
|
116
115
|
throw new config.CredentialsProviderError(`${parsed.hostname} is not a valid container metadata service hostname`, {
|
|
117
116
|
tryNextLink: false,
|
|
118
117
|
logger,
|
|
119
118
|
});
|
|
120
119
|
}
|
|
121
|
-
if (!parsed.protocol || !(parsed.protocol
|
|
120
|
+
if (!parsed.protocol || !GREENGRASS_PROTOCOLS.has(parsed.protocol)) {
|
|
122
121
|
throw new config.CredentialsProviderError(`${parsed.protocol} is not a valid container metadata service protocol`, {
|
|
123
122
|
tryNextLink: false,
|
|
124
123
|
logger,
|
|
125
124
|
});
|
|
126
125
|
}
|
|
127
126
|
return {
|
|
128
|
-
|
|
127
|
+
protocol: parsed.protocol,
|
|
128
|
+
hostname: parsed.hostname,
|
|
129
|
+
path: parsed.pathname + parsed.search,
|
|
129
130
|
port: parsed.port ? parseInt(parsed.port, 10) : undefined,
|
|
130
131
|
};
|
|
131
132
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { parse } from "node:url";
|
|
2
1
|
import { CredentialsProviderError } from "@smithy/core/config";
|
|
3
2
|
import { fromImdsCredentials, isImdsCredentials } from "./remoteProvider/ImdsCredentials";
|
|
4
3
|
import { providerConfigFromInit } from "./remoteProvider/RemoteProviderInit";
|
|
@@ -34,14 +33,8 @@ const requestFromEcsImds = async (timeout, options) => {
|
|
|
34
33
|
return buffer.toString();
|
|
35
34
|
};
|
|
36
35
|
const CMDS_IP = "169.254.170.2";
|
|
37
|
-
const GREENGRASS_HOSTS =
|
|
38
|
-
|
|
39
|
-
"127.0.0.1": true,
|
|
40
|
-
};
|
|
41
|
-
const GREENGRASS_PROTOCOLS = {
|
|
42
|
-
"http:": true,
|
|
43
|
-
"https:": true,
|
|
44
|
-
};
|
|
36
|
+
const GREENGRASS_HOSTS = new Set(["localhost", "127.0.0.1"]);
|
|
37
|
+
const GREENGRASS_PROTOCOLS = new Set(["http:", "https:"]);
|
|
45
38
|
const getCmdsUri = async ({ logger }) => {
|
|
46
39
|
if (process.env[ENV_CMDS_RELATIVE_URI]) {
|
|
47
40
|
return {
|
|
@@ -50,21 +43,29 @@ const getCmdsUri = async ({ logger }) => {
|
|
|
50
43
|
};
|
|
51
44
|
}
|
|
52
45
|
if (process.env[ENV_CMDS_FULL_URI]) {
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
let parsed;
|
|
47
|
+
try {
|
|
48
|
+
parsed = new URL(process.env[ENV_CMDS_FULL_URI]);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
throw new CredentialsProviderError(`${process.env[ENV_CMDS_FULL_URI]} is not a valid container metadata service URL`, { tryNextLink: false, logger });
|
|
52
|
+
}
|
|
53
|
+
if (!parsed.hostname || !GREENGRASS_HOSTS.has(parsed.hostname)) {
|
|
55
54
|
throw new CredentialsProviderError(`${parsed.hostname} is not a valid container metadata service hostname`, {
|
|
56
55
|
tryNextLink: false,
|
|
57
56
|
logger,
|
|
58
57
|
});
|
|
59
58
|
}
|
|
60
|
-
if (!parsed.protocol || !(parsed.protocol
|
|
59
|
+
if (!parsed.protocol || !GREENGRASS_PROTOCOLS.has(parsed.protocol)) {
|
|
61
60
|
throw new CredentialsProviderError(`${parsed.protocol} is not a valid container metadata service protocol`, {
|
|
62
61
|
tryNextLink: false,
|
|
63
62
|
logger,
|
|
64
63
|
});
|
|
65
64
|
}
|
|
66
65
|
return {
|
|
67
|
-
|
|
66
|
+
protocol: parsed.protocol,
|
|
67
|
+
hostname: parsed.hostname,
|
|
68
|
+
path: parsed.pathname + parsed.search,
|
|
68
69
|
port: parsed.port ? parseInt(parsed.port, 10) : undefined,
|
|
69
70
|
};
|
|
70
71
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/credential-provider-imds",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.7",
|
|
4
4
|
"description": "AWS credential provider that sources credentials from the EC2 instance metadata service and ECS container metadata service",
|
|
5
5
|
"main": "./dist-cjs/index.js",
|
|
6
6
|
"module": "./dist-es/index.js",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"license": "Apache-2.0",
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@smithy/core": "^3.24.
|
|
31
|
-
"@smithy/types": "^4.14.
|
|
30
|
+
"@smithy/core": "^3.24.6",
|
|
31
|
+
"@smithy/types": "^4.14.3",
|
|
32
32
|
"tslib": "^2.6.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|