Socket
Socket
Sign inDemoInstall

@aws-sdk/middleware-user-agent

Package Overview
Dependencies
9
Maintainers
5
Versions
169
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.489.0 to 3.495.0

11

dist-cjs/configurations.js

@@ -1,10 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveUserAgentConfig = void 0;
function resolveUserAgentConfig(input) {
return {
...input,
customUserAgent: typeof input.customUserAgent === "string" ? [[input.customUserAgent]] : input.customUserAgent,
};
}
exports.resolveUserAgentConfig = resolveUserAgentConfig;
module.exports = require("./index.js");

@@ -1,10 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
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;
exports.USER_AGENT = "user-agent";
exports.X_AMZ_USER_AGENT = "x-amz-user-agent";
exports.SPACE = " ";
exports.UA_NAME_SEPARATOR = "/";
exports.UA_NAME_ESCAPE_REGEX = /[^\!\$\%\&\'\*\+\-\.\^\_\`\|\~\d\w]/g;
exports.UA_VALUE_ESCAPE_REGEX = /[^\!\$\%\&\'\*\+\-\.\^\_\`\|\~\d\w\#]/g;
exports.UA_ESCAPE_CHAR = "-";
module.exports = require("./index.js");

125

dist-cjs/index.js

@@ -1,5 +0,120 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./configurations"), exports);
tslib_1.__exportStar(require("./user-agent-middleware"), exports);
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
getUserAgentMiddlewareOptions: () => getUserAgentMiddlewareOptions,
getUserAgentPlugin: () => getUserAgentPlugin,
resolveUserAgentConfig: () => resolveUserAgentConfig,
userAgentMiddleware: () => userAgentMiddleware
});
module.exports = __toCommonJS(src_exports);
// src/configurations.ts
function resolveUserAgentConfig(input) {
return {
...input,
customUserAgent: typeof input.customUserAgent === "string" ? [[input.customUserAgent]] : input.customUserAgent
};
}
__name(resolveUserAgentConfig, "resolveUserAgentConfig");
// src/user-agent-middleware.ts
var import_util_endpoints = require("@aws-sdk/util-endpoints");
var import_protocol_http = require("@smithy/protocol-http");
// src/constants.ts
var USER_AGENT = "user-agent";
var X_AMZ_USER_AGENT = "x-amz-user-agent";
var SPACE = " ";
var UA_NAME_SEPARATOR = "/";
var UA_NAME_ESCAPE_REGEX = /[^\!\$\%\&\'\*\+\-\.\^\_\`\|\~\d\w]/g;
var UA_VALUE_ESCAPE_REGEX = /[^\!\$\%\&\'\*\+\-\.\^\_\`\|\~\d\w\#]/g;
var UA_ESCAPE_CHAR = "-";
// src/user-agent-middleware.ts
var userAgentMiddleware = /* @__PURE__ */ __name((options) => (next, context) => async (args) => {
var _a, _b;
const { request } = args;
if (!import_protocol_http.HttpRequest.isInstance(request))
return next(args);
const { headers } = request;
const userAgent = ((_a = context == null ? void 0 : context.userAgent) == null ? void 0 : _a.map(escapeUserAgent)) || [];
const defaultUserAgent = (await options.defaultUserAgentProvider()).map(escapeUserAgent);
const customUserAgent = ((_b = options == null ? void 0 : options.customUserAgent) == null ? void 0 : _b.map(escapeUserAgent)) || [];
const prefix = (0, import_util_endpoints.getUserAgentPrefix)();
const sdkUserAgentValue = (prefix ? [prefix] : []).concat([...defaultUserAgent, ...userAgent, ...customUserAgent]).join(SPACE);
const normalUAValue = [
...defaultUserAgent.filter((section) => section.startsWith("aws-sdk-")),
...customUserAgent
].join(SPACE);
if (options.runtime !== "browser") {
if (normalUAValue) {
headers[X_AMZ_USER_AGENT] = headers[X_AMZ_USER_AGENT] ? `${headers[USER_AGENT]} ${normalUAValue}` : normalUAValue;
}
headers[USER_AGENT] = sdkUserAgentValue;
} else {
headers[X_AMZ_USER_AGENT] = sdkUserAgentValue;
}
return next({
...args,
request
});
}, "userAgentMiddleware");
var escapeUserAgent = /* @__PURE__ */ __name((userAgentPair) => {
var _a;
const name = userAgentPair[0].split(UA_NAME_SEPARATOR).map((part) => part.replace(UA_NAME_ESCAPE_REGEX, UA_ESCAPE_CHAR)).join(UA_NAME_SEPARATOR);
const version = (_a = userAgentPair[1]) == null ? void 0 : _a.replace(UA_VALUE_ESCAPE_REGEX, UA_ESCAPE_CHAR);
const prefixSeparatorIndex = name.indexOf(UA_NAME_SEPARATOR);
const prefix = name.substring(0, prefixSeparatorIndex);
let uaName = name.substring(prefixSeparatorIndex + 1);
if (prefix === "api") {
uaName = uaName.toLowerCase();
}
return [prefix, uaName, version].filter((item) => item && item.length > 0).reduce((acc, item, index) => {
switch (index) {
case 0:
return item;
case 1:
return `${acc}/${item}`;
default:
return `${acc}#${item}`;
}
}, "");
}, "escapeUserAgent");
var getUserAgentMiddlewareOptions = {
name: "getUserAgentMiddleware",
step: "build",
priority: "low",
tags: ["SET_USER_AGENT", "USER_AGENT"],
override: true
};
var getUserAgentPlugin = /* @__PURE__ */ __name((config) => ({
applyToStack: (clientStack) => {
clientStack.add(userAgentMiddleware(config), getUserAgentMiddlewareOptions);
}
}), "getUserAgentPlugin");
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
getUserAgentMiddlewareOptions,
getUserAgentPlugin,
resolveUserAgentConfig,
userAgentMiddleware
});

