@axway/axway-central-cli 2.31.0 → 2.32.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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.prompts = exports.localhost = exports.agents = void 0;
6
+ exports.validateFrequency = exports.prompts = exports.localhost = exports.agents = void 0;
7
7
  var _chalk = _interopRequireDefault(require("chalk"));
8
8
  var _snooplogg = _interopRequireDefault(require("snooplogg"));
9
9
  var _ApiServerClient = require("../../common/ApiServerClient");
@@ -103,7 +103,6 @@ const agents = exports.agents = {
103
103
  region
104
104
  });
105
105
  const defsManager = await new _DefinitionsManager.DefinitionsManager(apiServerClient).init();
106
-
107
106
  // Verify account has permission to create an environment and service account.
108
107
  const accountInfo = await platformClient.getAccountInfo();
109
108
  const isCentralAdmin = accountInfo === null || accountInfo === void 0 ? void 0 : (_accountInfo$roles = accountInfo.roles) === null || _accountInfo$roles === void 0 ? void 0 : _accountInfo$roles.includes(_CoreConfigController.AccountRole.ApiCentralAdmin);
@@ -184,6 +183,11 @@ const agents = exports.agents = {
184
183
  // Create the object of GatewayTypes -> GatewayConnectivity functions
185
184
  installConfig.gatewayConfig = await agentInstallFlow.AskGatewayQuestions(installConfig, apiServerClient, defsManager);
186
185
 
186
+ // create the Identity Provider configuration
187
+ if (agentInstallFlow.AddIDP) {
188
+ installConfig.idpConfig = await helpers.idpTestables.addIdentityProvider();
189
+ }
190
+
187
191
  // traceability options
188
192
  if (installConfig.switches.isTaEnabled && !installConfig.switches.isHostedInstall) {
189
193
  installConfig.traceabilityConfig = await platform.getTraceabilityConfig(installConfig);
@@ -240,4 +244,20 @@ function checkUserRole(isCentralAdmin, isPlatformAdmin, accountInfo, render) {
240
244
  }
241
245
  process.exit(1);
242
246
  }
243
- }
247
+ }
248
+ const validateFrequency = () => input => {
249
+ let val = (0, _basicPrompts.validateRegex)(helpers.frequencyRegex, helpers.invalidValueExampleErrMsg('frequency', '3d5h12m'))(input);
250
+ if (typeof val === 'string') {
251
+ return val;
252
+ }
253
+ let r = input.toString().match(/^(\d*)m/);
254
+ if (r) {
255
+ // only minutes
256
+ let mins = r[1];
257
+ if (parseInt(mins, 10) < 30) {
258
+ return 'Minimum frequency is 30m';
259
+ }
260
+ }
261
+ return true;
262
+ };
263
+ exports.validateFrequency = validateFrequency;
@@ -9,6 +9,7 @@ var _snooplogg = _interopRequireDefault(require("snooplogg"));
9
9
  var _basicPrompts = require("../../common/basicPrompts");
10
10
  var _types = require("../../common/types");
11
11
  var _utils = require("../../common/utils");
12
+ var _agents = require("./agents");
12
13
  var helpers = _interopRequireWildcard(require("./helpers"));
13
14
  var _crypto = _interopRequireDefault(require("crypto"));
14
15
  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); }
@@ -318,21 +319,6 @@ const askForAWSCredentials = async hostedAgentValues => {
318
319
  }
319
320
  return hostedAgentValues;
320
321
  };
321
- const validateFrequency = () => input => {
322
- let val = (0, _basicPrompts.validateRegex)(helpers.frequencyRegex, helpers.invalidValueExampleErrMsg('frequency', '3d5h12m'))(input);
323
- if (typeof val === 'string') {
324
- return val;
325
- }
326
- let r = input.toString().match(/^(\d*)m/);
327
- if (r) {
328
- // only minutes
329
- let mins = r[1];
330
- if (parseInt(mins, 10) < 30) {
331
- return 'Minimum frequency is 30m';
332
- }
333
- }
334
- return true;
335
- };
336
322
 
337
323
  // @ts-ignore
