@axway/axway-central-cli 2.17.0-rc.5 → 2.17.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.
Files changed (58) hide show
  1. package/dist/cli.js +28 -6
  2. package/dist/commands/apply/index.js +24 -9
  3. package/dist/commands/completion/index.js +9 -3
  4. package/dist/commands/config/common/index.js +11 -2
  5. package/dist/commands/config/index.js +7 -2
  6. package/dist/commands/config/list.js +6 -2
  7. package/dist/commands/config/set.js +31 -4
  8. package/dist/commands/config/unset.js +12 -2
  9. package/dist/commands/create/agentResource.js +32 -12
  10. package/dist/commands/create/environment.js +16 -6
  11. package/dist/commands/create/index.js +26 -9
  12. package/dist/commands/create/serviceAccount.js +6 -2
  13. package/dist/commands/delete/index.js +33 -15
  14. package/dist/commands/edit/environment.js +21 -6
  15. package/dist/commands/edit/index.js +8 -4
  16. package/dist/commands/get/index.js +44 -27
  17. package/dist/commands/install/agents.js +73 -44
  18. package/dist/commands/install/apigeexSaasAgents.js +98 -35
  19. package/dist/commands/install/awsAgents.js +139 -89
  20. package/dist/commands/install/awsSaasAgents.js +142 -50
  21. package/dist/commands/install/azureAgents.js +79 -39
  22. package/dist/commands/install/edgeAgents.js +110 -17
  23. package/dist/commands/install/helpers/creators.js +70 -17
  24. package/dist/commands/install/helpers/deleters.js +11 -2
  25. package/dist/commands/install/helpers/getters.js +30 -4
  26. package/dist/commands/install/helpers/index.js +48 -13
  27. package/dist/commands/install/helpers/inputs.js +98 -26
  28. package/dist/commands/install/helpers/regex.js +34 -29
  29. package/dist/commands/install/helpers/templates/awsTemplates.js +23 -6
  30. package/dist/commands/install/helpers/templates/azureTemplates.js +24 -5
  31. package/dist/commands/install/helpers/templates/edgeTemplates.js +38 -7
  32. package/dist/commands/install/helpers/templates/istioTemplates.js +16 -5
  33. package/dist/commands/install/index.js +10 -4
  34. package/dist/commands/install/istioAgents.js +117 -40
  35. package/dist/commands/install/platform.js +52 -20
  36. package/dist/commands/proxies/create.js +18 -2
  37. package/dist/commands/proxies/index.js +8 -4
  38. package/dist/commands/proxies/promote.js +21 -2
  39. package/dist/common/ApiServerClient.js +173 -64
  40. package/dist/common/CacheController.js +32 -11
  41. package/dist/common/CliConfigManager.js +27 -14
  42. package/dist/common/CompositeError.js +30 -6
  43. package/dist/common/CoreConfigController.js +40 -18
  44. package/dist/common/DefinitionsManager.js +76 -29
  45. package/dist/common/Kubectl.js +25 -2
  46. package/dist/common/PlatformClient.js +63 -19
  47. package/dist/common/Renderer.js +87 -25
  48. package/dist/common/TmpFile.js +28 -11
  49. package/dist/common/bashCommands.js +22 -3
  50. package/dist/common/basicPrompts.js +43 -8
  51. package/dist/common/dataService.js +50 -22
  52. package/dist/common/errorHandler.js +9 -0
  53. package/dist/common/resultsRenderers.js +42 -10
  54. package/dist/common/types.js +341 -116
  55. package/dist/common/utils.js +99 -37
  56. package/dist/main.js +2 -0
  57. package/package.json +2 -2
  58. package/dist/commands/install/gitHubSaasAgents.js +0 -283
@@ -4,82 +4,126 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.testables = exports.askBundleType = exports.AWSSaaSInstallMethods = void 0;
7
+
7
8
  var _chalk = _interopRequireDefault(require("chalk"));
9
+
8
10
  var _snooplogg = _interopRequireDefault(require("snooplogg"));
11
+
9
12
  var _basicPrompts = require("../../common/basicPrompts");
13
+
10
14
  var _types = require("../../common/types");
15
+
11
16
  var _utils = require("../../common/utils");
17
+
12
18
  var helpers = _interopRequireWildcard(require("./helpers"));
