@aws-sdk/middleware-user-agent 3.664.0 → 3.667.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,39 @@ __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, _b;
|
|
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
|
+
if (typeof config.credentials === "function") {
|
|
87
|
+
try {
|
|
88
|
+
const credentials = await ((_b = config.credentials) == null ? void 0 : _b.call(config));
|
|
89
|
+
if (credentials.accountId) {
|
|
90
|
+
(0, import_core2.setFeature)(context, "RESOLVED_ACCOUNT_ID", "T");
|
|
91
|
+
}
|
|
92
|
+
for (const [key, value] of Object.entries(credentials.$source ?? {})) {
|
|
93
|
+
(0, import_core2.setFeature)(context, key, value);
|
|
94
|
+
}
|
|
95
|
+
} catch (e) {
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
__name(checkFeatures, "checkFeatures");
|
|
100
|
+
|
|
68
101
|
// src/constants.ts
|
|
69
102
|
var USER_AGENT = "user-agent";
|
|
70
103
|
var X_AMZ_USER_AGENT = "x-amz-user-agent";
|
|
@@ -104,6 +137,7 @@ var userAgentMiddleware = /* @__PURE__ */ __name((options) => (next, context) =>
|
|
|
104
137
|
const { headers } = request;
|
|
105
138
|
const userAgent = ((_a = context == null ? void 0 : context.userAgent) == null ? void 0 : _a.map(escapeUserAgent)) || [];
|
|
106
139
|
const defaultUserAgent = (await options.defaultUserAgentProvider()).map(escapeUserAgent);
|
|
140
|
+
await checkFeatures(context, options, args);
|
|
107
141
|
const awsContext = context;
|
|
108
142
|
defaultUserAgent.push(
|
|
109
143
|
`m/${encodeFeatures(
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
if (typeof config.credentials === "function") {
|
|
18
|
+
try {
|
|
19
|
+
const credentials = await config.credentials?.();
|
|
20
|
+
if (credentials.accountId) {
|
|
21
|
+
setFeature(context, "RESOLVED_ACCOUNT_ID", "T");
|
|
22
|
+
}
|
|
23
|
+
for (const [key, value] of Object.entries(credentials.$source ?? {})) {
|
|
24
|
+
setFeature(context, key, value);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -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,17 @@
|
|
|
1
|
+
import type { AccountIdEndpointMode } from "@aws-sdk/core/account-id-endpoint";
|
|
2
|
+
import type { AwsHandlerExecutionContext } from "@aws-sdk/types";
|
|
3
|
+
import type { AwsCredentialIdentityProvider, BuildHandlerArguments, Provider } from "@smithy/types";
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
type PreviouslyResolved = Partial<{
|
|
8
|
+
credentials?: AwsCredentialIdentityProvider;
|
|
9
|
+
accountIdEndpointMode?: Provider<AccountIdEndpointMode>;
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
* Check for features that don't have a middleware activation site but
|
|
14
|
+
* may be detected on the context, client config, or request.
|
|
15
|
+
*/
|
|
16
|
+
export declare function checkFeatures(context: AwsHandlerExecutionContext, config: PreviouslyResolved, args: BuildHandlerArguments<any>): Promise<void>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AccountIdEndpointMode } from "@aws-sdk/core/account-id-endpoint";
|
|
2
|
+
import { AwsHandlerExecutionContext } from "@aws-sdk/types";
|
|
3
|
+
import {
|
|
4
|
+
AwsCredentialIdentityProvider,
|
|
5
|
+
BuildHandlerArguments,
|
|
6
|
+
Provider,
|
|
7
|
+
} from "@smithy/types";
|
|
8
|
+
type PreviouslyResolved = Partial<{
|
|
9
|
+
credentials?: AwsCredentialIdentityProvider;
|
|
10
|
+
accountIdEndpointMode?: Provider<AccountIdEndpointMode>;
|
|
11
|
+
}>;
|
|
12
|
+
export declare function checkFeatures(
|
|
13
|
+
context: AwsHandlerExecutionContext,
|
|
14
|
+
config: PreviouslyResolved,
|
|
15
|
+
args: BuildHandlerArguments<any>
|
|
16
|
+
): Promise<void>;
|
|
17
|
+
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.667.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/
|
|
26
|
-
"@aws-sdk/
|
|
27
|
-
"@
|
|
25
|
+
"@aws-sdk/core": "3.667.0",
|
|
26
|
+
"@aws-sdk/types": "3.667.0",
|
|
27
|
+
"@aws-sdk/util-endpoints": "3.667.0",
|
|
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"
|