@axway/axway-central-cli 4.7.0 → 4.9.0-rc.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.
@@ -15,6 +15,7 @@ var _CliConfigManager = require("../../common/CliConfigManager");
15
15
  var _Renderer = _interopRequireDefault(require("../../common/Renderer"));
16
16
  var _types = require("../../common/types");
17
17
  var _utils = require("../../common/utils");
18
+ var akamaiAgents = _interopRequireWildcard(require("./akamaiAgents"));
18
19
  var apigeeXAgents = _interopRequireWildcard(require("./apigeexAgents"));
19
20
  var awsAgents = _interopRequireWildcard(require("./awsAgents"));
20
21
  var awsSaaSAgents = _interopRequireWildcard(require("./awsSaasAgents"));
@@ -40,6 +41,8 @@ var sensediaAgents = _interopRequireWildcard(require("./sensediaAgents"));
40
41
  var wso2Agents = _interopRequireWildcard(require("./wso2Agents"));
41
42
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
42
43
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
44
+ // import * as akamaiSaasAgents from './akamaiSaasAgents';
45
+
43
46
  const {
44
47
  log
45
48
  } = (0, _snooplogg.default)('engage: install: agents');
@@ -50,6 +53,7 @@ const prompts = exports.prompts = {
50
53
  selectGatewayType: 'Select the type of gateway you want to connect'
51
54
  };
