@aws-sdk/middleware-user-agent 3.489.0 → 3.496.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.
@@ -1,10 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveUserAgentConfig = void 0;
4
- function resolveUserAgentConfig(input) {
5
- return {
6
- ...input,
7
- customUserAgent: typeof input.customUserAgent === "string" ? [[input.customUserAgent]] : input.customUserAgent,
8
- };
9
- }
10
- exports.resolveUserAgentConfig = resolveUserAgentConfig;
1
+ module.exports = require("./index.js");
@@ -1,10 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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
- exports.USER_AGENT = "user-agent";
5
- exports.X_AMZ_USER_AGENT = "x-amz-user-agent";
6
- exports.SPACE = " ";
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 = "-";
1
+ module.exports = require("./index.js");
package/dist-cjs/index.js CHANGED
@@ -1,5 +1,122 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./configurations"), exports);
5
- tslib_1.__exportStar(require("./user-agent-middleware"), exports);
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ getUserAgentMiddlewareOptions: () => getUserAgentMiddlewareOptions,
24
+ getUserAgentPlugin: () => getUserAgentPlugin,
25
+ resolveUserAgentConfig: () => resolveUserAgentConfig,
26
+ userAgentMiddleware: () => userAgentMiddleware
27
+ });
28
+ module.exports = __toCommonJS(src_exports);
29
+
30
+ // src/configurations.ts
31
+ function resolveUserAgentConfig(input) {
32
+ return {
33
+ ...input,
34
+ customUserAgent: typeof input.customUserAgent === "string" ? [[input.customUserAgent]] : input.customUserAgent
35
+ };
36
+ }
37
+ __name(resolveUserAgentConfig, "resolveUserAgentConfig");
38
+
39
+ // src/user-agent-middleware.ts
40
+ var import_util_endpoints = require("@aws-sdk/util-endpoints");
41
+ var import_protocol_http = require("@smithy/protocol-http");
42
+
43
+ // src/constants.ts
44
+ var USER_AGENT = "user-agent";
45
+ var X_AMZ_USER_AGENT = "x-amz-user-agent";
46
+ var SPACE = " ";
47
+ var UA_NAME_SEPARATOR = "/";
48
+ var UA_NAME_ESCAPE_REGEX = /[^\!\$\%\&\'\*\+\-\.\^\_\`\|\~\d\w]/g;
49
+ var UA_VALUE_ESCAPE_REGEX = /[^\!\$\%\&\'\*\+\-\.\^\_\`\|\~\d\w\#]/g;
50
+ var UA_ESCAPE_CHAR = "-";
51
+
52
+ // src/user-agent-middleware.ts
53
+ var userAgentMiddleware = /* @__PURE__ */ __name((options) => (next, context) => async (args) => {
54
+ var _a, _b;
55
+ const { request } = args;
56
+ if (!import_protocol_http.HttpRequest.isInstance(request))
57
+ return next(args);
58
+ const { headers } = request;
59
+ const userAgent = ((_a = context == null ? void 0 : context.userAgent) == null ? void 0 : _a.map(escapeUserAgent)) || [];
60
+ const defaultUserAgent = (await options.defaultUserAgentProvider()).map(escapeUserAgent);
61
+ const customUserAgent = ((_b = options == null ? void 0 : options.customUserAgent) == null ? void 0 : _b.map(escapeUserAgent)) || [];
62
+ const prefix = (0, import_util_endpoints.getUserAgentPrefix)();
63
+ const sdkUserAgentValue = (prefix ? [prefix] : []).concat([...defaultUserAgent, ...userAgent, ...customUserAgent]).join(SPACE);
64
+ const normalUAValue = [
65
+ ...defaultUserAgent.filter((section) => section.startsWith("aws-sdk-")),
66
+ ...customUserAgent
67
+ ].join(SPACE);
68
+ if (options.runtime !== "browser") {
69
+ if (normalUAValue) {
70
+ headers[X_AMZ_USER_AGENT] = headers[X_AMZ_USER_AGENT] ? `${headers[USER_AGENT]} ${normalUAValue}` : normalUAValue;
71
+ }
72
+ headers[USER_AGENT] = sdkUserAgentValue;
73
+ } else {
74
+ headers[X_AMZ_USER_AGENT] = sdkUserAgentValue;
75
+ }
76
+ return next({
77
+ ...args,
78
+ request
79
+ });
80
+ }, "userAgentMiddleware");
81
+ var escapeUserAgent = /* @__PURE__ */ __name((userAgentPair) => {
82
+ var _a;
83
+ const name = userAgentPair[0].split(UA_NAME_SEPARATOR).map((part) => part.replace(UA_NAME_ESCAPE_REGEX, UA_ESCAPE_CHAR)).join(UA_NAME_SEPARATOR);
84
+ const version = (_a = userAgentPair[1]) == null ? void 0 : _a.replace(UA_VALUE_ESCAPE_REGEX, UA_ESCAPE_CHAR);
85
+ const prefixSeparatorIndex = name.indexOf(UA_NAME_SEPARATOR);
86
+ const prefix = name.substring(0, prefixSeparatorIndex);
87
+ let uaName = name.substring(prefixSeparatorIndex + 1);
88
+ if (prefix === "api") {
89
+ uaName = uaName.toLowerCase();
90
+ }
91
+ return [prefix, uaName, version].filter((item) => item && item.length > 0).reduce((acc, item, index) => {
92
+ switch (index) {
93
+ case 0:
94
+ return item;
95
+ case 1:
96
+ return `${acc}/${item}`;
97
+ default:
98
+ return `${acc}#${item}`;
99
+ }
100
+ }, "");
101
+ }, "escapeUserAgent");
102
+ var getUserAgentMiddlewareOptions = {
103
+ name: "getUserAgentMiddleware",
104
+ step: "build",
105
+ priority: "low",
106
+ tags: ["SET_USER_AGENT", "USER_AGENT"],
107
+ override: true
108
+ };
109
+ var getUserAgentPlugin = /* @__PURE__ */ __name((config) => ({
110
+ applyToStack: (clientStack) => {
111
+ clientStack.add(userAgentMiddleware(config), getUserAgentMiddlewareOptions);
112
+ }
113
+ }), "getUserAgentPlugin");
114
+ // Annotate the CommonJS export names for ESM import in node:
115
+
116
+ 0 && (module.exports = {
117
+ getUserAgentMiddlewareOptions,
118
+ getUserAgentPlugin,
119
+ resolveUserAgentConfig,
120
+ userAgentMiddleware
121
+ });
122
+
@@ -1,79 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getUserAgentPlugin = exports.getUserAgentMiddlewareOptions = exports.userAgentMiddleware = void 0;
4
- const util_endpoints_1 = require("@aws-sdk/util-endpoints");
5
- const protocol_http_1 = require("@smithy/protocol-http");
6
- const constants_1 = require("./constants");
7
- const userAgentMiddleware = (options) => (next, context) => async (args) => {
8
- var _a, _b;
9
- const { request } = args;
10
- if (!protocol_http_1.HttpRequest.isInstance(request))
11
- return next(args);
12
- const { headers } = request;
13
- const userAgent = ((_a = context === null || context === void 0 ? void 0 : context.userAgent) === null || _a === void 0 ? void 0 : _a.map(escapeUserAgent)) || [];
14
- const defaultUserAgent = (await options.defaultUserAgentProvider()).map(escapeUserAgent);
15
- const customUserAgent = ((_b = options === null || options === void 0 ? void 0 : options.customUserAgent) === null || _b === void 0 ? void 0 : _b.map(escapeUserAgent)) || [];
16
- const prefix = (0, util_endpoints_1.getUserAgentPrefix)();
17
- const sdkUserAgentValue = (prefix ? [prefix] : [])
18
- .concat([...defaultUserAgent, ...userAgent, ...customUserAgent])
19
- .join(constants_1.SPACE);
20
- const normalUAValue = [
21
- ...defaultUserAgent.filter((section) => section.startsWith("aws-sdk-")),
22
- ...customUserAgent,
23
- ].join(constants_1.SPACE);
24
- if (options.runtime !== "browser") {
25
- if (normalUAValue) {
26
- headers[constants_1.X_AMZ_USER_AGENT] = headers[constants_1.X_AMZ_USER_AGENT]
27
- ? `${headers[constants_1.USER_AGENT]} ${normalUAValue}`
28
- : normalUAValue;
29
- }
30
- headers[constants_1.USER_AGENT] = sdkUserAgentValue;
31
- }
32
- else {
33
- headers[constants_1.X_AMZ_USER_AGENT] = sdkUserAgentValue;
34
- }
35
- return next({
36
- ...args,
37
- request,
38
- });
39
- };
40
- exports.userAgentMiddleware = userAgentMiddleware;
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);
49
- const prefix = name.substring(0, prefixSeparatorIndex);
50
- let uaName = name.substring(prefixSeparatorIndex + 1);
51
- if (prefix === "api") {
52
- uaName = uaName.toLowerCase();
53
- }
54
- return [prefix, uaName, version]
55
- .filter((item) => item && item.length > 0)
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
- }, "");
66
- };
67
- exports.getUserAgentMiddlewareOptions = {
68
- name: "getUserAgentMiddleware",
69
- step: "build",
70
- priority: "low",
71
- tags: ["SET_USER_AGENT", "USER_AGENT"],
72
- override: true,
73
- };
74
- const getUserAgentPlugin = (config) => ({
75
- applyToStack: (clientStack) => {
76
- clientStack.add((0, exports.userAgentMiddleware)(config), exports.getUserAgentMiddlewareOptions);
77
- },
78
- });
79
- exports.getUserAgentPlugin = getUserAgentPlugin;
1
+ module.exports = require("./index.js");
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-user-agent",
3
- "version": "3.489.0",
3
+ "version": "3.496.0",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
6
- "build:cjs": "tsc -p tsconfig.cjs.json",
6
+ "build:cjs": "node ../../scripts/compilation/inline middleware-user-agent",
7
7
  "build:es": "tsc -p tsconfig.es.json",
8
8
  "build:include:deps": "lerna run --scope $npm_package_name --include-dependencies build",
9
9
  "build:types": "tsc -p tsconfig.types.json",
@@ -22,10 +22,10 @@
22
22
  },
23
23
  "license": "Apache-2.0",
24
24
  "dependencies": {
25
- "@aws-sdk/types": "3.489.0",
26
- "@aws-sdk/util-endpoints": "3.489.0",
27
- "@smithy/protocol-http": "^3.0.12",
28
- "@smithy/types": "^2.8.0",
25
+ "@aws-sdk/types": "3.496.0",
26
+ "@aws-sdk/util-endpoints": "3.496.0",
27
+ "@smithy/protocol-http": "^3.1.1",
28
+ "@smithy/types": "^2.9.1",
29
29
  "tslib": "^2.5.0"
30
30
  },
31
31
  "devDependencies": {