auth0-deploy-cli 7.3.6 → 7.5.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/.circleci/config.yml +15 -0
- package/.github/CODEOWNERS +1 -0
- package/.husky/pre-commit +6 -0
- package/.husky/pre-push +4 -0
- package/.nyc_output/60b76a45-577b-4171-9982-a8e836ab7fd6.json +1 -0
- package/.nyc_output/processinfo/60b76a45-577b-4171-9982-a8e836ab7fd6.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/CHANGELOG.md +35 -2
- package/lib/args.js +89 -81
- package/lib/commands/export.js +51 -77
- package/lib/commands/import.js +45 -69
- package/lib/commands/index.js +11 -20
- package/lib/configFactory.js +19 -27
- package/lib/context/defaults.js +18 -41
- package/lib/context/directory/handlers/actions.js +77 -107
- package/lib/context/directory/handlers/attackProtection.js +59 -0
- package/lib/context/directory/handlers/clientGrants.js +45 -54
- package/lib/context/directory/handlers/clients.js +60 -79
- package/lib/context/directory/handlers/connections.js +65 -89
- package/lib/context/directory/handlers/databases.js +91 -123
- package/lib/context/directory/handlers/emailProvider.js +46 -57
- package/lib/context/directory/handlers/emailTemplates.js +67 -80
- package/lib/context/directory/handlers/guardianFactorProviders.js +41 -49
- package/lib/context/directory/handlers/guardianFactorTemplates.js +41 -49
- package/lib/context/directory/handlers/guardianFactors.js +41 -49
- package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.js +40 -50
- package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.js +40 -50
- package/lib/context/directory/handlers/guardianPolicies.js +40 -50
- package/lib/context/directory/handlers/hooks.js +55 -70
- package/lib/context/directory/handlers/index.js +53 -123
- package/lib/context/directory/handlers/migrations.js +36 -41
- package/lib/context/directory/handlers/organizations.js +54 -69
- package/lib/context/directory/handlers/pages.js +72 -86
- package/lib/context/directory/handlers/resourceServers.js +41 -49
- package/lib/context/directory/handlers/roles.js +49 -62
- package/lib/context/directory/handlers/rules.js +52 -68
- package/lib/context/directory/handlers/rulesConfigs.js +33 -32
- package/lib/context/directory/handlers/tenant.js +52 -47
- package/lib/context/directory/handlers/triggers.js +39 -54
- package/lib/context/directory/index.js +113 -101
- package/lib/context/index.js +96 -105
- package/lib/context/yaml/handlers/actions.js +71 -88
- package/lib/context/yaml/handlers/attackProtection.js +29 -0
- package/lib/context/yaml/handlers/clientGrants.js +36 -29
- package/lib/context/yaml/handlers/clients.js +61 -76
- package/lib/context/yaml/handlers/connections.js +76 -103
- package/lib/context/yaml/handlers/databases.js +64 -79
- package/lib/context/yaml/handlers/emailProvider.js +33 -30
- package/lib/context/yaml/handlers/emailTemplates.js +45 -54
- package/lib/context/yaml/handlers/guardianFactorProviders.js +27 -18
- package/lib/context/yaml/handlers/guardianFactorTemplates.js +27 -18
- package/lib/context/yaml/handlers/guardianFactors.js +27 -18
- package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.js +27 -20
- package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.js +27 -20
- package/lib/context/yaml/handlers/guardianPolicies.js +27 -20
- package/lib/context/yaml/handlers/hooks.js +57 -67
- package/lib/context/yaml/handlers/index.js +53 -123
- package/lib/context/yaml/handlers/migrations.js +23 -24
- package/lib/context/yaml/handlers/organizations.js +40 -38
- package/lib/context/yaml/handlers/pages.js +49 -58
- package/lib/context/yaml/handlers/resourceServers.js +27 -18
- package/lib/context/yaml/handlers/roles.js +34 -24
- package/lib/context/yaml/handlers/rules.js +48 -58
- package/lib/context/yaml/handlers/rulesConfigs.js +27 -18
- package/lib/context/yaml/handlers/tenant.js +44 -30
- package/lib/context/yaml/handlers/triggers.js +32 -23
- package/lib/context/yaml/index.js +127 -142
- package/lib/index.js +73 -79
- package/lib/logger.js +18 -22
- package/lib/readonly.js +74 -66
- package/lib/tools/ValidationError.js +8 -13
- package/lib/tools/auth0/client.js +143 -133
- package/lib/tools/auth0/handlers/actions.js +231 -241
- package/lib/tools/auth0/handlers/attackProtection.js +86 -0
- package/lib/tools/auth0/handlers/branding.js +47 -46
- package/lib/tools/auth0/handlers/clientGrants.js +118 -116
- package/lib/tools/auth0/handlers/clients.js +72 -90
- package/lib/tools/auth0/handlers/connections.js +150 -118
- package/lib/tools/auth0/handlers/databases.js +127 -124
- package/lib/tools/auth0/handlers/default.js +186 -189
- package/lib/tools/auth0/handlers/emailProvider.js +67 -78
- package/lib/tools/auth0/handlers/emailTemplates.js +116 -92
- package/lib/tools/auth0/handlers/guardianFactorProviders.js +66 -81
- package/lib/tools/auth0/handlers/guardianFactorTemplates.js +60 -71
- package/lib/tools/auth0/handlers/guardianFactors.js +56 -63
- package/lib/tools/auth0/handlers/guardianPhoneFactorMessageTypes.js +80 -79
- package/lib/tools/auth0/handlers/guardianPhoneFactorSelectedProvider.js +77 -76
- package/lib/tools/auth0/handlers/guardianPolicies.js +59 -62
- package/lib/tools/auth0/handlers/hooks.js +201 -227
- package/lib/tools/auth0/handlers/index.js +53 -111
- package/lib/tools/auth0/handlers/migrations.js +99 -79
- package/lib/tools/auth0/handlers/organizations.js +225 -247
- package/lib/tools/auth0/handlers/pages.js +116 -154
- package/lib/tools/auth0/handlers/prompts.js +47 -46
- package/lib/tools/auth0/handlers/resourceServers.js +88 -112
- package/lib/tools/auth0/handlers/roles.js +203 -220
- package/lib/tools/auth0/handlers/rules.js +168 -189
- package/lib/tools/auth0/handlers/rulesConfigs.js +54 -63
- package/lib/tools/auth0/handlers/tenant.js +88 -64
- package/lib/tools/auth0/handlers/triggers.js +126 -126
- package/lib/tools/auth0/index.js +92 -85
- package/lib/tools/auth0/schema.js +39 -31
- package/lib/tools/constants.js +111 -21
- package/lib/tools/deploy.js +35 -32
- package/lib/tools/index.js +19 -32
- package/lib/tools/logger.js +11 -12
- package/lib/tools/utils.js +258 -254
- package/lib/utils.js +167 -190
- package/package.json +6 -3
- package/tsconfig.json +96 -0
- package/typescript-migration-progress.sh +22 -0
- package/.nyc_output/8cf4dd0c-1f3a-4ac1-899c-8e453a64221e.json +0 -1
- package/.nyc_output/processinfo/8cf4dd0c-1f3a-4ac1-899c-8e453a64221e.json +0 -1
|
@@ -1,52 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const path_1 = __importDefault(require("path"));
|
|
27
|
+
const utils_1 = require("../../../utils");
|
|
15
28
|
function parse(context) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
tenant: Object.assign(tenant, session_lifetime && (0, _utils.hoursAsInteger)('session_lifetime', session_lifetime), idle_session_lifetime && (0, _utils.hoursAsInteger)('idle_session_lifetime', idle_session_lifetime))
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return {};
|
|
29
|
+
const baseFolder = path_1.default.join(context.filePath);
|
|
30
|
+
if (!(0, utils_1.existsMustBeDir)(baseFolder))
|
|
31
|
+
return {}; // Skip
|
|
32
|
+
const tenantFile = path_1.default.join(baseFolder, 'tenant.json');
|
|
33
|
+
if ((0, utils_1.isFile)(tenantFile)) {
|
|
34
|
+
/* eslint-disable camelcase */
|
|
35
|
+
const _a = (0, utils_1.loadJSON)(tenantFile, context.mappings), { session_lifetime, idle_session_lifetime } = _a, tenant = __rest(_a, ["session_lifetime", "idle_session_lifetime"]);
|
|
36
|
+
(0, utils_1.clearTenantFlags)(tenant);
|
|
37
|
+
return {
|
|
38
|
+
tenant: Object.assign(tenant, session_lifetime && (0, utils_1.hoursAsInteger)('session_lifetime', session_lifetime), idle_session_lifetime && (0, utils_1.hoursAsInteger)('idle_session_lifetime', idle_session_lifetime))
|
|
39
|
+
};
|
|
40
|
+
/* eslint-enable camelcase */
|
|
41
|
+
}
|
|
42
|
+
return {};
|
|
35
43
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
(0, _utils.dumpJSON)(tenantFile, tenant);
|
|
44
|
+
function dump(context) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
const { tenant } = context.assets;
|
|
47
|
+
if (!tenant)
|
|
48
|
+
return; // Skip, nothing to dump
|
|
49
|
+
(0, utils_1.clearTenantFlags)(tenant);
|
|
50
|
+
const tenantFile = path_1.default.join(context.filePath, 'tenant.json');
|
|
51
|
+
(0, utils_1.dumpJSON)(tenantFile, tenant);
|
|
52
|
+
});
|
|
47
53
|
}
|
|
48
|
-
|
|
49
54
|
exports.default = {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
};
|
|
55
|
+
parse,
|
|
56
|
+
dump
|
|
57
|
+
};
|
|
@@ -1,59 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var _logger2 = _interopRequireDefault(_logger);
|
|
22
|
-
|
|
23
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
-
|
|
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
|
+
const logger_1 = __importDefault(require("../../../logger"));
|
|
25
20
|
function parse(context) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const triggers = { ...(0, _utils.loadJSON)(files[0], context.mappings)
|
|
33
|
-
};
|
|
34
|
-
return {
|
|
35
|
-
triggers
|
|
36
|
-
};
|
|
21
|
+
const triggersFolder = path_1.default.join(context.filePath, tools_1.constants.TRIGGERS_DIRECTORY);
|
|
22
|
+
if (!(0, utils_1.existsMustBeDir)(triggersFolder))
|
|
23
|
+
return { triggers: undefined }; // Skip
|
|
24
|
+
const files = (0, utils_1.getFiles)(triggersFolder, ['.json']);
|
|
25
|
+
const triggers = Object.assign({}, (0, utils_1.loadJSON)(files[0], context.mappings));
|
|
26
|
+
return { triggers };
|
|
37
27
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
_logger2.default.info(`Writing ${triggerFile}`);
|
|
52
|
-
|
|
53
|
-
_fsExtra2.default.writeFileSync(triggerFile, JSON.stringify(triggers, null, 2));
|
|
28
|
+
function dump(context) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const { triggers } = context.assets;
|
|
31
|
+
if (!triggers)
|
|
32
|
+
return;
|
|
33
|
+
// Create triggers folder
|
|
34
|
+
const triggersFolder = path_1.default.join(context.filePath, tools_1.constants.TRIGGERS_DIRECTORY);
|
|
35
|
+
fs_extra_1.default.ensureDirSync(triggersFolder);
|
|
36
|
+
const triggerFile = path_1.default.join(triggersFolder, 'triggers.json');
|
|
37
|
+
logger_1.default.info(`Writing ${triggerFile}`);
|
|
38
|
+
fs_extra_1.default.writeFileSync(triggerFile, JSON.stringify(triggers, null, 2));
|
|
39
|
+
});
|
|
54
40
|
}
|
|
55
|
-
|
|
56
41
|
exports.default = {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
};
|
|
42
|
+
parse,
|
|
43
|
+
dump
|
|
44
|
+
};
|
|
@@ -1,107 +1,119 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
5
17
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const tools_1 = require("../../tools");
|
|
40
|
+
const readonly_1 = __importDefault(require("../../readonly"));
|
|
41
|
+
const logger_1 = __importDefault(require("../../logger"));
|
|
42
|
+
const handlers_1 = __importDefault(require("./handlers"));
|
|
43
|
+
const utils_1 = require("../../utils");
|
|
44
|
+
class default_1 {
|
|
45
|
+
constructor(config, mgmtClient) {
|
|
46
|
+
this.filePath = config.AUTH0_INPUT_FILE;
|
|
47
|
+
this.config = config;
|
|
48
|
+
this.mappings = config.AUTH0_KEYWORD_REPLACE_MAPPINGS;
|
|
49
|
+
this.mgmtClient = mgmtClient;
|
|
50
|
+
// Get excluded rules
|
|
51
|
+
this.assets = {
|
|
52
|
+
exclude: {
|
|
53
|
+
rules: config.AUTH0_EXCLUDED_RULES || [],
|
|
54
|
+
clients: config.AUTH0_EXCLUDED_CLIENTS || [],
|
|
55
|
+
databases: config.AUTH0_EXCLUDED_DATABASES || [],
|
|
56
|
+
connections: config.AUTH0_EXCLUDED_CONNECTIONS || [],
|
|
57
|
+
resourceServers: config.AUTH0_EXCLUDED_RESOURCE_SERVERS || [],
|
|
58
|
+
defaults: config.AUTH0_EXCLUDED_DEFAULTS || []
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
loadFile(f, folder) {
|
|
63
|
+
const basePath = path.join(this.filePath, folder);
|
|
64
|
+
let toLoad = path.join(basePath, f);
|
|
65
|
+
if (!(0, utils_1.isFile)(toLoad)) {
|
|
66
|
+
// try load not relative to yaml file
|
|
67
|
+
toLoad = f;
|
|
68
|
+
}
|
|
69
|
+
return (0, tools_1.loadFileAndReplaceKeywords)(toLoad, this.mappings);
|
|
57
70
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
load() {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
if ((0, utils_1.isDirectory)(this.filePath)) {
|
|
74
|
+
/* If this is a directory, look for each file in the directory */
|
|
75
|
+
logger_1.default.info(`Processing directory ${this.filePath}`);
|
|
76
|
+
Object.values(handlers_1.default)
|
|
77
|
+
.forEach((handler) => {
|
|
78
|
+
const parsed = handler.parse(this);
|
|
79
|
+
Object.entries(parsed)
|
|
80
|
+
.forEach(([k, v]) => {
|
|
81
|
+
this.assets[k] = v;
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
throw new Error(`Not sure what to do with, ${this.filePath} as it is not a directory...`);
|
|
70
87
|
});
|
|
71
|
-
});
|
|
72
|
-
return;
|
|
73
88
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
dump() {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
const auth0 = new tools_1.Auth0(this.mgmtClient, this.assets, (0, utils_1.toConfigFn)(this.config));
|
|
92
|
+
logger_1.default.info('Loading Auth0 Tenant Data');
|
|
93
|
+
yield auth0.loadAll();
|
|
94
|
+
this.assets = auth0.assets;
|
|
95
|
+
// Clean known read only fields
|
|
96
|
+
this.assets = (0, readonly_1.default)(this.assets, this.config);
|
|
97
|
+
// Copy clients to be used by handlers which require converting client_id to the name
|
|
98
|
+
// Must copy as the client_id will be stripped if AUTH0_EXPORT_IDENTIFIERS is false
|
|
99
|
+
this.assets.clientsOrig = [...this.assets.clients];
|
|
100
|
+
// Optionally Strip identifiers
|
|
101
|
+
if (!this.config.AUTH0_EXPORT_IDENTIFIERS) {
|
|
102
|
+
this.assets = (0, utils_1.stripIdentifiers)(auth0, this.assets);
|
|
103
|
+
}
|
|
104
|
+
yield Promise.all(Object.entries(handlers_1.default).map(([name, handler]) => __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
try {
|
|
106
|
+
const data = yield handler.dump(this);
|
|
107
|
+
if (data) {
|
|
108
|
+
logger_1.default.info(`Exporting ${name}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
logger_1.default.debug(err.stack);
|
|
113
|
+
throw new Error(`Problem exporting ${name}`);
|
|
114
|
+
}
|
|
115
|
+
})));
|
|
116
|
+
});
|
|
90
117
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
try {
|
|
94
|
-
const data = await handler.dump(this);
|
|
95
|
-
|
|
96
|
-
if (data) {
|
|
97
|
-
_logger2.default.info(`Exporting ${name}`);
|
|
98
|
-
}
|
|
99
|
-
} catch (err) {
|
|
100
|
-
_logger2.default.debug(err.stack);
|
|
101
|
-
|
|
102
|
-
throw new Error(`Problem exporting ${name}`);
|
|
103
|
-
}
|
|
104
|
-
}));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
};
|
|
118
|
+
}
|
|
119
|
+
exports.default = default_1;
|
package/lib/context/index.js
CHANGED
|
@@ -1,108 +1,99 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (!config.AUTH0_DOMAIN) errors.push('AUTH0_DOMAIN');
|
|
10
|
-
|
|
11
|
-
if (!config.AUTH0_ACCESS_TOKEN) {
|
|
12
|
-
if (!config.AUTH0_CLIENT_ID) errors.push('AUTH0_CLIENT_ID');
|
|
13
|
-
if (!config.AUTH0_CLIENT_SECRET) errors.push('AUTH0_CLIENT_SECRET');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (errors.length > 0) {
|
|
17
|
-
throw new Error(`The following parameters were missing. Please add them to your config.json or as an environment variable. ${JSON.stringify(errors)}`);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
let accessToken = config.AUTH0_ACCESS_TOKEN;
|
|
21
|
-
|
|
22
|
-
if (!accessToken) {
|
|
23
|
-
const authClient = new _auth.AuthenticationClient({
|
|
24
|
-
domain: config.AUTH0_DOMAIN,
|
|
25
|
-
clientId: config.AUTH0_CLIENT_ID,
|
|
26
|
-
clientSecret: config.AUTH0_CLIENT_SECRET
|
|
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());
|
|
27
9
|
});
|
|
28
|
-
const clientCredentials = await authClient.clientCredentialsGrant({
|
|
29
|
-
audience: config.AUTH0_AUDIENCE ? config.AUTH0_AUDIENCE : `https://${config.AUTH0_DOMAIN}/api/v2/`
|
|
30
|
-
});
|
|
31
|
-
accessToken = clientCredentials.access_token;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const mgmtClient = new _auth.ManagementClient({
|
|
35
|
-
domain: config.AUTH0_DOMAIN,
|
|
36
|
-
token: accessToken,
|
|
37
|
-
retry: {
|
|
38
|
-
maxRetries: config.AUTH0_API_MAX_RETRIES || 10,
|
|
39
|
-
enabled: true
|
|
40
|
-
},
|
|
41
|
-
headers: {
|
|
42
|
-
'User-agent': `deploy-cli/${_package.version} (node.js/${process.version.replace('v', '')})`
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
const inputFile = config.AUTH0_INPUT_FILE;
|
|
46
|
-
|
|
47
|
-
const ensureObject = (key, value) => {
|
|
48
|
-
if (typeof value === 'string') {
|
|
49
|
-
try {
|
|
50
|
-
return JSON.parse(value);
|
|
51
|
-
} catch (e) {
|
|
52
|
-
_logger2.default.debug(`Cannot convert config.${key} to an object. Error: ${e.message}`);
|
|
53
|
-
|
|
54
|
-
return value;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return value;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
nonPrimitiveProps.forEach(key => {
|
|
62
|
-
if (config[key]) {
|
|
63
|
-
config[key] = ensureObject(key, config[key]);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
if (typeof inputFile === 'object') {
|
|
68
|
-
return new _yaml2.default(config, mgmtClient);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if ((0, _utils.isDirectory)(inputFile)) {
|
|
72
|
-
return new _directory2.default(config, mgmtClient);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const ext = _path2.default.extname(inputFile);
|
|
76
|
-
|
|
77
|
-
if (ext === '.yaml' || ext === '.yml') {
|
|
78
|
-
return new _yaml2.default(config, mgmtClient);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
throw new Error(`Unable to determine context processor to load for file ${inputFile}, does it exist? `);
|
|
82
10
|
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const
|
|
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 path_1 = __importDefault(require("path"));
|
|
16
|
+
const auth0_1 = require("auth0");
|
|
17
|
+
const yaml_1 = __importDefault(require("./yaml"));
|
|
18
|
+
const directory_1 = __importDefault(require("./directory"));
|
|
19
|
+
const utils_1 = require("../utils");
|
|
20
|
+
const package_json_1 = require("../../package.json");
|
|
21
|
+
const logger_1 = __importDefault(require("../logger"));
|
|
22
|
+
const nonPrimitiveProps = [
|
|
23
|
+
'AUTH0_KEYWORD_REPLACE_MAPPINGS',
|
|
24
|
+
'AUTH0_EXCLUDED_RULES',
|
|
25
|
+
'AUTH0_EXCLUDED_CLIENTS',
|
|
26
|
+
'AUTH0_EXCLUDED_DATABASES',
|
|
27
|
+
'AUTH0_EXCLUDED_CONNECTIONS',
|
|
28
|
+
'AUTH0_EXCLUDED_RESOURCE_SERVERS',
|
|
29
|
+
'AUTH0_EXCLUDED_DEFAULTS',
|
|
30
|
+
'EXCLUDED_PROPS',
|
|
31
|
+
'INCLUDED_PROPS'
|
|
32
|
+
];
|
|
33
|
+
function default_1(config) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
// Validate config
|
|
36
|
+
const errors = [];
|
|
37
|
+
if (!config.AUTH0_DOMAIN)
|
|
38
|
+
errors.push('AUTH0_DOMAIN');
|
|
39
|
+
if (!config.AUTH0_ACCESS_TOKEN) {
|
|
40
|
+
if (!config.AUTH0_CLIENT_ID)
|
|
41
|
+
errors.push('AUTH0_CLIENT_ID');
|
|
42
|
+
if (!config.AUTH0_CLIENT_SECRET)
|
|
43
|
+
errors.push('AUTH0_CLIENT_SECRET');
|
|
44
|
+
}
|
|
45
|
+
if (errors.length > 0) {
|
|
46
|
+
throw new Error(`The following parameters were missing. Please add them to your config.json or as an environment variable. ${JSON.stringify(errors)}`);
|
|
47
|
+
}
|
|
48
|
+
let accessToken = config.AUTH0_ACCESS_TOKEN;
|
|
49
|
+
if (!accessToken) {
|
|
50
|
+
const authClient = new auth0_1.AuthenticationClient({
|
|
51
|
+
domain: config.AUTH0_DOMAIN,
|
|
52
|
+
clientId: config.AUTH0_CLIENT_ID,
|
|
53
|
+
clientSecret: config.AUTH0_CLIENT_SECRET
|
|
54
|
+
});
|
|
55
|
+
const clientCredentials = yield authClient.clientCredentialsGrant({
|
|
56
|
+
audience: config.AUTH0_AUDIENCE ? config.AUTH0_AUDIENCE : `https://${config.AUTH0_DOMAIN}/api/v2/`
|
|
57
|
+
});
|
|
58
|
+
accessToken = clientCredentials.access_token;
|
|
59
|
+
}
|
|
60
|
+
const mgmtClient = new auth0_1.ManagementClient({
|
|
61
|
+
domain: config.AUTH0_DOMAIN,
|
|
62
|
+
token: accessToken,
|
|
63
|
+
retry: { maxRetries: config.AUTH0_API_MAX_RETRIES || 10, enabled: true },
|
|
64
|
+
headers: {
|
|
65
|
+
'User-agent': `deploy-cli/${package_json_1.version} (node.js/${process.version.replace('v', '')})`
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const inputFile = config.AUTH0_INPUT_FILE;
|
|
69
|
+
const ensureObject = (key, value) => {
|
|
70
|
+
if (typeof value === 'string') {
|
|
71
|
+
try {
|
|
72
|
+
return JSON.parse(value);
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
logger_1.default.debug(`Cannot convert config.${key} to an object. Error: ${e.message}`);
|
|
76
|
+
return value;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return value;
|
|
80
|
+
};
|
|
81
|
+
nonPrimitiveProps.forEach((key) => {
|
|
82
|
+
if (config[key]) {
|
|
83
|
+
config[key] = ensureObject(key, config[key]);
|
|
84
|
+
}
|
|
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
|
+
}
|
|
92
|
+
const ext = path_1.default.extname(inputFile);
|
|
93
|
+
if (ext === '.yaml' || ext === '.yml') {
|
|
94
|
+
return new yaml_1.default(config, mgmtClient);
|
|
95
|
+
}
|
|
96
|
+
throw new Error(`Unable to determine context processor to load for file ${inputFile}, does it exist? `);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
exports.default = default_1;
|