52
55
  const agentInstallFlows = {
56
+ [_types.GatewayTypes.AKAMAI]: akamaiAgents.AkamaiInstallMethods,
53
57
  [_types.GatewayTypes.EDGE_GATEWAY]: edgeAgents.EdgeInstallMethods,
54
58
  [_types.GatewayTypes.EDGE_GATEWAY_ONLY]: edgeAgents.EdgeGWOnlyInstallMethods,
55
59
  [_types.GatewayTypes.AWS_GATEWAY]: awsAgents.AWSInstallMethods,
@@ -69,6 +73,7 @@ const agentInstallFlows = {
69
73
  [_types.GatewayTypes.WSO2]: wso2Agents.WSO2InstallMethods
70
74
  };
71
75
  const saasAgentInstallFlows = {
76
+ // [GatewayTypes.AKAMAI]: akamaiSaasAgents.AkamaiSaaSInstallMethods,
72
77
  [_types.SaaSGatewayTypes.AWS_GATEWAY]: awsSaaSAgents.AWSSaaSInstallMethods,
73
78
  [_types.SaaSGatewayTypes.GITHUB]: gitHubAgents.GitHubSaaSInstallMethods,
74
79
  [_types.SaaSGatewayTypes.APIGEEX_GATEWAY]: apigeeSaaSAgents.APIGEEXSaaSInstallMethods,
@@ -145,7 +150,7 @@ const agents = exports.agents = {
145
150
  installConfig.centralConfig.region = await determineRegion(orgRegion);
146
151
  let gatewayTypeChoices = [];
147
152
  Object.values(_types.GatewayTypes).forEach(v => gatewayTypeChoices.push(v));
148
- Object.values(_types.SaaSGatewayTypes).filter(v => v !== _types.SaaSGatewayTypes.AWS_GATEWAY && v !== _types.SaaSGatewayTypes.APIGEEX_GATEWAY && v !== _types.SaaSGatewayTypes.TRACEABLE).forEach(v => gatewayTypeChoices.push(v));
153
+ Object.values(_types.SaaSGatewayTypes).filter(v => v !== _types.SaaSGatewayTypes.AWS_GATEWAY && v !== _types.SaaSGatewayTypes.APIGEEX_GATEWAY && v !== _types.SaaSGatewayTypes.TRACEABLE && v !== _types.SaaSGatewayTypes.AKAMAI).forEach(v => gatewayTypeChoices.push(v));
149
154
  let gatewayChoices = gatewayTypeChoices.sort().filter(v => v !== _types.GatewayTypes.EDGE_GATEWAY_ONLY);
150
155
  let gatewayType = await (0, _basicPrompts.askList)({
151
156
  msg: prompts.selectGatewayType,
@@ -164,7 +169,9 @@ const agents = exports.agents = {
164
169
  }
165
170
 
166
171
  // if this check gets bigger, may think about an array of agents that can be both ground and embedded until ground agents become obsolete
167
- if (gatewayType === _types.GatewayTypes.AWS_GATEWAY || gatewayType === _types.GatewayTypes.AZURE_GATEWAY || gatewayType === _types.GatewayTypes.AZURE_EVENTHUB || gatewayType === _types.GatewayTypes.APIGEEX_GATEWAY || gatewayType === _types.GatewayTypes.TRACEABLE) {
172
+ if (gatewayType === _types.GatewayTypes.AWS_GATEWAY || gatewayType === _types.GatewayTypes.AZURE_GATEWAY || gatewayType === _types.GatewayTypes.AZURE_EVENTHUB || gatewayType === _types.GatewayTypes.APIGEEX_GATEWAY || gatewayType === _types.GatewayTypes.TRACEABLE
173
+ // gatewayType === GatewayTypes.AKAMAI
174
+ ) {
168
175
  // hosted vs on premise
169
176
  installConfig.switches.isHostedInstall = (await (0, _basicPrompts.askList)({
170
177
  msg: prompts.hostedAgentOption,
@@ -0,0 +1,256 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.testables = exports.gatewayConnectivity = exports.completeInstall = exports.askConfigType = exports.askBundleType = exports.amplifyAgentsNs = exports.ConfigFiles = exports.AkamaiInstallMethods = void 0;
7
+ var _chalk = _interopRequireDefault(require("chalk"));
8
+ var _snooplogg = _interopRequireDefault(require("snooplogg"));
9
+ var _Kubectl = require("../../common/Kubectl");
10
+ var _basicPrompts = require("../../common/basicPrompts");
11
+ var _inputs = require("./helpers/inputs");
12
+ var _types = require("../../common/types");
13
+ var helpers = _interopRequireWildcard(require("./helpers"));
14
+ var _akamaiTemplates = require("./helpers/templates/akamaiTemplates");
15
+ var _utils = require("../../common/utils");
16
+ var _agents = require("./agents");
17
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
18
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
+ // @ts-ignore
20
+ const {
21
+ log
22
+ } = (0, _snooplogg.default)('central: install: agents: Akamai');
23
+ const caImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.AKAMAI_CA}`;
24
+ const amplifyAgentsNs = exports.amplifyAgentsNs = 'amplify-agents';
25
+
26
+ // ConfigFiles - all the config file that are used in the setup
27
+ const ConfigFiles = exports.ConfigFiles = {
28
+ helmOverride: 'agent-overrides.yaml',
29
+ agentEnvVars: `${helpers.configFiles.AGENT_ENV_VARS}`
30
+ };
31
+ const prompts = {
32
+ configTypeMsg: 'Select the mode of installation',
33
+ agentNamespace: 'Enter the namespace to use for the Amplify Akamai Agents',
34
+ enterBaseUrl: 'Enter the Akamai Base URL',
35
+ enterClientId: 'Enter the Akamai Client ID',
36
+ enterClientSecret: 'Enter the Akamai Client Secret',
37
+ enterSegmentLength: 'Enter the Akamai Segment Length',
38
+ enterEnvironments: 'Enter an Akamai environment',
39
+ enterMoreEnvironments: 'Do you want to enter another mapping?',
40
+ selectCentralMappingEnvironment: 'Select an Engage environment to map to the provided Akamai environment',
41
+ environmentsDescription: 'Configure a mapping of Akamai environment to Engage environment that the agent will use'
42
+ };
43
+ const askBundleType = async () => {
44
+ return _types.BundleType.TRACEABILITY;
45
+ };
46
+ exports.askBundleType = askBundleType;
47
+ const askConfigType = async () => {
48
+ return await (0, _basicPrompts.askList)({
49
+ msg: prompts.configTypeMsg,
50
+ choices: [_types.AgentConfigTypes.DOCKERIZED, _types.AgentConfigTypes.HELM]
51
+ });
52
+ };
53
+
54
+ //
55
+ // Questions for the configuration of Akamai agents
56
+ //
57
+ exports.askConfigType = askConfigType;
58
+ const askAkamaiBaseUrl = async () => await (0, _basicPrompts.askInput)({
59
+ msg: prompts.enterBaseUrl,
60
+ validate: (0, _basicPrompts.validateRegex)(helpers.AkamaiRegexPatterns.baseURLRegex, helpers.invalidValueExampleErrMsg('baseURL', 'https://akamai.com'))
61
+ });
62
+ const askAkamaiClientId = async () => await (0, _basicPrompts.askInput)({
63
+ msg: prompts.enterClientId
64
+ });
65
+ const askAkamaiClientSecret = async () => await (0, _basicPrompts.askInput)({
66
+ msg: prompts.enterClientSecret
67
+ });
68
+ const askAkamaiSegmentLength = async () => await (0, _basicPrompts.askInput)({
69
+ msg: prompts.enterSegmentLength,
70
+ type: 'number',
71
+ validate: (0, _basicPrompts.validateValueRange)(0)
72
+ });
73
+ const askEnvironments = async (centralEnvs, akamaiAgentValues, excludeEnvironment) => {
74
+ // Filter out the already-selected agent installation environment
75
+ if (excludeEnvironment) {
76
+ centralEnvs = centralEnvs.filter(env => env.name !== excludeEnvironment);
77
+ }
78
+
79
+ // If no central environments are available, exit the installation
80
+ if (centralEnvs.length === 0) {
81
+ console.log(_chalk.default.red('Installation cannot proceed: No Engage environments are available for mapping.'));
82
+ console.log(_chalk.default.yellow('Please create at least one Engage environment before installing the Akamai agent.'));
83
+ console.log(_chalk.default.gray('You can create an environment using: axway engage create environment'));
84
+ process.exit(1);
85
+ }
86
+ let askEnvs = true;
87
+ let envs = [];
88
+ let mappedCentralEnvs = [];
89
+ console.log(_chalk.default.gray(prompts.environmentsDescription));
90
+ while (askEnvs) {
91
+ const env = await (0, _basicPrompts.askInput)({
92
+ msg: prompts.enterEnvironments,
93
+ allowEmptyInput: true
94
+ });
95
+ if (envs.length === 0 && (!env || env.toString().trim() === "")) {
96
+ break;
97
+ }
98
+ if (env && env.toString().trim() !== "") {
99
+ envs.push(env);
100
+ }
101
+ const centralMappingEnv = await (0, _basicPrompts.askList)({
102
+ msg: prompts.selectCentralMappingEnvironment,
103
+ choices: centralEnvs.map(e => e.name)
104
+ });
105
+ if (centralMappingEnv && centralMappingEnv.toString().trim() !== "") {
106
+ mappedCentralEnvs.push(centralMappingEnv);
107
+ }
108
+
109
+ // Remove the selected environment from available choices for next iteration
110
+ centralEnvs = centralEnvs.filter(env => env.name !== centralMappingEnv);
111
+
112
+ // Only ask to continue if there are remaining central environments
113
+ if (centralEnvs.length > 0) {
114
+ askEnvs = (await (0, _basicPrompts.askList)({
115
+ msg: prompts.enterMoreEnvironments,
116
+ default: _types.YesNo.No,
117
+ choices: _types.YesNoChoices
118
+ })) === _types.YesNo.Yes;
119
+ } else {
120
+ askEnvs = false; // Auto-stop when no environments remain
121
+ }
122
+ }
123
+ akamaiAgentValues.environments = envs;
124
+ akamaiAgentValues.centralEnvironments = mappedCentralEnvs;
125
+ };
126
+ const gatewayConnectivity = async installConfig => {
127
+ let akamaiAgentValues = new _akamaiTemplates.AkamaiAgentValues();
128
+ if (installConfig.switches.isHelmInstall) {
129
+ console.log(_chalk.default.gray(`The Amplify Akamai Agent needs to be deployed to your Kubernetes cluster to discover APIs for publishing to Amplify Central.`));
130
+ const {
131
+ error
132
+ } = await _Kubectl.kubectl.isInstalled();
133
+ if (error) {
134
+ throw new Error(`Kubectl is required to fill out the following prompts. It appears to be missing or misconfigured.\n${error}`);
135
+ }
136
+ akamaiAgentValues.namespace = await (0, _inputs.askNamespace)(prompts.agentNamespace, amplifyAgentsNs);
137
+ }
138
+ if (installConfig.switches.isDockerInstall) {
139
+ console.log('\nCONNECTION TO AKAMAI API GATEWAY:');
140
+ console.log(_chalk.default.gray("The Compliance Agent needs to connect to the Akamai API Gateway to discover API's for publishing to Amplify Central."));
141
+ }
142
+ akamaiAgentValues.baseUrl = await askAkamaiBaseUrl();
143
+ akamaiAgentValues.clientId = await askAkamaiClientId();
144
+ akamaiAgentValues.clientSecret = await askAkamaiClientSecret();
145
+ akamaiAgentValues.segmentLength = await askAkamaiSegmentLength();
146
+ await helpers.getCentralEnvironments(installConfig.centralConfig.apiServerClient, installConfig.centralConfig.definitionManager).then(async envs => {
147
+ if (envs) {
148
+ var _installConfig$centra;
149
+ // Pass the already-selected agent installation environment to exclude it from mapping choices
150
+ const agentInstallEnv = (_installConfig$centra = installConfig.centralConfig.ampcEnvInfo) === null || _installConfig$centra === void 0 ? void 0 : _installConfig$centra.name;
151
+ await askEnvironments(envs, akamaiAgentValues, agentInstallEnv);
152
+ }
153
+ });
154
+ return akamaiAgentValues;
155
+ };
156
+ exports.gatewayConnectivity = gatewayConnectivity;
157
+ const dockerSuccessMsg = installConfig => {
158
+ let dockerInfo;
159
+ const runAgentLinuxMsg = `docker run -it --env-file ${helpers.pwd}/${helpers.configFiles.AGENT_ENV_VARS} -v ${helpers.pwd}:/keys ${helpers.eolChar}`;
160
+ const runAgentWinMsg = `docker run -it --env-file ${helpers.pwdWin}/${helpers.configFiles.AGENT_ENV_VARS} -v ${helpers.pwdWin}:/keys ${helpers.eolCharWin}`;
161
+ const startAgentLinuxMsg = `\nStart the Akamai Agent on a Linux based machine`;
162
+ const startAgentWinMsg = `\nStart the Akamai Agent on a Windows machine`;
163
+ dockerInfo = `To utilize the agent, pull the latest Docker image and run it using the appropriate supplied environment file, (${helpers.configFiles.AGENT_ENV_VARS}):`;
164
+ console.log(_chalk.default.whiteBright(dockerInfo), '\n');
165
+ const caImageVersion = `${caImage}:${installConfig.caVersion}`;
166
+ console.log(_chalk.default.white('Pull the latest image of the Agent:'));
167
+ console.log(_chalk.default.cyan(`docker pull ${caImageVersion}`));
168
+ console.log(_chalk.default.white(_utils.isWindows ? startAgentWinMsg : startAgentLinuxMsg));
169
+ console.log(_chalk.default.cyan(_utils.isWindows ? runAgentWinMsg : runAgentLinuxMsg));
170
+ console.log('\t', _chalk.default.cyan(`-v /data ${caImageVersion}`), '\n');
171
+ };
172
+ const helmSuccessMsg = namespace => {
173
+ console.log(`Akamai Agent override file has been placed at ${process.cwd()}/${ConfigFiles.helmOverride}`);
174
+ helpers.helmImageSecretInfo(namespace);
175
+ let agentHelmInfo = new Set();
176
+ agentHelmInfo.add({
177
+ helmReleaseName: 'akamai-agent',
178
+ helmChartName: ' axway/akamai-agent',
179
+ overrideFileName: ConfigFiles.helmOverride,
180
+ imageSecretOverrides: `--set image.pullSecret=<image-pull-secret-name>`
181
+ });
182
+ helpers.helmInstallInfo('Akamai', namespace, agentHelmInfo);
183
+ };
184
+ const generateSuccessHelpMsg = installConfig => {
185
+ const akamaiAgentValues = installConfig.gatewayConfig;
186
+ const configType = installConfig.deploymentType;
187
+ if (installConfig.centralConfig.ampcDosaInfo.isNew && !installConfig.switches.isHelmInstall) {
188
+ console.log(_chalk.default.yellow(_agents.svcAccMsg));
189
+ }
190
+ if (configType === _types.AgentConfigTypes.DOCKERIZED) {
191
+ dockerSuccessMsg(installConfig);
192
+ } else if (configType === _types.AgentConfigTypes.HELM) {
193
+ helmSuccessMsg(akamaiAgentValues.namespace.name);
194
+ }
195
+ console.log('Configuration file(s) have been successfully created.\n');
196
+ console.log(_chalk.default.gray(`\nAdditional information about agent features can be found here:\n${helpers.agentsDocsUrl.AKAMAI}`));
197
+ };
198
+ const completeInstall = async installConfig => {
199
+ // Add final settings to AkamaiAgentValues
200
+ const akamaiAgentValues = installConfig.gatewayConfig;
201
+ akamaiAgentValues.centralConfig = installConfig.centralConfig;
202
+ akamaiAgentValues.traceabilityConfig = installConfig.traceabilityConfig;
203
+ if (installConfig.switches.isHelmInstall) {
204
+ akamaiAgentValues.akamaiSecret = helpers.amplifyAgentsCredsSecret;
205
+ akamaiAgentValues.agentKeysSecret = helpers.amplifyAgentsKeysSecret;
206
+ if (akamaiAgentValues.namespace.isNew) {
207
+ await helpers.createNamespace(akamaiAgentValues.namespace.name);
208
+ }
209
+ await helpers.createSecret(akamaiAgentValues.namespace.name, helpers.amplifyAgentsKeysSecret, async () => {
210
+ if (installConfig.centralConfig.ampcDosaInfo.isNew) {
211
+ console.log(_chalk.default.yellow(`The secret '${helpers.amplifyAgentsKeysSecret}' will be created with the same "private_key.pem" and "public_key.pem" that was auto generated to create the Service Account.`));
212
+ }
213
+ await helpers.createAmplifyAgentKeysSecret(akamaiAgentValues.namespace.name, helpers.amplifyAgentsKeysSecret, 'publicKey', akamaiAgentValues.centralConfig.dosaAccount.publicKey, 'privateKey', akamaiAgentValues.centralConfig.dosaAccount.privateKey);
214
+ });
215
+ await helpers.createSecret(akamaiAgentValues.namespace.name, helpers.amplifyAgentsCredsSecret, async () => {
216
+ await createAkamaiCredsSecret(akamaiAgentValues.namespace.name, helpers.amplifyAgentsCredsSecret, akamaiAgentValues.akamaiSecret, akamaiAgentValues.agentKeysSecret);
217
+ });
218
+ }
219
+ console.log('Generating the configuration file(s)...');
220
+ if (installConfig.switches.isDockerInstall) {
221
+ (0, _utils.writeTemplates)(ConfigFiles.agentEnvVars, akamaiAgentValues, helpers.akamaiEnvVarTemplate);
222
+ } else if (installConfig.switches.isHelmInstall) {
223
+ (0, _utils.writeTemplates)(ConfigFiles.helmOverride, akamaiAgentValues, helpers.akamaiHelmOverrideTemplate);
224
+ }
225
+ generateSuccessHelpMsg(installConfig);
226
+ };
227
+ exports.completeInstall = completeInstall;
228
+ const createAkamaiCredsSecret = async (namespace, secretName, clientID, clientSecret) => {
229
+ const {
230
+ error
231
+ } = await _Kubectl.kubectl.create('secret', `-n ${namespace} generic ${secretName} \
232
+ --from-literal=clientID=${clientID} \
233
+ --from-literal=clientSecret=${clientSecret}`);
234
+ if (error) {
235
+ throw Error(error);
236
+ }
237
+ console.log(`Created ${secretName} in the ${namespace} namespace.`);
238
+ };
239
+ const AkamaiInstallMethods = exports.AkamaiInstallMethods = {
240
+ GetBundleType: askBundleType,
241
+ GetDeploymentType: askConfigType,
242
+ AskGatewayQuestions: gatewayConnectivity,
243
+ FinalizeGatewayInstall: completeInstall,
244
+ ConfigFiles: Object.values(ConfigFiles),
245
+ AgentNameMap: {
246
+ [_types.AgentTypes.ca]: _types.AgentNames.AKAMAI_CA
247
+ },
248
+ GatewayDisplay: _types.GatewayTypes.AKAMAI
249
+ };
250
+ const testables = exports.testables = {
251
+ prompts,
252
+ ConfigFiles,
253
+ askEnvironments,
254
+ gatewayConnectivity,
255
+ createAkamaiCredsSecret
256
+ };
@@ -0,0 +1,285 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.testables = exports.askBundleType = exports.AkamaiSaaSInstallMethods = void 0;
7
+ var _snooplogg = _interopRequireDefault(require("snooplogg"));
8
+ var _types = require("../../common/types");
9
+ var _chalk = _interopRequireDefault(require("chalk"));
10
+ var _basicPrompts = require("../../common/basicPrompts");
11
+ var helpers = _interopRequireWildcard(require("./helpers"));
12
+ var _crypto = _interopRequireDefault(require("crypto"));
13
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
16
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
17
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
+ const {
19
+ log
20
+ } = (0, _snooplogg.default)('engage: install: agents: Akamai');
21
+ class DataplaneConfig {
22
+ constructor(type) {
23
+ _defineProperty(this, "type", void 0);
24
+ this.type = type || '';
25
+ }
26
+ }
27
+ class AkamaiDataplaneConfig extends DataplaneConfig {
28
+ constructor(clientId, baseUrl, segmentLength, groups) {
29
+ super("Akamai");
30
+ _defineProperty(this, "clientId", void 0);
31
+ _defineProperty(this, "baseUrl", void 0);
32
+ _defineProperty(this, "segmentLength", void 0);
33
+ _defineProperty(this, "groups", void 0);
34
+ this.clientId = clientId;
35
+ this.baseUrl = baseUrl;
36
+ this.segmentLength = segmentLength;
37
+ this.groups = groups;
38
+ }
39
+ }
40
+ class AkamaiGroups {
41
+ constructor(akamai, environment) {
42
+ _defineProperty(this, "akamai", void 0);
43
+ _defineProperty(this, "environment", void 0);
44
+ this.akamai = akamai;
45
+ this.environment = environment;
46
+ }
47
+ }
48
+ class SaasAgentValues {
49
+ constructor() {
50
+ _defineProperty(this, "dataplaneConfig", void 0);
51
+ _defineProperty(this, "centralConfig", void 0);
52
+ this.dataplaneConfig = new DataplaneConfig();
53
+ this.centralConfig = new _types.CentralAgentConfig();
54
+ }
55
+ getAccessData() {
56
+ return '';
57
+ }
58
+ }
59
+ class SaasAkamaiAgentValues extends SaasAgentValues {
60
+ constructor() {
61
+ super();
62
+ _defineProperty(this, "baseUrl", void 0);
63
+ _defineProperty(this, "clientId", void 0);
64
+ _defineProperty(this, "clientSecret", void 0);
65
+ _defineProperty(this, "segmentLength", void 0);
66
+ _defineProperty(this, "environments", void 0);
67
+ _defineProperty(this, "centralEnvironments", void 0);
68
+ this.baseUrl = '';
69
+ this.clientId = '';
70
+ this.clientSecret = '';
71
+ this.segmentLength = 1;
72
+ this.environments = [];
73
+ this.centralEnvironments = [];
74
+ }
75
+ getAccessData() {
76
+ let data = JSON.stringify({
77
+ client_secret: this.clientSecret
78
+ });
79
+ return data;
80
+ }
81
+ }
82
+
83
+ // ConfigFiles - all the config file that are used in the setup
84
+ const ConfigFiles = {};
85
+
86
+ // AkamaiSaaSPrompts - all Akamai Saas prompts to the user for input
87
+ const SaasPrompts = {
88
+ configTypeMsg: 'Select the mode of installation',
89
+ agentNamespace: 'Enter the namespace to use for the Amplify Akamai Agents',
90
+ enterBaseUrl: 'Enter the Akamai Base URL',
91
+ enterClientId: 'Enter the Akamai Client ID',
92
+ enterClientSecret: 'Enter the Akamai Client Secret',
93
+ enterSegmentLength: 'Enter the Akamai Segment Length',
94
+ enterEnvironments: 'Enter an Akamai environment',
95
+ enterMoreEnvironments: 'Do you want to enter another mapping?',
96
+ selectCentralMappingEnvironment: 'Select an Engage environment to map to the provided Akamai environment',
97
+ environmentsDescription: 'Configure a mapping of Akamai environment to Engage environment that the agent will use'
98
+ };
99
+ const askBundleType = async () => {
100
+ return _types.BundleType.TRACEABILITY;
101
+ };
102
+ exports.askBundleType = askBundleType;
103
+ const askConfigType = async () => {
104
+ return _types.AgentConfigTypes.HOSTED;
105
+ };
106
+ const askEnvironments = async (centralEnvs, hostedAgentValues, excludeEnvironment) => {
107
+ // Filter out the already-selected agent installation environment
108
+ if (excludeEnvironment) {
109
+ centralEnvs = centralEnvs.filter(env => env.name !== excludeEnvironment);
110
+ }
111
+ let askEnvs = true;
112
+ let envs = [];
113
+ let mappedCentralEnvs = [];
114
+ console.log(_chalk.default.gray(SaasPrompts.environmentsDescription));
115
+ while (askEnvs) {
116
+ const env = await (0, _basicPrompts.askInput)({
117
+ msg: SaasPrompts.enterEnvironments,
118
+ allowEmptyInput: true
119
+ });
120
+ if (envs.length === 0 && (!env || env.toString().trim() === "")) {
121
+ break;
122
+ }
123
+ if (env && env.toString().trim() !== "") {
124
+ envs.push(env);
125
+ }
126
+ const centralMappingEnv = await (0, _basicPrompts.askList)({
127
+ msg: SaasPrompts.selectCentralMappingEnvironment,
128
+ choices: centralEnvs.map(e => e.name)
129
+ });
130
+ if (centralMappingEnv && centralMappingEnv.toString().trim() !== "") {
131
+ mappedCentralEnvs.push(centralMappingEnv);
132
+ }
133
+ centralEnvs = centralEnvs.filter(env => env.name !== centralMappingEnv);
134
+
135
+ // Only ask if they want to continue if there are still environments available to map
136
+ if (centralEnvs.length > 0) {
137
+ askEnvs = (await (0, _basicPrompts.askList)({
138
+ msg: SaasPrompts.enterMoreEnvironments,
139
+ default: _types.YesNo.No,
140
+ choices: _types.YesNoChoices
141
+ })) === _types.YesNo.Yes;
142
+ } else {
143
+ askEnvs = false;
144
+ }
145
+ }
146
+ hostedAgentValues.environments = envs;
147
+ hostedAgentValues.centralEnvironments = mappedCentralEnvs;
148
+ };
149
+ const validateFrequency = () => input => {
150
+ let val = (0, _basicPrompts.validateRegex)(helpers.frequencyRegex, helpers.invalidValueExampleErrMsg('frequency', '3d5h12m'))(input);
151
+ if (typeof val === "string") {
152
+ return val;
153
+ }
154
+ let r = input.toString().match(/^(\d*)m/);
155
+ if (r) {
156
+ // only minutes
157
+ let mins = r[1];
158
+ if (parseInt(mins, 10) < 30) {
159
+ return "Minimum frequency is 30m";
160
+ }
161
+ }
162
+ return true;
163
+ };
164
+
165
+ //
166
+ // Questions for the configuration of Akamai agents
167
+ //
168
+ const askAkamaiBaseUrl = async () => await (0, _basicPrompts.askInput)({
169
+ msg: SaasPrompts.enterBaseUrl,
170
+ validate: (0, _basicPrompts.validateRegex)(helpers.AkamaiRegexPatterns.baseURLRegex, helpers.invalidValueExampleErrMsg('baseURL', 'https://akamai.com'))
171
+ });
172
+ const askAkamaiClientId = async () => await (0, _basicPrompts.askInput)({
173
+ msg: SaasPrompts.enterClientId
174
+ });
175
+ const askAkamaiClientSecret = async () => await (0, _basicPrompts.askInput)({
176
+ msg: SaasPrompts.enterClientSecret
177
+ });
178
+ const askAkamaiSegmentLength = async () => await (0, _basicPrompts.askInput)({
179
+ msg: SaasPrompts.enterSegmentLength,
180
+ type: 'number',
181
+ validate: (0, _basicPrompts.validateValueRange)(0)
182
+ });
183
+
184
+ // @ts-ignore
185
+ const gatewayConnectivity = async installConfig => {
186
+ console.log('\nCONNECTION TO AKAMAI API GATEWAY:');
187
+ // DeploymentType
188
+ let hostedAgentValues = new SaasAkamaiAgentValues();
189
+ if (installConfig.gatewayType === _types.SaaSGatewayTypes.AKAMAI) {
190
+ var _installConfig$centra;
191
+ log('gathering access details for akamai');
192
+
193
+ // Akamai connection details
194
+ hostedAgentValues = new SaasAkamaiAgentValues();
195
+ hostedAgentValues.baseUrl = await askAkamaiBaseUrl();
196
+ hostedAgentValues.clientId = await askAkamaiClientId();
197
+ hostedAgentValues.clientSecret = await askAkamaiClientSecret();
198
+ hostedAgentValues.segmentLength = await askAkamaiSegmentLength();
199
+ const centralEnvs = await helpers.getCentralEnvironments(installConfig.centralConfig.apiServerClient, installConfig.centralConfig.definitionManager);
200
+ // Pass the already-selected agent installation environment to exclude it from mapping choices
201
+ const agentInstallEnv = (_installConfig$centra = installConfig.centralConfig.ampcEnvInfo) === null || _installConfig$centra === void 0 ? void 0 : _installConfig$centra.name;
202
+ await askEnvironments(centralEnvs, hostedAgentValues, agentInstallEnv);
203
+ }
204
+ return hostedAgentValues;
205
+ };
206
+ const generateOutput = async installConfig => {
207
+ return `Install complete of hosted agent for ${installConfig.gatewayType} region`;
208
+ };
209
+ const createEncryptedAccessData = async (hostedAgentValues, dataplaneRes) => {
210
+ var _dataplaneRes$securit, _dataplaneRes$securit2;
211
+ // grab key from data plane resource
212
+ let key = ((_dataplaneRes$securit = dataplaneRes.security) === null || _dataplaneRes$securit === void 0 ? void 0 : _dataplaneRes$securit.encryptionKey) || "";
213
+ let hash = ((_dataplaneRes$securit2 = dataplaneRes.security) === null || _dataplaneRes$securit2 === void 0 ? void 0 : _dataplaneRes$securit2.encryptionHash) || "";
214
+ if (key === "" || hash === "") {
215
+ throw Error(`cannot encrypt access data as the encryption key info was incomplete`);
216
+ }
217
+ const accessData = hostedAgentValues.getAccessData();
218
+ let encData = _crypto.default.publicEncrypt({
219
+ key: key,
220
+ padding: _crypto.default.constants.RSA_PKCS1_OAEP_PADDING,
221
+ oaepHash: hash
222
+ }, new Uint8Array(Buffer.from(accessData, 'utf8')));
223
+ return encData.toString("base64");
224
+ };
225
+ const completeInstall = async (installConfig, apiServerClient, defsManager) => {
226
+ /**
227
+ * Create agent resources
228
+ */
229
+ console.log("\n");
230
+ let akamaiAgentValues = installConfig.gatewayConfig;
231
+
232
+ // create the environment, if necessary
233
+ installConfig.centralConfig.environment = installConfig.centralConfig.ampcEnvInfo.isNew ? await helpers.createByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', {
234
+ axwayManaged: installConfig.centralConfig.axwayManaged,
235
+ production: installConfig.centralConfig.production
236
+ }) : installConfig.centralConfig.ampcEnvInfo.name;
237
+ if (installConfig.gatewayType === _types.GatewayTypes.AKAMAI) {
238
+ const akamaiGroupObjs = (akamaiAgentValues.environments || []).map((env, idx) => new AkamaiGroups(env, akamaiAgentValues.centralEnvironments[idx]));
239
+ akamaiAgentValues.dataplaneConfig = new AkamaiDataplaneConfig(akamaiAgentValues.clientId, akamaiAgentValues.baseUrl, akamaiAgentValues.segmentLength, akamaiGroupObjs);
240
+ }
241
+
242
+ // create the data plane resource
243
+ let dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], akamaiAgentValues.dataplaneConfig);
244
+ // create data plane secret resource
245
+ try {
246
+ await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], dataplaneRes.name, await createEncryptedAccessData(akamaiAgentValues, dataplaneRes));
247
+ } catch (error) {
248
+ log(error);
249
+ console.log(_chalk.default.redBright("rolling back installation. Please check the credential data before re-running install"));
250
+ if (installConfig.centralConfig.ampcEnvInfo.isNew) {
251
+ await helpers.deleteByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env');
252
+ } else {
253
+ await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneRes.name, "Dataplane", "dp", installConfig.centralConfig.environment);
254
+ }
255
+ return;
256
+ }
257
+
258
+ // create compliance agent resource
259
+ installConfig.centralConfig.taAgentName = await helpers.createNewAgentResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], _types.AgentResourceKind.ca, _types.AgentTypes.ca, installConfig.centralConfig.ampcTeamName, _types.GatewayTypeToDataPlane[installConfig.gatewayType] + " Compliance Agent", dataplaneRes.name);
260
+ console.log(await generateOutput(installConfig));
261
+ };
262
+ const AkamaiSaaSInstallMethods = exports.AkamaiSaaSInstallMethods = {
263
+ GetBundleType: askBundleType,
264
+ GetDeploymentType: askConfigType,
265
+ AskGatewayQuestions: gatewayConnectivity,
266
+ FinalizeGatewayInstall: completeInstall,
267
+ ConfigFiles: [],
268
+ AgentNameMap: {
269
+ [_types.AgentTypes.ca]: _types.AgentNames.AKAMAI_CA
270
+ },
271
+ GatewayDisplay: _types.GatewayTypes.AKAMAI
272
+ };
273
+
274
+ // These are the items that are not exported, but need to be for testing
275
+ const testables = exports.testables = {
276
+ SaasAgentValues,
277
+ SaasAkamaiAgentValues,
278
+ SaasPrompts,
279
+ ConfigFiles,
280
+ createEncryptedAccessData,
281
+ // <-- already exported
282
+ validateFrequency,
283
+ // <-- add this line for test access
284
+ askEnvironments // <-- add this for testing the new logic
285
+ };
@@ -367,11 +367,12 @@ const createEncryptedAccessData = async (hostedAgentValues, dataplaneRes) => {
367
367
  if (key === '' || hash === '') {
368
368
  throw Error(`cannot encrypt access data as the encryption key info was incomplete`);
369
369
  }
370
+ let accessData = hostedAgentValues.getAccessData();
370
371
  let encData = _crypto.default.publicEncrypt({
371
372
  key: key,
372
373
  padding: _crypto.default.constants.RSA_PKCS1_OAEP_PADDING,
373
374
  oaepHash: hash
374
- }, Buffer.from(hostedAgentValues.getAccessData()));
375
+ }, new Uint8Array(Buffer.from(accessData, 'utf8')));
375
376
  return encData.toString('base64');
376
377
  };
377
378
  const completeInstall = async (installConfig, apiServerClient, defsManager) => {
@@ -80,6 +80,18 @@ Object.keys(_regex).forEach(function (key) {
80
80
  }
81
81
  });
82
82
  });
83
+ var _akamaiTemplates = require("./templates/akamaiTemplates");
84
+ Object.keys(_akamaiTemplates).forEach(function (key) {
85
+ if (key === "default" || key === "__esModule") return;
86
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
87
+ if (key in exports && exports[key] === _akamaiTemplates[key]) return;
88
+ Object.defineProperty(exports, key, {
89
+ enumerable: true,
90
+ get: function () {
91
+ return _akamaiTemplates[key];
92
+ }
93
+ });
94
+ });
83
95
  var _apigeexTemplates = require("./templates/apigeexTemplates");
84
96
  Object.keys(_apigeexTemplates).forEach(function (key) {
85
97
  if (key === "default" || key === "__esModule") return;
@@ -263,6 +275,7 @@ const configFiles = exports.configFiles = {
263
275
  };
264
276
  const agentsDocsUrl = exports.agentsDocsUrl = {
265
277
  V7: 'https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/connect_api_manager/index.html',
278
+ AKAMAI: 'https://docs.axway.com/bundle/amplify-central/page/docs/runtime_security/configure_runtime_compliance_akamai/index.html',
266
279
  APIGEEX: 'https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/connect_apigeex_gateway/index.html',
267
280
  AWS: 'https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/connect_aws_gateway/index.html',
268
281
  AZURE: 'https://docs.axway.com/bundle/amplify-central/page/docs/connect_manage_environ/connect_azure_gateway/index.html',
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.serviceAccountNameAlreadyExists = exports.selectServiceAccount = exports.selectAWSRegion = exports.secretAlreadyExists = exports.namespaceAlreadyExists = exports.k8sClusterMessages = exports.idpTestables = exports.idpMessages = exports.getCentralEnvironments = exports.envMessages = exports.enterServiceAccountName = exports.enterPublicKeyPath = exports.enterPrivateKeyPath = exports.enterNamespaceName = exports.enterAWSRegion = exports.createNamespace = exports.createGatewayAgentCredsSecret = exports.createAmplifyAgentKeysSecret = exports.askServiceAccountName = exports.askReferencedEnvironments = exports.askPublicKeyPath = exports.askPublicAndPrivateKeysPath = exports.askPrivateKeyPath = exports.askNamespace = exports.askKeyValuePairLoop = exports.askK8sClusterName = exports.askForSecretName = exports.askForIDPConfiguration = exports.askForIDPAuthConfiguration = exports.askEnvironmentName = exports.askDosaClientId = exports.askBundleType = exports.askArrayLoop = exports.askAgentName = exports.askAWSRegion = exports.agentMessages = exports.addIdentityProvider = void 0;
6
+ exports.serviceAccountNameAlreadyExists = exports.selectServiceAccount = exports.selectAWSRegion = exports.secretAlreadyExists = exports.namespaceAlreadyExists = exports.idpTestables = exports.idpMessages = exports.getCentralEnvironments = exports.envMessages = exports.enterServiceAccountName = exports.enterPublicKeyPath = exports.enterPrivateKeyPath = exports.enterNamespaceName = exports.enterAWSRegion = exports.createNamespace = exports.createGatewayAgentCredsSecret = exports.createAmplifyAgentKeysSecret = exports.clusterMessages = exports.askServiceAccountName = exports.askReferencedEnvironments = exports.askPublicKeyPath = exports.askPublicAndPrivateKeysPath = exports.askPrivateKeyPath = exports.askNamespace = exports.askKeyValuePairLoop = exports.askForSecretName = exports.askForIDPConfiguration = exports.askForIDPAuthConfiguration = exports.askEnvironmentName = exports.askDosaClientId = exports.askClusterName = exports.askBundleType = exports.askArrayLoop = exports.askAgentName = exports.askAWSRegion = exports.agentMessages = exports.addIdentityProvider = void 0;
7
7
  var _chalk = _interopRequireDefault(require("chalk"));
8
8
  var _snooplogg = _interopRequireDefault(require("snooplogg"));
9
9
  var _inquirer = _interopRequireDefault(require("inquirer"));
@@ -30,8 +30,8 @@ const envMessages = exports.envMessages = {
30
30
  environmentAlreadyExists: 'Environment already exists. Please enter a new name.',
31
31
  selectTeam: 'Select a team'
32
32
  };
33
- const k8sClusterMessages = exports.k8sClusterMessages = {
34
- enterK8sClusterName: 'Enter a unique k8s cluster name'
33
+ const clusterMessages = exports.clusterMessages = {
34
+ enterClusterName: 'Enter a unique cluster name'
35
35
  };
36
36
  const agentMessages = exports.agentMessages = {
37
37
  enterDiscoveryAgentName: 'Enter a new discovery agent name',
@@ -317,15 +317,15 @@ const askReferencedEnvironments = async (client, defsManager, envInfo) => {
317
317
  return selectedRefEnv;
318
318
  };
319
319
  exports.askReferencedEnvironments = askReferencedEnvironments;
320
- const askK8sClusterName = async () => {
320
+ const askClusterName = async () => {
321
321
  const name = await (0, _basicPrompts.askInput)({
322
- msg: k8sClusterMessages.enterK8sClusterName,
322
+ msg: clusterMessages.enterClusterName,
323
323
  defaultValue: cliNowString,
324
- validate: (0, _basicPrompts.runValidations)((0, _basicPrompts.validateRegex)(_regex.resourceRegex, (0, _regex.invalidResourceMsg)('K8sCluster')))
324
+ validate: (0, _basicPrompts.runValidations)((0, _basicPrompts.validateRegex)(_regex.resourceRegex, (0, _regex.invalidResourceMsg)('Cluster')))
325
325
  });
326
326
  return name;
327
327
  };
328
- exports.askK8sClusterName = askK8sClusterName;
328
+ exports.askClusterName = askClusterName;
329
329
  const askAgentName = async (client, defsManager, agentType, scopeName) => {
330
330
  var _agents;
331
331
  let resourceType;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.resourceRegex = exports.namespaceRegex = exports.maskingRegex = exports.keyFromKeyValuePairRegex = exports.invalidResourceMsg = exports.invalidNamespace = exports.invalidDosaName = exports.invalidDomainName = exports.frequencyRegex = exports.dosaRegex = exports.domainNameRegex = exports.WSO2RegexPatterns = exports.SensediaRegexPatterns = exports.KafkaRegexPatterns = exports.GitLabRegexPatterns = exports.GitHubRegexPatterns = exports.AzureRegexPatterns = exports.AWSRegexPatterns = exports.APIGEEXRegexPatterns = void 0;
6
+ exports.resourceRegex = exports.namespaceRegex = exports.maskingRegex = exports.keyFromKeyValuePairRegex = exports.invalidResourceMsg = exports.invalidNamespace = exports.invalidDosaName = exports.invalidDomainName = exports.frequencyRegex = exports.dosaRegex = exports.domainNameRegex = exports.WSO2RegexPatterns = exports.SensediaRegexPatterns = exports.KafkaRegexPatterns = exports.GitLabRegexPatterns = exports.GitHubRegexPatterns = exports.AzureRegexPatterns = exports.AkamaiRegexPatterns = exports.AWSRegexPatterns = exports.APIGEEXRegexPatterns = void 0;
7
7
  const resourceRegex = exports.resourceRegex = '^(?:[a-z0-9]*(?:\\.(?=[a-z0-9])|-+(?=[a-z0-9]))?)+[a-z0-9]$';
8
8
  const namespaceRegex = exports.namespaceRegex = '^[a-z0-9]?(?:[-a-z0-9]*[a-z0-9]){1,100}?$';
9
9
  const domainNameRegex = exports.domainNameRegex = '^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\\.)+([A-Za-z]){2,}$';
@@ -69,4 +69,7 @@ const SensediaRegexPatterns = exports.SensediaRegexPatterns = {
69
69
  noCommaRegex: '^[^,]+$',
70
70
  emailRegex: '^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$',
71
71
  urlRegex: '^(http:\/\/|https:\/\/)[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$'
72
+ };
73
+ const AkamaiRegexPatterns = exports.AkamaiRegexPatterns = {
74
+ baseURLRegex: '^(http:\/\/|https:\/\/)[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$'
72
75
  };
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.akamaiHelmOverrideTemplate = exports.akamaiEnvVarTemplate = exports.AkamaiAgentValues = void 0;
7
+ var _types = require("../../../../common/types");
8
+ var _handlebars = _interopRequireDefault(require("handlebars"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
12
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
+ /**
14
+ * @description Parameters to provide to the Akamai handlebars templates.
15
+ */
16
+ class AkamaiAgentValues {
17
+ constructor() {
18
+ _defineProperty(this, "namespace", void 0);
19
+ _defineProperty(this, "baseUrl", void 0);
20
+ _defineProperty(this, "clientId", void 0);
21
+ _defineProperty(this, "clientSecret", void 0);
22
+ _defineProperty(this, "segmentLength", void 0);
23
+ _defineProperty(this, "environments", void 0);
24
+ _defineProperty(this, "centralEnvironments", void 0);
25
+ _defineProperty(this, "centralConfig", void 0);
26
+ _defineProperty(this, "traceabilityConfig", void 0);
27
+ _defineProperty(this, "akamaiSecret", void 0);
28
+ _defineProperty(this, "agentKeysSecret", void 0);
29
+ this.namespace = {
30
+ name: '',
31
+ isNew: false
32
+ };
33
+ this.baseUrl = '';
34
+ this.clientId = '';
35
+ this.clientSecret = '';
36
+ this.segmentLength = 1;
37
+ this.environments = [];
38
+ this.centralEnvironments = [];
39
+ this.centralConfig = new _types.CentralAgentConfig();
40
+ this.traceabilityConfig = new _types.TraceabilityConfig();
41
+ this.akamaiSecret = '';
42
+ this.agentKeysSecret = '';
43
+ }
44
+ }
45
+ exports.AkamaiAgentValues = AkamaiAgentValues;
46
+ _handlebars.default.registerHelper('formatIndex', index => {
47
+ return index + 1;
48
+ });
49
+
50
+ /**
51
+ * @description Generates the helm override file for the Amplify Akamai Agent.
52
+ */
53
+ const akamaiHelmOverrideTemplate = () => {
54
+ return `---
55
+ # Akamai Agent image overrides
56
+ # image:
57
+ # fullPath:
58
+ # registry: docker.repository.axway.com
59
+ # repository: ampc-beano-docker-prod/1.1
60
+ # name: akamai-agent
61
+ # tag:
62
+ # pullPolicy: IfNotPresent
63
+ # pullSecret:
64
+
65
+ akamai:
66
+ baseUrl: {{baseUrl}}
67
+ clientId: {{clientId}}
68
+ clientSecret: {{clientSecret}}
69
+ segmentLength: {{segmentLength}}
70
+ {{#compare . environments.length 0 operator="!=" }}
71
+ {{#environments}}
72
+ akamai_environmentmapping_akamai_{{formatIndex @index}}={{.}}
73
+ akamai_environmentmapping_amplify_{{formatIndex @index}}={{lookup ../centralEnvironments @index}}
74
+ {{/environments}}
75
+ {{/compare}}
76
+
77
+ env:
78
+ CENTRAL_REGION: {{centralConfig.region}}
79
+ CENTRAL_ORGANIZATIONID: "{{centralConfig.orgId}}"
80
+ CENTRAL_TEAM: {{centralConfig.ampcTeamName}}
81
+ CENTRAL_ENVIRONMENT: {{centralConfig.environment}}
82
+ CENTRAL_AGENTNAME: {{centralConfig.caAgentName}}
83
+ CENTRAL_AUTH_CLIENTID: {{centralConfig.dosaAccount.clientId}}
84
+ `;
85
+ };
86
+
87
+ /**
88
+ * @description Generates the Amplify Akamai Agent env vars file.
89
+ */
90
+ exports.akamaiHelmOverrideTemplate = akamaiHelmOverrideTemplate;
91
+ const akamaiEnvVarTemplate = () => {
92
+ return `# Akamai configs
93
+ AKAMAI_BASEURL={{baseUrl}}
94
+ AKAMAI_CLIENTID={{clientId}}
95
+ AKAMAI_CLIENTSECRET={{clientSecret}}
96
+ AKAMAI_SEGMENTLENGTH={{segmentLength}}
97
+ {{#compare . environments.length 0 operator="!=" }}
98
+ {{#environments}}
99
+ AKAMAI_ENVIRONMENTMAPPING_AKAMAI_{{formatIndex @index}}={{.}}
100
+ AKAMAI_ENVIRONMENTMAPPING_AMPLIFY_{{formatIndex @index}}={{lookup ../centralEnvironments @index}}
101
+ {{/environments}}
102
+ {{/compare}}
103
+
104
+ # Amplify Central configs
105
+ CENTRAL_AGENTNAME={{centralConfig.caAgentName}}
106
+ CENTRAL_AUTH_CLIENTID={{centralConfig.dosaAccount.clientId}}
107
+ CENTRAL_AUTH_PRIVATEKEY={{centralConfig.dosaAccount.templatePrivateKey}}
108
+ CENTRAL_AUTH_PUBLICKEY={{centralConfig.dosaAccount.templatePublicKey}}
109
+ CENTRAL_ENVIRONMENT={{centralConfig.environment}}
110
+ CENTRAL_ORGANIZATIONID={{centralConfig.orgId}}
111
+ CENTRAL_TEAM={{centralConfig.ampcTeamName}}
112
+ CENTRAL_REGION={{centralConfig.region}}
113
+ # Logging configs
114
+ # Define the logging level: info, debug, error
115
+ LOG_LEVEL=info
116
+ # Specify where to send the log: stdout, file, both
117
+ LOG_OUTPUT=stdout
118
+ # Define where the log files are written
119
+ LOG_FILE_PATH=logs
120
+ `;
121
+ };
122
+ exports.akamaiEnvVarTemplate = akamaiEnvVarTemplate;
@@ -53,10 +53,10 @@ als:
53
53
  # pullPolicy: IfNotPresent
54
54
  # pullSecret:
55
55
 
56
- # Header publishing mode. Set to default or verbose.
56
+ # Header publishing mode. Set to ambient, default, or verbose. Ambient is the recommended baseline.
57
57
  mode: {{istioAgentValues.alsMode}}
58
58
 
59
- # Name of the k8scluster
59
+ # Name of the cluster
60
60
  clusterName: {{istioAgentValues.clusterName}}
61
61
 
62
62
  # Name of the secret containing the public & private keys used by the provided service account client ID
@@ -95,7 +95,7 @@ da:
95
95
  # Name of the secret containing the public & private keys used by the provided service account client ID
96
96
  keysSecretName: {{istioAgentValues.keysSecretName}}
97
97
 
98
- # Name of the K8SCluster the agent is connected to
98
+ # Name of the cluster the agent is connected to
99
99
  clusterName: {{istioAgentValues.clusterName}}
100
100
 
101
101
  # Resource discovery config
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.testables = exports.setupKubernetes = exports.setupIstio = exports.istioSystemNs = exports.istioPrompts = exports.installPreprocess = exports.gatewayConnectivity = exports.gatewayCertSecret = exports.defaultLogFiles = exports.createIstioOverride = exports.createIstioGatewayCert = exports.createHybridOverride = exports.createEnvResources = exports.completeInstall = exports.askIstioSecret = exports.askConfigType = exports.askBundleType = exports.amplifyAgentsNs = exports.amplifyAgentsCredsSecret = exports.ampcDemoNs = exports.IstioInstallMethods = exports.ConfigFiles = exports.AlsMode = void 0;
6
+ exports.testables = exports.setupKubernetes = exports.setupIstio = exports.istioSystemNs = exports.istioPrompts = exports.installPreprocess = exports.gatewayConnectivity = exports.gatewayCertSecret = exports.defaultLogFiles = exports.createIstioOverride = exports.createIstioGatewayCert = exports.createHybridOverride = exports.completeInstall = exports.askIstioSecret = exports.askConfigType = exports.askBundleType = exports.amplifyAgentsNs = exports.amplifyAgentsCredsSecret = exports.ampcDemoNs = exports.IstioInstallMethods = exports.ConfigFiles = exports.AlsMode = void 0;
7
7
  var _chalk = _interopRequireDefault(require("chalk"));
8
8
  var _snooplogg = _interopRequireDefault(require("snooplogg"));
9
9
  var _bashCommands = require("../../common/bashCommands");
@@ -30,6 +30,7 @@ const amplifyAgentsCredsSecret = exports.amplifyAgentsCredsSecret = 'amplify-age
30
30
  let AlsMode = exports.AlsMode = /*#__PURE__*/function (AlsMode) {
31
31
  AlsMode["Verbose"] = "verbose";
32
32
  AlsMode["Default"] = "default";
33
+ AlsMode["Ambient"] = "ambient";
33
34
  return AlsMode;
34
35
  }({}); // ConfigFiles - all the config file that are used in the setup
35
36
  const ConfigFiles = exports.ConfigFiles = {
@@ -189,12 +190,16 @@ const askALSMode = async () => {
189
190
  return (0, _basicPrompts.askList)({
190
191
  msg: istioPrompts.alsMode,
191
192
  choices: [{
193
+ name: AlsMode.Ambient.charAt(0).toUpperCase() + AlsMode.Ambient.slice(1),
194
+ value: AlsMode.Ambient
195
+ }, {
192
196
  name: AlsMode.Default.charAt(0).toUpperCase() + AlsMode.Default.slice(1),
193
197
  value: AlsMode.Default
194
198
  }, {
195
199
  name: AlsMode.Verbose.charAt(0).toUpperCase() + AlsMode.Verbose.slice(1),
196
200
  value: AlsMode.Verbose
197
- }]
201
+ }],
202
+ default: AlsMode.Ambient
198
203
  });
199
204
  };
200
205
  const askVsNamespacePrompt = async () => {
@@ -218,7 +223,7 @@ const setupKubernetes = async istioValues => {
218
223
  let istioAgentValues = istioValues.istioAgentValues;
219
224
  console.log(_chalk.default.gray(`\nThere are several steps to prepare a Kubernetes cluster for the Amplify Istio Agents.\nThe following questions collect the namespace and secret to use for the Istio gateway.\n`));
220
225
  if (istioAgentValues.alsEnabled) {
221
- console.log(_chalk.default.gray(`\nThe Istio Traceability Agent can log a minimal set of HTTP headers needed for transaction publishing (default) or it can capture all headers (verbose).\n`));
226
+ console.log(_chalk.default.gray(`\nThe Istio Traceability Agent supports three modes: default (minimal required header subset), ambient (baseline headers with optional Telemetry CR emission), and verbose (capture all request/response headers).\n`));
222
227
  istioAgentValues.alsMode = await askALSMode();
223
228
  }
224
229
  if (istioAgentValues.discoveryEnabled) {
@@ -233,7 +238,7 @@ const setupKubernetes = async istioValues => {
233
238
 
234
239
  // set keySecretName
235
240
  istioAgentValues.keysSecretName = helpers.amplifyAgentsKeysSecret;
236
- istioAgentValues.clusterName = await (0, _helpers.askK8sClusterName)();
241
+ istioAgentValues.clusterName = await (0, _helpers.askClusterName)();
237
242
  return istioAgentValues;
238
243
  };
239
244
  exports.setupKubernetes = setupKubernetes;
@@ -273,11 +278,6 @@ const createIstioOverride = overrides => {
273
278
  }
274
279
  };
275
280
  exports.createIstioOverride = createIstioOverride;
276
- const createEnvResources = async (client, defs, clusterName) => {
277
- // Create the mesh K8SCluster resource
278
- await helpers.createByResourceType(client, defs, clusterName, 'K8SCluster', 'k8sc', {}, '');
279
- };
280
- exports.createEnvResources = createEnvResources;
281
281
  const createHybridOverride = overrides => {
282
282
  const overrideFileName = ConfigFiles.HybridOverrideFile;
283
283
  (0, _utils.writeTemplates)(overrideFileName, overrides, helpers.istioAgentsTemplate);
@@ -90,8 +90,8 @@ const getCentralConfig = async (apiServerClient, platformClient, defsManager, ap
90
90
  centralConfig.taAgentName = '';
91
91
  centralConfig.caAgentName = '';
92
92
 
93
- // Determine if we should use CA (compliance) or TA agent. Compliance is good for TRACEABLE and GRAYLOG (atm)
94
- const isCaType = installConfig.gatewayType === _types.GatewayTypes.TRACEABLE || installConfig.gatewayType === _types.GatewayTypes.GRAYLOG;
93
+ // Determine if we should use CA (compliance) or TA agent. Compliance is good for TRACEABLE, AKAMAI and GRAYLOG (atm)
94
+ const isCaType = installConfig.gatewayType === _types.GatewayTypes.TRACEABLE || installConfig.gatewayType === _types.GatewayTypes.AKAMAI || installConfig.gatewayType === _types.GatewayTypes.GRAYLOG;
95
95
  const agentType = isCaType ? _types.AgentTypes.ca : _types.AgentTypes.ta;
96
96
  const agentNameProperty = isCaType ? 'caAgentName' : 'taAgentName';
97
97
  if (installConfig.switches.isTaEnabled && !installConfig.switches.isHostedInstall) {
@@ -209,7 +209,7 @@ const createEncryptedAccessData = async (hostedAgentValues, dataplaneRes) => {
209
209
  key: key,
210
210
  padding: _crypto.default.constants.RSA_PKCS1_OAEP_PADDING,
211
211
  oaepHash: hash
212
- }, Buffer.from(accessData));
212
+ }, new Uint8Array(Buffer.from(accessData, 'utf8')));
213
213
  return encData.toString("base64");
214
214
  };
215
215
  const completeInstall = async (installConfig, apiServerClient, defsManager) => {
@@ -186,6 +186,7 @@ let BundleType = exports.BundleType = /*#__PURE__*/function (BundleType) {
186
186
  return BundleType;
187
187
  }({});
188
188
  let AgentNames = exports.AgentNames = /*#__PURE__*/function (AgentNames) {
189
+ AgentNames["AKAMAI_CA"] = "akamai-compliance-agent";
189
190
  AgentNames["AWS_DA"] = "aws-apigw-discovery-agent";
190
191
  AgentNames["AWS_TA"] = "aws-apigw-traceability-agent";
191
192
  AgentNames["GITHUB_DA"] = "github-discovery-agent";
@@ -216,6 +217,7 @@ let AgentNames = exports.AgentNames = /*#__PURE__*/function (AgentNames) {
216
217
  return AgentNames;
217
218
  }({});
218
219
  let GatewayTypes = exports.GatewayTypes = /*#__PURE__*/function (GatewayTypes) {
220
+ GatewayTypes["AKAMAI"] = "Akamai";
219
221
  GatewayTypes["EDGE_GATEWAY"] = "Amplify API Gateway";
220
222
  GatewayTypes["APIGEEX_GATEWAY"] = "Apigee X Gateway";
221
223
  GatewayTypes["AWS_GATEWAY"] = "Amazon API Gateway";
@@ -236,6 +238,7 @@ let GatewayTypes = exports.GatewayTypes = /*#__PURE__*/function (GatewayTypes) {
236
238
  return GatewayTypes;
237
239
  }({});
238
240
  let SaaSGatewayTypes = exports.SaaSGatewayTypes = /*#__PURE__*/function (SaaSGatewayTypes) {
241
+ SaaSGatewayTypes["AKAMAI"] = "Akamai";
239
242
  SaaSGatewayTypes["AWS_GATEWAY"] = "Amazon API Gateway";
240
243
  SaaSGatewayTypes["APIGEEX_GATEWAY"] = "Apigee X Gateway";
241
244
  SaaSGatewayTypes["GITHUB"] = "GitHub";
@@ -244,6 +247,7 @@ let SaaSGatewayTypes = exports.SaaSGatewayTypes = /*#__PURE__*/function (SaaSGat
244
247
  return SaaSGatewayTypes;
245
248
  }({});
246
249
  let DataPlaneNames = exports.DataPlaneNames = /*#__PURE__*/function (DataPlaneNames) {
250
+ DataPlaneNames["AKAMAI"] = "Akamai";
247
251
  DataPlaneNames["APIGEEX"] = "Apigee X";
248
252
  DataPlaneNames["AWS"] = "AWS";
249
253
  DataPlaneNames["GITHUB"] = "GitHub";
@@ -266,6 +270,7 @@ let DataPlaneNames = exports.DataPlaneNames = /*#__PURE__*/function (DataPlaneNa
266
270
  return DataPlaneNames;
267
271
  }({});
268
272
  const GatewayTypeToDataPlane = exports.GatewayTypeToDataPlane = {
273
+ [GatewayTypes.AKAMAI]: DataPlaneNames.AKAMAI,
269
274
  [GatewayTypes.EDGE_GATEWAY]: DataPlaneNames.EDGE,
270
275
  [GatewayTypes.EDGE_GATEWAY_ONLY]: DataPlaneNames.EDGE,
271
276
  [GatewayTypes.APIGEEX_GATEWAY]: DataPlaneNames.APIGEEX,
@@ -409,6 +414,7 @@ class AgentInstallConfig {
409
414
  _defineProperty(this, "deploymentType", void 0);
410
415
  _defineProperty(this, "daVersion", void 0);
411
416
  _defineProperty(this, "taVersion", void 0);
417
+ _defineProperty(this, "caVersion", void 0);
412
418
  _defineProperty(this, "gatewayConfig", void 0);
413
419
  _defineProperty(this, "idpConfig", void 0);
414
420
  _defineProperty(this, "traceabilityConfig", void 0);
@@ -421,6 +427,7 @@ class AgentInstallConfig {
421
427
  this.idpConfig = [[], []];
422
428
  this.daVersion = 'latest';
423
429
  this.taVersion = 'latest';
430
+ this.caVersion = 'latest';
424
431
  this.switches = new AgentInstallSwitches();
425
432
  this.traceabilityConfig = new TraceabilityConfig();
426
433
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axway/axway-central-cli",
3
- "version": "4.7.0",
3
+ "version": "4.9.0-rc.0",
4
4
  "description": "Manage APIs, services and publish to the Amplify Marketplace",
5
5
  "homepage": "https://platform.axway.com",
6
6
  "author": {