338
324
  const gatewayConnectivity = async installConfig => {
@@ -364,7 +350,7 @@ const gatewayConnectivity = async installConfig => {
364
350
  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.'));
365
351
  hostedAgentValues.frequencyDA = await (0, _basicPrompts.askInput)({
366
352
  msg: SaasPrompts.DA_FREQUENCY,
367
- validate: validateFrequency(),
353
+ validate: (0, _agents.validateFrequency)(),
368
354
  allowEmptyInput: true
369
355
  });
370
356
  hostedAgentValues.queueDA = (await (0, _basicPrompts.askList)({
@@ -377,7 +363,7 @@ const gatewayConnectivity = async installConfig => {
377
363
  hostedAgentValues.frequencyTA = await (0, _basicPrompts.askInput)({
378
364
  msg: SaasPrompts.TA_FREQUENCY,
379
365
  defaultValue: '30m',
380
- validate: validateFrequency(),
366
+ validate: (0, _agents.validateFrequency)(),
381
367
  allowEmptyInput: true
382
368
  });
383
369
  hostedAgentValues = await askForSampling(hostedAgentValues);
@@ -9,6 +9,7 @@ var _snooplogg = _interopRequireDefault(require("snooplogg"));
9
9
  var _basicPrompts = require("../../common/basicPrompts");
10
10
  var _types = require("../../common/types");
11
11
  var _utils = require("../../common/utils");
12
+ var _agents = require("./agents");
12
13
  var helpers = _interopRequireWildcard(require("./helpers"));
13
14
  var _crypto = _interopRequireDefault(require("crypto"));
14
15
  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); }
@@ -314,21 +315,6 @@ const askForAzureCredentials = async (hostedAgentValues, installConfig) => {
314
315
  }
315
316
  return hostedAgentValues;
316
317
  };
317
- const validateFrequency = () => input => {
318
- let val = (0, _basicPrompts.validateRegex)(helpers.frequencyRegex, helpers.invalidValueExampleErrMsg('frequency', '3d5h12m'))(input);
319
- if (typeof val === 'string') {
320
- return val;
321
- }
322
- let r = input.toString().match(/^(\d*)m/);
323
- if (r) {
324
- // only minutes
325
- let mins = r[1];
326
- if (parseInt(mins, 10) < 30) {
327
- return 'Minimum frequency is 30m';
328
- }
329
- }
330
- return true;
331
- };
332
318
 
333
319
  // @ts-ignore
334
320
  const gatewayConnectivity = async installConfig => {
@@ -360,7 +346,7 @@ const gatewayConnectivity = async installConfig => {
360
346
  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.'));
361
347
  hostedAgentValues.frequencyDA = await (0, _basicPrompts.askInput)({
362
348
  msg: SaasPrompts.DA_FREQUENCY,
363
- validate: validateFrequency(),
349
+ validate: (0, _agents.validateFrequency)(),
364
350
  allowEmptyInput: true
365
351
  });
366
352
  hostedAgentValues.queueDA = (await (0, _basicPrompts.askList)({
@@ -373,7 +359,7 @@ const gatewayConnectivity = async installConfig => {
373
359
  hostedAgentValues.frequencyTA = await (0, _basicPrompts.askInput)({
374
360
  msg: SaasPrompts.TA_FREQUENCY,
375
361
  defaultValue: '30m',
376
- validate: validateFrequency(),
362
+ validate: (0, _agents.validateFrequency)(),
377
363
  allowEmptyInput: true
378
364
  });
379
365
  hostedAgentValues = await askForSampling(hostedAgentValues);
@@ -384,7 +370,7 @@ const gatewayConnectivity = async installConfig => {
384
370
  const generateOutput = async installConfig => {
385
371
  return `Install complete of hosted agent for ${installConfig.gatewayType} region`;
386
372
  };
387
- const createEncryptedAccessData = async (hostedAgentValues, dataplaneRes) => {
373
+ const createEncryptedAccessData = async (agentValues, dataplaneRes) => {
388
374
  var _dataplaneRes$securit, _dataplaneRes$securit2;
389
375
  // grab key from data plane resource
390
376
  let key = ((_dataplaneRes$securit = dataplaneRes.security) === null || _dataplaneRes$securit === void 0 ? void 0 : _dataplaneRes$securit.encryptionKey) || '';
@@ -396,7 +382,7 @@ const createEncryptedAccessData = async (hostedAgentValues, dataplaneRes) => {
396
382
  key: key,
397
383
  padding: _crypto.default.constants.RSA_PKCS1_OAEP_PADDING,
398
384
  oaepHash: hash
399
- }, Buffer.from(hostedAgentValues.getAccessData()));
385
+ }, Buffer.from(agentValues.getAccessData()));
400
386
  return encData.toString('base64');
401
387
  };
402
388
  const completeInstall = async (installConfig, apiServerClient, defsManager) => {
@@ -405,12 +391,59 @@ const completeInstall = async (installConfig, apiServerClient, defsManager) => {
405
391
  */
406
392
  console.log('\n');
407
393
  let azureAgentValues = installConfig.gatewayConfig;
408
-
394
+ let resourceFuncsForCleanup = [];
395
+ let referencedIDPs = [];
396
+ let providedIDPs = installConfig.idpConfig[0];
397
+ let providedIDPAuths = installConfig.idpConfig[1];
398
+ // create Identity Provider resource
399
+ try {
400
+ for (let i = 0; i < providedIDPs.length; i++) {
401
+ let idpResource = await helpers.createNewIDPResource(apiServerClient, defsManager, providedIDPs[i]);
402
+ let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, idpResource === null || idpResource === void 0 ? void 0 : idpResource.name, 'IdentityProvider', 'idp');
403
+ resourceFuncsForCleanup.push(cleanupFunc);
404
+ referencedIDPs.push({
405
+ name: idpResource === null || idpResource === void 0 ? void 0 : idpResource.name
406
+ });
407
+ log(idpResource);
408
+ let encryptedAccessData = await createEncryptedAccessData(providedIDPAuths[i], idpResource);
409
+ providedIDPAuths[i].setAccessData(encryptedAccessData);
410
+ let idpSecResource = await helpers.createNewIDPSecretResource(apiServerClient, defsManager, providedIDPAuths[i], idpResource);
411
+ let anotherCleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, idpSecResource === null || idpSecResource === void 0 ? void 0 : idpSecResource.name, 'IdentityProviderSecret', 'idpsec', idpResource === null || idpResource === void 0 ? void 0 : idpResource.name);
412
+ resourceFuncsForCleanup.push(anotherCleanupFunc);
413
+ }
414
+ } catch (error) {
415
+ log(error);
416
+ console.log(_chalk.default.redBright('rolling back installation. Could not create the Identity Provider resources'));
417
+ await cleanResources(resourceFuncsForCleanup);
418
+ return;
419
+ }
420
+ let refIDPsSubResources = {
421
+ references: {
422
+ identityProviders: referencedIDPs
423
+ }
424
+ };
409
425
  // create the environment, if necessary
410
- installConfig.centralConfig.environment = installConfig.centralConfig.ampcEnvInfo.isNew ? await helpers.createByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', {
411
- axwayManaged: installConfig.centralConfig.axwayManaged,
412
- production: installConfig.centralConfig.production
413
- }) : installConfig.centralConfig.ampcEnvInfo.name;
426
+ if (installConfig.centralConfig.ampcEnvInfo.isNew) {
427
+ installConfig.centralConfig.environment = await helpers.createByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', {
428
+ axwayManaged: installConfig.centralConfig.axwayManaged,
429
+ production: installConfig.centralConfig.production
430
+ }, '', refIDPsSubResources);
431
+ let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env');
432
+ resourceFuncsForCleanup.push(cleanupFunc);
433
+ } else {
434
+ // if the env exists, we simply update the references with the newly created IDPs, while preserving the existing IDP references
435
+ // In the case of any failure during the whole process, we return everything back to how it was before.
436
+ installConfig.centralConfig.environment = installConfig.centralConfig.ampcEnvInfo.name;
437
+ refIDPsSubResources.references.identityProviders.push(...installConfig.centralConfig.ampcEnvInfo.referencedIdentityProviders);
438
+ await helpers.updateSubResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', '', refIDPsSubResources);
439
+ let oldIDPRef = {
440
+ references: {
441
+ identityProviders: installConfig.centralConfig.ampcEnvInfo.referencedIdentityProviders
442
+ }
443
+ };
444
+ let cleanupFunc = async () => await helpers.updateSubResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', '', oldIDPRef);
445
+ resourceFuncsForCleanup.push(cleanupFunc);
446
+ }
414
447
  if (installConfig.gatewayType === _types.GatewayTypes.AZURE_GATEWAY) {
415
448
  azureAgentValues.dataplaneConfig = new AzureDataplaneConfig(azureAgentValues.tenantId, azureAgentValues.resourceGroup, azureAgentValues.subscriptionId, azureAgentValues.apimManagementServiceName);
416
449
  if (installConfig.switches.isTaEnabled) {
@@ -421,24 +454,22 @@ const completeInstall = async (installConfig, apiServerClient, defsManager) => {
421
454
  let dataplaneRes;
422
455
  try {
423
456
  dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], azureAgentValues.dataplaneConfig);
457
+ let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneRes.name, 'Dataplane', 'dp', installConfig.centralConfig.environment);
458
+ resourceFuncsForCleanup.push(cleanupFunc);
424
459
  } catch (error) {
425
460
  console.log(_chalk.default.redBright('rolling back installation. Please check the configuration data before re-running install'));
426
- if (installConfig.centralConfig.ampcEnvInfo.isNew) {
427
- await helpers.deleteByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env');
428
- }
461
+ await cleanResources(resourceFuncsForCleanup);
429
462
  return;
430
463
  }
431
464
 
432
465
  // create data plane secret resource
433
466
  try {
434
- await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], dataplaneRes.name, await createEncryptedAccessData(azureAgentValues, dataplaneRes));
467
+ let dataplaneSecretRes = await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], dataplaneRes.name, await createEncryptedAccessData(azureAgentValues, dataplaneRes));
468
+ let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneSecretRes === null || dataplaneSecretRes === void 0 ? void 0 : dataplaneSecretRes.name, 'DataplaneSecret', 'dps', installConfig.centralConfig.environment);
469
+ resourceFuncsForCleanup.push(cleanupFunc);
435
470
  } catch (error) {
436
471
  console.log(_chalk.default.redBright('rolling back installation. Please check the credential data before re-running install'));
437
- if (installConfig.centralConfig.ampcEnvInfo.isNew) {
438
- await helpers.deleteByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env');
439
- } else {
440
- await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneRes.name, 'Dataplane', 'dp', installConfig.centralConfig.environment);
441
- }
472
+ await cleanResources(resourceFuncsForCleanup);
442
473
  return;
