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
@@ -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
  }
@@ -0,0 +1,13 @@
1
+ import { Assets, Config, Auth0APIClient, KeywordMappings } from '../../types';
2
+ export default class YAMLContext {
3
+ basePath: string;
4
+ configFile: string;
5
+ config: Config;
6
+ mappings: KeywordMappings;
7
+ mgmtClient: Auth0APIClient;
8
+ assets: Assets;
9
+ constructor(config: Config, mgmtClient: any);
10
+ loadFile(f: any): string;
11
+ load(): Promise<void>;
12
+ dump(): Promise<void>;
13
+ }
@@ -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.d.ts ADDED
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env node
2
+ import importCMD from './commands/import';
3
+ import exportCMD from './commands/export';
4
+ declare const _default: {
5
+ deploy: typeof importCMD;
6
+ dump: typeof exportCMD;
7
+ import: typeof importCMD;
8
+ export: typeof exportCMD;
9
+ tools: {
10
+ constants: {
11
+ CONCURRENT_CALLS: number;
12
+ RULES_DIRECTORY: string;
13
+ RULES_STAGES: string[];
14
+ DEFAULT_RULE_STAGE: string;
15
+ HOOKS_HIDDEN_SECRET_VALUE: string;
16
+ OBFUSCATED_SECRET_VALUE: string;
17
+ HOOKS_DIRECTORY: string;
18
+ ACTIONS_DIRECTORY: string;
19
+ TRIGGERS_DIRECTORY: string;
20
+ RULES_CONFIGS_DIRECTORY: string;
21
+ PAGES_DIRECTORY: string;
22
+ PAGE_LOGIN: string;
23
+ PAGE_GUARDIAN_MULTIFACTOR: string;
24
+ PAGE_PASSWORD_RESET: string;
25
+ PAGE_ERROR: string;
26
+ DATABASE_CONNECTIONS_DIRECTORY: string;
27
+ DATABASE_SCRIPTS_CHANGE_EMAIL: string;
28
+ DATABASE_SCRIPTS_GET_USER: string;
29
+ EMAIL_TEMPLATES_TYPES: string[];
30
+ ACTIONS_TRIGGERS: string[];
31
+ EMAIL_TEMPLATES_DIRECTORY: string;
32
+ EMAIL_VERIFY: string;
33
+ EMAIL_VERIFY_BY_CODE: string;
34
+ EMAIL_RESET: string;
35
+ EMAIL_WELCOME: string;
36
+ EMAIL_BLOCKED: string;
37
+ EMAIL_STOLEN_CREDENTIALS: string;
38
+ EMAIL_ENROLLMENT: string;
39
+ EMAIL_CHANGE_PASSWORD: string;
40
+ EMAIL_PASSWORD_RESET: string;
41
+ EMAIL_MFA_OOB_CODE: string;
42
+ EMAIL_USER_INVITATION: string;
43
+ GUARDIAN_DIRECTORY: string;
44
+ GUARDIAN_FACTORS_DIRECTORY: string;
45
+ GUARDIAN_PROVIDERS_DIRECTORY: string;
46
+ GUARDIAN_TEMPLATES_DIRECTORY: string;
47
+ UNIVERSAL_LOGIN_TEMPLATE: string;
48
+ RESOURCE_SERVERS_DIRECTORY: string;
49
+ RESOURCE_SERVERS_CLIENT_NAME: string;
50
+ RESOURCE_SERVERS_MANAGEMENT_API_NAME: string;
51
+ RESOURCE_SERVERS_ID_NAME: string;
52
+ CLIENTS_DIRECTORY: string;
53
+ CLIENTS_GRANTS_DIRECTORY: string;
54
+ BRANDING_DIRECTORY: string;
55
+ BRANDING_TEMPLATES_DIRECTORY: string;
56
+ BRANDING_TEMPLATES_YAML_DIRECTORY: string;
57
+ CLIENTS_CLIENT_NAME: string;
58
+ CLIENTS_CLIENT_ID_NAME: string;
59
+ CONNECTIONS_DIRECTORY: string;
60
+ CONNECTIONS_CLIENT_NAME: string;
61
+ CONNECTIONS_ID_NAME: string;
62
+ ROLES_DIRECTORY: string;
63
+ ATTACK_PROTECTION_DIRECTORY: string;
64
+ GUARDIAN_FACTORS: string[];
65
+ GUARDIAN_POLICIES: string[];
66
+ GUARDIAN_PHONE_PROVIDERS: string[];
67
+ GUARDIAN_PHONE_MESSAGE_TYPES: string[];
68
+ GUARDIAN_FACTOR_TEMPLATES: string[];
69
+ GUARDIAN_FACTOR_PROVIDERS: {
70
+ sms: string[];
71
+ 'push-notification': string[];
72
+ };
73
+ PAGE_NAMES: string[];
74
+ DATABASE_SCRIPTS: string[];
75
+ DATABASE_SCRIPTS_NO_IMPORT: string[];
76
+ DATABASE_SCRIPTS_IMPORT: string[];
77
+ EMAIL_TEMPLATES_NAMES: string[];
78
+ SUPPORTED_BRANDING_TEMPLATES: string[];
79
+ };
80
+ deploy: typeof import("./tools").deploy;
81
+ keywordReplace: typeof import("./tools").keywordReplace;
82
+ loadFileAndReplaceKeywords: typeof import("./tools").loadFileAndReplaceKeywords;
83
+ Auth0: typeof import("./tools").Auth0;
84
+ };
85
+ };
86
+ export default _default;
87
+ export declare const dump: typeof exportCMD;
88
+ export declare const deploy: typeof importCMD;
package/lib/index.js CHANGED
@@ -13,15 +13,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  return (mod && mod.__esModule) ? mod : { "default": mod };
14
14
  };
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.deploy = exports.dump = void 0;
16
17
  const global_agent_1 = require("global-agent");
