auth0-deploy-cli 7.6.0 → 7.7.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 (112) hide show
  1. package/.eslintrc +7 -41
  2. package/.husky/pre-commit +4 -0
  3. package/.husky/pre-push +3 -1
  4. package/.prettierignore +10 -0
  5. package/.prettierrc.json +4 -0
  6. package/CHANGELOG.md +194 -7
  7. package/CONTRIBUTING.md +2 -2
  8. package/README.md +3 -0
  9. package/lib/args.js +16 -15
  10. package/lib/commands/export.js +3 -3
  11. package/lib/commands/import.js +6 -6
  12. package/lib/commands/index.js +1 -1
  13. package/lib/configFactory.js +5 -1
  14. package/lib/context/defaults.js +4 -3
  15. package/lib/context/directory/handlers/actions.js +3 -3
  16. package/lib/context/directory/handlers/attackProtection.js +4 -4
  17. package/lib/context/directory/handlers/branding.js +6 -5
  18. package/lib/context/directory/handlers/clientGrants.js +3 -2
  19. package/lib/context/directory/handlers/clients.js +1 -1
  20. package/lib/context/directory/handlers/connections.js +4 -2
  21. package/lib/context/directory/handlers/databases.js +13 -7
  22. package/lib/context/directory/handlers/emailProvider.js +3 -2
  23. package/lib/context/directory/handlers/emailTemplates.js +2 -2
  24. package/lib/context/directory/handlers/guardianFactorProviders.js +3 -2
  25. package/lib/context/directory/handlers/guardianFactorTemplates.js +3 -2
  26. package/lib/context/directory/handlers/guardianFactors.js +3 -2
  27. package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.js +1 -1
  28. package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.js +1 -1
  29. package/lib/context/directory/handlers/guardianPolicies.js +1 -1
  30. package/lib/context/directory/handlers/hooks.js +2 -2
  31. package/lib/context/directory/handlers/index.js +3 -2
  32. package/lib/context/directory/handlers/organizations.js +1 -1
  33. package/lib/context/directory/handlers/pages.js +2 -2
  34. package/lib/context/directory/handlers/resourceServers.js +3 -2
  35. package/lib/context/directory/handlers/roles.js +1 -1
  36. package/lib/context/directory/handlers/rules.js +2 -2
  37. package/lib/context/directory/handlers/rulesConfigs.js +3 -2
  38. package/lib/context/directory/handlers/tenant.js +3 -2
  39. package/lib/context/directory/index.js +21 -18
  40. package/lib/context/index.js +66 -62
  41. package/lib/context/yaml/handlers/actions.js +9 -6
  42. package/lib/context/yaml/handlers/attackProtection.js +1 -1
  43. package/lib/context/yaml/handlers/branding.js +5 -4
  44. package/lib/context/yaml/handlers/clientGrants.js +2 -2
  45. package/lib/context/yaml/handlers/clients.js +6 -4
  46. package/lib/context/yaml/handlers/connections.js +7 -5
  47. package/lib/context/yaml/handlers/databases.js +12 -8
  48. package/lib/context/yaml/handlers/emailProvider.js +4 -3
  49. package/lib/context/yaml/handlers/emailTemplates.js +3 -3
  50. package/lib/context/yaml/handlers/guardianFactorProviders.js +1 -1
  51. package/lib/context/yaml/handlers/guardianFactorTemplates.js +1 -1
  52. package/lib/context/yaml/handlers/guardianFactors.js +1 -1
  53. package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.js +1 -1
  54. package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.js +1 -1
  55. package/lib/context/yaml/handlers/guardianPolicies.js +1 -1
  56. package/lib/context/yaml/handlers/hooks.js +4 -3
  57. package/lib/context/yaml/handlers/index.js +3 -2
  58. package/lib/context/yaml/handlers/organizations.js +3 -3
  59. package/lib/context/yaml/handlers/pages.js +3 -3
  60. package/lib/context/yaml/handlers/resourceServers.js +2 -2
  61. package/lib/context/yaml/handlers/roles.js +3 -3
  62. package/lib/context/yaml/handlers/rules.js +3 -3
  63. package/lib/context/yaml/handlers/rulesConfigs.js +2 -2
  64. package/lib/context/yaml/handlers/tenant.js +4 -3
  65. package/lib/context/yaml/handlers/triggers.js +2 -2
  66. package/lib/context/yaml/index.js +31 -23
  67. package/lib/index.js +20 -15
  68. package/lib/logger.js +4 -3
  69. package/lib/readonly.js +11 -16
  70. package/lib/sessionDurationsToMinutes.js +15 -0
  71. package/lib/tools/auth0/client.js +6 -6
  72. package/lib/tools/auth0/handlers/actions.js +21 -23
  73. package/lib/tools/auth0/handlers/attackProtection.js +14 -17
  74. package/lib/tools/auth0/handlers/branding.js +13 -9
  75. package/lib/tools/auth0/handlers/clientGrants.js +17 -10
  76. package/lib/tools/auth0/handlers/clients.js +15 -8
  77. package/lib/tools/auth0/handlers/connections.js +30 -10
  78. package/lib/tools/auth0/handlers/databases.js +24 -12
  79. package/lib/tools/auth0/handlers/default.js +41 -29
  80. package/lib/tools/auth0/handlers/emailTemplates.js +8 -10
  81. package/lib/tools/auth0/handlers/guardianFactorProviders.js +3 -3
  82. package/lib/tools/auth0/handlers/guardianFactorTemplates.js +3 -3
  83. package/lib/tools/auth0/handlers/guardianFactors.js +3 -3
  84. package/lib/tools/auth0/handlers/guardianPhoneFactorMessageTypes.js +11 -10
  85. package/lib/tools/auth0/handlers/guardianPhoneFactorSelectedProvider.js +10 -9
  86. package/lib/tools/auth0/handlers/guardianPolicies.js +5 -4
  87. package/lib/tools/auth0/handlers/hooks.js +34 -21
  88. package/lib/tools/auth0/handlers/index.js +31 -27
  89. package/lib/tools/auth0/handlers/migrations.js +2 -1
  90. package/lib/tools/auth0/handlers/organizations.js +61 -31
  91. package/lib/tools/auth0/handlers/pages.js +20 -14
  92. package/lib/tools/auth0/handlers/prompts.js +1 -0
  93. package/lib/tools/auth0/handlers/resourceServers.js +22 -14
  94. package/lib/tools/auth0/handlers/roles.js +55 -31
  95. package/lib/tools/auth0/handlers/rules.js +49 -32
  96. package/lib/tools/auth0/handlers/rulesConfigs.js +12 -6
  97. package/lib/tools/auth0/handlers/tenant.js +8 -4
  98. package/lib/tools/auth0/handlers/triggers.js +11 -12
  99. package/lib/tools/auth0/index.js +15 -31
  100. package/lib/tools/auth0/schema.js +7 -27
  101. package/lib/tools/calculateChanges.js +11 -6
  102. package/lib/tools/constants.js +162 -161
  103. package/lib/tools/deploy.js +1 -1
  104. package/lib/tools/index.js +1 -1
  105. package/lib/tools/logger.js +14 -8
  106. package/lib/tools/utils.js +2 -2
  107. package/lib/tools/{ValidationError.js → validationError.js} +3 -1
  108. package/lib/types.js +2 -0
  109. package/lib/utils.js +12 -22
  110. package/package.json +8 -1
  111. package/tsconfig.json +1 -3
  112. package/typescript-migration-progress.sh +1 -1
@@ -13,7 +13,7 @@ function parse(context) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
14
  // nothing to do, set default if empty
15
15
  return {
16
- resourceServers: context.assets.resourceServers
16
+ resourceServers: context.assets.resourceServers,
17
17
  };
18
18
  });
19
19
  }
@@ -21,7 +21,7 @@ function dump(context) {
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
22
  // nothing to do, set default if empty
23
23
  return {
24
- resourceServers: [...context.assets.resourceServers || []]
24
+ resourceServers: [...(context.assets.resourceServers || [])],
25
25
  };
26
26
  });
27
27
  }
@@ -13,7 +13,7 @@ function parse(context) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
14
  // nothing to do, set default empty
15
15
  return {
16
- roles: context.assets.roles
16
+ roles: context.assets.roles,
17
17
  };
18
18
  });
19
19
  }
@@ -27,8 +27,8 @@ function dump(context) {
27
27
  delete role.description;
28
28
  }
29
29
  return role;
30
- })
31
- ]
30
+ }),
31
+ ],
32
32
  };
33
33
  });
34
34
  }
@@ -23,14 +23,14 @@ function parse(context) {
23
23
  return {};
24
24
  return {
25
25
  rules: [
26
- ...context.assets.rules.map((rule) => (Object.assign(Object.assign({}, rule), { script: context.loadFile(rule.script) })))
27
- ]
26
+ ...context.assets.rules.map((rule) => (Object.assign(Object.assign({}, rule), { script: context.loadFile(rule.script) }))),
27
+ ],
28
28
  };
