@aws-sdk/credential-provider-http 3.972.56 → 3.972.57
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 +16 -10
- package/dist-es/fromHttp/fromHttp.js +16 -10
- package/package.json +2 -2
package/dist-cjs/index.js
CHANGED
|
@@ -123,19 +123,19 @@ const fromHttp = (options = {}) => {
|
|
|
123
123
|
if (relative && full) {
|
|
124
124
|
warn("@aws-sdk/credential-provider-http: " +
|
|
125
125
|
"you have set both awsContainerCredentialsRelativeUri and awsContainerCredentialsFullUri.");
|
|
126
|
-
warn("
|
|
126
|
+
warn("awsContainerCredentialsRelativeUri will take precedence.");
|
|
127
127
|
}
|
|
128
128
|
if (token && tokenFile) {
|
|
129
129
|
warn("@aws-sdk/credential-provider-http: " +
|
|
130
130
|
"you have set both awsContainerAuthorizationToken and awsContainerAuthorizationTokenFile.");
|
|
131
|
-
warn("
|
|
131
|
+
warn("awsContainerAuthorizationTokenFile will take precedence.");
|
|
132
132
|
}
|
|
133
|
-
if (
|
|
134
|
-
host = full;
|
|
135
|
-
}
|
|
136
|
-
else if (relative) {
|
|
133
|
+
if (relative) {
|
|
137
134
|
host = `${DEFAULT_LINK_LOCAL_HOST}${relative}`;
|
|
138
135
|
}
|
|
136
|
+
else if (full) {
|
|
137
|
+
host = full;
|
|
138
|
+
}
|
|
139
139
|
else {
|
|
140
140
|
throw new CredentialsProviderError(`No HTTP credential provider host provided.
|
|
141
141
|
Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.`, { logger: options.logger });
|
|
@@ -146,11 +146,11 @@ Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
|
|
|
146
146
|
const requestTimeout = options.timeout ?? 1000;
|
|
147
147
|
const provider = retryWrapper(async () => {
|
|
148
148
|
const request = createGetRequest(url);
|
|
149
|
-
if (
|
|
150
|
-
request.headers.Authorization =
|
|
149
|
+
if (tokenFile) {
|
|
150
|
+
request.headers.Authorization = validateToken((await fs.readFile(tokenFile)).toString());
|
|
151
151
|
}
|
|
152
|
-
else if (
|
|
153
|
-
request.headers.Authorization = (
|
|
152
|
+
else if (token) {
|
|
153
|
+
request.headers.Authorization = validateToken(token);
|
|
154
154
|
}
|
|
155
155
|
try {
|
|
156
156
|
const result = await requestHandler.handle(request, { requestTimeout });
|
|
@@ -169,5 +169,11 @@ Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
|
|
|
169
169
|
}
|
|
170
170
|
};
|
|
171
171
|
};
|
|
172
|
+
const validateToken = (token) => {
|
|
173
|
+
if (token.includes("\r\n")) {
|
|
174
|
+
throw new CredentialsProviderError("Authorization token contains invalid \\r\\n sequence.");
|
|
175
|
+
}
|
|
176
|
+
return token;
|
|
177
|
+
};
|
|
172
178
|
|
|
173
179
|
exports.fromHttp = fromHttp;
|
|
@@ -23,19 +23,19 @@ export const fromHttp = (options = {}) => {
|
|
|
23
23
|
if (relative && full) {
|
|
24
24
|
warn("@aws-sdk/credential-provider-http: " +
|
|
25
25
|
"you have set both awsContainerCredentialsRelativeUri and awsContainerCredentialsFullUri.");
|
|
26
|
-
warn("
|
|
26
|
+
warn("awsContainerCredentialsRelativeUri will take precedence.");
|
|
27
27
|
}
|
|
28
28
|
if (token && tokenFile) {
|
|
29
29
|
warn("@aws-sdk/credential-provider-http: " +
|
|
30
30
|
"you have set both awsContainerAuthorizationToken and awsContainerAuthorizationTokenFile.");
|
|
31
|
-
warn("
|
|
31
|
+
warn("awsContainerAuthorizationTokenFile will take precedence.");
|
|
32
32
|
}
|
|
33
|
-
if (
|
|
34
|
-
host = full;
|
|
35
|
-
}
|
|
36
|
-
else if (relative) {
|
|
33
|
+
if (relative) {
|
|
37
34
|
host = `${DEFAULT_LINK_LOCAL_HOST}${relative}`;
|
|
38
35
|
}
|
|
36
|
+
else if (full) {
|
|
37
|
+
host = full;
|
|
38
|
+
}
|
|
39
39
|
else {
|
|
40
40
|
throw new CredentialsProviderError(`No HTTP credential provider host provided.
|
|
41
41
|
Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.`, { logger: options.logger });
|
|
@@ -46,11 +46,11 @@ Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
|
|
|
46
46
|
const requestTimeout = options.timeout ?? 1000;
|
|
47
47
|
const provider = retryWrapper(async () => {
|
|
48
48
|
const request = createGetRequest(url);
|
|
49
|
-
if (
|
|
50
|
-
request.headers.Authorization =
|
|
49
|
+
if (tokenFile) {
|
|
50
|
+
request.headers.Authorization = validateToken((await fs.readFile(tokenFile)).toString());
|
|
51
51
|
}
|
|
52
|
-
else if (
|
|
53
|
-
request.headers.Authorization = (
|
|
52
|
+
else if (token) {
|
|
53
|
+
request.headers.Authorization = validateToken(token);
|
|
54
54
|
}
|
|
55
55
|
try {
|
|
56
56
|
const result = await requestHandler.handle(request, { requestTimeout });
|
|
@@ -69,3 +69,9 @@ Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
|
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
|
+
const validateToken = (token) => {
|
|
73
|
+
if (token.includes("\r\n")) {
|
|
74
|
+
throw new CredentialsProviderError("Authorization token contains invalid \\r\\n sequence.");
|
|
75
|
+
}
|
|
76
|
+
return token;
|
|
77
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/credential-provider-http",
|
|
3
|
-
"version": "3.972.
|
|
3
|
+
"version": "3.972.57",
|
|
4
4
|
"description": "AWS credential provider for containers and HTTP sources",
|
|
5
5
|
"main": "./dist-cjs/index.js",
|
|
6
6
|
"module": "./dist-es/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"license": "Apache-2.0",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@aws-sdk/core": "^3.974.
|
|
39
|
+
"@aws-sdk/core": "^3.974.29",
|
|
40
40
|
"@aws-sdk/types": "^3.973.15",
|
|
41
41
|
"@smithy/core": "^3.29.0",
|
|
42
42
|
"@smithy/fetch-http-handler": "^5.6.2",
|