443
474
  }
444
475
 
@@ -459,6 +490,7 @@ const AzureSaaSInstallMethods = exports.AzureSaaSInstallMethods = {
459
490
  GetBundleType: askBundleType,
460
491
  GetDeploymentType: askConfigType,
461
492
  AskGatewayQuestions: gatewayConnectivity,
493
+ AddIDP: true,
462
494
  FinalizeGatewayInstall: completeInstall,
463
495
  ConfigFiles: [],
464
496
  AgentNameMap: {
@@ -474,4 +506,12 @@ const testables = exports.testables = {
474
506
  SaasAzureAgentValues,
475
507
  SaasPrompts,
476
508
  ConfigFiles
509
+ };
510
+ // These are useful because there are multiple resources created in a specific order and in case of failure, this goes through
511
+ // everything that was created and deletes it one by one. It deletes the resources in opposite order because resources added
512
+ // at the beginning might be referred by resources added afterwards
513
+ const cleanResources = async cleanupFuncs => {
514
+ for (let i = cleanupFuncs.length - 1; i >= 0; i--) {
515
+ await cleanupFuncs[i]();
516
+ }
477
517
  };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.updateSubResourceType = exports.createSecret = exports.createNewDataPlaneSecretResource = exports.createNewDataPlaneResource = exports.createNewAgentResource = exports.createDosaAndCerts = exports.createByResourceType = exports.createBackUpConfigs = void 0;
6
+ exports.updateSubResourceType = exports.createSecret = exports.createNewIDPSecretResource = exports.createNewIDPResource = exports.createNewDataPlaneSecretResource = exports.createNewDataPlaneResource = exports.createNewAgentResource = exports.createDosaAndCerts = exports.createByResourceType = exports.createBackUpConfigs = void 0;
7
7
  var _chalk = _interopRequireDefault(require("chalk"));
8
8
  var _snooplogg = _interopRequireDefault(require("snooplogg"));
9
9
  var _fsExtra = _interopRequireDefault(require("fs-extra"));
@@ -257,13 +257,91 @@ const createNewDataPlaneSecretResource = async (client, defsManager, envName, da
257
257
  return result.data;
258
258
  };
259
259
 
260
+ /**
261
+ * @description Helper func to create a new Identity Provider resource
262
+ * @param client API Service Client
263
+ * @param defsManager Definition Manager
264
+ * @param idpConfig IDP Configuration from inputs
265
+ */
266
+ exports.createNewDataPlaneSecretResource = createNewDataPlaneSecretResource;
267
+ const createNewIDPResource = async (client, defsManager, idpConfig) => {
268
+ console.log(`Creating a new Identity Provider resource.`);
269
+ // NOTE: only a first found set is used
270
+ const defs = defsManager.findDefsByWord("idp");
271
+ if (!defs) {
272
+ throw Error(`the server doesn't have a resource type Identity Provider`);
273
+ }
274
+ const result = await client.createResource({
275
+ // @ts-ignore payload
276
+ resource: {
277
+ title: idpConfig.title,
278
+ spec: idpConfig.getSpec()
279
+ },
280
+ resourceDef: defs[0].resource,
281
+ scopeDef: defs[0].scope ? defs[0].scope : undefined
282
+ });
283
+ log(result);
284
+ if (!result.data) {
285
+ var _result$error5;
286
+ const errMsg = `cannot create a new agent`;
287
+ if ((_result$error5 = result.error) !== null && _result$error5 !== void 0 && _result$error5.length) {
288
+ throw Error(`${errMsg}: ${result.error[0].detail}.`);
289
+ } else {
290
+ throw Error(`${errMsg}.`);
291
+ }
292
+ } else {
293
+ console.log(`New Identity Provider of type "${defs[0].resource.name}" named "${result.data.name}" has been successfully created.`);
294
+ }
295
+ return result.data;
296
+ };
297
+
298
+ /**
299
+ * @description Helper func to create a new Identity Provider Secret resource
300
+ * @param client API Service Client
301
+ * @param defsManager Definition Manager
302
+ * @param idpAuthConfig IDP Auth Configuration from inputs
303
+ * @param idpResource IDP Configuration received after creating the IDP from inputs
304
+ */
305
+ exports.createNewIDPResource = createNewIDPResource;
306
+ const createNewIDPSecretResource = async (client, defsManager, idpAuthConfig, idpResource) => {
307
+ console.log(`Creating a new Identity Provider Secret resource.`);
308
+ // NOTE: only a first found set is used
309
+ const defs = defsManager.findDefsByWord("idpsec");
310
+ if (!defs) {
311
+ throw Error(`the server doesn't have a resource type Identity Provider Secret`);
312
+ }
313
+ const result = await client.createResource({
314
+ // @ts-ignore payload
315
+ resource: {
316
+ title: idpResource.title + ' IDPSecret',
317
+ spec: idpAuthConfig.getSpec()
318
+ },
319
+ resourceDef: defs[0].resource,
320
+ scopeDef: defs[0].scope ? defs[0].scope : undefined,
321
+ scopeName: idpResource.name
322
+ });
323
+ log(result);
324
+ if (!result.data) {
325
+ var _result$error6;
326
+ const errMsg = `cannot create a new agent`;
327
+ if ((_result$error6 = result.error) !== null && _result$error6 !== void 0 && _result$error6.length) {
328
+ throw Error(`${errMsg}: ${result.error[0].detail}.`);
329
+ } else {
330
+ throw Error(`${errMsg}.`);
331
+ }
332
+ } else {
333
+ console.log(`New Identity Provider of type "${defs[0].resource.name}" named "${result.data.name}" has been successfully created.`);
334
+ }
335
+ return result.data;
336
+ };
337
+
260
338
  /**
261
339
  * @description Helper func to check for existing secret, and clean up old secret before creating a new one.
262
340
  * @param namespace Namespace to create the secret in.
263
341
  * @param secretName The name of the secret.
264
342
  * @param createFunc A function that will create the secret
265
343
  */
266
- exports.createNewDataPlaneSecretResource = createNewDataPlaneSecretResource;
344
+ exports.createNewIDPSecretResource = createNewIDPSecretResource;
267
345
  const createSecret = async (namespace, secretName, createFunc) => {
268
346
  const secrets = await _Kubectl.kubectl.get('secrets', `-n ${namespace} ${secretName}`);
269
347
  // NotFound errors are ok. Throw an error for anything else.
@@ -3,8 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.transactionLoggingMessages = exports.serviceAccountNameAlreadyExists = exports.selectServiceAccount = exports.selectIngestionProtocol = exports.selectAWSRegion = exports.secretAlreadyExists = exports.namespaceAlreadyExists = exports.k8sClusterMessages = exports.envMessages = exports.enterServiceAccountName = exports.enterPublicKeyPath = exports.enterPrivateKeyPath = exports.enterNamespaceName = exports.enterAWSRegion = exports.createNamespace = exports.createGatewayAgentCredsSecret = exports.createAmplifyAgentKeysSecret = exports.askToEnableTransactionLogging = exports.askServiceAccountName = exports.askReferencedEnvironments = exports.askPublicKeyPath = exports.askPublicAndPrivateKeysPath = exports.askPrivateKeyPath = exports.askNamespace = exports.askK8sClusterName = exports.askIngestionProtocol = exports.askForSecretName = exports.askEnvironmentName = exports.askDosaClientId = exports.askBundleType = exports.askAgentName = exports.askAWSRegion = exports.agentMessages = void 0;
6
+ exports.transactionLoggingMessages = exports.serviceAccountNameAlreadyExists = exports.selectServiceAccount = exports.selectIngestionProtocol = exports.selectAWSRegion = exports.secretAlreadyExists = exports.namespaceAlreadyExists = exports.k8sClusterMessages = exports.idpTestables = exports.idpMessages = exports.envMessages = exports.enterServiceAccountName = exports.enterPublicKeyPath = exports.enterPrivateKeyPath = exports.enterNamespaceName = exports.enterAWSRegion = exports.createNamespace = exports.createGatewayAgentCredsSecret = exports.createAmplifyAgentKeysSecret = exports.askToEnableTransactionLogging = exports.askServiceAccountName = exports.askReferencedEnvironments = exports.askPublicKeyPath = exports.askPublicAndPrivateKeysPath = exports.askPrivateKeyPath = exports.askNamespace = exports.askKeyValuePairLoop = exports.askK8sClusterName = exports.askIngestionProtocol = exports.askForSecretName = exports.askForIDPConfiguration = exports.askForIDPAuthConfiguration = exports.askEnvironmentName = exports.askDosaClientId = exports.askBundleType = exports.askArrayLoop = exports.askAgentName = exports.askAWSRegion = exports.agentMessages = exports.addIdentityProvider = void 0;
7
7
  var _chalk = _interopRequireDefault(require("chalk"));
8
+ var _snooplogg = _interopRequireDefault(require("snooplogg"));
8
9
  var _inquirer = _interopRequireDefault(require("inquirer"));
9
10
  var _basicPrompts = require("../../../common/basicPrompts");
10
11
  var _Kubectl = require("../../../common/Kubectl");
@@ -13,6 +14,9 @@ var _types = require("../../../common/types");
13
14
  var _getters = require("./getters");
14
15
  var _regex = require("./regex");
15
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+ const {
18
+ log
19
+ } = (0, _snooplogg.default)('central: install: agents: saas');
16
20
  const cliNowString = `cli-${Date.now()}`;
17
21
  const envMessages = exports.envMessages = {
18
22
  createNewEnvironment: 'Create a new environment',
@@ -38,6 +42,24 @@ const agentMessages = exports.agentMessages = {
38
42
  agentAlreadyExists: 'Agent already exists. Please enter a new name.',
39
43
  selectAgentType: 'Select the type of agent(s) you want to install'
40
44
  };
45
+ const idpMessages = exports.idpMessages = {
46
+ addIDP: 'Choose if you want to add an IDP Configuration. Multiple Identity providers can be configured',
47
+ enterTitle: 'Enter the title of the IDP config',
48
+ selectType: 'Select the type of the IDP',
49
+ enterMetadataURL: 'Enter the metadata URL',
50
+ provideReqHeadersRegistration: 'Add request headers used for registration calls as key-value pairs. Stops when empty key is provided',
51
+ provideQueryParamsRegistration: 'Add query parameters used for registration calls as key-value pairs. Stops when empty key is provided',
52
+ provideClientProperties: "Enter additional client properties used for registration calls as key-value pairs. Stops when empty key is provided",
53
+ enterClientTimeout: "Enter client timeout (in seconds) for dynamic registration calls. Defaults to 60s. Minimum 30s",
54
+ selectAuthType: "Select the auth type",
55
+ enterToken: "Enter the access token",
56
+ selectClientSecretAuthMethod: "Select the auth method for ClientSecret based auth",
57
+ enterClientID: "Enter the clientID",
58
+ enterClientSecret: "Enter the clientSecret",
59
+ enterClientScopes: "Enter the list of scope names",
60
+ provideReqHeadersForTokenFetch: "Enter the request headers used for the token fetch call as key-value pairs. Stops when empty input is provided",
61
+ provideQueryParamsForTokenFetch: "Enter the query parameters used for the token fetch call as key-value pairs. Stops when empty input is provided"
62
+ };
41
63
  const transactionLoggingMessages = exports.transactionLoggingMessages = {
42
64
  askToEnableLogging: 'Would you like to enable transaction logging?',
43
65
  transactionLoggingInfoMsg: 'Transaction logging is optional and not required for usage and metrics logging.\nTurning on transaction logging can have an impact on performance.',
@@ -242,12 +264,13 @@ const askEnvironmentName = async (client, defsManager, isAxwayManaged = null) =>
242
264
  isNew: true
243
265
  };
244
266
  } else {
245
- var _selectedEnv$referenc;
267
+ var _selectedEnv$referenc, _selectedEnv$referenc2, _selectedEnv$referenc3, _selectedEnv$referenc4;
246
268
  const selectedEnv = envs.find(env => env.name == answer);
247
269
  return {
248
270
  name: answer,
249
271
  isNew: false,
250
- referencedEnvironments: selectedEnv === null || selectedEnv === void 0 ? void 0 : (_selectedEnv$referenc = selectedEnv.references) === null || _selectedEnv$referenc === void 0 ? void 0 : _selectedEnv$referenc.managedEnvironments
272
+ referencedEnvironments: selectedEnv !== null && selectedEnv !== void 0 && (_selectedEnv$referenc = selectedEnv.references) !== null && _selectedEnv$referenc !== void 0 && _selectedEnv$referenc.managedEnvironments ? selectedEnv === null || selectedEnv === void 0 ? void 0 : (_selectedEnv$referenc2 = selectedEnv.references) === null || _selectedEnv$referenc2 === void 0 ? void 0 : _selectedEnv$referenc2.managedEnvironments : [],
273
+ referencedIdentityProviders: selectedEnv !== null && selectedEnv !== void 0 && (_selectedEnv$referenc3 = selectedEnv.references) !== null && _selectedEnv$referenc3 !== void 0 && _selectedEnv$referenc3.identityProviders ? selectedEnv === null || selectedEnv === void 0 ? void 0 : (_selectedEnv$referenc4 = selectedEnv.references) === null || _selectedEnv$referenc4 === void 0 ? void 0 : _selectedEnv$referenc4.identityProviders : []
251
274
  };
252
275
  }
253
276
  };
@@ -448,4 +471,166 @@ const askToEnableTransactionLogging = async () => {
448
471
  };
449
472
  }
450
473
  };