19
+
13
20
  var _crypto = _interopRequireDefault(require("crypto"));
14
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
21
+
22
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
+
24
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+
16
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
19
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
27
+
28
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
29
+
20
30
  const {
21
31
  log
22
32
  } = (0, _snooplogg.default)('central: install: agents: saas');
33
+
23
34
  class DataplaneConfig {
24
35
  constructor(type) {
25
36
  _defineProperty(this, "type", void 0);
37
+
26
38
  this.type = type || "";
27
39
  }
40
+
28
41
  }
42
+
29
43
  class AWSDataplaneConfig extends DataplaneConfig {
30
44
  constructor(arn) {
31
45
  super("AWS");
46
+
32
47
  _defineProperty(this, "accessLogARN", void 0);
48
+
33
49
  this.accessLogARN = arn;
34
50
  }
51
+
35
52
  }
53
+
36
54
  class Sampling {
37
55
  constructor() {
38
56
  _defineProperty(this, "percentage", void 0);
57
+
39
58
  _defineProperty(this, "allErrors", void 0);
59
+
40
60
  this.percentage = 10;
41
61
  this.allErrors = true;
42
62
  }
63
+
43
64
  }
65
+
44
66
  class Sanitize {
45
67
  constructor(k, m) {
46
68
  _defineProperty(this, "keyMatch", void 0);
69
+
47
70
  _defineProperty(this, "valueMatch", void 0);
71
+
48
72
  this.keyMatch = k;
49
73
  this.valueMatch = m;
50
74
  }
75
+
51
76
  }
77
+
52
78
  class RedactionSet {
53
79
  constructor() {
54
80
  _defineProperty(this, "show", void 0);
81
+
55
82
  _defineProperty(this, "sanitize", void 0);
83
+
56
84
  this.show = [];
57
85
  this.sanitize = [];
58
86
  }
87
+
59
88
  }
89
+
60
90
  class Redaction {
61
91
  constructor() {
62
92
  _defineProperty(this, "maskingCharacter", void 0);
93
+
63
94
  _defineProperty(this, "path", void 0);
95
+
64
96
  _defineProperty(this, "queryArgument", void 0);
97
+
65
98
  _defineProperty(this, "requestHeaders", void 0);
99
+
66
100
  _defineProperty(this, "responseHeaders", void 0);
101
+
67
102
  this.maskingCharacter = "{*}";
68
103
  this.path = [];
69
104
  this.queryArgument = new RedactionSet();
70
105
  this.requestHeaders = new RedactionSet();
71
106
  this.responseHeaders = new RedactionSet();
72
107
  }
108
+
73
109
  }
