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
|
@@ -23,7 +23,7 @@ function parse(context) {
|
|
|
23
23
|
const file = path_1.default.join(guardianFolder, 'phoneFactorSelectedProvider.json');
|
|
24
24
|
if ((0, utils_1.isFile)(file)) {
|
|
25
25
|
return {
|
|
26
|
-
guardianPhoneFactorSelectedProvider: (0, utils_1.loadJSON)(file, context.mappings)
|
|
26
|
+
guardianPhoneFactorSelectedProvider: (0, utils_1.loadJSON)(file, context.mappings),
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
return {};
|
|
@@ -23,7 +23,7 @@ function parse(context) {
|
|
|
23
23
|
const file = path_1.default.join(guardianFolder, 'policies.json');
|
|
24
24
|
if ((0, utils_1.isFile)(file)) {
|
|
25
25
|
return {
|
|
26
|
-
guardianPolicies: (0, utils_1.loadJSON)(file, context.mappings)
|
|
26
|
+
guardianPolicies: (0, utils_1.loadJSON)(file, context.mappings),
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
return {};
|
|
@@ -31,12 +31,12 @@ function parse(context) {
|
|
|
31
31
|
return hook;
|
|
32
32
|
});
|
|
33
33
|
return {
|
|
34
|
-
hooks
|
|
34
|
+
hooks,
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
function dump(context) {
|
|
38
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
const hooks = [...context.assets.hooks || []];
|
|
39
|
+
const hooks = [...(context.assets.hooks || [])];
|
|
40
40
|
if (hooks.length < 1)
|
|
41
41
|
return;
|
|
42
42
|
// Create Hooks folder
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import DirectoryContext from '..';
|
|
2
|
+
import { AssetTypes } from '../../../types';
|
|
3
|
+
export declare type DirectoryHandler<T> = {
|
|
4
|
+
dump: (context: DirectoryContext) => void;
|
|
5
|
+
parse: (context: DirectoryContext) => T;
|
|
6
|
+
};
|
|
7
|
+
declare const directoryHandlers: {
|
|
8
|
+
[key in AssetTypes]: DirectoryHandler<{
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}>;
|
|
11
|
+
};
|
|
12
|
+
export default directoryHandlers;
|
|
@@ -28,7 +28,7 @@ const organizations_1 = __importDefault(require("./organizations"));
|
|
|
28
28
|
const triggers_1 = __importDefault(require("./triggers"));
|
|
29
29
|
const attackProtection_1 = __importDefault(require("./attackProtection"));
|
|
30
30
|
const branding_1 = __importDefault(require("./branding"));
|
|
31
|
-
|
|
31
|
+
const directoryHandlers = {
|
|
32
32
|
rules: rules_1.default,
|
|
33
33
|
rulesConfigs: rulesConfigs_1.default,
|
|
34
34
|
hooks: hooks_1.default,
|
|
@@ -53,5 +53,6 @@ exports.default = {
|
|
|
53
53
|
organizations: organizations_1.default,
|
|
54
54
|
triggers: triggers_1.default,
|
|
55
55
|
attackProtection: attackProtection_1.default,
|
|
56
|
-
branding: branding_1.default
|
|
56
|
+
branding: branding_1.default,
|
|
57
57
|
};
|
|
58
|
+
exports.default = directoryHandlers;
|
|
@@ -44,12 +44,12 @@ function parse(context) {
|
|
|
44
44
|
return Object.assign(Object.assign({}, (0, utils_1.loadJSON)(meta, context.mappings)), { html: (0, tools_1.loadFileAndReplaceKeywords)(html, context.mappings) });
|
|
45
45
|
});
|
|
46
46
|
return {
|
|
47
|
-
pages
|
|
47
|
+
pages,
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
function dump(context) {
|
|
51
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
const pages = [...context.assets.pages || []];
|
|
52
|
+
const pages = [...(context.assets.pages || [])];
|
|
53
53
|
if (!pages)
|
|
54
54
|
return; // Skip, nothing to dump
|
|
55
55
|
// Create Pages folder
|
|
@@ -21,10 +21,11 @@ function parse(context) {
|
|
|
21
21
|
if (!(0, utils_1.existsMustBeDir)(resourceServersFolder))
|
|
22
22
|
return { resourceServers: undefined }; // Skip
|
|
23
23
|
const foundFiles = (0, utils_1.getFiles)(resourceServersFolder, ['.json']);
|
|
24
|
-
const resourceServers = foundFiles
|
|
24
|
+
const resourceServers = foundFiles
|
|
25
|
+
.map((f) => (0, utils_1.loadJSON)(f, context.mappings))
|
|
25
26
|
.filter((p) => Object.keys(p).length > 0); // Filter out empty resourceServers
|
|
26
27
|
return {
|
|
27
|
-
resourceServers
|
|
28
|
+
resourceServers,
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
function dump(context) {
|
|
@@ -30,12 +30,12 @@ function parse(context) {
|
|
|
30
30
|
return rule;
|
|
31
31
|
});
|
|
32
32
|
return {
|
|
33
|
-
rules
|
|
33
|
+
rules,
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
function dump(context) {
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
const rules = [...context.assets.rules || []];
|
|
38
|
+
const rules = [...(context.assets.rules || [])];
|
|
39
39
|
if (!rules)
|
|
40
40
|
return; // Skip, nothing to dump
|
|
41
41
|
// Create Rules folder
|
|
@@ -20,10 +20,11 @@ function parse(context) {
|
|
|
20
20
|
if (!(0, utils_1.existsMustBeDir)(rulesConfigsFolder))
|
|
21
21
|
return { rulesConfigs: undefined }; // Skip
|
|
22
22
|
const foundFiles = (0, utils_1.getFiles)(rulesConfigsFolder, ['.json']);
|
|
23
|
-
const rulesConfigs = foundFiles
|
|
23
|
+
const rulesConfigs = foundFiles
|
|
24
|
+
.map((f) => (0, utils_1.loadJSON)(f, context.mappings))
|
|
24
25
|
.filter((p) => Object.keys(p).length > 0); // Filter out empty rulesConfigs
|
|
25
26
|
return {
|
|
26
|
-
rulesConfigs
|
|
27
|
+
rulesConfigs,
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
30
|
function dump() {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DirectoryHandler } from '.';
|
|
2
|
+
declare type ParsedTenant = {
|
|
3
|
+
tenant: {
|
|
4
|
+
session_lifetime: number;
|
|
5
|
+
idle_session_lifetime: number;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
};
|
|
8
|
+
} | {};
|
|
9
|
+
declare const tenantHandler: DirectoryHandler<ParsedTenant>;
|
|
10
|
+
export default tenantHandler;
|
|
@@ -25,6 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const path_1 = __importDefault(require("path"));
|
|
27
27
|
const utils_1 = require("../../../utils");
|
|
28
|
+
const sessionDurationsToMinutes_1 = require("../../../sessionDurationsToMinutes");
|
|
28
29
|
function parse(context) {
|
|
29
30
|
const baseFolder = path_1.default.join(context.filePath);
|
|
30
31
|
if (!(0, utils_1.existsMustBeDir)(baseFolder))
|
|
@@ -34,10 +35,10 @@ function parse(context) {
|
|
|
34
35
|
/* eslint-disable camelcase */
|
|
35
36
|
const _a = (0, utils_1.loadJSON)(tenantFile, context.mappings), { session_lifetime, idle_session_lifetime } = _a, tenant = __rest(_a, ["session_lifetime", "idle_session_lifetime"]);
|
|
36
37
|
(0, utils_1.clearTenantFlags)(tenant);
|
|
38
|
+
const sessionDurations = (0, sessionDurationsToMinutes_1.sessionDurationsToMinutes)({ session_lifetime, idle_session_lifetime });
|
|
37
39
|
return {
|
|
38
|
-
tenant: Object.assign(Object.assign({}, tenant),
|
|
40
|
+
tenant: Object.assign(Object.assign({}, tenant), sessionDurations),
|
|
39
41
|
};
|
|
40
|
-
/* eslint-enable camelcase */
|
|
41
42
|
}
|
|
42
43
|
return {};
|
|
43
44
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Assets, Auth0APIClient, Config } from '../../types';
|
|
2
|
+
declare type KeywordMappings = {
|
|
3
|
+
[key: string]: (string | number)[] | string | number;
|
|
4
|
+
};
|
|
5
|
+
export default class DirectoryContext {
|
|
6
|
+
basePath: string;
|
|
7
|
+
filePath: string;
|
|
8
|
+
config: Config;
|
|
9
|
+
mappings: KeywordMappings;
|
|
10
|
+
mgmtClient: Auth0APIClient;
|
|
11
|
+
assets: Assets;
|
|
12
|
+
constructor(config: Config, mgmtClient: Auth0APIClient);
|
|
13
|
+
loadFile(f: string, folder: string): string;
|
|
14
|
+
load(): Promise<void>;
|
|
15
|
+
dump(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -41,22 +41,22 @@ const readonly_1 = __importDefault(require("../../readonly"));
|
|
|
41
41
|
const logger_1 = __importDefault(require("../../logger"));
|
|
42
42
|
const handlers_1 = __importDefault(require("./handlers"));
|
|
43
43
|
const utils_1 = require("../../utils");
|
|
44
|
-
class
|
|
44
|
+
class DirectoryContext {
|
|
45
45
|
constructor(config, mgmtClient) {
|
|
46
46
|
this.filePath = config.AUTH0_INPUT_FILE;
|
|
47
47
|
this.config = config;
|
|
48
|
-
this.mappings = config.AUTH0_KEYWORD_REPLACE_MAPPINGS;
|
|
48
|
+
this.mappings = config.AUTH0_KEYWORD_REPLACE_MAPPINGS || {};
|
|
49
49
|
this.mgmtClient = mgmtClient;
|
|
50
|
+
//@ts-ignore for now
|
|
51
|
+
this.assets = {};
|
|
50
52
|
// Get excluded rules
|
|
51
|
-
this.assets = {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
defaults: config.AUTH0_EXCLUDED_DEFAULTS || []
|
|
59
|
-
}
|
|
53
|
+
this.assets.exclude = {
|
|
54
|
+
rules: config.AUTH0_EXCLUDED_RULES || [],
|
|
55
|
+
clients: config.AUTH0_EXCLUDED_CLIENTS || [],
|
|
56
|
+
databases: config.AUTH0_EXCLUDED_DATABASES || [],
|
|
57
|
+
connections: config.AUTH0_EXCLUDED_CONNECTIONS || [],
|
|
58
|
+
resourceServers: config.AUTH0_EXCLUDED_RESOURCE_SERVERS || [],
|
|
59
|
+
defaults: config.AUTH0_EXCLUDED_DEFAULTS || [],
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
loadFile(f, folder) {
|
|
@@ -73,11 +73,9 @@ class default_1 {
|
|
|
73
73
|
if ((0, utils_1.isDirectory)(this.filePath)) {
|
|
74
74
|
/* If this is a directory, look for each file in the directory */
|
|
75
75
|
logger_1.default.info(`Processing directory ${this.filePath}`);
|
|
76
|
-
Object.values(handlers_1.default)
|
|
77
|
-
.forEach((handler) => {
|
|
76
|
+
Object.values(handlers_1.default).forEach((handler) => {
|
|
78
77
|
const parsed = handler.parse(this);
|
|
79
|
-
Object.entries(parsed)
|
|
80
|
-
.forEach(([k, v]) => {
|
|
78
|
+
Object.entries(parsed).forEach(([k, v]) => {
|
|
81
79
|
this.assets[k] = v;
|
|
82
80
|
});
|
|
83
81
|
});
|
|
@@ -97,12 +95,17 @@ class default_1 {
|
|
|
97
95
|
// Copy clients to be used by handlers which require converting client_id to the name
|
|
98
96
|
// Must copy as the client_id will be stripped if AUTH0_EXPORT_IDENTIFIERS is false
|
|
99
97
|
//@ts-ignore because assets haven't been typed yet TODO: type assets
|
|
100
|
-
this.assets.clientsOrig = [...this.assets.clients];
|
|
98
|
+
this.assets.clientsOrig = [...(this.assets.clients || [])];
|
|
101
99
|
// Optionally Strip identifiers
|
|
102
100
|
if (!this.config.AUTH0_EXPORT_IDENTIFIERS) {
|
|
103
101
|
this.assets = (0, utils_1.stripIdentifiers)(auth0, this.assets);
|
|
104
102
|
}
|
|
105
|
-
yield Promise.all(Object.entries(handlers_1.default)
|
|
103
|
+
yield Promise.all(Object.entries(handlers_1.default)
|
|
104
|
+
.filter(([handlerName]) => {
|
|
105
|
+
const excludedAssetTypes = this.config.AUTH0_EXCLUDED || [];
|
|
106
|
+
return !excludedAssetTypes.includes(handlerName);
|
|
107
|
+
})
|
|
108
|
+
.map(([name, handler]) => __awaiter(this, void 0, void 0, function* () {
|
|
106
109
|
try {
|
|
107
110
|
yield handler.dump(this);
|
|
108
111
|
}
|
|
@@ -114,4 +117,4 @@ class default_1 {
|
|
|
114
117
|
});
|
|
115
118
|
}
|
|
116
119
|
}
|
|
117
|
-
exports.default =
|
|
120
|
+
exports.default = DirectoryContext;
|
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,25 +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
|
-
//@ts-ignore
|
|
63
|
+
//@ts-ignore TODO: need to investigate why returning void here when other handlers do not
|
|
62
64
|
if (!actions)
|
|
63
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
|
};
|
|
82
85
|
exports.default = ActionsHandler;
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
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
|
}
|