@@ -1,79 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getUserAgentPlugin = exports.getUserAgentMiddlewareOptions = exports.userAgentMiddleware = void 0;
const util_endpoints_1 = require("@aws-sdk/util-endpoints");
const protocol_http_1 = require("@smithy/protocol-http");
const constants_1 = require("./constants");
const userAgentMiddleware = (options) => (next, context) => async (args) => {
var _a, _b;
const { request } = args;
if (!protocol_http_1.HttpRequest.isInstance(request))
return next(args);
const { headers } = request;
const userAgent = ((_a = context === null || context === void 0 ? void 0 : context.userAgent) === null || _a === void 0 ? void 0 : _a.map(escapeUserAgent)) || [];
const defaultUserAgent = (await options.defaultUserAgentProvider()).map(escapeUserAgent);
const customUserAgent = ((_b = options === null || options === void 0 ? void 0 : options.customUserAgent) === null || _b === void 0 ? void 0 : _b.map(escapeUserAgent)) || [];
const prefix = (0, util_endpoints_1.getUserAgentPrefix)();
const sdkUserAgentValue = (prefix ? [prefix] : [])
.concat([...defaultUserAgent, ...userAgent, ...customUserAgent])
.join(constants_1.SPACE);
const normalUAValue = [
...defaultUserAgent.filter((section) => section.startsWith("aws-sdk-")),
...customUserAgent,
].join(constants_1.SPACE);
if (options.runtime !== "browser") {
if (normalUAValue) {
headers[constants_1.X_AMZ_USER_AGENT] = headers[constants_1.X_AMZ_USER_AGENT]
? `${headers[constants_1.USER_AGENT]} ${normalUAValue}`
: normalUAValue;
}
headers[constants_1.USER_AGENT] = sdkUserAgentValue;
}
else {
headers[constants_1.X_AMZ_USER_AGENT] = sdkUserAgentValue;
}
return next({
...args,
request,
});
};
exports.userAgentMiddleware = userAgentMiddleware;
const escapeUserAgent = (userAgentPair) => {
var _a;
const name = userAgentPair[0]
.split(constants_1.UA_NAME_SEPARATOR)
.map((part) => part.replace(constants_1.UA_NAME_ESCAPE_REGEX, constants_1.UA_ESCAPE_CHAR))
.join(constants_1.UA_NAME_SEPARATOR);
const version = (_a = userAgentPair[1]) === null || _a === void 0 ? void 0 : _a.replace(constants_1.UA_VALUE_ESCAPE_REGEX, constants_1.UA_ESCAPE_CHAR);
const prefixSeparatorIndex = name.indexOf(constants_1.UA_NAME_SEPARATOR);
const prefix = name.substring(0, prefixSeparatorIndex);
let uaName = name.substring(prefixSeparatorIndex + 1);
if (prefix === "api") {
uaName = uaName.toLowerCase();
}
return [prefix, uaName, version]
.filter((item) => item && item.length > 0)
.reduce((acc, item, index) => {
switch (index) {
case 0:
return item;
case 1:
return `${acc}/${item}`;
default:
return `${acc}#${item}`;
}
}, "");
};
exports.getUserAgentMiddlewareOptions = {
name: "getUserAgentMiddleware",
step: "build",
priority: "low",
tags: ["SET_USER_AGENT", "USER_AGENT"],
override: true,
};
const getUserAgentPlugin = (config) => ({
applyToStack: (clientStack) => {
clientStack.add((0, exports.userAgentMiddleware)(config), exports.getUserAgentMiddlewareOptions);
},
});
exports.getUserAgentPlugin = getUserAgentPlugin;
module.exports = require("./index.js");
{
"name": "@aws-sdk/middleware-user-agent",
"version": "3.489.0",
"version": "3.495.0",
"scripts": {
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
"build:cjs": "tsc -p tsconfig.cjs.json",
"build:cjs": "node ../../scripts/compilation/inline middleware-user-agent",
"build:es": "tsc -p tsconfig.es.json",

@@ -25,6 +25,6 @@ "build:include:deps": "lerna run --scope $npm_package_name --include-dependencies build",

"dependencies": {
"@aws-sdk/types": "3.489.0",
"@aws-sdk/util-endpoints": "3.489.0",
"@smithy/protocol-http": "^3.0.12",
"@smithy/types": "^2.8.0",
"@aws-sdk/types": "3.495.0",
"@aws-sdk/util-endpoints": "3.495.0",
"@smithy/protocol-http": "^3.1.0",
"@smithy/types": "^2.9.0",
"tslib": "^2.5.0"

@@ -31,0 +31,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc