auth0-deploy-cli 7.6.0 → 7.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +7 -41
- package/.husky/pre-commit +4 -0
- package/.husky/pre-push +3 -1
- package/.prettierignore +10 -0
- package/.prettierrc.json +4 -0
- package/CHANGELOG.md +194 -7
- package/CONTRIBUTING.md +2 -2
- package/README.md +3 -0
- package/lib/args.js +16 -15
- package/lib/commands/export.js +3 -3
- package/lib/commands/import.js +6 -6
- package/lib/commands/index.js +1 -1
- package/lib/configFactory.js +5 -1
- package/lib/context/defaults.js +4 -3
- package/lib/context/directory/handlers/actions.js +3 -3
- package/lib/context/directory/handlers/attackProtection.js +4 -4
- package/lib/context/directory/handlers/branding.js +6 -5
- package/lib/context/directory/handlers/clientGrants.js +3 -2
- package/lib/context/directory/handlers/clients.js +1 -1
- package/lib/context/directory/handlers/connections.js +4 -2
- package/lib/context/directory/handlers/databases.js +13 -7
- package/lib/context/directory/handlers/emailProvider.js +3 -2
- package/lib/context/directory/handlers/emailTemplates.js +2 -2
- package/lib/context/directory/handlers/guardianFactorProviders.js +3 -2
- package/lib/context/directory/handlers/guardianFactorTemplates.js +3 -2
- package/lib/context/directory/handlers/guardianFactors.js +3 -2
- package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.js +1 -1
- package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.js +1 -1
- package/lib/context/directory/handlers/guardianPolicies.js +1 -1
- package/lib/context/directory/handlers/hooks.js +2 -2
- package/lib/context/directory/handlers/index.js +3 -2
- package/lib/context/directory/handlers/organizations.js +1 -1
- package/lib/context/directory/handlers/pages.js +2 -2
- package/lib/context/directory/handlers/resourceServers.js +3 -2
- package/lib/context/directory/handlers/roles.js +1 -1
- package/lib/context/directory/handlers/rules.js +2 -2
- package/lib/context/directory/handlers/rulesConfigs.js +3 -2
- package/lib/context/directory/handlers/tenant.js +3 -2
- package/lib/context/directory/index.js +21 -18
- package/lib/context/index.js +66 -62
- package/lib/context/yaml/handlers/actions.js +9 -6
- package/lib/context/yaml/handlers/attackProtection.js +1 -1
- package/lib/context/yaml/handlers/branding.js +5 -4
- package/lib/context/yaml/handlers/clientGrants.js +2 -2
- package/lib/context/yaml/handlers/clients.js +6 -4
- package/lib/context/yaml/handlers/connections.js +7 -5
- package/lib/context/yaml/handlers/databases.js +12 -8
- package/lib/context/yaml/handlers/emailProvider.js +4 -3
- package/lib/context/yaml/handlers/emailTemplates.js +3 -3
- package/lib/context/yaml/handlers/guardianFactorProviders.js +1 -1
- package/lib/context/yaml/handlers/guardianFactorTemplates.js +1 -1
- package/lib/context/yaml/handlers/guardianFactors.js +1 -1
- package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.js +1 -1
- package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.js +1 -1
- package/lib/context/yaml/handlers/guardianPolicies.js +1 -1
- package/lib/context/yaml/handlers/hooks.js +4 -3
- package/lib/context/yaml/handlers/index.js +3 -2
- package/lib/context/yaml/handlers/organizations.js +3 -3
- package/lib/context/yaml/handlers/pages.js +3 -3
- package/lib/context/yaml/handlers/resourceServers.js +2 -2
- package/lib/context/yaml/handlers/roles.js +3 -3
- package/lib/context/yaml/handlers/rules.js +3 -3
- package/lib/context/yaml/handlers/rulesConfigs.js +2 -2
- package/lib/context/yaml/handlers/tenant.js +4 -3
- package/lib/context/yaml/handlers/triggers.js +2 -2
- package/lib/context/yaml/index.js +31 -23
- package/lib/index.js +20 -15
- package/lib/logger.js +4 -3
- package/lib/readonly.js +11 -16
- package/lib/sessionDurationsToMinutes.js +15 -0
- package/lib/tools/auth0/client.js +6 -6
- package/lib/tools/auth0/handlers/actions.js +21 -23
- package/lib/tools/auth0/handlers/attackProtection.js +14 -17
- package/lib/tools/auth0/handlers/branding.js +13 -9
- package/lib/tools/auth0/handlers/clientGrants.js +17 -10
- package/lib/tools/auth0/handlers/clients.js +15 -8
- package/lib/tools/auth0/handlers/connections.js +30 -10
- package/lib/tools/auth0/handlers/databases.js +24 -12
- package/lib/tools/auth0/handlers/default.js +41 -29
- package/lib/tools/auth0/handlers/emailTemplates.js +8 -10
- package/lib/tools/auth0/handlers/guardianFactorProviders.js +3 -3
- package/lib/tools/auth0/handlers/guardianFactorTemplates.js +3 -3
- package/lib/tools/auth0/handlers/guardianFactors.js +3 -3
- package/lib/tools/auth0/handlers/guardianPhoneFactorMessageTypes.js +11 -10
- package/lib/tools/auth0/handlers/guardianPhoneFactorSelectedProvider.js +10 -9
- package/lib/tools/auth0/handlers/guardianPolicies.js +5 -4
- package/lib/tools/auth0/handlers/hooks.js +34 -21
- package/lib/tools/auth0/handlers/index.js +31 -27
- package/lib/tools/auth0/handlers/migrations.js +2 -1
- package/lib/tools/auth0/handlers/organizations.js +61 -31
- package/lib/tools/auth0/handlers/pages.js +20 -14
- package/lib/tools/auth0/handlers/prompts.js +1 -0
- package/lib/tools/auth0/handlers/resourceServers.js +22 -14
- package/lib/tools/auth0/handlers/roles.js +55 -31
- package/lib/tools/auth0/handlers/rules.js +49 -32
- package/lib/tools/auth0/handlers/rulesConfigs.js +12 -6
- package/lib/tools/auth0/handlers/tenant.js +8 -4
- package/lib/tools/auth0/handlers/triggers.js +11 -12
- package/lib/tools/auth0/index.js +15 -31
- package/lib/tools/auth0/schema.js +7 -27
- package/lib/tools/calculateChanges.js +11 -6
- package/lib/tools/constants.js +162 -161
- package/lib/tools/deploy.js +1 -1
- package/lib/tools/index.js +1 -1
- package/lib/tools/logger.js +14 -8
- package/lib/tools/utils.js +2 -2
- package/lib/tools/{ValidationError.js → validationError.js} +3 -1
- package/lib/types.js +2 -0
- package/lib/utils.js +12 -22
- package/package.json +8 -1
- package/tsconfig.json +1 -3
- package/typescript-migration-progress.sh +1 -1
package/lib/args.js
CHANGED
|
@@ -13,71 +13,71 @@ function getParams() {
|
|
|
13
13
|
alias: 'd',
|
|
14
14
|
describe: 'Dump extra debug information.',
|
|
15
15
|
type: 'boolean',
|
|
16
|
-
default: false
|
|
16
|
+
default: false,
|
|
17
17
|
})
|
|
18
18
|
.option('proxy_url', {
|
|
19
19
|
alias: 'p',
|
|
20
20
|
describe: 'A url for proxying requests, only set this if you are behind a proxy.',
|
|
21
|
-
type: 'string'
|
|
21
|
+
type: 'string',
|
|
22
22
|
})
|
|
23
23
|
.command(['import', 'deploy'], 'Deploy Configuration', {
|
|
24
24
|
input_file: {
|
|
25
25
|
alias: 'i',
|
|
26
26
|
describe: 'The updates to deploy. Either a JSON file, or directory that contains the correct file layout. See README and online for more info.',
|
|
27
27
|
type: 'string',
|
|
28
|
-
demandOption: true
|
|
28
|
+
demandOption: true,
|
|
29
29
|
},
|
|
30
30
|
config_file: {
|
|
31
31
|
alias: 'c',
|
|
32
32
|
describe: 'The JSON configuration file.',
|
|
33
|
-
type: 'string'
|
|
33
|
+
type: 'string',
|
|
34
34
|
},
|
|
35
35
|
env: {
|
|
36
36
|
describe: 'Override the mappings in config with environment variables.',
|
|
37
37
|
boolean: true,
|
|
38
|
-
default: true
|
|
38
|
+
default: true,
|
|
39
39
|
},
|
|
40
40
|
secret: {
|
|
41
41
|
alias: 'x',
|
|
42
42
|
describe: 'The client secret, this allows you to encrypt the secret in your build configuration instead of storing it in a config file',
|
|
43
|
-
type: 'string'
|
|
44
|
-
}
|
|
43
|
+
type: 'string',
|
|
44
|
+
},
|
|
45
45
|
})
|
|
46
46
|
.command(['export', 'dump'], 'Export Auth0 Tenant Configuration', {
|
|
47
47
|
output_folder: {
|
|
48
48
|
alias: 'o',
|
|
49
49
|
describe: 'The output directory.',
|
|
50
50
|
type: 'string',
|
|
51
|
-
demandOption: true
|
|
51
|
+
demandOption: true,
|
|
52
52
|
},
|
|
53
53
|
format: {
|
|
54
54
|
alias: 'f',
|
|
55
55
|
describe: 'The output format.',
|
|
56
56
|
type: 'string',
|
|
57
57
|
choices: ['yaml', 'directory'],
|
|
58
|
-
demandOption: true
|
|
58
|
+
demandOption: true,
|
|
59
59
|
},
|
|
60
60
|
config_file: {
|
|
61
61
|
alias: 'c',
|
|
62
62
|
describe: 'The JSON configuration file.',
|
|
63
|
-
type: 'string'
|
|
63
|
+
type: 'string',
|
|
64
64
|
},
|
|
65
65
|
secret: {
|
|
66
66
|
alias: 'x',
|
|
67
67
|
describe: 'The client secret, this allows you to encrypt the secret in your build configuration instead of storing it in a config file',
|
|
68
|
-
type: 'string'
|
|
68
|
+
type: 'string',
|
|
69
69
|
},
|
|
70
70
|
env: {
|
|
71
71
|
describe: 'Override the mappings in config with environment variables.',
|
|
72
72
|
boolean: true,
|
|
73
|
-
default: false
|
|
73
|
+
default: false,
|
|
74
74
|
},
|
|
75
75
|
export_ids: {
|
|
76
76
|
alias: 'e',
|
|
77
77
|
describe: 'Export identifier field for each object type.',
|
|
78
78
|
type: 'boolean',
|
|
79
|
-
default: false
|
|
80
|
-
}
|
|
79
|
+
default: false,
|
|
80
|
+
},
|
|
81
81
|
})
|
|
82
82
|
.example('$0 export -c config.json -f yaml -o path/to/export', 'Dump Auth0 config to folder in YAML format')
|
|
83
83
|
.example('$0 export -c config.json -f directory -o path/to/export', 'Dump Auth0 config to folder in directory format')
|
|
@@ -89,9 +89,10 @@ function getParams() {
|
|
|
89
89
|
.example('$0 deploy -c config.json -i path/to/files', 'Deploy Auth0 via Path')
|
|
90
90
|
.epilogue('See README (https://github.com/auth0/auth0-deploy-cli) for more in-depth information on configuration and setup.')
|
|
91
91
|
.wrap(null);
|
|
92
|
+
//@ts-ignore because we know these types are either ExportParams or ImportParams. TODO: fix more native way of inferring types from yargs
|
|
92
93
|
return args.argv;
|
|
93
94
|
}
|
|
94
95
|
exports.getParams = getParams;
|
|
95
96
|
exports.default = {
|
|
96
|
-
getParams
|
|
97
|
+
getParams,
|
|
97
98
|
};
|
package/lib/commands/export.js
CHANGED
|
@@ -17,7 +17,7 @@ const nconf_1 = __importDefault(require("nconf"));
|
|
|
17
17
|
const mkdirp_1 = __importDefault(require("mkdirp"));
|
|
18
18
|
const logger_1 = __importDefault(require("../logger"));
|
|
19
19
|
const utils_1 = require("../utils");
|
|
20
|
-
const
|
|
20
|
+
const index_1 = require("../context/index");
|
|
21
21
|
function exportCMD(params) {
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
23
|
const { output_folder: outputFolder, base_path: basePath, config_file: configFile, config: configObj, export_ids: exportIds, secret: clientSecret, env: shouldInheritEnv = false, } = params;
|
|
@@ -27,7 +27,7 @@ function exportCMD(params) {
|
|
|
27
27
|
if (configFile) {
|
|
28
28
|
nconf_1.default.file(configFile);
|
|
29
29
|
}
|
|
30
|
-
const overrides = Object.assign({ AUTH0_INPUT_FILE: outputFolder, AUTH0_BASE_PATH: basePath
|
|
30
|
+
const overrides = Object.assign({ AUTH0_INPUT_FILE: outputFolder, AUTH0_BASE_PATH: basePath }, (configObj || {}));
|
|
31
31
|
// Prepare configuration by initializing nconf, then passing that as the provider to the config object
|
|
32
32
|
// Allow passed in secret to override the configured one
|
|
33
33
|
if (clientSecret) {
|
|
@@ -47,7 +47,7 @@ function exportCMD(params) {
|
|
|
47
47
|
}
|
|
48
48
|
nconf_1.default.overrides(overrides);
|
|
49
49
|
// Setup context and load
|
|
50
|
-
const context = yield (0,
|
|
50
|
+
const context = yield (0, index_1.setupContext)(nconf_1.default.get());
|
|
51
51
|
yield context.dump();
|
|
52
52
|
logger_1.default.info('Export Successful');
|
|
53
53
|
});
|
package/lib/commands/import.js
CHANGED
|
@@ -13,13 +13,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const nconf_1 = __importDefault(require("nconf"));
|
|
16
|
-
const configFactory_1 =
|
|
16
|
+
const configFactory_1 = require("../configFactory");
|
|
17
17
|
const tools_1 = require("../tools");
|
|
18
18
|
const logger_1 = __importDefault(require("../logger"));
|
|
19
|
-
const context_1 =
|
|
19
|
+
const context_1 = require("../context");
|
|
20
20
|
function importCMD(params) {
|
|
21
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
const { input_file: inputFile, base_path: basePath, config_file: configFile, config: configObj, env: shouldInheritEnv = false, secret: clientSecret } = params;
|
|
22
|
+
const { input_file: inputFile, base_path: basePath, config_file: configFile, config: configObj, env: shouldInheritEnv = false, secret: clientSecret, } = params;
|
|
23
23
|
if (shouldInheritEnv) {
|
|
24
24
|
nconf_1.default.env().use('memory');
|
|
25
25
|
const mappings = nconf_1.default.get('AUTH0_KEYWORD_REPLACE_MAPPINGS') || {};
|
|
@@ -28,7 +28,7 @@ function importCMD(params) {
|
|
|
28
28
|
if (configFile) {
|
|
29
29
|
nconf_1.default.file(configFile);
|
|
30
30
|
}
|
|
31
|
-
const overrides = Object.assign({ AUTH0_INPUT_FILE: inputFile, AUTH0_BASE_PATH: basePath,
|
|
31
|
+
const overrides = Object.assign({ AUTH0_INPUT_FILE: inputFile, AUTH0_BASE_PATH: basePath, AUTH0_KEYWORD_REPLACE_MAPPINGS: {} }, (configObj || {}));
|
|
32
32
|
// Prepare configuration by initializing nconf, then passing that as the provider to the config object
|
|
33
33
|
// Allow passed in secret to override the configured one
|
|
34
34
|
if (clientSecret) {
|
|
@@ -36,9 +36,9 @@ function importCMD(params) {
|
|
|
36
36
|
}
|
|
37
37
|
nconf_1.default.overrides(overrides);
|
|
38
38
|
// Setup context and load
|
|
39
|
-
const context = yield (0, context_1.
|
|
39
|
+
const context = yield (0, context_1.setupContext)(nconf_1.default.get());
|
|
40
40
|
yield context.load();
|
|
41
|
-
const config = (0, configFactory_1.
|
|
41
|
+
const config = (0, configFactory_1.configFactory)();
|
|
42
42
|
config.setProvider((key) => nconf_1.default.get(key));
|
|
43
43
|
//@ts-ignore because context and assets still need to be typed TODO: type assets and type context
|
|
44
44
|
yield (0, tools_1.deploy)(context.assets, context.mgmtClient, config);
|
package/lib/commands/index.js
CHANGED
package/lib/configFactory.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.configFactory = void 0;
|
|
4
|
+
const configFactory = () => {
|
|
2
5
|
const settings = {};
|
|
3
6
|
let currentProvider = null;
|
|
4
7
|
const config = function getConfig(key) {
|
|
@@ -18,3 +21,4 @@ module.exports = function () {
|
|
|
18
21
|
};
|
|
19
22
|
return config;
|
|
20
23
|
};
|
|
24
|
+
exports.configFactory = configFactory;
|
package/lib/context/defaults.js
CHANGED
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.emailProviderDefaults = void 0;
|
|
4
4
|
function emailProviderDefaults(emailProvider) {
|
|
5
|
+
// eslint-disable-line
|
|
5
6
|
const updated = Object.assign({}, emailProvider);
|
|
6
7
|
const apiKeyProviders = ['mailgun', 'mandrill', 'sendgrid', 'sparkpost'];
|
|
7
8
|
// Add placeholder for credentials as they cannot be exported
|
|
8
9
|
const { name } = updated;
|
|
9
10
|
if (apiKeyProviders.includes(name)) {
|
|
10
|
-
updated.credentials = Object.assign({ api_key: `##${name.toUpperCase()}_API_KEY##` }, updated.credentials || {});
|
|
11
|
+
updated.credentials = Object.assign({ api_key: `##${name.toUpperCase()}_API_KEY##` }, (updated.credentials || {}));
|
|
11
12
|
}
|
|
12
13
|
if (name === 'smtp') {
|
|
13
|
-
updated.credentials = Object.assign({ smtp_host: '##SMTP_HOSTNAME##', smtp_port: '##SMTP_PORT##', smtp_user: '##SMTP_USER##', smtp_pass: '##SMTP_PASS##' }, updated.credentials || {});
|
|
14
|
+
updated.credentials = Object.assign({ smtp_host: '##SMTP_HOSTNAME##', smtp_port: '##SMTP_PORT##', smtp_user: '##SMTP_USER##', smtp_pass: '##SMTP_PASS##' }, (updated.credentials || {}));
|
|
14
15
|
}
|
|
15
16
|
if (name === 'ses') {
|
|
16
|
-
updated.credentials = Object.assign({ accessKeyId: '##SES_ACCESS_KEY_ID##', secretAccessKey: '##SES_ACCESS_SECRET_KEY##', region: '##SES_AWS_REGION##' }, updated.credentials || {});
|
|
17
|
+
updated.credentials = Object.assign({ accessKeyId: '##SES_ACCESS_KEY_ID##', secretAccessKey: '##SES_ACCESS_SECRET_KEY##', region: '##SES_AWS_REGION##' }, (updated.credentials || {}));
|
|
17
18
|
}
|
|
18
19
|
return updated;
|
|
19
20
|
}
|
|
@@ -32,7 +32,7 @@ function parse(context) {
|
|
|
32
32
|
return action;
|
|
33
33
|
});
|
|
34
34
|
return {
|
|
35
|
-
actions
|
|
35
|
+
actions,
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
function mapSecrets(secrets) {
|
|
@@ -63,12 +63,12 @@ function mapToAction(filePath, action) {
|
|
|
63
63
|
dependencies: action.dependencies || [],
|
|
64
64
|
secrets: mapSecrets(action.secrets),
|
|
65
65
|
supported_triggers: action.supported_triggers,
|
|
66
|
-
deployed: action.deployed || action.all_changes_deployed
|
|
66
|
+
deployed: action.deployed || action.all_changes_deployed,
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
function dump(context) {
|
|
70
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
const actions = [...context.assets.actions || []];
|
|
71
|
+
const actions = [...(context.assets.actions || [])];
|
|
72
72
|
if (actions.length < 1)
|
|
73
73
|
return;
|
|
74
74
|
// Create Actions folder
|
|
@@ -22,14 +22,14 @@ function attackProtectionFiles(filePath) {
|
|
|
22
22
|
directory: directory,
|
|
23
23
|
breachedPasswordDetection: path_1.default.join(directory, 'breached-password-detection.json'),
|
|
24
24
|
bruteForceProtection: path_1.default.join(directory, 'brute-force-protection.json'),
|
|
25
|
-
suspiciousIpThrottling: path_1.default.join(directory, 'suspicious-ip-throttling.json')
|
|
25
|
+
suspiciousIpThrottling: path_1.default.join(directory, 'suspicious-ip-throttling.json'),
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
function parse(context) {
|
|
29
29
|
const files = attackProtectionFiles(context.filePath);
|
|
30
30
|
if (!(0, utils_1.existsMustBeDir)(files.directory)) {
|
|
31
31
|
return {
|
|
32
|
-
attackProtection: undefined
|
|
32
|
+
attackProtection: undefined,
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
const breachedPasswordDetection = (0, utils_1.loadJSON)(files.breachedPasswordDetection);
|
|
@@ -39,8 +39,8 @@ function parse(context) {
|
|
|
39
39
|
attackProtection: {
|
|
40
40
|
breachedPasswordDetection,
|
|
41
41
|
bruteForceProtection,
|
|
42
|
-
suspiciousIpThrottling
|
|
43
|
-
}
|
|
42
|
+
suspiciousIpThrottling,
|
|
43
|
+
},
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
function dump(context) {
|
|
@@ -19,7 +19,7 @@ const utils_1 = require("../../../utils");
|
|
|
19
19
|
function parse(context) {
|
|
20
20
|
const brandingTemplatesFolder = path_1.default.join(context.filePath, tools_1.constants.BRANDING_DIRECTORY, tools_1.constants.BRANDING_TEMPLATES_DIRECTORY);
|
|
21
21
|
if (!(0, utils_1.existsMustBeDir)(brandingTemplatesFolder))
|
|
22
|
-
return { branding: context.branding };
|
|
22
|
+
return { branding: context.assets.branding };
|
|
23
23
|
const templatesDefinitionFiles = (0, utils_1.getFiles)(brandingTemplatesFolder, ['.json']);
|
|
24
24
|
const templates = templatesDefinitionFiles.map((templateDefinitionFile) => {
|
|
25
25
|
const definition = (0, utils_1.loadJSON)(templateDefinitionFile, context.mappings);
|
|
@@ -28,8 +28,8 @@ function parse(context) {
|
|
|
28
28
|
}, {});
|
|
29
29
|
return {
|
|
30
30
|
branding: {
|
|
31
|
-
templates
|
|
32
|
-
}
|
|
31
|
+
templates,
|
|
32
|
+
},
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
function dump(context) {
|
|
@@ -53,7 +53,8 @@ function dump(context) {
|
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
const brandingHandler = {
|
|
57
57
|
parse,
|
|
58
|
-
dump
|
|
58
|
+
dump,
|
|
59
59
|
};
|
|
60
|
+
exports.default = brandingHandler;
|
|
@@ -21,10 +21,11 @@ function parse(context) {
|
|
|
21
21
|
if (!(0, utils_1.existsMustBeDir)(grantsFolder))
|
|
22
22
|
return { clientGrants: undefined }; // Skip
|
|
23
23
|
const foundFiles = (0, utils_1.getFiles)(grantsFolder, ['.json']);
|
|
24
|
-
const clientGrants = foundFiles
|
|
24
|
+
const clientGrants = foundFiles
|
|
25
|
+
.map((f) => (0, utils_1.loadJSON)(f, context.mappings))
|
|
25
26
|
.filter((p) => Object.keys(p).length > 0); // Filter out empty grants
|
|
26
27
|
return {
|
|
27
|
-
clientGrants
|
|
28
|
+
clientGrants,
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
function dump(context) {
|
|
@@ -37,7 +37,7 @@ function parse(context) {
|
|
|
37
37
|
})
|
|
38
38
|
.filter((p) => Object.keys(p).length > 0); // Filter out empty connections
|
|
39
39
|
return {
|
|
40
|
-
connections
|
|
40
|
+
connections,
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
function dump(context) {
|
|
@@ -49,7 +49,9 @@ function dump(context) {
|
|
|
49
49
|
fs_extra_1.default.ensureDirSync(connectionsFolder);
|
|
50
50
|
// Convert enabled_clients from id to name
|
|
51
51
|
connections.forEach((connection) => {
|
|
52
|
-
const dumpedConnection = Object.assign(Object.assign({}, connection), (connection.enabled_clients && {
|
|
52
|
+
const dumpedConnection = Object.assign(Object.assign({}, connection), (connection.enabled_clients && {
|
|
53
|
+
enabled_clients: (0, utils_1.mapClientID2NameSorted)(connection.enabled_clients, context.assets.clientsOrig),
|
|
54
|
+
}));
|
|
53
55
|
const connectionName = (0, utils_1.sanitize)(dumpedConnection.name);
|
|
54
56
|
if (dumpedConnection.strategy === 'email') {
|
|
55
57
|
(0, utils_1.ensureProp)(dumpedConnection, 'options.email.body');
|
|
@@ -53,13 +53,15 @@ function parse(context) {
|
|
|
53
53
|
const databaseFolder = path_1.default.join(context.filePath, tools_1.constants.DATABASE_CONNECTIONS_DIRECTORY);
|
|
54
54
|
if (!(0, utils_1.existsMustBeDir)(databaseFolder))
|
|
55
55
|
return { databases: undefined }; // Skip
|
|
56
|
-
const folders = fs_extra_1.default
|
|
56
|
+
const folders = fs_extra_1.default
|
|
57
|
+
.readdirSync(databaseFolder)
|
|
57
58
|
.map((f) => path_1.default.join(databaseFolder, f))
|
|
58
59
|
.filter((f) => (0, utils_1.isDirectory)(f));
|
|
59
|
-
const databases = folders
|
|
60
|
+
const databases = folders
|
|
61
|
+
.map((f) => getDatabase(f, context.mappings))
|
|
60
62
|
.filter((p) => Object.keys(p).length > 1);
|
|
61
63
|
return {
|
|
62
|
-
databases
|
|
64
|
+
databases,
|
|
63
65
|
};
|
|
64
66
|
}
|
|
65
67
|
function dump(context) {
|
|
@@ -77,9 +79,13 @@ function dump(context) {
|
|
|
77
79
|
return 0;
|
|
78
80
|
return name1 > name2 ? 1 : -1;
|
|
79
81
|
};
|
|
80
|
-
const formatted = Object.assign(Object.assign(Object.assign({}, database), (database.enabled_clients && {
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
const formatted = Object.assign(Object.assign(Object.assign({}, database), (database.enabled_clients && {
|
|
83
|
+
enabled_clients: (0, utils_1.mapClientID2NameSorted)(database.enabled_clients, context.assets.clientsOrig),
|
|
84
|
+
})), { options: Object.assign(Object.assign({}, database.options), (database.options.customScripts && {
|
|
85
|
+
customScripts: Object.entries(database.options.customScripts)
|
|
86
|
+
//@ts-ignore
|
|
87
|
+
.sort(sortCustomScripts)
|
|
88
|
+
.reduce((scripts, [name, script]) => {
|
|
83
89
|
// Dump custom script to file
|
|
84
90
|
const scriptName = (0, utils_1.sanitize)(`${name}.js`);
|
|
85
91
|
const scriptFile = path_1.default.join(dbFolder, scriptName);
|
|
@@ -87,7 +93,7 @@ function dump(context) {
|
|
|
87
93
|
fs_extra_1.default.writeFileSync(scriptFile, script);
|
|
88
94
|
scripts[name] = `./${scriptName}`;
|
|
89
95
|
return scripts;
|
|
90
|
-
}, {})
|
|
96
|
+
}, {}),
|
|
91
97
|
})) });
|
|
92
98
|
const databaseFile = path_1.default.join(dbFolder, 'database.json');
|
|
93
99
|
(0, utils_1.dumpJSON)(databaseFile, formatted);
|
|
@@ -24,17 +24,18 @@ function parse(context) {
|
|
|
24
24
|
const providerFile = path_1.default.join(emailsFolder, 'provider.json');
|
|
25
25
|
if ((0, utils_1.isFile)(providerFile)) {
|
|
26
26
|
return {
|
|
27
|
-
emailProvider: (0, utils_1.loadJSON)(providerFile, context.mappings)
|
|
27
|
+
emailProvider: (0, utils_1.loadJSON)(providerFile, context.mappings),
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
return {};
|
|
31
31
|
}
|
|
32
32
|
function dump(context) {
|
|
33
|
+
var _a;
|
|
33
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
35
|
let { emailProvider } = context.assets;
|
|
35
36
|
if (!emailProvider)
|
|
36
37
|
return; // Skip, nothing to dump
|
|
37
|
-
const excludedDefaults = context.assets.exclude.defaults || [];
|
|
38
|
+
const excludedDefaults = ((_a = context.assets.exclude) === null || _a === void 0 ? void 0 : _a.defaults) || [];
|
|
38
39
|
if (!excludedDefaults.includes('emailProvider')) {
|
|
39
40
|
// Add placeholder for credentials as they cannot be exported
|
|
40
41
|
emailProvider = (0, defaults_1.emailProviderDefaults)(emailProvider);
|
|
@@ -46,12 +46,12 @@ function parse(context) {
|
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
return {
|
|
49
|
-
emailTemplates
|
|
49
|
+
emailTemplates,
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
function dump(context) {
|
|
53
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
const emailTemplates = [...context.assets.emailTemplates || []];
|
|
54
|
+
const emailTemplates = [...(context.assets.emailTemplates || [])];
|
|
55
55
|
if (!emailTemplates)
|
|
56
56
|
return; // Skip, nothing to dump
|
|
57
57
|
// Create Templates folder
|
|
@@ -21,10 +21,11 @@ function parse(context) {
|
|
|
21
21
|
if (!(0, utils_1.existsMustBeDir)(factorProvidersFolder))
|
|
22
22
|
return { guardianFactorProviders: undefined }; // Skip
|
|
23
23
|
const foundFiles = (0, utils_1.getFiles)(factorProvidersFolder, ['.json']);
|
|
24
|
-
const guardianFactorProviders = foundFiles
|
|
24
|
+
const guardianFactorProviders = foundFiles
|
|
25
|
+
.map((f) => (0, utils_1.loadJSON)(f, context.mappings))
|
|
25
26
|
.filter((p) => Object.keys(p).length > 0); // Filter out empty factorProvidersFolder
|
|
26
27
|
return {
|
|
27
|
-
guardianFactorProviders
|
|
28
|
+
guardianFactorProviders,
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
function dump(context) {
|
|
@@ -21,10 +21,11 @@ function parse(context) {
|
|
|
21
21
|
if (!(0, utils_1.existsMustBeDir)(factorTemplatesFolder))
|
|
22
22
|
return { guardianFactorTemplates: undefined }; // Skip
|
|
23
23
|
const foundFiles = (0, utils_1.getFiles)(factorTemplatesFolder, ['.json']);
|
|
24
|
-
const guardianFactorTemplates = foundFiles
|
|
24
|
+
const guardianFactorTemplates = foundFiles
|
|
25
|
+
.map((f) => (0, utils_1.loadJSON)(f, context.mappings))
|
|
25
26
|
.filter((p) => Object.keys(p).length > 0); // Filter out empty guardianFactorTemplates
|
|
26
27
|
return {
|
|
27
|
-
guardianFactorTemplates
|
|
28
|
+
guardianFactorTemplates,
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
function dump(context) {
|
|
@@ -21,10 +21,11 @@ function parse(context) {
|
|
|
21
21
|
if (!(0, utils_1.existsMustBeDir)(factorsFolder))
|
|
22
22
|
return { guardianFactors: undefined }; // Skip
|
|
23
23
|
const foundFiles = (0, utils_1.getFiles)(factorsFolder, ['.json']);
|
|
24
|
-
const guardianFactors = foundFiles
|
|
24
|
+
const guardianFactors = foundFiles
|
|
25
|
+
.map((f) => (0, utils_1.loadJSON)(f, context.mappings))
|
|
25
26
|
.filter((p) => Object.keys(p).length > 0); // Filter out empty guardianFactors
|
|
26
27
|
return {
|
|
27
|
-
guardianFactors
|
|
28
|
+
guardianFactors,
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
function dump(context) {
|
|
@@ -23,7 +23,7 @@ function parse(context) {
|
|
|
23
23
|
const file = path_1.default.join(guardianFolder, 'phoneFactorMessageTypes.json');
|
|
24
24
|
if ((0, utils_1.isFile)(file)) {
|
|
25
25
|
return {
|
|
26
|
-
guardianPhoneFactorMessageTypes: (0, utils_1.loadJSON)(file, context.mappings)
|
|
26
|
+
guardianPhoneFactorMessageTypes: (0, utils_1.loadJSON)(file, context.mappings),
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
return {};
|
|
@@ -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 {};
|
|
@@ -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 {};
|
|
@@ -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
|
|
@@ -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
|
-
|
|
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;
|
|
@@ -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
|
|
@@ -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
|
|
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) {
|
|
@@ -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
|
|
@@ -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
|
|
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() {
|
|
@@ -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),
|
|
40
|
+
tenant: Object.assign(Object.assign({}, tenant), sessionDurations),
|
|
39
41
|
};
|
|
40
|
-
/* eslint-enable camelcase */
|
|
41
42
|
}
|
|
42
43
|
return {};
|
|
43
44
|
}
|