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
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
@@ -38,7 +47,7 @@ exports.schema = {
|
|
|
38
47
|
properties: {
|
|
39
48
|
mechanism: {
|
|
40
49
|
type: 'string',
|
|
41
|
-
enum: Object.values(auth0_1.
|
|
50
|
+
enum: Object.values(auth0_1.ResourceServerProofOfPossessionMechanismEnum),
|
|
42
51
|
},
|
|
43
52
|
required: { type: 'boolean' },
|
|
44
53
|
},
|
|
@@ -53,7 +62,7 @@ exports.schema = {
|
|
|
53
62
|
properties: {
|
|
54
63
|
policy: {
|
|
55
64
|
type: 'string',
|
|
56
|
-
enum: Object.values(auth0_1.
|
|
65
|
+
enum: Object.values(auth0_1.ResourceServerSubjectTypeAuthorizationUserPolicyEnum),
|
|
57
66
|
},
|
|
58
67
|
},
|
|
59
68
|
},
|
|
@@ -63,7 +72,7 @@ exports.schema = {
|
|
|
63
72
|
properties: {
|
|
64
73
|
policy: {
|
|
65
74
|
type: 'string',
|
|
66
|
-
enum: Object.values(auth0_1.
|
|
75
|
+
enum: Object.values(auth0_1.ResourceServerSubjectTypeAuthorizationClientPolicyEnum),
|
|
67
76
|
},
|
|
68
77
|
},
|
|
69
78
|
},
|
|
@@ -81,71 +90,63 @@ exports.schema = {
|
|
|
81
90
|
};
|
|
82
91
|
class ResourceServersHandler extends default_1.default {
|
|
83
92
|
constructor(options) {
|
|
84
|
-
super({
|
|
85
|
-
...options,
|
|
86
|
-
type: 'resourceServers',
|
|
87
|
-
identifiers: ['id', 'identifier'],
|
|
88
|
-
stripCreateFields: ['client_id'],
|
|
89
|
-
stripUpdateFields: ['identifier', 'client_id'],
|
|
90
|
-
functions: {
|
|
91
|
-
update: async ({ id }, bodyParams) => this.client.resourceServers.update(id, bodyParams),
|
|
92
|
-
},
|
|
93
|
-
});
|
|
93
|
+
super(Object.assign(Object.assign({}, options), { type: 'resourceServers', identifiers: ['id', 'identifier'], stripCreateFields: ['client_id'], stripUpdateFields: ['identifier', 'client_id', 'is_system'] }));
|
|
94
94
|
}
|
|
95
95
|
objString(resourceServer) {
|
|
96
96
|
return super.objString({ name: resourceServer.name, identifier: resourceServer.identifier });
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
paginate
|
|
98
|
+
getType() {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
if (this.existing)
|
|
101
|
+
return this.existing;
|
|
102
|
+
const resourceServers = yield (0, client_1.paginate)(this.client.resourceServers.getAll, {
|
|
103
|
+
paginate: true,
|
|
104
|
+
include_totals: true,
|
|
105
|
+
});
|
|
106
|
+
return resourceServers.filter((rs) => rs.name !== constants_1.default.RESOURCE_SERVERS_MANAGEMENT_API_NAME);
|
|
103
107
|
});
|
|
104
|
-
return resourceServers.filter((rs) => rs.name !== constants_1.default.RESOURCE_SERVERS_MANAGEMENT_API_NAME);
|
|
105
108
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
109
|
+
calcChanges(assets) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
let { resourceServers } = assets;
|
|
112
|
+
// Do nothing if not set
|
|
113
|
+
if (!resourceServers)
|
|
114
|
+
return {
|
|
115
|
+
del: [],
|
|
116
|
+
create: [],
|
|
117
|
+
conflicts: [],
|
|
118
|
+
update: [],
|
|
119
|
+
};
|
|
120
|
+
const excluded = (assets.exclude && assets.exclude.resourceServers) || [];
|
|
121
|
+
let existing = yield this.getType();
|
|
122
|
+
// Filter excluded
|
|
123
|
+
resourceServers = resourceServers.filter((r) => !excluded.includes(r.name));
|
|
124
|
+
existing = existing.filter((r) => !excluded.includes(r.name));
|
|
125
|
+
return (0, calculateChanges_1.calculateChanges)({
|
|
126
|
+
handler: this,
|
|
127
|
+
assets: resourceServers,
|
|
128
|
+
existing,
|
|
129
|
+
identifiers: this.identifiers,
|
|
130
|
+
allowDelete: !!this.config('AUTH0_ALLOW_DELETE'),
|
|
131
|
+
});
|
|
127
132
|
});
|
|
128
133
|
}
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (!resourceServers)
|
|
144
|
-
return;
|
|
145
|
-
const changes = await this.calcChanges(assets);
|
|
146
|
-
await super.processChanges(assets, {
|
|
147
|
-
...changes,
|
|
134
|
+
validate(assets) {
|
|
135
|
+
const _super = Object.create(null, {
|
|
136
|
+
validate: { get: () => super.validate }
|
|
137
|
+
});
|
|
138
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
const { resourceServers } = assets;
|
|
140
|
+
// Do nothing if not set
|
|
141
|
+
if (!resourceServers)
|
|
142
|
+
return;
|
|
143
|
+
const mgmtAPIResource = resourceServers.find((r) => r.name === constants_1.default.RESOURCE_SERVERS_MANAGEMENT_API_NAME);
|
|
144
|
+
if (mgmtAPIResource) {
|
|
145
|
+
throw new validationError_1.default(`You can not configure the '${constants_1.default.RESOURCE_SERVERS_MANAGEMENT_API_NAME}'.`);
|
|
146
|
+
}
|
|
147
|
+
yield _super.validate.call(this, assets);
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
exports.default = ResourceServersHandler;
|
|
152
|
+
//# sourceMappingURL=resourceServers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceServers.js","sourceRoot":"","sources":["../../../../src/tools/auth0/handlers/resourceServers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iCAKe;AACf,4EAAoD;AAEpD,gEAAwC;AACxC,wDAAuC;AACvC,6DAA0D;AAE1D,sCAAqC;AAExB,QAAA,aAAa,GAAG;IAC3B,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;CAC1B,CAAC;AAEW,QAAA,MAAM,GAAG;IACpB,IAAI,EAAE,OAAO;IACb,KAAK,EAAE;QACL,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACxB,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC9B,MAAM,EAAE;gBACN,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBACxB,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;qBAChC;iBACF;aACF;YACD,gBAAgB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;YACrC,aAAa,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACjC,mBAAmB,EAAE;gBACnB,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,SAAS,EAAE;wBACT,IAAI,EAAE,QAAQ;wBACd,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,oDAA4C,CAAC;qBAClE;oBACD,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AI,CAAC,WAAW;gBAC7B,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;aACjD,CAAC,CAAC;QACL,CAAC;KAAA;IAEK,QAAQ,CAAC,MAAc;;;;;YAC3B,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC;YAEnC,wBAAwB;YACxB,IAAI,CAAC,eAAe;gBAAE,OAAO;YAE7B,MAAM,eAAe,GAAG,eAAe,CAAC,IAAI,CAC1C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,mBAAS,CAAC,oCAAoC,CACjE,CAAC;YACF,IAAI,eAAe,EAAE,CAAC;gBACpB,MAAM,IAAI,yBAAe,CACvB,8BAA8B,mBAAS,CAAC,oCAAoC,IAAI,CACjF,CAAC;YACJ,CAAC;YAED,MAAM,OAAM,QAAQ,YAAC,MAAM,CAAC,CAAC;QAC/B,CAAC;KAAA;CACF;AA3ED,yCA2EC"}
|
|
@@ -38,11 +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;
|
|
55
|
+
const lodash_1 = require("lodash");
|
|
46
56
|
const default_1 = __importStar(require("./default"));
|
|
47
57
|
const calculateChanges_1 = require("../../calculateChanges");
|
|
48
58
|
const logger_1 = __importDefault(require("../../../logger"));
|
|
@@ -71,190 +81,196 @@ exports.schema = {
|
|
|
71
81
|
};
|
|
72
82
|
class RolesHandler extends default_1.default {
|
|
73
83
|
constructor(config) {
|
|
74
|
-
super({
|
|
75
|
-
...config,
|
|
76
|
-
type: 'roles',
|
|
77
|
-
id: 'id',
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
async createRole(data) {
|
|
81
|
-
const role = { ...data };
|
|
82
|
-
delete role.permissions;
|
|
83
|
-
const created = await this.client.roles.create(role);
|
|
84
|
-
if (created.id && typeof data.permissions !== 'undefined' && data.permissions.length > 0) {
|
|
85
|
-
await this.client.roles.permissions.add(created.id, { permissions: data.permissions });
|
|
86
|
-
}
|
|
87
|
-
return created;
|
|
88
|
-
}
|
|
89
|
-
async createRoles(creates) {
|
|
90
|
-
await this.client.pool
|
|
91
|
-
.addEachTask({
|
|
92
|
-
data: creates || [],
|
|
93
|
-
generator: (item) => this.createRole(item)
|
|
94
|
-
.then((data) => {
|
|
95
|
-
this.didCreate(data);
|
|
96
|
-
this.created += 1;
|
|
97
|
-
})
|
|
98
|
-
.catch((err) => {
|
|
99
|
-
throw new Error(`Problem creating ${this.type} ${this.objString(item)}\n${err}`);
|
|
100
|
-
}),
|
|
101
|
-
})
|
|
102
|
-
.promise();
|
|
84
|
+
super(Object.assign(Object.assign({}, config), { type: 'roles', id: 'id' }));
|
|
103
85
|
}
|
|
104
|
-
|
|
105
|
-
|
|
86
|
+
createRole(data) {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
const role = Object.assign({}, data);
|
|
89
|
+
delete role.permissions;
|
|
90
|
+
const { data: created } = yield this.client.roles.create(role);
|
|
91
|
+
if (typeof data.permissions !== 'undefined' && data.permissions.length > 0) {
|
|
92
|
+
yield this.client.roles.addPermissions({ id: created.id }, { permissions: data.permissions });
|
|
93
|
+
}
|
|
94
|
+
return created;
|
|
95
|
+
});
|
|
106
96
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
this.
|
|
110
|
-
await this.client.pool
|
|
97
|
+
createRoles(creates) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
yield this.client.pool
|
|
111
100
|
.addEachTask({
|
|
112
|
-
data:
|
|
113
|
-
generator: (item) => this.
|
|
114
|
-
.then(() => {
|
|
115
|
-
this.
|
|
116
|
-
this.
|
|
101
|
+
data: creates || [],
|
|
102
|
+
generator: (item) => this.createRole(item)
|
|
103
|
+
.then((data) => {
|
|
104
|
+
this.didCreate(data);
|
|
105
|
+
this.created += 1;
|
|
117
106
|
})
|
|
118
107
|
.catch((err) => {
|
|
119
|
-
throw new Error(`Problem
|
|
108
|
+
throw new Error(`Problem creating ${this.type} ${this.objString(item)}\n${err}`);
|
|
120
109
|
}),
|
|
121
110
|
})
|
|
122
111
|
.promise();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
deleteRole(data) {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
yield this.client.roles.delete({ id: data.id });
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
deleteRoles(dels) {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
if (this.config('AUTH0_ALLOW_DELETE') === 'true' ||
|
|
122
|
+
this.config('AUTH0_ALLOW_DELETE') === true) {
|
|
123
|
+
yield this.client.pool
|
|
124
|
+
.addEachTask({
|
|
125
|
+
data: dels || [],
|
|
126
|
+
generator: (item) => this.deleteRole(item)
|
|
127
|
+
.then(() => {
|
|
128
|
+
this.didDelete(item);
|
|
129
|
+
this.deleted += 1;
|
|
130
|
+
})
|
|
131
|
+
.catch((err) => {
|
|
132
|
+
throw new Error(`Problem deleting ${this.type} ${this.objString(item)}\n${err}`);
|
|
133
|
+
}),
|
|
134
|
+
})
|
|
135
|
+
.promise();
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
logger_1.default.warn(`Detected the following roles should be deleted. Doing so may be destructive.\nYou can enable deletes by setting 'AUTH0_ALLOW_DELETE' to true in the config
|
|
126
139
|
\n${dels.map((i) => this.objString(i)).join('\n')}`);
|
|
127
|
-
|
|
140
|
+
}
|
|
141
|
+
});
|
|
128
142
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
permissions: existingRole.permissions
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
updateRole(data, roles) {
|
|
144
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
const existingRole = yield roles.find((roleDataForUpdate) => roleDataForUpdate.name === data.name);
|
|
146
|
+
const params = { id: data.id };
|
|
147
|
+
const newPermissions = data.permissions;
|
|
148
|
+
delete data.permissions;
|
|
149
|
+
delete data.id;
|
|
150
|
+
yield this.client.roles.update(params, data);
|
|
151
|
+
if (typeof existingRole.permissions !== 'undefined' && existingRole.permissions.length > 0) {
|
|
152
|
+
yield this.client.roles.deletePermissions(params, { permissions: existingRole.permissions });
|
|
153
|
+
}
|
|
154
|
+
if (typeof newPermissions !== 'undefined' && newPermissions.length > 0) {
|
|
155
|
+
yield this.client.roles.addPermissions(params, { permissions: newPermissions });
|
|
156
|
+
}
|
|
157
|
+
return params;
|
|
158
|
+
});
|
|
145
159
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
160
|
+
updateRoles(updates, roles) {
|
|
161
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
+
yield this.client.pool
|
|
163
|
+
.addEachTask({
|
|
164
|
+
data: updates || [],
|
|
165
|
+
generator: (item) => this.updateRole(item, roles)
|
|
166
|
+
.then((data) => {
|
|
167
|
+
this.didUpdate(data);
|
|
168
|
+
this.updated += 1;
|
|
169
|
+
})
|
|
170
|
+
.catch((err) => {
|
|
171
|
+
throw new Error(`Problem updating ${this.type} ${this.objString(item)}\n${err}`);
|
|
172
|
+
}),
|
|
154
173
|
})
|
|
155
|
-
.
|
|
156
|
-
|
|
157
|
-
}),
|
|
158
|
-
})
|
|
159
|
-
.promise();
|
|
174
|
+
.promise();
|
|
175
|
+
});
|
|
160
176
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
let page = 0;
|
|
174
|
-
while (true) {
|
|
175
|
-
const {
|
|
176
|
-
data: { permissions, total },
|
|
177
|
-
} = await this.client.roles.permissions.list({
|
|
177
|
+
getType() {
|
|
178
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
179
|
+
if (this.existing) {
|
|
180
|
+
return this.existing;
|
|
181
|
+
}
|
|
182
|
+
// in case client version does not support roles
|
|
183
|
+
if (!this.client.roles || typeof this.client.roles.getAll !== 'function') {
|
|
184
|
+
return [];
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
const roles = yield (0, client_1.paginate)(this.client.roles.getAll, {
|
|
188
|
+
paginate: true,
|
|
178
189
|
include_totals: true,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
190
|
+
});
|
|
191
|
+
for (let index = 0; index < roles.length; index++) {
|
|
192
|
+
// paginate without paginate<T> helper as this is not getAll but getPermissions
|
|
193
|
+
// paginate through all permissions for each role
|
|
194
|
+
const allPermission = [];
|
|
195
|
+
let page = 0;
|
|
196
|
+
while (true) {
|
|
197
|
+
const { data: { permissions, total }, } = yield this.client.roles.getPermissions({
|
|
198
|
+
include_totals: true,
|
|
199
|
+
id: roles[index].id,
|
|
200
|
+
page: page,
|
|
201
|
+
per_page: 100,
|
|
202
|
+
});
|
|
203
|
+
allPermission.push(...permissions);
|
|
204
|
+
page += 1;
|
|
205
|
+
if (allPermission.length === total) {
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
// if we get an unexpected response, break the loop to avoid infinite loop
|
|
209
|
+
if (!(0, lodash_1.isArray)(permissions) || typeof total !== 'number') {
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
const strippedPerms = yield Promise.all(allPermission.map((permission) => __awaiter(this, void 0, void 0, function* () {
|
|
214
|
+
delete permission.resource_server_name;
|
|
215
|
+
delete permission.description;
|
|
216
|
+
return permission;
|
|
217
|
+
})));
|
|
218
|
+
roles[index].permissions = strippedPerms;
|
|
193
219
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
let permissions = await this.client.roles.permissions.list(rolesId, { per_page: 100 });
|
|
197
|
-
do {
|
|
198
|
-
allPermission.push(...permissions.data);
|
|
199
|
-
permissions = await permissions.getNextPage();
|
|
200
|
-
} while (permissions.hasNextPage());
|
|
201
|
-
const strippedPerms = await Promise.all(allPermission.map(async (permission) => {
|
|
202
|
-
delete permission.resource_server_name;
|
|
203
|
-
delete permission.description;
|
|
204
|
-
return permission;
|
|
205
|
-
}));
|
|
206
|
-
roles[index].permissions = strippedPerms;
|
|
220
|
+
this.existing = roles;
|
|
221
|
+
return this.existing;
|
|
207
222
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
return [];
|
|
223
|
+
catch (err) {
|
|
224
|
+
if (err.statusCode === 404 || err.statusCode === 501) {
|
|
225
|
+
return [];
|
|
226
|
+
}
|
|
227
|
+
throw err;
|
|
214
228
|
}
|
|
215
|
-
|
|
216
|
-
}
|
|
229
|
+
});
|
|
217
230
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
+
processChanges(assets) {
|
|
232
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
233
|
+
const { roles } = assets;
|
|
234
|
+
// Do nothing if not set
|
|
235
|
+
if (!roles)
|
|
236
|
+
return;
|
|
237
|
+
// Gets roles from destination tenant
|
|
238
|
+
const existing = yield this.getType();
|
|
239
|
+
const changes = (0, calculateChanges_1.calculateChanges)({
|
|
240
|
+
handler: this,
|
|
241
|
+
assets: roles,
|
|
242
|
+
existing,
|
|
243
|
+
identifiers: this.identifiers,
|
|
244
|
+
allowDelete: !!this.config('AUTH0_ALLOW_DELETE'),
|
|
245
|
+
});
|
|
246
|
+
logger_1.default.debug(`Start processChanges for roles [delete:${changes.del.length}] [update:${changes.update.length}], [create:${changes.create.length}]`);
|
|
247
|
+
const myChanges = [
|
|
248
|
+
{ del: changes.del },
|
|
249
|
+
{ create: changes.create },
|
|
250
|
+
{ update: changes.update },
|
|
251
|
+
];
|
|
252
|
+
yield Promise.all(myChanges.map((change) => __awaiter(this, void 0, void 0, function* () {
|
|
253
|
+
switch (true) {
|
|
254
|
+
case change.del && change.del.length > 0:
|
|
255
|
+
if (change.del)
|
|
256
|
+
yield this.deleteRoles(change.del);
|
|
257
|
+
break;
|
|
258
|
+
case change.create && change.create.length > 0:
|
|
259
|
+
yield this.createRoles(changes.create); //TODO: fix this tho change.create
|
|
260
|
+
break;
|
|
261
|
+
case change.update && change.update.length > 0:
|
|
262
|
+
if (change.update)
|
|
263
|
+
yield this.updateRoles(change.update, existing);
|
|
264
|
+
break;
|
|
265
|
+
default:
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
})));
|
|
231
269
|
});
|
|
232
|
-
logger_1.default.debug(`Start processChanges for roles [delete:${changes.del.length}] [update:${changes.update.length}], [create:${changes.create.length}]`);
|
|
233
|
-
const myChanges = [
|
|
234
|
-
{ del: changes.del },
|
|
235
|
-
{ create: changes.create },
|
|
236
|
-
{ update: changes.update },
|
|
237
|
-
];
|
|
238
|
-
await Promise.all(myChanges.map(async (change) => {
|
|
239
|
-
switch (true) {
|
|
240
|
-
case change.del && change.del.length > 0:
|
|
241
|
-
if (change.del)
|
|
242
|
-
await this.deleteRoles(change.del);
|
|
243
|
-
break;
|
|
244
|
-
case change.create && change.create.length > 0:
|
|
245
|
-
await this.createRoles(changes.create);
|
|
246
|
-
break;
|
|
247
|
-
case change.update && change.update.length > 0:
|
|
248
|
-
if (change.update)
|
|
249
|
-
await this.updateRoles(change.update, existing);
|
|
250
|
-
break;
|
|
251
|
-
default:
|
|
252
|
-
break;
|
|
253
|
-
}
|
|
254
|
-
}));
|
|
255
270
|
}
|
|
256
271
|
}
|
|
257
272
|
exports.default = RolesHandler;
|
|
258
273
|
__decorate([
|
|
259
274
|
(0, default_1.order)('60')
|
|
260
275
|
], RolesHandler.prototype, "processChanges", null);
|
|
276
|
+
//# sourceMappingURL=roles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roles.js","sourceRoot":"","sources":["../../../../src/tools/auth0/handlers/roles.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mCAAiC;AACjC,qDAAkD;AAClD,6DAA0D;AAC1D,6DAAkC;AAElC,sCAAqC;AAExB,QAAA,MAAM,GAAG;IACpB,IAAI,EAAE,OAAO;IACb,KAAK,EAAE;QACL,IAAI,EAAE,QAAQ;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