@aws-sdk/middleware-user-agent 3.178.0 → 3.183.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/CHANGELOG.md +8 -0
- package/dist-es/configurations.js +4 -2
- package/dist-es/constants.js +4 -4
- package/dist-es/user-agent-middleware.js +38 -47
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @aws-sdk/middleware-user-agent
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [3.178.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.177.0...v3.178.0) (2022-09-23)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @aws-sdk/middleware-user-agent
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
export function resolveUserAgentConfig(input) {
|
|
3
|
-
return
|
|
2
|
+
return {
|
|
3
|
+
...input,
|
|
4
|
+
customUserAgent: typeof input.customUserAgent === "string" ? [[input.customUserAgent]] : input.customUserAgent,
|
|
5
|
+
};
|
|
4
6
|
}
|
package/dist-es/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
1
|
+
export const USER_AGENT = "user-agent";
|
|
2
|
+
export const X_AMZ_USER_AGENT = "x-amz-user-agent";
|
|
3
|
+
export const SPACE = " ";
|
|
4
|
+
export const UA_ESCAPE_REGEX = /[^\!\#\$\%\&\'\*\+\-\.\^\_\`\|\~\d\w]/g;
|
|
@@ -1,64 +1,55 @@
|
|
|
1
|
-
import { __assign, __awaiter, __generator, __read, __spreadArray } from "tslib";
|
|
2
1
|
import { HttpRequest } from "@aws-sdk/protocol-http";
|
|
3
2
|
import { SPACE, UA_ESCAPE_REGEX, USER_AGENT, X_AMZ_USER_AGENT } from "./constants";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
headers[X_AMZ_USER_AGENT] = sdkUserAgentValue;
|
|
33
|
-
}
|
|
34
|
-
return [2, next(__assign(__assign({}, args), { request: request }))];
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}); };
|
|
38
|
-
};
|
|
3
|
+
export const userAgentMiddleware = (options) => (next, context) => async (args) => {
|
|
4
|
+
const { request } = args;
|
|
5
|
+
if (!HttpRequest.isInstance(request))
|
|
6
|
+
return next(args);
|
|
7
|
+
const { headers } = request;
|
|
8
|
+
const userAgent = context?.userAgent?.map(escapeUserAgent) || [];
|
|
9
|
+
const defaultUserAgent = (await options.defaultUserAgentProvider()).map(escapeUserAgent);
|
|
10
|
+
const customUserAgent = options?.customUserAgent?.map(escapeUserAgent) || [];
|
|
11
|
+
const sdkUserAgentValue = [...defaultUserAgent, ...userAgent, ...customUserAgent].join(SPACE);
|
|
12
|
+
const normalUAValue = [
|
|
13
|
+
...defaultUserAgent.filter((section) => section.startsWith("aws-sdk-")),
|
|
14
|
+
...customUserAgent,
|
|
15
|
+
].join(SPACE);
|
|
16
|
+
if (options.runtime !== "browser") {
|
|
17
|
+
if (normalUAValue) {
|
|
18
|
+
headers[X_AMZ_USER_AGENT] = headers[X_AMZ_USER_AGENT]
|
|
19
|
+
? `${headers[USER_AGENT]} ${normalUAValue}`
|
|
20
|
+
: normalUAValue;
|
|
21
|
+
}
|
|
22
|
+
headers[USER_AGENT] = sdkUserAgentValue;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
headers[X_AMZ_USER_AGENT] = sdkUserAgentValue;
|
|
26
|
+
}
|
|
27
|
+
return next({
|
|
28
|
+
...args,
|
|
29
|
+
request,
|
|
30
|
+
});
|
|
39
31
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
var uaName = name.substring(prefixSeparatorIndex + 1);
|
|
32
|
+
const escapeUserAgent = ([name, version]) => {
|
|
33
|
+
const prefixSeparatorIndex = name.indexOf("/");
|
|
34
|
+
const prefix = name.substring(0, prefixSeparatorIndex);
|
|
35
|
+
let uaName = name.substring(prefixSeparatorIndex + 1);
|
|
45
36
|
if (prefix === "api") {
|
|
46
37
|
uaName = uaName.toLowerCase();
|
|
47
38
|
}
|
|
48
39
|
return [prefix, uaName, version]
|
|
49
|
-
.filter(
|
|
50
|
-
.map(
|
|
40
|
+
.filter((item) => item && item.length > 0)
|
|
41
|
+
.map((item) => item?.replace(UA_ESCAPE_REGEX, "_"))
|
|
51
42
|
.join("/");
|
|
52
43
|
};
|
|
53
|
-
export
|
|
44
|
+
export const getUserAgentMiddlewareOptions = {
|
|
54
45
|
name: "getUserAgentMiddleware",
|
|
55
46
|
step: "build",
|
|
56
47
|
priority: "low",
|
|
57
48
|
tags: ["SET_USER_AGENT", "USER_AGENT"],
|
|
58
49
|
override: true,
|
|
59
50
|
};
|
|
60
|
-
export
|
|
61
|
-
applyToStack:
|
|
51
|
+
export const getUserAgentPlugin = (config) => ({
|
|
52
|
+
applyToStack: (clientStack) => {
|
|
62
53
|
clientStack.add(userAgentMiddleware(config), getUserAgentMiddlewareOptions);
|
|
63
54
|
},
|
|
64
|
-
});
|
|
55
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-user-agent",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.183.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
6
6
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@aws-sdk/protocol-http": "3.
|
|
24
|
-
"@aws-sdk/types": "3.
|
|
23
|
+
"@aws-sdk/protocol-http": "3.183.0",
|
|
24
|
+
"@aws-sdk/types": "3.183.0",
|
|
25
25
|
"tslib": "^2.3.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@aws-sdk/middleware-stack": "3.
|
|
28
|
+
"@aws-sdk/middleware-stack": "3.183.0",
|
|
29
29
|
"@tsconfig/recommended": "1.0.1",
|
|
30
30
|
"concurrently": "7.0.0",
|
|
31
31
|
"downlevel-dts": "0.10.1",
|