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
|
@@ -44,7 +44,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
44
44
|
exports.schema = void 0;
|
|
45
45
|
const default_1 = __importStar(require("./default"));
|
|
46
46
|
const calculateChanges_1 = require("../../calculateChanges");
|
|
47
|
-
const logger_1 = __importDefault(require("
|
|
47
|
+
const logger_1 = __importDefault(require("../../../logger"));
|
|
48
48
|
exports.schema = {
|
|
49
49
|
type: 'array',
|
|
50
50
|
items: {
|
|
@@ -59,15 +59,15 @@ exports.schema = {
|
|
|
59
59
|
type: 'object',
|
|
60
60
|
properties: {
|
|
61
61
|
permission_name: { type: 'string' },
|
|
62
|
-
resource_server_identifier: { type: 'string' }
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
62
|
+
resource_server_identifier: { type: 'string' },
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
66
|
},
|
|
67
|
-
required: ['name']
|
|
68
|
-
}
|
|
67
|
+
required: ['name'],
|
|
68
|
+
},
|
|
69
69
|
};
|
|
70
|
-
class
|
|
70
|
+
class RolesHandler extends default_1.default {
|
|
71
71
|
constructor(config) {
|
|
72
72
|
super(Object.assign(Object.assign({}, config), { type: 'roles', id: 'id', identifiers: ['name'] }));
|
|
73
73
|
}
|
|
@@ -84,15 +84,19 @@ class RoleHandler extends default_1.default {
|
|
|
84
84
|
}
|
|
85
85
|
createRoles(creates) {
|
|
86
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
-
yield this.client.pool
|
|
87
|
+
yield this.client.pool
|
|
88
|
+
.addEachTask({
|
|
88
89
|
data: creates || [],
|
|
89
|
-
generator: (item) => this.createRole(item)
|
|
90
|
+
generator: (item) => this.createRole(item)
|
|
91
|
+
.then((data) => {
|
|
90
92
|
this.didCreate(data);
|
|
91
93
|
this.created += 1;
|
|
92
|
-
}).catch((err) => {
|
|
93
|
-
throw new Error(`Problem creating ${this.type} ${this.objString(item)}\n${err}`);
|
|
94
94
|
})
|
|
95
|
-
|
|
95
|
+
.catch((err) => {
|
|
96
|
+
throw new Error(`Problem creating ${this.type} ${this.objString(item)}\n${err}`);
|
|
97
|
+
}),
|
|
98
|
+
})
|
|
99
|
+
.promise();
|
|
96
100
|
});
|
|
97
101
|
}
|
|
98
102
|
deleteRole(data) {
|
|
@@ -102,16 +106,21 @@ class RoleHandler extends default_1.default {
|
|
|
102
106
|
}
|
|
103
107
|
deleteRoles(dels) {
|
|
104
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
-
if (this.config('AUTH0_ALLOW_DELETE') === 'true' ||
|
|
106
|
-
|
|
109
|
+
if (this.config('AUTH0_ALLOW_DELETE') === 'true' ||
|
|
110
|
+
this.config('AUTH0_ALLOW_DELETE') === true) {
|
|
111
|
+
yield this.client.pool
|
|
112
|
+
.addEachTask({
|
|
107
113
|
data: dels || [],
|
|
108
|
-
generator: (item) => this.deleteRole(item)
|
|
114
|
+
generator: (item) => this.deleteRole(item)
|
|
115
|
+
.then(() => {
|
|
109
116
|
this.didDelete(item);
|
|
110
117
|
this.deleted += 1;
|
|
111
|
-
}).catch((err) => {
|
|
112
|
-
throw new Error(`Problem deleting ${this.type} ${this.objString(item)}\n${err}`);
|
|
113
118
|
})
|
|
114
|
-
|
|
119
|
+
.catch((err) => {
|
|
120
|
+
throw new Error(`Problem deleting ${this.type} ${this.objString(item)}\n${err}`);
|
|
121
|
+
}),
|
|
122
|
+
})
|
|
123
|
+
.promise();
|
|
115
124
|
}
|
|
116
125
|
else {
|
|
117
126
|
logger_1.default.warn(`Detected the following roles should be deleted. Doing so may be destructive.\nYou can enable deletes by setting 'AUTH0_ALLOW_DELETE' to true in the config
|
|
@@ -138,15 +147,19 @@ class RoleHandler extends default_1.default {
|
|
|
138
147
|
}
|
|
139
148
|
updateRoles(updates, roles) {
|
|
140
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
-
yield this.client.pool
|
|
150
|
+
yield this.client.pool
|
|
151
|
+
.addEachTask({
|
|
142
152
|
data: updates || [],
|
|
143
|
-
generator: (item) => this.updateRole(item, roles)
|
|
153
|
+
generator: (item) => this.updateRole(item, roles)
|
|
154
|
+
.then((data) => {
|
|
144
155
|
this.didUpdate(data);
|
|
145
156
|
this.updated += 1;
|
|
146
|
-
}).catch((err) => {
|
|
147
|
-
throw new Error(`Problem updating ${this.type} ${this.objString(item)}\n${err}`);
|
|
148
157
|
})
|
|
149
|
-
|
|
158
|
+
.catch((err) => {
|
|
159
|
+
throw new Error(`Problem updating ${this.type} ${this.objString(item)}\n${err}`);
|
|
160
|
+
}),
|
|
161
|
+
})
|
|
162
|
+
.promise();
|
|
150
163
|
});
|
|
151
164
|
}
|
|
152
165
|
getType() {
|
|
@@ -161,7 +174,11 @@ class RoleHandler extends default_1.default {
|
|
|
161
174
|
try {
|
|
162
175
|
const roles = yield this.client.roles.getAll({ paginate: true, include_totals: true });
|
|
163
176
|
for (let index = 0; index < roles.length; index++) {
|
|
164
|
-
const permissions = yield this.client.roles.permissions.getAll({
|
|
177
|
+
const permissions = yield this.client.roles.permissions.getAll({
|
|
178
|
+
paginate: true,
|
|
179
|
+
include_totals: true,
|
|
180
|
+
id: roles[index].id,
|
|
181
|
+
});
|
|
165
182
|
const strippedPerms = yield Promise.all(permissions.map((permission) => __awaiter(this, void 0, void 0, function* () {
|
|
166
183
|
delete permission.resource_server_name;
|
|
167
184
|
delete permission.description;
|
|
@@ -192,20 +209,27 @@ class RoleHandler extends default_1.default {
|
|
|
192
209
|
handler: this,
|
|
193
210
|
assets: roles,
|
|
194
211
|
existing,
|
|
195
|
-
identifiers: ['id', 'name']
|
|
212
|
+
identifiers: ['id', 'name'],
|
|
213
|
+
allowDelete: false, //TODO: actually pass in correct allowDelete value
|
|
196
214
|
});
|
|
197
215
|
logger_1.default.debug(`Start processChanges for roles [delete:${changes.del.length}] [update:${changes.update.length}], [create:${changes.create.length}]`);
|
|
198
|
-
const myChanges = [
|
|
216
|
+
const myChanges = [
|
|
217
|
+
{ del: changes.del },
|
|
218
|
+
{ create: changes.create },
|
|
219
|
+
{ update: changes.update },
|
|
220
|
+
];
|
|
199
221
|
yield Promise.all(myChanges.map((change) => __awaiter(this, void 0, void 0, function* () {
|
|
200
222
|
switch (true) {
|
|
201
223
|
case change.del && change.del.length > 0:
|
|
202
|
-
|
|
224
|
+
if (change.del)
|
|
225
|
+
yield this.deleteRoles(change.del);
|
|
203
226
|
break;
|
|
204
227
|
case change.create && change.create.length > 0:
|
|
205
|
-
yield this.createRoles(changes.create);
|
|
228
|
+
yield this.createRoles(changes.create); //TODO: fix this tho change.create
|
|
206
229
|
break;
|
|
207
230
|
case change.update && change.update.length > 0:
|
|
208
|
-
|
|
231
|
+
if (change.update)
|
|
232
|
+
yield this.updateRoles(change.update, existing);
|
|
209
233
|
break;
|
|
210
234
|
default:
|
|
211
235
|
break;
|
|
@@ -216,5 +240,5 @@ class RoleHandler extends default_1.default {
|
|
|
216
240
|
}
|
|
217
241
|
__decorate([
|
|
218
242
|
(0, default_1.order)('60')
|
|
219
|
-
],
|
|
220
|
-
exports.default =
|
|
243
|
+
], RolesHandler.prototype, "processChanges", null);
|
|
244
|
+
exports.default = RolesHandler;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import DefaultHandler from './default';
|
|
2
|
+
import { Asset, Assets, CalculatedChanges } from '../../../types';
|
|
3
|
+
export declare const excludeSchema: {
|
|
4
|
+
type: string;
|
|
5
|
+
items: {
|
|
6
|
+
type: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export declare const schema: {
|
|
10
|
+
type: string;
|
|
11
|
+
items: {
|
|
12
|
+
type: string;
|
|
13
|
+
default: never[];
|
|
14
|
+
properties: {
|
|
15
|
+
script: {
|
|
16
|
+
type: string;
|
|
17
|
+
description: string;
|
|
18
|
+
default: string;
|
|
19
|
+
};
|
|
20
|
+
name: {
|
|
21
|
+
type: string;
|
|
22
|
+
description: string;
|
|
23
|
+
pattern: string;
|
|
24
|
+
};
|
|
25
|
+
order: {
|
|
26
|
+
type: string[];
|
|
27
|
+
description: string;
|
|
28
|
+
default: null;
|
|
29
|
+
};
|
|
30
|
+
enabled: {
|
|
31
|
+
type: string;
|
|
32
|
+
description: string;
|
|
33
|
+
default: boolean;
|
|
34
|
+
};
|
|
35
|
+
stage: {
|
|
36
|
+
type: string;
|
|
37
|
+
description: string;
|
|
38
|
+
default: string;
|
|
39
|
+
enum: string[];
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
required: string[];
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export default class RulesHandler extends DefaultHandler {
|
|
46
|
+
existing: Asset[];
|
|
47
|
+
constructor(options: DefaultHandler);
|
|
48
|
+
getType(): Promise<Asset[]>;
|
|
49
|
+
objString(rule: any): string;
|
|
50
|
+
calcChanges(assets: any, includeExcluded?: boolean): Promise<CalculatedChanges & {
|
|
51
|
+
reOrder: Asset[];
|
|
52
|
+
}>;
|
|
53
|
+
validate(assets: Assets): Promise<void>;
|
|
54
|
+
processChanges(assets: Assets): Promise<void>;
|
|
55
|
+
}
|
|
@@ -13,14 +13,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.schema = exports.excludeSchema = void 0;
|
|
16
|
-
const
|
|
16
|
+
const validationError_1 = __importDefault(require("../../validationError"));
|
|
17
17
|
const utils_1 = require("../../utils");
|
|
18
18
|
const default_1 = __importDefault(require("./default"));
|
|
19
|
-
const logger_1 = __importDefault(require("
|
|
19
|
+
const logger_1 = __importDefault(require("../../../logger"));
|
|
20
20
|
const calculateChanges_1 = require("../../calculateChanges");
|
|
21
21
|
exports.excludeSchema = {
|
|
22
22
|
type: 'array',
|
|
23
|
-
items: { type: 'string' }
|
|
23
|
+
items: { type: 'string' },
|
|
24
24
|
};
|
|
25
25
|
exports.schema = {
|
|
26
26
|
type: 'array',
|
|
@@ -30,38 +30,37 @@ exports.schema = {
|
|
|
30
30
|
properties: {
|
|
31
31
|
script: {
|
|
32
32
|
type: 'string',
|
|
33
|
-
description:
|
|
34
|
-
default: ''
|
|
33
|
+
description: "A script that contains the rule's code",
|
|
34
|
+
default: '',
|
|
35
35
|
},
|
|
36
36
|
name: {
|
|
37
37
|
type: 'string',
|
|
38
|
-
description:
|
|
39
|
-
pattern: '^[^-\\s][a-zA-Z0-9-\\s]+[^-\\s]$'
|
|
38
|
+
description: "The name of the rule. Can only contain alphanumeric characters, spaces and '-'. Can neither start nor end with '-' or spaces",
|
|
39
|
+
pattern: '^[^-\\s][a-zA-Z0-9-\\s]+[^-\\s]$',
|
|
40
40
|
},
|
|
41
41
|
order: {
|
|
42
42
|
type: ['number', 'null'],
|
|
43
|
-
description:
|
|
44
|
-
default: null
|
|
43
|
+
description: "The rule's order in relation to other rules. A rule with a lower order than another rule executes first.",
|
|
44
|
+
default: null,
|
|
45
45
|
},
|
|
46
46
|
enabled: {
|
|
47
47
|
type: 'boolean',
|
|
48
48
|
description: 'true if the rule is enabled, false otherwise',
|
|
49
|
-
default: true
|
|
49
|
+
default: true,
|
|
50
50
|
},
|
|
51
51
|
stage: {
|
|
52
52
|
type: 'string',
|
|
53
|
-
description:
|
|
53
|
+
description: "The rule's execution stage",
|
|
54
54
|
default: 'login_success',
|
|
55
|
-
enum: ['login_success', 'login_failure', 'pre_authorize']
|
|
56
|
-
}
|
|
55
|
+
enum: ['login_success', 'login_failure', 'pre_authorize'],
|
|
56
|
+
},
|
|
57
57
|
},
|
|
58
|
-
required: ['name']
|
|
59
|
-
}
|
|
58
|
+
required: ['name'],
|
|
59
|
+
},
|
|
60
60
|
};
|
|
61
61
|
class RulesHandler extends default_1.default {
|
|
62
62
|
constructor(options) {
|
|
63
|
-
super(Object.assign(Object.assign({}, options), { type: 'rules', stripUpdateFields: ['stage']
|
|
64
|
-
}));
|
|
63
|
+
super(Object.assign(Object.assign({}, options), { type: 'rules', stripUpdateFields: ['stage'] }));
|
|
65
64
|
}
|
|
66
65
|
getType() {
|
|
67
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -89,18 +88,23 @@ class RulesHandler extends default_1.default {
|
|
|
89
88
|
handler: this,
|
|
90
89
|
assets: rules,
|
|
91
90
|
existing,
|
|
92
|
-
identifiers: ['id', 'name']
|
|
91
|
+
identifiers: ['id', 'name'],
|
|
92
|
+
allowDelete: false, //TODO: actually pass in correct allowDelete value
|
|
93
93
|
});
|
|
94
94
|
// Figure out the rules that need to be re-ordered
|
|
95
95
|
const futureRules = [...create, ...update];
|
|
96
96
|
const futureMaxOrder = Math.max(...futureRules.map((r) => r.order));
|
|
97
97
|
const existingMaxOrder = Math.max(...existing.map((r) => r.order));
|
|
98
98
|
let nextOrderNo = Math.max(futureMaxOrder, existingMaxOrder);
|
|
99
|
+
//@ts-ignore because we know reOrder is Asset[]
|
|
99
100
|
const reOrder = futureRules.reduce((accum, r) => {
|
|
100
101
|
const conflict = existing.find((f) => r.order === f.order && r.name !== f.name);
|
|
101
|
-
if (conflict) {
|
|
102
|
+
if (conflict !== undefined) {
|
|
102
103
|
nextOrderNo += 1;
|
|
103
|
-
|
|
104
|
+
return [
|
|
105
|
+
...accum,
|
|
106
|
+
Object.assign(Object.assign({}, conflict), { order: nextOrderNo }),
|
|
107
|
+
];
|
|
104
108
|
}
|
|
105
109
|
return accum;
|
|
106
110
|
}, []);
|
|
@@ -109,7 +113,7 @@ class RulesHandler extends default_1.default {
|
|
|
109
113
|
update,
|
|
110
114
|
create,
|
|
111
115
|
reOrder,
|
|
112
|
-
conflicts
|
|
116
|
+
conflicts,
|
|
113
117
|
};
|
|
114
118
|
});
|
|
115
119
|
}
|
|
@@ -127,24 +131,30 @@ class RulesHandler extends default_1.default {
|
|
|
127
131
|
const { update, create, del } = yield this.calcChanges(assets, true);
|
|
128
132
|
// Include del rules which are actually not going to be deleted but are excluded
|
|
129
133
|
// they can still muck up the ordering so we must take it into consideration.
|
|
130
|
-
const futureRules = [
|
|
134
|
+
const futureRules = [
|
|
135
|
+
...create,
|
|
136
|
+
...update,
|
|
137
|
+
...del.filter((r) => excludedRules.includes(r.name)),
|
|
138
|
+
];
|
|
131
139
|
// Detect rules with the same order
|
|
132
140
|
const rulesSameOrder = (0, utils_1.duplicateItems)(futureRules, 'order');
|
|
133
141
|
if (rulesSameOrder.length > 0) {
|
|
134
142
|
const formatted = rulesSameOrder.map((dups) => dups.map((d) => `${d.name}`));
|
|
135
|
-
throw new
|
|
136
|
-
${(0, utils_1.
|
|
143
|
+
throw new validationError_1.default(`There are multiple rules for the following stage-order combinations
|
|
144
|
+
${(0, utils_1.convertJsonToString)(formatted)}.
|
|
137
145
|
Only one rule must be defined for the same order number in a stage.`);
|
|
138
146
|
}
|
|
139
147
|
// Detect Rules that are changing stage as it's not allowed.
|
|
140
148
|
const existing = yield this.getType();
|
|
141
|
-
const stateChanged = futureRules
|
|
149
|
+
const stateChanged = futureRules
|
|
150
|
+
.reduce((changed, rule) => [
|
|
142
151
|
...changed,
|
|
143
|
-
...existing.filter((r) => rule.name.toLowerCase() === r.name.toLowerCase() && r.stage !== rule.stage)
|
|
144
|
-
]
|
|
152
|
+
...existing.filter((r) => rule.name.toLowerCase() === r.name.toLowerCase() && r.stage !== rule.stage),
|
|
153
|
+
], [])
|
|
154
|
+
.map((r) => r.name);
|
|
145
155
|
if (stateChanged.length > 0) {
|
|
146
|
-
throw new
|
|
147
|
-
${(0, utils_1.
|
|
156
|
+
throw new validationError_1.default(`The following rules changed stage which is not allowed:
|
|
157
|
+
${(0, utils_1.convertJsonToString)(stateChanged)}.
|
|
148
158
|
Rename the rules to recreate them and avoid this error.`);
|
|
149
159
|
}
|
|
150
160
|
yield _super.validate.call(this, assets);
|
|
@@ -162,20 +172,27 @@ class RulesHandler extends default_1.default {
|
|
|
162
172
|
// Figure out what needs to be updated vs created
|
|
163
173
|
const changes = yield this.calcChanges(assets);
|
|
164
174
|
// Temporally re-order rules with conflicting ordering
|
|
165
|
-
yield this.client.pool
|
|
175
|
+
yield this.client.pool
|
|
176
|
+
.addEachTask({
|
|
166
177
|
data: changes.reOrder,
|
|
167
|
-
generator: (rule) => this.client
|
|
178
|
+
generator: (rule) => this.client
|
|
179
|
+
.updateRule({ id: rule.id }, (0, utils_1.stripFields)(rule, this.stripUpdateFields))
|
|
180
|
+
.then(() => {
|
|
168
181
|
const updated = {
|
|
169
|
-
name: rule.name,
|
|
182
|
+
name: rule.name,
|
|
183
|
+
stage: rule.stage,
|
|
184
|
+
order: rule.order,
|
|
185
|
+
id: rule.id,
|
|
170
186
|
};
|
|
171
|
-
logger_1.default.info(`Temporally re-order Rule ${(0, utils_1.
|
|
172
|
-
})
|
|
173
|
-
})
|
|
187
|
+
logger_1.default.info(`Temporally re-order Rule ${(0, utils_1.convertJsonToString)(updated)}`);
|
|
188
|
+
}),
|
|
189
|
+
})
|
|
190
|
+
.promise();
|
|
174
191
|
yield _super.processChanges.call(this, assets, {
|
|
175
192
|
del: changes.del,
|
|
176
193
|
create: changes.create,
|
|
177
194
|
update: changes.update,
|
|
178
|
-
conflicts: changes.conflicts
|
|
195
|
+
conflicts: changes.conflicts,
|
|
179
196
|
});
|
|
180
197
|
});
|
|
181
198
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Assets, Asset, CalculatedChanges } from '../../../types';
|
|
2
|
+
import DefaultHandler from './default';
|
|
3
|
+
export declare const schema: {
|
|
4
|
+
type: string;
|
|
5
|
+
items: {
|
|
6
|
+
type: string;
|
|
7
|
+
properties: {
|
|
8
|
+
key: {
|
|
9
|
+
type: string;
|
|
10
|
+
pattern: string;
|
|
11
|
+
};
|
|
12
|
+
value: {
|
|
13
|
+
type: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
required: string[];
|
|
17
|
+
};
|
|
18
|
+
additionalProperties: boolean;
|
|
19
|
+
};
|
|
20
|
+
export default class RulesConfigsHandler extends DefaultHandler {
|
|
21
|
+
constructor(options: DefaultHandler);
|
|
22
|
+
getType(): Promise<Asset[]>;
|
|
23
|
+
objString(item: any): string;
|
|
24
|
+
calcChanges(assets: Assets): Promise<CalculatedChanges>;
|
|
25
|
+
}
|
|
@@ -20,16 +20,16 @@ exports.schema = {
|
|
|
20
20
|
type: 'object',
|
|
21
21
|
properties: {
|
|
22
22
|
key: { type: 'string', pattern: '^[A-Za-z0-9_-]*$' },
|
|
23
|
-
value: { type: 'string' }
|
|
23
|
+
value: { type: 'string' },
|
|
24
24
|
},
|
|
25
|
-
required: ['key', 'value']
|
|
25
|
+
required: ['key', 'value'],
|
|
26
26
|
},
|
|
27
|
-
additionalProperties: false
|
|
27
|
+
additionalProperties: false,
|
|
28
28
|
};
|
|
29
29
|
class RulesConfigsHandler extends default_1.default {
|
|
30
30
|
constructor(options) {
|
|
31
31
|
super(Object.assign(Object.assign({}, options), { type: 'rulesConfigs', id: 'key', functions: {
|
|
32
|
-
update: 'set' // Update or Creation of a ruleConfig is via set not update
|
|
32
|
+
update: 'set', // Update or Creation of a ruleConfig is via set not update
|
|
33
33
|
} }));
|
|
34
34
|
}
|
|
35
35
|
getType() {
|
|
@@ -45,12 +45,18 @@ class RulesConfigsHandler extends default_1.default {
|
|
|
45
45
|
const { rulesConfigs } = assets;
|
|
46
46
|
// Do nothing if not set
|
|
47
47
|
if (!rulesConfigs || !rulesConfigs.length)
|
|
48
|
-
return {
|
|
48
|
+
return {
|
|
49
|
+
del: [],
|
|
50
|
+
update: [],
|
|
51
|
+
create: [],
|
|
52
|
+
conflicts: [],
|
|
53
|
+
};
|
|
49
54
|
// Intention is to not delete/cleanup old configRules, that needs to be handled manually.
|
|
50
55
|
return {
|
|
51
56
|
del: [],
|
|
52
57
|
update: rulesConfigs,
|
|
53
|
-
create: []
|
|
58
|
+
create: [],
|
|
59
|
+
conflicts: [],
|
|
54
60
|
};
|
|
55
61
|
});
|
|
56
62
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import DefaultHandler from './default';
|
|
2
|
+
import { Asset, Assets } from '../../../types';
|
|
3
|
+
export declare const schema: {
|
|
4
|
+
type: string;
|
|
5
|
+
};
|
|
6
|
+
export default class TenantHandler extends DefaultHandler {
|
|
7
|
+
constructor(options: DefaultHandler);
|
|
8
|
+
getType(): Promise<Asset>;
|
|
9
|
+
validate(assets: Assets): Promise<void>;
|
|
10
|
+
processChanges(assets: Assets): Promise<void>;
|
|
11
|
+
}
|
|
@@ -42,14 +42,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
42
42
|
};
|
|
43
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
44
|
exports.schema = void 0;
|
|
45
|
-
const
|
|
45
|
+
const validationError_1 = __importDefault(require("../../validationError"));
|
|
46
46
|
const default_1 = __importStar(require("./default"));
|
|
47
47
|
const pages_1 = require("./pages");
|
|
48
48
|
const utils_1 = require("../../utils");
|
|
49
49
|
exports.schema = {
|
|
50
|
-
type: 'object'
|
|
50
|
+
type: 'object',
|
|
51
51
|
};
|
|
52
|
-
const blockPageKeys = [
|
|
52
|
+
const blockPageKeys = [
|
|
53
|
+
...Object.keys(pages_1.pageNameMap),
|
|
54
|
+
...Object.values(pages_1.pageNameMap),
|
|
55
|
+
...pages_1.supportedPages,
|
|
56
|
+
];
|
|
53
57
|
class TenantHandler extends default_1.default {
|
|
54
58
|
constructor(options) {
|
|
55
59
|
super(Object.assign(Object.assign({}, options), { type: 'tenant' }));
|
|
@@ -72,7 +76,7 @@ class TenantHandler extends default_1.default {
|
|
|
72
76
|
return;
|
|
73
77
|
const pageKeys = Object.keys(tenant).filter((k) => blockPageKeys.includes(k));
|
|
74
78
|
if (pageKeys.length > 0) {
|
|
75
|
-
throw new
|
|
79
|
+
throw new validationError_1.default(`The following pages ${(0, utils_1.convertJsonToString)(pageKeys)} were found in tenant settings. Pages should be set separately. Please refer to the documentation.`);
|
|
76
80
|
}
|
|
77
81
|
});
|
|
78
82
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import DefaultHandler from './default';
|
|
2
|
+
import { Assets } from '../../../types';
|
|
3
|
+
export declare const schema: {
|
|
4
|
+
type: string;
|
|
5
|
+
items: {
|
|
6
|
+
type: string;
|
|
7
|
+
additionalProperties: boolean;
|
|
8
|
+
properties: {
|
|
9
|
+
trigger_id: {
|
|
10
|
+
type: string;
|
|
11
|
+
properties: {
|
|
12
|
+
action_name: {
|
|
13
|
+
type: string;
|
|
14
|
+
enum: string[];
|
|
15
|
+
};
|
|
16
|
+
display_name: {
|
|
17
|
+
type: string;
|
|
18
|
+
default: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export default class TriggersHandler extends DefaultHandler {
|
|
26
|
+
existing: {
|
|
27
|
+
[key: string]: {
|
|
28
|
+
action_name: string;
|
|
29
|
+
display_name: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
constructor(options: DefaultHandler);
|
|
33
|
+
getType(): Promise<DefaultHandler['existing']>;
|
|
34
|
+
processChanges(assets: Assets): Promise<void>;
|
|
35
|
+
}
|
|
@@ -45,7 +45,7 @@ exports.schema = void 0;
|
|
|
45
45
|
const lodash_1 = __importDefault(require("lodash"));
|
|
46
46
|
const default_1 = __importStar(require("./default"));
|
|
47
47
|
const constants_1 = __importDefault(require("../../constants"));
|
|
48
|
-
const logger_1 = __importDefault(require("
|
|
48
|
+
const logger_1 = __importDefault(require("../../../logger"));
|
|
49
49
|
exports.schema = {
|
|
50
50
|
type: 'object',
|
|
51
51
|
items: {
|
|
@@ -56,15 +56,15 @@ exports.schema = {
|
|
|
56
56
|
type: 'object',
|
|
57
57
|
properties: {
|
|
58
58
|
action_name: { type: 'string', enum: constants_1.default.ACTIONS_TRIGGERS },
|
|
59
|
-
display_name: { type: 'string', default: '' }
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
59
|
+
display_name: { type: 'string', default: '' },
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
64
|
};
|
|
65
65
|
function isActionsDisabled(err) {
|
|
66
66
|
const errorBody = lodash_1.default.get(err, 'originalError.response.body') || {};
|
|
67
|
-
return
|
|
67
|
+
return err.statusCode === 403 && errorBody.errorCode === 'feature_not_enabled';
|
|
68
68
|
}
|
|
69
69
|
class TriggersHandler extends default_1.default {
|
|
70
70
|
constructor(options) {
|
|
@@ -76,8 +76,7 @@ class TriggersHandler extends default_1.default {
|
|
|
76
76
|
return this.existing;
|
|
77
77
|
}
|
|
78
78
|
// in case client version does not support actions
|
|
79
|
-
if (!this.client.actions
|
|
80
|
-
|| typeof this.client.actions.getAllTriggers !== 'function') {
|
|
79
|
+
if (!this.client.actions || typeof this.client.actions.getAllTriggers !== 'function') {
|
|
81
80
|
return [];
|
|
82
81
|
}
|
|
83
82
|
const triggerBindings = {};
|
|
@@ -87,12 +86,12 @@ class TriggersHandler extends default_1.default {
|
|
|
87
86
|
for (let i = 0; i < triggers.length; i++) {
|
|
88
87
|
const triggerId = triggers[i];
|
|
89
88
|
const { bindings } = yield this.client.actions.getTriggerBindings({
|
|
90
|
-
trigger_id: triggerId
|
|
89
|
+
trigger_id: triggerId,
|
|
91
90
|
});
|
|
92
91
|
if (bindings.length > 0) {
|
|
93
92
|
triggerBindings[triggerId] = bindings.map((binding) => ({
|
|
94
93
|
action_name: binding.action.name,
|
|
95
|
-
display_name: binding.display_name
|
|
94
|
+
display_name: binding.display_name,
|
|
96
95
|
}));
|
|
97
96
|
}
|
|
98
97
|
}
|
|
@@ -123,9 +122,9 @@ class TriggersHandler extends default_1.default {
|
|
|
123
122
|
const bindings = data.map((binding) => ({
|
|
124
123
|
ref: {
|
|
125
124
|
type: 'action_name',
|
|
126
|
-
value: binding.action_name
|
|
125
|
+
value: binding.action_name,
|
|
127
126
|
},
|
|
128
|
-
display_name: binding.display_name
|
|
127
|
+
display_name: binding.display_name,
|
|
129
128
|
}));
|
|
130
129
|
yield this.client.actions.updateTriggerBindings({ trigger_id: name }, { bindings });
|
|
131
130
|
this.didUpdate({ trigger_id: name });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Assets, Auth0APIClient, BaseAuth0APIClient } from '../../types';
|
|
2
|
+
import APIHandler from './handlers/default';
|
|
3
|
+
import { ConfigFunction } from '../../configFactory';
|
|
4
|
+
export declare type Stage = 'load' | 'validate' | 'processChanges';
|
|
5
|
+
export default class Auth0 {
|
|
6
|
+
client: Auth0APIClient;
|
|
7
|
+
config: ConfigFunction;
|
|
8
|
+
assets: Assets;
|
|
9
|
+
handlers: APIHandler[];
|
|
10
|
+
constructor(client: BaseAuth0APIClient, assets: Assets, config: ConfigFunction);
|
|
11
|
+
runStage(stage: Stage): Promise<void>;
|
|
12
|
+
validate(): Promise<void>;
|
|
13
|
+
loadAll(): Promise<void>;
|
|
14
|
+
processChanges(): Promise<void>;
|
|
15
|
+
}
|