@aws-sdk/client-eventbridge 3.621.0 → 3.623.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.
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveHttpAuthSchemeConfig = exports.defaultEventBridgeHttpAuthSchemeProvider = exports.defaultEventBridgeHttpAuthSchemeParametersProvider = void 0;
4
+ const core_1 = require("@aws-sdk/core");
5
+ const signature_v4_multi_region_1 = require("@aws-sdk/signature-v4-multi-region");
6
+ const middleware_endpoint_1 = require("@smithy/middleware-endpoint");
7
+ const util_middleware_1 = require("@smithy/util-middleware");
8
+ const endpointResolver_1 = require("../endpoint/endpointResolver");
9
+ const createEndpointRuleSetHttpAuthSchemeParametersProvider = (defaultHttpAuthSchemeParametersProvider) => async (config, context, input) => {
10
+ if (!input) {
11
+ throw new Error(`Could not find \`input\` for \`defaultEndpointRuleSetHttpAuthSchemeParametersProvider\``);
12
+ }
13
+ const defaultParameters = await defaultHttpAuthSchemeParametersProvider(config, context, input);
14
+ const instructionsFn = (0, util_middleware_1.getSmithyContext)(context)?.commandInstance?.constructor
15
+ ?.getEndpointParameterInstructions;
16
+ if (!instructionsFn) {
17
+ throw new Error(`getEndpointParameterInstructions() is not defined on \`${context.commandName}\``);
18
+ }
19
+ const endpointParameters = await (0, middleware_endpoint_1.resolveParams)(input, { getEndpointParameterInstructions: instructionsFn }, config);
20
+ return Object.assign(defaultParameters, endpointParameters);
21
+ };
22
+ const _defaultEventBridgeHttpAuthSchemeParametersProvider = async (config, context, input) => {
23
+ return {
24
+ operation: (0, util_middleware_1.getSmithyContext)(context).operation,
25
+ region: (await (0, util_middleware_1.normalizeProvider)(config.region)()) ||
26
+ (() => {
27
+ throw new Error("expected `region` to be configured for `aws.auth#sigv4`");
28
+ })(),
29
+ };
30
+ };
31
+ exports.defaultEventBridgeHttpAuthSchemeParametersProvider = createEndpointRuleSetHttpAuthSchemeParametersProvider(_defaultEventBridgeHttpAuthSchemeParametersProvider);
32
+ function createAwsAuthSigv4HttpAuthOption(authParameters) {
33
+ return {
34
+ schemeId: "aws.auth#sigv4",
35
+ signingProperties: {
36
+ name: "events",
37
+ region: authParameters.region,
38
+ },
39
+ propertiesExtractor: (config, context) => ({
40
+ signingProperties: {
41
+ config,
42
+ context,
43
+ },
44
+ }),
45
+ };
46
+ }
47
+ function createAwsAuthSigv4aHttpAuthOption(authParameters) {
48
+ return {
49
+ schemeId: "aws.auth#sigv4a",
50
+ signingProperties: {
51
+ name: "events",
52
+ region: authParameters.region,
53
+ },
54
+ propertiesExtractor: (config, context) => ({
55
+ signingProperties: {
56
+ config,
57
+ context,
58
+ },
59
+ }),
60
+ };
61
+ }
62
+ const createEndpointRuleSetHttpAuthSchemeProvider = (defaultEndpointResolver, defaultHttpAuthSchemeResolver, createHttpAuthOptionFunctions) => {
63
+ const endpointRuleSetHttpAuthSchemeProvider = (authParameters) => {
64
+ const endpoint = defaultEndpointResolver(authParameters);
65
+ const authSchemes = endpoint.properties?.authSchemes;
66
+ if (!authSchemes) {
67
+ return defaultHttpAuthSchemeResolver(authParameters);
68
+ }
69
+ const options = [];
70
+ for (const scheme of authSchemes) {
71
+ const { name: resolvedName, properties = {}, ...rest } = scheme;
72
+ const name = resolvedName.toLowerCase();
73
+ if (resolvedName !== name) {
74
+ console.warn(`HttpAuthScheme has been normalized with lowercasing: \`${resolvedName}\` to \`${name}\``);
75
+ }
76
+ let schemeId;
77
+ if (name === "sigv4a") {
78
+ schemeId = "aws.auth#sigv4a";
79
+ const sigv4Present = authSchemes.find((s) => {
80
+ const name = s.name.toLowerCase();
81
+ return name !== "sigv4a" && name.startsWith("sigv4");
82
+ });
83
+ if (!signature_v4_multi_region_1.signatureV4CrtContainer.CrtSignerV4 && sigv4Present) {
84
+ continue;
85
+ }
86
+ }
87
+ else if (name.startsWith("sigv4")) {
88
+ schemeId = "aws.auth#sigv4";
89
+ }
90
+ else {
91
+ throw new Error(`Unknown HttpAuthScheme found in \`@smithy.rules#endpointRuleSet\`: \`${name}\``);
92
+ }
93
+ const createOption = createHttpAuthOptionFunctions[schemeId];
94
+ if (!createOption) {
95
+ throw new Error(`Could not find HttpAuthOption create function for \`${schemeId}\``);
96
+ }
97
+ const option = createOption(authParameters);
98
+ option.schemeId = schemeId;
99
+ option.signingProperties = { ...(option.signingProperties || {}), ...rest, ...properties };
100
+ options.push(option);
101
+ }
102
+ return options;
103
+ };
104
+ return endpointRuleSetHttpAuthSchemeProvider;
105
+ };
106
+ const _defaultEventBridgeHttpAuthSchemeProvider = (authParameters) => {
107
+ const options = [];
108
+ switch (authParameters.operation) {
109
+ default: {
110
+ options.push(createAwsAuthSigv4HttpAuthOption(authParameters));
111
+ options.push(createAwsAuthSigv4aHttpAuthOption(authParameters));
112
+ }
113
+ }
114
+ return options;
115
+ };
116
+ exports.defaultEventBridgeHttpAuthSchemeProvider = createEndpointRuleSetHttpAuthSchemeProvider(endpointResolver_1.defaultEndpointResolver, _defaultEventBridgeHttpAuthSchemeProvider, {
117
+ "aws.auth#sigv4": createAwsAuthSigv4HttpAuthOption,
118
+ "aws.auth#sigv4a": createAwsAuthSigv4aHttpAuthOption,
119
+ });
120
+ const resolveHttpAuthSchemeConfig = (config) => {
121
+ const config_0 = (0, core_1.resolveAwsSdkSigV4Config)(config);
122
+ return {
123
+ ...config_0,
124
+ };
125
+ };
126
+ exports.resolveHttpAuthSchemeConfig = resolveHttpAuthSchemeConfig;