auth0-deploy-cli 7.5.1 → 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 +209 -7
- package/CONTRIBUTING.md +2 -2
- package/README.md +3 -0
- package/lib/args.js +16 -17
- package/lib/commands/export.js +3 -3
- package/lib/commands/import.js +7 -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 +6 -5
- package/lib/context/directory/handlers/attackProtection.js +7 -6
- package/lib/context/directory/handlers/branding.js +60 -0
- package/lib/context/directory/handlers/clientGrants.js +6 -4
- package/lib/context/directory/handlers/clients.js +4 -3
- package/lib/context/directory/handlers/connections.js +7 -4
- package/lib/context/directory/handlers/databases.js +30 -22
- package/lib/context/directory/handlers/emailProvider.js +6 -4
- package/lib/context/directory/handlers/emailTemplates.js +13 -11
- package/lib/context/directory/handlers/guardianFactorProviders.js +6 -4
- package/lib/context/directory/handlers/guardianFactorTemplates.js +6 -4
- package/lib/context/directory/handlers/guardianFactors.js +6 -4
- package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.js +4 -3
- package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.js +4 -3
- package/lib/context/directory/handlers/guardianPolicies.js +4 -3
- package/lib/context/directory/handlers/hooks.js +5 -4
- package/lib/context/directory/handlers/index.js +5 -2
- package/lib/context/directory/handlers/migrations.js +8 -8
- package/lib/context/directory/handlers/organizations.js +4 -3
- package/lib/context/directory/handlers/pages.js +20 -20
- package/lib/context/directory/handlers/resourceServers.js +6 -4
- package/lib/context/directory/handlers/roles.js +4 -3
- package/lib/context/directory/handlers/rules.js +5 -4
- package/lib/context/directory/handlers/rulesConfigs.js +7 -5
- package/lib/context/directory/handlers/tenant.js +7 -4
- package/lib/context/directory/handlers/triggers.js +3 -2
- package/lib/context/directory/index.js +23 -22
- package/lib/context/index.js +66 -62
- package/lib/context/yaml/handlers/actions.js +12 -8
- package/lib/context/yaml/handlers/attackProtection.js +6 -12
- package/lib/context/yaml/handlers/branding.js +66 -0
- package/lib/context/yaml/handlers/clientGrants.js +5 -4
- package/lib/context/yaml/handlers/clients.js +9 -6
- package/lib/context/yaml/handlers/connections.js +10 -7
- package/lib/context/yaml/handlers/databases.js +15 -10
- package/lib/context/yaml/handlers/emailProvider.js +7 -5
- package/lib/context/yaml/handlers/emailTemplates.js +6 -5
- package/lib/context/yaml/handlers/guardianFactorProviders.js +6 -13
- package/lib/context/yaml/handlers/guardianFactorTemplates.js +6 -13
- package/lib/context/yaml/handlers/guardianFactors.js +6 -13
- package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.js +6 -13
- package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.js +6 -13
- package/lib/context/yaml/handlers/guardianPolicies.js +6 -13
- package/lib/context/yaml/handlers/hooks.js +7 -5
- package/lib/context/yaml/handlers/index.js +5 -2
- package/lib/context/yaml/handlers/migrations.js +3 -2
- package/lib/context/yaml/handlers/organizations.js +6 -5
- package/lib/context/yaml/handlers/pages.js +6 -5
- package/lib/context/yaml/handlers/resourceServers.js +5 -4
- package/lib/context/yaml/handlers/roles.js +6 -5
- package/lib/context/yaml/handlers/rules.js +6 -5
- package/lib/context/yaml/handlers/rulesConfigs.js +6 -5
- package/lib/context/yaml/handlers/tenant.js +7 -5
- package/lib/context/yaml/handlers/triggers.js +5 -4
- package/lib/context/yaml/index.js +33 -24
- 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 +71 -13
- 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 +47 -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 +67 -32
- 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 +28 -15
- package/lib/tools/auth0/handlers/roles.js +61 -32
- package/lib/tools/auth0/handlers/rules.js +55 -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 +149 -0
- package/lib/tools/constants.js +162 -154
- 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 +3 -144
- package/lib/tools/{ValidationError.js → validationError.js} +3 -1
- package/lib/types.js +2 -0
- package/lib/utils.js +12 -22
- package/package.json +9 -2
- package/tsconfig.json +2 -3
- package/typescript-migration-progress.sh +1 -1
package/lib/args.js
CHANGED
|
@@ -13,73 +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
|
-
alias: 'e',
|
|
37
36
|
describe: 'Override the mappings in config with environment variables.',
|
|
38
37
|
boolean: true,
|
|
39
|
-
default: true
|
|
38
|
+
default: true,
|
|
40
39
|
},
|
|
41
40
|
secret: {
|
|
42
41
|
alias: 'x',
|
|
43
42
|
describe: 'The client secret, this allows you to encrypt the secret in your build configuration instead of storing it in a config file',
|
|
44
|
-
type: 'string'
|
|
45
|
-
}
|
|
43
|
+
type: 'string',
|
|
44
|
+
},
|
|
46
45
|
})
|
|
47
46
|
.command(['export', 'dump'], 'Export Auth0 Tenant Configuration', {
|
|
48
47
|
output_folder: {
|
|
49
48
|
alias: 'o',
|
|
50
49
|
describe: 'The output directory.',
|
|
51
50
|
type: 'string',
|
|
52
|
-
demandOption: true
|
|
51
|
+
demandOption: true,
|
|
53
52
|
},
|
|
54
53
|
format: {
|
|
55
54
|
alias: 'f',
|
|
56
55
|
describe: 'The output format.',
|
|
57
56
|
type: 'string',
|
|
58
57
|
choices: ['yaml', 'directory'],
|
|
59
|
-
demandOption: true
|
|
58
|
+
demandOption: true,
|
|
60
59
|
},
|
|
61
60
|
config_file: {
|
|
62
61
|
alias: 'c',
|
|
63
62
|
describe: 'The JSON configuration file.',
|
|
64
|
-
type: 'string'
|
|
63
|
+
type: 'string',
|
|
65
64
|
},
|
|
66
65
|
secret: {
|
|
67
66
|
alias: 'x',
|
|
68
67
|
describe: 'The client secret, this allows you to encrypt the secret in your build configuration instead of storing it in a config file',
|
|
69
|
-
type: 'string'
|
|
68
|
+
type: 'string',
|
|
70
69
|
},
|
|
71
70
|
env: {
|
|
72
|
-
alias: 'e',
|
|
73
71
|
describe: 'Override the mappings in config with environment variables.',
|
|
74
72
|
boolean: true,
|
|
75
|
-
default: false
|
|
73
|
+
default: false,
|
|
76
74
|
},
|
|
77
75
|
export_ids: {
|
|
78
76
|
alias: 'e',
|
|
79
77
|
describe: 'Export identifier field for each object type.',
|
|
80
78
|
type: 'boolean',
|
|
81
|
-
default: false
|
|
82
|
-
}
|
|
79
|
+
default: false,
|
|
80
|
+
},
|
|
83
81
|
})
|
|
84
82
|
.example('$0 export -c config.json -f yaml -o path/to/export', 'Dump Auth0 config to folder in YAML format')
|
|
85
83
|
.example('$0 export -c config.json -f directory -o path/to/export', 'Dump Auth0 config to folder in directory format')
|
|
@@ -91,9 +89,10 @@ function getParams() {
|
|
|
91
89
|
.example('$0 deploy -c config.json -i path/to/files', 'Deploy Auth0 via Path')
|
|
92
90
|
.epilogue('See README (https://github.com/auth0/auth0-deploy-cli) for more in-depth information on configuration and setup.')
|
|
93
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
|
|
94
93
|
return args.argv;
|
|
95
94
|
}
|
|
96
95
|
exports.getParams = getParams;
|
|
97
96
|
exports.default = {
|
|
98
|
-
getParams
|
|
97
|
+
getParams,
|
|
99
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,10 +36,11 @@ 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
|
+
//@ts-ignore because context and assets still need to be typed TODO: type assets and type context
|
|
43
44
|
yield (0, tools_1.deploy)(context.assets, context.mgmtClient, config);
|
|
44
45
|
logger_1.default.info('Import Successful');
|
|
45
46
|
});
|
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
|
|
@@ -83,7 +83,8 @@ function dump(context) {
|
|
|
83
83
|
});
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
|
-
|
|
86
|
+
const actionsHandler = {
|
|
87
87
|
parse,
|
|
88
|
-
dump
|
|
88
|
+
dump,
|
|
89
89
|
};
|
|
90
|
+
exports.default = actionsHandler;
|
|
@@ -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) {
|
|
@@ -53,7 +53,8 @@ function dump(context) {
|
|
|
53
53
|
(0, utils_1.dumpJSON)(files.suspiciousIpThrottling, attackProtection.suspiciousIpThrottling);
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
const attackProtectionHandler = {
|
|
57
57
|
parse,
|
|
58
|
-
dump
|
|
58
|
+
dump,
|
|
59
59
|
};
|
|
60
|
+
exports.default = attackProtectionHandler;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const tools_1 = require("../../../tools");
|
|
18
|
+
const utils_1 = require("../../../utils");
|
|
19
|
+
function parse(context) {
|
|
20
|
+
const brandingTemplatesFolder = path_1.default.join(context.filePath, tools_1.constants.BRANDING_DIRECTORY, tools_1.constants.BRANDING_TEMPLATES_DIRECTORY);
|
|
21
|
+
if (!(0, utils_1.existsMustBeDir)(brandingTemplatesFolder))
|
|
22
|
+
return { branding: context.assets.branding };
|
|
23
|
+
const templatesDefinitionFiles = (0, utils_1.getFiles)(brandingTemplatesFolder, ['.json']);
|
|
24
|
+
const templates = templatesDefinitionFiles.map((templateDefinitionFile) => {
|
|
25
|
+
const definition = (0, utils_1.loadJSON)(templateDefinitionFile, context.mappings);
|
|
26
|
+
definition.body = (0, tools_1.loadFileAndReplaceKeywords)(path_1.default.join(brandingTemplatesFolder, definition.body), context.mappings);
|
|
27
|
+
return definition;
|
|
28
|
+
}, {});
|
|
29
|
+
return {
|
|
30
|
+
branding: {
|
|
31
|
+
templates,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function dump(context) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const { branding } = context.assets;
|
|
38
|
+
if (!branding || !branding.templates || !branding.templates)
|
|
39
|
+
return; // Skip, nothing to dump
|
|
40
|
+
const brandingTemplatesFolder = path_1.default.join(context.filePath, tools_1.constants.BRANDING_DIRECTORY, tools_1.constants.BRANDING_TEMPLATES_DIRECTORY);
|
|
41
|
+
fs_extra_1.default.ensureDirSync(brandingTemplatesFolder);
|
|
42
|
+
branding.templates.forEach((templateDefinition) => {
|
|
43
|
+
const markup = templateDefinition.body;
|
|
44
|
+
try {
|
|
45
|
+
fs_extra_1.default.writeFileSync(path_1.default.join(brandingTemplatesFolder, `${templateDefinition.template}.html`), markup);
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
throw new Error(`Error writing template file: ${templateDefinition.template}, because: ${e.message}`);
|
|
49
|
+
}
|
|
50
|
+
// save the location as relative file.
|
|
51
|
+
templateDefinition.body = `.${path_1.default.sep}${templateDefinition.template}.html`;
|
|
52
|
+
(0, utils_1.dumpJSON)(path_1.default.join(brandingTemplatesFolder, `${templateDefinition.template}.json`), templateDefinition);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const brandingHandler = {
|
|
57
|
+
parse,
|
|
58
|
+
dump,
|
|
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) {
|
|
@@ -44,7 +45,8 @@ function dump(context) {
|
|
|
44
45
|
});
|
|
45
46
|
});
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
+
const clientGrantsHandler = {
|
|
48
49
|
parse,
|
|
49
|
-
dump
|
|
50
|
+
dump,
|
|
50
51
|
};
|
|
52
|
+
exports.default = clientGrantsHandler;
|
|
@@ -35,7 +35,7 @@ function parse(context) {
|
|
|
35
35
|
})
|
|
36
36
|
.filter((p) => Object.keys(p).length > 0); // Filter out empty clients
|
|
37
37
|
return {
|
|
38
|
-
clients
|
|
38
|
+
clients,
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
function dump(context) {
|
|
@@ -59,7 +59,8 @@ function dump(context) {
|
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
const clientsHandler = {
|
|
63
63
|
parse,
|
|
64
|
-
dump
|
|
64
|
+
dump,
|
|
65
65
|
};
|
|
66
|
+
exports.default = clientsHandler;
|
|
@@ -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');
|
|
@@ -64,7 +66,8 @@ function dump(context) {
|
|
|
64
66
|
});
|
|
65
67
|
});
|
|
66
68
|
}
|
|
67
|
-
|
|
69
|
+
const connectionsHandler = {
|
|
68
70
|
parse,
|
|
69
|
-
dump
|
|
71
|
+
dump,
|
|
70
72
|
};
|
|
73
|
+
exports.default = connectionsHandler;
|
|
@@ -19,22 +19,20 @@ const logger_1 = __importDefault(require("../../../logger"));
|
|
|
19
19
|
const utils_1 = require("../../../utils");
|
|
20
20
|
function getDatabase(folder, mappings) {
|
|
21
21
|
const metaFile = path_1.default.join(folder, 'database.json');
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
22
|
+
const metaData = (() => {
|
|
23
|
+
try {
|
|
24
|
+
return (0, utils_1.loadJSON)(metaFile, mappings);
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
logger_1.default.warn(`Skipping database folder ${folder} as cannot find or read ${metaFile}`);
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
})();
|
|
31
31
|
if (!metaData) {
|
|
32
32
|
logger_1.default.warn(`Skipping database folder ${folder} as ${metaFile} is empty`);
|
|
33
33
|
return {};
|
|
34
34
|
}
|
|
35
|
-
const database = Object.assign(Object.assign({}, metaData), { options: Object.assign(Object.assign({}, metaData.options), (metaData.customScripts && {
|
|
36
|
-
customScripts: metaData.customScripts
|
|
37
|
-
})) });
|
|
35
|
+
const database = Object.assign(Object.assign({}, metaData), { options: Object.assign(Object.assign({}, metaData.options), (metaData.customScripts && { customScripts: metaData.customScripts })) });
|
|
38
36
|
// If any customScripts configured then load content of files
|
|
39
37
|
if (database.options.customScripts) {
|
|
40
38
|
Object.entries(database.options.customScripts).forEach(([name, script]) => {
|
|
@@ -43,7 +41,9 @@ function getDatabase(folder, mappings) {
|
|
|
43
41
|
logger_1.default.warn('Skipping invalid database configuration: ' + name);
|
|
44
42
|
}
|
|
45
43
|
else {
|
|
46
|
-
database.options.customScripts[name] = (0, tools_1.loadFileAndReplaceKeywords)(
|
|
44
|
+
database.options.customScripts[name] = (0, tools_1.loadFileAndReplaceKeywords)(
|
|
45
|
+
//@ts-ignore
|
|
46
|
+
path_1.default.join(folder, script), mappings);
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
49
|
}
|
|
@@ -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) {
|
|
@@ -72,13 +74,18 @@ function dump(context) {
|
|
|
72
74
|
databases.forEach((database) => {
|
|
73
75
|
const dbFolder = path_1.default.join(databasesFolder, (0, utils_1.sanitize)(database.name));
|
|
74
76
|
fs_extra_1.default.ensureDirSync(dbFolder);
|
|
75
|
-
const sortCustomScripts = (
|
|
77
|
+
const sortCustomScripts = (name1, name2) => {
|
|
76
78
|
if (name1 === name2)
|
|
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
|
+
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]) => {
|
|
82
89
|
// Dump custom script to file
|
|
83
90
|
const scriptName = (0, utils_1.sanitize)(`${name}.js`);
|
|
84
91
|
const scriptFile = path_1.default.join(dbFolder, scriptName);
|
|
@@ -86,14 +93,15 @@ function dump(context) {
|
|
|
86
93
|
fs_extra_1.default.writeFileSync(scriptFile, script);
|
|
87
94
|
scripts[name] = `./${scriptName}`;
|
|
88
95
|
return scripts;
|
|
89
|
-
}, {})
|
|
96
|
+
}, {}),
|
|
90
97
|
})) });
|
|
91
98
|
const databaseFile = path_1.default.join(dbFolder, 'database.json');
|
|
92
99
|
(0, utils_1.dumpJSON)(databaseFile, formatted);
|
|
93
100
|
});
|
|
94
101
|
});
|
|
95
102
|
}
|
|
96
|
-
|
|
103
|
+
const databasesHandler = {
|
|
97
104
|
parse,
|
|
98
|
-
dump
|
|
105
|
+
dump,
|
|
99
106
|
};
|
|
107
|
+
exports.default = databasesHandler;
|
|
@@ -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);
|
|
@@ -45,7 +46,8 @@ function dump(context) {
|
|
|
45
46
|
(0, utils_1.dumpJSON)(emailProviderFile, emailProvider);
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
+
const emailProviderHandler = {
|
|
49
50
|
parse,
|
|
50
|
-
dump
|
|
51
|
+
dump,
|
|
51
52
|
};
|
|
53
|
+
exports.default = emailProviderHandler;
|
|
@@ -32,25 +32,26 @@ function parse(context) {
|
|
|
32
32
|
if (ext === '.html')
|
|
33
33
|
sorted[name].html = file;
|
|
34
34
|
});
|
|
35
|
-
const emailTemplates =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
const emailTemplates = Object.values(sorted).flatMap(({ meta, html }) => {
|
|
36
|
+
if (!meta) {
|
|
37
|
+
logger_1.default.warn(`Skipping email template file ${html} as missing the corresponding '.json' file`);
|
|
38
|
+
return [];
|
|
39
39
|
}
|
|
40
|
-
else if (!
|
|
41
|
-
logger_1.default.warn(`Skipping email template file ${
|
|
40
|
+
else if (!html) {
|
|
41
|
+
logger_1.default.warn(`Skipping email template file ${meta} as missing corresponding '.html' file`);
|
|
42
|
+
return [];
|
|
42
43
|
}
|
|
43
44
|
else {
|
|
44
|
-
|
|
45
|
+
return Object.assign(Object.assign({}, (0, utils_1.loadJSON)(meta, context.mappings)), { body: (0, tools_1.loadFileAndReplaceKeywords)(html, context.mappings) });
|
|
45
46
|
}
|
|
46
47
|
});
|
|
47
48
|
return {
|
|
48
|
-
emailTemplates
|
|
49
|
+
emailTemplates,
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
52
|
function dump(context) {
|
|
52
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
const emailTemplates = [...context.assets.emailTemplates || []];
|
|
54
|
+
const emailTemplates = [...(context.assets.emailTemplates || [])];
|
|
54
55
|
if (!emailTemplates)
|
|
55
56
|
return; // Skip, nothing to dump
|
|
56
57
|
// Create Templates folder
|
|
@@ -67,7 +68,8 @@ function dump(context) {
|
|
|
67
68
|
});
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
+
const emailTemplatesHandler = {
|
|
71
72
|
parse,
|
|
72
|
-
dump
|
|
73
|
+
dump,
|
|
73
74
|
};
|
|
75
|
+
exports.default = emailTemplatesHandler;
|
|
@@ -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) {
|
|
@@ -40,7 +41,8 @@ function dump(context) {
|
|
|
40
41
|
});
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
+
const guardianFactorProvidersHandler = {
|
|
44
45
|
parse,
|
|
45
|
-
dump
|
|
46
|
+
dump,
|
|
46
47
|
};
|
|
48
|
+
exports.default = guardianFactorProvidersHandler;
|