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
@@ -41,22 +41,22 @@ const readonly_1 = __importDefault(require("../../readonly"));
41
41
  const logger_1 = __importDefault(require("../../logger"));
42
42
  const handlers_1 = __importDefault(require("./handlers"));
43
43
  const utils_1 = require("../../utils");
44
- class default_1 {
44
+ class DirectoryContext {
45
45
  constructor(config, mgmtClient) {
46
46
  this.filePath = config.AUTH0_INPUT_FILE;
47
47
  this.config = config;
48
- this.mappings = config.AUTH0_KEYWORD_REPLACE_MAPPINGS;
48
+ this.mappings = config.AUTH0_KEYWORD_REPLACE_MAPPINGS || {};
49
49
  this.mgmtClient = mgmtClient;
50
+ //@ts-ignore for now
51
+ this.assets = {};
50
52
  // Get excluded rules
51
- this.assets = {
52
- exclude: {
53
- rules: config.AUTH0_EXCLUDED_RULES || [],
54
- clients: config.AUTH0_EXCLUDED_CLIENTS || [],
55
- databases: config.AUTH0_EXCLUDED_DATABASES || [],
56
- connections: config.AUTH0_EXCLUDED_CONNECTIONS || [],
57
- resourceServers: config.AUTH0_EXCLUDED_RESOURCE_SERVERS || [],
58
- defaults: config.AUTH0_EXCLUDED_DEFAULTS || []
59
- }
53
+ this.assets.exclude = {
54
+ rules: config.AUTH0_EXCLUDED_RULES || [],
55
+ clients: config.AUTH0_EXCLUDED_CLIENTS || [],
56
+ databases: config.AUTH0_EXCLUDED_DATABASES || [],
57
+ connections: config.AUTH0_EXCLUDED_CONNECTIONS || [],
58
+ resourceServers: config.AUTH0_EXCLUDED_RESOURCE_SERVERS || [],
59
+ defaults: config.AUTH0_EXCLUDED_DEFAULTS || [],
60
60
  };
61
61
  }
62
62
  loadFile(f, folder) {
@@ -73,11 +73,9 @@ class default_1 {
73
73
  if ((0, utils_1.isDirectory)(this.filePath)) {
74
74
  /* If this is a directory, look for each file in the directory */
75
75
  logger_1.default.info(`Processing directory ${this.filePath}`);
76
- Object.values(handlers_1.default)
77
- .forEach((handler) => {
76
+ Object.values(handlers_1.default).forEach((handler) => {
78
77
  const parsed = handler.parse(this);
79
- Object.entries(parsed)
80
- .forEach(([k, v]) => {
78
+ Object.entries(parsed).forEach(([k, v]) => {
81
79
  this.assets[k] = v;
82
80
  });
83
81
  });
@@ -97,12 +95,17 @@ class default_1 {
97
95
  // Copy clients to be used by handlers which require converting client_id to the name
98
96
  // Must copy as the client_id will be stripped if AUTH0_EXPORT_IDENTIFIERS is false
99
97
  //@ts-ignore because assets haven't been typed yet TODO: type assets
100
- this.assets.clientsOrig = [...this.assets.clients];
98
+ this.assets.clientsOrig = [...(this.assets.clients || [])];
101
99
  // Optionally Strip identifiers
102
100
  if (!this.config.AUTH0_EXPORT_IDENTIFIERS) {
103
101
  this.assets = (0, utils_1.stripIdentifiers)(auth0, this.assets);
104
102
  }
105
- yield Promise.all(Object.entries(handlers_1.default).map(([name, handler]) => __awaiter(this, void 0, void 0, function* () {
103
+ yield Promise.all(Object.entries(handlers_1.default)
104
+ .filter(([handlerName]) => {
105
+ const excludedAssetTypes = this.config.AUTH0_EXCLUDED || [];
106
+ return !excludedAssetTypes.includes(handlerName);
107
+ })
108
+ .map(([name, handler]) => __awaiter(this, void 0, void 0, function* () {
106
109
  try {
107
110
  yield handler.dump(this);
108
111
  }
@@ -114,4 +117,4 @@ class default_1 {
114
117
  });
115
118
  }
116
119
  }
117
- exports.default = default_1;
120
+ exports.default = DirectoryContext;
@@ -12,13 +12,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.setupContext = void 0;
15
16
  const path_1 = __importDefault(require("path"));
16
17
  const auth0_1 = require("auth0");
17
18
  const yaml_1 = __importDefault(require("./yaml"));
18
19
  const directory_1 = __importDefault(require("./directory"));
19
20
  const utils_1 = require("../utils");
20
- const package_json_1 = require("../../package.json");
21
21
  const logger_1 = __importDefault(require("../logger"));
22
+ const { version: packageVersion } = require('../../package.json');
22
23
  const nonPrimitiveProps = [
23
24
  'AUTH0_KEYWORD_REPLACE_MAPPINGS',
24
25
  'AUTH0_EXCLUDED_RULES',
@@ -27,73 +28,76 @@ const nonPrimitiveProps = [
27
28
  'AUTH0_EXCLUDED_CONNECTIONS',
28
29
  'AUTH0_EXCLUDED_RESOURCE_SERVERS',
29
30
  'AUTH0_EXCLUDED_DEFAULTS',
31
+ 'AUTH0_EXCLUDED',
30
32
  'EXCLUDED_PROPS',
31
- 'INCLUDED_PROPS'
33
+ 'INCLUDED_PROPS',
32
34
  ];
33
- function default_1(config) {
34
- return __awaiter(this, void 0, void 0, function* () {
35
- // Validate config
36
- const errors = [];
37
- if (!config.AUTH0_DOMAIN)
38
- errors.push('AUTH0_DOMAIN');
39
- if (!config.AUTH0_ACCESS_TOKEN) {
40
- if (!config.AUTH0_CLIENT_ID)
41
- errors.push('AUTH0_CLIENT_ID');
42
- if (!config.AUTH0_CLIENT_SECRET)
43
- errors.push('AUTH0_CLIENT_SECRET');
44
- }
45
- if (errors.length > 0) {
46
- throw new Error(`The following parameters were missing. Please add them to your config.json or as an environment variable. ${JSON.stringify(errors)}`);
47
- }
48
- let accessToken = config.AUTH0_ACCESS_TOKEN;
49
- if (!accessToken) {
50
- const authClient = new auth0_1.AuthenticationClient({
51
- domain: config.AUTH0_DOMAIN,
52
- clientId: config.AUTH0_CLIENT_ID,
53
- clientSecret: config.AUTH0_CLIENT_SECRET
54
- });
55
- const clientCredentials = yield authClient.clientCredentialsGrant({
56
- audience: config.AUTH0_AUDIENCE ? config.AUTH0_AUDIENCE : `https://${config.AUTH0_DOMAIN}/api/v2/`
57
- });
58
- accessToken = clientCredentials.access_token;
59
- }
60
- const mgmtClient = new auth0_1.ManagementClient({
35
+ const setupContext = (config) => __awaiter(void 0, void 0, void 0, function* () {
36
+ // Validate config
37
+ const missingParams = [];
38
+ if (!config.AUTH0_DOMAIN)
39
+ missingParams.push('AUTH0_DOMAIN');
40
+ if (!config.AUTH0_ACCESS_TOKEN) {
41
+ if (!config.AUTH0_CLIENT_ID)
42
+ missingParams.push('AUTH0_CLIENT_ID');
43
+ if (!config.AUTH0_CLIENT_SECRET)
44
+ missingParams.push('AUTH0_CLIENT_SECRET');
45
+ }
46
+ if (missingParams.length > 0) {
47
+ throw new Error(`The following parameters were missing. Please add them to your config.json or as an environment variable. ${JSON.stringify(missingParams)}`);
48
+ }
49
+ const accessToken = yield (() => __awaiter(void 0, void 0, void 0, function* () {
50
+ if (!!config.AUTH0_ACCESS_TOKEN)
51
+ return config.AUTH0_ACCESS_TOKEN;
52
+ const authClient = new auth0_1.AuthenticationClient({
61
53
  domain: config.AUTH0_DOMAIN,
62
- token: accessToken,
63
- retry: { maxRetries: config.AUTH0_API_MAX_RETRIES || 10, enabled: true },
64
- headers: {
65
- 'User-agent': `deploy-cli/${package_json_1.version} (node.js/${process.version.replace('v', '')})`
66
- }
54
+ clientId: config.AUTH0_CLIENT_ID,
55
+ clientSecret: config.AUTH0_CLIENT_SECRET,
67
56
  });
68
- const inputFile = config.AUTH0_INPUT_FILE;
69
- const ensureObject = (key, value) => {
70
- if (typeof value === 'string') {
71
- try {
72
- return JSON.parse(value);
73
- }
74
- catch (e) {
75
- logger_1.default.debug(`Cannot convert config.${key} to an object. Error: ${e.message}`);
76
- return value;
77
- }
57
+ const clientCredentials = yield authClient.clientCredentialsGrant({
58
+ audience: config.AUTH0_AUDIENCE
59
+ ? config.AUTH0_AUDIENCE
60
+ : `https://${config.AUTH0_DOMAIN}/api/v2/`,
61
+ });
62
+ return clientCredentials.access_token;
63
+ }))();
64
+ const mgmtClient = new auth0_1.ManagementClient({
65
+ domain: config.AUTH0_DOMAIN,
66
+ token: accessToken,
67
+ retry: { maxRetries: config.AUTH0_API_MAX_RETRIES || 10, enabled: true },
68
+ headers: {
69
+ 'User-agent': `deploy-cli/${packageVersion} (node.js/${process.version.replace('v', '')})`,
70
+ },
71
+ });
72
+ const inputFile = config.AUTH0_INPUT_FILE;
73
+ const ensureObject = (key, value) => {
74
+ if (typeof value === 'string') {
75
+ try {
76
+ return JSON.parse(value);
78
77
  }
79
- return value;
80
- };
81
- nonPrimitiveProps.forEach((key) => {
82
- if (config[key]) {
83
- config[key] = ensureObject(key, config[key]);
78
+ catch (e) {
79
+ logger_1.default.debug(`Cannot convert config.${key} to an object. Error: ${e.message}`);
80
+ return value;
84
81
  }
85
- });
86
- if (typeof inputFile === 'object') {
87
- return new yaml_1.default(config, mgmtClient);
88
- }
89
- if ((0, utils_1.isDirectory)(inputFile)) {
90
- return new directory_1.default(config, mgmtClient);
91
82
  }
92
- const ext = path_1.default.extname(inputFile);
93
- if (ext === '.yaml' || ext === '.yml') {
94
- return new yaml_1.default(config, mgmtClient);
83
+ return value;
84
+ };
85
+ nonPrimitiveProps.forEach((key) => {
86
+ if (config[key]) {
87
+ //@ts-ignore because this method of config overwriting technically functions
88
+ config[key] = ensureObject(key, config[key]);
95
89
  }
96
- throw new Error(`Unable to determine context processor to load for file ${inputFile}, does it exist? `);
97
90
  });
98
- }
99
- exports.default = default_1;
91
+ if (typeof inputFile === 'object') {
92
+ return new yaml_1.default(config, mgmtClient);
93
+ }
94
+ if ((0, utils_1.isDirectory)(inputFile)) {
95
+ return new directory_1.default(config, mgmtClient);
96
+ }
97
+ const ext = path_1.default.extname(inputFile);
98
+ if (ext === '.yaml' || ext === '.yml') {
99
+ return new yaml_1.default(config, mgmtClient);
100
+ }
101
+ throw new Error(`Unable to determine context processor to load for file ${inputFile}, does it exist? `);
102
+ });
103
+ exports.setupContext = setupContext;
@@ -20,18 +20,20 @@ const utils_1 = require("../../../utils");
20
20
  const logger_1 = __importDefault(require("../../../logger"));
21
21
  function parseCode(context, code) {
22
22
  if (code) {
23
+ //@ts-ignore TODO: understand why two arguments are passed when context.loadFile only accepts one
23
24
  return context.loadFile(code, tools_1.constants.ACTIONS_DIRECTORY);
24
25
  }
25
26
  }
26
27
  function parse(context) {
27
28
  return __awaiter(this, void 0, void 0, function* () {
28
29
  // Load the script file for each action
30
+ //@ts-ignore TODO: understand if empty array is intentionally being returned
29
31
  if (!context.assets.actions)
30
32
  return [];
31
33
  const actions = {
32
34
  actions: [
33
- ...context.assets.actions.map((action) => (Object.assign(Object.assign({}, action), { code: parseCode(context, action.code) })))
34
- ]
35
+ ...context.assets.actions.map((action) => (Object.assign(Object.assign({}, action), { code: parseCode(context, action.code) }))),
36
+ ],
35
37
  };
36
38
  return actions;
37
39
  });
@@ -58,25 +60,26 @@ function mapActionCode(basePath, action) {
58
60
  function dump(context) {
59
61
  return __awaiter(this, void 0, void 0, function* () {
60
62
  const { actions } = context.assets;
61
- //@ts-ignore but need to investigate why returning void here when other handlers do not
63
+ //@ts-ignore TODO: need to investigate why returning void here when other handlers do not
62
64
  if (!actions)
63
65
  return; // Nothing to do
64
66
  return {
65
67
  actions: actions.map((action) => ({
66
68
  name: action.name,
67
69
  deployed: action.deployed || action.all_changes_deployed,
70
+ //@ts-ignore because Action resource needs to be typed more accurately
68
71
  code: mapActionCode(context.basePath, action),
69
72
  runtime: action.runtime,
70
73
  dependencies: action.dependencies || [],
71
74
  status: action.status,
72
75
  secrets: mapSecrets(action.secrets),
73
- supported_triggers: action.supported_triggers
74
- }))
76
+ supported_triggers: action.supported_triggers,
77
+ })),
75
78
  };
76
79
  });
77
80
  }
78
81
  const ActionsHandler = {
79
82
  parse,
80
- dump
83
+ dump,
81
84
  };
82
85
  exports.default = ActionsHandler;
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  function parseAndDump(context) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
14
  return {
15
- attackProtection: context.assets.attackProtection || {}
15
+ attackProtection: context.assets.attackProtection || {},
16
16
  };
17
17
  });
18
18
  }
@@ -25,11 +25,11 @@ function parse(context) {
25
25
  const markupFile = path_1.default.join(templateDefinition.body);
26
26
  return {
27
27
  template: templateDefinition.template,
28
- body: (0, tools_1.loadFileAndReplaceKeywords)(markupFile, context.mappings)
28
+ body: (0, tools_1.loadFileAndReplaceKeywords)(markupFile, context.mappings),
29
29
  };
30
30
  });
31
31
  return {
32
- branding: Object.assign(Object.assign({}, branding), { templates })
32
+ branding: Object.assign(Object.assign({}, branding), { templates }),
33
33
  };
34
34
  });
35
35
  }
@@ -59,7 +59,8 @@ function dump(context) {
59
59
  return { branding };
60
60
  });
61
61
  }
62
- exports.default = {
62
+ const brandingHandler = {
63
63
  parse,
64
- dump
64
+ dump,
65
65
  };
66
+ exports.default = brandingHandler;
@@ -14,7 +14,7 @@ function parse(context) {
14
14
  return __awaiter(this, void 0, void 0, function* () {
15
15
  // nothing to do, set default empty
16
16
  return {
17
- clientGrants: context.assets.clientGrants
17
+ clientGrants: context.assets.clientGrants,
18
18
  };
19
19
  });
20
20
  }
@@ -30,7 +30,7 @@ function dump(context) {
30
30
  const dumpGrant = Object.assign({}, grant);
31
31
  dumpGrant.client_id = (0, utils_1.convertClientIdToName)(dumpGrant.client_id, context.assets.clients);
32
32
  return dumpGrant;
33
- })
33
+ }),
34
34
  };
35
35
  });
36
36
  }
@@ -35,8 +35,8 @@ function parse(context) {
35
35
  }
36
36
  }
37
37
  return client;
38
- })
39
- ]
38
+ }),
39
+ ],
40
40
  };