110
+
74
111
  class SaasAgentValues {
75
112
  constructor() {
76
113
  _defineProperty(this, "frequencyDA", void 0);
114
+
77
115
  _defineProperty(this, "queueDA", void 0);
116
+
78
117
  _defineProperty(this, "frequencyTA", void 0);
118
+
79
119
  _defineProperty(this, "sampling", void 0);
120
+
80
121
  _defineProperty(this, "redaction", void 0);
122
+
81
123
  _defineProperty(this, "dataplaneConfig", void 0);
124
+
82
125
  _defineProperty(this, "centralConfig", void 0);
126
+
83
127
  this.frequencyDA = '';
84
128
  this.queueDA = false;
85
129
  this.frequencyTA = '';
@@ -88,20 +132,31 @@ class SaasAgentValues {
88
132
  this.dataplaneConfig = new DataplaneConfig();
89
133
  this.centralConfig = new _types.CentralAgentConfig();
90
134
  }
135
+
91
136
  getAccessData() {
92
137
  return "";
93
138
  }
139
+
94
140
  }
141
+
95
142
  class SaasAWSAgentValues extends SaasAgentValues {
96
143
  constructor() {
97
144
  super();
145
+
98
146
  _defineProperty(this, "authType", void 0);
147
+
99
148
  _defineProperty(this, "accessKey", void 0);
149
+
100
150
  _defineProperty(this, "secretKey", void 0);
151
+
101
152
  _defineProperty(this, "region", void 0);
153
+
102
154
  _defineProperty(this, "assumeRole", void 0);
155
+
103
156
  _defineProperty(this, "externalID", void 0);
157
+
104
158
  _defineProperty(this, "accessLogARN", void 0);
159
+
105
160
  this.authType = AWSAuthType.ASSUME;
106
161
  this.accessKey = '';
107
162
  this.secretKey = '';
@@ -110,12 +165,14 @@ class SaasAWSAgentValues extends SaasAgentValues {
110
165
  this.externalID = '';
111
166
  this.accessLogARN = '';
112
167
  }
168
+
113
169
  getAccessData() {
114
170
  let data = JSON.stringify({
115
171
  region: this.region,
116
172
  roleARN: this.assumeRole,
117
173
  externalID: this.externalID
118
174
  });
175
+
119
176
  if (this.authType == AWSAuthType.KEYS) {
120
177
  data = JSON.stringify({
121
178
  region: this.region,
@@ -123,19 +180,22 @@ class SaasAWSAgentValues extends SaasAgentValues {
123
180
  secretAccessKey: this.secretKey
124
181
  });
125
182
  }
183
+
126
184
  return data;
127
185
  }
128
- }
129
186
 
130
- // ConfigFiles - all the config file that are used in the setup
131
- const ConfigFiles = {};
187
+ } // ConfigFiles - all the config file that are used in the setup
188
+
189
+
190
+ const ConfigFiles = {}; // AWSAuthType - how the agent will authenticate to AWS
132
191
 
133
- // AWSAuthType - how the agent will authenticate to AWS
134
- var AWSAuthType = /*#__PURE__*/function (AWSAuthType) {
192
+ var AWSAuthType; // AWSSaaSPrompts - all AWS Saas prompts to the user for input
193
+
194
+ (function (AWSAuthType) {
135
195
  AWSAuthType["ASSUME"] = "Assume Role Policy";
136
196
  AWSAuthType["KEYS"] = "Access and Secret Keys";
137
- return AWSAuthType;
138
- }(AWSAuthType || {}); // AWSSaaSPrompts - all AWS Saas prompts to the user for input
197
+ })(AWSAuthType || (AWSAuthType = {}));
198
+
139
199
  const SaasPrompts = {
140
200
  AUTHENTICATION_TYPE: 'Authenticate with an AssumeRole Policy or an Access Key ID and Secret Access Key',
141
201
  ACCESS_KEY: 'Enter the AWS Access Key ID the agent will use',
@@ -155,24 +215,28 @@ const SaasPrompts = {
155
215
  MASKING_CHARS: 'Enter the characters to use when sanitizing a value',
156
216
  ENTER_MORE: 'Do you want to enter another {0} for {1}'
157
217
  };
218
+
158
219
  const askBundleType = async () => {
159
220
  return await (0, _basicPrompts.askList)({
160
221
  msg: helpers.agentMessages.selectAgentType,
161
222
  choices: [_types.BundleType.ALL_AGENTS, _types.BundleType.DISCOVERY]
162
223
  });
163
224
  };
225
+
164
226
  exports.askBundleType = askBundleType;
227
+
165
228
  const askConfigType = async () => {
166
229
  return _types.AgentConfigTypes.HOSTED;
167
- };
168
-
169
- //
230
+ }; //
170
231
  // Complex prompts
171
232
  //
233
+
234
+
172
235
  const askForRedactionSet = async (setting, redactionSet) => {
173
236
  // ask for path reg exs
174
237
  let askShow = true;
175
238
  console.log(_chalk.default.gray((0, _utils.FormatString)("\nRedaction settings for {0}s", setting)));
239
+
176
240
  while (askShow) {
177
241
  const input = await (0, _basicPrompts.askInput)({
178
242
  msg: (0, _utils.FormatString)(SaasPrompts.REDACT_SHOW, setting),
@@ -186,6 +250,7 @@ const askForRedactionSet = async (setting, redactionSet) => {
186
250
  choices: _types.YesNoChoices
187
251
  })) === _types.YesNo.Yes;
188
252
  }
253
+
189
254
  console.log(_chalk.default.gray((0, _utils.FormatString)("Sanitization settings for {0}s", setting)));
190
255
  let askSanitize = (await (0, _basicPrompts.askList)({
191
256
  msg: (0, _utils.FormatString)(SaasPrompts.ENTER_SANITIZE_RULE, setting),
@@ -193,6 +258,7 @@ const askForRedactionSet = async (setting, redactionSet) => {
193
258
  choices: _types.YesNoChoices
194
259
  })) === _types.YesNo.Yes;
195
260
  console.log(_chalk.default.gray("When a match for the key regular expression is found, a match\nfor the value regular expression will be replaced by the masking character(s)"));
261
+
196
262
  while (askSanitize) {
197
263
  const keyMatch = await (0, _basicPrompts.askInput)({
198
264
  msg: (0, _utils.FormatString)(SaasPrompts.SANITIZE_KEY, setting),
@@ -204,24 +270,29 @@ const askForRedactionSet = async (setting, redactionSet) => {
204
270
  allowEmptyInput: true,
205
271
  validate: (0, _basicPrompts.validateValidRegex)()
206
272
  });
273
+
207
274
  if (keyMatch === "" || valMatch === "") {
208
275
  console.log("can't add sanitization rule with an empty key or value regular expression");
209
276
  } else {
210
277
  redactionSet.sanitize.push(new Sanitize(keyMatch, valMatch));
211
278
  }
279
+
212
280
  askSanitize = (await (0, _basicPrompts.askList)({
213
281
  msg: (0, _utils.FormatString)(SaasPrompts.ENTER_MORE, "sanitization rule", setting),
214
282
  default: _types.YesNo.No,
215
283
  choices: _types.YesNoChoices
216
284
  })) === _types.YesNo.Yes;
217
285
  }
286
+
218
287
  return redactionSet;
219
288
  };
289
+
220
290
  const askForRedaction = async hostedAgentValues => {
221
- console.log(_chalk.default.gray("\nRedaction and Sanitization settings"));
222
- // ask for path reg exps
291
+ console.log(_chalk.default.gray("\nRedaction and Sanitization settings")); // ask for path reg exps
292
+
223
293
  let askPaths = true;
224
294
  console.log(_chalk.default.gray("\nRedaction settings for URL paths"));
295
+
225
296
  while (askPaths) {
226
297
  const input = await (0, _basicPrompts.askInput)({
227
298
  msg: (0, _utils.FormatString)(SaasPrompts.REDACT_SHOW, "URL path"),
@@ -235,6 +306,7 @@ const askForRedaction = async hostedAgentValues => {
235
306
  choices: _types.YesNoChoices
236
307
  })) === _types.YesNo.Yes;
237
308
  }
309
+
238
310
  hostedAgentValues.redaction.queryArgument = await askForRedactionSet("query argument", hostedAgentValues.redaction.queryArgument);
239
311
  hostedAgentValues.redaction.requestHeaders = await askForRedactionSet("request header", hostedAgentValues.redaction.requestHeaders);
240
312
  hostedAgentValues.redaction.responseHeaders = await askForRedactionSet("response header", hostedAgentValues.redaction.responseHeaders);
@@ -245,6 +317,7 @@ const askForRedaction = async hostedAgentValues => {
245
317
  });
246
318
  return hostedAgentValues;
247
319
  };
320
+
248
321
  const askForSampling = async hostedAgentValues => {
249
322
  // ask sampling percentage
250
323
  console.log(_chalk.default.gray("\nSampling settings"));
@@ -254,20 +327,19 @@ const askForSampling = async hostedAgentValues => {
254
327
  msg: SaasPrompts.SAMP_PERCENTAGE,
255
328
  defaultValue: 10,
256
329
  validate: (0, _basicPrompts.validateValueRange)(0, 50)
257
- });
330
+ }); // ask sampling all errorsSN
258
331
 
259
- // ask sampling all errorsSN
260
332
  hostedAgentValues.sampling.allErrors = (await (0, _basicPrompts.askList)({
261
333
  msg: SaasPrompts.SAMP_ALL_ERRS,
262
334
  choices: _types.YesNoChoices
263
335
  })) === _types.YesNo.Yes;
264
336
  return hostedAgentValues;
265
337
  };