451
- exports.askToEnableTransactionLogging = askToEnableTransactionLogging;
474
+ exports.askToEnableTransactionLogging = askToEnableTransactionLogging;
475
+ const askKeyValuePairLoop = async (msg, keyLabel, validateFunc) => {
476
+ let key = "non-empty";
477
+ let map = new Map();
478
+ console.log(_chalk.default.cyan(msg));
479
+ while (key != "") {
480
+ key = await (0, _basicPrompts.askInput)({
481
+ msg: `Enter the ${keyLabel} name`,
482
+ allowEmptyInput: true,
483
+ validate: validateFunc
484
+ });
485
+ if (key === "") {
486
+ return map;
487
+ }
488
+ let value = await (0, _basicPrompts.askInput)({
489
+ msg: `Enter the ${keyLabel} value`
490
+ });
491
+ map.set(key, value);
492
+ }
493
+ return map;
494
+ };
495
+ exports.askKeyValuePairLoop = askKeyValuePairLoop;
496
+ const askArrayLoop = async msg => {
497
+ let value = "non-empty";
498
+ let array = [];
499
+ console.log(_chalk.default.gray(msg));
500
+ while (value != "") {
501
+ value = await (0, _basicPrompts.askInput)({
502
+ msg: "Enter the value",
503
+ allowEmptyInput: true
504
+ });
505
+ if (value === "") {
506
+ return array;
507
+ }
508
+ array.push(value);
509
+ }
510
+ return array;
511
+ };
512
+ exports.askArrayLoop = askArrayLoop;
513
+ const addIdentityProvider = async () => {
514
+ let providedIDPs = [];
515
+ let providedIDPAuths = [];
516
+ while ((await (0, _basicPrompts.askList)({
517
+ msg: idpMessages.addIDP,
518
+ choices: _types.YesNoChoices,
519
+ default: _types.YesNo.Yes
520
+ })) === _types.YesNo.Yes) {
521
+ console.log("starting IDP Configuration process");
522
+ let idpConfig = new _types.IDPConfiguration();
523
+ idpConfig = await askForIDPConfiguration(idpConfig);
524
+ providedIDPs.push(idpConfig);
525
+ let idpAuthConfig = new _types.IDPAuthConfiguration();
526
+ idpAuthConfig = await askForIDPAuthConfiguration(idpAuthConfig);
527
+ providedIDPAuths.push(idpAuthConfig);
528
+ }
529
+ return [providedIDPs, providedIDPAuths];
530
+ };
531
+ exports.addIdentityProvider = addIdentityProvider;
532
+ const askForIDPAuthAccessToken = async idpAuth => {
533
+ console.log(_chalk.default.gray('gathering the access token auth configuration'));
534
+ idpAuth.token = await (0, _basicPrompts.askInput)({
535
+ msg: idpMessages.enterToken
536
+ });
537
+ return idpAuth;
538
+ };
539
+ const askForIDPAuthClientSecret = async idpAuth => {
540
+ console.log(_chalk.default.gray('gathering the client secret auth configuration'));
541
+ idpAuth.authMethod = await (0, _basicPrompts.askList)({
542
+ msg: idpMessages.selectClientSecretAuthMethod,
543
+ choices: [{
544
+ name: _types.IDPClientSecretAuthMethod.ClientSecretBasic,
545
+ value: _types.IDPClientSecretAuthMethod.ClientSecretBasic
546
+ }, {
547
+ name: _types.IDPClientSecretAuthMethod.ClientSecretPost,
548
+ value: _types.IDPClientSecretAuthMethod.ClientSecretPost
549
+ }, {
550
+ name: _types.IDPClientSecretAuthMethod.ClientSecretJWT,
551
+ value: _types.IDPClientSecretAuthMethod.ClientSecretJWT
552
+ }]
553
+ });
554
+ idpAuth.clientID = await (0, _basicPrompts.askInput)({
555
+ msg: idpMessages.enterClientID
556
+ });
557
+ idpAuth.clientSecret = await (0, _basicPrompts.askInput)({
558
+ msg: idpMessages.enterClientSecret
559
+ });
560
+ idpAuth.clientScopes = await idpTestables.askArrayLoop(idpMessages.enterClientScopes);
561
+ return idpAuth;
562
+ };
563
+ const askForIDPConfiguration = async idpConfigValues => {
564
+ console.log(_chalk.default.gray('gathering idp configuration for azure'));
565
+ idpConfigValues.title = await (0, _basicPrompts.askInput)({
566
+ msg: idpMessages.enterTitle
567
+ });
568
+ idpConfigValues.type = await (0, _basicPrompts.askList)({
569
+ msg: idpMessages.selectType,
570
+ choices: [{
571
+ name: _types.IDPType.Generic,
572
+ value: _types.IDPType.Generic
573
+ }, {
574
+ name: _types.IDPType.KeyCloak,
575
+ value: _types.IDPType.KeyCloak
576
+ }, {
577
+ name: _types.IDPType.Okta,
578
+ value: _types.IDPType.Okta
579
+ }]
580
+ });
581
+ idpConfigValues.metadataURL = await (0, _basicPrompts.askInput)({
582
+ msg: idpMessages.enterMetadataURL,
583
+ validate: (0, _basicPrompts.validateRegex)(_regex.GitLabRegexPatterns.gitLabBaseURLRegex, 'metadataURL must have a valid URL format')
584
+ });
585
+ idpConfigValues.requestHeaders = await idpTestables.askKeyValuePairLoop(idpMessages.provideReqHeadersRegistration, "request header", (0, _basicPrompts.validateRegex)(_regex.keyFromKeyValuePairRegex, 'Please enter a valid value'));
586
+ idpConfigValues.queryParameters = await idpTestables.askKeyValuePairLoop(idpMessages.provideQueryParamsRegistration, "query parameter", (0, _basicPrompts.validateRegex)(_regex.keyFromKeyValuePairRegex, 'Please enter a valid value'));
587
+ idpConfigValues.clientProperties = await idpTestables.askKeyValuePairLoop(idpMessages.provideClientProperties, "client property", (0, _basicPrompts.validateRegex)(_regex.keyFromKeyValuePairRegex, 'Please enter a valid value'));
588
+ idpConfigValues.clientTimeout = await (0, _basicPrompts.askInput)({
589
+ type: 'number',
590
+ msg: idpMessages.enterClientTimeout,
591
+ validate: (0, _basicPrompts.validateValueRange)(30, 600),
592
+ defaultValue: 60,
593
+ allowEmptyInput: true
594
+ });
595
+ return idpConfigValues;
596
+ };
597
+ exports.askForIDPConfiguration = askForIDPConfiguration;
598
+ const askForIDPAuthConfiguration = async idpConfigValues => {
599
+ console.log(_chalk.default.gray('gathering idp auth configuration for azure'));
600
+ idpConfigValues.authType = await (0, _basicPrompts.askList)({
601
+ msg: idpMessages.selectAuthType,
602
+ choices: [{
603
+ name: _types.IDPAuthType.AccessToken,
604
+ value: _types.IDPAuthType.AccessToken
605
+ }, {
606
+ name: _types.IDPAuthType.ClientSecret,
607
+ value: _types.IDPAuthType.ClientSecret
608
+ }]
609
+ });
610
+ log(idpConfigValues.authType);
611
+ switch (idpConfigValues.authType) {
612
+ case _types.IDPAuthType.AccessToken:
613
+ {
614
+ let auth = new _types.IDPAuthAccessToken();
615
+ idpConfigValues.authConfig = await askForIDPAuthAccessToken(auth);
616
+ break;
617
+ }
618
+ case _types.IDPAuthType.ClientSecret:
619
+ {
620
+ let auth = new _types.IDPAuthClientSecret();
621
+ idpConfigValues.authConfig = await askForIDPAuthClientSecret(auth);
622
+ break;
623
+ }
624
+ }
625
+ idpConfigValues.requestHeaders = await idpTestables.askKeyValuePairLoop(idpMessages.provideReqHeadersForTokenFetch, "request header", (0, _basicPrompts.validateRegex)(_regex.keyFromKeyValuePairRegex, 'Please enter a valid value'));
626
+ idpConfigValues.queryParameters = await idpTestables.askKeyValuePairLoop(idpMessages.provideQueryParamsForTokenFetch, "query parameter", (0, _basicPrompts.validateRegex)(_regex.keyFromKeyValuePairRegex, 'Please enter a valid value'));
627
+ return idpConfigValues;
628
+ };
629
+
630
+ // exported inside another object because we want to mock this function when testing
631
+ exports.askForIDPAuthConfiguration = askForIDPAuthConfiguration;
632
+ const idpTestables = exports.idpTestables = {
633
+ addIdentityProvider,
634
+ askKeyValuePairLoop,
635
+ askArrayLoop
636
+ };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.resourceRegex = exports.percentageRegex = exports.namespaceRegex = exports.maskingRegex = exports.invalidResourceMsg = exports.invalidPercentage = exports.invalidNamespace = exports.invalidDosaName = exports.invalidDomainName = exports.frequencyRegex = exports.dosaRegex = exports.domainNameRegex = exports.KafkaRegexPatterns = exports.GitLabRegexPatterns = exports.GitHubRegexPatterns = exports.AzureRegexPatterns = exports.AWSRegexPatterns = exports.APIGEEXRegexPatterns = void 0;
6
+ exports.resourceRegex = exports.percentageRegex = exports.namespaceRegex = exports.maskingRegex = exports.keyFromKeyValuePairRegex = exports.invalidResourceMsg = exports.invalidPercentage = exports.invalidNamespace = exports.invalidDosaName = exports.invalidDomainName = exports.frequencyRegex = exports.dosaRegex = exports.domainNameRegex = exports.KafkaRegexPatterns = exports.GitLabRegexPatterns = exports.GitHubRegexPatterns = exports.AzureRegexPatterns = 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,}$';
@@ -11,6 +11,7 @@ const dosaRegex = exports.dosaRegex = '^[\\w\\s-()[\\]]{1,100}$';
11
11
  const percentageRegex = exports.percentageRegex = '^[1-9]$|10$';
