@aws-sdk/middleware-user-agent 3.664.0 → 3.666.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/index.js
CHANGED
|
@@ -65,6 +65,27 @@ __name(resolveUserAgentConfig, "resolveUserAgentConfig");
|
|
|
65
65
|
var import_util_endpoints = require("@aws-sdk/util-endpoints");
|
|
66
66
|
var import_protocol_http = require("@smithy/protocol-http");
|
|
67
67
|
|
|
68
|
+
// src/check-features.ts
|
|
69
|
+
var import_core2 = require("@aws-sdk/core");
|
|
70
|
+
async function checkFeatures(context, config, args) {
|
|
71
|
+
var _a;
|
|
72
|
+
const request = args.request;
|
|
73
|
+
if (typeof config.accountIdEndpointMode === "function") {
|
|
74
|
+
switch (await ((_a = config.accountIdEndpointMode) == null ? void 0 : _a.call(config))) {
|
|
75
|
+
case "disabled":
|
|
76
|
+
(0, import_core2.setFeature)(context, "ACCOUNT_ID_MODE_DISABLED", "Q");
|
|
77
|
+
break;
|
|
78
|
+
case "preferred":
|
|
79
|
+
(0, import_core2.setFeature)(context, "ACCOUNT_ID_MODE_PREFERRED", "P");
|
|
80
|
+
break;
|
|
81
|
+
case "required":
|
|
82
|
+
(0, import_core2.setFeature)(context, "ACCOUNT_ID_MODE_REQUIRED", "R");
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
__name(checkFeatures, "checkFeatures");
|
|
88
|
+
|
|
68
89
|
// src/constants.ts
|
|
69
90
|
var USER_AGENT = "user-agent";
|
|
70
91
|
var X_AMZ_USER_AGENT = "x-amz-user-agent";
|
|
@@ -104,6 +125,7 @@ var userAgentMiddleware = /* @__PURE__ */ __name((options) => (next, context) =>
|
|
|
104
125
|
const { headers } = request;
|
|
105
126
|
const userAgent = ((_a = context == null ? void 0 : context.userAgent) == null ? void 0 : _a.map(escapeUserAgent)) || [];
|
|
106
127
|
const defaultUserAgent = (await options.defaultUserAgentProvider()).map(escapeUserAgent);
|
|
128
|
+
await checkFeatures(context, options, args);
|
|
107
129
|
const awsContext = context;
|
|
108
130
|
defaultUserAgent.push(
|
|
109
131
|
`m/${encodeFeatures(
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { setFeature } from "@aws-sdk/core";
|
|
2
|
+
export async function checkFeatures(context, config, args) {
|
|
3
|
+
const request = args.request;
|
|
4
|
+
if (typeof config.accountIdEndpointMode === "function") {
|
|
5
|
+
switch (await config.accountIdEndpointMode?.()) {
|
|
6
|
+
case "disabled":
|
|
7
|
+
setFeature(context, "ACCOUNT_ID_MODE_DISABLED", "Q");
|
|
8
|
+
break;
|
|
9
|
+
case "preferred":
|
|
10
|
+
setFeature(context, "ACCOUNT_ID_MODE_PREFERRED", "P");
|
|
11
|
+
break;
|
|
12
|
+
case "required":
|
|
13
|
+
setFeature(context, "ACCOUNT_ID_MODE_REQUIRED", "R");
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getUserAgentPrefix } from "@aws-sdk/util-endpoints";
|
|
2
2
|
import { HttpRequest } from "@smithy/protocol-http";
|
|
3
|
+
import { checkFeatures } from "./check-features";
|
|
3
4
|
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
5
|
import { encodeFeatures } from "./encode-features";
|
|
5
6
|
export const userAgentMiddleware = (options) => (next, context) => async (args) => {
|
|
@@ -10,6 +11,7 @@ export const userAgentMiddleware = (options) => (next, context) => async (args)
|
|
|
10
11
|
const { headers } = request;
|
|
11
12
|
const userAgent = context?.userAgent?.map(escapeUserAgent) || [];
|
|
12
13
|
const defaultUserAgent = (await options.defaultUserAgentProvider()).map(escapeUserAgent);
|
|
14
|
+
await checkFeatures(context, options, args);
|
|
13
15
|
const awsContext = context;
|
|
14
16
|
defaultUserAgent.push(`m/${encodeFeatures(Object.assign({}, context.__smithy_context?.features, awsContext.__aws_sdk_context?.features))}`);
|
|
15
17
|
const customUserAgent = options?.customUserAgent?.map(escapeUserAgent) || [];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AccountIdEndpointMode } from "@aws-sdk/core/account-id-endpoint";
|
|
2
|
+
import type { AwsHandlerExecutionContext } from "@aws-sdk/types";
|
|
3
|
+
import type { BuildHandlerArguments, Provider } from "@smithy/types";
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
type PreviouslyResolved = Partial<{
|
|
8
|
+
accountIdEndpointMode?: Provider<AccountIdEndpointMode>;
|
|
9
|
+
}>;
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
* Check for features that don't have a middleware activation site but
|
|
13
|
+
* may be detected on the context, client config, or request.
|
|
14
|
+
*/
|
|
15
|
+
export declare function checkFeatures(context: AwsHandlerExecutionContext, config: PreviouslyResolved, args: BuildHandlerArguments<any>): Promise<void>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AccountIdEndpointMode } from "@aws-sdk/core/account-id-endpoint";
|
|
2
|
+
import { AwsHandlerExecutionContext } from "@aws-sdk/types";
|
|
3
|
+
import { BuildHandlerArguments, Provider } from "@smithy/types";
|
|
4
|
+
type PreviouslyResolved = Partial<{
|
|
5
|
+
accountIdEndpointMode?: Provider<AccountIdEndpointMode>;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function checkFeatures(
|
|
8
|
+
context: AwsHandlerExecutionContext,
|
|
9
|
+
config: PreviouslyResolved,
|
|
10
|
+
args: BuildHandlerArguments<any>
|
|
11
|
+
): Promise<void>;
|
|
12
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-user-agent",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.666.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
6
6
|
"build:cjs": "node ../../scripts/compilation/inline middleware-user-agent",
|
|
@@ -22,9 +22,10 @@
|
|
|
22
22
|
},
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"dependencies": {
|
|
25
|
+
"@aws-sdk/core": "3.666.0",
|
|
25
26
|
"@aws-sdk/types": "3.664.0",
|
|
26
27
|
"@aws-sdk/util-endpoints": "3.664.0",
|
|
27
|
-
"@smithy/core": "^2.4.
|
|
28
|
+
"@smithy/core": "^2.4.8",
|
|
28
29
|
"@smithy/protocol-http": "^4.1.4",
|
|
29
30
|
"@smithy/types": "^3.5.0",
|
|
30
31
|
"tslib": "^2.6.2"
|