41
41
  });
42
42
  }
@@ -45,7 +45,8 @@ function dump(context) {
45
45
  // Save custom_login_page to a separate html file
46
46
  const clientsFolder = path_1.default.join(context.basePath, tools_1.constants.CLIENTS_DIRECTORY);
47
47
  return {
48
- clients: [...context.assets.clients.map((client) => {
48
+ clients: [
49
+ ...context.assets.clients.map((client) => {
49
50
  if (client.custom_login_page) {
50
51
  const clientName = (0, utils_1.sanitize)(client.name);
51
52
  const html = client.custom_login_page;
@@ -56,7 +57,8 @@ function dump(context) {
56
57
  client.custom_login_page = `./${clientName}_custom_login_page.html`;
57
58
  }
58
59
  return (0, utils_1.clearClientArrays)(client);
59
- })]
60
+ }),
61
+ ],
60
62
  };
61
63
  });
62
64
  }
@@ -36,15 +36,15 @@ function parse(context) {
36
36
  }
37
37
  }
38
38
  return connection;
39
- })
40
- ]
39
+ }),
40
+ ],
41
41
  };
42
42
  });
43
43
  }
44
44
  const getFormattedOptions = (connection, clients) => {
45
45
  try {
46
46
  return {
47
- options: Object.assign(Object.assign({}, connection.options), { idpinitiated: Object.assign(Object.assign({}, connection.options.idpinitiated), { client_id: (0, utils_1.convertClientIdToName)(connection.options.idpinitiated.client_id, clients) }) })
47
+ options: Object.assign(Object.assign({}, connection.options), { idpinitiated: Object.assign(Object.assign({}, connection.options.idpinitiated), { client_id: (0, utils_1.convertClientIdToName)(connection.options.idpinitiated.client_id, clients) }) }),
48
48
  };
49
49
  }
50
50
  catch (e) {
@@ -60,7 +60,9 @@ function dump(context) {
60
60
  // nothing to do, set default if empty
61
61
  return {
62
62
  connections: connections.map((connection) => {
63
- const dumpedConnection = Object.assign(Object.assign(Object.assign({}, connection), getFormattedOptions(connection, context.assets.clients)), (connection.enabled_clients && { enabled_clients: (0, utils_1.mapClientID2NameSorted)(connection.enabled_clients, context.assets.clients) }));
63
+ const dumpedConnection = Object.assign(Object.assign(Object.assign({}, connection), getFormattedOptions(connection, context.assets.clients)), (connection.enabled_clients && {
64
+ enabled_clients: (0, utils_1.mapClientID2NameSorted)(connection.enabled_clients, context.assets.clients),
65
+ }));
64
66
  if (dumpedConnection.strategy === 'email') {
65
67
  (0, utils_1.ensureProp)(connection, 'options.email.body');
66
68
  const connectionsFolder = path_1.default.join(context.basePath, tools_1.constants.CONNECTIONS_DIRECTORY);
@@ -73,7 +75,7 @@ function dump(context) {
73
75
  dumpedConnection.options.email.body = `./${connectionName}.html`;
74
76
  }
75
77
  return dumpedConnection;
76
- })
78
+ }),
77
79
  };
78
80
  });