338
+
266
339
  const askForAWSCredentials = async hostedAgentValues => {
267
340
  hostedAgentValues.region = await helpers.askAWSRegion();
268
- log("gathering access details for aws");
341
+ log("gathering access details for aws"); // Ask Auth type
269
342
 
270
- // Ask Auth type
271
343
  hostedAgentValues.authType = await (0, _basicPrompts.askList)({
272
344
  msg: SaasPrompts.AUTHENTICATION_TYPE,
273
345
  default: AWSAuthType.ASSUME,
@@ -280,66 +352,73 @@ const askForAWSCredentials = async hostedAgentValues => {
280
352
  }]
281
353
  });
282
354
  console.log(_chalk.default.gray("Please refer to docs.axway.com for information on creating the necessary AWS IAM policies"));
355
+
283
356
  if (hostedAgentValues.authType === AWSAuthType.ASSUME) {
284
- log("using an assume role policy authentication");
285
- // get assume role arn
357
+ log("using an assume role policy authentication"); // get assume role arn
358
+
286
359
  hostedAgentValues.assumeRole = await (0, _basicPrompts.askInput)({
287
360
  msg: SaasPrompts.ASSUME_ROLE,
288
361
  defaultValue: hostedAgentValues.assumeRole !== '' ? hostedAgentValues.assumeRole : undefined,
289
362
  validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP_ROLE_ARN, helpers.invalidValueExampleErrMsg('assume role arn', 'arn:aws:iam::000000000000:role/name-of-role'))
290
- });
363
+ }); // get external id
291
364
 
