auth0-deploy-cli 7.6.0 → 7.8.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 (216) 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 +222 -7
  7. package/CONTRIBUTING.md +2 -2
  8. package/README.md +3 -0
  9. package/lib/args.d.ts +29 -0
  10. package/lib/args.js +16 -15
  11. package/lib/commands/export.d.ts +2 -0
  12. package/lib/commands/export.js +3 -3
  13. package/lib/commands/import.d.ts +2 -0
  14. package/lib/commands/import.js +6 -6
  15. package/lib/commands/index.d.ts +9 -0
  16. package/lib/commands/index.js +1 -1
  17. package/lib/configFactory.d.ts +7 -0
  18. package/lib/configFactory.js +5 -1
  19. package/lib/context/defaults.d.ts +1 -0
  20. package/lib/context/defaults.js +4 -3
  21. package/lib/context/directory/handlers/actions.d.ts +6 -0
  22. package/lib/context/directory/handlers/actions.js +3 -3
  23. package/lib/context/directory/handlers/attackProtection.d.ts +10 -0
  24. package/lib/context/directory/handlers/attackProtection.js +7 -7
  25. package/lib/context/directory/handlers/branding.d.ts +6 -0
  26. package/lib/context/directory/handlers/branding.js +6 -5
  27. package/lib/context/directory/handlers/clientGrants.d.ts +6 -0
  28. package/lib/context/directory/handlers/clientGrants.js +3 -2
  29. package/lib/context/directory/handlers/clients.d.ts +6 -0
  30. package/lib/context/directory/handlers/clients.js +1 -1
  31. package/lib/context/directory/handlers/connections.d.ts +6 -0
  32. package/lib/context/directory/handlers/connections.js +4 -2
  33. package/lib/context/directory/handlers/databases.d.ts +6 -0
  34. package/lib/context/directory/handlers/databases.js +13 -7
  35. package/lib/context/directory/handlers/emailProvider.d.ts +6 -0
  36. package/lib/context/directory/handlers/emailProvider.js +3 -2
  37. package/lib/context/directory/handlers/emailTemplates.d.ts +6 -0
  38. package/lib/context/directory/handlers/emailTemplates.js +2 -2
  39. package/lib/context/directory/handlers/guardianFactorProviders.d.ts +6 -0
  40. package/lib/context/directory/handlers/guardianFactorProviders.js +3 -2
  41. package/lib/context/directory/handlers/guardianFactorTemplates.d.ts +6 -0
  42. package/lib/context/directory/handlers/guardianFactorTemplates.js +3 -2
  43. package/lib/context/directory/handlers/guardianFactors.d.ts +6 -0
  44. package/lib/context/directory/handlers/guardianFactors.js +3 -2
  45. package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.d.ts +6 -0
  46. package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.js +1 -1
  47. package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.d.ts +6 -0
  48. package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.js +1 -1
  49. package/lib/context/directory/handlers/guardianPolicies.d.ts +6 -0
  50. package/lib/context/directory/handlers/guardianPolicies.js +1 -1
  51. package/lib/context/directory/handlers/hooks.d.ts +6 -0
  52. package/lib/context/directory/handlers/hooks.js +2 -2
  53. package/lib/context/directory/handlers/index.d.ts +12 -0
  54. package/lib/context/directory/handlers/index.js +3 -2
  55. package/lib/context/directory/handlers/migrations.d.ts +6 -0
  56. package/lib/context/directory/handlers/organizations.d.ts +6 -0
  57. package/lib/context/directory/handlers/organizations.js +1 -1
  58. package/lib/context/directory/handlers/pages.d.ts +6 -0
  59. package/lib/context/directory/handlers/pages.js +2 -2
  60. package/lib/context/directory/handlers/resourceServers.d.ts +6 -0
  61. package/lib/context/directory/handlers/resourceServers.js +3 -2
  62. package/lib/context/directory/handlers/roles.d.ts +6 -0
  63. package/lib/context/directory/handlers/roles.js +1 -1
  64. package/lib/context/directory/handlers/rules.d.ts +6 -0
  65. package/lib/context/directory/handlers/rules.js +2 -2
  66. package/lib/context/directory/handlers/rulesConfigs.d.ts +6 -0
  67. package/lib/context/directory/handlers/rulesConfigs.js +3 -2
  68. package/lib/context/directory/handlers/tenant.d.ts +10 -0
  69. package/lib/context/directory/handlers/tenant.js +3 -2
  70. package/lib/context/directory/handlers/triggers.d.ts +6 -0
  71. package/lib/context/directory/index.d.ts +17 -0
  72. package/lib/context/directory/index.js +21 -18
  73. package/lib/context/index.d.ts +4 -0
  74. package/lib/context/index.js +83 -61
  75. package/lib/context/yaml/handlers/actions.d.ts +6 -0
  76. package/lib/context/yaml/handlers/actions.js +9 -6
  77. package/lib/context/yaml/handlers/attackProtection.d.ts +6 -0
  78. package/lib/context/yaml/handlers/attackProtection.js +1 -1
  79. package/lib/context/yaml/handlers/branding.d.ts +6 -0
  80. package/lib/context/yaml/handlers/branding.js +5 -4
  81. package/lib/context/yaml/handlers/clientGrants.d.ts +6 -0
  82. package/lib/context/yaml/handlers/clientGrants.js +2 -2
  83. package/lib/context/yaml/handlers/clients.d.ts +6 -0
  84. package/lib/context/yaml/handlers/clients.js +6 -4
  85. package/lib/context/yaml/handlers/connections.d.ts +6 -0
  86. package/lib/context/yaml/handlers/connections.js +7 -5
  87. package/lib/context/yaml/handlers/databases.d.ts +6 -0
  88. package/lib/context/yaml/handlers/databases.js +12 -8
  89. package/lib/context/yaml/handlers/emailProvider.d.ts +6 -0
  90. package/lib/context/yaml/handlers/emailProvider.js +4 -3
  91. package/lib/context/yaml/handlers/emailTemplates.d.ts +6 -0
  92. package/lib/context/yaml/handlers/emailTemplates.js +3 -3
  93. package/lib/context/yaml/handlers/guardianFactorProviders.d.ts +6 -0
  94. package/lib/context/yaml/handlers/guardianFactorProviders.js +1 -1
  95. package/lib/context/yaml/handlers/guardianFactorTemplates.d.ts +6 -0
  96. package/lib/context/yaml/handlers/guardianFactorTemplates.js +1 -1
  97. package/lib/context/yaml/handlers/guardianFactors.d.ts +6 -0
  98. package/lib/context/yaml/handlers/guardianFactors.js +1 -1
  99. package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.d.ts +6 -0
  100. package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.js +1 -1
  101. package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.d.ts +6 -0
  102. package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.js +1 -1
  103. package/lib/context/yaml/handlers/guardianPolicies.d.ts +6 -0
  104. package/lib/context/yaml/handlers/guardianPolicies.js +1 -1
  105. package/lib/context/yaml/handlers/hooks.d.ts +6 -0
  106. package/lib/context/yaml/handlers/hooks.js +4 -3
  107. package/lib/context/yaml/handlers/index.d.ts +12 -0
  108. package/lib/context/yaml/handlers/index.js +3 -2
  109. package/lib/context/yaml/handlers/migrations.d.ts +6 -0
  110. package/lib/context/yaml/handlers/organizations.d.ts +6 -0
  111. package/lib/context/yaml/handlers/organizations.js +3 -3
  112. package/lib/context/yaml/handlers/pages.d.ts +6 -0
  113. package/lib/context/yaml/handlers/pages.js +3 -3
  114. package/lib/context/yaml/handlers/resourceServers.d.ts +6 -0
  115. package/lib/context/yaml/handlers/resourceServers.js +2 -2
  116. package/lib/context/yaml/handlers/roles.d.ts +6 -0
  117. package/lib/context/yaml/handlers/roles.js +3 -3
  118. package/lib/context/yaml/handlers/rules.d.ts +6 -0
  119. package/lib/context/yaml/handlers/rules.js +3 -3
  120. package/lib/context/yaml/handlers/rulesConfigs.d.ts +6 -0
  121. package/lib/context/yaml/handlers/rulesConfigs.js +2 -2
  122. package/lib/context/yaml/handlers/tenant.d.ts +6 -0
  123. package/lib/context/yaml/handlers/tenant.js +4 -3
  124. package/lib/context/yaml/handlers/triggers.d.ts +6 -0
  125. package/lib/context/yaml/handlers/triggers.js +2 -2
  126. package/lib/context/yaml/index.d.ts +13 -0
  127. package/lib/context/yaml/index.js +31 -23
  128. package/lib/index.d.ts +88 -0
  129. package/lib/index.js +25 -17
  130. package/lib/logger.d.ts +2 -0
  131. package/lib/logger.js +8 -17
  132. package/lib/readonly.d.ts +2 -0
  133. package/lib/readonly.js +11 -16
  134. package/lib/sessionDurationsToMinutes.d.ts +7 -0
  135. package/lib/sessionDurationsToMinutes.js +15 -0
  136. package/lib/tools/auth0/client.d.ts +2 -0
  137. package/lib/tools/auth0/client.js +12 -12
  138. package/lib/tools/auth0/handlers/actions.d.ts +95 -0
  139. package/lib/tools/auth0/handlers/actions.js +22 -24
  140. package/lib/tools/auth0/handlers/attackProtection.d.ts +28 -0
  141. package/lib/tools/auth0/handlers/attackProtection.js +14 -17
  142. package/lib/tools/auth0/handlers/branding.d.ts +27 -0
  143. package/lib/tools/auth0/handlers/branding.js +13 -9
  144. package/lib/tools/auth0/handlers/clientGrants.d.ts +32 -0
  145. package/lib/tools/auth0/handlers/clientGrants.js +17 -10
  146. package/lib/tools/auth0/handlers/clients.d.ts +23 -0
  147. package/lib/tools/auth0/handlers/clients.js +15 -8
  148. package/lib/tools/auth0/handlers/connections.d.ts +54 -0
  149. package/lib/tools/auth0/handlers/connections.js +30 -10
  150. package/lib/tools/auth0/handlers/databases.d.ts +36 -0
  151. package/lib/tools/auth0/handlers/databases.js +25 -13
  152. package/lib/tools/auth0/handlers/default.d.ts +54 -0
  153. package/lib/tools/auth0/handlers/default.js +62 -36
  154. package/lib/tools/auth0/handlers/emailProvider.d.ts +11 -0
  155. package/lib/tools/auth0/handlers/emailTemplates.d.ts +26 -0
  156. package/lib/tools/auth0/handlers/emailTemplates.js +8 -10
  157. package/lib/tools/auth0/handlers/guardianFactorProviders.d.ts +25 -0
  158. package/lib/tools/auth0/handlers/guardianFactorProviders.js +3 -3
  159. package/lib/tools/auth0/handlers/guardianFactorTemplates.d.ts +21 -0
  160. package/lib/tools/auth0/handlers/guardianFactorTemplates.js +3 -3
  161. package/lib/tools/auth0/handlers/guardianFactors.d.ts +21 -0
  162. package/lib/tools/auth0/handlers/guardianFactors.js +3 -3
  163. package/lib/tools/auth0/handlers/guardianPhoneFactorMessageTypes.d.ts +21 -0
  164. package/lib/tools/auth0/handlers/guardianPhoneFactorMessageTypes.js +11 -10
  165. package/lib/tools/auth0/handlers/guardianPhoneFactorSelectedProvider.d.ts +18 -0
  166. package/lib/tools/auth0/handlers/guardianPhoneFactorSelectedProvider.js +10 -9
  167. package/lib/tools/auth0/handlers/guardianPolicies.d.ts +23 -0
  168. package/lib/tools/auth0/handlers/guardianPolicies.js +5 -4
  169. package/lib/tools/auth0/handlers/hooks.d.ts +58 -0
  170. package/lib/tools/auth0/handlers/hooks.js +34 -21
  171. package/lib/tools/auth0/handlers/index.d.ts +129 -0
  172. package/lib/tools/auth0/handlers/index.js +31 -27
  173. package/lib/tools/auth0/handlers/migrations.d.ts +15 -0
  174. package/lib/tools/auth0/handlers/migrations.js +3 -2
  175. package/lib/tools/auth0/handlers/organizations.d.ts +51 -0
  176. package/lib/tools/auth0/handlers/organizations.js +62 -32
  177. package/lib/tools/auth0/handlers/pages.d.ts +42 -0
  178. package/lib/tools/auth0/handlers/pages.js +20 -14
  179. package/lib/tools/auth0/handlers/prompts.d.ts +11 -0
  180. package/lib/tools/auth0/handlers/prompts.js +1 -0
  181. package/lib/tools/auth0/handlers/resourceServers.d.ts +51 -0
  182. package/lib/tools/auth0/handlers/resourceServers.js +22 -14
  183. package/lib/tools/auth0/handlers/roles.d.ts +48 -0
  184. package/lib/tools/auth0/handlers/roles.js +56 -32
  185. package/lib/tools/auth0/handlers/rules.d.ts +55 -0
  186. package/lib/tools/auth0/handlers/rules.js +53 -36
  187. package/lib/tools/auth0/handlers/rulesConfigs.d.ts +25 -0
  188. package/lib/tools/auth0/handlers/rulesConfigs.js +12 -6
  189. package/lib/tools/auth0/handlers/tenant.d.ts +11 -0
  190. package/lib/tools/auth0/handlers/tenant.js +8 -4
  191. package/lib/tools/auth0/handlers/triggers.d.ts +35 -0
  192. package/lib/tools/auth0/handlers/triggers.js +12 -13
  193. package/lib/tools/auth0/index.d.ts +15 -0
  194. package/lib/tools/auth0/index.js +15 -31
  195. package/lib/tools/auth0/schema.d.ts +15 -0
  196. package/lib/tools/auth0/schema.js +7 -27
  197. package/lib/tools/calculateChanges.d.ts +26 -0
  198. package/lib/tools/calculateChanges.js +12 -7
  199. package/lib/tools/constants.d.ts +71 -0
  200. package/lib/tools/constants.js +164 -161
  201. package/lib/tools/deploy.d.ts +3 -0
  202. package/lib/tools/deploy.js +3 -3
  203. package/lib/tools/index.d.ts +82 -0
  204. package/lib/tools/index.js +1 -1
  205. package/lib/tools/utils.d.ts +18 -0
  206. package/lib/tools/utils.js +68 -10
  207. package/lib/tools/validationError.d.ts +5 -0
  208. package/lib/tools/{ValidationError.js → validationError.js} +3 -1
  209. package/lib/types.d.ts +255 -0
  210. package/lib/types.js +2 -0
  211. package/lib/utils.d.ts +66 -0
  212. package/lib/utils.js +18 -25
  213. package/package.json +16 -7
  214. package/tsconfig.json +3 -4
  215. package/typescript-migration-progress.sh +1 -1
  216. package/lib/tools/logger.js +0 -15