79
81
  }
@@ -24,9 +24,9 @@ function parse(context) {
24
24
  return {
25
25
  databases: [
26
26
  ...context.assets.databases.map((database) => (Object.assign(Object.assign({}, database), { options: Object.assign(Object.assign({}, database.options), (database.options.customScripts && {
27
- customScripts: Object.entries(database.options.customScripts).reduce((scripts, [name, script]) => (Object.assign(Object.assign({}, scripts), { [name]: context.loadFile(script) })), {})
28
- })) })))
29
- ]
27
+ customScripts: Object.entries(database.options.customScripts).reduce((scripts, [name, script]) => (Object.assign(Object.assign({}, scripts), { [name]: context.loadFile(script) })), {}),
28
+ })) }))),
29
+ ],
30
30
  };
31
31
  });
32
32
  }
@@ -43,8 +43,12 @@ function dump(context) {
43
43
  };
44
44
  return {
45
45
  databases: [
46
- ...databases.map((database) => (Object.assign(Object.assign(Object.assign({}, database), (database.enabled_clients && { enabled_clients: (0, utils_1.mapClientID2NameSorted)(database.enabled_clients, context.assets.clients) })), { options: Object.assign(Object.assign({}, database.options), (database.options.customScripts && {
47
- customScripts: Object.entries(database.options.customScripts).sort(sortCustomScripts).reduce((scripts, [name, script]) => {
46
+ ...databases.map((database) => (Object.assign(Object.assign(Object.assign({}, database), (database.enabled_clients && {
47
+ enabled_clients: (0, utils_1.mapClientID2NameSorted)(database.enabled_clients, context.assets.clients),
48
+ })), { options: Object.assign(Object.assign({}, database.options), (database.options.customScripts && {
49
+ customScripts: Object.entries(database.options.customScripts)
50
+ .sort(sortCustomScripts)
51
+ .reduce((scripts, [name, script]) => {
48
52
  // Create Database folder
49
53
  const dbName = (0, utils_1.sanitize)(database.name);
50
54
  const dbFolder = path_1.default.join(context.basePath, 'databases', (0, utils_1.sanitize)(dbName));
@@ -56,9 +60,9 @@ function dump(context) {
56
60
  fs_extra_1.default.writeFileSync(scriptFile, script);
57
61
  scripts[name] = `./databases/${dbName}/${scriptName}.js`;
58
62
  return scripts;
59
- }, {})
60
- })) })))
61
- ]
63
+ }, {}),
64
+ })) }))),
65
+ ],
62
66
  };
