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