@@ -23,7 +23,7 @@ function parse(context) {
23
23
  const file = path_1.default.join(guardianFolder, 'phoneFactorSelectedProvider.json');
24
24
  if ((0, utils_1.isFile)(file)) {
25
25
  return {
26
- guardianPhoneFactorSelectedProvider: (0, utils_1.loadJSON)(file, context.mappings)
26
+ guardianPhoneFactorSelectedProvider: (0, utils_1.loadJSON)(file, context.mappings),
27
27
  };
28
28
  }
29
29
  return {};
@@ -0,0 +1,6 @@
1
+ import { DirectoryHandler } from '.';
2
+ declare type ParsedGuardianPolicies = {
3
+ guardianPolicies: unknown[];
4
+ } | {};
5
+ declare const guardianPoliciesHandler: DirectoryHandler<ParsedGuardianPolicies>;
6
+ export default guardianPoliciesHandler;
@@ -23,7 +23,7 @@ function parse(context) {
23
23
  const file = path_1.default.join(guardianFolder, 'policies.json');
24
24
  if ((0, utils_1.isFile)(file)) {
25
25
  return {
26
- guardianPolicies: (0, utils_1.loadJSON)(file, context.mappings)
26
+ guardianPolicies: (0, utils_1.loadJSON)(file, context.mappings),
27
27
  };
28
28
  }
29
29
  return {};
@@ -0,0 +1,6 @@
1
+ import { DirectoryHandler } from '.';
2
+ declare type ParsedHooks = {
3
+ hooks: unknown[] | undefined;
4
+ };
5
+ declare const hooksHandler: DirectoryHandler<ParsedHooks>;
6
+ export default hooksHandler;
@@ -31,12 +31,12 @@ function parse(context) {
31
31
  return hook;
32
32
  });
33
33
  return {
34
- hooks
34
+ hooks,
35
35
  };
36
36
  }