63
67
  });
64
68
  }
@@ -14,20 +14,21 @@ function parse(context) {
14
14
  return __awaiter(this, void 0, void 0, function* () {
15
15
  // nothing to do, set default if empty
16
16
  return {
17
- emailProvider: Object.assign({}, context.assets.emailProvider || {})
17
+ emailProvider: Object.assign({}, (context.assets.emailProvider || {})),
18
18
  };
19
19
  });
20
20
  }
21
21
  function dump(context) {
22
+ var _a;
22
23
  return __awaiter(this, void 0, void 0, function* () {
23
24
  let { emailProvider } = context.assets;
24
- const excludedDefaults = context.assets.exclude.defaults || [];
25
+ const excludedDefaults = ((_a = context.assets.exclude) === null || _a === void 0 ? void 0 : _a.defaults) || [];
25
26
  if (emailProvider && !excludedDefaults.includes('emailProvider')) {
26
27
  // Add placeholder for credentials as they cannot be exported
27
28
  emailProvider = (0, defaults_1.emailProviderDefaults)(emailProvider);
28
29
  }
29
30
  return {
30
- emailProvider: emailProvider || {}
31
+ emailProvider: emailProvider || {},
31
32
  };
32
33
  });
33
34
  }
@@ -21,14 +21,14 @@ function parse(context) {
21
21
  const emailTemplates = context.assets.emailTemplates || [];
22
22
  return {
23
23
  emailTemplates: [
24
- ...emailTemplates.map((et) => (Object.assign(Object.assign({}, et), { body: context.loadFile(et.body) })))
25
- ]
24
+ ...emailTemplates.map((et) => (Object.assign(Object.assign({}, et), { body: context.loadFile(et.body) }))),
25
+ ],
26
26
  };
