UNPKG

infrastructure-components

Version:

Infrastructure-Components configure the infrastructure of your React-App as part of your React-Components.

76 lines (67 loc) 3.06 kB
"use strict"; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }; Object.defineProperty(exports, "__esModule", { value: true }); const plugin_1 = require("../libs/plugin"); const authentication_component_1 = require("./authentication-component"); const deepmerge = __importStar(require("deepmerge")); /** * We require an AuthenticationPlugin to forward the configuration from lower level webapps * TODO: refactor so that we don't need such dummy plugins! */ exports.AuthenticationPlugin = (props) => { const path = require('path'); const result = { applies: (component) => { return authentication_component_1.isAuthentication(component); }, // convert the component into configuration parts // while the component is of Type `any`, its props must be of type `IDataLayerArgs` | `IDataLayerProps` process: (component, childConfigs, infrastructureMode) => { // we need to environment variable const slsEnv = { provider: { environment: {} } }; slsEnv.provider.environment[authentication_component_1.getProviderKey(component.provider)] = authentication_component_1.getClientSecret(component.provider); console.log("slsEnv: ", slsEnv); const iamRoleStatements = [ component.provider === authentication_component_1.AuthenticationProvider.EMAIL ? { Effect: "Allow", Action: [ "ses:SendEmail" ], Resource: [ '"arn:aws:ses:${self:provider.region}:*:identity/' + `${component.senderEmail}"` ] } : {} ].concat(plugin_1.forwardChildIamRoleStatements(childConfigs)); return { slsConfigs: deepmerge.all([slsEnv].concat(childConfigs.map(config => config.slsConfigs))), // add the server config webpackConfigs: plugin_1.forwardChildWebpackConfigs(childConfigs), postBuilds: plugin_1.forwardChildPostBuilds(childConfigs), iamRoleStatements: iamRoleStatements /* THESE VALUES MUST NOT BE PROVIDED BY A CHILD, THEY ARE NOT FORWARED UPWARDS environments: environments, //stackName: component.stackName, assetsPath: component.assetsPath, buildPath: component.buildPath, region: component.region, domain: domain, certArn: certArn, supportOfflineStart: true, supportCreateDomain: true */ }; } }; return result; }; //# sourceMappingURL=authentication-plugin.js.map