@aws-sdk/middleware-user-agent 3.341.0 → 3.345.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/constants.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.UA_ESCAPE_CHAR = exports.UA_VALUE_ESCAPE_REGEX = exports.UA_NAME_ESCAPE_REGEX = exports.UA_NAME_SEPARATOR = exports.SPACE = exports.X_AMZ_USER_AGENT = exports.USER_AGENT = void 0;
|
|
4
4
|
exports.USER_AGENT = "user-agent";
|
|
5
5
|
exports.X_AMZ_USER_AGENT = "x-amz-user-agent";
|
|
6
6
|
exports.SPACE = " ";
|
|
7
|
-
exports.
|
|
7
|
+
exports.UA_NAME_SEPARATOR = "/";
|
|
8
|
+
exports.UA_NAME_ESCAPE_REGEX = /[^\!\$\%\&\'\*\+\-\.\^\_\`\|\~\d\w]/g;
|
|
9
|
+
exports.UA_VALUE_ESCAPE_REGEX = /[^\!\$\%\&\'\*\+\-\.\^\_\`\|\~\d\w\#]/g;
|
|
10
|
+
exports.UA_ESCAPE_CHAR = "-";
|
|
@@ -38,8 +38,14 @@ const userAgentMiddleware = (options) => (next, context) => async (args) => {
|
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
40
|
exports.userAgentMiddleware = userAgentMiddleware;
|
|
41
|
-
const escapeUserAgent = (
|
|
42
|
-
|
|
41
|
+
const escapeUserAgent = (userAgentPair) => {
|
|
42
|
+
var _a;
|
|
43
|
+
const name = userAgentPair[0]
|
|
44
|
+
.split(constants_1.UA_NAME_SEPARATOR)
|
|
45
|
+
.map((part) => part.replace(constants_1.UA_NAME_ESCAPE_REGEX, constants_1.UA_ESCAPE_CHAR))
|
|
46
|
+
.join(constants_1.UA_NAME_SEPARATOR);
|
|
47
|
+
const version = (_a = userAgentPair[1]) === null || _a === void 0 ? void 0 : _a.replace(constants_1.UA_VALUE_ESCAPE_REGEX, constants_1.UA_ESCAPE_CHAR);
|
|
48
|
+
const prefixSeparatorIndex = name.indexOf(constants_1.UA_NAME_SEPARATOR);
|
|
43
49
|
const prefix = name.substring(0, prefixSeparatorIndex);
|
|
44
50
|
let uaName = name.substring(prefixSeparatorIndex + 1);
|
|
45
51
|
if (prefix === "api") {
|
|
@@ -47,8 +53,16 @@ const escapeUserAgent = ([name, version]) => {
|
|
|
47
53
|
}
|
|
48
54
|
return [prefix, uaName, version]
|
|
49
55
|
.filter((item) => item && item.length > 0)
|
|
50
|
-
.
|
|
51
|
-
|
|
56
|
+
.reduce((acc, item, index) => {
|
|
57
|
+
switch (index) {
|
|
58
|
+
case 0:
|
|
59
|
+
return item;
|
|
60
|
+
case 1:
|
|
61
|
+
return `${acc}/${item}`;
|
|
62
|
+
default:
|
|
63
|
+
return `${acc}#${item}`;
|
|
64
|
+
}
|
|
65
|
+
}, "");
|
|
52
66
|
};
|
|
53
67
|
exports.getUserAgentMiddlewareOptions = {
|
|
54
68
|
name: "getUserAgentMiddleware",
|
package/dist-es/constants.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export const USER_AGENT = "user-agent";
|
|
2
2
|
export const X_AMZ_USER_AGENT = "x-amz-user-agent";
|
|
3
3
|
export const SPACE = " ";
|
|
4
|
-
export const
|
|
4
|
+
export const UA_NAME_SEPARATOR = "/";
|
|
5
|
+
export const UA_NAME_ESCAPE_REGEX = /[^\!\$\%\&\'\*\+\-\.\^\_\`\|\~\d\w]/g;
|
|
6
|
+
export const UA_VALUE_ESCAPE_REGEX = /[^\!\$\%\&\'\*\+\-\.\^\_\`\|\~\d\w\#]/g;
|
|
7
|
+
export const UA_ESCAPE_CHAR = "-";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HttpRequest } from "@aws-sdk/protocol-http";
|
|
2
2
|
import { getUserAgentPrefix } from "@aws-sdk/util-endpoints";
|
|
3
|
-
import { SPACE,
|
|
3
|
+
import { SPACE, UA_ESCAPE_CHAR, UA_NAME_ESCAPE_REGEX, UA_NAME_SEPARATOR, UA_VALUE_ESCAPE_REGEX, USER_AGENT, X_AMZ_USER_AGENT, } from "./constants";
|
|
4
4
|
export const userAgentMiddleware = (options) => (next, context) => async (args) => {
|
|
5
5
|
const { request } = args;
|
|
6
6
|
if (!HttpRequest.isInstance(request))
|
|
@@ -33,8 +33,13 @@ export const userAgentMiddleware = (options) => (next, context) => async (args)
|
|
|
33
33
|
request,
|
|
34
34
|
});
|
|
35
35
|
};
|
|
36
|
-
const escapeUserAgent = (
|
|
37
|
-
const
|
|
36
|
+
const escapeUserAgent = (userAgentPair) => {
|
|
37
|
+
const name = userAgentPair[0]
|
|
38
|
+
.split(UA_NAME_SEPARATOR)
|
|
39
|
+
.map((part) => part.replace(UA_NAME_ESCAPE_REGEX, UA_ESCAPE_CHAR))
|
|
40
|
+
.join(UA_NAME_SEPARATOR);
|
|
41
|
+
const version = userAgentPair[1]?.replace(UA_VALUE_ESCAPE_REGEX, UA_ESCAPE_CHAR);
|
|
42
|
+
const prefixSeparatorIndex = name.indexOf(UA_NAME_SEPARATOR);
|
|
38
43
|
const prefix = name.substring(0, prefixSeparatorIndex);
|
|
39
44
|
let uaName = name.substring(prefixSeparatorIndex + 1);
|
|
40
45
|
if (prefix === "api") {
|
|
@@ -42,8 +47,16 @@ const escapeUserAgent = ([name, version]) => {
|
|
|
42
47
|
}
|
|
43
48
|
return [prefix, uaName, version]
|
|
44
49
|
.filter((item) => item && item.length > 0)
|
|
45
|
-
.
|
|
46
|
-
|
|
50
|
+
.reduce((acc, item, index) => {
|
|
51
|
+
switch (index) {
|
|
52
|
+
case 0:
|
|
53
|
+
return item;
|
|
54
|
+
case 1:
|
|
55
|
+
return `${acc}/${item}`;
|
|
56
|
+
default:
|
|
57
|
+
return `${acc}#${item}`;
|
|
58
|
+
}
|
|
59
|
+
}, "");
|
|
47
60
|
};
|
|
48
61
|
export const getUserAgentMiddlewareOptions = {
|
|
49
62
|
name: "getUserAgentMiddleware",
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export declare const USER_AGENT = "user-agent";
|
|
2
2
|
export declare const X_AMZ_USER_AGENT = "x-amz-user-agent";
|
|
3
3
|
export declare const SPACE = " ";
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const UA_NAME_SEPARATOR = "/";
|
|
5
|
+
export declare const UA_NAME_ESCAPE_REGEX: RegExp;
|
|
6
|
+
export declare const UA_VALUE_ESCAPE_REGEX: RegExp;
|
|
7
|
+
export declare const UA_ESCAPE_CHAR = "-";
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export declare const USER_AGENT = "user-agent";
|
|
2
2
|
export declare const X_AMZ_USER_AGENT = "x-amz-user-agent";
|
|
3
3
|
export declare const SPACE = " ";
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const UA_NAME_SEPARATOR = "/";
|
|
5
|
+
export declare const UA_NAME_ESCAPE_REGEX: RegExp;
|
|
6
|
+
export declare const UA_VALUE_ESCAPE_REGEX: RegExp;
|
|
7
|
+
export declare const UA_ESCAPE_CHAR = "-";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-user-agent",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.345.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",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "Apache-2.0",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@aws-sdk/protocol-http": "3.
|
|
25
|
-
"@aws-sdk/types": "3.
|
|
26
|
-
"@aws-sdk/util-endpoints": "3.
|
|
24
|
+
"@aws-sdk/protocol-http": "3.342.0",
|
|
25
|
+
"@aws-sdk/types": "3.342.0",
|
|
26
|
+
"@aws-sdk/util-endpoints": "3.342.0",
|
|
27
27
|
"tslib": "^2.5.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|