29
29
  });
30
30
  }
31
31
  function dump(context) {
32
32
  return __awaiter(this, void 0, void 0, function* () {
33
- let rules = [...context.assets.rules || []];
33
+ let rules = [...(context.assets.rules || [])];
34
34
  if (rules.length > 0) {
35
35
  // Create Rules folder
36
36
  const rulesFolder = path_1.default.join(context.basePath, 'rules');
@@ -13,7 +13,7 @@ function parse(context) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
14
  // nothing to do, set default if empty
15
15
  return {
16
- rulesConfigs: context.assets.rulesConfigs
16
+ rulesConfigs: context.assets.rulesConfigs,
17
17
  };
18
18
  });
19
19
  }
@@ -21,7 +21,7 @@ function dump(_context) {
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
22
  // do not export rulesConfigs as its values cannot be extracted
23
23
  return {
24
- rulesConfigs: []
24
+ rulesConfigs: [],
25
25
  };
26
26
  });
27
27
  }
@@ -21,6 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  const utils_1 = require("../../../utils");
24
+ const sessionDurationsToMinutes_1 = require("../../../sessionDurationsToMinutes");
24
25
  function parse(context) {
25
26
  return __awaiter(this, void 0, void 0, function* () {
26
27
  // Nothing to do
@@ -29,15 +30,15 @@ function parse(context) {
29
30
  /* eslint-disable camelcase */
30
31
  const _a = context.assets.tenant, { session_lifetime, idle_session_lifetime } = _a, tenant = __rest(_a, ["session_lifetime", "idle_session_lifetime"]);
31
32
  (0, utils_1.clearTenantFlags)(tenant);
33
+ const sessionDurations = (0, sessionDurationsToMinutes_1.sessionDurationsToMinutes)({ session_lifetime, idle_session_lifetime });
32
34
  return {
33
- tenant: Object.assign(tenant, session_lifetime && (0, utils_1.hoursAsInteger)('session_lifetime', session_lifetime), idle_session_lifetime && (0, utils_1.hoursAsInteger)('idle_session_lifetime', idle_session_lifetime))
35
+ tenant: Object.assign(Object.assign({}, tenant), sessionDurations),
34
36
  };
35
- /* eslint-enable camelcase */
36
37
  });
37
38
  }
38
39
  function dump(context) {
39
40
  return __awaiter(this, void 0, void 0, function* () {
40
- const tenant = Object.assign({}, context.assets.tenant || {});
41
+ const tenant = Object.assign({}, (context.assets.tenant || {}));
41
42
  (0, utils_1.clearTenantFlags)(tenant);
42
43
  return { tenant };
43
44
  });
@@ -15,7 +15,7 @@ function parse(context) {
15
15
  if (!context.assets.triggers)
16
16
  return {};
17
17
  return {
18
- triggers: context.assets.triggers
18
+ triggers: context.assets.triggers,
19
19
  };
20
20
  });
21
21
  }
@@ -26,7 +26,7 @@ function dump(context) {
26
26
  if (!triggers)
27
27
  return {};
28
28
  return {
29
- triggers: triggers
29
+ triggers: triggers,
30
30
  };
31
31
  });
32
32
  }
@@ -20,28 +20,29 @@ const logger_1 = __importDefault(require("../../logger"));
20
20
  const utils_1 = require("../../utils");
21
21
  const handlers_1 = __importDefault(require("./handlers"));
22
22
  const readonly_1 = __importDefault(require("../../readonly"));