12
12
  const frequencyRegex = exports.frequencyRegex = '^(\\d*[d])?(\\d*[h])?(\\d*[m])?$|^$';
13
13
  const maskingRegex = exports.maskingRegex = '^[a-zA-Z0-9-*#^~.{}]{0,5}$';
14
+ const keyFromKeyValuePairRegex = exports.keyFromKeyValuePairRegex = '^[A-Za-z]+[_\-\w]+$';
14
15
  const invalidPercentage = exports.invalidPercentage = 'Percentage must be an integer between 1-10';
15
16
  const invalidDosaName = exports.invalidDosaName = 'Account name can contain A-z 0-9 _ - ( ) [ ] and can include 1-100 characters.';
16
17
  const invalidNamespace = exports.invalidNamespace = `Namespace must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character, and be fewer than 100 characters long.`;
@@ -3,8 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.docsUrl = exports.commonCmdArgsDescription = exports.cliVersionHeader = exports.YesNoChoices = exports.YesNo = exports.WAIT_TIMEOUT = exports.TrueFalseChoices = exports.TrueFalse = exports.TraceabilityConfig = exports.SingleEntryPointUrls = exports.SaaSGatewayTypes = exports.Regions = exports.PublicRepoUrl = exports.PublicDockerRepoBaseUrl = exports.Protocol = exports.ProdBaseUrls = exports.Platforms = exports.OutputTypes = exports.MAX_TABLE_STRING_LENGTH = exports.MAX_FILE_SIZE = exports.MAX_CACHE_FILE_SIZE = exports.LoggingSource = exports.KindTypes = exports.Kind = exports.IstioProfileChoices = exports.IstioInstallValues = exports.IstioAgentValues = exports.IngestionProtocolToHosts = exports.IngestionProtocol = exports.IngestionHostsHTTP = exports.IngestionHosts = exports.IngestionHTTPHosts = exports.GatewayTypes = exports.GatewayTypeToDataPlane = exports.GatewayMode = exports.EnvironmentConfigInfo = exports.DosaAccount = exports.DataPlaneNames = exports.DOSAConfigInfo = exports.ConfigTypes = exports.CloudFormationConfig = exports.Certificate = exports.CentralAgentConfig = exports.CACHE_FILE_TTL_MILLISECONDS = exports.BundleType = exports.BasePaths = exports.AuthUrls = exports.AgentTypes = exports.AgentResourceKind = exports.AgentNames = exports.AgentInstallSwitches = exports.AgentInstallConfig = exports.AgentConfigTypes = exports.AWSRegions = exports.APIGEEXDISCOVERYMODES = exports.APICDeployments = exports.ABORT_TIMEOUT = void 0;
6
+ exports.docsUrl = exports.commonCmdArgsDescription = exports.cliVersionHeader = exports.YesNoChoices = exports.YesNo = exports.WAIT_TIMEOUT = exports.TrueFalseChoices = exports.TrueFalse = exports.TraceabilityConfig = exports.SingleEntryPointUrls = exports.SaaSGatewayTypes = exports.Regions = exports.PublicRepoUrl = exports.PublicDockerRepoBaseUrl = exports.Protocol = exports.ProdBaseUrls = exports.Platforms = exports.OutputTypes = exports.MAX_TABLE_STRING_LENGTH = exports.MAX_FILE_SIZE = exports.MAX_CACHE_FILE_SIZE = exports.LoggingSource = exports.KindTypes = exports.Kind = exports.IstioProfileChoices = exports.IstioInstallValues = exports.IstioAgentValues = exports.IngestionProtocolToHosts = exports.IngestionProtocol = exports.IngestionHostsHTTP = exports.IngestionHosts = exports.IngestionHTTPHosts = exports.IDPType = exports.IDPConfiguration = exports.IDPClientSecretAuthMethod = exports.IDPAuthType = exports.IDPAuthConfiguration = exports.IDPAuthClientSecret = exports.IDPAuthAccessToken = exports.GatewayTypes = exports.GatewayTypeToDataPlane = exports.GatewayMode = exports.EnvironmentConfigInfo = exports.DosaAccount = exports.DataPlaneNames = exports.DOSAConfigInfo = exports.ConfigTypes = exports.CloudFormationConfig = exports.Certificate = exports.CentralAgentConfig = exports.CACHE_FILE_TTL_MILLISECONDS = exports.BundleType = exports.BasePaths = exports.AuthUrls = exports.AgentTypes = exports.AgentResourceKind = exports.AgentNames = exports.AgentInstallSwitches = exports.AgentInstallConfig = exports.AgentConfigTypes = exports.AWSRegions = exports.APIGEEXDISCOVERYMODES = exports.APICDeployments = exports.ABORT_TIMEOUT = void 0;
7
7
  var _dataService = require("./dataService");
