auth0-deploy-cli 7.5.2 → 7.7.1
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 +219 -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 +10 -9
- 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 +83 -61
- 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 +12 -12
- 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 +25 -13
- package/lib/tools/auth0/handlers/default.js +46 -28
- 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 +58 -35
- 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 +34 -150
- package/lib/tools/{ValidationError.js → validationError.js} +3 -1
- package/lib/types.js +2 -0
- package/lib/utils.js +18 -25
- package/package.json +11 -2
- package/tsconfig.json +2 -3
- package/typescript-migration-progress.sh +1 -1
package/lib/context/index.js
CHANGED
|
@@ -12,13 +12,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.setupContext = void 0;
|
|
15
16
|
const path_1 = __importDefault(require("path"));
|
|
16
17
|
const auth0_1 = require("auth0");
|
|
17
18
|
const yaml_1 = __importDefault(require("./yaml"));
|
|
18
19
|
const directory_1 = __importDefault(require("./directory"));
|
|
19
20
|
const utils_1 = require("../utils");
|
|
20
|
-
const package_json_1 = require("../../package.json");
|
|
21
21
|
const logger_1 = __importDefault(require("../logger"));
|
|
22
|
+
const { version: packageVersion } = require('../../package.json');
|
|
22
23
|
const nonPrimitiveProps = [
|
|
23
24
|
'AUTH0_KEYWORD_REPLACE_MAPPINGS',
|
|
24
25
|
'AUTH0_EXCLUDED_RULES',
|
|
@@ -27,73 +28,94 @@ const nonPrimitiveProps = [
|
|
|
27
28
|
'AUTH0_EXCLUDED_CONNECTIONS',
|
|
28
29
|
'AUTH0_EXCLUDED_RESOURCE_SERVERS',
|
|
29
30
|
'AUTH0_EXCLUDED_DEFAULTS',
|
|
31
|
+
'AUTH0_EXCLUDED',
|
|
30
32
|
'EXCLUDED_PROPS',
|
|
31
|
-
'INCLUDED_PROPS'
|
|
33
|
+
'INCLUDED_PROPS',
|
|
32
34
|
];
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (!config.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
35
|
+
const setupContext = (config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
// Validate config
|
|
37
|
+
const missingParams = [];
|
|
38
|
+
if (!config.AUTH0_DOMAIN)
|
|
39
|
+
missingParams.push('AUTH0_DOMAIN');
|
|
40
|
+
if (!config.AUTH0_ACCESS_TOKEN) {
|
|
41
|
+
if (!config.AUTH0_CLIENT_ID)
|
|
42
|
+
missingParams.push('AUTH0_CLIENT_ID');
|
|
43
|
+
if (!config.AUTH0_CLIENT_SECRET)
|
|
44
|
+
missingParams.push('AUTH0_CLIENT_SECRET');
|
|
45
|
+
}
|
|
46
|
+
if (missingParams.length > 0) {
|
|
47
|
+
throw new Error(`The following parameters were missing. Please add them to your config.json or as an environment variable. ${JSON.stringify(missingParams)}`);
|
|
48
|
+
}
|
|
49
|
+
((config) => {
|
|
50
|
+
// Detect and warn on usage of deprecated exclusion params. See: https://github.com/auth0/auth0-deploy-cli/issues/451#user-content-deprecated-exclusion-props
|
|
51
|
+
const deprecatedExclusionParams = [
|
|
52
|
+
'AUTH0_EXCLUDED_RULES',
|
|
53
|
+
'AUTH0_EXCLUDED_CLIENTS',
|
|
54
|
+
'AUTH0_EXCLUDED_DATABASES',
|
|
55
|
+
'AUTH0_EXCLUDED_CONNECTIONS',
|
|
56
|
+
'AUTH0_EXCLUDED_RESOURCE_SERVERS',
|
|
57
|
+
'AUTH0_EXCLUDED_DEFAULTS',
|
|
58
|
+
];
|
|
59
|
+
const usedDeprecatedParams = deprecatedExclusionParams.filter((deprecatedParam) => {
|
|
60
|
+
const deprecatedConfigValue = config[deprecatedParam];
|
|
61
|
+
return !!deprecatedConfigValue && deprecatedConfigValue.length > 0;
|
|
62
|
+
});
|
|
63
|
+
if (usedDeprecatedParams.length > 0) {
|
|
64
|
+
logger_1.default.warn(`Usage of the ${usedDeprecatedParams.join(', ')} exclusion ${usedDeprecatedParams.length > 1 ? 'params are' : 'param is'} deprecated and may be removed from future major versions. See: https://github.com/auth0/auth0-deploy-cli/issues/451#user-content-deprecated-exclusion-props for details.`);
|
|
59
65
|
}
|
|
60
|
-
|
|
66
|
+
})(config);
|
|
67
|
+
const accessToken = yield (() => __awaiter(void 0, void 0, void 0, function* () {
|
|
68
|
+
if (!!config.AUTH0_ACCESS_TOKEN)
|
|
69
|
+
return config.AUTH0_ACCESS_TOKEN;
|
|
70
|
+
const authClient = new auth0_1.AuthenticationClient({
|
|
61
71
|
domain: config.AUTH0_DOMAIN,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
headers: {
|
|
65
|
-
'User-agent': `deploy-cli/${package_json_1.version} (node.js/${process.version.replace('v', '')})`
|
|
66
|
-
}
|
|
72
|
+
clientId: config.AUTH0_CLIENT_ID,
|
|
73
|
+
clientSecret: config.AUTH0_CLIENT_SECRET,
|
|
67
74
|
});
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
const clientCredentials = yield authClient.clientCredentialsGrant({
|
|
76
|
+
audience: config.AUTH0_AUDIENCE
|
|
77
|
+
? config.AUTH0_AUDIENCE
|
|
78
|
+
: `https://${config.AUTH0_DOMAIN}/api/v2/`,
|
|
79
|
+
});
|
|
80
|
+
return clientCredentials.access_token;
|
|
81
|
+
}))();
|
|
82
|
+
const mgmtClient = new auth0_1.ManagementClient({
|
|
83
|
+
domain: config.AUTH0_DOMAIN,
|
|
84
|
+
token: accessToken,
|
|
85
|
+
retry: { maxRetries: config.AUTH0_API_MAX_RETRIES || 10, enabled: true },
|
|
86
|
+
headers: {
|
|
87
|
+
'User-agent': `deploy-cli/${packageVersion} (node.js/${process.version.replace('v', '')})`,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
const inputFile = config.AUTH0_INPUT_FILE;
|
|
91
|
+
const ensureObject = (key, value) => {
|
|
92
|
+
if (typeof value === 'string') {
|
|
93
|
+
try {
|
|
94
|
+
return JSON.parse(value);
|
|
78
95
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (config[key]) {
|
|
83
|
-
config[key] = ensureObject(key, config[key]);
|
|
96
|
+
catch (e) {
|
|
97
|
+
logger_1.default.debug(`Cannot convert config.${key} to an object. Error: ${e.message}`);
|
|
98
|
+
return value;
|
|
84
99
|
}
|
|
85
|
-
});
|
|
86
|
-
if (typeof inputFile === 'object') {
|
|
87
|
-
return new yaml_1.default(config, mgmtClient);
|
|
88
|
-
}
|
|
89
|
-
if ((0, utils_1.isDirectory)(inputFile)) {
|
|
90
|
-
return new directory_1.default(config, mgmtClient);
|
|
91
100
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
101
|
+
return value;
|
|
102
|
+
};
|
|
103
|
+
nonPrimitiveProps.forEach((key) => {
|
|
104
|
+
if (config[key]) {
|
|
105
|
+
//@ts-ignore because this method of config overwriting technically functions
|
|
106
|
+
config[key] = ensureObject(key, config[key]);
|
|
95
107
|
}
|
|
96
|
-
throw new Error(`Unable to determine context processor to load for file ${inputFile}, does it exist? `);
|
|
97
108
|
});
|
|
98
|
-
|
|
99
|
-
|
|
109
|
+
if (typeof inputFile === 'object') {
|
|
110
|
+
return new yaml_1.default(config, mgmtClient);
|
|
111
|
+
}
|
|
112
|
+
if ((0, utils_1.isDirectory)(inputFile)) {
|
|
113
|
+
return new directory_1.default(config, mgmtClient);
|
|
114
|
+
}
|
|
115
|
+
const ext = path_1.default.extname(inputFile);
|
|
116
|
+
if (ext === '.yaml' || ext === '.yml') {
|
|
117
|
+
return new yaml_1.default(config, mgmtClient);
|
|
118
|
+
}
|
|
119
|
+
throw new Error(`Unable to determine context processor to load for file ${inputFile}, does it exist? `);
|
|
120
|
+
});
|
|
121
|
+
exports.setupContext = setupContext;
|
|
@@ -20,18 +20,20 @@ const utils_1 = require("../../../utils");
|
|
|
20
20
|
const logger_1 = __importDefault(require("../../../logger"));
|
|
21
21
|
function parseCode(context, code) {
|
|
22
22
|
if (code) {
|
|
23
|
+
//@ts-ignore TODO: understand why two arguments are passed when context.loadFile only accepts one
|
|
23
24
|
return context.loadFile(code, tools_1.constants.ACTIONS_DIRECTORY);
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
function parse(context) {
|
|
27
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
29
|
// Load the script file for each action
|
|
30
|
+
//@ts-ignore TODO: understand if empty array is intentionally being returned
|
|
29
31
|
if (!context.assets.actions)
|
|
30
32
|
return [];
|
|
31
33
|
const actions = {
|
|
32
34
|
actions: [
|
|
33
|
-
...context.assets.actions.map((action) => (Object.assign(Object.assign({}, action), { code: parseCode(context, action.code) })))
|
|
34
|
-
]
|
|
35
|
+
...context.assets.actions.map((action) => (Object.assign(Object.assign({}, action), { code: parseCode(context, action.code) }))),
|
|
36
|
+
],
|
|
35
37
|
};
|
|
36
38
|
return actions;
|
|
37
39
|
});
|
|
@@ -58,24 +60,26 @@ function mapActionCode(basePath, action) {
|
|
|
58
60
|
function dump(context) {
|
|
59
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
62
|
const { actions } = context.assets;
|
|
61
|
-
|
|
63
|
+
//@ts-ignore TODO: need to investigate why returning void here when other handlers do not
|
|
62
64
|
if (!actions)
|
|
63
|
-
return;
|
|
65
|
+
return; // Nothing to do
|
|
64
66
|
return {
|
|
65
67
|
actions: actions.map((action) => ({
|
|
66
68
|
name: action.name,
|
|
67
69
|
deployed: action.deployed || action.all_changes_deployed,
|
|
70
|
+
//@ts-ignore because Action resource needs to be typed more accurately
|
|
68
71
|
code: mapActionCode(context.basePath, action),
|
|
69
72
|
runtime: action.runtime,
|
|
70
73
|
dependencies: action.dependencies || [],
|
|
71
74
|
status: action.status,
|
|
72
75
|
secrets: mapSecrets(action.secrets),
|
|
73
|
-
supported_triggers: action.supported_triggers
|
|
74
|
-
}))
|
|
76
|
+
supported_triggers: action.supported_triggers,
|
|
77
|
+
})),
|
|
75
78
|
};
|
|
76
79
|
});
|
|
77
80
|
}
|
|
78
|
-
|
|
81
|
+
const ActionsHandler = {
|
|
79
82
|
parse,
|
|
80
|
-
dump
|
|
83
|
+
dump,
|
|
81
84
|
};
|
|
85
|
+
exports.default = ActionsHandler;
|
|
@@ -9,21 +9,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
function
|
|
12
|
+
function parseAndDump(context) {
|
|
13
13
|
return __awaiter(this, void 0, void 0, function* () {
|
|
14
14
|
return {
|
|
15
|
-
attackProtection: context.assets.attackProtection || {}
|
|
15
|
+
attackProtection: context.assets.attackProtection || {},
|
|
16
16
|
};
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
attackProtection: context.assets.attackProtection || {}
|
|
23
|
-
};
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
exports.default = {
|
|
27
|
-
parse,
|
|
28
|
-
dump
|
|
19
|
+
const attackProtectionHandler = {
|
|
20
|
+
parse: parseAndDump,
|
|
21
|
+
dump: parseAndDump,
|
|
29
22
|
};
|
|
23
|
+
exports.default = attackProtectionHandler;
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
function parse(context) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
// Load the HTML file for each page
|
|
21
|
+
const { branding } = context.assets;
|
|
22
|
+
if (!branding || !branding.templates)
|
|
23
|
+
return { branding };
|
|
24
|
+
const templates = branding.templates.map((templateDefinition) => {
|
|
25
|
+
const markupFile = path_1.default.join(templateDefinition.body);
|
|
26
|
+
return {
|
|
27
|
+
template: templateDefinition.template,
|
|
28
|
+
body: (0, tools_1.loadFileAndReplaceKeywords)(markupFile, context.mappings),
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
branding: Object.assign(Object.assign({}, branding), { templates }),
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function dump(context) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const { branding } = context.assets || { branding: undefined };
|
|
39
|
+
branding.templates = branding.templates || [];
|
|
40
|
+
// create templates folder
|
|
41
|
+
if (branding.templates.length) {
|
|
42
|
+
const brandingTemplatesFolder = path_1.default.join(context.basePath, tools_1.constants.BRANDING_TEMPLATES_YAML_DIRECTORY);
|
|
43
|
+
fs_extra_1.default.ensureDirSync(brandingTemplatesFolder);
|
|
44
|
+
branding.templates = branding.templates.map((templateDefinition) => {
|
|
45
|
+
const file = `${templateDefinition.template}.html`;
|
|
46
|
+
const templateMarkupFile = path_1.default.join(brandingTemplatesFolder, file);
|
|
47
|
+
const markup = templateDefinition.body;
|
|
48
|
+
try {
|
|
49
|
+
fs_extra_1.default.writeFileSync(templateMarkupFile, markup);
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
throw new Error(`Error writing template file: ${templateDefinition.template}, because: ${e.message}`);
|
|
53
|
+
}
|
|
54
|
+
// save the location as relative file.
|
|
55
|
+
templateDefinition.body = `.${path_1.default.sep}${path_1.default.join(tools_1.constants.BRANDING_TEMPLATES_YAML_DIRECTORY, file)}`;
|
|
56
|
+
return templateDefinition;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return { branding };
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const brandingHandler = {
|
|
63
|
+
parse,
|
|
64
|
+
dump,
|
|
65
|
+
};
|
|
66
|
+
exports.default = brandingHandler;
|
|
@@ -14,7 +14,7 @@ function parse(context) {
|
|
|
14
14
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
15
|
// nothing to do, set default empty
|
|
16
16
|
return {
|
|
17
|
-
clientGrants: context.assets.clientGrants
|
|
17
|
+
clientGrants: context.assets.clientGrants,
|
|
18
18
|
};
|
|
19
19
|
});
|
|
20
20
|
}
|
|
@@ -30,11 +30,12 @@ function dump(context) {
|
|
|
30
30
|
const dumpGrant = Object.assign({}, grant);
|
|
31
31
|
dumpGrant.client_id = (0, utils_1.convertClientIdToName)(dumpGrant.client_id, context.assets.clients);
|
|
32
32
|
return dumpGrant;
|
|
33
|
-
})
|
|
33
|
+
}),
|
|
34
34
|
};
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
const clientGrantsHandler = {
|
|
38
38
|
parse,
|
|
39
|
-
dump
|
|
39
|
+
dump,
|
|
40
40
|
};
|
|
41
|
+
exports.default = clientGrantsHandler;
|
|
@@ -35,8 +35,8 @@ function parse(context) {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
return client;
|
|
38
|
-
})
|
|
39
|
-
]
|
|
38
|
+
}),
|
|
39
|
+
],
|
|
40
40
|
};
|
|
41
41
|
});
|
|
42
42
|
}
|
|
@@ -45,7 +45,8 @@ function dump(context) {
|
|
|
45
45
|
// Save custom_login_page to a separate html file
|
|
46
46
|
const clientsFolder = path_1.default.join(context.basePath, tools_1.constants.CLIENTS_DIRECTORY);
|
|
47
47
|
return {
|
|
48
|
-
clients: [
|
|
48
|
+
clients: [
|
|
49
|
+
...context.assets.clients.map((client) => {
|
|
49
50
|
if (client.custom_login_page) {
|
|
50
51
|
const clientName = (0, utils_1.sanitize)(client.name);
|
|
51
52
|
const html = client.custom_login_page;
|
|
@@ -56,11 +57,13 @@ function dump(context) {
|
|
|
56
57
|
client.custom_login_page = `./${clientName}_custom_login_page.html`;
|
|
57
58
|
}
|
|
58
59
|
return (0, utils_1.clearClientArrays)(client);
|
|
59
|
-
})
|
|
60
|
+
}),
|
|
61
|
+
],
|
|
60
62
|
};
|
|
61
63
|
});
|
|
62
64
|
}
|
|
63
|
-
|
|
65
|
+
const clientsHandler = {
|
|
64
66
|
parse,
|
|
65
|
-
dump
|
|
67
|
+
dump,
|
|
66
68
|
};
|
|
69
|
+
exports.default = clientsHandler;
|
|
@@ -36,15 +36,15 @@ function parse(context) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
return connection;
|
|
39
|
-
})
|
|
40
|
-
]
|
|
39
|
+
}),
|
|
40
|
+
],
|
|
41
41
|
};
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
const getFormattedOptions = (connection, clients) => {
|
|
45
45
|
try {
|
|
46
46
|
return {
|
|
47
|
-
options: Object.assign(Object.assign({}, connection.options), { idpinitiated: Object.assign(Object.assign({}, connection.options.idpinitiated), { client_id: (0, utils_1.convertClientIdToName)(connection.options.idpinitiated.client_id, clients) }) })
|
|
47
|
+
options: Object.assign(Object.assign({}, connection.options), { idpinitiated: Object.assign(Object.assign({}, connection.options.idpinitiated), { client_id: (0, utils_1.convertClientIdToName)(connection.options.idpinitiated.client_id, clients) }) }),
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
catch (e) {
|
|
@@ -60,7 +60,9 @@ function dump(context) {
|
|
|
60
60
|
// nothing to do, set default if empty
|
|
61
61
|
return {
|
|
62
62
|
connections: connections.map((connection) => {
|
|
63
|
-
const dumpedConnection = Object.assign(Object.assign(Object.assign({}, connection), getFormattedOptions(connection, context.assets.clients)), (connection.enabled_clients && {
|
|
63
|
+
const dumpedConnection = Object.assign(Object.assign(Object.assign({}, connection), getFormattedOptions(connection, context.assets.clients)), (connection.enabled_clients && {
|
|
64
|
+
enabled_clients: (0, utils_1.mapClientID2NameSorted)(connection.enabled_clients, context.assets.clients),
|
|
65
|
+
}));
|
|
64
66
|
if (dumpedConnection.strategy === 'email') {
|
|
65
67
|
(0, utils_1.ensureProp)(connection, 'options.email.body');
|
|
66
68
|
const connectionsFolder = path_1.default.join(context.basePath, tools_1.constants.CONNECTIONS_DIRECTORY);
|
|
@@ -73,11 +75,12 @@ function dump(context) {
|
|
|
73
75
|
dumpedConnection.options.email.body = `./${connectionName}.html`;
|
|
74
76
|
}
|
|
75
77
|
return dumpedConnection;
|
|
76
|
-
})
|
|
78
|
+
}),
|
|
77
79
|
};
|
|
78
80
|
});
|
|
79
81
|
}
|
|
80
|
-
|
|
82
|
+
const connectionsHandler = {
|
|
81
83
|
parse,
|
|
82
|
-
dump
|
|
84
|
+
dump,
|
|
83
85
|
};
|
|
86
|
+
exports.default = connectionsHandler;
|
|
@@ -24,9 +24,9 @@ function parse(context) {
|
|
|
24
24
|
return {
|
|
25
25
|
databases: [
|
|
26
26
|
...context.assets.databases.map((database) => (Object.assign(Object.assign({}, database), { options: Object.assign(Object.assign({}, database.options), (database.options.customScripts && {
|
|
27
|
-
customScripts: Object.entries(database.options.customScripts).reduce((scripts, [name, script]) => (Object.assign(Object.assign({}, scripts), { [name]: context.loadFile(script) })), {})
|
|
28
|
-
})) })))
|
|
29
|
-
]
|
|
27
|
+
customScripts: Object.entries(database.options.customScripts).reduce((scripts, [name, script]) => (Object.assign(Object.assign({}, scripts), { [name]: context.loadFile(script) })), {}),
|
|
28
|
+
})) }))),
|
|
29
|
+
],
|
|
30
30
|
};
|
|
31
31
|
});
|
|
32
32
|
}
|
|
@@ -43,8 +43,12 @@ function dump(context) {
|
|
|
43
43
|
};
|
|
44
44
|
return {
|
|
45
45
|
databases: [
|
|
46
|
-
...databases.map((database) => (Object.assign(Object.assign(Object.assign({}, database), (database.enabled_clients && {
|
|
47
|
-
|
|
46
|
+
...databases.map((database) => (Object.assign(Object.assign(Object.assign({}, database), (database.enabled_clients && {
|
|
47
|
+
enabled_clients: (0, utils_1.mapClientID2NameSorted)(database.enabled_clients, context.assets.clients),
|
|
48
|
+
})), { options: Object.assign(Object.assign({}, database.options), (database.options.customScripts && {
|
|
49
|
+
customScripts: Object.entries(database.options.customScripts)
|
|
50
|
+
.sort(sortCustomScripts)
|
|
51
|
+
.reduce((scripts, [name, script]) => {
|
|
48
52
|
// Create Database folder
|
|
49
53
|
const dbName = (0, utils_1.sanitize)(database.name);
|
|
50
54
|
const dbFolder = path_1.default.join(context.basePath, 'databases', (0, utils_1.sanitize)(dbName));
|
|
@@ -56,13 +60,14 @@ function dump(context) {
|
|
|
56
60
|
fs_extra_1.default.writeFileSync(scriptFile, script);
|
|
57
61
|
scripts[name] = `./databases/${dbName}/${scriptName}.js`;
|
|
58
62
|
return scripts;
|
|
59
|
-
}, {})
|
|
60
|
-
})) })))
|
|
61
|
-
]
|
|
63
|
+
}, {}),
|
|
64
|
+
})) }))),
|
|
65
|
+
],
|
|
62
66
|
};
|
|
63
67
|
});
|
|
64
68
|
}
|
|
65
|
-
|
|
69
|
+
const databasesHandler = {
|
|
66
70
|
parse,
|
|
67
|
-
dump
|
|
71
|
+
dump,
|
|
68
72
|
};
|
|
73
|
+
exports.default = databasesHandler;
|
|
@@ -14,24 +14,26 @@ function parse(context) {
|
|
|
14
14
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
15
|
// nothing to do, set default if empty
|
|
16
16
|
return {
|
|
17
|
-
emailProvider: Object.assign({}, context.assets.emailProvider || {})
|
|
17
|
+
emailProvider: Object.assign({}, (context.assets.emailProvider || {})),
|
|
18
18
|
};
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
function dump(context) {
|
|
22
|
+
var _a;
|
|
22
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
24
|
let { emailProvider } = context.assets;
|
|
24
|
-
const excludedDefaults = context.assets.exclude.defaults || [];
|
|
25
|
+
const excludedDefaults = ((_a = context.assets.exclude) === null || _a === void 0 ? void 0 : _a.defaults) || [];
|
|
25
26
|
if (emailProvider && !excludedDefaults.includes('emailProvider')) {
|
|
26
27
|
// Add placeholder for credentials as they cannot be exported
|
|
27
28
|
emailProvider = (0, defaults_1.emailProviderDefaults)(emailProvider);
|
|
28
29
|
}
|
|
29
30
|
return {
|
|
30
|
-
emailProvider: emailProvider || {}
|
|
31
|
+
emailProvider: emailProvider || {},
|
|
31
32
|
};
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
|
-
|
|
35
|
+
const emailProviderHandler = {
|
|
35
36
|
parse,
|
|
36
|
-
dump
|
|
37
|
+
dump,
|
|
37
38
|
};
|
|
39
|
+
exports.default = emailProviderHandler;
|
|
@@ -21,14 +21,14 @@ function parse(context) {
|
|
|
21
21
|
const emailTemplates = context.assets.emailTemplates || [];
|
|
22
22
|
return {
|
|
23
23
|
emailTemplates: [
|
|
24
|
-
...emailTemplates.map((et) => (Object.assign(Object.assign({}, et), { body: context.loadFile(et.body) })))
|
|
25
|
-
]
|
|
24
|
+
...emailTemplates.map((et) => (Object.assign(Object.assign({}, et), { body: context.loadFile(et.body) }))),
|
|
25
|
+
],
|
|
26
26
|
};
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
function dump(context) {
|
|
30
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
let emailTemplates = [...context.assets.emailTemplates || []];
|
|
31
|
+
let emailTemplates = [...(context.assets.emailTemplates || [])];
|
|
32
32
|
if (emailTemplates.length > 0) {
|
|
33
33
|
// Create Templates folder
|
|
34
34
|
const templatesFolder = path_1.default.join(context.basePath, 'emailTemplates');
|
|
@@ -44,7 +44,8 @@ function dump(context) {
|
|
|
44
44
|
return { emailTemplates };
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
const emailTemplatesHandler = {
|
|
48
48
|
parse,
|
|
49
|
-
dump
|
|
49
|
+
dump,
|
|
50
50
|
};
|
|
51
|
+
exports.default = emailTemplatesHandler;
|
|
@@ -9,23 +9,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
function
|
|
13
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
-
// nothing to do, set default if empty
|
|
15
|
-
return {
|
|
16
|
-
guardianFactorProviders: [...context.assets.guardianFactorProviders || []]
|
|
17
|
-
};
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
function dump(context) {
|
|
12
|
+
function parseAndDump(context) {
|
|
21
13
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
14
|
// nothing to do, set default empty
|
|
23
15
|
return {
|
|
24
|
-
guardianFactorProviders: [...context.assets.guardianFactorProviders || []]
|
|
16
|
+
guardianFactorProviders: [...(context.assets.guardianFactorProviders || [])],
|
|
25
17
|
};
|
|
26
18
|
});
|
|
27
19
|
}
|
|
28
|
-
|
|
29
|
-
parse,
|
|
30
|
-
dump
|
|
20
|
+
const guardianFactorProvidersHandler = {
|
|
21
|
+
parse: parseAndDump,
|
|
22
|
+
dump: parseAndDump,
|
|
31
23
|
};
|
|
24
|
+
exports.default = guardianFactorProvidersHandler;
|
|
@@ -9,23 +9,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
function
|
|
12
|
+
function parseAndDump(context) {
|
|
13
13
|
return __awaiter(this, void 0, void 0, function* () {
|
|
14
14
|
// nothing to do, set default if empty
|
|
15
15
|
return {
|
|
16
|
-
guardianFactorTemplates: [...context.assets.guardianFactorTemplates || []]
|
|
16
|
+
guardianFactorTemplates: [...(context.assets.guardianFactorTemplates || [])],
|
|
17
17
|
};
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return {
|
|
24
|
-
guardianFactorTemplates: [...context.assets.guardianFactorTemplates || []]
|
|
25
|
-
};
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
exports.default = {
|
|
29
|
-
parse,
|
|
30
|
-
dump
|
|
20
|
+
const guardianFactorTemplatesHandler = {
|
|
21
|
+
parse: parseAndDump,
|
|
22
|
+
dump: parseAndDump,
|
|
31
23
|
};
|
|
24
|
+
exports.default = guardianFactorTemplatesHandler;
|
|
@@ -9,23 +9,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
function
|
|
12
|
+
function parseAndDump(context) {
|
|
13
13
|
return __awaiter(this, void 0, void 0, function* () {
|
|
14
14
|
// nothing to do, set default if empty
|
|
15
15
|
return {
|
|
16
|
-
guardianFactors: [...context.assets.guardianFactors || []]
|
|
16
|
+
guardianFactors: [...(context.assets.guardianFactors || [])],
|
|
17
17
|
};
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return {
|
|
24
|
-
guardianFactors: [...context.assets.guardianFactors || []]
|
|
25
|
-
};
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
exports.default = {
|
|
29
|
-
parse,
|
|
30
|
-
dump
|
|
20
|
+
const guardianFactorsHandler = {
|
|
21
|
+
parse: parseAndDump,
|
|
22
|
+
dump: parseAndDump,
|
|
31
23
|
};
|
|
24
|
+
exports.default = guardianFactorsHandler;
|