17
18
  const args_1 = require("./args");
18
- const commands_1 = __importDefault(require("./commands"));
19
19
  const logger_1 = __importDefault(require("./logger"));
20
20
  const tools_1 = __importDefault(require("./tools"));
21
+ const import_1 = __importDefault(require("./commands/import"));
22
+ const export_1 = __importDefault(require("./commands/export"));
21
23
  function run(params) {
22
24
  return __awaiter(this, void 0, void 0, function* () {
23
25
  // Run command
24
- const cmd = commands_1.default[params._[0]];
26
+ const command = params._[0];
25
27
  const proxy = params.proxy_url;
26
28
  if (proxy) {
27
29
  const MAJOR_NODEJS_VERSION = parseInt(process.version.slice(1).split('.')[0], 10);
@@ -32,9 +34,14 @@ function run(params) {
32
34
  process.env.GLOBAL_AGENT_HTTP_PROXY = proxy;
33
35
  (0, global_agent_1.bootstrap)();
34
36
  }
35
- logger_1.default.debug(`Start command ${params._[0]}`);
36
- yield cmd(params);
37
- logger_1.default.debug(`Finished command ${params._[0]}`);
37
+ logger_1.default.debug(`Start command ${command}`);
38
+ if (['deploy', 'import'].includes(command) && 'input_file' in params) {
39
+ yield (0, import_1.default)(params);
40
+ }
41
+ if (['dump', 'export'].includes(command) && 'output_folder' in params) {
42
+ yield (0, export_1.default)(params);
43
+ }
44
+ logger_1.default.debug(`Finished command ${command}`);
38
45
  });
39
46
  }
40
47
  // Only run if from command line
@@ -42,10 +49,8 @@ if (require.main === module) {
42
49
  // Load cli params
43
50
  const params = (0, args_1.getParams)();
44
51
  logger_1.default.debug('Starting Auth0 Deploy CLI Tool');
45
- // Set log level
46
- logger_1.default.transports.console.level = params.level;
47
52
  if (params.debug) {
48
- logger_1.default.transports.console.level = 'debug';
53
+ logger_1.default.level = 'debug';
49
54
  // Set for tools
50
55
  process.env.AUTH0_DEBUG = 'true';
51
56
  process.env.AUTH0_LOG = 'debug';
@@ -53,15 +58,16 @@ if (require.main === module) {
53
58
  run(params)
54
59
  .then(() => process.exit(0))
55
60
  .catch((error) => {
61
+ const command = params._[0];
56
62
  if (error.type || error.stage) {
57
- logger_1.default.error(`Problem running command ${params._[0]} during stage ${error.stage} when processing type ${error.type}`);
63
+ logger_1.default.error(`Problem running command ${command} during stage ${error.stage} when processing type ${error.type}`);
58
64
  }
59
65
  else {
60
- logger_1.default.error(`Problem running command ${params._[0]}`);
66
+ logger_1.default.error(`Problem running command ${command}`);
61
67
  }
62
68
  const msg = error.message || error.toString();
63
69
  logger_1.default.error(msg);
64
- if (process.env.AUTH0_DEBUG === 'true') {
70
+ if (process.env.AUTH0_DEBUG === 'true' && error.stack) {
65
71
  logger_1.default.debug(error.stack);
66
72
  }
67
73
  if (typeof msg === 'string' && msg.includes('Payload validation error')) {
@@ -71,10 +77,12 @@ if (require.main === module) {
71
77
  });
72
78
  }
73
79
  // Export commands to be used programmatically
74
- 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
+ exports.default = {
81
+ deploy: import_1.default,
82
+ dump: export_1.default,
83
+ import: import_1.default,
84
+ export: export_1.default,
85
+ tools: tools_1.default,
80
86
  };
87
+ exports.dump = export_1.default;
88
+ exports.deploy = import_1.default;
@@ -0,0 +1,2 @@
1
+ declare const logger: import("winston").Logger;
2
+ export default logger;
package/lib/logger.js CHANGED
@@ -1,20 +1,11 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const winston_1 = __importDefault(require("winston"));
7
- winston_1.default.emitErrs = true;
8
- const log = new winston_1.default.Logger({
9
- transports: [
10
- new winston_1.default.transports.Console({
11
- timestamp: true,
12
- level: process.env.AUTH0_LOG || 'info',
13
- handleExceptions: true,
14
- json: false,
15
- colorize: true
16
- })
17
- ],
18
- exitOnError: false
3
+ const winston_1 = require("winston");
4
+ const { combine, timestamp, colorize } = winston_1.format;
5
+ const logger = (0, winston_1.createLogger)({
6
+ level: process.env.AUTH0_LOG || 'info',
7
+ format: combine(colorize(), timestamp(), winston_1.format.printf((info) => `${info.timestamp} - ${info.level}: ${info.message}`)),
8
+ transports: [new winston_1.transports.Console()],
9
+ exitOnError: false,
19
10
  });
20
- exports.default = log;
11
+ exports.default = logger;
@@ -0,0 +1,2 @@
1
+ import { Assets, Config } from './types';
2
+ export default function cleanAssets(assets: Assets, config: Config): Assets;
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,7 @@
1
+ export declare const sessionDurationsToMinutes: ({ session_lifetime, idle_session_lifetime, }: {
2
+ session_lifetime?: number | undefined;
3
+ idle_session_lifetime?: number | undefined;
4
+ }) => {
5
+ session_lifetime_in_minutes?: number;
6
+ idle_session_lifetime_in_minutes?: number;
7
+ };
@@ -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;
@@ -0,0 +1,2 @@
1
+ import { Auth0APIClient, BaseAuth0APIClient } from '../../types';
2
+ export default function pagedClient(client: BaseAuth0APIClient): Auth0APIClient;
@@ -33,7 +33,7 @@ const API_FREQUENCY_PER_SECOND = 8;
33
33
  const MAX_PAGE_SIZE = 100;
34
34
  function getEntity(rsp) {
35
35
  const found = Object.values(rsp).filter((a) => Array.isArray(a));
36
- if (found.length === 1) {
36
+ if (Array.isArray(found) && found.length === 1) {
37
37
  return found[0];
38
38
  }
39
39
  throw new Error('There was an error trying to find the entity within paginate');
@@ -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,16 +142,16 @@ 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
149
149
  function pagedClient(client) {
150
- client.pool = new promise_pool_executor_1.PromisePoolExecutor({
151
- concurrencyLimit: API_CONCURRENCY,
152
- frequencyLimit: API_FREQUENCY_PER_SECOND,
153
- frequencyWindow: 1000 // 1 sec
154
- });
155
- return pagedManager(client, client);
150
+ const clientWithPooling = Object.assign(Object.assign({}, client), { pool: new promise_pool_executor_1.PromisePoolExecutor({
151
+ concurrencyLimit: API_CONCURRENCY,
152
+ frequencyLimit: API_FREQUENCY_PER_SECOND,
153
+ frequencyWindow: 1000, // 1 sec
154
+ }) });
155
+ return pagedManager(clientWithPooling, clientWithPooling);
156
156
  }
157
157
  exports.default = pagedClient;
@@ -0,0 +1,95 @@
1
+ import DefaultAPIHandler from './default';
2
+ import { Asset } from '../../../types';
3
+ export declare const schema: {
4
+ type: string;
5
+ items: {
6
+ type: string;
7
+ required: string[];
8
+ additionalProperties: boolean;
9
+ properties: {
10
+ code: {
11
+ type: string;
12
+ default: string;
13
+ };
14
+ runtime: {
15
+ type: string;
16
+ };
17
+ dependencies: {
18
+ type: string;
19
+ items: {
20
+ type: string;
21
+ additionalProperties: boolean;
22
+ properties: {
23
+ name: {
24
+ type: string;
25
+ };
26
+ version: {
27
+ type: string;
28
+ };
29
+ registry_url: {
30
+ type: string;
31
+ };
32
+ };
33
+ };
34
+ };
35
+ secrets: {
36
+ type: string;
37
+ items: {
38
+ type: string;
39
+ properties: {
40
+ name: {
41
+ type: string;
42
+ };
43
+ value: {
44
+ type: string;
45
+ };
46
+ updated_at: {
47
+ type: string;
48
+ format: string;
49
+ };
50
+ };
51
+ };
52
+ };
53
+ name: {
54
+ type: string;
55
+ default: string;
56
+ };
57
+ supported_triggers: {
58
+ type: string;
59
+ items: {
60
+ type: string;
61
+ properties: {
62
+ id: {
63
+ type: string;
64
+ default: string;
65
+ };
66
+ version: {
67
+ type: string;
68
+ };
69
+ url: {
70
+ type: string;
71
+ };
72
+ };
73
+ };
74
+ };
75
+ deployed: {
76
+ type: string;
77
+ };
78
+ status: {
79
+ type: string;
80
+ };
81
+ };
82
+ };
83
+ };
84
+ export default class ActionHandler extends DefaultAPIHandler {
85
+ existing: Asset[] | null;
86
+ constructor(options: any);
87
+ createAction(action: any): Promise<Asset>;
88
+ deleteAction(action: any): Promise<void | never[]>;
89
+ objString(action: any): string;
90
+ deployActions(actions: any): Promise<void>;
91
+ deployAction(action: any): Promise<void>;
92
+ actionChanges(action: any, found: any): Promise<Asset>;
93
+ getType(): Promise<Asset[] | null>;
94
+ processChanges(assets: any): Promise<void>;
95
+ }