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.
- 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 +222 -7
- package/CONTRIBUTING.md +2 -2
- package/README.md +3 -0
- package/lib/args.d.ts +29 -0
- package/lib/args.js +16 -15
- package/lib/commands/export.d.ts +2 -0
- package/lib/commands/export.js +3 -3
- package/lib/commands/import.d.ts +2 -0
- package/lib/commands/import.js +6 -6
- package/lib/commands/index.d.ts +9 -0
- package/lib/commands/index.js +1 -1
- package/lib/configFactory.d.ts +7 -0
- package/lib/configFactory.js +5 -1
- package/lib/context/defaults.d.ts +1 -0
- package/lib/context/defaults.js +4 -3
- package/lib/context/directory/handlers/actions.d.ts +6 -0
- package/lib/context/directory/handlers/actions.js +3 -3
- package/lib/context/directory/handlers/attackProtection.d.ts +10 -0
- package/lib/context/directory/handlers/attackProtection.js +7 -7
- package/lib/context/directory/handlers/branding.d.ts +6 -0
- package/lib/context/directory/handlers/branding.js +6 -5
- package/lib/context/directory/handlers/clientGrants.d.ts +6 -0
- package/lib/context/directory/handlers/clientGrants.js +3 -2
- package/lib/context/directory/handlers/clients.d.ts +6 -0
- package/lib/context/directory/handlers/clients.js +1 -1
- package/lib/context/directory/handlers/connections.d.ts +6 -0
- package/lib/context/directory/handlers/connections.js +4 -2
- package/lib/context/directory/handlers/databases.d.ts +6 -0
- package/lib/context/directory/handlers/databases.js +13 -7
- package/lib/context/directory/handlers/emailProvider.d.ts +6 -0
- package/lib/context/directory/handlers/emailProvider.js +3 -2
- package/lib/context/directory/handlers/emailTemplates.d.ts +6 -0
- package/lib/context/directory/handlers/emailTemplates.js +2 -2
- package/lib/context/directory/handlers/guardianFactorProviders.d.ts +6 -0
- package/lib/context/directory/handlers/guardianFactorProviders.js +3 -2
- package/lib/context/directory/handlers/guardianFactorTemplates.d.ts +6 -0
- package/lib/context/directory/handlers/guardianFactorTemplates.js +3 -2
- package/lib/context/directory/handlers/guardianFactors.d.ts +6 -0
- package/lib/context/directory/handlers/guardianFactors.js +3 -2
- package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.d.ts +6 -0
- package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.js +1 -1
- package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.d.ts +6 -0
- package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.js +1 -1
- package/lib/context/directory/handlers/guardianPolicies.d.ts +6 -0
- package/lib/context/directory/handlers/guardianPolicies.js +1 -1
- package/lib/context/directory/handlers/hooks.d.ts +6 -0
- package/lib/context/directory/handlers/hooks.js +2 -2
- package/lib/context/directory/handlers/index.d.ts +12 -0
- package/lib/context/directory/handlers/index.js +3 -2
- package/lib/context/directory/handlers/migrations.d.ts +6 -0
- package/lib/context/directory/handlers/organizations.d.ts +6 -0
- package/lib/context/directory/handlers/organizations.js +1 -1
- package/lib/context/directory/handlers/pages.d.ts +6 -0
- package/lib/context/directory/handlers/pages.js +2 -2
- package/lib/context/directory/handlers/resourceServers.d.ts +6 -0
- package/lib/context/directory/handlers/resourceServers.js +3 -2
- package/lib/context/directory/handlers/roles.d.ts +6 -0
- package/lib/context/directory/handlers/roles.js +1 -1
- package/lib/context/directory/handlers/rules.d.ts +6 -0
- package/lib/context/directory/handlers/rules.js +2 -2
- package/lib/context/directory/handlers/rulesConfigs.d.ts +6 -0
- package/lib/context/directory/handlers/rulesConfigs.js +3 -2
- package/lib/context/directory/handlers/tenant.d.ts +10 -0
- package/lib/context/directory/handlers/tenant.js +3 -2
- package/lib/context/directory/handlers/triggers.d.ts +6 -0
- package/lib/context/directory/index.d.ts +17 -0
- package/lib/context/directory/index.js +21 -18
- package/lib/context/index.d.ts +4 -0
- package/lib/context/index.js +83 -61
- package/lib/context/yaml/handlers/actions.d.ts +6 -0
- package/lib/context/yaml/handlers/actions.js +9 -6
- package/lib/context/yaml/handlers/attackProtection.d.ts +6 -0
- package/lib/context/yaml/handlers/attackProtection.js +1 -1
- package/lib/context/yaml/handlers/branding.d.ts +6 -0
- package/lib/context/yaml/handlers/branding.js +5 -4
- package/lib/context/yaml/handlers/clientGrants.d.ts +6 -0
- package/lib/context/yaml/handlers/clientGrants.js +2 -2
- package/lib/context/yaml/handlers/clients.d.ts +6 -0
- package/lib/context/yaml/handlers/clients.js +6 -4
- package/lib/context/yaml/handlers/connections.d.ts +6 -0
- package/lib/context/yaml/handlers/connections.js +7 -5
- package/lib/context/yaml/handlers/databases.d.ts +6 -0
- package/lib/context/yaml/handlers/databases.js +12 -8
- package/lib/context/yaml/handlers/emailProvider.d.ts +6 -0
- package/lib/context/yaml/handlers/emailProvider.js +4 -3
- package/lib/context/yaml/handlers/emailTemplates.d.ts +6 -0
- package/lib/context/yaml/handlers/emailTemplates.js +3 -3
- package/lib/context/yaml/handlers/guardianFactorProviders.d.ts +6 -0
- package/lib/context/yaml/handlers/guardianFactorProviders.js +1 -1
- package/lib/context/yaml/handlers/guardianFactorTemplates.d.ts +6 -0
- package/lib/context/yaml/handlers/guardianFactorTemplates.js +1 -1
- package/lib/context/yaml/handlers/guardianFactors.d.ts +6 -0
- package/lib/context/yaml/handlers/guardianFactors.js +1 -1
- package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.d.ts +6 -0
- package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.js +1 -1
- package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.d.ts +6 -0
- package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.js +1 -1
- package/lib/context/yaml/handlers/guardianPolicies.d.ts +6 -0
- package/lib/context/yaml/handlers/guardianPolicies.js +1 -1
- package/lib/context/yaml/handlers/hooks.d.ts +6 -0
- package/lib/context/yaml/handlers/hooks.js +4 -3
- package/lib/context/yaml/handlers/index.d.ts +12 -0
- package/lib/context/yaml/handlers/index.js +3 -2
- package/lib/context/yaml/handlers/migrations.d.ts +6 -0
- package/lib/context/yaml/handlers/organizations.d.ts +6 -0
- package/lib/context/yaml/handlers/organizations.js +3 -3
- package/lib/context/yaml/handlers/pages.d.ts +6 -0
- package/lib/context/yaml/handlers/pages.js +3 -3
- package/lib/context/yaml/handlers/resourceServers.d.ts +6 -0
- package/lib/context/yaml/handlers/resourceServers.js +2 -2
- package/lib/context/yaml/handlers/roles.d.ts +6 -0
- package/lib/context/yaml/handlers/roles.js +3 -3
- package/lib/context/yaml/handlers/rules.d.ts +6 -0
- package/lib/context/yaml/handlers/rules.js +3 -3
- package/lib/context/yaml/handlers/rulesConfigs.d.ts +6 -0
- package/lib/context/yaml/handlers/rulesConfigs.js +2 -2
- package/lib/context/yaml/handlers/tenant.d.ts +6 -0
- package/lib/context/yaml/handlers/tenant.js +4 -3
- package/lib/context/yaml/handlers/triggers.d.ts +6 -0
- package/lib/context/yaml/handlers/triggers.js +2 -2
- package/lib/context/yaml/index.d.ts +13 -0
- package/lib/context/yaml/index.js +31 -23
- package/lib/index.d.ts +88 -0
- package/lib/index.js +25 -17
- package/lib/logger.d.ts +2 -0
- package/lib/logger.js +8 -17
- package/lib/readonly.d.ts +2 -0
- package/lib/readonly.js +11 -16
- package/lib/sessionDurationsToMinutes.d.ts +7 -0
- package/lib/sessionDurationsToMinutes.js +15 -0
- package/lib/tools/auth0/client.d.ts +2 -0
- package/lib/tools/auth0/client.js +12 -12
- package/lib/tools/auth0/handlers/actions.d.ts +95 -0
- package/lib/tools/auth0/handlers/actions.js +22 -24
- package/lib/tools/auth0/handlers/attackProtection.d.ts +28 -0
- package/lib/tools/auth0/handlers/attackProtection.js +14 -17
- package/lib/tools/auth0/handlers/branding.d.ts +27 -0
- package/lib/tools/auth0/handlers/branding.js +13 -9
- package/lib/tools/auth0/handlers/clientGrants.d.ts +32 -0
- package/lib/tools/auth0/handlers/clientGrants.js +17 -10
- package/lib/tools/auth0/handlers/clients.d.ts +23 -0
- package/lib/tools/auth0/handlers/clients.js +15 -8
- package/lib/tools/auth0/handlers/connections.d.ts +54 -0
- package/lib/tools/auth0/handlers/connections.js +30 -10
- package/lib/tools/auth0/handlers/databases.d.ts +36 -0
- package/lib/tools/auth0/handlers/databases.js +25 -13
- package/lib/tools/auth0/handlers/default.d.ts +54 -0
- package/lib/tools/auth0/handlers/default.js +62 -36
- package/lib/tools/auth0/handlers/emailProvider.d.ts +11 -0
- package/lib/tools/auth0/handlers/emailTemplates.d.ts +26 -0
- package/lib/tools/auth0/handlers/emailTemplates.js +8 -10
- package/lib/tools/auth0/handlers/guardianFactorProviders.d.ts +25 -0
- package/lib/tools/auth0/handlers/guardianFactorProviders.js +3 -3
- package/lib/tools/auth0/handlers/guardianFactorTemplates.d.ts +21 -0
- package/lib/tools/auth0/handlers/guardianFactorTemplates.js +3 -3
- package/lib/tools/auth0/handlers/guardianFactors.d.ts +21 -0
- package/lib/tools/auth0/handlers/guardianFactors.js +3 -3
- package/lib/tools/auth0/handlers/guardianPhoneFactorMessageTypes.d.ts +21 -0
- package/lib/tools/auth0/handlers/guardianPhoneFactorMessageTypes.js +11 -10
- package/lib/tools/auth0/handlers/guardianPhoneFactorSelectedProvider.d.ts +18 -0
- package/lib/tools/auth0/handlers/guardianPhoneFactorSelectedProvider.js +10 -9
- package/lib/tools/auth0/handlers/guardianPolicies.d.ts +23 -0
- package/lib/tools/auth0/handlers/guardianPolicies.js +5 -4
- package/lib/tools/auth0/handlers/hooks.d.ts +58 -0
- package/lib/tools/auth0/handlers/hooks.js +34 -21
- package/lib/tools/auth0/handlers/index.d.ts +129 -0
- package/lib/tools/auth0/handlers/index.js +31 -27
- package/lib/tools/auth0/handlers/migrations.d.ts +15 -0
- package/lib/tools/auth0/handlers/migrations.js +3 -2
- package/lib/tools/auth0/handlers/organizations.d.ts +51 -0
- package/lib/tools/auth0/handlers/organizations.js +62 -32
- package/lib/tools/auth0/handlers/pages.d.ts +42 -0
- package/lib/tools/auth0/handlers/pages.js +20 -14
- package/lib/tools/auth0/handlers/prompts.d.ts +11 -0
- package/lib/tools/auth0/handlers/prompts.js +1 -0
- package/lib/tools/auth0/handlers/resourceServers.d.ts +51 -0
- package/lib/tools/auth0/handlers/resourceServers.js +22 -14
- package/lib/tools/auth0/handlers/roles.d.ts +48 -0
- package/lib/tools/auth0/handlers/roles.js +56 -32
- package/lib/tools/auth0/handlers/rules.d.ts +55 -0
- package/lib/tools/auth0/handlers/rules.js +53 -36
- package/lib/tools/auth0/handlers/rulesConfigs.d.ts +25 -0
- package/lib/tools/auth0/handlers/rulesConfigs.js +12 -6
- package/lib/tools/auth0/handlers/tenant.d.ts +11 -0
- package/lib/tools/auth0/handlers/tenant.js +8 -4
- package/lib/tools/auth0/handlers/triggers.d.ts +35 -0
- package/lib/tools/auth0/handlers/triggers.js +12 -13
- package/lib/tools/auth0/index.d.ts +15 -0
- package/lib/tools/auth0/index.js +15 -31
- package/lib/tools/auth0/schema.d.ts +15 -0
- package/lib/tools/auth0/schema.js +7 -27
- package/lib/tools/calculateChanges.d.ts +26 -0
- package/lib/tools/calculateChanges.js +12 -7
- package/lib/tools/constants.d.ts +71 -0
- package/lib/tools/constants.js +164 -161
- package/lib/tools/deploy.d.ts +3 -0
- package/lib/tools/deploy.js +3 -3
- package/lib/tools/index.d.ts +82 -0
- package/lib/tools/index.js +1 -1
- package/lib/tools/utils.d.ts +18 -0
- package/lib/tools/utils.js +68 -10
- package/lib/tools/validationError.d.ts +5 -0
- package/lib/tools/{ValidationError.js → validationError.js} +3 -1
- package/lib/types.d.ts +255 -0
- package/lib/types.js +2 -0
- package/lib/utils.d.ts +66 -0
- package/lib/utils.js +18 -25
- package/package.json +16 -7
- package/tsconfig.json +3 -4
- package/typescript-migration-progress.sh +1 -1
- package/lib/tools/logger.js +0 -15
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
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Config } from './types';
|
|
2
|
+
export declare type ConfigFunction = (arg0: keyof Config) => any;
|
|
3
|
+
export declare const configFactory: () => {
|
|
4
|
+
(key: keyof Config): any;
|
|
5
|
+
setProvider(providerFunction: ConfigFunction): void;
|
|
6
|
+
setValue(key: keyof Config, value: any): void;
|
|
7
|
+
};
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function emailProviderDefaults(emailProvider: any): any;
|
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
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DirectoryHandler } from '.';
|
|
2
|
+
declare type ParsedAttackProtection = {
|
|
3
|
+
attackProtection: {
|
|
4
|
+
breachedPasswordDetection: unknown;
|
|
5
|
+
bruteForceProtection: unknown;
|
|
6
|
+
suspiciousIpThrottling: unknown;
|
|
7
|
+
} | undefined;
|
|
8
|
+
};
|
|
9
|
+
declare const attackProtectionHandler: DirectoryHandler<ParsedAttackProtection>;
|
|
10
|
+
export default attackProtectionHandler;
|
|
@@ -22,25 +22,25 @@ 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
|
-
const breachedPasswordDetection = (0, utils_1.loadJSON)(files.breachedPasswordDetection);
|
|
36
|
-
const bruteForceProtection = (0, utils_1.loadJSON)(files.bruteForceProtection);
|
|
37
|
-
const suspiciousIpThrottling = (0, utils_1.loadJSON)(files.suspiciousIpThrottling);
|
|
35
|
+
const breachedPasswordDetection = (0, utils_1.loadJSON)(files.breachedPasswordDetection, context.mappings);
|
|
36
|
+
const bruteForceProtection = (0, utils_1.loadJSON)(files.bruteForceProtection, context.mappings);
|
|
37
|
+
const suspiciousIpThrottling = (0, utils_1.loadJSON)(files.suspiciousIpThrottling, context.mappings);
|
|
38
38
|
return {
|
|
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
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DirectoryHandler } from '.';
|
|
2
|
+
declare type ParsedGuardianFactorProviders = {
|
|
3
|
+
guardianFactorProviders: unknown[] | undefined;
|
|
4
|
+
};
|
|
5
|
+
declare const guardianFactorProvidersHandler: DirectoryHandler<ParsedGuardianFactorProviders>;
|
|
6
|
+
export default guardianFactorProvidersHandler;
|
|
@@ -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) {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DirectoryHandler } from '.';
|
|
2
|
+
declare type ParsedGuardianFactorTemplates = {
|
|
3
|
+
guardianFactorTemplates: unknown[] | undefined;
|
|
4
|
+
};
|
|
5
|
+
declare const guardianFactorTemplatesHandler: DirectoryHandler<ParsedGuardianFactorTemplates>;
|
|
6
|
+
export default guardianFactorTemplatesHandler;
|
|
@@ -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) {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DirectoryHandler } from '.';
|
|
2
|
+
declare type ParsedGuardianFactorMessageTypes = {
|
|
3
|
+
guardianPhoneFactorMessageTypes: unknown;
|
|
4
|
+
} | {};
|
|
5
|
+
declare const guardianFactorMessageTypesHandler: DirectoryHandler<ParsedGuardianFactorMessageTypes>;
|
|
6
|
+
export default guardianFactorMessageTypesHandler;
|
|
@@ -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 {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DirectoryHandler } from '.';
|
|
2
|
+
declare type ParsedGuardianFactorSelectedProvider = {
|
|
3
|
+
guardianPhoneFactorSelectedProvider: unknown;
|
|
4
|
+
} | {};
|
|
5
|
+
declare const guardianFactorSelectedProviderHandler: DirectoryHandler<ParsedGuardianFactorSelectedProvider>;
|
|
6
|
+
export default guardianFactorSelectedProviderHandler;
|