27
27
  });
28
28
  }
29
29
  function dump(context) {
30
30
  return __awaiter(this, void 0, void 0, function* () {
31
- let emailTemplates = [...context.assets.emailTemplates || []];
31
+ let emailTemplates = [...(context.assets.emailTemplates || [])];
32
32
  if (emailTemplates.length > 0) {
33
33
  // Create Templates folder
34
34
  const templatesFolder = path_1.default.join(context.basePath, 'emailTemplates');
@@ -13,7 +13,7 @@ function parseAndDump(context) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
14
  // nothing to do, set default empty
15
15
  return {
16
- guardianFactorProviders: [...context.assets.guardianFactorProviders || []]
16
+ guardianFactorProviders: [...(context.assets.guardianFactorProviders || [])],
17
17
  };
18
18
  });
19
19
  }
@@ -13,7 +13,7 @@ function parseAndDump(context) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
14
  // nothing to do, set default if empty
15
15
  return {
16
- guardianFactorTemplates: [...context.assets.guardianFactorTemplates || []]
16
+ guardianFactorTemplates: [...(context.assets.guardianFactorTemplates || [])],
17
17
  };
18
18
  });
19
19
  }
@@ -13,7 +13,7 @@ function parseAndDump(context) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
14
  // nothing to do, set default if empty
