auth0-deploy-cli 7.4.0 → 7.5.2
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/.eslintrc +66 -17
- package/.github/CODEOWNERS +1 -0
- package/.husky/pre-commit +2 -0
- package/CHANGELOG.md +27 -2
- package/lib/args.js +94 -81
- package/lib/commands/export.js +54 -78
- package/lib/commands/import.js +46 -70
- 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 -243
- 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 +255 -282
- package/lib/utils.js +167 -190
- package/package.json +10 -16
- package/tsconfig.json +17 -0
- package/typescript-migration-progress.sh +22 -0
- package/.babelrc +0 -17
- package/.nyc_output/597f412e-a239-4319-ad5b-ddb87fc39e67.json +0 -1
- package/.nyc_output/processinfo/597f412e-a239-4319-ad5b-ddb87fc39e67.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
|
@@ -1,147 +1,157 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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 promise_pool_executor_1 = require("promise-pool-executor");
|
|
27
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
28
|
+
const utils_1 = require("../utils");
|
|
18
29
|
const API_CONCURRENCY = 3;
|
|
30
|
+
// To ensure a complete deployment, limit the API requests generated to be 80% of the capacity
|
|
31
|
+
// https://auth0.com/docs/policies/rate-limits#management-api-v2
|
|
19
32
|
const API_FREQUENCY_PER_SECOND = 8;
|
|
20
33
|
const MAX_PAGE_SIZE = 100;
|
|
21
|
-
|
|
22
34
|
function getEntity(rsp) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
throw new Error('There was an error trying to find the entity within paginate');
|
|
35
|
+
const found = Object.values(rsp).filter((a) => Array.isArray(a));
|
|
36
|
+
if (found.length === 1) {
|
|
37
|
+
return found[0];
|
|
38
|
+
}
|
|
39
|
+
throw new Error('There was an error trying to find the entity within paginate');
|
|
30
40
|
}
|
|
31
|
-
|
|
32
41
|
function checkpointPaginator(client, target, name) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
};
|
|
42
|
+
return function (...args) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
const data = [];
|
|
45
|
+
// remove the _checkpoint_ flag
|
|
46
|
+
const _a = lodash_1.default.cloneDeep(args[0]), { checkpoint } = _a, newArgs = __rest(_a, ["checkpoint"]);
|
|
47
|
+
// fetch the total to validate records match
|
|
48
|
+
const { total } = yield client.pool
|
|
49
|
+
.addSingleTask({
|
|
50
|
+
data: newArgs,
|
|
51
|
+
generator: (requestArgs) => target[name](requestArgs)
|
|
52
|
+
})
|
|
53
|
+
.promise();
|
|
54
|
+
let done = false;
|
|
55
|
+
// use checkpoint pagination to allow fetching 1000+ results
|
|
56
|
+
newArgs.take = 50;
|
|
57
|
+
while (!done) {
|
|
58
|
+
const rsp = yield client.pool
|
|
59
|
+
.addSingleTask({
|
|
60
|
+
data: newArgs,
|
|
61
|
+
generator: (requestArgs) => target[name](requestArgs)
|
|
62
|
+
})
|
|
63
|
+
.promise();
|
|
64
|
+
data.push(...getEntity(rsp));
|
|
65
|
+
if (!rsp.next) {
|
|
66
|
+
done = true;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
newArgs.from = rsp.next;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (data.length !== total) {
|
|
73
|
+
throw new Error('Fail to load data from tenant');
|
|
74
|
+
}
|
|
75
|
+
return data;
|
|
76
|
+
});
|
|
77
|
+
};
|
|
70
78
|
}
|
|
71
|
-
|
|
72
79
|
function pagePaginator(client, target, name) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
return function (...args) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
// Where the entity data will be collected
|
|
83
|
+
const data = [];
|
|
84
|
+
// Create new args and inject the properties we require for pagination automation
|
|
85
|
+
const newArgs = [...args];
|
|
86
|
+
newArgs[0] = Object.assign(Object.assign({}, newArgs[0]), { page: 0 });
|
|
87
|
+
// Grab data we need from the request then delete the keys as they are only needed for this automation function to work
|
|
88
|
+
const perPage = newArgs[0].per_page || MAX_PAGE_SIZE;
|
|
89
|
+
newArgs[0].per_page = perPage;
|
|
90
|
+
delete newArgs[0].paginate;
|
|
91
|
+
// Run the first request to get the total number of entity items
|
|
92
|
+
const rsp = yield client.pool
|
|
93
|
+
.addSingleTask({
|
|
94
|
+
data: lodash_1.default.cloneDeep(newArgs),
|
|
95
|
+
generator: (pageArgs) => target[name](...pageArgs)
|
|
96
|
+
})
|
|
97
|
+
.promise();
|
|
98
|
+
data.push(...getEntity(rsp));
|
|
99
|
+
const total = rsp.total || 0;
|
|
100
|
+
const pagesLeft = Math.ceil(total / perPage) - 1;
|
|
101
|
+
// Setup pool to get the rest of the pages
|
|
102
|
+
if (pagesLeft > 0) {
|
|
103
|
+
const pages = yield client.pool
|
|
104
|
+
.addEachTask({
|
|
105
|
+
data: Array.from(Array(pagesLeft).keys()),
|
|
106
|
+
generator: (page) => {
|
|
107
|
+
const pageArgs = lodash_1.default.cloneDeep(newArgs);
|
|
108
|
+
pageArgs[0].page = page + 1;
|
|
109
|
+
return target[name](...pageArgs).then((r) => getEntity(r));
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
.promise();
|
|
113
|
+
data.push(...(0, utils_1.flatten)(pages));
|
|
114
|
+
if (data.length !== total) {
|
|
115
|
+
throw new Error('Fail to load data from tenant');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return data;
|
|
119
|
+
});
|
|
78
120
|
};
|
|
79
|
-
const perPage = newArgs[0].per_page || MAX_PAGE_SIZE;
|
|
80
|
-
newArgs[0].per_page = perPage;
|
|
81
|
-
delete newArgs[0].paginate;
|
|
82
|
-
const rsp = await client.pool.addSingleTask({
|
|
83
|
-
data: _lodash2.default.cloneDeep(newArgs),
|
|
84
|
-
generator: pageArgs => target[name](...pageArgs)
|
|
85
|
-
}).promise();
|
|
86
|
-
data.push(...getEntity(rsp));
|
|
87
|
-
const total = rsp.total || 0;
|
|
88
|
-
const pagesLeft = Math.ceil(total / perPage) - 1;
|
|
89
|
-
|
|
90
|
-
if (pagesLeft > 0) {
|
|
91
|
-
const pages = await client.pool.addEachTask({
|
|
92
|
-
data: Array.from(Array(pagesLeft).keys()),
|
|
93
|
-
generator: page => {
|
|
94
|
-
const pageArgs = _lodash2.default.cloneDeep(newArgs);
|
|
95
|
-
|
|
96
|
-
pageArgs[0].page = page + 1;
|
|
97
|
-
return target[name](...pageArgs).then(r => getEntity(r));
|
|
98
|
-
}
|
|
99
|
-
}).promise();
|
|
100
|
-
data.push(...(0, _utils.flatten)(pages));
|
|
101
|
-
|
|
102
|
-
if (data.length !== total) {
|
|
103
|
-
throw new Error('Fail to load data from tenant');
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return data;
|
|
108
|
-
};
|
|
109
121
|
}
|
|
110
|
-
|
|
122
|
+
// Warp around a <resource>Manager and detect when requesting specific pages to return all
|
|
111
123
|
function pagedManager(client, manager) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return nestedManager;
|
|
136
|
-
}
|
|
137
|
-
});
|
|
124
|
+
return new Proxy(manager, {
|
|
125
|
+
get: function (target, name, receiver) {
|
|
126
|
+
if (name === 'getAll') {
|
|
127
|
+
return function (...args) {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
switch (true) {
|
|
130
|
+
case args[0] && typeof args[0] === 'object' && args[0].checkpoint:
|
|
131
|
+
return checkpointPaginator(client, target, name)(...args);
|
|
132
|
+
case args[0] && typeof args[0] === 'object' && args[0].paginate:
|
|
133
|
+
return pagePaginator(client, target, name)(...args);
|
|
134
|
+
default:
|
|
135
|
+
return target[name](...args);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
const nestedManager = Reflect.get(target, name, receiver);
|
|
141
|
+
if (typeof nestedManager === 'object' && nestedManager !== null) {
|
|
142
|
+
return pagedManager(client, nestedManager);
|
|
143
|
+
}
|
|
144
|
+
return nestedManager;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
138
147
|
}
|
|
139
|
-
|
|
148
|
+
// Warp around the ManagementClient and detect when requesting specific pages to return all
|
|
140
149
|
function pagedClient(client) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
150
|
+
client.pool = new promise_pool_executor_1.PromisePoolExecutor({
|
|
151
|
+
concurrencyLimit: API_CONCURRENCY,
|
|
152
|
+
frequencyLimit: API_FREQUENCY_PER_SECOND,
|
|
153
|
+
frequencyWindow: 1000 // 1 sec
|
|
154
|
+
});
|
|
155
|
+
return pagedManager(client, client);
|
|
156
|
+
}
|
|
157
|
+
exports.default = pagedClient;
|