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
@@ -13,11 +13,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const auth0_1 = __importDefault(require("./auth0"));
16
- const logger_1 = __importDefault(require("./logger"));
16
+ const logger_1 = __importDefault(require("../logger"));
17
17
  function deploy(assets, client, config) {
18
18
  return __awaiter(this, void 0, void 0, function* () {
19
19
  // Setup log level
20
- logger_1.default.transports.console.level = process.env.AUTH0_DEBUG === 'true' ? 'debug' : 'info';
20
+ logger_1.default.level = process.env.AUTH0_DEBUG === 'true' ? 'debug' : 'info';
21
21
  logger_1.default.info('Getting access token for ' + config('AUTH0_CLIENT_ID') + '/' + config('AUTH0_DOMAIN'));
22
22
  const auth0 = new auth0_1.default(client, assets, config);
23
23
  // Validate Assets
@@ -28,7 +28,7 @@ function deploy(assets, client, config) {
28
28
  accum[h.type] = {
29
29
  deleted: h.deleted,
30
30
  created: h.created,
31
- updated: h.updated
31
+ updated: h.updated,
32
32
  };
33
33
  return accum;
34
34
  }, {});
@@ -0,0 +1,82 @@
1
+ import constants from './constants';
2
+ import deploy from './deploy';
3
+ import Auth0 from './auth0';
4
+ import { keywordReplace, loadFileAndReplaceKeywords } from './utils';
5
+ declare const _default: {
6
+ constants: {
7
+ CONCURRENT_CALLS: number;
8
+ RULES_DIRECTORY: string;
9
+ RULES_STAGES: string[];
10
+ DEFAULT_RULE_STAGE: string;
11
+ HOOKS_HIDDEN_SECRET_VALUE: string;
12
+ OBFUSCATED_SECRET_VALUE: string;
13
+ HOOKS_DIRECTORY: string;
14
+ ACTIONS_DIRECTORY: string;
15
+ TRIGGERS_DIRECTORY: string;
16
+ RULES_CONFIGS_DIRECTORY: string;
17
+ PAGES_DIRECTORY: string;
18
+ PAGE_LOGIN: string;
19
+ PAGE_GUARDIAN_MULTIFACTOR: string;
20
+ PAGE_PASSWORD_RESET: string;
21
+ PAGE_ERROR: string;
22
+ DATABASE_CONNECTIONS_DIRECTORY: string;
23
+ DATABASE_SCRIPTS_CHANGE_EMAIL: string;
24
+ DATABASE_SCRIPTS_GET_USER: string;
25
+ EMAIL_TEMPLATES_TYPES: string[];
26
+ ACTIONS_TRIGGERS: string[];
27
+ EMAIL_TEMPLATES_DIRECTORY: string;
28
+ EMAIL_VERIFY: string;
29
+ EMAIL_VERIFY_BY_CODE: string;
30
+ EMAIL_RESET: string;
31
+ EMAIL_WELCOME: string;
32
+ EMAIL_BLOCKED: string;
33
+ EMAIL_STOLEN_CREDENTIALS: string;
34
+ EMAIL_ENROLLMENT: string;
35
+ EMAIL_CHANGE_PASSWORD: string;
36
+ EMAIL_PASSWORD_RESET: string;
37
+ EMAIL_MFA_OOB_CODE: string;
38
+ EMAIL_USER_INVITATION: string;
39
+ GUARDIAN_DIRECTORY: string;
40
+ GUARDIAN_FACTORS_DIRECTORY: string;
41
+ GUARDIAN_PROVIDERS_DIRECTORY: string;
42
+ GUARDIAN_TEMPLATES_DIRECTORY: string;
43
+ UNIVERSAL_LOGIN_TEMPLATE: string;
44
+ RESOURCE_SERVERS_DIRECTORY: string;
45
+ RESOURCE_SERVERS_CLIENT_NAME: string;
46
+ RESOURCE_SERVERS_MANAGEMENT_API_NAME: string;
47
+ RESOURCE_SERVERS_ID_NAME: string;
48
+ CLIENTS_DIRECTORY: string;
49
+ CLIENTS_GRANTS_DIRECTORY: string;
50
+ BRANDING_DIRECTORY: string;
51
+ BRANDING_TEMPLATES_DIRECTORY: string;
52
+ BRANDING_TEMPLATES_YAML_DIRECTORY: string;
53
+ CLIENTS_CLIENT_NAME: string;
54
+ CLIENTS_CLIENT_ID_NAME: string;
55
+ CONNECTIONS_DIRECTORY: string;
56
+ CONNECTIONS_CLIENT_NAME: string;
57
+ CONNECTIONS_ID_NAME: string;
58
+ ROLES_DIRECTORY: string;
59
+ ATTACK_PROTECTION_DIRECTORY: string;
60
+ GUARDIAN_FACTORS: string[];
61
+ GUARDIAN_POLICIES: string[];
62
+ GUARDIAN_PHONE_PROVIDERS: string[];
63
+ GUARDIAN_PHONE_MESSAGE_TYPES: string[];
64
+ GUARDIAN_FACTOR_TEMPLATES: string[];
65
+ GUARDIAN_FACTOR_PROVIDERS: {
66
+ sms: string[];
67
+ 'push-notification': string[];
68
+ };
69
+ PAGE_NAMES: string[];
70
+ DATABASE_SCRIPTS: string[];
71
+ DATABASE_SCRIPTS_NO_IMPORT: string[];
72
+ DATABASE_SCRIPTS_IMPORT: string[];
73
+ EMAIL_TEMPLATES_NAMES: string[];
74
+ SUPPORTED_BRANDING_TEMPLATES: string[];
75
+ };
76
+ deploy: typeof deploy;
77
+ keywordReplace: typeof keywordReplace;
78
+ loadFileAndReplaceKeywords: typeof loadFileAndReplaceKeywords;
79
+ Auth0: typeof Auth0;
80
+ };
81
+ export default _default;
82
+ export { constants, deploy, keywordReplace, loadFileAndReplaceKeywords, Auth0 };
@@ -18,5 +18,5 @@ exports.default = {
18
18
  deploy: deploy_1.default,
19
19
  keywordReplace: utils_1.keywordReplace,
20
20
  loadFileAndReplaceKeywords: utils_1.loadFileAndReplaceKeywords,
21
- Auth0: auth0_1.default
21
+ Auth0: auth0_1.default,
22
22
  };
@@ -0,0 +1,18 @@
1
+ import { Asset, Assets, CalculatedChanges, KeywordMappings } from '../types';
2
+ export declare function keywordArrayReplace(input: string, mappings: KeywordMappings): string;
3
+ export declare function keywordStringReplace(input: string, mappings: KeywordMappings): string;
4
+ export declare function keywordReplace(input: string, mappings: KeywordMappings): string;
5
+ export declare function convertClientNameToId(name: string, clients: Asset[]): string;
6
+ export declare function convertClientNamesToIds(names: string[], clients: Asset[]): string[];
7
+ export declare function loadFileAndReplaceKeywords(file: string, mappings: KeywordMappings): string;
8
+ export declare function flatten(list: any[]): any[];
9
+ export declare function convertJsonToString(obj: {
10
+ [key: string]: any;
11
+ }, spacing?: number): string;
12
+ export declare function stripFields(obj: Asset, fields: string[]): Asset;
13
+ export declare function getEnabledClients(assets: Assets, connection: Asset, existing: Asset[], clients: Asset[]): string[];
14
+ export declare function duplicateItems(arr: Asset[], key: string): Asset[];
15
+ export declare function filterExcluded(changes: CalculatedChanges, exclude: string[]): CalculatedChanges;
16
+ export declare function areArraysEquals(x: any[], y: any[]): boolean;
17
+ export declare const obfuscateSensitiveValues: (data: Asset | Asset[] | null, sensitiveFieldsToObfuscate: string[]) => Asset | Asset[] | null;
18
+ export declare const stripObfuscatedFieldsFromPayload: (data: Asset | Asset[] | null, obfuscatedFields: string[]) => Asset | Asset[] | null;
@@ -1,14 +1,38 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.areArraysEquals = exports.filterExcluded = exports.duplicateItems = exports.getEnabledClients = exports.stripFields = exports.dumpJSON = exports.flatten = exports.loadFileAndReplaceKeywords = exports.convertClientNamesToIds = exports.convertClientNameToId = exports.keywordReplace = exports.keywordStringReplace = exports.keywordArrayReplace = void 0;
29
+ exports.stripObfuscatedFieldsFromPayload = exports.obfuscateSensitiveValues = exports.areArraysEquals = exports.filterExcluded = exports.duplicateItems = exports.getEnabledClients = exports.stripFields = exports.convertJsonToString = exports.flatten = exports.loadFileAndReplaceKeywords = exports.convertClientNamesToIds = exports.convertClientNameToId = exports.keywordReplace = exports.keywordStringReplace = exports.keywordArrayReplace = void 0;
7
30
  const path_1 = __importDefault(require("path"));
8
- const fs_1 = __importDefault(require("fs"));
31
+ const fs_1 = __importStar(require("fs"));
9
32
  const dot_prop_1 = __importDefault(require("dot-prop"));
10
33
  const lodash_1 = __importDefault(require("lodash"));
11
- const logger_1 = __importDefault(require("./logger"));
34
+ const logger_1 = __importDefault(require("../logger"));
35
+ const constants_1 = __importDefault(require("./constants"));
12
36
  function keywordArrayReplace(input, mappings) {
13
37
  Object.keys(mappings).forEach(function (key) {
14
38
  // Matching against two sets of patterns because a developer may provide their array replacement keyword with or without wrapping quotes. It is not obvious to the developer which to do depending if they're operating in YAML or JSON.
@@ -23,6 +47,7 @@ exports.keywordArrayReplace = keywordArrayReplace;
23
47
  function keywordStringReplace(input, mappings) {
24
48
  Object.keys(mappings).forEach(function (key) {
25
49
  const regex = new RegExp(`##${key}##`, 'g');
50
+ // @ts-ignore TODO: come back and distinguish strings vs array replacement.
26
51
  input = input.replace(regex, mappings[key]);
27
52
  });
28
53
  return input;
@@ -48,11 +73,12 @@ function convertClientNamesToIds(names, clients) {
48
73
  if (names.includes(client.name)) {
49
74
  const index = resolvedNames.findIndex((item) => item.name === client.name);
50
75
  resolvedNames[index].resolved = true;
51
- acc.push(client.client_id);
76
+ return [...acc, client.client_id];
52
77
  }
53
- return acc;
78
+ return [...acc];
54
79
  }, []);
55
80
  const unresolved = resolvedNames.filter((item) => !item.resolved).map((item) => item.name);
81
+ // @ts-ignore TODO: come back and refactor to use map instead of reduce.
56
82
  return [...unresolved, ...result];
57
83
  }
58
84
  exports.convertClientNamesToIds = convertClientNamesToIds;
@@ -60,7 +86,7 @@ function loadFileAndReplaceKeywords(file, mappings) {
60
86
  // Load file and replace keyword mappings
61
87
  const f = path_1.default.resolve(file);
62
88
  try {
63
- fs_1.default.accessSync(f, fs_1.default.F_OK);
89
+ fs_1.default.accessSync(f, fs_1.constants.F_OK);
64
90
  if (mappings) {
65
91
  return keywordReplace(fs_1.default.readFileSync(f, 'utf8'), mappings);
66
92
  }
@@ -76,10 +102,10 @@ function flatten(list) {
76
102
  return list.reduce((a, b) => a.concat(Array.isArray(b) ? flatten(b) : b), []);
77
103
  }
78
104
  exports.flatten = flatten;
79
- function dumpJSON(obj, spacing = 0) {
105
+ function convertJsonToString(obj, spacing = 0) {
80
106
  return JSON.stringify(obj, null, spacing);
81
107
  }
82
- exports.dumpJSON = dumpJSON;
108
+ exports.convertJsonToString = convertJsonToString;
83
109
  function stripFields(obj, fields) {
84
110
  // Strip object fields supporting dot notation (ie: a.deep.field)
85
111
  const stripped = [];
@@ -102,7 +128,7 @@ function getEnabledClients(assets, connection, existing, clients) {
102
128
  const excludedClientsByNames = (assets.exclude && assets.exclude.clients) || [];
103
129
  const excludedClients = convertClientNamesToIds(excludedClientsByNames, clients);
104
130
  const enabledClients = [
105
- ...convertClientNamesToIds(connection.enabled_clients || [], clients).filter((item) => ![...excludedClientsByNames, ...excludedClients].includes(item))
131
+ ...convertClientNamesToIds(connection.enabled_clients || [], clients).filter((item) => ![...excludedClientsByNames, ...excludedClients].includes(item)),
106
132
  ];
107
133
  // If client is excluded and in the existing connection this client is enabled, it should keep enabled
108
134
  // If client is excluded and in the existing connection this client is disabled, it should keep disabled
@@ -142,7 +168,7 @@ function filterExcluded(changes, exclude) {
142
168
  del: filter(del),
143
169
  update: filter(update),
144
170
  create: filter(create),
145
- conflicts: filter(conflicts)
171
+ conflicts: filter(conflicts),
146
172
  };
147
173
  }
148
174
  exports.filterExcluded = filterExcluded;
@@ -150,3 +176,35 @@ function areArraysEquals(x, y) {
150
176
  return lodash_1.default.isEqual(x && x.sort(), y && y.sort());
151
177
  }
152
178
  exports.areArraysEquals = areArraysEquals;
179
+ const obfuscateSensitiveValues = (data, sensitiveFieldsToObfuscate) => {
180
+ if (data === null)
181
+ return data;
182
+ if (Array.isArray(data)) {
183
+ return data.map((asset) => (0, exports.obfuscateSensitiveValues)(asset, sensitiveFieldsToObfuscate));
184
+ }
185
+ const newAsset = Object.assign({}, data);
186
+ sensitiveFieldsToObfuscate.forEach((sensitiveField) => {
187
+ if (dot_prop_1.default.get(newAsset, sensitiveField) !== undefined) {
188
+ dot_prop_1.default.set(newAsset, sensitiveField, constants_1.default.OBFUSCATED_SECRET_VALUE);
189
+ }
190
+ });
191
+ return newAsset;
192
+ };
193
+ exports.obfuscateSensitiveValues = obfuscateSensitiveValues;
194
+ // The reverse of `obfuscateSensitiveValues()`, preventing an obfuscated value from being passed to the API
195
+ const stripObfuscatedFieldsFromPayload = (data, obfuscatedFields) => {
196
+ if (data === null)
197
+ return data;
198
+ if (Array.isArray(data)) {
199
+ return data.map((asset) => (0, exports.stripObfuscatedFieldsFromPayload)(asset, obfuscatedFields));
200
+ }
201
+ const newAsset = Object.assign({}, data);
202
+ obfuscatedFields.forEach((sensitiveField) => {
203
+ const obfuscatedFieldValue = dot_prop_1.default.get(newAsset, sensitiveField);
204
+ if (obfuscatedFieldValue === constants_1.default.OBFUSCATED_SECRET_VALUE) {
205
+ dot_prop_1.default.delete(newAsset, sensitiveField);
206
+ }
207
+ });
208
+ return newAsset;
209
+ };
210
+ exports.stripObfuscatedFieldsFromPayload = stripObfuscatedFieldsFromPayload;
@@ -0,0 +1,5 @@
1
+ declare function ValidationError(message: string): void;
2
+ declare namespace ValidationError {
3
+ var prototype: any;
4
+ }
5
+ export default ValidationError;
@@ -1,3 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  function ValidationError(message) {
2
4
  Error.call(this, message);
3
5
  if (process.env.NODE_ENV !== 'production') {
@@ -9,4 +11,4 @@ function ValidationError(message) {
9
11
  }
10
12
  ValidationError.prototype = Object.create(Error.prototype);
11
13
  ValidationError.prototype.constructor = ValidationError;
12
- module.exports = ValidationError;
14
+ exports.default = ValidationError;
package/lib/types.d.ts ADDED
@@ -0,0 +1,255 @@
1
+ declare type SharedPaginationParams = {
2
+ checkpoint?: boolean;
3
+ paginate?: boolean;
4
+ is_global?: boolean;
5
+ include_totals?: boolean;
6
+ id?: string;
7
+ strategy?: 'auth0';
8
+ };
9
+ export declare type CheckpointPaginationParams = SharedPaginationParams & {
10
+ from: string;
11
+ take: number;
12
+ };
13
+ export declare type PagePaginationParams = SharedPaginationParams & {
14
+ page: number;
15
+ per_page: number;
16
+ };
17
+ declare type APIClientBaseFunctions = {
18
+ getAll: (arg0: SharedPaginationParams) => Promise<Asset[]>;
19
+ create: (arg0: {
20
+ id: string;
21
+ }) => Promise<Asset>;
22
+ update: (arg0: {}, arg1: Asset) => Promise<Asset>;
23
+ delete: (arg0: Asset) => Promise<void>;
24
+ };
25
+ export declare type ApiResponse = {
26
+ start: number;
27
+ limit: number;
28
+ total: number;
29
+ next?: string;
30
+ } & {
31
+ [key in AssetTypes]: Asset[];
32
+ };
33
+ export declare type BaseAuth0APIClient = {
34
+ actions: APIClientBaseFunctions & {
35
+ deploy: ({ id: string }: {
36
+ id: any;
37
+ }) => Promise<void>;
38
+ getAllTriggers: () => Promise<{
39
+ triggers: Asset[];
40
+ }>;
41
+ getTriggerBindings: ({ trigger_id: string }: {
42
+ trigger_id: any;
43
+ }) => Promise<{
44
+ bindings: Asset[];
45
+ }>;
46
+ updateTriggerBindings: ({ trigger_id: string }: {
47
+ trigger_id: any;
48
+ }, { bindings: Object }: {
49
+ bindings: any;
50
+ }) => Promise<{
51
+ bindings: Asset[];
52
+ }>;
53
+ };
54
+ attackProtection: APIClientBaseFunctions & {
55
+ getBreachedPasswordDetectionConfig: () => Promise<Asset>;
56
+ getBruteForceConfig: () => Promise<Asset>;
57
+ getSuspiciousIpThrottlingConfig: () => Promise<Asset>;
58
+ updateBreachedPasswordDetectionConfig: ({}: {}, arg1: Asset) => Promise<void>;
59
+ updateSuspiciousIpThrottlingConfig: ({}: {}, arg1: Asset) => Promise<void>;
60
+ updateBruteForceConfig: ({}: {}, arg1: Asset) => Promise<void>;
61
+ };
62
+ branding: APIClientBaseFunctions & {
63
+ getSettings: () => Promise<Asset>;
64
+ getUniversalLoginTemplate: () => Promise<Asset>;
65
+ updateSettings: ({}: {}, Asset: any) => Promise<void>;
66
+ setUniversalLoginTemplate: ({}: {}, Asset: any) => Promise<void>;
67
+ };
68
+ clients: APIClientBaseFunctions;
69
+ clientGrants: APIClientBaseFunctions;
70
+ connections: APIClientBaseFunctions & {
71
+ get: (arg0: Asset) => Promise<Asset>;
72
+ getAll: (arg0: PagePaginationParams | CheckpointPaginationParams) => Promise<Asset[]>;
73
+ };
74
+ customDomains: APIClientBaseFunctions & {
75
+ getAll: () => Promise<Asset[]>;
76
+ };
77
+ emailProvider: APIClientBaseFunctions & {
78
+ delete: () => Promise<void>;
79
+ get: (arg0: Asset) => Promise<Asset>;
80
+ configure: (arg0: Object, arg1: Object) => Promise<Asset>;
81
+ };
82
+ emailTemplates: APIClientBaseFunctions & {
83
+ get: (arg0: Asset) => Promise<Asset>;
84
+ };
85
+ guardian: APIClientBaseFunctions & {
86
+ getFactorProvider: (arg0: Asset) => Promise<Asset>;
87
+ updateFactorProvider: (arg0: {}, arg1: Asset) => Promise<void>;
88
+ getFactors: () => Promise<Asset[]>;
89
+ updateFactor: (arg0: {}, arg1: Asset) => Promise<void>;
90
+ getPolicies: () => Promise<Asset[]>;
91
+ updatePolicies: (arg0: {}, arg1: Asset) => Promise<void>;
92
+ getFactorTemplates: (arg0: {
93
+ name: string;
94
+ }) => Promise<Asset[]>;
95
+ updateFactorTemplates: (arg0: {}, arg1: Asset) => Promise<void>;
96
+ updatePhoneFactorMessageTypes: (arg0: {}, arg1: Asset) => Promise<void>;
97
+ getPhoneFactorSelectedProvider: () => Promise<Asset[]>;
98
+ getPhoneFactorMessageTypes: () => Promise<Asset[]>;
99
+ updatePhoneFactorSelectedProvider: (arg0: {}, arg1: Asset) => Promise<void>;
100
+ };
101
+ hooks: APIClientBaseFunctions & {
102
+ get: ({ id: string }: {
103
+ id: any;
104
+ }) => Promise<Asset>;
105
+ removeSecrets: (arg0: {}, arg1: Asset) => Promise<void>;
106
+ updateSecrets: (arg0: {}, arg1: Asset) => Promise<void>;
107
+ getSecrets: ({ id: string }: {
108
+ id: any;
109
+ }) => Promise<Promise<Asset[]>>;
110
+ addSecrets: (arg0: {}, arg1: Asset) => Promise<void>;
111
+ };
112
+ migrations: APIClientBaseFunctions & {
113
+ getMigrations: () => Promise<{
114
+ flags: Asset[];
115
+ }>;
116
+ updateMigrations: (arg0: {
117
+ flags: Asset[];
118
+ }) => Promise<void>;
119
+ };
120
+ organizations: APIClientBaseFunctions & {
121
+ updateEnabledConnection: (arg0: {}, arg1: Asset) => Promise<void>;
122
+ addEnabledConnection: (arg0: {}, arg1: Asset) => Promise<void>;
123
+ removeEnabledConnection: (arg0: Asset) => Promise<void>;
124
+ connections: {
125
+ get: (arg0: Asset) => Promise<Asset>;
126
+ };
127
+ };
128
+ prompts: APIClientBaseFunctions & {
129
+ getSettings: () => Promise<Asset[]>;
130
+ updateSettings: (arg0: {}, arg1: Asset) => Promise<void>;
131
+ };
132
+ resourceServers: APIClientBaseFunctions;
133
+ roles: APIClientBaseFunctions & {
134
+ permissions: APIClientBaseFunctions & {
135
+ delete: (arg0: {
136
+ id: string;
137
+ }, arg1: {
138
+ permissions: Asset[];
139
+ }) => Promise<void>;
140
+ create: (arg0: {
141
+ id: string;
142
+ }, arg1: {
143
+ permissions: Asset[];
144
+ }) => Promise<Asset>;
145
+ };
146
+ };
147
+ rules: APIClientBaseFunctions;
148
+ rulesConfigs: APIClientBaseFunctions & {
149
+ getAll: () => Promise<Asset[]>;
150
+ };
151
+ tenant: APIClientBaseFunctions & {
152
+ getSettings: () => Promise<Asset>;
153
+ updateSettings: (arg0: Asset) => Promise<void>;
154
+ };
155
+ triggers: APIClientBaseFunctions & {
156
+ getTriggerBindings: () => Promise<Asset>;
157
+ };
158
+ updateRule: (arg0: {
159
+ id: string;
160
+ }, arg1: Asset) => Promise<Asset>;
161
+ };
162
+ export declare type Auth0APIClient = BaseAuth0APIClient & {
163
+ pool: {
164
+ addSingleTask: (arg0: {
165
+ data: Object;
166
+ generator: any;
167
+ }) => {
168
+ promise: () => Promise<ApiResponse>;
169
+ };
170
+ addEachTask: (arg0: {
171
+ data: Object;
172
+ generator: any;
173
+ }) => {
174
+ promise: () => Promise<Asset[][]>;
175
+ };
176
+ };
177
+ };
178
+ export declare type Config = {
179
+ AUTH0_DOMAIN: string;
180
+ AUTH0_CLIENT_ID: string;
181
+ AUTH0_CLIENT_SECRET: string;
182
+ AUTH0_INPUT_FILE: string;
183
+ AUTH0_ALLOW_DELETE: boolean;
184
+ AUTH0_EXCLUDED: AssetTypes[];
185
+ EXTENSION_SECRET: string;
186
+ AUTH0_ACCESS_TOKEN?: string;
187
+ AUTH0_BASE_PATH?: string;
188
+ AUTH0_AUDIENCE?: string;
189
+ AUTH0_API_MAX_RETRIES?: number;
190
+ AUTH0_KEYWORD_REPLACE_MAPPINGS?: KeywordMappings;
191
+ AUTH0_EXPORT_IDENTIFIERS?: boolean;
192
+ AUTH0_CONNECTIONS_DIRECTORY?: string;
193
+ EXCLUDED_PROPS?: {
194
+ [key: string]: string[];
195
+ };
196
+ INCLUDED_PROPS?: {
197
+ [key: string]: string[];
198
+ };
199
+ AUTH0_IGNORE_UNAVAILABLE_MIGRATIONS?: boolean;
200
+ AUTH0_EXCLUDED_RULES?: string[];
201
+ AUTH0_EXCLUDED_CLIENTS?: string[];
202
+ AUTH0_EXCLUDED_DATABASES?: string[];
203
+ AUTH0_EXCLUDED_CONNECTIONS?: string[];
204
+ AUTH0_EXCLUDED_RESOURCE_SERVERS?: string[];
205
+ AUTH0_EXCLUDED_DEFAULTS?: string[];
206
+ };
207
+ export declare type Asset = {
208
+ [key: string]: any;
209
+ };
210
+ export declare type Assets = {
211
+ actions: Asset[];
212
+ attackProtection: Asset;
213
+ branding: Asset;
214
+ clients: Asset[];
215
+ clientGrants: Asset[];
216
+ connections: Asset[];
217
+ databases: Asset[];
218
+ emailProvider: Asset;
219
+ emailTemplates: Asset[];
220
+ guardianFactorProviders: Asset[];
221
+ guardianFactors: Asset[];
222
+ guardianFactorTemplates: Asset[];
223
+ guardianPhoneFactorMessageTypes: {
224
+ message_types: Asset[];
225
+ };
226
+ guardianPhoneFactorSelectedProvider: Asset;
227
+ guardianPolicies: {
228
+ policies: Asset[];
229
+ };
230
+ hooks: Asset[];
231
+ migrations: Asset[];
232
+ organizations: Asset[];
233
+ pages: Asset[];
234
+ resourceServers: Asset[];
235
+ roles: Asset[];
236
+ rules: Asset[];
237
+ rulesConfigs: Asset[];
238
+ tenant: Asset;
239
+ triggers: Asset[];
240
+ exclude?: {
241
+ [key: string]: string[];
242
+ };
243
+ clientsOrig: Asset[];
244
+ };
245
+ export declare type CalculatedChanges = {
246
+ del: Asset[];
247
+ update: Asset[];
248
+ conflicts: Asset[];
249
+ create: Asset[];
250
+ };
251
+ export declare type AssetTypes = 'rules' | 'rulesConfigs' | 'hooks' | 'pages' | 'databases' | 'clientGrants' | 'resourceServers' | 'clients' | 'connections' | 'tenant' | 'emailProvider' | 'emailTemplates' | 'guardianFactors' | 'guardianFactorProviders' | 'guardianFactorTemplates' | 'migrations' | 'guardianPhoneFactorMessageTypes' | 'guardianPhoneFactorSelectedProvider' | 'guardianPolicies' | 'roles' | 'actions' | 'organizations' | 'triggers' | 'attackProtection' | 'branding';
252
+ export declare type KeywordMappings = {
253
+ [key: string]: (string | number)[] | string | number;
254
+ };
255
+ export {};
package/lib/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/lib/utils.d.ts ADDED
@@ -0,0 +1,66 @@
1
+ import { Auth0 } from './tools';
2
+ import { Asset, Assets, Config, KeywordMappings } from './types';
3
+ export declare function isDirectory(filePath: string): boolean;
4
+ export declare function isFile(filePath: string): boolean;
5
+ export declare function getFiles(folder: string, exts: string[]): string[];
6
+ export declare function loadJSON(file: string, mappings: KeywordMappings): any;
7
+ export declare function dumpJSON(file: string, mappings: {
8
+ [key: string]: any;
9
+ }): void;
10
+ export declare function existsMustBeDir(folder: string): boolean;
11
+ export declare function toConfigFn(data: Config): (arg0: keyof Config) => any;
12
+ export declare function stripIdentifiers(auth0: Auth0, assets: Assets): {
13
+ actions: Asset[];
14
+ attackProtection: Asset;
15
+ branding: Asset;
16
+ clients: Asset[];
17
+ clientGrants: Asset[];
18
+ connections: Asset[];
19
+ databases: Asset[];
20
+ emailProvider: Asset;
21
+ emailTemplates: Asset[];
22
+ guardianFactorProviders: Asset[];
23
+ guardianFactors: Asset[];
24
+ guardianFactorTemplates: Asset[];
25
+ guardianPhoneFactorMessageTypes: {
26
+ message_types: Asset[];
27
+ };
28
+ guardianPhoneFactorSelectedProvider: Asset;
29
+ guardianPolicies: {
30
+ policies: Asset[];
31
+ };
32
+ hooks: Asset[];
33
+ migrations: Asset[];
34
+ organizations: Asset[];
35
+ pages: Asset[];
36
+ resourceServers: Asset[];
37
+ roles: Asset[];
38
+ rules: Asset[];
39
+ rulesConfigs: Asset[];
40
+ tenant: Asset;
41
+ triggers: Asset[];
42
+ exclude?: {
43
+ [key: string]: string[];
44
+ } | undefined;
45
+ clientsOrig: Asset[];
46
+ };
47
+ export declare function sanitize(str: string): string;
48
+ declare type ImportantFields = {
49
+ name: string | null;
50
+ client_id: string | null;
51
+ audience: string | null;
52
+ template: string | null;
53
+ identifier: string | null;
54
+ strategy: string | null;
55
+ script: string | null;
56
+ stage: string | null;
57
+ id: string | null;
58
+ };
59
+ export declare function formatResults(item: any): Partial<ImportantFields>;
60
+ export declare function recordsSorter(a: Partial<ImportantFields>, b: Partial<ImportantFields>): number;
61
+ export declare function clearTenantFlags(tenant: Asset): void;
62
+ export declare function ensureProp(obj: Asset, props: string): void;
63
+ export declare function clearClientArrays(client: Asset): Asset;
64
+ export declare function convertClientIdToName(clientId: string, knownClients?: Asset[]): string;
65
+ export declare function mapClientID2NameSorted(enabledClients: string[], knownClients: Asset[]): string[];
66
+ export {};