8
+ var _utils = require("./utils");
8
9
  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; }
9
10
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
10
11
  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); }
@@ -310,10 +311,12 @@ class EnvironmentConfigInfo {
310
311
  _defineProperty(this, "isNew", void 0);
311
312
  _defineProperty(this, "isUpdated", void 0);
312
313
  _defineProperty(this, "referencedEnvironments", void 0);
314
+ _defineProperty(this, "referencedIdentityProviders", void 0);
313
315
  this.name = '';
314
316
  this.isNew = false;
315
317
  this.isUpdated = false;
316
318
  this.referencedEnvironments = [];
319
+ this.referencedIdentityProviders = [];
317
320
  }
318
321
  }
319
322
  exports.EnvironmentConfigInfo = EnvironmentConfigInfo;
@@ -404,6 +407,7 @@ class AgentInstallConfig {
404
407
  _defineProperty(this, "daVersion", void 0);
405
408
  _defineProperty(this, "taVersion", void 0);
406
409
  _defineProperty(this, "gatewayConfig", void 0);
410
+ _defineProperty(this, "idpConfig", void 0);
407
411
  _defineProperty(this, "traceabilityConfig", void 0);
408
412
  _defineProperty(this, "switches", void 0);
409
413
  this.centralConfig = new CentralAgentConfig();
@@ -411,6 +415,7 @@ class AgentInstallConfig {
411
415
  this.gatewayType = GatewayTypes.EDGE_GATEWAY;
412
416
  this.deploymentType = AgentConfigTypes.DOCKERIZED;
413
417
  this.gatewayConfig = new Object();
418
+ this.idpConfig = [[], []];
414
419
  this.daVersion = 'latest';
415
420
  this.taVersion = 'latest';
416
421
  this.switches = new AgentInstallSwitches();
@@ -599,4 +604,131 @@ class IstioInstallValues {
599
604
  * Invoked multiple times to indicate progress on something, such as download progress.
600
605
  * @param progress Value ranging from 0 to 100.
601
606
  */
602
- exports.IstioInstallValues = IstioInstallValues;
607
+ exports.IstioInstallValues = IstioInstallValues;
608
+ class ReqHeadersQParams {
609
+ constructor() {
610
+ _defineProperty(this, "requestHeaders", void 0);
611
+ _defineProperty(this, "queryParameters", void 0);
612
+ }
613
+ }
614
+ class IDPConfiguration extends ReqHeadersQParams {
615
+ constructor() {
616
+ super();
617
+ _defineProperty(this, "title", void 0);
618
+ _defineProperty(this, "type", void 0);
619
+ _defineProperty(this, "metadataURL", void 0);
620
+ _defineProperty(this, "clientProperties", void 0);
621
+ _defineProperty(this, "clientTimeout", void 0);
622
+ this.title = '';
623
+ this.type = IDPType.Generic;
624
+ this.metadataURL = '';
625
+ this.clientTimeout = 60;
626
+ }
627
+ getSpec() {
628
+ let spec = new Map([["metadataUrl", this.metadataURL], ["providerType", this.type], ["clientTimeout", this.clientTimeout], ["requestHeaders", this.requestHeaders ? (0, _utils.KeyValueMapToNameValueArray)(this.requestHeaders) : undefined], ["queryParameters", this.queryParameters ? (0, _utils.KeyValueMapToNameValueArray)(this.queryParameters) : undefined], ["additionalClientProperties", this.clientProperties ? (0, _utils.KeyValueMapToNameValueArray)(this.clientProperties) : undefined]]);
629
+ let omitUndefinedSpec = new Map();
630
+ spec.forEach((v, k) => {
631
+ if (v !== undefined) {
632
+ omitUndefinedSpec.set(k, v);
633
+ }
634
+ });
635
+ return Object.fromEntries(omitUndefinedSpec.entries());
636
+ }
637
+ }
638
+ exports.IDPConfiguration = IDPConfiguration;
639
+ class IDPAuthConfiguration extends ReqHeadersQParams {
640
+ constructor() {
641
+ super();
642
+ _defineProperty(this, "authType", void 0);
643
+ _defineProperty(this, "authConfig", void 0);
644
+ this.authType = IDPAuthType.AccessToken;
645
+ this.authConfig = new IDPAuthAccessToken();
646
+ }
647
+ getAccessData() {
648
+ return this.authConfig.getAccessData();
649
+ }
650
+ setAccessData(data) {
651
+ this.authConfig.setAccessData(data);
652
+ }
653
+ getSpec() {
654
+ let spec = new Map([["type", this.authType], ["config", this.authConfig.getSpec(this.authType)], ["requestHeaders", this.requestHeaders ? (0, _utils.KeyValueMapToNameValueArray)(this.requestHeaders) : undefined], ["queryParameters", this.queryParameters ? (0, _utils.KeyValueMapToNameValueArray)(this.queryParameters) : undefined]]);
655
+ let omitUndefinedSpec = new Map();
656
+ spec.forEach((v, k) => {
657
+ if (v !== undefined) {
658
+ omitUndefinedSpec.set(k, v);
659
+ }
660
+ });
661
+ return Object.fromEntries(omitUndefinedSpec.entries());
662
+ }
663
+ }
664
+
665
+ // IDPType - which idp configuration can be used
666
+ exports.IDPAuthConfiguration = IDPAuthConfiguration;
667
+ let IDPType = exports.IDPType = /*#__PURE__*/function (IDPType) {
668
+ IDPType["KeyCloak"] = "keycloak";
669
+ IDPType["Okta"] = "okta";
670
+ IDPType["Generic"] = "generic";
671
+ return IDPType;
672
+ }({});
673
+ class IDPAuthAccessToken {
674
+ constructor() {
675
+ _defineProperty(this, "token", void 0);
676
+ this.token = '';
677
+ }
678
+ getAccessData() {
679
+ return JSON.stringify({
680
+ token: this.token
681
+ });
682
+ }
683
+ setAccessData(data) {
684
+ this.token = data;
685
+ }
686
+ getSpec(authType) {
687
+ return {
688
+ type: authType,
689
+ token: this.token
690
+ };
691
+ }
692
+ }
693
+ exports.IDPAuthAccessToken = IDPAuthAccessToken;
694
+ class IDPAuthClientSecret {
695
+ constructor() {
696
+ _defineProperty(this, "authMethod", void 0);
697
+ _defineProperty(this, "clientID", void 0);
698
+ _defineProperty(this, "clientSecret", void 0);
699
+ _defineProperty(this, "clientScopes", void 0);
700
+ this.authMethod = IDPClientSecretAuthMethod.ClientSecretBasic;
701
+ this.clientID = '';
702
+ this.clientSecret = '';
703
+ }
704
+ getAccessData() {
705
+ return JSON.stringify({
706
+ clientSecret: this.clientSecret
707
+ });
708
+ }
709
+ setAccessData(data) {
710
+ this.clientSecret = data;
711
+ }
712
+ getSpec(authType) {
713
+ let spec = new Map([["type", authType], ["authMethod", this.authMethod], ["clientId", this.clientID], ["clientSecret", this.clientSecret], ["clientScopes", this.clientScopes ? this.clientScopes : undefined]]);
714
+ let omitUndefinedSpec = new Map();
715
+ spec.forEach((v, k) => {
716
+ if (v !== undefined) {
717
+ omitUndefinedSpec.set(k, v);
718
+ }
719
+ });
720
+ return Object.fromEntries(omitUndefinedSpec.entries());
721
+ }
722
+ }
723
+ exports.IDPAuthClientSecret = IDPAuthClientSecret;
724
+ let IDPClientSecretAuthMethod = exports.IDPClientSecretAuthMethod = /*#__PURE__*/function (IDPClientSecretAuthMethod) {
725
+ IDPClientSecretAuthMethod["ClientSecretBasic"] = "client_secret_basic";
726
+ IDPClientSecretAuthMethod["ClientSecretPost"] = "client_secret_post";
727
+ IDPClientSecretAuthMethod["ClientSecretJWT"] = "client_secret_jwt";
728
+ return IDPClientSecretAuthMethod;
729
+ }({});
730
+ let IDPAuthType = exports.IDPAuthType = /*#__PURE__*/function (IDPAuthType) {
731
+ IDPAuthType["AccessToken"] = "AccessToken";
732
+ IDPAuthType["ClientSecret"] = "ClientSecret";
733
+ return IDPAuthType;
734
+ }({});
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.FormatString = FormatString;
7
+ exports.KeyValueMapToNameValueArray = KeyValueMapToNameValueArray;
7
8
  exports.parseScopeParam = exports.loadAndVerifySpecs = exports.loadAndVerifyApigeeXCredentialFile = exports.isWindows = exports.isValidJson = exports.isApiServerErrorType = exports.isApiServerErrorResponseType = exports.hbsCompare = exports.getConfig = exports.configFile = exports.compareResourcesByKindDesc = exports.compareResourcesByKindAsc = exports.buildTemplate = exports.buildGenericResource = void 0;
8
9
  exports.sanitizeMetadata = sanitizeMetadata;
9
10
  exports.writeToFile = exports.writeTemplates = exports.verifyScopeParam = exports.verifyFile = exports.transformSimpleFilters = void 0;
@@ -376,4 +377,17 @@ const loadAndVerifyApigeeXCredentialFile = async credentialFilePath => {
376
377
  // Return loaded info.
377
378
  return fileInfo;
378
379
  };
379
- exports.loadAndVerifyApigeeXCredentialFile = loadAndVerifyApigeeXCredentialFile;
380
+ exports.loadAndVerifyApigeeXCredentialFile = loadAndVerifyApigeeXCredentialFile;
381
+ function KeyValueMapToNameValueArray(m) {
382
+ let array = [];
383
+ m.forEach((value, key) => {
384
+ array.push({
385
+ name: key,
386
+ value: value
387
+ });
388
+ });
389
+ if (array.length == 0) {
390
+ return undefined;
391
+ }
392
+ return array;
393
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axway/axway-central-cli",
3
- "version": "2.31.0",
3
+ "version": "2.32.0",
4
4
  "description": "Manage APIs, services and publish to the Unified Catalog",
5
5
  "homepage": "https://platform.axway.com",
6
6
  "author": {