auth0-deploy-cli 8.20.4-beta.0 → 8.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +5 -46
- package/.eslintignore +5 -0
- package/.eslintrc +69 -0
- package/CHANGELOG.md +15 -6
- package/lib/args.js +1 -0
- package/lib/args.js.map +1 -0
- package/lib/commands/export.js +49 -41
- package/lib/commands/export.js.map +1 -0
- package/lib/commands/import.js +43 -36
- package/lib/commands/import.js.map +1 -0
- package/lib/commands/index.js +1 -0
- package/lib/commands/index.js.map +1 -0
- package/lib/configFactory.js +1 -0
- package/lib/configFactory.js.map +1 -0
- package/lib/context/defaults.js +10 -38
- package/lib/context/defaults.js.map +1 -0
- package/lib/context/directory/handlers/actions.js +39 -40
- package/lib/context/directory/handlers/actions.js.map +1 -0
- package/lib/context/directory/handlers/attackProtection.js +34 -22
- package/lib/context/directory/handlers/attackProtection.js.map +1 -0
- package/lib/context/directory/handlers/branding.js +21 -12
- package/lib/context/directory/handlers/branding.js.map +1 -0
- package/lib/context/directory/handlers/clientGrants.js +62 -52
- package/lib/context/directory/handlers/clientGrants.js.map +1 -0
- package/lib/context/directory/handlers/clients.js +60 -17
- package/lib/context/directory/handlers/clients.js.map +1 -0
- package/lib/context/directory/handlers/connectionProfiles.d.ts +11 -0
- package/lib/context/directory/handlers/connectionProfiles.js +59 -0
- package/lib/context/directory/handlers/connectionProfiles.js.map +1 -0
- package/lib/context/directory/handlers/connections.js +41 -32
- package/lib/context/directory/handlers/connections.js.map +1 -0
- package/lib/context/directory/handlers/customDomains.js +21 -9
- package/lib/context/directory/handlers/customDomains.js.map +1 -0
- package/lib/context/directory/handlers/databases.js +35 -37
- package/lib/context/directory/handlers/databases.js.map +1 -0
- package/lib/context/directory/handlers/emailProvider.js +36 -22
- package/lib/context/directory/handlers/emailProvider.js.map +1 -0
- package/lib/context/directory/handlers/emailTemplates.js +29 -20
- package/lib/context/directory/handlers/emailTemplates.js.map +1 -0
- package/lib/context/directory/handlers/flowVaultConnections.js +49 -39
- package/lib/context/directory/handlers/flowVaultConnections.js.map +1 -0
- package/lib/context/directory/handlers/flows.js +48 -38
- package/lib/context/directory/handlers/flows.js.map +1 -0
- package/lib/context/directory/handlers/forms.js +48 -38
- package/lib/context/directory/handlers/forms.js.map +1 -0
- package/lib/context/directory/handlers/guardianFactorProviders.js +21 -9
- package/lib/context/directory/handlers/guardianFactorProviders.js.map +1 -0
- package/lib/context/directory/handlers/guardianFactorTemplates.js +21 -9
- package/lib/context/directory/handlers/guardianFactorTemplates.js.map +1 -0
- package/lib/context/directory/handlers/guardianFactors.js +21 -9
- package/lib/context/directory/handlers/guardianFactors.js.map +1 -0
- package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.js +20 -8
- package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.js.map +1 -0
- package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.js +20 -8
- package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.js.map +1 -0
- package/lib/context/directory/handlers/guardianPolicies.js +20 -8
- package/lib/context/directory/handlers/guardianPolicies.js.map +1 -0
- package/lib/context/directory/handlers/hooks.js +34 -24
- package/lib/context/directory/handlers/hooks.js.map +1 -0
- package/lib/context/directory/handlers/index.js +3 -0
- package/lib/context/directory/handlers/index.js.map +1 -0
- package/lib/context/directory/handlers/logStreams.js +24 -12
- package/lib/context/directory/handlers/logStreams.js.map +1 -0
- package/lib/context/directory/handlers/networkACLs.js +34 -22
- package/lib/context/directory/handlers/networkACLs.js.map +1 -0
- package/lib/context/directory/handlers/organizations.js +44 -39
- package/lib/context/directory/handlers/organizations.js.map +1 -0
- package/lib/context/directory/handlers/pages.js +37 -31
- package/lib/context/directory/handlers/pages.js.map +1 -0
- package/lib/context/directory/handlers/phoneProvider.js +24 -12
- package/lib/context/directory/handlers/phoneProvider.js.map +1 -0
- package/lib/context/directory/handlers/prompts.js +76 -58
- package/lib/context/directory/handlers/prompts.js.map +1 -0
- package/lib/context/directory/handlers/resourceServers.d.ts +1 -1
- package/lib/context/directory/handlers/resourceServers.js +30 -18
- package/lib/context/directory/handlers/resourceServers.js.map +1 -0
- package/lib/context/directory/handlers/roles.js +31 -21
- package/lib/context/directory/handlers/roles.js.map +1 -0
- package/lib/context/directory/handlers/rules.js +32 -22
- package/lib/context/directory/handlers/rules.js.map +1 -0
- package/lib/context/directory/handlers/rulesConfigs.js +15 -3
- package/lib/context/directory/handlers/rulesConfigs.js.map +1 -0
- package/lib/context/directory/handlers/selfServiceProfiles.js +40 -28
- package/lib/context/directory/handlers/selfServiceProfiles.js.map +1 -0
- package/lib/context/directory/handlers/tenant.js +34 -14
- package/lib/context/directory/handlers/tenant.js.map +1 -0
- package/lib/context/directory/handlers/themes.js +21 -9
- package/lib/context/directory/handlers/themes.js.map +1 -0
- package/lib/context/directory/handlers/triggers.d.ts +1 -1
- package/lib/context/directory/handlers/triggers.js +26 -16
- package/lib/context/directory/handlers/triggers.js.map +1 -0
- package/lib/context/directory/handlers/userAttributeProfiles.d.ts +1 -1
- package/lib/context/directory/handlers/userAttributeProfiles.js +26 -16
- package/lib/context/directory/handlers/userAttributeProfiles.js.map +1 -0
- package/lib/context/directory/index.js +80 -66
- package/lib/context/directory/index.js.map +1 -0
- package/lib/context/index.js +20 -9
- package/lib/context/index.js.map +1 -0
- package/lib/context/yaml/handlers/actions.js +41 -39
- package/lib/context/yaml/handlers/actions.js.map +1 -0
- package/lib/context/yaml/handlers/attackProtection.js +41 -27
- package/lib/context/yaml/handlers/attackProtection.js.map +1 -0
- package/lib/context/yaml/handlers/branding.js +69 -47
- package/lib/context/yaml/handlers/branding.js.map +1 -0
- package/lib/context/yaml/handlers/clientGrants.js +40 -26
- package/lib/context/yaml/handlers/clientGrants.js.map +1 -0
- package/lib/context/yaml/handlers/clients.js +85 -41
- package/lib/context/yaml/handlers/clients.js.map +1 -0
- package/lib/context/yaml/handlers/connectionProfiles.d.ts +11 -0
- package/lib/context/yaml/handlers/connectionProfiles.js +44 -0
- package/lib/context/yaml/handlers/connectionProfiles.js.map +1 -0
- package/lib/context/yaml/handlers/connections.js +67 -63
- package/lib/context/yaml/handlers/connections.js.map +1 -0
- package/lib/context/yaml/handlers/customDomains.js +19 -7
- package/lib/context/yaml/handlers/customDomains.js.map +1 -0
- package/lib/context/yaml/handlers/databases.js +65 -63
- package/lib/context/yaml/handlers/databases.js.map +1 -0
- package/lib/context/yaml/handlers/emailProvider.js +37 -22
- package/lib/context/yaml/handlers/emailProvider.js.map +1 -0
- package/lib/context/yaml/handlers/emailTemplates.js +39 -28
- package/lib/context/yaml/handlers/emailTemplates.js.map +1 -0
- package/lib/context/yaml/handlers/flowVaultConnections.js +50 -36
- package/lib/context/yaml/handlers/flowVaultConnections.js.map +1 -0
- package/lib/context/yaml/handlers/flows.js +66 -55
- package/lib/context/yaml/handlers/flows.js.map +1 -0
- package/lib/context/yaml/handlers/forms.js +66 -55
- package/lib/context/yaml/handlers/forms.js.map +1 -0
- package/lib/context/yaml/handlers/guardianFactorProviders.js +19 -7
- package/lib/context/yaml/handlers/guardianFactorProviders.js.map +1 -0
- package/lib/context/yaml/handlers/guardianFactorTemplates.js +19 -7
- package/lib/context/yaml/handlers/guardianFactorTemplates.js.map +1 -0
- package/lib/context/yaml/handlers/guardianFactors.js +19 -7
- package/lib/context/yaml/handlers/guardianFactors.js.map +1 -0
- package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.js +19 -7
- package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.js.map +1 -0
- package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.js +19 -7
- package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.js.map +1 -0
- package/lib/context/yaml/handlers/guardianPolicies.js +19 -7
- package/lib/context/yaml/handlers/guardianPolicies.js.map +1 -0
- package/lib/context/yaml/handlers/hooks.js +48 -34
- package/lib/context/yaml/handlers/hooks.js.map +1 -0
- package/lib/context/yaml/handlers/index.js +3 -0
- package/lib/context/yaml/handlers/index.js.map +1 -0
- package/lib/context/yaml/handlers/logStreams.js +30 -16
- package/lib/context/yaml/handlers/logStreams.js.map +1 -0
- package/lib/context/yaml/handlers/networkACLs.js +39 -25
- package/lib/context/yaml/handlers/networkACLs.js.map +1 -0
- package/lib/context/yaml/handlers/organizations.js +46 -37
- package/lib/context/yaml/handlers/organizations.js.map +1 -0
- package/lib/context/yaml/handlers/pages.js +39 -31
- package/lib/context/yaml/handlers/pages.js.map +1 -0
- package/lib/context/yaml/handlers/phoneProvider.js +31 -17
- package/lib/context/yaml/handlers/phoneProvider.js.map +1 -0
- package/lib/context/yaml/handlers/prompts.js +47 -22
- package/lib/context/yaml/handlers/prompts.js.map +1 -0
- package/lib/context/yaml/handlers/resourceServers.d.ts +1 -1
- package/lib/context/yaml/handlers/resourceServers.js +33 -21
- package/lib/context/yaml/handlers/resourceServers.js.map +1 -0
- package/lib/context/yaml/handlers/roles.js +33 -19
- package/lib/context/yaml/handlers/roles.js.map +1 -0
- package/lib/context/yaml/handlers/rules.js +39 -28
- package/lib/context/yaml/handlers/rules.js.map +1 -0
- package/lib/context/yaml/handlers/rulesConfigs.js +28 -14
- package/lib/context/yaml/handlers/rulesConfigs.js.map +1 -0
- package/lib/context/yaml/handlers/selfServiceProfiles.js +43 -29
- package/lib/context/yaml/handlers/selfServiceProfiles.js.map +1 -0
- package/lib/context/yaml/handlers/tenant.js +41 -19
- package/lib/context/yaml/handlers/tenant.js.map +1 -0
- package/lib/context/yaml/handlers/themes.js +19 -7
- package/lib/context/yaml/handlers/themes.js.map +1 -0
- package/lib/context/yaml/handlers/triggers.d.ts +1 -1
- package/lib/context/yaml/handlers/triggers.js +29 -15
- package/lib/context/yaml/handlers/triggers.js.map +1 -0
- package/lib/context/yaml/handlers/userAttributeProfiles.d.ts +1 -1
- package/lib/context/yaml/handlers/userAttributeProfiles.js +19 -7
- package/lib/context/yaml/handlers/userAttributeProfiles.js.map +1 -0
- package/lib/context/yaml/index.js +128 -120
- package/lib/context/yaml/index.js.map +1 -0
- package/lib/index.d.ts +96 -4
- package/lib/index.js +34 -24
- package/lib/index.js.map +1 -0
- package/lib/keywordPreservation.d.ts +1 -1
- package/lib/keywordPreservation.js +6 -10
- package/lib/keywordPreservation.js.map +1 -0
- package/lib/logger.js +1 -0
- package/lib/logger.js.map +1 -0
- package/lib/readonly.js +4 -3
- package/lib/readonly.js.map +1 -0
- package/lib/sessionDurationsToMinutes.js +1 -0
- package/lib/sessionDurationsToMinutes.js.map +1 -0
- package/lib/tools/auth0/client.js +127 -108
- package/lib/tools/auth0/client.js.map +1 -0
- package/lib/tools/auth0/handlers/actions.d.ts +26 -8
- package/lib/tools/auth0/handlers/actions.js +149 -138
- package/lib/tools/auth0/handlers/actions.js.map +1 -0
- package/lib/tools/auth0/handlers/attackProtection.js +92 -80
- package/lib/tools/auth0/handlers/attackProtection.js.map +1 -0
- package/lib/tools/auth0/handlers/branding.js +99 -75
- package/lib/tools/auth0/handlers/branding.js.map +1 -0
- package/lib/tools/auth0/handlers/clientGrants.d.ts +9 -2
- package/lib/tools/auth0/handlers/clientGrants.js +72 -65
- package/lib/tools/auth0/handlers/clientGrants.js.map +1 -0
- package/lib/tools/auth0/handlers/clients.d.ts +85 -7
- package/lib/tools/auth0/handlers/clients.js +187 -66
- package/lib/tools/auth0/handlers/clients.js.map +1 -0
- package/lib/tools/auth0/handlers/connectionProfiles.d.ts +182 -0
- package/lib/tools/auth0/handlers/connectionProfiles.js +239 -0
- package/lib/tools/auth0/handlers/connectionProfiles.js.map +1 -0
- package/lib/tools/auth0/handlers/connections.d.ts +1 -3
- package/lib/tools/auth0/handlers/connections.js +135 -130
- package/lib/tools/auth0/handlers/connections.js.map +1 -0
- package/lib/tools/auth0/handlers/customDomains.d.ts +1 -4
- package/lib/tools/auth0/handlers/customDomains.js +53 -43
- package/lib/tools/auth0/handlers/customDomains.js.map +1 -0
- package/lib/tools/auth0/handlers/databases.js +114 -94
- package/lib/tools/auth0/handlers/databases.js.map +1 -0
- package/lib/tools/auth0/handlers/default.d.ts +2 -2
- package/lib/tools/auth0/handlers/default.js +171 -210
- package/lib/tools/auth0/handlers/default.js.map +1 -0
- package/lib/tools/auth0/handlers/emailProvider.js +52 -41
- package/lib/tools/auth0/handlers/emailProvider.js.map +1 -0
- package/lib/tools/auth0/handlers/emailTemplates.js +71 -49
- package/lib/tools/auth0/handlers/emailTemplates.js.map +1 -0
- package/lib/tools/auth0/handlers/flowVaultConnections.d.ts +12 -5
- package/lib/tools/auth0/handlers/flowVaultConnections.js +143 -108
- package/lib/tools/auth0/handlers/flowVaultConnections.js.map +1 -0
- package/lib/tools/auth0/handlers/flows.d.ts +3 -2
- package/lib/tools/auth0/handlers/flows.js +129 -92
- package/lib/tools/auth0/handlers/flows.js.map +1 -0
- package/lib/tools/auth0/handlers/forms.d.ts +3 -3
- package/lib/tools/auth0/handlers/forms.js +112 -98
- package/lib/tools/auth0/handlers/forms.js.map +1 -0
- package/lib/tools/auth0/handlers/guardianFactorProviders.js +84 -61
- package/lib/tools/auth0/handlers/guardianFactorProviders.js.map +1 -0
- package/lib/tools/auth0/handlers/guardianFactorTemplates.js +68 -46
- package/lib/tools/auth0/handlers/guardianFactorTemplates.js.map +1 -0
- package/lib/tools/auth0/handlers/guardianFactors.js +45 -35
- package/lib/tools/auth0/handlers/guardianFactors.js.map +1 -0
- package/lib/tools/auth0/handlers/guardianPhoneFactorMessageTypes.js +45 -29
- package/lib/tools/auth0/handlers/guardianPhoneFactorMessageTypes.js.map +1 -0
- package/lib/tools/auth0/handlers/guardianPhoneFactorSelectedProvider.js +45 -29
- package/lib/tools/auth0/handlers/guardianPhoneFactorSelectedProvider.js.map +1 -0
- package/lib/tools/auth0/handlers/guardianPolicies.js +35 -20
- package/lib/tools/auth0/handlers/guardianPolicies.js.map +1 -0
- package/lib/tools/auth0/handlers/hooks.js +153 -123
- package/lib/tools/auth0/handlers/hooks.js.map +1 -0
- package/lib/tools/auth0/handlers/index.js +3 -0
- package/lib/tools/auth0/handlers/index.js.map +1 -0
- package/lib/tools/auth0/handlers/logStreams.js +47 -42
- package/lib/tools/auth0/handlers/logStreams.js.map +1 -0
- package/lib/tools/auth0/handlers/networkACLs.d.ts +4 -5
- package/lib/tools/auth0/handlers/networkACLs.js +133 -115
- package/lib/tools/auth0/handlers/networkACLs.js.map +1 -0
- package/lib/tools/auth0/handlers/organizations.d.ts +9 -10
- package/lib/tools/auth0/handlers/organizations.js +429 -360
- package/lib/tools/auth0/handlers/organizations.js.map +1 -0
- package/lib/tools/auth0/handlers/pages.js +83 -74
- package/lib/tools/auth0/handlers/pages.js.map +1 -0
- package/lib/tools/auth0/handlers/phoneProvider.d.ts +2 -2
- package/lib/tools/auth0/handlers/phoneProvider.js +82 -69
- package/lib/tools/auth0/handlers/phoneProvider.js.map +1 -0
- package/lib/tools/auth0/handlers/prompts.d.ts +5 -5
- package/lib/tools/auth0/handlers/prompts.js +235 -240
- package/lib/tools/auth0/handlers/prompts.js.map +1 -0
- package/lib/tools/auth0/handlers/resourceServers.d.ts +1 -3
- package/lib/tools/auth0/handlers/resourceServers.js +60 -59
- package/lib/tools/auth0/handlers/resourceServers.js.map +1 -0
- package/lib/tools/auth0/handlers/roles.js +178 -162
- package/lib/tools/auth0/handlers/roles.js.map +1 -0
- package/lib/tools/auth0/handlers/rules.js +162 -144
- package/lib/tools/auth0/handlers/rules.js.map +1 -0
- package/lib/tools/auth0/handlers/rulesConfigs.js +39 -30
- package/lib/tools/auth0/handlers/rulesConfigs.js.map +1 -0
- package/lib/tools/auth0/handlers/scimHandler.d.ts +3 -4
- package/lib/tools/auth0/handlers/scimHandler.js +132 -110
- package/lib/tools/auth0/handlers/scimHandler.js.map +1 -0
- package/lib/tools/auth0/handlers/selfServiceProfiles.d.ts +5 -13
- package/lib/tools/auth0/handlers/selfServiceProfiles.js +204 -170
- package/lib/tools/auth0/handlers/selfServiceProfiles.js.map +1 -0
- package/lib/tools/auth0/handlers/tenant.d.ts +3 -5
- package/lib/tools/auth0/handlers/tenant.js +52 -45
- package/lib/tools/auth0/handlers/tenant.js.map +1 -0
- package/lib/tools/auth0/handlers/themes.d.ts +12 -12
- package/lib/tools/auth0/handlers/themes.js +102 -86
- package/lib/tools/auth0/handlers/themes.js.map +1 -0
- package/lib/tools/auth0/handlers/triggers.js +75 -59
- package/lib/tools/auth0/handlers/triggers.js.map +1 -0
- package/lib/tools/auth0/handlers/userAttributeProfiles.d.ts +4 -4
- package/lib/tools/auth0/handlers/userAttributeProfiles.js +63 -56
- package/lib/tools/auth0/handlers/userAttributeProfiles.js.map +1 -0
- package/lib/tools/auth0/index.js +48 -35
- package/lib/tools/auth0/index.js.map +1 -0
- package/lib/tools/auth0/schema.js +4 -6
- package/lib/tools/auth0/schema.js.map +1 -0
- package/lib/tools/calculateChanges.js +15 -24
- package/lib/tools/calculateChanges.js.map +1 -0
- package/lib/tools/constants.d.ts +3 -2
- package/lib/tools/constants.js +2 -0
- package/lib/tools/constants.js.map +1 -0
- package/lib/tools/deploy.js +29 -17
- package/lib/tools/deploy.js.map +1 -0
- package/lib/tools/index.d.ts +89 -3
- package/lib/tools/index.js +2 -3
- package/lib/tools/index.js.map +1 -0
- package/lib/tools/utils.d.ts +1 -1
- package/lib/tools/utils.js +22 -12
- package/lib/tools/utils.js.map +1 -0
- package/lib/tools/validationError.js +1 -0
- package/lib/tools/validationError.js.map +1 -0
- package/lib/types.d.ts +6 -9
- package/lib/types.js +1 -0
- package/lib/types.js.map +1 -0
- package/lib/utils.d.ts +58 -3
- package/lib/utils.js +5 -8
- package/lib/utils.js.map +1 -0
- package/package.json +10 -11
- package/tsconfig.json +3 -4
- package/eslint.config.js +0 -130
|
@@ -38,12 +38,21 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
38
38
|
return result;
|
|
39
39
|
};
|
|
40
40
|
})();
|
|
41
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
42
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
43
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
44
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
45
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
46
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
47
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
48
|
+
});
|
|
49
|
+
};
|
|
41
50
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
42
51
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
43
52
|
};
|
|
44
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
54
|
exports.schema = void 0;
|
|
46
|
-
const lodash_1 = require("lodash");
|
|
55
|
+
const lodash_1 = __importStar(require("lodash"));
|
|
47
56
|
const default_1 = __importStar(require("./default"));
|
|
48
57
|
const calculateChanges_1 = require("../../calculateChanges");
|
|
49
58
|
const logger_1 = __importDefault(require("../../../logger"));
|
|
@@ -122,408 +131,468 @@ exports.schema = {
|
|
|
122
131
|
};
|
|
123
132
|
class OrganizationsHandler extends default_1.default {
|
|
124
133
|
constructor(config) {
|
|
125
|
-
super({
|
|
126
|
-
...config,
|
|
127
|
-
type: 'organizations',
|
|
128
|
-
id: 'id',
|
|
129
|
-
});
|
|
134
|
+
super(Object.assign(Object.assign({}, config), { type: 'organizations', id: 'id' }));
|
|
130
135
|
}
|
|
131
|
-
|
|
132
|
-
|
|
136
|
+
deleteOrganization(org) {
|
|
137
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
yield this.client.organizations.delete({ id: org.id });
|
|
139
|
+
});
|
|
133
140
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
this.config('AUTH0_ALLOW_DELETE') === true
|
|
137
|
-
|
|
138
|
-
.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
deleteOrganizations(data) {
|
|
142
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
if (this.config('AUTH0_ALLOW_DELETE') === 'true' ||
|
|
144
|
+
this.config('AUTH0_ALLOW_DELETE') === true) {
|
|
145
|
+
yield this.client.pool
|
|
146
|
+
.addEachTask({
|
|
147
|
+
data: data || [],
|
|
148
|
+
generator: (item) => this.deleteOrganization(item)
|
|
149
|
+
.then(() => {
|
|
150
|
+
this.didDelete(item);
|
|
151
|
+
this.deleted += 1;
|
|
152
|
+
})
|
|
153
|
+
.catch((err) => {
|
|
154
|
+
throw new Error(`Problem deleting ${this.type} ${this.objString(item)}\n${err}`);
|
|
155
|
+
}),
|
|
144
156
|
})
|
|
145
|
-
.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
.promise();
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
logger_1.default.warn(`Detected the following organizations should be deleted. Doing so may be destructive.\nYou can enable deletes by setting 'AUTH0_ALLOW_DELETE' to true in the config
|
|
157
|
+
.promise();
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
logger_1.default.warn(`Detected the following organizations should be deleted. Doing so may be destructive.\nYou can enable deletes by setting 'AUTH0_ALLOW_DELETE' to true in the config
|
|
153
161
|
\n${data.map((i) => this.objString(i)).join('\n')}`);
|
|
154
|
-
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
createOrganization(org) {
|
|
166
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
+
const organization = Object.assign({}, org);
|
|
168
|
+
delete organization.connections;
|
|
169
|
+
delete organization.client_grants;
|
|
170
|
+
if ('discovery_domains' in organization) {
|
|
171
|
+
delete organization.discovery_domains;
|
|
172
|
+
}
|
|
173
|
+
const { data: created } = yield this.client.organizations.create(organization);
|
|
174
|
+
if (typeof org.connections !== 'undefined' && org.connections.length > 0) {
|
|
175
|
+
yield Promise.all(org.connections.map((conn) => this.client.organizations.addEnabledConnection({ id: created.id }, conn)));
|
|
176
|
+
}
|
|
177
|
+
if (typeof org.client_grants !== 'undefined' && org.client_grants.length > 0) {
|
|
178
|
+
yield Promise.all(org.client_grants.map((organizationClientGrants) => this.createOrganizationClientGrants(created.id, this.getClientGrantIDByClientName(organizationClientGrants.client_id))));
|
|
179
|
+
}
|
|
180
|
+
if (typeof org.discovery_domains !== 'undefined' && org.discovery_domains.length > 0) {
|
|
181
|
+
yield this.client.pool
|
|
182
|
+
.addEachTask({
|
|
183
|
+
data: org.discovery_domains,
|
|
184
|
+
generator: (discoveryDomain) => this.createOrganizationDiscoveryDomain(created.id, {
|
|
185
|
+
domain: discoveryDomain === null || discoveryDomain === void 0 ? void 0 : discoveryDomain.domain,
|
|
186
|
+
status: discoveryDomain === null || discoveryDomain === void 0 ? void 0 : discoveryDomain.status,
|
|
187
|
+
}).catch((err) => {
|
|
188
|
+
throw new Error(`Problem creating discovery domain ${discoveryDomain === null || discoveryDomain === void 0 ? void 0 : discoveryDomain.domain} for organization ${created.id}\n${err}`);
|
|
189
|
+
}),
|
|
190
|
+
})
|
|
191
|
+
.promise();
|
|
192
|
+
}
|
|
193
|
+
return created;
|
|
194
|
+
});
|
|
155
195
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
delete organization.client_grants;
|
|
160
|
-
if ('discovery_domains' in organization) {
|
|
161
|
-
delete organization.discovery_domains;
|
|
162
|
-
}
|
|
163
|
-
const { data: created } = await this.client.organizations.create(organization);
|
|
164
|
-
if (typeof org.connections !== 'undefined' && org.connections.length > 0) {
|
|
165
|
-
await Promise.all(org.connections.map((conn) => this.client.organizations.enabledConnections.add(created.id, conn)));
|
|
166
|
-
}
|
|
167
|
-
if (typeof org.client_grants !== 'undefined' && org.client_grants.length > 0) {
|
|
168
|
-
await Promise.all(org.client_grants.map((organizationClientGrants) => this.createOrganizationClientGrants(created.id, this.getClientGrantIDByClientName(organizationClientGrants.client_id))));
|
|
169
|
-
}
|
|
170
|
-
if (typeof org.discovery_domains !== 'undefined' && org.discovery_domains.length > 0) {
|
|
171
|
-
await this.client.pool
|
|
196
|
+
createOrganizations(creates) {
|
|
197
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
198
|
+
yield this.client.pool
|
|
172
199
|
.addEachTask({
|
|
173
|
-
data:
|
|
174
|
-
generator: (
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
200
|
+
data: creates || [],
|
|
201
|
+
generator: (item) => this.createOrganization(item)
|
|
202
|
+
.then((data) => {
|
|
203
|
+
this.didCreate(data);
|
|
204
|
+
this.created += 1;
|
|
205
|
+
})
|
|
206
|
+
.catch((err) => {
|
|
207
|
+
throw new Error(`Problem creating ${this.type} ${this.objString(item)}\n${err}`);
|
|
179
208
|
}),
|
|
180
209
|
})
|
|
181
210
|
.promise();
|
|
182
|
-
}
|
|
183
|
-
return created;
|
|
211
|
+
});
|
|
184
212
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
213
|
+
updateOrganization(org, organizations) {
|
|
214
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
215
|
+
var _a, _b;
|
|
216
|
+
const { connections: existingConnections, client_grants: existingClientGrants, discovery_domains: existingDiscoveryDomains, } = yield organizations.find((orgToUpdate) => orgToUpdate.name === org.name);
|
|
217
|
+
const params = { id: org.id };
|
|
218
|
+
const { connections, client_grants: organizationClientGrants, discovery_domains: organizationDiscoveryDomains, } = org;
|
|
219
|
+
delete org.connections;
|
|
220
|
+
delete org.name;
|
|
221
|
+
delete org.id;
|
|
222
|
+
delete org.client_grants;
|
|
223
|
+
delete org.discovery_domains;
|
|
224
|
+
yield this.client.organizations.update(params, org);
|
|
225
|
+
// organization connections
|
|
226
|
+
const connectionsToRemove = existingConnections.filter((c) => !connections.find((x) => x.connection_id === c.connection_id));
|
|
227
|
+
const connectionsToAdd = connections.filter((c) => !existingConnections.find((x) => x.connection_id === c.connection_id));
|
|
228
|
+
const connectionsToUpdate = connections.filter((c) => existingConnections.find((x) => x.connection_id === c.connection_id &&
|
|
229
|
+
(x.assign_membership_on_login !== c.assign_membership_on_login ||
|
|
230
|
+
x.show_as_button !== c.show_as_button ||
|
|
231
|
+
x.is_signup_enabled !== c.is_signup_enabled)));
|
|
232
|
+
// Handle updates first
|
|
233
|
+
yield Promise.all(connectionsToUpdate.map((conn) => this.client.organizations
|
|
234
|
+
.updateEnabledConnection(Object.assign({ connectionId: conn.connection_id }, params), {
|
|
235
|
+
assign_membership_on_login: conn.assign_membership_on_login,
|
|
236
|
+
show_as_button: conn.show_as_button,
|
|
237
|
+
is_signup_enabled: conn.is_signup_enabled,
|
|
193
238
|
})
|
|
194
|
-
.catch((
|
|
195
|
-
throw new Error(`Problem
|
|
196
|
-
})
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
.
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
.catch(() => {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
await Promise.all(orgClientGrantsToRemove.map((orgClientGrant) => this.deleteOrganizationClientGrants(params.id, orgClientGrant.grant_id).catch(() => {
|
|
253
|
-
throw new Error(`Problem removing organization clientGrant ${orgClientGrant.grant_id} for organizations ${params.id}`);
|
|
254
|
-
})));
|
|
255
|
-
// organization discovery_domains
|
|
256
|
-
const orgDiscoveryDomainsToRemove = existingDiscoveryDomains?.filter((existingDomain) => !organizationDiscoveryDomains?.find((d) => d.domain === existingDomain.domain)) || [];
|
|
257
|
-
const orgDiscoveryDomainsToAdd = organizationDiscoveryDomains?.filter((domain) => !existingDiscoveryDomains?.find((d) => d.domain === domain.domain)) || [];
|
|
258
|
-
const orgDiscoveryDomainsToUpdate = existingDiscoveryDomains
|
|
259
|
-
?.filter((existingDomain) => {
|
|
260
|
-
const updatedDomain = organizationDiscoveryDomains?.find((d) => d.domain === existingDomain.domain);
|
|
261
|
-
return updatedDomain && updatedDomain.status !== existingDomain.status;
|
|
262
|
-
})
|
|
263
|
-
.map((existingDomain) => ({
|
|
264
|
-
id: existingDomain.id,
|
|
265
|
-
domain: existingDomain.domain,
|
|
266
|
-
status: organizationDiscoveryDomains.find((d) => d.domain === existingDomain.domain)
|
|
267
|
-
.status,
|
|
268
|
-
})) || [];
|
|
269
|
-
// Handle updates first
|
|
270
|
-
await Promise.all(orgDiscoveryDomainsToUpdate.map((domainUpdate) => this.updateOrganizationDiscoveryDomain(params.id, domainUpdate.id, domainUpdate.domain, domainUpdate.status).catch((err) => {
|
|
271
|
-
throw new Error(`Problem updating discovery domain ${domainUpdate.domain} for organization ${params.id}\n${err.message}`);
|
|
272
|
-
})));
|
|
273
|
-
await Promise.all(orgDiscoveryDomainsToAdd.map((domain) => this.createOrganizationDiscoveryDomain(params.id, {
|
|
274
|
-
domain: domain.domain,
|
|
275
|
-
status: domain.status,
|
|
276
|
-
}).catch((err) => {
|
|
277
|
-
throw new Error(`Problem adding discovery domain ${domain.domain} for organization ${params.id}\n${err.message}`);
|
|
278
|
-
})));
|
|
279
|
-
if (orgDiscoveryDomainsToRemove.length > 0) {
|
|
280
|
-
if (this.config('AUTH0_ALLOW_DELETE') === 'true' ||
|
|
281
|
-
this.config('AUTH0_ALLOW_DELETE') === true) {
|
|
282
|
-
await Promise.all(orgDiscoveryDomainsToRemove.map((domain) => this.deleteOrganizationDiscoveryDomain(params.id, domain.domain, domain.id).catch((err) => {
|
|
283
|
-
throw new Error(`Problem removing discovery domain ${domain.domain} for organization ${params.id}\n${err.message}`);
|
|
284
|
-
})));
|
|
285
|
-
}
|
|
286
|
-
else {
|
|
287
|
-
logger_1.default.warn(`Detected the following organization discovery domains should be deleted. Doing so may be destructive.\nYou can enable deletes by setting 'AUTH0_ALLOW_DELETE' to true in the config
|
|
239
|
+
.catch(() => {
|
|
240
|
+
throw new Error(`Problem updating Enabled Connection ${conn.connection_id} for organizations ${params.id}`);
|
|
241
|
+
})));
|
|
242
|
+
yield Promise.all(connectionsToAdd.map((conn) => this.client.organizations
|
|
243
|
+
.addEnabledConnection(params, lodash_1.default.omit(conn, 'connection'))
|
|
244
|
+
.catch(() => {
|
|
245
|
+
throw new Error(`Problem adding Enabled Connection ${conn.connection_id} for organizations ${params.id}`);
|
|
246
|
+
})));
|
|
247
|
+
yield Promise.all(connectionsToRemove.map((conn) => this.client.organizations
|
|
248
|
+
.deleteEnabledConnection(Object.assign({ connectionId: conn.connection_id }, params))
|
|
249
|
+
.catch(() => {
|
|
250
|
+
throw new Error(`Problem removing Enabled Connection ${conn.connection_id} for organizations ${params.id}`);
|
|
251
|
+
})));
|
|
252
|
+
// organization client_grants
|
|
253
|
+
const orgClientGrantsToRemove = ((_a = existingClientGrants === null || existingClientGrants === void 0 ? void 0 : existingClientGrants.filter((c) => !(organizationClientGrants === null || organizationClientGrants === void 0 ? void 0 : organizationClientGrants.find((x) => x.client_id === c.client_id)))) === null || _a === void 0 ? void 0 : _a.map((clientGrant) => ({
|
|
254
|
+
grant_id: this.getClientGrantIDByClientName(clientGrant.client_id),
|
|
255
|
+
}))) || [];
|
|
256
|
+
const orgClientGrantsToAdd = ((_b = organizationClientGrants === null || organizationClientGrants === void 0 ? void 0 : organizationClientGrants.filter((c) => !(existingClientGrants === null || existingClientGrants === void 0 ? void 0 : existingClientGrants.find((x) => x.client_id === c.client_id)))) === null || _b === void 0 ? void 0 : _b.map((clientGrant) => ({
|
|
257
|
+
grant_id: this.getClientGrantIDByClientName(clientGrant.client_id),
|
|
258
|
+
}))) || [];
|
|
259
|
+
// Handle updates first
|
|
260
|
+
yield Promise.all(orgClientGrantsToAdd.map((orgClientGrant) => this.createOrganizationClientGrants(params.id, orgClientGrant.grant_id).catch(() => {
|
|
261
|
+
throw new Error(`Problem adding organization clientGrant ${orgClientGrant.grant_id} for organizations ${params.id}`);
|
|
262
|
+
})));
|
|
263
|
+
yield Promise.all(orgClientGrantsToRemove.map((orgClientGrant) => this.deleteOrganizationClientGrants(params.id, orgClientGrant.grant_id).catch(() => {
|
|
264
|
+
throw new Error(`Problem removing organization clientGrant ${orgClientGrant.grant_id} for organizations ${params.id}`);
|
|
265
|
+
})));
|
|
266
|
+
// organization discovery_domains
|
|
267
|
+
const orgDiscoveryDomainsToRemove = (existingDiscoveryDomains === null || existingDiscoveryDomains === void 0 ? void 0 : existingDiscoveryDomains.filter((existingDomain) => !(organizationDiscoveryDomains === null || organizationDiscoveryDomains === void 0 ? void 0 : organizationDiscoveryDomains.find((d) => d.domain === existingDomain.domain)))) || [];
|
|
268
|
+
const orgDiscoveryDomainsToAdd = (organizationDiscoveryDomains === null || organizationDiscoveryDomains === void 0 ? void 0 : organizationDiscoveryDomains.filter((domain) => !(existingDiscoveryDomains === null || existingDiscoveryDomains === void 0 ? void 0 : existingDiscoveryDomains.find((d) => d.domain === domain.domain)))) || [];
|
|
269
|
+
const orgDiscoveryDomainsToUpdate = (existingDiscoveryDomains === null || existingDiscoveryDomains === void 0 ? void 0 : existingDiscoveryDomains.filter((existingDomain) => {
|
|
270
|
+
const updatedDomain = organizationDiscoveryDomains === null || organizationDiscoveryDomains === void 0 ? void 0 : organizationDiscoveryDomains.find((d) => d.domain === existingDomain.domain);
|
|
271
|
+
return updatedDomain && updatedDomain.status !== existingDomain.status;
|
|
272
|
+
}).map((existingDomain) => ({
|
|
273
|
+
id: existingDomain.id,
|
|
274
|
+
domain: existingDomain.domain,
|
|
275
|
+
status: organizationDiscoveryDomains.find((d) => d.domain === existingDomain.domain)
|
|
276
|
+
.status,
|
|
277
|
+
}))) || [];
|
|
278
|
+
// Handle updates first
|
|
279
|
+
yield Promise.all(orgDiscoveryDomainsToUpdate.map((domainUpdate) => this.updateOrganizationDiscoveryDomain(params.id, domainUpdate.id, domainUpdate.domain, domainUpdate.status).catch((err) => {
|
|
280
|
+
throw new Error(`Problem updating discovery domain ${domainUpdate.domain} for organization ${params.id}\n${err.message}`);
|
|
281
|
+
})));
|
|
282
|
+
yield Promise.all(orgDiscoveryDomainsToAdd.map((domain) => this.createOrganizationDiscoveryDomain(params.id, {
|
|
283
|
+
domain: domain.domain,
|
|
284
|
+
status: domain.status,
|
|
285
|
+
}).catch((err) => {
|
|
286
|
+
throw new Error(`Problem adding discovery domain ${domain.domain} for organization ${params.id}\n${err.message}`);
|
|
287
|
+
})));
|
|
288
|
+
if (orgDiscoveryDomainsToRemove.length > 0) {
|
|
289
|
+
if (this.config('AUTH0_ALLOW_DELETE') === 'true' ||
|
|
290
|
+
this.config('AUTH0_ALLOW_DELETE') === true) {
|
|
291
|
+
yield Promise.all(orgDiscoveryDomainsToRemove.map((domain) => this.deleteOrganizationDiscoveryDomain(params.id, domain.domain, domain.id).catch((err) => {
|
|
292
|
+
throw new Error(`Problem removing discovery domain ${domain.domain} for organization ${params.id}\n${err.message}`);
|
|
293
|
+
})));
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
logger_1.default.warn(`Detected the following organization discovery domains should be deleted. Doing so may be destructive.\nYou can enable deletes by setting 'AUTH0_ALLOW_DELETE' to true in the config
|
|
288
297
|
\n${orgDiscoveryDomainsToRemove.map((i) => this.objString(i)).join('\n')}`);
|
|
298
|
+
}
|
|
289
299
|
}
|
|
290
|
-
|
|
291
|
-
|
|
300
|
+
return params;
|
|
301
|
+
});
|
|
292
302
|
}
|
|
293
303
|
getClientGrantIDByClientName(clientsName) {
|
|
294
304
|
const found = this.formattedClientGrants.find((c) => c.client_id === clientsName);
|
|
295
|
-
return found
|
|
296
|
-
}
|
|
297
|
-
async getFormattedClientGrants() {
|
|
298
|
-
const [clients, clientGrants] = await Promise.all([
|
|
299
|
-
(0, client_1.paginate)(this.client.clients.list, {
|
|
300
|
-
paginate: true,
|
|
301
|
-
}),
|
|
302
|
-
(0, client_1.paginate)(this.client.clientGrants.list, {
|
|
303
|
-
paginate: true,
|
|
304
|
-
}),
|
|
305
|
-
]);
|
|
306
|
-
// Convert clients by name to the id and store it in the formattedClientGrants
|
|
307
|
-
const formattedClientGrantsMapping = clientGrants?.map((clientGrant) => {
|
|
308
|
-
const { id, client_id: clientName } = clientGrant;
|
|
309
|
-
const grant = { grant_id: id, client_id: clientName };
|
|
310
|
-
const found = clients.find((c) => c.client_id === grant.client_id);
|
|
311
|
-
if (found)
|
|
312
|
-
grant.client_id = found.name;
|
|
313
|
-
return grant;
|
|
314
|
-
});
|
|
315
|
-
return formattedClientGrantsMapping;
|
|
316
|
-
}
|
|
317
|
-
async updateOrganizations(updates, orgs) {
|
|
318
|
-
await this.client.pool
|
|
319
|
-
.addEachTask({
|
|
320
|
-
data: updates || [],
|
|
321
|
-
generator: (item) => this.updateOrganization(item, orgs)
|
|
322
|
-
.then((data) => {
|
|
323
|
-
this.didUpdate(data);
|
|
324
|
-
this.updated += 1;
|
|
325
|
-
})
|
|
326
|
-
.catch((err) => {
|
|
327
|
-
throw new Error(`Problem updating ${this.type} ${this.objString(item)}\n${err}`);
|
|
328
|
-
}),
|
|
329
|
-
})
|
|
330
|
-
.promise();
|
|
305
|
+
return (found === null || found === void 0 ? void 0 : found.grant_id) || '';
|
|
331
306
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
(0, client_1.paginate)(this.client.organizations.list, {
|
|
339
|
-
checkpoint: true,
|
|
307
|
+
getFormattedClientGrants() {
|
|
308
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
309
|
+
const [clients, clientGrants] = yield Promise.all([
|
|
310
|
+
(0, client_1.paginate)(this.client.clients.getAll, {
|
|
311
|
+
paginate: true,
|
|
312
|
+
include_totals: true,
|
|
340
313
|
}),
|
|
341
|
-
(0, client_1.paginate)(this.client.
|
|
314
|
+
(0, client_1.paginate)(this.client.clientGrants.getAll, {
|
|
342
315
|
paginate: true,
|
|
316
|
+
include_totals: true,
|
|
343
317
|
}),
|
|
344
318
|
]);
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
319
|
+
// Convert clients by name to the id and store it in the formattedClientGrants
|
|
320
|
+
const formattedClientGrantsMapping = clientGrants === null || clientGrants === void 0 ? void 0 : clientGrants.map((clientGrant) => {
|
|
321
|
+
const { id, client_id: clientName } = clientGrant;
|
|
322
|
+
const grant = { grant_id: id, client_id: clientName };
|
|
323
|
+
const found = clients.find((c) => c.client_id === grant.client_id);
|
|
324
|
+
if (found)
|
|
325
|
+
grant.client_id = found.name;
|
|
326
|
+
return grant;
|
|
327
|
+
});
|
|
328
|
+
return formattedClientGrantsMapping;
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
updateOrganizations(updates, orgs) {
|
|
332
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
333
|
+
yield this.client.pool
|
|
334
|
+
.addEachTask({
|
|
335
|
+
data: updates || [],
|
|
336
|
+
generator: (item) => this.updateOrganization(item, orgs)
|
|
337
|
+
.then((data) => {
|
|
338
|
+
this.didUpdate(data);
|
|
339
|
+
this.updated += 1;
|
|
340
|
+
})
|
|
341
|
+
.catch((err) => {
|
|
342
|
+
throw new Error(`Problem updating ${this.type} ${this.objString(item)}\n${err}`);
|
|
343
|
+
}),
|
|
344
|
+
})
|
|
345
|
+
.promise();
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
getType() {
|
|
349
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
350
|
+
if (this.existing) {
|
|
351
|
+
return this.existing;
|
|
361
352
|
}
|
|
362
|
-
this.
|
|
363
|
-
return this.existing;
|
|
364
|
-
}
|
|
365
|
-
catch (err) {
|
|
366
|
-
if (err.statusCode === 404 || err.statusCode === 501) {
|
|
353
|
+
if (!this.client.organizations || typeof this.client.organizations.getAll !== 'function') {
|
|
367
354
|
return [];
|
|
368
355
|
}
|
|
369
|
-
|
|
370
|
-
|
|
356
|
+
try {
|
|
357
|
+
const [organizations, clients] = yield Promise.all([
|
|
358
|
+
(0, client_1.paginate)(this.client.organizations.getAll, {
|
|
359
|
+
checkpoint: true,
|
|
360
|
+
include_totals: true,
|
|
361
|
+
}),
|
|
362
|
+
(0, client_1.paginate)(this.client.clients.getAll, {
|
|
363
|
+
paginate: true,
|
|
364
|
+
include_totals: true,
|
|
365
|
+
}),
|
|
366
|
+
]);
|
|
367
|
+
for (let index = 0; index < organizations.length; index++) {
|
|
368
|
+
// Get enabled connections for each organization
|
|
369
|
+
const { data: connections } = yield this.client.organizations.getEnabledConnections({
|
|
370
|
+
id: organizations[index].id,
|
|
371
|
+
});
|
|
372
|
+
organizations[index].connections = connections;
|
|
373
|
+
// Get client grants for each organization
|
|
374
|
+
const organizationClientGrants = yield this.getOrganizationClientGrants(organizations[index].id);
|
|
375
|
+
organizations[index].client_grants = organizationClientGrants === null || organizationClientGrants === void 0 ? void 0 : organizationClientGrants.map((clientGrant) => ({
|
|
376
|
+
client_id: (0, utils_1.convertClientIdToName)(clientGrant.client_id, clients),
|
|
377
|
+
}));
|
|
378
|
+
// Get discovery domains for each organization
|
|
379
|
+
const organizationDiscoveryDomains = yield this.getAllOrganizationDiscoveryDomains(organizations[index].id);
|
|
380
|
+
if (organizationDiscoveryDomains) {
|
|
381
|
+
organizations[index].discovery_domains = organizationDiscoveryDomains;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
this.existing = organizations;
|
|
385
|
+
return this.existing;
|
|
386
|
+
}
|
|
387
|
+
catch (err) {
|
|
388
|
+
if (err.statusCode === 404 || err.statusCode === 501) {
|
|
389
|
+
return [];
|
|
390
|
+
}
|
|
391
|
+
throw err;
|
|
392
|
+
}
|
|
393
|
+
});
|
|
371
394
|
}
|
|
372
395
|
// Run after connections
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
connection_id: (existingConnections.find((c) => c.name === name) || {}).id
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
396
|
+
processChanges(assets) {
|
|
397
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
398
|
+
const { organizations } = assets;
|
|
399
|
+
// Do nothing if not set
|
|
400
|
+
if (!organizations)
|
|
401
|
+
return;
|
|
402
|
+
// Gets organizations from destination tenant
|
|
403
|
+
const existing = yield this.getType();
|
|
404
|
+
const existingConnections = yield (0, client_1.paginate)(this.client.connections.getAll, {
|
|
405
|
+
checkpoint: true,
|
|
406
|
+
include_totals: true,
|
|
407
|
+
});
|
|
408
|
+
// We need to get the connection ids for the names configured so we can link them together
|
|
409
|
+
organizations.forEach((org) => {
|
|
410
|
+
org.connections = (org.connections || [])
|
|
411
|
+
.map((connection) => {
|
|
412
|
+
const { name } = connection;
|
|
413
|
+
delete connection.name;
|
|
414
|
+
return Object.assign(Object.assign({}, connection), { connection_id: (existingConnections.find((c) => c.name === name) || {}).id });
|
|
415
|
+
})
|
|
416
|
+
.filter((connection) => !!connection.connection_id);
|
|
417
|
+
});
|
|
418
|
+
// store formated client_grants->client_id to client grant->grant_id mapping
|
|
419
|
+
this.formattedClientGrants = yield this.getFormattedClientGrants();
|
|
420
|
+
const changes = (0, calculateChanges_1.calculateChanges)({
|
|
421
|
+
handler: this,
|
|
422
|
+
assets: organizations,
|
|
423
|
+
existing,
|
|
424
|
+
identifiers: this.identifiers,
|
|
425
|
+
allowDelete: !!this.config('AUTH0_ALLOW_DELETE'),
|
|
426
|
+
});
|
|
427
|
+
logger_1.default.debug(`Start processChanges for organizations [delete:${changes.del.length}] [update:${changes.update.length}], [create:${changes.create.length}]`);
|
|
428
|
+
const myChanges = [
|
|
429
|
+
{ del: changes.del },
|
|
430
|
+
{ create: changes.create },
|
|
431
|
+
{ update: changes.update },
|
|
432
|
+
];
|
|
433
|
+
yield Promise.all(myChanges.map((change) => __awaiter(this, void 0, void 0, function* () {
|
|
434
|
+
switch (true) {
|
|
435
|
+
case change.del && change.del.length > 0:
|
|
436
|
+
yield this.deleteOrganizations(change.del || []);
|
|
437
|
+
break;
|
|
438
|
+
case change.create && change.create.length > 0:
|
|
439
|
+
yield this.createOrganizations(changes.create);
|
|
440
|
+
break;
|
|
441
|
+
case change.update && change.update.length > 0:
|
|
442
|
+
if (change.update)
|
|
443
|
+
yield this.updateOrganizations(change.update, existing);
|
|
444
|
+
break;
|
|
445
|
+
default:
|
|
446
|
+
break;
|
|
447
|
+
}
|
|
448
|
+
})));
|
|
404
449
|
});
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
await this.updateOrganizations(change.update, existing);
|
|
450
|
+
}
|
|
451
|
+
getOrganizationClientGrants(organizationId) {
|
|
452
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
453
|
+
// paginate without paginate<T> helper as this is not getAll but getOrganizationClientGrants
|
|
454
|
+
// paginate through all oranizaion client grants for oranizaion id
|
|
455
|
+
const allOrganizationClientGrants = [];
|
|
456
|
+
let page = 0;
|
|
457
|
+
while (true) {
|
|
458
|
+
const { data: { client_grants: organizationClientGrants, total }, } = yield this.client.organizations.getOrganizationClientGrants({
|
|
459
|
+
id: organizationId,
|
|
460
|
+
page: page,
|
|
461
|
+
per_page: 100,
|
|
462
|
+
include_totals: true,
|
|
463
|
+
});
|
|
464
|
+
// if we get an unexpected response, break the loop to avoid infinite loop
|
|
465
|
+
if (!(0, lodash_1.isArray)(organizationClientGrants) || typeof total !== 'number') {
|
|
422
466
|
break;
|
|
423
|
-
|
|
467
|
+
}
|
|
468
|
+
allOrganizationClientGrants.push(...organizationClientGrants);
|
|
469
|
+
page += 1;
|
|
470
|
+
if (allOrganizationClientGrants.length === total) {
|
|
424
471
|
break;
|
|
472
|
+
}
|
|
425
473
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
async getOrganizationEnabledConnections(organizationId) {
|
|
429
|
-
const allOrganizationConnections = [];
|
|
430
|
-
let organizationConnections = await this.client.organizations.enabledConnections.list(organizationId);
|
|
431
|
-
do {
|
|
432
|
-
allOrganizationConnections.push(...organizationConnections.data);
|
|
433
|
-
organizationConnections = await organizationConnections.getNextPage();
|
|
434
|
-
} while (organizationConnections.hasNextPage());
|
|
435
|
-
return allOrganizationConnections;
|
|
436
|
-
}
|
|
437
|
-
async getOrganizationClientGrants(organizationId) {
|
|
438
|
-
const allOrganizationClientGrants = [];
|
|
439
|
-
let organizationClientGrants = await this.client.organizations.clientGrants.list(organizationId);
|
|
440
|
-
do {
|
|
441
|
-
allOrganizationClientGrants.push(...organizationClientGrants.data);
|
|
442
|
-
organizationClientGrants = await organizationClientGrants.getNextPage();
|
|
443
|
-
} while (organizationClientGrants.hasNextPage());
|
|
444
|
-
return allOrganizationClientGrants;
|
|
474
|
+
return allOrganizationClientGrants;
|
|
475
|
+
});
|
|
445
476
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
477
|
+
createOrganizationClientGrants(organizationId, grantId) {
|
|
478
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
479
|
+
logger_1.default.debug(`Creating organization client grant ${grantId} for organization ${organizationId}`);
|
|
480
|
+
const { data: organizationClientGrants } = yield this.client.organizations.postOrganizationClientGrants({
|
|
481
|
+
id: organizationId,
|
|
482
|
+
}, {
|
|
483
|
+
grant_id: grantId,
|
|
484
|
+
});
|
|
485
|
+
return organizationClientGrants;
|
|
450
486
|
});
|
|
451
|
-
return organizationClientGrants;
|
|
452
487
|
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
488
|
+
deleteOrganizationClientGrants(organizationId, grantId) {
|
|
489
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
490
|
+
logger_1.default.debug(`Deleting organization client grant ${grantId} for organization ${organizationId}`);
|
|
491
|
+
yield this.client.organizations.deleteClientGrantsByGrantId({
|
|
492
|
+
id: organizationId,
|
|
493
|
+
grant_id: grantId,
|
|
494
|
+
});
|
|
495
|
+
});
|
|
456
496
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
497
|
+
getAllOrganizationDiscoveryDomains(organizationId) {
|
|
498
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
499
|
+
var _a, _b;
|
|
500
|
+
// paginate using checkpoint pagination for getAllDiscoveryDomains
|
|
501
|
+
const allDiscoveryDomains = [];
|
|
502
|
+
const requestArgs = { id: organizationId, take: 50 };
|
|
503
|
+
let next;
|
|
504
|
+
try {
|
|
505
|
+
do {
|
|
506
|
+
if (next) {
|
|
507
|
+
requestArgs.from = next;
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
delete requestArgs.from;
|
|
511
|
+
}
|
|
512
|
+
const rsp = yield this.client.pool
|
|
513
|
+
.addSingleTask({
|
|
514
|
+
data: requestArgs,
|
|
515
|
+
generator: (args) => this.client.organizations.getAllDiscoveryDomains(args),
|
|
516
|
+
})
|
|
517
|
+
.promise();
|
|
518
|
+
const discoveryDomains = Array.isArray(rsp.data) ? rsp.data : ((_a = rsp.data) === null || _a === void 0 ? void 0 : _a.domains) || [];
|
|
519
|
+
allDiscoveryDomains.push(...discoveryDomains);
|
|
520
|
+
next = (_b = rsp.data) === null || _b === void 0 ? void 0 : _b.next;
|
|
521
|
+
} while (next);
|
|
522
|
+
return allDiscoveryDomains;
|
|
471
523
|
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
524
|
+
catch (err) {
|
|
525
|
+
if (err.statusCode === 404 || err.statusCode === 501) {
|
|
526
|
+
return null;
|
|
527
|
+
}
|
|
528
|
+
if (err.statusCode === 403 || err.errorCode === 'feature_not_enabled') {
|
|
529
|
+
logger_1.default.debug('Organization Discovery domains are not enabled for this tenant. Please verify `scope` or contact Auth0 support to enable this feature.');
|
|
530
|
+
return null;
|
|
531
|
+
}
|
|
532
|
+
throw err;
|
|
475
533
|
}
|
|
476
|
-
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
async getOrganizationDiscoveryDomain(organizationId, discoveryDomainId) {
|
|
480
|
-
const orgDiscoveryDomain = await this.client.organizations.discoveryDomains.get(organizationId, discoveryDomainId);
|
|
481
|
-
return orgDiscoveryDomain;
|
|
534
|
+
});
|
|
482
535
|
}
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
.addSingleTask({
|
|
487
|
-
data: {
|
|
536
|
+
getOrganizationDiscoveryDomain(organizationId, discoveryDomainId) {
|
|
537
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
538
|
+
const { data } = yield this.client.organizations.getDiscoveryDomain({
|
|
488
539
|
id: organizationId,
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
return orgDiscoveryDomain;
|
|
540
|
+
discovery_domain_id: discoveryDomainId,
|
|
541
|
+
});
|
|
542
|
+
return data;
|
|
543
|
+
});
|
|
494
544
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
}),
|
|
509
|
-
})
|
|
510
|
-
.promise();
|
|
511
|
-
return discoveryDomainUpdated;
|
|
545
|
+
createOrganizationDiscoveryDomain(organizationId, discoveryDomain) {
|
|
546
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
547
|
+
logger_1.default.debug(`Creating discovery domain ${discoveryDomain.domain} for organization ${organizationId}`);
|
|
548
|
+
const { data } = yield this.client.pool
|
|
549
|
+
.addSingleTask({
|
|
550
|
+
data: {
|
|
551
|
+
id: organizationId,
|
|
552
|
+
},
|
|
553
|
+
generator: (args) => this.client.organizations.createDiscoveryDomain(args, discoveryDomain),
|
|
554
|
+
})
|
|
555
|
+
.promise();
|
|
556
|
+
return data;
|
|
557
|
+
});
|
|
512
558
|
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
559
|
+
updateOrganizationDiscoveryDomain(organizationId, discoveryDomainId, discoveryDomain, status) {
|
|
560
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
561
|
+
logger_1.default.debug(`Updating discovery domain ${discoveryDomain} for organization ${organizationId}`);
|
|
562
|
+
// stripUpdateFields does not support in sub modules
|
|
563
|
+
const stripUpdateFields = ['verification_host', 'verification_txt'];
|
|
564
|
+
logger_1.default.debug(`Stripping ${this.type} discovery domain read-only fields ${JSON.stringify(stripUpdateFields)}`);
|
|
565
|
+
const { data } = yield this.client.pool
|
|
566
|
+
.addSingleTask({
|
|
567
|
+
data: {
|
|
568
|
+
id: organizationId,
|
|
569
|
+
discovery_domain_id: discoveryDomainId,
|
|
570
|
+
},
|
|
571
|
+
generator: (args) => this.client.organizations.updateDiscoveryDomain(args, {
|
|
572
|
+
status,
|
|
573
|
+
}),
|
|
574
|
+
})
|
|
575
|
+
.promise();
|
|
576
|
+
return data;
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
deleteOrganizationDiscoveryDomain(organizationId, discoveryDomain, discoveryDomainId) {
|
|
580
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
581
|
+
logger_1.default.debug(`Deleting discovery domain ${discoveryDomain} for organization ${organizationId}`);
|
|
582
|
+
yield this.client.pool
|
|
583
|
+
.addSingleTask({
|
|
584
|
+
data: {
|
|
585
|
+
id: organizationId,
|
|
586
|
+
discovery_domain_id: discoveryDomainId,
|
|
587
|
+
},
|
|
588
|
+
generator: (args) => this.client.organizations.deleteDiscoveryDomain(args),
|
|
589
|
+
})
|
|
590
|
+
.promise();
|
|
591
|
+
});
|
|
524
592
|
}
|
|
525
593
|
}
|
|
526
594
|
exports.default = OrganizationsHandler;
|
|
527
595
|
__decorate([
|
|
528
596
|
(0, default_1.order)('70')
|
|
529
597
|
], OrganizationsHandler.prototype, "processChanges", null);
|
|
598
|
+
//# sourceMappingURL=organizations.js.map
|