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,51 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _default2 = _interopRequireDefault(_default);
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
const schema = exports.schema = {
|
|
15
|
-
type: 'object'
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
class BrandingHandler extends _default2.default {
|
|
19
|
-
constructor(options) {
|
|
20
|
-
super({ ...options,
|
|
21
|
-
type: 'branding'
|
|
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());
|
|
22
9
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
+
exports.schema = void 0;
|
|
16
|
+
const default_1 = __importDefault(require("./default"));
|
|
17
|
+
exports.schema = { type: 'object' };
|
|
18
|
+
class BrandingHandler extends default_1.default {
|
|
19
|
+
constructor(options) {
|
|
20
|
+
super(Object.assign(Object.assign({}, options), { type: 'branding' }));
|
|
21
|
+
}
|
|
22
|
+
getType() {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
// in case client version does not support branding
|
|
25
|
+
if (!this.client.branding || typeof this.client.branding.getSettings !== 'function') {
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
return yield this.client.branding.getSettings();
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
if (err.statusCode === 404)
|
|
33
|
+
return {};
|
|
34
|
+
if (err.statusCode === 501)
|
|
35
|
+
return {};
|
|
36
|
+
throw err;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
28
39
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
40
|
+
processChanges(assets) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const { branding } = assets;
|
|
43
|
+
// Do nothing if not set
|
|
44
|
+
if (!branding || !Object.keys(branding).length)
|
|
45
|
+
return;
|
|
46
|
+
yield this.client.branding.updateSettings({}, branding);
|
|
47
|
+
this.updated += 1;
|
|
48
|
+
this.didUpdate(branding);
|
|
49
|
+
});
|
|
36
50
|
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async processChanges(assets) {
|
|
40
|
-
const {
|
|
41
|
-
branding
|
|
42
|
-
} = assets;
|
|
43
|
-
if (!branding || !Object.keys(branding).length) return;
|
|
44
|
-
await this.client.branding.updateSettings({}, branding);
|
|
45
|
-
this.updated += 1;
|
|
46
|
-
this.didUpdate(branding);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
51
|
}
|
|
50
|
-
|
|
51
|
-
exports.default = BrandingHandler;
|
|
52
|
+
exports.default = BrandingHandler;
|
|
@@ -1,121 +1,123 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
5
17
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _default2 = _interopRequireDefault(_default);
|
|
13
|
-
|
|
14
|
-
var _utils = require("../../utils");
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
19
|
-
|
|
20
|
-
const schema = exports.schema = {
|
|
21
|
-
type: 'array',
|
|
22
|
-
items: {
|
|
23
|
-
type: 'object',
|
|
24
|
-
properties: {
|
|
25
|
-
client_id: {
|
|
26
|
-
type: 'string'
|
|
27
|
-
},
|
|
28
|
-
audience: {
|
|
29
|
-
type: 'string'
|
|
30
|
-
},
|
|
31
|
-
scope: {
|
|
32
|
-
type: 'array',
|
|
33
|
-
items: {
|
|
34
|
-
type: 'string'
|
|
35
|
-
},
|
|
36
|
-
uniqueItems: true
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
required: ['client_id', 'scope', 'audience']
|
|
40
|
-
}
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
41
23
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
audience: item.audience
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
32
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
33
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
34
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
35
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
36
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
37
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
57
38
|
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
39
|
+
};
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.schema = void 0;
|
|
42
|
+
const default_1 = __importStar(require("./default"));
|
|
43
|
+
const utils_1 = require("../../utils");
|
|
44
|
+
exports.schema = {
|
|
45
|
+
type: 'array',
|
|
46
|
+
items: {
|
|
47
|
+
type: 'object',
|
|
48
|
+
properties: {
|
|
49
|
+
client_id: { type: 'string' },
|
|
50
|
+
audience: { type: 'string' },
|
|
51
|
+
scope: {
|
|
52
|
+
type: 'array',
|
|
53
|
+
items: { type: 'string' },
|
|
54
|
+
uniqueItems: true
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
required: ['client_id', 'scope', 'audience']
|
|
63
58
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
59
|
+
};
|
|
60
|
+
class ClientHandler extends default_1.default {
|
|
61
|
+
constructor(config) {
|
|
62
|
+
super(Object.assign(Object.assign({}, config), { type: 'clientGrants', id: 'id', identifiers: ['id', ['client_id', 'audience']], stripUpdateFields: ['audience', 'client_id'] }));
|
|
63
|
+
}
|
|
64
|
+
objString(item) {
|
|
65
|
+
return super.objString({ id: item.id, client_id: item.client_id, audience: item.audience });
|
|
66
|
+
}
|
|
67
|
+
getType() {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
if (this.existing) {
|
|
70
|
+
return this.existing;
|
|
71
|
+
}
|
|
72
|
+
this.existing = yield this.client.clientGrants.getAll({ paginate: true, include_totals: true });
|
|
73
|
+
// Always filter out the client we are using to access Auth0 Management API
|
|
74
|
+
// As it could cause problems if the grants are deleted or updated etc
|
|
75
|
+
const currentClient = this.config('AUTH0_CLIENT_ID');
|
|
76
|
+
this.existing = this.existing.filter((grant) => grant.client_id !== currentClient);
|
|
77
|
+
return this.existing;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
// Run after clients are updated so we can convert client_id names to id's
|
|
81
|
+
processChanges(assets) {
|
|
82
|
+
const _super = Object.create(null, {
|
|
83
|
+
processChanges: { get: () => super.processChanges }
|
|
84
|
+
});
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
const { clientGrants } = assets;
|
|
87
|
+
// Do nothing if not set
|
|
88
|
+
if (!clientGrants)
|
|
89
|
+
return;
|
|
90
|
+
const clients = yield this.client.clients.getAll({ paginate: true, include_totals: true });
|
|
91
|
+
const excludedClientsByNames = (assets.exclude && assets.exclude.clients) || [];
|
|
92
|
+
const excludedClients = (0, utils_1.convertClientNamesToIds)(excludedClientsByNames, clients);
|
|
93
|
+
// Convert clients by name to the id
|
|
94
|
+
const formatted = assets.clientGrants.map((clientGrant) => {
|
|
95
|
+
const grant = Object.assign({}, clientGrant);
|
|
96
|
+
const found = clients.find((c) => c.name === grant.client_id);
|
|
97
|
+
if (found)
|
|
98
|
+
grant.client_id = found.client_id;
|
|
99
|
+
return grant;
|
|
100
|
+
});
|
|
101
|
+
// Always filter out the client we are using to access Auth0 Management API
|
|
102
|
+
const currentClient = this.config('AUTH0_CLIENT_ID');
|
|
103
|
+
const { del, update, create, conflicts } = yield this.calcChanges(Object.assign(Object.assign({}, assets), { clientGrants: formatted }));
|
|
104
|
+
const filterGrants = (list) => {
|
|
105
|
+
if (excludedClients.length) {
|
|
106
|
+
return list.filter((item) => item.client_id !== currentClient && ![...excludedClientsByNames, ...excludedClients].includes(item.client_id));
|
|
107
|
+
}
|
|
108
|
+
return list.filter((item) => item.client_id !== currentClient);
|
|
109
|
+
};
|
|
110
|
+
const changes = {
|
|
111
|
+
del: filterGrants(del),
|
|
112
|
+
update: filterGrants(update),
|
|
113
|
+
create: filterGrants(create),
|
|
114
|
+
conflicts: filterGrants(conflicts)
|
|
115
|
+
};
|
|
116
|
+
yield _super.processChanges.call(this, assets, Object.assign({}, changes));
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
__decorate([
|
|
121
|
+
(0, default_1.order)('60')
|
|
122
|
+
], ClientHandler.prototype, "processChanges", null);
|
|
123
|
+
exports.default = ClientHandler;
|
|
@@ -1,94 +1,76 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _default2 = _interopRequireDefault(_default);
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
const schema = exports.schema = {
|
|
15
|
-
type: 'array',
|
|
16
|
-
items: {
|
|
17
|
-
type: 'object',
|
|
18
|
-
properties: {
|
|
19
|
-
name: {
|
|
20
|
-
type: 'string',
|
|
21
|
-
minLength: 1,
|
|
22
|
-
pattern: '[^<>]+'
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
required: ['name']
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
class ClientHandler extends _default2.default {
|
|
30
|
-
constructor(config) {
|
|
31
|
-
super({ ...config,
|
|
32
|
-
type: 'clients',
|
|
33
|
-
id: 'client_id',
|
|
34
|
-
identifiers: ['client_id', 'name'],
|
|
35
|
-
objectFields: ['client_metadata'],
|
|
36
|
-
stripUpdateFields: ['callback_url_template', 'signing_keys', 'global', 'tenant', 'jwt_configuration.secret_encoded']
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
objString(item) {
|
|
41
|
-
return super.objString({
|
|
42
|
-
name: item.name,
|
|
43
|
-
client_id: item.client_id
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async processChanges(assets) {
|
|
48
|
-
const {
|
|
49
|
-
clients
|
|
50
|
-
} = assets;
|
|
51
|
-
if (!clients) return;
|
|
52
|
-
const excludedClients = assets.exclude && assets.exclude.clients || [];
|
|
53
|
-
const {
|
|
54
|
-
del,
|
|
55
|
-
update,
|
|
56
|
-
create,
|
|
57
|
-
conflicts
|
|
58
|
-
} = await this.calcChanges(assets);
|
|
59
|
-
const currentClient = this.config('AUTH0_CLIENT_ID');
|
|
60
|
-
|
|
61
|
-
const filterClients = list => {
|
|
62
|
-
if (excludedClients.length) {
|
|
63
|
-
return list.filter(item => item.client_id !== currentClient && !excludedClients.includes(item.name));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return list.filter(item => item.client_id !== currentClient);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const changes = {
|
|
70
|
-
del: filterClients(del),
|
|
71
|
-
update: filterClients(update),
|
|
72
|
-
create: filterClients(create),
|
|
73
|
-
conflicts: filterClients(conflicts)
|
|
74
|
-
};
|
|
75
|
-
await super.processChanges(assets, { ...changes
|
|
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());
|
|
76
9
|
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
+
exports.schema = void 0;
|
|
16
|
+
const default_1 = __importDefault(require("./default"));
|
|
17
|
+
exports.schema = {
|
|
18
|
+
type: 'array',
|
|
19
|
+
items: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: {
|
|
22
|
+
name: { type: 'string', minLength: 1, pattern: '[^<>]+' }
|
|
23
|
+
},
|
|
24
|
+
required: ['name']
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
class ClientHandler extends default_1.default {
|
|
28
|
+
constructor(config) {
|
|
29
|
+
super(Object.assign(Object.assign({}, config), { type: 'clients', id: 'client_id', identifiers: ['client_id', 'name'], objectFields: ['client_metadata'], stripUpdateFields: [
|
|
30
|
+
// Fields not allowed during updates
|
|
31
|
+
'callback_url_template', 'signing_keys', 'global', 'tenant', 'jwt_configuration.secret_encoded'
|
|
32
|
+
] }));
|
|
33
|
+
}
|
|
34
|
+
objString(item) {
|
|
35
|
+
return super.objString({ name: item.name, client_id: item.client_id });
|
|
36
|
+
}
|
|
37
|
+
processChanges(assets) {
|
|
38
|
+
const _super = Object.create(null, {
|
|
39
|
+
processChanges: { get: () => super.processChanges }
|
|
40
|
+
});
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const { clients } = assets;
|
|
43
|
+
// Do nothing if not set
|
|
44
|
+
if (!clients)
|
|
45
|
+
return;
|
|
46
|
+
const excludedClients = (assets.exclude && assets.exclude.clients) || [];
|
|
47
|
+
const { del, update, create, conflicts } = yield this.calcChanges(assets);
|
|
48
|
+
// Always filter out the client we are using to access Auth0 Management API
|
|
49
|
+
// As it could cause problems if it gets deleted or updated etc
|
|
50
|
+
const currentClient = this.config('AUTH0_CLIENT_ID');
|
|
51
|
+
const filterClients = (list) => {
|
|
52
|
+
if (excludedClients.length) {
|
|
53
|
+
return list.filter((item) => item.client_id !== currentClient && !excludedClients.includes(item.name));
|
|
54
|
+
}
|
|
55
|
+
return list.filter((item) => item.client_id !== currentClient);
|
|
56
|
+
};
|
|
57
|
+
const changes = {
|
|
58
|
+
del: filterClients(del),
|
|
59
|
+
update: filterClients(update),
|
|
60
|
+
create: filterClients(create),
|
|
61
|
+
conflicts: filterClients(conflicts)
|
|
62
|
+
};
|
|
63
|
+
yield _super.processChanges.call(this, assets, Object.assign({}, changes));
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
getType() {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
if (this.existing) {
|
|
69
|
+
return this.existing;
|
|
70
|
+
}
|
|
71
|
+
this.existing = yield this.client.clients.getAll({ paginate: true, include_totals: true, is_global: false });
|
|
72
|
+
return this.existing;
|
|
73
|
+
});
|
|
82
74
|
}
|
|
83
|
-
|
|
84
|
-
this.existing = await this.client.clients.getAll({
|
|
85
|
-
paginate: true,
|
|
86
|
-
include_totals: true,
|
|
87
|
-
is_global: false
|
|
88
|
-
});
|
|
89
|
-
return this.existing;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
75
|
}
|
|
93
|
-
|
|
94
|
-
exports.default = ClientHandler;
|
|
76
|
+
exports.default = ClientHandler;
|