292
- // get external id
293
365
  hostedAgentValues.externalID = await (0, _basicPrompts.askInput)({
294
366
  msg: SaasPrompts.EXTERNAL_ID,
295
367
  defaultValue: hostedAgentValues.externalID !== '' ? hostedAgentValues.externalID : undefined,
296
368
  allowEmptyInput: true
297
369
  });
298
370
  } else {
299
- log("using key and secret authentication");
300
- // get access key
371
+ log("using key and secret authentication"); // get access key
372
+
301
373
  hostedAgentValues.accessKey = await (0, _basicPrompts.askInput)({
302
374
  msg: SaasPrompts.ACCESS_KEY,
303
375
  defaultValue: hostedAgentValues.accessKey !== '' ? hostedAgentValues.accessKey : undefined,
304
376
  validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP_ACCESS_KEY_ID, helpers.invalidValueExampleErrMsg('access key id', 'AKIAIOSFODNN7EXAMPLE'))
305
- });
377
+ }); // get secret access key
306
378
 
307
- // get secret access key
308
379
  hostedAgentValues.secretKey = await (0, _basicPrompts.askInput)({
309
380
  msg: SaasPrompts.SECRET_KEY,
310
381
  defaultValue: hostedAgentValues.secretKey !== '' ? hostedAgentValues.secretKey : undefined,
311
382
  validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP_SECRET_ACCESS_KEY, helpers.invalidValueExampleErrMsg('secret access key', 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'))
312
383
  });
313
384
  }
385
+
314
386
  return hostedAgentValues;
315
387
  };
388
+
316
389
  const validateFrequency = () => input => {
317
390
  let val = (0, _basicPrompts.validateRegex)(helpers.frequencyRegex, helpers.invalidValueExampleErrMsg('frequency', '3d5h12m'))(input);
391
+
318
392
  if (typeof val === "string") {
319
393
  return val;
320
394
  }
395
+
321
396
  let r = input.toString().match(/^(\d*)m/);
397
+
322
398
  if (r) {
323
399
  // only minutes
324
400
  let mins = r[1];
401
+
325
402
  if (parseInt(mins, 10) < 30) {
326
403
  return "Minimum frequency is 30m";
327
404
  }
328
405
  }
406
+
329
407
  return true;
330
- };
408
+ }; // @ts-ignore
409
+
331
410
 
