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,28 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
function parse(context) {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
// nothing to do, set default empty
|
|
15
|
+
return {
|
|
16
|
+
roles: context.assets.roles
|
|
17
|
+
};
|
|
18
|
+
});
|
|
11
19
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
function dump(context) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
// remove empty descriptions
|
|
23
|
+
return {
|
|
24
|
+
roles: [
|
|
25
|
+
...(context.assets.roles || []).map((role) => {
|
|
26
|
+
if (role.description === null) {
|
|
27
|
+
delete role.description;
|
|
28
|
+
}
|
|
29
|
+
return role;
|
|
30
|
+
})
|
|
31
|
+
]
|
|
32
|
+
};
|
|
33
|
+
});
|
|
23
34
|
}
|
|
24
|
-
|
|
25
35
|
exports.default = {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
36
|
+
parse,
|
|
37
|
+
dump
|
|
38
|
+
};
|
|
@@ -1,63 +1,53 @@
|
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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 path_1 = __importDefault(require("path"));
|
|
16
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
17
|
+
const utils_1 = require("../../../utils");
|
|
18
|
+
const logger_1 = __importDefault(require("../../../logger"));
|
|
19
|
+
function parse(context) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
// Load the script file for each rule
|
|
22
|
+
if (!context.assets.rules)
|
|
23
|
+
return {};
|
|
24
|
+
return {
|
|
25
|
+
rules: [
|
|
26
|
+
...context.assets.rules.map((rule) => (Object.assign(Object.assign({}, rule), { script: context.loadFile(rule.script) })))
|
|
27
|
+
]
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return { ...rule,
|
|
50
|
-
script: `./rules/${scriptName}`
|
|
51
|
-
};
|
|
31
|
+
function dump(context) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
let rules = [...context.assets.rules || []];
|
|
34
|
+
if (rules.length > 0) {
|
|
35
|
+
// Create Rules folder
|
|
36
|
+
const rulesFolder = path_1.default.join(context.basePath, 'rules');
|
|
37
|
+
fs_extra_1.default.ensureDirSync(rulesFolder);
|
|
38
|
+
rules = rules.map((rule) => {
|
|
39
|
+
// Dump rule to file
|
|
40
|
+
const scriptName = (0, utils_1.sanitize)(`${rule.name}.js`);
|
|
41
|
+
const scriptFile = path_1.default.join(rulesFolder, scriptName);
|
|
42
|
+
logger_1.default.info(`Writing ${scriptFile}`);
|
|
43
|
+
fs_extra_1.default.writeFileSync(scriptFile, rule.script);
|
|
44
|
+
return Object.assign(Object.assign({}, rule), { script: `./rules/${scriptName}` });
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return { rules };
|
|
52
48
|
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
rules
|
|
57
|
-
};
|
|
58
49
|
}
|
|
59
|
-
|
|
60
50
|
exports.default = {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
};
|
|
51
|
+
parse,
|
|
52
|
+
dump
|
|
53
|
+
};
|
|
@@ -1,22 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
function parse(context) {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
// nothing to do, set default if empty
|
|
15
|
+
return {
|
|
16
|
+
rulesConfigs: context.assets.rulesConfigs
|
|
17
|
+
};
|
|
18
|
+
});
|
|
11
19
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
function dump() {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
// do not export rulesConfigs as its values cannot be extracted
|
|
23
|
+
return {
|
|
24
|
+
rulesConfigs: []
|
|
25
|
+
};
|
|
26
|
+
});
|
|
17
27
|
}
|
|
18
|
-
|
|
19
28
|
exports.default = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
29
|
+
parse,
|
|
30
|
+
dump
|
|
31
|
+
};
|
|
@@ -1,34 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
const utils_1 = require("../../../utils");
|
|
24
|
+
function parse(context) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
// Nothing to do
|
|
27
|
+
if (!context.assets.tenant)
|
|
28
|
+
return {};
|
|
29
|
+
/* eslint-disable camelcase */
|
|
30
|
+
const _a = context.assets.tenant, { session_lifetime, idle_session_lifetime } = _a, tenant = __rest(_a, ["session_lifetime", "idle_session_lifetime"]);
|
|
31
|
+
(0, utils_1.clearTenantFlags)(tenant);
|
|
32
|
+
return {
|
|
33
|
+
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))
|
|
34
|
+
};
|
|
35
|
+
/* eslint-enable camelcase */
|
|
36
|
+
});
|
|
20
37
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
tenant
|
|
28
|
-
};
|
|
38
|
+
function dump(context) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const tenant = Object.assign({}, context.assets.tenant || {});
|
|
41
|
+
(0, utils_1.clearTenantFlags)(tenant);
|
|
42
|
+
return { tenant };
|
|
43
|
+
});
|
|
29
44
|
}
|
|
30
|
-
|
|
31
45
|
exports.default = {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
46
|
+
parse,
|
|
47
|
+
dump
|
|
48
|
+
};
|
|
@@ -1,27 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
function parse(context) {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
// Load the script file for each action
|
|
15
|
+
if (!context.assets.triggers)
|
|
16
|
+
return {};
|
|
17
|
+
return {
|
|
18
|
+
triggers: context.assets.triggers
|
|
19
|
+
};
|
|
20
|
+
});
|
|
12
21
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
function dump(context) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const { triggers } = context.assets;
|
|
25
|
+
// Nothing to do
|
|
26
|
+
if (!triggers)
|
|
27
|
+
return {};
|
|
28
|
+
return {
|
|
29
|
+
triggers: triggers
|
|
30
|
+
};
|
|
31
|
+
});
|
|
22
32
|
}
|
|
23
|
-
|
|
24
33
|
exports.default = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
34
|
+
parse,
|
|
35
|
+
dump
|
|
36
|
+
};
|
|
@@ -1,148 +1,133 @@
|
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
exclude: {
|
|
45
|
-
rules: config.AUTH0_EXCLUDED_RULES || [],
|
|
46
|
-
clients: config.AUTH0_EXCLUDED_CLIENTS || [],
|
|
47
|
-
databases: config.AUTH0_EXCLUDED_DATABASES || [],
|
|
48
|
-
connections: config.AUTH0_EXCLUDED_CONNECTIONS || [],
|
|
49
|
-
resourceServers: config.AUTH0_EXCLUDED_RESOURCE_SERVERS || [],
|
|
50
|
-
defaults: config.AUTH0_EXCLUDED_DEFAULTS || []
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
this.basePath = config.AUTH0_BASE_PATH;
|
|
54
|
-
|
|
55
|
-
if (!this.basePath) {
|
|
56
|
-
this.basePath = typeof configFile === 'object' ? process.cwd() : _path2.default.dirname(this.configFile);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
loadFile(f) {
|
|
61
|
-
let toLoad = _path2.default.join(this.basePath, f);
|
|
62
|
-
|
|
63
|
-
if (!(0, _utils.isFile)(toLoad)) {
|
|
64
|
-
toLoad = f;
|
|
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 js_yaml_1 = __importDefault(require("js-yaml"));
|
|
17
|
+
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const tools_1 = require("../../tools");
|
|
19
|
+
const logger_1 = __importDefault(require("../../logger"));
|
|
20
|
+
const utils_1 = require("../../utils");
|
|
21
|
+
const handlers_1 = __importDefault(require("./handlers"));
|
|
22
|
+
const readonly_1 = __importDefault(require("../../readonly"));
|
|
23
|
+
class default_1 {
|
|
24
|
+
constructor(config, mgmtClient) {
|
|
25
|
+
this.configFile = config.AUTH0_INPUT_FILE;
|
|
26
|
+
this.config = config;
|
|
27
|
+
this.mappings = config.AUTH0_KEYWORD_REPLACE_MAPPINGS;
|
|
28
|
+
this.mgmtClient = mgmtClient;
|
|
29
|
+
// Get excluded rules
|
|
30
|
+
this.assets = {
|
|
31
|
+
exclude: {
|
|
32
|
+
rules: config.AUTH0_EXCLUDED_RULES || [],
|
|
33
|
+
clients: config.AUTH0_EXCLUDED_CLIENTS || [],
|
|
34
|
+
databases: config.AUTH0_EXCLUDED_DATABASES || [],
|
|
35
|
+
connections: config.AUTH0_EXCLUDED_CONNECTIONS || [],
|
|
36
|
+
resourceServers: config.AUTH0_EXCLUDED_RESOURCE_SERVERS || [],
|
|
37
|
+
defaults: config.AUTH0_EXCLUDED_DEFAULTS || []
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
this.basePath = config.AUTH0_BASE_PATH;
|
|
41
|
+
if (!this.basePath) {
|
|
42
|
+
this.basePath = (typeof configFile === 'object') ? process.cwd() : path_1.default.dirname(this.configFile);
|
|
43
|
+
}
|
|
65
44
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
} else {
|
|
74
|
-
try {
|
|
75
|
-
const fPath = _path2.default.resolve(this.configFile);
|
|
76
|
-
|
|
77
|
-
_logger2.default.debug(`Loading YAML from ${fPath}`);
|
|
78
|
-
|
|
79
|
-
Object.assign(this.assets, _jsYaml2.default.load((0, _tools.keywordReplace)(_fsExtra2.default.readFileSync(fPath, 'utf8'), this.mappings)) || {});
|
|
80
|
-
} catch (err) {
|
|
81
|
-
_logger2.default.debug(err.stack);
|
|
82
|
-
|
|
83
|
-
throw new Error(`Problem loading ${this.configFile}\n${err}`);
|
|
84
|
-
}
|
|
45
|
+
loadFile(f) {
|
|
46
|
+
let toLoad = path_1.default.join(this.basePath, f);
|
|
47
|
+
if (!(0, utils_1.isFile)(toLoad)) {
|
|
48
|
+
// try load not relative to yaml file
|
|
49
|
+
toLoad = f;
|
|
50
|
+
}
|
|
51
|
+
return (0, tools_1.loadFileAndReplaceKeywords)(path_1.default.resolve(toLoad), this.mappings);
|
|
85
52
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
53
|
+
load() {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
// Allow to send object/json directly
|
|
56
|
+
if (typeof this.configFile === 'object') {
|
|
57
|
+
this.assets = this.configFile;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
try {
|
|
61
|
+
const fPath = path_1.default.resolve(this.configFile);
|
|
62
|
+
logger_1.default.debug(`Loading YAML from ${fPath}`);
|
|
63
|
+
Object.assign(this.assets, js_yaml_1.default.load((0, tools_1.keywordReplace)(fs_extra_1.default.readFileSync(fPath, 'utf8'), this.mappings)) || {});
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
logger_1.default.debug(err.stack);
|
|
67
|
+
throw new Error(`Problem loading ${this.configFile}\n${err}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Run initial schema check to ensure valid YAML
|
|
71
|
+
const auth0 = new tools_1.Auth0(this.mgmtClient, this.assets, (0, utils_1.toConfigFn)(this.config));
|
|
72
|
+
yield auth0.validate('validate');
|
|
73
|
+
// Allow handlers to process the assets such as loading files etc
|
|
74
|
+
yield Promise.all(Object.entries(handlers_1.default).map(([name, handler]) => __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
try {
|
|
76
|
+
const parsed = yield handler.parse(this);
|
|
77
|
+
Object.entries(parsed)
|
|
78
|
+
.forEach(([k, v]) => {
|
|
79
|
+
this.assets[k] = v;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
logger_1.default.debug(err.stack);
|
|
84
|
+
throw new Error(`Problem deploying ${name}`);
|
|
85
|
+
}
|
|
86
|
+
})));
|
|
94
87
|
});
|
|
95
|
-
} catch (err) {
|
|
96
|
-
_logger2.default.debug(err.stack);
|
|
97
|
-
|
|
98
|
-
throw new Error(`Problem deploying ${name}`);
|
|
99
|
-
}
|
|
100
|
-
}));
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async dump() {
|
|
104
|
-
const auth0 = new _tools.Auth0(this.mgmtClient, this.assets, (0, _utils.toConfigFn)(this.config));
|
|
105
|
-
|
|
106
|
-
_logger2.default.info('Loading Auth0 Tenant Data');
|
|
107
|
-
|
|
108
|
-
try {
|
|
109
|
-
await auth0.loadAll();
|
|
110
|
-
this.assets = auth0.assets;
|
|
111
|
-
} catch (err) {
|
|
112
|
-
const docUrl = 'https://auth0.com/docs/deploy/deploy-cli-tool/create-and-configure-the-deploy-cli-application#modify-deploy-cli-application-scopes';
|
|
113
|
-
const extraMessage = err.message.startsWith('Insufficient scope') ? `\nSee ${docUrl} for more information` : '';
|
|
114
|
-
throw new Error(`Problem loading tenant data from Auth0 ${err}${extraMessage}`);
|
|
115
88
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
+
try {
|
|
94
|
+
yield auth0.loadAll();
|
|
95
|
+
this.assets = auth0.assets;
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
const docUrl = 'https://auth0.com/docs/deploy/deploy-cli-tool/create-and-configure-the-deploy-cli-application#modify-deploy-cli-application-scopes';
|
|
99
|
+
const extraMessage = err.message.startsWith('Insufficient scope') ? `\nSee ${docUrl} for more information` : '';
|
|
100
|
+
throw new Error(`Problem loading tenant data from Auth0 ${err}${extraMessage}`);
|
|
101
|
+
}
|
|
102
|
+
yield Promise.all(Object.entries(handlers_1.default).map(([name, handler]) => __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
try {
|
|
104
|
+
const data = yield handler.dump(this);
|
|
105
|
+
if (data) {
|
|
106
|
+
logger_1.default.info(`Exporting ${name}`);
|
|
107
|
+
Object.entries(data)
|
|
108
|
+
.forEach(([k, v]) => {
|
|
109
|
+
this.assets[k] = Array.isArray(v) ? v.map(utils_1.formatResults).sort(utils_1.recordsSorter) : (0, utils_1.formatResults)(v);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
logger_1.default.debug(err.stack);
|
|
115
|
+
throw new Error(`Problem exporting ${name}`);
|
|
116
|
+
}
|
|
117
|
+
})));
|
|
118
|
+
// Clean known read only fields
|
|
119
|
+
let cleaned = (0, readonly_1.default)(this.assets, this.config);
|
|
120
|
+
// Delete exclude as it's not part of the auth0 tenant config
|
|
121
|
+
delete cleaned.exclude;
|
|
122
|
+
// Optionally Strip identifiers
|
|
123
|
+
if (!this.config.AUTH0_EXPORT_IDENTIFIERS) {
|
|
124
|
+
cleaned = (0, utils_1.stripIdentifiers)(auth0, cleaned);
|
|
125
|
+
}
|
|
126
|
+
// Write YAML File
|
|
127
|
+
const raw = js_yaml_1.default.dump(cleaned);
|
|
128
|
+
logger_1.default.info(`Writing ${this.configFile}`);
|
|
129
|
+
fs_extra_1.default.writeFileSync(this.configFile, raw);
|
|
130
|
+
});
|
|
139
131
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
_logger2.default.info(`Writing ${this.configFile}`);
|
|
144
|
-
|
|
145
|
-
_fsExtra2.default.writeFileSync(this.configFile, raw);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
};
|
|
132
|
+
}
|
|
133
|
+
exports.default = default_1;
|