37
37
  function dump(context) {
38
38
  return __awaiter(this, void 0, void 0, function* () {
39
- const hooks = [...context.assets.hooks || []];
39
+ const hooks = [...(context.assets.hooks || [])];
40
40
  if (hooks.length < 1)
41
41
  return;
42
42
  // Create Hooks folder
@@ -0,0 +1,12 @@
1
+ import DirectoryContext from '..';
2
+ import { AssetTypes } from '../../../types';
3
+ export declare type DirectoryHandler<T> = {
4
+ dump: (context: DirectoryContext) => void;
5
+ parse: (context: DirectoryContext) => T;
6
+ };
7
+ declare const directoryHandlers: {
8
+ [key in AssetTypes]: DirectoryHandler<{
9
+ [key: string]: unknown;
10
+ }>;
11
+ };
12
+ export default directoryHandlers;
@@ -28,7 +28,7 @@ const organizations_1 = __importDefault(require("./organizations"));
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 directoryHandlers = {
32
32
  rules: rules_1.default,
33
33
  rulesConfigs: rulesConfigs_1.default,
34
34
  hooks: hooks_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 = directoryHandlers;
@@ -0,0 +1,6 @@
1
+ import { DirectoryHandler } from '.';
2
+ declare type ParsedMigrations = {
3
+ migrations: unknown[];
4
+ } | {};
5
+ declare const migrationsHandler: DirectoryHandler<ParsedMigrations>;
6
+ export default migrationsHandler;
@@ -0,0 +1,6 @@
1
+ import { DirectoryHandler } from '.';
2
+ declare type ParsedOrganizations = {
3
+ organizations: unknown[] | undefined;
4
+ };
5
+ declare const organizationsHandler: DirectoryHandler<ParsedOrganizations>;
6
+ export default organizationsHandler;
@@ -26,7 +26,7 @@ function parse(context) {
26
26
  return org;
27
27
  });
28
28
  return {
29
- organizations
29
+ organizations,
30
30
  };
31
31
  }
32
32
  function dump(context) {
@@ -0,0 +1,6 @@
1
+ import { DirectoryHandler } from '.';
2
+ declare type ParsedPages = {
3
+ pages: unknown[] | undefined;
4
+ };
5
+ declare const pagesHandler: DirectoryHandler<ParsedPages>;
6
+ export default pagesHandler;
@@ -44,12 +44,12 @@ function parse(context) {
44
44
  return Object.assign(Object.assign({}, (0, utils_1.loadJSON)(meta, context.mappings)), { html: (0, tools_1.loadFileAndReplaceKeywords)(html, context.mappings) });
45
45
  });
46
46
  return {
47
- pages
47
+ pages,
48
48
  };
49
49
  }
50
50
  function dump(context) {
51
51
  return __awaiter(this, void 0, void 0, function* () {
52
- const pages = [...context.assets.pages || []];
52
+ const pages = [...(context.assets.pages || [])];
53
53
  if (!pages)
54
54
  return; // Skip, nothing to dump
55
55
  // Create Pages folder
@@ -0,0 +1,6 @@
1
+ import { DirectoryHandler } from '.';
2
+ declare type ParsedResourceServers = {
3
+ resourceServers: unknown[] | undefined;
4
+ };
5
+ declare const resourceServersHandler: DirectoryHandler<ParsedResourceServers>;
6
+ export default resourceServersHandler;
@@ -21,10 +21,11 @@ function parse(context) {
21
21
  if (!(0, utils_1.existsMustBeDir)(resourceServersFolder))
22
22
  return { resourceServers: undefined }; // Skip
23
23
  const foundFiles = (0, utils_1.getFiles)(resourceServersFolder, ['.json']);
24
- const resourceServers = foundFiles.map((f) => (0, utils_1.loadJSON)(f, context.mappings))
24
+ const resourceServers = foundFiles
25
+ .map((f) => (0, utils_1.loadJSON)(f, context.mappings))
25
26
  .filter((p) => Object.keys(p).length > 0); // Filter out empty resourceServers
26
27
  return {
27
- resourceServers
28
+ resourceServers,
28
29
  };
29
30
  }
30
31
  function dump(context) {
@@ -0,0 +1,6 @@
1
+ import { DirectoryHandler } from '.';
2
+ declare type ParsedRoles = {
3
+ roles: unknown[] | undefined;
4
+ };
5
+ declare const rolesHandler: DirectoryHandler<ParsedRoles>;
6
+ export default rolesHandler;
@@ -27,7 +27,7 @@ function parse(context) {
27
27
  return role;
28
28
  });
29
29
  return {
30
- roles
30
+ roles,
31
31
  };
32
32
  }
33
33
  function dump(context) {
@@ -0,0 +1,6 @@
1
+ import { DirectoryHandler } from './index';
2
+ declare type ParsedRules = {
3
+ rules: unknown[] | undefined;
4
+ };
5
+ declare const rulesHandler: DirectoryHandler<ParsedRules>;
6
+ export default rulesHandler;
@@ -30,12 +30,12 @@ function parse(context) {
30
30
  return rule;
31
31
  });
32
32
  return {
33
- rules
33
+ rules,
34
34
  };
35
35
  }
36
36
  function dump(context) {
37
37
  return __awaiter(this, void 0, void 0, function* () {
38
- const rules = [...context.assets.rules || []];
38
+ const rules = [...(context.assets.rules || [])];
39
39
  if (!rules)
40
40
  return; // Skip, nothing to dump
41
41
  // Create Rules folder
@@ -0,0 +1,6 @@
1
+ import { DirectoryHandler } from '.';
2
+ declare type ParsedRulesConfigs = {
3
+ rulesConfigs: unknown[] | undefined;
4
+ };
5
+ declare const rulesConfigsHandler: DirectoryHandler<ParsedRulesConfigs>;
6
+ export default rulesConfigsHandler;
@@ -20,10 +20,11 @@ function parse(context) {
20
20
  if (!(0, utils_1.existsMustBeDir)(rulesConfigsFolder))
21
21
  return { rulesConfigs: undefined }; // Skip
22
22
  const foundFiles = (0, utils_1.getFiles)(rulesConfigsFolder, ['.json']);
23
- const rulesConfigs = foundFiles.map((f) => (0, utils_1.loadJSON)(f, context.mappings))
23
+ const rulesConfigs = foundFiles
24
+ .map((f) => (0, utils_1.loadJSON)(f, context.mappings))
24
25
  .filter((p) => Object.keys(p).length > 0); // Filter out empty rulesConfigs
25
26
  return {
26
- rulesConfigs
27
+ rulesConfigs,
27
28
  };
28
29
  }
29
30
  function dump() {
@@ -0,0 +1,10 @@
1
+ import { DirectoryHandler } from '.';
2
+ declare type ParsedTenant = {
3
+ tenant: {
4
+ session_lifetime: number;
5
+ idle_session_lifetime: number;
6
+ [key: string]: unknown;
7
+ };
8
+ } | {};
9
+ declare const tenantHandler: DirectoryHandler<ParsedTenant>;
10
+ export default tenantHandler;
@@ -25,6 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  const path_1 = __importDefault(require("path"));
27
27
  const utils_1 = require("../../../utils");
28
+ const sessionDurationsToMinutes_1 = require("../../../sessionDurationsToMinutes");
28
29
  function parse(context) {
29
30
  const baseFolder = path_1.default.join(context.filePath);
30
31
  if (!(0, utils_1.existsMustBeDir)(baseFolder))
@@ -34,10 +35,10 @@ function parse(context) {
34
35
  /* eslint-disable camelcase */
35
36
  const _a = (0, utils_1.loadJSON)(tenantFile, context.mappings), { session_lifetime, idle_session_lifetime } = _a, tenant = __rest(_a, ["session_lifetime", "idle_session_lifetime"]);
36
37
  (0, utils_1.clearTenantFlags)(tenant);
38
+ const sessionDurations = (0, sessionDurationsToMinutes_1.sessionDurationsToMinutes)({ session_lifetime, idle_session_lifetime });
37
39
  return {
38
- tenant: Object.assign(Object.assign({}, tenant), { session_lifetime_in_minutes: (0, utils_1.hoursAsInteger)('session_lifetime', session_lifetime)['session_lifetime_in_minutes'], idle_session_lifetime_in_minutes: (0, utils_1.hoursAsInteger)('idle_session_lifetime', idle_session_lifetime)['idle_session_lifetime_in_minutes'] })
40
+ tenant: Object.assign(Object.assign({}, tenant), sessionDurations),
39
41
  };
40
- /* eslint-enable camelcase */
41
42
  }
42
43
  return {};
43
44
  }
@@ -0,0 +1,6 @@
1
+ import { DirectoryHandler } from '.';
2
+ declare type ParsedTriggers = {
3
+ triggers: unknown[] | undefined;
4
+ };
5
+ declare const triggersHandler: DirectoryHandler<ParsedTriggers>;
6
+ export default triggersHandler;
@@ -0,0 +1,17 @@
1
+ import { Assets, Auth0APIClient, Config } from '../../types';
2
+ declare type KeywordMappings = {
3
+ [key: string]: (string | number)[] | string | number;
4
+ };
5
+ export default class DirectoryContext {
6
+ basePath: string;
7
+ filePath: string;
8
+ config: Config;
9
+ mappings: KeywordMappings;
10
+ mgmtClient: Auth0APIClient;
11
+ assets: Assets;
12
+ constructor(config: Config, mgmtClient: Auth0APIClient);
13
+ loadFile(f: string, folder: string): string;
14
+ load(): Promise<void>;
15
+ dump(): Promise<void>;
16
+ }
17
+ export {};
@@ -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;
@@ -0,0 +1,4 @@
1
+ import YAMLContext from './yaml';
2
+ import DirectoryContext from './directory';
3
+ import { Config } from '../types';
4
+ export declare const setupContext: (config: Config) => Promise<DirectoryContext | YAMLContext>;
@@ -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,94 @@ 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;
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
+ ((config) => {
50
+ // Detect and warn on usage of deprecated exclusion params. See: https://github.com/auth0/auth0-deploy-cli/issues/451#user-content-deprecated-exclusion-props
51
+ const deprecatedExclusionParams = [
52
+ 'AUTH0_EXCLUDED_RULES',
53
+ 'AUTH0_EXCLUDED_CLIENTS',
54
+ 'AUTH0_EXCLUDED_DATABASES',
55
+ 'AUTH0_EXCLUDED_CONNECTIONS',
56
+ 'AUTH0_EXCLUDED_RESOURCE_SERVERS',
57
+ 'AUTH0_EXCLUDED_DEFAULTS',
58
+ ];
59
+ const usedDeprecatedParams = deprecatedExclusionParams.filter((deprecatedParam) => {
60
+ const deprecatedConfigValue = config[deprecatedParam];
61
+ return !!deprecatedConfigValue && deprecatedConfigValue.length > 0;
62
+ });
63
+ if (usedDeprecatedParams.length > 0) {
64
+ logger_1.default.warn(`Usage of the ${usedDeprecatedParams.join(', ')} exclusion ${usedDeprecatedParams.length > 1 ? 'params are' : 'param is'} deprecated and may be removed from future major versions. See: https://github.com/auth0/auth0-deploy-cli/issues/451#user-content-deprecated-exclusion-props for details.`);
59
65
  }
60
- const mgmtClient = new auth0_1.ManagementClient({
66
+ })(config);
67
+ const accessToken = yield (() => __awaiter(void 0, void 0, void 0, function* () {
68
+ if (!!config.AUTH0_ACCESS_TOKEN)
69
+ return config.AUTH0_ACCESS_TOKEN;
70
+ const authClient = new auth0_1.AuthenticationClient({
61
71
  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
- }
72
+ clientId: config.AUTH0_CLIENT_ID,
73
+ clientSecret: config.AUTH0_CLIENT_SECRET,
67
74
  });
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
- }
75
+ const clientCredentials = yield authClient.clientCredentialsGrant({
76
+ audience: config.AUTH0_AUDIENCE
77
+ ? config.AUTH0_AUDIENCE
78
+ : `https://${config.AUTH0_DOMAIN}/api/v2/`,
79
+ });
80
+ return clientCredentials.access_token;
81
+ }))();
82
+ const mgmtClient = new auth0_1.ManagementClient({
83
+ domain: config.AUTH0_DOMAIN,
84
+ token: accessToken,
85
+ retry: { maxRetries: config.AUTH0_API_MAX_RETRIES || 10, enabled: true },
86
+ headers: {
87
+ 'User-agent': `deploy-cli/${packageVersion} (node.js/${process.version.replace('v', '')})`,
88
+ },
89
+ });
90
+ const inputFile = config.AUTH0_INPUT_FILE;
91
+ const ensureObject = (key, value) => {
92
+ if (typeof value === 'string') {
93
+ try {
94
+ return JSON.parse(value);
78
95
  }
79
- return value;
80
- };
81
- nonPrimitiveProps.forEach((key) => {
82
- if (config[key]) {
83
- config[key] = ensureObject(key, config[key]);
96
+ catch (e) {
97
+ logger_1.default.debug(`Cannot convert config.${key} to an object. Error: ${e.message}`);
98
+ return value;
84
99
  }
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
100
  }
92
- const ext = path_1.default.extname(inputFile);
93
- if (ext === '.yaml' || ext === '.yml') {
94
- return new yaml_1.default(config, mgmtClient);
101
+ return value;
102
+ };
103
+ nonPrimitiveProps.forEach((key) => {
104
+ if (config[key]) {
105
+ //@ts-ignore because this method of config overwriting technically functions
106
+ config[key] = ensureObject(key, config[key]);
95
107
  }
96
- throw new Error(`Unable to determine context processor to load for file ${inputFile}, does it exist? `);
97
108
  });
98
- }
99
- exports.default = default_1;
109
+ if (typeof inputFile === 'object') {
110
+ return new yaml_1.default(config, mgmtClient);
111
+ }
112
+ if ((0, utils_1.isDirectory)(inputFile)) {
113
+ return new directory_1.default(config, mgmtClient);
114
+ }
115
+ const ext = path_1.default.extname(inputFile);
116
+ if (ext === '.yaml' || ext === '.yml') {
117
+ return new yaml_1.default(config, mgmtClient);
118
+ }
119
+ throw new Error(`Unable to determine context processor to load for file ${inputFile}, does it exist? `);
120
+ });
121
+ exports.setupContext = setupContext;
@@ -0,0 +1,6 @@
1
+ import { YAMLHandler } from '.';
2
+ declare type ParsedActions = {
3
+ actions: unknown[] | undefined;
4
+ };
5
+ declare const ActionsHandler: YAMLHandler<ParsedActions>;
6
+ export default ActionsHandler;
@@ -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;
@@ -0,0 +1,6 @@
1
+ import { YAMLHandler } from '.';
2
+ declare type ParsedAttackProtection = {
3
+ attackProtection: unknown;
4
+ };
5
+ declare const attackProtectionHandler: YAMLHandler<ParsedAttackProtection>;
6
+ export default attackProtectionHandler;
@@ -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
  }
@@ -0,0 +1,6 @@
1
+ import { YAMLHandler } from '.';
2
+ declare type ParsedBranding = {
3
+ branding: unknown;
4
+ };
5
+ declare const brandingHandler: YAMLHandler<ParsedBranding>;
6
+ export default brandingHandler;