332
- // @ts-ignore
333
411
  const gatewayConnectivity = async installConfig => {
334
412
  console.log('\nCONNECTION TO AMAZON API GATEWAY:');
335
- console.log(_chalk.default.gray("The Discovery Agent needs to connect to the AWS API Gateway to discover API's for publishing to Amplify Central"));
413
+ console.log(_chalk.default.gray("The Discovery Agent needs to connect to the AWS API Gateway to discover API's for publishing to Amplify Central")); // DeploymentType
336
414
 
337
- // DeploymentType
338
415
  let hostedAgentValues = new SaasAgentValues();
416
+
339
417
  if (installConfig.gatewayType === _types.GatewayTypes.AWS_GATEWAY) {
340
418
  // AWS connection details
341
419
  hostedAgentValues = new SaasAWSAgentValues();
342
420
  hostedAgentValues = await askForAWSCredentials(hostedAgentValues);
421
+
343
422
  if (installConfig.switches.isTaEnabled) {
344
423
  console.log(_chalk.default.gray("\nThe access log ARN is a cloud watch log group amazon resource name"));
345
424
  hostedAgentValues.accessLogARN = await (0, _basicPrompts.askInput)({
@@ -347,9 +426,9 @@ const gatewayConnectivity = async installConfig => {
347
426
  validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_ACCESS_LOG_ARN, helpers.invalidValueExampleErrMsg('access log arn', 'arn:aws:logs:region:000000000000:log-group:log-group-name'))
348
427
  });
349
428
  }
350
- }
429
+ } // Ask to queue discovery now
430
+
351
431
 
352
- // Ask to queue discovery now
353
432
  log("getting the frequency and if the agent should run now");
354
433
  console.log(_chalk.default.gray("\n00d00h00m format, where 30m = 30 minutes, 1h = 1 hour, 7d = 7 days, and 7d1h30m = 7 days 1 hour and 30 minutes. Minimum of 30m."));
355
434
  hostedAgentValues.frequencyDA = await (0, _basicPrompts.askInput)({
@@ -362,6 +441,7 @@ const gatewayConnectivity = async installConfig => {
362
441
  default: _types.YesNo.No,
363
442
  choices: _types.YesNoChoices
364
443
  })) === _types.YesNo.Yes;
444
+
365
445
  if (installConfig.switches.isTaEnabled) {
366
446
  console.log(_chalk.default.gray("\n00d00h00m format, where 30m = 30 minutes, 1h = 1 hour, 7d = 7 days, and 7d1h30m = 7 days 1 hour and 30 minutes. Minimum of 30m."));
367
447
  hostedAgentValues.frequencyTA = await (0, _basicPrompts.askInput)({
@@ -373,72 +453,83 @@ const gatewayConnectivity = async installConfig => {
373
453
  hostedAgentValues = await askForSampling(hostedAgentValues);
374
454
  hostedAgentValues = await askForRedaction(hostedAgentValues);
375
455
  }
456
+
376
457
  return hostedAgentValues;
377
458
  };
459
+
378
460
  const generateOutput = async installConfig => {
379
461
  return `Install complete of hosted agent for ${installConfig.gatewayType} region`;
380
462
  };
463
+
381
464
  const createEncryptedAccessData = async (hostedAgentValues, dataplaneRes) => {
382
465
  var _dataplaneRes$securit, _dataplaneRes$securit2;
466
+
383
467
  // grab key from data plane resource
384
468
  let key = ((_dataplaneRes$securit = dataplaneRes.security) === null || _dataplaneRes$securit === void 0 ? void 0 : _dataplaneRes$securit.encryptionKey) || "";
385
469
  let hash = ((_dataplaneRes$securit2 = dataplaneRes.security) === null || _dataplaneRes$securit2 === void 0 ? void 0 : _dataplaneRes$securit2.encryptionHash) || "";
470
+
386
471
  if (key === "" || hash === "") {
387
472
  throw Error(`cannot encrypt access data as the encryption key info was incomplete`);
388
473
  }
474
+
389
475
  let encData = _crypto.default.publicEncrypt({
390
476
  key: key,
391
477
  padding: _crypto.default.constants.RSA_PKCS1_OAEP_PADDING,
392
478
  oaepHash: hash
393
479
  }, Buffer.from(hostedAgentValues.getAccessData()));
480
+
394
481
  return encData.toString("base64");
395
482
  };
483
+
396
484
  const completeInstall = async (installConfig, apiServerClient, defsManager) => {
397
485
  /**
398
486
  * Create agent resources
399
487
  */
400
488
  console.log("\n");
401
- let awsAgentValues = installConfig.gatewayConfig;
489
+ let awsAgentValues = installConfig.gatewayConfig; // create the environment, if necessary
402
490
 
403
- // create the environment, if necessary
404
491
  installConfig.centralConfig.environment = installConfig.centralConfig.ampcEnvInfo.isNew ? await helpers.createByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', {
405
492
  axwayManaged: installConfig.centralConfig.axwayManaged,
406
493
  production: installConfig.centralConfig.production
407
494
  }) : installConfig.centralConfig.ampcEnvInfo.name;
495
+
408
496
  if (installConfig.gatewayType === _types.GatewayTypes.AWS_GATEWAY) {
409
497
  awsAgentValues.dataplaneConfig = new AWSDataplaneConfig(awsAgentValues.accessLogARN);
410
- }
498
+ } // create the data plane resource
499
+
411
500
 
