This repository has been archived on 2024-09-11. You can view files and clone it, but cannot push or open issues or pull requests.
svrjs-blog-newsletter/cronjob/node_modules/@smithy/middleware-endpoint/dist-es/endpointMiddleware.js

33 lines
1.5 KiB
JavaScript
Raw Normal View History

2024-05-26 22:54:55 +02:00
import { getSmithyContext } from "@smithy/util-middleware";
import { getEndpointFromInstructions } from "./adaptors/getEndpointFromInstructions";
export const endpointMiddleware = ({ config, instructions, }) => {
return (next, context) => async (args) => {
const endpoint = await getEndpointFromInstructions(args.input, {
getEndpointParameterInstructions() {
return instructions;
},
}, { ...config }, context);
context.endpointV2 = endpoint;
context.authSchemes = endpoint.properties?.authSchemes;
const authScheme = context.authSchemes?.[0];
if (authScheme) {
context["signing_region"] = authScheme.signingRegion;
context["signing_service"] = authScheme.signingName;
const smithyContext = getSmithyContext(context);
const httpAuthOption = smithyContext?.selectedHttpAuthScheme?.httpAuthOption;
if (httpAuthOption) {
httpAuthOption.signingProperties = Object.assign(httpAuthOption.signingProperties || {}, {
signing_region: authScheme.signingRegion,
signingRegion: authScheme.signingRegion,
signing_service: authScheme.signingName,
signingName: authScheme.signingName,
signingRegionSet: authScheme.signingRegionSet,
}, authScheme.properties);
}
}
return next({
...args,
});
};
};