auth0-deploy-cli 8.30.0 → 8.32.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 (82) hide show
  1. package/.circleci/config.yml +17 -5
  2. package/AGENTS.md +21 -1
  3. package/CHANGELOG.md +48 -415
  4. package/CLAUDE.md +3 -0
  5. package/lib/args.d.ts +5 -0
  6. package/lib/args.js +23 -0
  7. package/lib/commands/export.js +5 -1
  8. package/lib/commands/import.js +40 -3
  9. package/lib/context/directory/handlers/actions.js +1 -2
  10. package/lib/context/directory/handlers/clients.js +14 -0
  11. package/lib/context/directory/handlers/connections.js +1 -0
  12. package/lib/context/directory/handlers/guardianFactors.js +8 -6
  13. package/lib/context/directory/handlers/tenant.d.ts +1 -6
  14. package/lib/context/directory/handlers/tenant.js +0 -1
  15. package/lib/context/directory/handlers/triggers.js +1 -3
  16. package/lib/context/index.js +5 -0
  17. package/lib/context/yaml/handlers/clients.js +12 -0
  18. package/lib/context/yaml/handlers/connections.js +1 -17
  19. package/lib/context/yaml/handlers/guardianFactors.js +3 -1
  20. package/lib/context/yaml/handlers/tenant.js +1 -1
  21. package/lib/context/yaml/index.js +2 -1
  22. package/lib/sessionDurationsToMinutes.d.ts +9 -7
  23. package/lib/sessionDurationsToMinutes.js +11 -10
  24. package/lib/tools/auth0/handlers/actions.d.ts +1 -0
  25. package/lib/tools/auth0/handlers/actions.js +36 -0
  26. package/lib/tools/auth0/handlers/attackProtection.js +15 -0
  27. package/lib/tools/auth0/handlers/branding.js +7 -0
  28. package/lib/tools/auth0/handlers/clientGrants.js +32 -4
  29. package/lib/tools/auth0/handlers/clients.d.ts +52 -2
  30. package/lib/tools/auth0/handlers/clients.js +175 -22
  31. package/lib/tools/auth0/handlers/connections.d.ts +1 -1
  32. package/lib/tools/auth0/handlers/connections.js +42 -6
  33. package/lib/tools/auth0/handlers/customDomains.d.ts +5 -0
  34. package/lib/tools/auth0/handlers/customDomains.js +26 -0
  35. package/lib/tools/auth0/handlers/databases.d.ts +91 -0
  36. package/lib/tools/auth0/handlers/databases.js +162 -2
  37. package/lib/tools/auth0/handlers/default.d.ts +4 -0
  38. package/lib/tools/auth0/handlers/default.js +82 -4
  39. package/lib/tools/auth0/handlers/emailProvider.js +8 -0
  40. package/lib/tools/auth0/handlers/emailTemplates.js +7 -0
  41. package/lib/tools/auth0/handlers/flowVaultConnections.js +6 -1
  42. package/lib/tools/auth0/handlers/flows.js +13 -4
  43. package/lib/tools/auth0/handlers/forms.js +10 -1
  44. package/lib/tools/auth0/handlers/guardianFactors.js +7 -1
  45. package/lib/tools/auth0/handlers/guardianPhoneFactorMessageTypes.js +8 -1
  46. package/lib/tools/auth0/handlers/guardianPhoneFactorSelectedProvider.js +8 -1
  47. package/lib/tools/auth0/handlers/guardianPolicies.js +7 -0
  48. package/lib/tools/auth0/handlers/hooks.d.ts +1 -0
  49. package/lib/tools/auth0/handlers/hooks.js +10 -0
  50. package/lib/tools/auth0/handlers/organizations.d.ts +11 -1
  51. package/lib/tools/auth0/handlers/organizations.js +48 -52
  52. package/lib/tools/auth0/handlers/pages.js +7 -0
  53. package/lib/tools/auth0/handlers/phoneProvider.js +7 -0
  54. package/lib/tools/auth0/handlers/prompts.js +7 -0
  55. package/lib/tools/auth0/handlers/resourceServers.d.ts +1 -2
  56. package/lib/tools/auth0/handlers/resourceServers.js +9 -25
  57. package/lib/tools/auth0/handlers/roles.js +7 -0
  58. package/lib/tools/auth0/handlers/rules.d.ts +1 -0
  59. package/lib/tools/auth0/handlers/rules.js +9 -0
  60. package/lib/tools/auth0/handlers/rulesConfigs.d.ts +1 -0
  61. package/lib/tools/auth0/handlers/rulesConfigs.js +3 -0
  62. package/lib/tools/auth0/handlers/scimHandler.js +8 -1
  63. package/lib/tools/auth0/handlers/selfServiceProfiles.d.ts +1 -1
  64. package/lib/tools/auth0/handlers/selfServiceProfiles.js +10 -17
  65. package/lib/tools/auth0/handlers/tenant.d.ts +13 -1
  66. package/lib/tools/auth0/handlers/tenant.js +48 -4
  67. package/lib/tools/auth0/handlers/themes.js +11 -2
  68. package/lib/tools/auth0/handlers/triggers.js +6 -0
  69. package/lib/tools/auth0/handlers/userAttributeProfiles.js +16 -10
  70. package/lib/tools/auth0/index.d.ts +3 -0
  71. package/lib/tools/auth0/index.js +204 -0
  72. package/lib/tools/calculateChanges.d.ts +2 -2
  73. package/lib/tools/calculateChanges.js +21 -6
  74. package/lib/tools/calculateDryRunChanges.d.ts +71 -0
  75. package/lib/tools/calculateDryRunChanges.js +492 -0
  76. package/lib/tools/deploy.js +25 -1
  77. package/lib/tools/utils.d.ts +5 -0
  78. package/lib/tools/utils.js +64 -3
  79. package/lib/types.d.ts +17 -0
  80. package/lib/utils.d.ts +7 -0
  81. package/lib/utils.js +46 -2
  82. package/package.json +10 -6