412
- // create the data plane resource
413
- let dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], awsAgentValues.dataplaneConfig);
501
+ let dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], awsAgentValues.dataplaneConfig); // create data plane secret resource
414
502
 
415
- // create data plane secret resource
416
503
  try {
417
504
  await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], dataplaneRes.name, await createEncryptedAccessData(awsAgentValues, dataplaneRes));
418
505
  } catch (error) {
419
506
  console.log(_chalk.default.redBright("rolling back installation. Please check the credential data before re-running install"));
507
+
420
508
  if (installConfig.centralConfig.ampcEnvInfo.isNew) {
421
509
  await helpers.deleteByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env');
422
510
  } else {
423
511
  await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneRes.name, "Dataplane", "dp", installConfig.centralConfig.environment);
424
512
  }
513
+
425
514
  return;
426
- }
515
+ } // create discovery agent resource
516
+
427
517
 
428
- // create discovery agent resource
429
518
  installConfig.centralConfig.daAgentName = await helpers.createNewAgentResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], _types.AgentResourceKind.da, _types.AgentTypes.da, installConfig.centralConfig.ampcTeamName, _types.GatewayTypeToDataPlane[installConfig.gatewayType] + " Discovery Agent", dataplaneRes.name, awsAgentValues.frequencyDA, awsAgentValues.queueDA);
519
+
430
520
  if (installConfig.switches.isTaEnabled) {
431
521
  // create traceability agent resource
432
- installConfig.centralConfig.taAgentName = await helpers.createNewAgentResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], _types.AgentResourceKind.ta, _types.AgentTypes.ta, installConfig.centralConfig.ampcTeamName, _types.GatewayTypeToDataPlane[installConfig.gatewayType] + " Traceability Agent", dataplaneRes.name, awsAgentValues.frequencyTA, false,
433
- // AWS TA is never triggered at install, as DA has to run prior
522
+ installConfig.centralConfig.taAgentName = await helpers.createNewAgentResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], _types.AgentResourceKind.ta, _types.AgentTypes.ta, installConfig.centralConfig.ampcTeamName, _types.GatewayTypeToDataPlane[installConfig.gatewayType] + " Traceability Agent", dataplaneRes.name, awsAgentValues.frequencyTA, false, // AWS TA is never triggered at install, as DA has to run prior
434
523
  {
435
524
  sampling: awsAgentValues.sampling,
436
525
  redaction: awsAgentValues.redaction
437
526
  });
438
527
  }
528
+
439
529
  console.log(await generateOutput(installConfig));
440
530
  };
441
- const AWSSaaSInstallMethods = exports.AWSSaaSInstallMethods = {
531
+
532
+ const AWSSaaSInstallMethods = {
442
533
  GetBundleType: askBundleType,
443
534
  GetDeploymentType: askConfigType,
444
535
  AskGatewayQuestions: gatewayConnectivity,
@@ -449,13 +540,14 @@ const AWSSaaSInstallMethods = exports.AWSSaaSInstallMethods = {
449
540
  [_types.AgentTypes.ta]: _types.AgentNames.AWS_TA
450
541
  },
451
542
  GatewayDisplay: _types.GatewayTypes.AWS_GATEWAY
452
- };
543
+ }; // These are the items that are not exported, but need to be for testing
453
544
 
454
- // These are the items that are not exported, but need to be for testing
455
- const testables = exports.testables = {
545
+ exports.AWSSaaSInstallMethods = AWSSaaSInstallMethods;
546
+ const testables = {
456
547
  SaasAgentValues,
457
548
  SaasAWSAgentValues,
458
549
  AWSAuthType,
459
550
  SaasPrompts,
460
551
  ConfigFiles
461
- };
552
+ };
553
+ exports.testables = testables;