初始化环境文件
This commit is contained in:
17
node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/getHttpAuthSchemeEndpointRuleSetPlugin.js
generated
vendored
Normal file
17
node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/getHttpAuthSchemeEndpointRuleSetPlugin.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { httpAuthSchemeMiddleware } from "./httpAuthSchemeMiddleware";
|
||||
export const httpAuthSchemeEndpointRuleSetMiddlewareOptions = {
|
||||
step: "serialize",
|
||||
tags: ["HTTP_AUTH_SCHEME"],
|
||||
name: "httpAuthSchemeMiddleware",
|
||||
override: true,
|
||||
relation: "before",
|
||||
toMiddleware: "endpointV2Middleware",
|
||||
};
|
||||
export const getHttpAuthSchemeEndpointRuleSetPlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }) => ({
|
||||
applyToStack: (clientStack) => {
|
||||
clientStack.addRelativeTo(httpAuthSchemeMiddleware(config, {
|
||||
httpAuthSchemeParametersProvider,
|
||||
identityProviderConfigProvider,
|
||||
}), httpAuthSchemeEndpointRuleSetMiddlewareOptions);
|
||||
},
|
||||
});
|
||||
17
node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/getHttpAuthSchemePlugin.js
generated
vendored
Normal file
17
node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/getHttpAuthSchemePlugin.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { httpAuthSchemeMiddleware } from "./httpAuthSchemeMiddleware";
|
||||
export const httpAuthSchemeMiddlewareOptions = {
|
||||
step: "serialize",
|
||||
tags: ["HTTP_AUTH_SCHEME"],
|
||||
name: "httpAuthSchemeMiddleware",
|
||||
override: true,
|
||||
relation: "before",
|
||||
toMiddleware: "serializerMiddleware",
|
||||
};
|
||||
export const getHttpAuthSchemePlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }) => ({
|
||||
applyToStack: (clientStack) => {
|
||||
clientStack.addRelativeTo(httpAuthSchemeMiddleware(config, {
|
||||
httpAuthSchemeParametersProvider,
|
||||
identityProviderConfigProvider,
|
||||
}), httpAuthSchemeMiddlewareOptions);
|
||||
},
|
||||
});
|
||||
42
node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/httpAuthSchemeMiddleware.js
generated
vendored
Normal file
42
node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/httpAuthSchemeMiddleware.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
import { getSmithyContext } from "@smithy/util-middleware";
|
||||
import { resolveAuthOptions } from "./resolveAuthOptions";
|
||||
function convertHttpAuthSchemesToMap(httpAuthSchemes) {
|
||||
const map = new Map();
|
||||
for (const scheme of httpAuthSchemes) {
|
||||
map.set(scheme.schemeId, scheme);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
export const httpAuthSchemeMiddleware = (config, mwOptions) => (next, context) => async (args) => {
|
||||
const options = config.httpAuthSchemeProvider(await mwOptions.httpAuthSchemeParametersProvider(config, context, args.input));
|
||||
const authSchemePreference = config.authSchemePreference ? await config.authSchemePreference() : [];
|
||||
const resolvedOptions = resolveAuthOptions(options, authSchemePreference);
|
||||
const authSchemes = convertHttpAuthSchemesToMap(config.httpAuthSchemes);
|
||||
const smithyContext = getSmithyContext(context);
|
||||
const failureReasons = [];
|
||||
for (const option of resolvedOptions) {
|
||||
const scheme = authSchemes.get(option.schemeId);
|
||||
if (!scheme) {
|
||||
failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` was not enabled for this service.`);
|
||||
continue;
|
||||
}
|
||||
const identityProvider = scheme.identityProvider(await mwOptions.identityProviderConfigProvider(config));
|
||||
if (!identityProvider) {
|
||||
failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` did not have an IdentityProvider configured.`);
|
||||
continue;
|
||||
}
|
||||
const { identityProperties = {}, signingProperties = {} } = option.propertiesExtractor?.(config, context) || {};
|
||||
option.identityProperties = Object.assign(option.identityProperties || {}, identityProperties);
|
||||
option.signingProperties = Object.assign(option.signingProperties || {}, signingProperties);
|
||||
smithyContext.selectedHttpAuthScheme = {
|
||||
httpAuthOption: option,
|
||||
identity: await identityProvider(option.identityProperties),
|
||||
signer: scheme.signer,
|
||||
};
|
||||
break;
|
||||
}
|
||||
if (!smithyContext.selectedHttpAuthScheme) {
|
||||
throw new Error(failureReasons.join("\n"));
|
||||
}
|
||||
return next(args);
|
||||
};
|
||||
3
node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/index.js
generated
vendored
Normal file
3
node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/index.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from "./httpAuthSchemeMiddleware";
|
||||
export * from "./getHttpAuthSchemeEndpointRuleSetPlugin";
|
||||
export * from "./getHttpAuthSchemePlugin";
|
||||
20
node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/resolveAuthOptions.js
generated
vendored
Normal file
20
node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/resolveAuthOptions.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
export const resolveAuthOptions = (candidateAuthOptions, authSchemePreference) => {
|
||||
if (!authSchemePreference || authSchemePreference.length === 0) {
|
||||
return candidateAuthOptions;
|
||||
}
|
||||
const preferredAuthOptions = [];
|
||||
for (const preferredSchemeName of authSchemePreference) {
|
||||
for (const candidateAuthOption of candidateAuthOptions) {
|
||||
const candidateAuthSchemeName = candidateAuthOption.schemeId.split("#")[1];
|
||||
if (candidateAuthSchemeName === preferredSchemeName) {
|
||||
preferredAuthOptions.push(candidateAuthOption);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const candidateAuthOption of candidateAuthOptions) {
|
||||
if (!preferredAuthOptions.find(({ schemeId }) => schemeId === candidateAuthOption.schemeId)) {
|
||||
preferredAuthOptions.push(candidateAuthOption);
|
||||
}
|
||||
}
|
||||
return preferredAuthOptions;
|
||||
};
|
||||
Reference in New Issue
Block a user