23
- class default_1 {
23
+ class YAMLContext {
24
24
  constructor(config, mgmtClient) {
25
25
  this.configFile = config.AUTH0_INPUT_FILE;
26
26
  this.config = config;
27
- this.mappings = config.AUTH0_KEYWORD_REPLACE_MAPPINGS;
27
+ this.mappings = config.AUTH0_KEYWORD_REPLACE_MAPPINGS || {};
28
28
  this.mgmtClient = mgmtClient;
29
+ //@ts-ignore because the assets property gets filled out throughout
30
+ this.assets = {};
29
31
  // Get excluded rules
30
- this.assets = {
31
- exclude: {
32
- rules: config.AUTH0_EXCLUDED_RULES || [],
33
- clients: config.AUTH0_EXCLUDED_CLIENTS || [],
34
- databases: config.AUTH0_EXCLUDED_DATABASES || [],
35
- connections: config.AUTH0_EXCLUDED_CONNECTIONS || [],
36
- resourceServers: config.AUTH0_EXCLUDED_RESOURCE_SERVERS || [],
37
- defaults: config.AUTH0_EXCLUDED_DEFAULTS || []
38
- }
32
+ this.assets.exclude = {
33
+ rules: config.AUTH0_EXCLUDED_RULES || [],
34
+ clients: config.AUTH0_EXCLUDED_CLIENTS || [],
35
+ databases: config.AUTH0_EXCLUDED_DATABASES || [],
36
+ connections: config.AUTH0_EXCLUDED_CONNECTIONS || [],
37
+ resourceServers: config.AUTH0_EXCLUDED_RESOURCE_SERVERS || [],
38
+ defaults: config.AUTH0_EXCLUDED_DEFAULTS || [],
39
39
  };
40
- this.basePath = config.AUTH0_BASE_PATH;
41
- if (!this.basePath) {
40
+ this.basePath = (() => {
41
+ if (!!config.AUTH0_BASE_PATH)
42
+ return config.AUTH0_BASE_PATH;
42
43
  //@ts-ignore because this looks to be a bug, but do not want to introduce regression; more investigation needed
43
- this.basePath = (typeof configFile === 'object') ? process.cwd() : path_1.default.dirname(this.configFile);
44
- }
44
+ return typeof configFile === 'object' ? process.cwd() : path_1.default.dirname(this.configFile);
45
+ })();
45
46
  }
46
47
  loadFile(f) {
47
48
  let toLoad = path_1.default.join(this.basePath, f);
@@ -75,8 +76,7 @@ class default_1 {
75
76
  yield Promise.all(Object.entries(handlers_1.default).map(([name, handler]) => __awaiter(this, void 0, void 0, function* () {
76
77
  try {
77
78
  const parsed = yield handler.parse(this);
78
- Object.entries(parsed)
79
- .forEach(([k, v]) => {
79
+ Object.entries(parsed).forEach(([k, v]) => {
80
80
  this.assets[k] = v;
81
81
  });
82
82
  }
@@ -97,17 +97,25 @@ class default_1 {
97
97
  }
98
98
  catch (err) {
99
99
  const docUrl = 'https://auth0.com/docs/deploy/deploy-cli-tool/create-and-configure-the-deploy-cli-application#modify-deploy-cli-application-scopes';
100
- const extraMessage = err.message.startsWith('Insufficient scope') ? `\nSee ${docUrl} for more information` : '';
100
+ const extraMessage = err.message.startsWith('Insufficient scope')
101
+ ? `\nSee ${docUrl} for more information`
102
+ : '';
101
103
  throw new Error(`Problem loading tenant data from Auth0 ${err}${extraMessage}`);
102
104
  }
103
- yield Promise.all(Object.entries(handlers_1.default).map(([name, handler]) => __awaiter(this, void 0, void 0, function* () {
105
+ yield Promise.all(Object.entries(handlers_1.default)
106
+ .filter(([handlerName]) => {
107
+ const excludedAssetTypes = this.config.AUTH0_EXCLUDED || [];
108
+ return !excludedAssetTypes.includes(handlerName);
109
+ })
110
+ .map(([name, handler]) => __awaiter(this, void 0, void 0, function* () {
104
111
  try {
105
112
  const data = yield handler.dump(this);
106
113
  if (data) {
107
114
  logger_1.default.info(`Exporting ${name}`);
108
- Object.entries(data)
109
- .forEach(([k, v]) => {
110
- this.assets[k] = Array.isArray(v) ? v.map(utils_1.formatResults).sort(utils_1.recordsSorter) : (0, utils_1.formatResults)(v);
115
+ Object.entries(data).forEach(([k, v]) => {
116
+ this.assets[k] = Array.isArray(v)
117
+ ? v.map(utils_1.formatResults).sort(utils_1.recordsSorter)
118
+ : (0, utils_1.formatResults)(v);
111
119
  });
112
120
  }
113
121
  }
@@ -131,4 +139,4 @@ class default_1 {
131
139
  });
132
140
  }
133
141
  }
134
- exports.default = default_1;
142
+ exports.default = YAMLContext;
package/lib/index.js CHANGED
@@ -15,13 +15,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  const global_agent_1 = require("global-agent");
17
17
  const args_1 = require("./args");
18
- const commands_1 = __importDefault(require("./commands"));
19
18
  const logger_1 = __importDefault(require("./logger"));
20
19
  const tools_1 = __importDefault(require("./tools"));
20
+ const import_1 = __importDefault(require("./commands/import"));
21
+ const export_1 = __importDefault(require("./commands/export"));
21
22
  function run(params) {
22
23
  return __awaiter(this, void 0, void 0, function* () {
23
24
  // Run command
24
- const cmd = commands_1.default[params._[0]];
25
+ const command = params._[0];
25
26
  const proxy = params.proxy_url;
26
27
  if (proxy) {
27
28
  const MAJOR_NODEJS_VERSION = parseInt(process.version.slice(1).split('.')[0], 10);
@@ -32,9 +33,14 @@ function run(params) {
32
33
  process.env.GLOBAL_AGENT_HTTP_PROXY = proxy;
33
34
  (0, global_agent_1.bootstrap)();
34
35
  }
35
- logger_1.default.debug(`Start command ${params._[0]}`);
36
- yield cmd(params);
37
- logger_1.default.debug(`Finished command ${params._[0]}`);
36
+ logger_1.default.debug(`Start command ${command}`);
37
+ if (['deploy', 'import'].includes(command) && 'input_file' in params) {
38
+ yield (0, import_1.default)(params);
39
+ }
40
+ if (['dump', 'export'].includes(command) && 'output_folder' in params) {
41
+ yield (0, export_1.default)(params);
42
+ }
43
+ logger_1.default.debug(`Finished command ${command}`);
38
44
  });
39
45
  }
40
46
  // Only run if from command line
@@ -42,8 +48,6 @@ if (require.main === module) {
42
48
  // Load cli params
43
49
  const params = (0, args_1.getParams)();
44
50
  logger_1.default.debug('Starting Auth0 Deploy CLI Tool');
45
- // Set log level
46
- logger_1.default.transports.console.level = params.level;
47
51
  if (params.debug) {
48
52
  logger_1.default.transports.console.level = 'debug';
49
53
  // Set for tools
@@ -53,15 +57,16 @@ if (require.main === module) {
53
57
  run(params)
54
58
  .then(() => process.exit(0))
55
59
  .catch((error) => {
60
+ const command = params._[0];
56
61
  if (error.type || error.stage) {
57
- logger_1.default.error(`Problem running command ${params._[0]} during stage ${error.stage} when processing type ${error.type}`);
62
+ logger_1.default.error(`Problem running command ${command} during stage ${error.stage} when processing type ${error.type}`);
58
63
  }
59
64
  else {
60
- logger_1.default.error(`Problem running command ${params._[0]}`);
65
+ logger_1.default.error(`Problem running command ${command}`);
61
66
  }
62
67
  const msg = error.message || error.toString();
63
68
  logger_1.default.error(msg);
64
- if (process.env.AUTH0_DEBUG === 'true') {
69
+ if (process.env.AUTH0_DEBUG === 'true' && error.stack) {
65
70
  logger_1.default.debug(error.stack);
66
71
  }
67
72
  if (typeof msg === 'string' && msg.includes('Payload validation error')) {
@@ -72,9 +77,9 @@ if (require.main === module) {
72
77
  }
73
78
  // Export commands to be used programmatically
74
79
  module.exports = {
75
- deploy: commands_1.default.import,
76
- dump: commands_1.default.export,
77
- import: commands_1.default.import,
78
- export: commands_1.default.export,
79
- tools: tools_1.default
80
+ deploy: import_1.default,
81
+ dump: export_1.default,
82
+ import: import_1.default,
83
+ export: export_1.default,
84
+ tools: tools_1.default,
80
85
  };
package/lib/logger.js CHANGED
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const winston_1 = __importDefault(require("winston"));
7
+ //@ts-ignore because used version of Winston still supports emitErrs property
7
8
  winston_1.default.emitErrs = true;
8
9
  const log = new winston_1.default.Logger({
9
10
  transports: [
@@ -12,9 +13,9 @@ const log = new winston_1.default.Logger({
12
13
  level: process.env.AUTH0_LOG || 'info',
13
14
  handleExceptions: true,
14
15
  json: false,
15
- colorize: true
16
- })
16
+ colorize: true,
17
+ }),
17
18
  ],
18
- exitOnError: false
19
+ exitOnError: false,
19
20
  });
20
21
  exports.default = log;
package/lib/readonly.js CHANGED
@@ -6,24 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const dot_prop_1 = __importDefault(require("dot-prop"));
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
8
  // Filter out known read only fields during dump
9
- const readOnly = {
10
- guardianFactors: [
11
- 'trial_expired'
12
- ],
13
- connections: [
14
- 'provisioning_ticket_url',
15
- 'realms'
16
- ],
17
- databases: [
18
- 'options.configuration'
19
- ],
9
+ const readOnlyFields = {
10
+ guardianFactors: ['trial_expired'],
11
+ connections: ['provisioning_ticket_url', 'realms'],
12
+ databases: ['options.configuration'],
20
13
  tenant: [
21
14
  'sandbox_version',
22
15
  'sandbox_versions_available',
23
16
  'flags.allow_changing_enable_sso',
24
17
  'flags.enable_sso',
25
18
  'flags.disable_impersonation',
26
- 'flags.remove_stale_idp_attributes'
19
+ 'flags.remove_stale_idp_attributes',
27
20
  ],
28
21
  clients: [
29
22
  'client_secret',
@@ -33,11 +26,11 @@ const readOnly = {
33
26
  'tenant',
34
27
  'custom_login_page_preview',
35
28
  'config_route',
36
- 'owners'
37
- ]
29
+ 'owners',
30
+ ],
38
31
  };
39
32
  function getExcludedFields(config) {
40
- const strippedFields = Object.assign({}, readOnly);
33
+ const strippedFields = Object.assign({}, readOnlyFields);
41
34
  let { EXCLUDED_PROPS: excluded, INCLUDED_PROPS: included } = config;
42
35
  if (typeof excluded !== 'object')
43
36
  excluded = {};
@@ -45,7 +38,7 @@ function getExcludedFields(config) {
45
38
  included = {};
46
39
  Object.entries(excluded).forEach(([name, fields]) => {
47
40
  // Do not allow same field to be included and excluded at the same time
48
- const intersections = fields.filter((field) => included[name] && included[name].includes(field));
41
+ const intersections = fields.filter((field) => included && included[name] && included[name].includes(field));
49
42
  if (intersections.length > 0) {
50
43
  throw new Error(`EXCLUDED_PROPS should NOT have any intersections with INCLUDED_PROPS. Intersections found: ${name}: ${intersections.join(', ')}`);
51
44
  }
@@ -71,9 +64,11 @@ function cleanAssets(assets, config) {
71
64
  if (!obj)
72
65
  return;
73
66
  if (Array.isArray(obj)) {
67
+ //@ts-ignore because `message_types` and `policies` on guardianPhoneFactorMessageTypes and guardianPolicies don't adhere to the expect types
74
68
  cleaned[name] = obj.map((o) => deleteKeys(o, fields));
75
69
  }
76
70
  else {
71
+ //@ts-ignore because `message_types` and `policies` on guardianPhoneFactorMessageTypes and guardianPolicies don't adhere to the expect types
77
72
  cleaned[name] = deleteKeys(cleaned[name], fields);
78
73
  }
79
74
  });
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sessionDurationsToMinutes = void 0;
4
+ function hoursToMinutes(hours) {
5
+ return Math.round(hours * 60);
6
+ }
7
+ const sessionDurationsToMinutes = ({ session_lifetime, idle_session_lifetime, }) => {
8
+ const sessionDurations = {};
9
+ if (!!session_lifetime)
10
+ sessionDurations.session_lifetime_in_minutes = hoursToMinutes(session_lifetime);
11
+ if (!!idle_session_lifetime)
12
+ sessionDurations.idle_session_lifetime_in_minutes = hoursToMinutes(idle_session_lifetime);
13
+ return sessionDurations;
14
+ };
15
+ exports.sessionDurationsToMinutes = sessionDurationsToMinutes;
@@ -48,7 +48,7 @@ function checkpointPaginator(client, target, name) {
48
48
  const { total } = yield client.pool
49
49
  .addSingleTask({
50
50
  data: newArgs,
51
- generator: (requestArgs) => target[name](requestArgs)
51
+ generator: (requestArgs) => target[name](requestArgs),
52
52
  })
53
53
  .promise();
54
54
  let done = false;
@@ -58,7 +58,7 @@ function checkpointPaginator(client, target, name) {
58
58
  const rsp = yield client.pool
59
59
  .addSingleTask({
60
60
  data: newArgs,
61
- generator: (requestArgs) => target[name](requestArgs)
61
+ generator: (requestArgs) => target[name](requestArgs),
62
62
  })
63
63
  .promise();
64
64
  data.push(...getEntity(rsp));
@@ -92,7 +92,7 @@ function pagePaginator(client, target, name) {
92
92
  const rsp = yield client.pool
93
93
  .addSingleTask({
94
94
  data: lodash_1.default.cloneDeep(newArgs),
95
- generator: (pageArgs) => target[name](...pageArgs)
95
+ generator: (pageArgs) => target[name](...pageArgs),
96
96
  })
97
97
  .promise();
98
98
  data.push(...getEntity(rsp));
@@ -107,7 +107,7 @@ function pagePaginator(client, target, name) {
107
107
  const pageArgs = lodash_1.default.cloneDeep(newArgs);
108
108
  pageArgs[0].page = page + 1;
109
109
  return target[name](...pageArgs).then((r) => getEntity(r));
110
- }
110
+ },
111
111
  })
112
112
  .promise();
113
113
  data.push(...(0, utils_1.flatten)(pages));
@@ -142,7 +142,7 @@ function pagedManager(client, manager) {
142
142
  return pagedManager(client, nestedManager);
143
143
  }
144
144
  return nestedManager;
145
- }
145
+ },
146
146
  });
147
147
  }
148
148
  // Warp around the ManagementClient and detect when requesting specific pages to return all
@@ -150,7 +150,7 @@ function pagedClient(client) {
150
150
  client.pool = new promise_pool_executor_1.PromisePoolExecutor({
151
151
  concurrencyLimit: API_CONCURRENCY,
152
152
  frequencyLimit: API_FREQUENCY_PER_SECOND,
153
- frequencyWindow: 1000 // 1 sec
153
+ frequencyWindow: 1000, // 1 sec
154
154
  });
155
155
  return pagedManager(client, client);
156
156
  }
@@ -65,9 +65,9 @@ exports.schema = {
65
65
  properties: {
66
66
  name: { type: 'string' },
67
67
  version: { type: 'string' },
68
- registry_url: { type: 'string' }
69
- }
70
- }
68
+ registry_url: { type: 'string' },
69
+ },
70
+ },
71
71
  },
72
72
  secrets: {
73
73
  type: 'array',
@@ -76,9 +76,9 @@ exports.schema = {
76
76
  properties: {
77
77
  name: { type: 'string' },
78
78
  value: { type: 'string' },
79
- updated_at: { type: 'string', format: 'date-time' }
80
- }
81
- }
79
+ updated_at: { type: 'string', format: 'date-time' },
80
+ },
81
+ },
82
82
  },
83
83
  name: { type: 'string', default: '' },
84
84
  supported_triggers: {
@@ -88,31 +88,28 @@ exports.schema = {
88
88
  properties: {
89
89
  id: { type: 'string', default: '' },
90
90
  version: { type: 'string' },
91
- url: { type: 'string' }
92
- }
93
- }
91
+ url: { type: 'string' },
92
+ },
93
+ },
94
94
  },
95
95
  deployed: { type: 'boolean' },
96
- status: { type: 'string' }
97
- }
98
- }
96
+ status: { type: 'string' },
97
+ },
98
+ },
99
99
  };
100
100
  function sleep(ms) {
101
101
  return new Promise((resolve) => setTimeout(resolve, ms));
102
102
  }
103
103
  function isActionsDisabled(err) {
104
104
  const errorBody = lodash_1.default.get(err, 'originalError.response.body') || {};
105
- return (err.statusCode === 403 && errorBody.errorCode === 'feature_not_enabled');
105
+ return err.statusCode === 403 && errorBody.errorCode === 'feature_not_enabled';
106
106
  }
107
107
  class ActionHandler extends default_1.default {
108
108
  constructor(options) {
109
109
  super(Object.assign(Object.assign({}, options), { type: 'actions', functions: {
110
110
  create: (action) => this.createAction(action),
111
- delete: (action) => this.deleteAction(action)
112
- }, stripUpdateFields: [
113
- 'deployed',
114
- 'status'
115
- ] }));
111
+ delete: (action) => this.deleteAction(action),
112
+ }, stripUpdateFields: ['deployed', 'status'] }));
116
113
  }
117
114
  createAction(action) {
118
115
  return __awaiter(this, void 0, void 0, function* () {
@@ -148,7 +145,7 @@ class ActionHandler extends default_1.default {
148
145
  })
149
146
  .catch((err) => {
150
147
  throw new Error(`Problem Deploying ${this.type} ${this.objString(action)}\n${err}`);
151
- })
148
+ }),
152
149
  })
153
150
  .promise();
154
151
  });
@@ -160,7 +157,7 @@ class ActionHandler extends default_1.default {
160
157
  }
161
158
  catch (err) {
162
159
  // Retry if pending build.
163
- if (err.message && err.message.includes('must be in the \'built\' state')) {
160
+ if (err.message && err.message.includes("must be in the 'built' state")) {
164
161
  if (!action.retry_count) {
165
162
  logger_1.default.info(`[${this.type}]: Waiting for build to complete ${this.objString(action)}`);
166
163
  action.retry_count = 1;
@@ -237,9 +234,10 @@ class ActionHandler extends default_1.default {
237
234
  const changes = yield this.calcChanges(assets);
238
235
  yield _super.processChanges.call(this, assets, changes);
239
236
  // Deploy actions
240
- const deployActions = [];
241
- deployActions.push(...changes.create.filter((action) => action.deployed));
242
- deployActions.push(...changes.update.filter((action) => action.deployed));
237
+ const deployActions = [
238
+ ...changes.create.filter((action) => action.deployed),
239
+ ...changes.update.filter((action) => action.deployed),
240
+ ];
243
241
  yield this.deployActions(deployActions);
244
242
  });
245
243
  }
@@ -18,16 +18,16 @@ exports.schema = {
18
18
  type: 'object',
19
19
  properties: {
20
20
  breachedPasswordDetection: {
21
- type: 'object'
21
+ type: 'object',
22
22
  },
23
23
  bruteForceProtection: {
24
- type: 'object'
24
+ type: 'object',
25
25
  },
26
26
  suspiciousIpThrottling: {
27
- type: 'object'
28
- }
27
+ type: 'object',
28
+ },
29
29
  },
30
- additionalProperties: false
30
+ additionalProperties: false,
31
31
  };
32
32
  class AttackProtectionHandler extends default_1.default {
33
33
  constructor(config) {
@@ -36,14 +36,14 @@ class AttackProtectionHandler extends default_1.default {
36
36
  objString(item) {
37
37
  return super.objString({
38
38
  'breached-password-protection': {
39
- enabled: item.breachedPasswordDetection.enabled
39
+ enabled: item.breachedPasswordDetection.enabled,
40
40
  },
41
41
  'brute-force-protection': {
42
- enabled: item.bruteForceProtection.enabled
42
+ enabled: item.bruteForceProtection.enabled,
43
43
  },
44
44
  'suspicious-ip-throttling': {
45
- enabled: item.suspiciousIpThrottling.enabled
46
- }
45
+ enabled: item.suspiciousIpThrottling.enabled,
46
+ },
47
47
  });
48
48
  }
49
49
  getType() {
@@ -54,12 +54,12 @@ class AttackProtectionHandler extends default_1.default {
54
54
  const [breachedPasswordDetection, bruteForceProtection, suspiciousIpThrottling] = yield Promise.all([
55
55
  this.client.attackProtection.getBreachedPasswordDetectionConfig(),
56
56
  this.client.attackProtection.getBruteForceConfig(),
57
- this.client.attackProtection.getSuspiciousIpThrottlingConfig()
57
+ this.client.attackProtection.getSuspiciousIpThrottlingConfig(),
58
58
  ]);
59
59
  this.existing = {
60
60
  breachedPasswordDetection,
61
61
  bruteForceProtection,
62
- suspiciousIpThrottling
62
+ suspiciousIpThrottling,
63
63
  };
64
64
  return this.existing;
65
65
  });
@@ -71,12 +71,9 @@ class AttackProtectionHandler extends default_1.default {
71
71
  return;
72
72
  }
73
73
  Promise.all([
74
- this.client.attackProtection
75
- .updateBreachedPasswordDetectionConfig({}, attackProtection.breachedPasswordDetection),
76
- this.client.attackProtection
77
- .updateSuspiciousIpThrottlingConfig({}, attackProtection.suspiciousIpThrottling),
78
- this.client.attackProtection
79
- .updateBruteForceConfig({}, attackProtection.bruteForceProtection)
74
+ this.client.attackProtection.updateBreachedPasswordDetectionConfig({}, attackProtection.breachedPasswordDetection),
75
+ this.client.attackProtection.updateSuspiciousIpThrottlingConfig({}, attackProtection.suspiciousIpThrottling),
76
+ this.client.attackProtection.updateBruteForceConfig({}, attackProtection.bruteForceProtection),
80
77
  ]);
81
78
  this.updated += 1;
82
79
  this.didUpdate(attackProtection);