15
15
  return {
16
- guardianFactors: [...context.assets.guardianFactors || []]
16
+ guardianFactors: [...(context.assets.guardianFactors || [])],
17
17
  };
18
18
  });
19
19
  }
@@ -13,7 +13,7 @@ function parseAndDump(context) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
14
  // nothing to do, set default if empty
15
15
  return {
16
- guardianPhoneFactorMessageTypes: Object.assign({}, context.assets.guardianPhoneFactorMessageTypes || {})
16
+ guardianPhoneFactorMessageTypes: Object.assign({}, (context.assets.guardianPhoneFactorMessageTypes || {})),
17
17
  };
18
18
  });
19
19
  }
@@ -13,7 +13,7 @@ function parseAndDump(context) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
14
  // nothing to do, set default empty
15
15
  return {
16
- guardianPhoneFactorSelectedProvider: Object.assign({}, context.assets.guardianPhoneFactorSelectedProvider || {})
16
+ guardianPhoneFactorSelectedProvider: Object.assign({}, (context.assets.guardianPhoneFactorSelectedProvider || {})),
17
17
  };
18
18
  });
19
19
  }
@@ -13,7 +13,7 @@ function parseAndDump(context) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
14
  // nothing to do, set default if empty
15
15
  return {
16
- guardianPolicies: Object.assign({}, context.assets.guardianPolicies || {})
16
+ guardianPolicies: Object.assign({}, (context.assets.guardianPolicies || {})),
17
17
  };