package/lib/types.d.ts CHANGED
@@ -71,7 +71,11 @@ export type Config = {
71
71
  AUTH0_RETRY_MAX_DELAY_MS?: number;
72
72
  AUTH0_KEYWORD_REPLACE_MAPPINGS?: KeywordMappings;
73
73
  AUTH0_EXPORT_IDENTIFIERS?: boolean;
74
+ AUTH0_EXPORT_ORDERED?: boolean;
74
75
  AUTH0_CONNECTIONS_DIRECTORY?: string;
76
+ AUTH0_DRY_RUN?: boolean | 'preview';
77
+ AUTH0_DRY_RUN_INTERACTIVE?: boolean;
78
+ AUTH0_DRY_RUN_APPLY?: boolean;
75
79
  EXCLUDED_PROPS?: {
76
80
  [key: string]: string[];
77
81
  };
@@ -157,6 +161,19 @@ export type CalculatedChanges = {
157
161
  conflicts: Asset[];
158
162
  create: Asset[];
159
163
  };
164
+ export type DetailedDryRunChange = {
165
+ action: 'CREATE' | 'UPDATE' | 'DELETE';
166
+ identifier: string;
167
+ details?: any;
168
+ };
169
+ export type DetailedDryRunChanges = {
170
+ [key: string]: {
171
+ created: number;
172
+ updated: number;
173
+ deleted: number;
174
+ changes: DetailedDryRunChange[];
175
+ };
176
+ };
160
177
  export type AssetTypes = 'rules' | 'rulesConfigs' | 'hooks' | 'pages' | 'databases' | 'clientGrants' | 'resourceServers' | 'clients' | 'connections' | 'tenant' | 'emailProvider' | 'emailTemplates' | 'guardianFactors' | 'guardianFactorProviders' | 'guardianFactorTemplates' | 'guardianPhoneFactorMessageTypes' | 'guardianPhoneFactorSelectedProvider' | 'guardianPolicies' | 'roles' | 'actions' | 'actionModules' | 'organizations' | 'triggers' | 'attackProtection' | 'riskAssessment' | 'branding' | 'phoneProviders' | 'phoneTemplates' | 'logStreams' | 'prompts' | 'customDomains' | 'themes' | 'forms' | 'flows' | 'flowVaultConnections' | 'selfServiceProfiles' | 'networkACLs' | 'userAttributeProfiles' | 'connectionProfiles' | 'tokenExchangeProfiles' | 'supplementalSignals';
161
178
  export type KeywordMappings = {
162
179
  [key: string]: (string | number)[] | string | number;
package/lib/utils.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Auth0 } from './tools';
2
2
  import { Asset, Assets, Config, KeywordMappings } from './types';
3
+ export declare function isTruthy(value: unknown): boolean;
3
4
  export declare function isDirectory(filePath: string): boolean;
4
5
  export declare function isFile(filePath: string): boolean;
5
6
  export declare function getFiles(folder: string, exts: string[]): string[];
@@ -45,4 +46,10 @@ export declare const findKeyPathWithValue: (obj: any, findKey: string, parentPat
45
46
  * @returns The Base64 encoded certificate string if the input starts with '-----BEGIN CERTIFICATE-----', otherwise returns the original string.
46
47
  */
47
48
  export declare const encodeCertStringToBase64: (cert: string) => string;
49
+ export declare const decodeBase64ToCertString: (base64Cert: string) => string;
50
+ export declare const getFormattedOptions: (connection: any, clients: any) => {
51
+ options: any;
52
+ } | {
53
+ options?: undefined;
54
+ };
48
55
  export {};
package/lib/utils.js CHANGED
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.encodeCertStringToBase64 = exports.findKeyPathWithValue = void 0;
6
+ exports.getFormattedOptions = exports.decodeBase64ToCertString = exports.encodeCertStringToBase64 = exports.findKeyPathWithValue = void 0;
7
+ exports.isTruthy = isTruthy;
7
8
  exports.isDirectory = isDirectory;
8
9
  exports.isFile = isFile;
9
10
  exports.getFiles = getFiles;
@@ -24,11 +25,15 @@ exports.mapClientID2NameSorted = mapClientID2NameSorted;
24
25
  exports.nomalizedYAMLPath = nomalizedYAMLPath;
25
26
  const path_1 = __importDefault(require("path"));
26
27
  const fs_extra_1 = __importDefault(require("fs-extra"));
28
+ const nconf_1 = __importDefault(require("nconf"));
27
29
  const sanitize_filename_1 = __importDefault(require("sanitize-filename"));
28
30
  const dot_prop_1 = __importDefault(require("dot-prop"));
29
31
  const lodash_1 = require("lodash");
30
32
  const tools_1 = require("./tools");
31
33
  const logger_1 = __importDefault(require("./logger"));
34
+ function isTruthy(value) {
35
+ return value === true || value === 'true';
36
+ }
32
37
  function isDirectory(filePath) {
33
38
  try {
34
39
  return fs_extra_1.default.statSync(path_1.default.resolve(filePath)).isDirectory();
@@ -69,10 +74,21 @@ function loadJSON(file, opts = {
69
74
  throw new Error(`Error parsing JSON from metadata file: ${file}, because: ${e.message}`);
70
75
  }
71
76
  }
77
+ function orderedKeysReplacer(_key, value) {
78
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
79
+ const obj = value;
80
+ return Object.fromEntries(Object.keys(obj)
81
+ .sort()
82
+ .map((k) => [k, obj[k]]));
83
+ }
84
+ return value;
85
+ }
72
86
  function dumpJSON(file, mappings) {
73
87
  try {
74
88
  logger_1.default.info(`Writing ${file}`);
75
- const jsonBody = JSON.stringify(mappings, null, 2);
89
+ const exportOrdered = Boolean(nconf_1.default.get('AUTH0_EXPORT_ORDERED'));
90
+ const replacer = exportOrdered ? orderedKeysReplacer : undefined;
91
+ const jsonBody = JSON.stringify(mappings, replacer, 2);
76
92
  fs_extra_1.default.writeFileSync(file, jsonBody.endsWith('\n') ? jsonBody : `${jsonBody}\n`);
77
93
  }
78
94
  catch (e) {
@@ -272,3 +288,31 @@ const encodeCertStringToBase64 = (cert) => {
272
288
  return cert;
273
289
  };
274
290
  exports.encodeCertStringToBase64 = encodeCertStringToBase64;
291
+ // Decode a Base64 encoded certificate string back to its original format.
292
+ const decodeBase64ToCertString = (base64Cert) => {
293
+ try {
294
+ return Buffer.from(base64Cert, 'base64').toString('utf-8');
295
+ }
296
+ catch (e) {
297
+ return base64Cert;
298
+ }
299
+ };
300
+ exports.decodeBase64ToCertString = decodeBase64ToCertString;
301
+ // Format connection options by converting client IDs to client names for SAML connections
302
+ const getFormattedOptions = (connection, clients) => {
303
+ try {
304
+ return {
305
+ options: {
306
+ ...connection.options,
307
+ idpinitiated: {
308
+ ...connection.options.idpinitiated,
309
+ client_id: convertClientIdToName(connection.options.idpinitiated.client_id, clients),
310
+ },
311
+ },
312
+ };
313
+ }
314
+ catch (e) {
315
+ return {};
316
+ }
317
+ };
318
+ exports.getFormattedOptions = getFormattedOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auth0-deploy-cli",
3
- "version": "8.30.0",
3
+ "version": "8.32.0",
4
4
  "description": "A command line tool for deploying updates to your Auth0 tenant",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
@@ -9,6 +9,7 @@
9
9
  "scripts": {
10
10
  "lint:fix": "eslint --fix . && kacl lint",
11
11
  "lint": "eslint . && kacl lint",
12
+ "format:check": "npx prettier --check .",
12
13
  "format": "npx prettier --write .",
13
14
  "test": "ts-mocha -p tsconfig.json --recursive 'test/**/*.test*' --exclude 'test/e2e/*' --timeout 20000",
14
15
  "test:e2e:node-module": "ts-mocha -p tsconfig.json --recursive 'test/e2e/*.test*' --timeout 150000",
@@ -32,28 +33,31 @@
32
33
  "readme": "README.md",
33
34
  "homepage": "https://github.com/auth0/auth0-deploy-cli#readme",
34
35
  "dependencies": {
36
+ "@clack/prompts": "1.2.0",
35
37
  "ajv": "^6.12.6",
36
- "auth0": "^5.5.0",
38
+ "chalk": "5.6.2",
39
+ "auth0": "^5.8.0",
37
40
  "dot-prop": "^5.3.0",
38
41
  "fs-extra": "^10.1.0",
39
42
  "js-yaml": "^4.1.1",
40
- "lodash": "^4.17.23",
43
+ "lodash": "^4.18.1",
41
44
  "mkdirp": "^1.0.4",
42
45
  "nconf": "^0.13.0",
43
46
  "promise-pool-executor": "^1.1.1",
44
- "sanitize-filename": "^1.6.3",
47
+ "sanitize-filename": "^1.6.4",
45
48
  "undici": "^7.24.3",
46
49
  "winston": "^3.19.0",
47
50
  "yargs": "^15.4.1"
48
51
  },
49
52
  "devDependencies": {
50
53
  "@eslint/js": "^9.39.2",
54
+ "@types/chai": "^5.2.3",
51
55
  "@types/fs-extra": "^9.0.13",
52
56
  "@types/lodash": "^4.17.24",
53
57
  "@types/mocha": "^10.0.10",
54
58
  "@types/nconf": "^0.10.7",
55
- "@typescript-eslint/eslint-plugin": "^8.57.0",
56
- "@typescript-eslint/parser": "^8.57.0",
59
+ "@typescript-eslint/eslint-plugin": "^8.58.1",
60
+ "@typescript-eslint/parser": "^8.58.1",
57
61
  "chai": "^4.5.0",
58
62
  "chai-as-promised": "^7.1.2",
59
63
  "eslint": "^9.39.2",