18
18
  });
19
19
  }
@@ -26,18 +26,19 @@ function parse(context) {
26
26
  hooks: [
27
27
  ...context.assets.hooks.map((hook) => {
28
28
  if (hook.script) {
29
+ //@ts-ignore TODO: understand why two arguments are passed when context.loadFile only accepts one
29
30
  hook.script = context.loadFile(hook.script, tools_1.constants.HOOKS_DIRECTORY);
30
31
  }
31
32
  hook.name = hook.name.toLowerCase().replace(/\s/g, '-');
32
33
  return Object.assign({}, hook);
33
- })
34
- ]
34
+ }),
35
+ ],
35
36
  };
36
37
  });
37
38
  }
38
39
  function dump(context) {
39
40
  return __awaiter(this, void 0, void 0, function* () {
40
- let hooks = [...context.assets.hooks || []];
41
+ let hooks = [...(context.assets.hooks || [])];
41
42
  if (hooks.length > 0) {
42
43
  // Create hooks folder
43
44
  const hooksFolder = path_1.default.join(context.basePath, 'hooks');
@@ -28,7 +28,7 @@ const actions_1 = __importDefault(require("./actions"));
28
28
  const triggers_1 = __importDefault(require("./triggers"));
29
29
  const attackProtection_1 = __importDefault(require("./attackProtection"));
30
30
  const branding_1 = __importDefault(require("./branding"));
31
- exports.default = {
31
+ const yamlHandlers = {
32
32
  rules: rules_1.default,
33
33
  hooks: hooks_1.default,
34
34
  rulesConfigs: rulesConfigs_1.default,
@@ -53,5 +53,6 @@ exports.default = {
53
53
  organizations: organizations_1.default,
54
54
  triggers: triggers_1.default,
55
55
  attackProtection: attackProtection_1.default,
56
- branding: branding_1.default
56
+ branding: branding_1.default,
57
57
  };
58
+ exports.default = yamlHandlers;
@@ -13,7 +13,7 @@ function parse(context) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
14
  const { organizations } = context.assets;
15
15
  return {
16
- organizations: organizations
16
+ organizations: organizations,
17
17
  };
18
18
  });
19
19
  }
@@ -33,8 +33,8 @@ function dump(context) {
33
33
  });
34
34
  }
35
35
  return org;
36
- })
37
- ]
36
+ }),
37
+ ],
38
38
  };
39
39
  });
40
40
  }
@@ -22,14 +22,14 @@ function parse(context) {
22
22
  return {};
23
23
  return {
24
24
  pages: [
25
- ...context.assets.pages.map((page) => (Object.assign(Object.assign({}, page), { html: page.html ? context.loadFile(page.html) : '' })))
26
- ]
25
+ ...context.assets.pages.map((page) => (Object.assign(Object.assign({}, page), { html: page.html ? context.loadFile(page.html) : '' }))),
26
+ ],
27
27
  };
28
28
  });
29
29
  }
30
30
  function dump(context) {
31
31
  return __awaiter(this, void 0, void 0, function* () {
32
- let pages = [...context.assets.pages || []];
32
+ let pages = [...(context.assets.pages || [])];
33
33
  if (pages.length > 0) {
34
34
  // Create Pages folder
35
35
  const pagesFolder = path_1.default.join(context.basePath, 'pages');