auth0-deploy-cli 8.22.0 → 8.23.1
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 +41 -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 +102 -145
- 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 +350 -431
- 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 +221 -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 +149 -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 +263 -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
|
@@ -1,13 +1,4 @@
|
|
|
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
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -39,96 +30,96 @@ exports.schema = {
|
|
|
39
30
|
};
|
|
40
31
|
class PagesHandler extends default_1.default {
|
|
41
32
|
constructor(options) {
|
|
42
|
-
super(
|
|
33
|
+
super({
|
|
34
|
+
...options,
|
|
35
|
+
type: 'pages',
|
|
36
|
+
identifiers: ['name'],
|
|
37
|
+
});
|
|
43
38
|
}
|
|
44
39
|
objString(page) {
|
|
45
40
|
return super.objString({ name: page.name, enabled: page.enabled });
|
|
46
41
|
}
|
|
47
|
-
updateLoginPage(page) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
include_totals: true,
|
|
52
|
-
is_global: true,
|
|
53
|
-
});
|
|
54
|
-
if (!globalClient[0]) {
|
|
55
|
-
throw new Error('Unable to find global client id when trying to update the login page');
|
|
56
|
-
}
|
|
57
|
-
yield this.client.clients.update({ client_id: globalClient[0].client_id }, {
|
|
58
|
-
custom_login_page: page.html,
|
|
59
|
-
custom_login_page_on: page.enabled,
|
|
60
|
-
});
|
|
61
|
-
this.updated += 1;
|
|
62
|
-
this.didUpdate(page);
|
|
42
|
+
async updateLoginPage(page) {
|
|
43
|
+
const globalClient = await (0, client_1.paginate)(this.client.clients.list, {
|
|
44
|
+
paginate: true,
|
|
45
|
+
is_global: true,
|
|
63
46
|
});
|
|
47
|
+
if (!globalClient[0]) {
|
|
48
|
+
throw new Error('Unable to find global client id when trying to update the login page');
|
|
49
|
+
}
|
|
50
|
+
if (!globalClient[0].client_id) {
|
|
51
|
+
throw new Error('Unable to find global client id when trying to update the login page');
|
|
52
|
+
}
|
|
53
|
+
await this.client.clients.update(globalClient[0].client_id, {
|
|
54
|
+
custom_login_page: page.html,
|
|
55
|
+
custom_login_page_on: page.enabled,
|
|
56
|
+
});
|
|
57
|
+
this.updated += 1;
|
|
58
|
+
this.didUpdate(page);
|
|
64
59
|
}
|
|
65
|
-
updatePages(pages) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
throw new Error(`Unable to map page ${page.name} into tenant level page setting`);
|
|
73
|
-
}
|
|
74
|
-
accum[pageName] = Object.assign({}, page);
|
|
75
|
-
delete accum[pageName].name;
|
|
60
|
+
async updatePages(pages) {
|
|
61
|
+
const toUpdate = pages.filter((p) => exports.supportedPages.includes(p.name));
|
|
62
|
+
const update = toUpdate.reduce((accum, page) => {
|
|
63
|
+
if (exports.supportedPages.includes(page.name)) {
|
|
64
|
+
const pageName = exports.pageNameMap[page.name];
|
|
65
|
+
if (!pageName) {
|
|
66
|
+
throw new Error(`Unable to map page ${page.name} into tenant level page setting`);
|
|
76
67
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (Object.keys(update).length) {
|
|
80
|
-
yield this.client.tenants.updateSettings(update);
|
|
68
|
+
accum[pageName] = { ...page };
|
|
69
|
+
delete accum[pageName].name;
|
|
81
70
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
71
|
+
return accum;
|
|
72
|
+
}, {});
|
|
73
|
+
if (Object.keys(update).length) {
|
|
74
|
+
await this.client.tenants.settings.update(update);
|
|
75
|
+
}
|
|
76
|
+
toUpdate.forEach((page) => {
|
|
77
|
+
this.updated += 1;
|
|
78
|
+
this.didUpdate(page);
|
|
86
79
|
});
|
|
87
80
|
}
|
|
88
|
-
getType() {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
81
|
+
async getType() {
|
|
82
|
+
const pages = [];
|
|
83
|
+
// Login page is handled via the global client
|
|
84
|
+
const globalClient = await (0, client_1.paginate)(this.client.clients.list, {
|
|
85
|
+
paginate: true,
|
|
86
|
+
include_totals: true,
|
|
87
|
+
is_global: true,
|
|
88
|
+
});
|
|
89
|
+
if (!globalClient[0]) {
|
|
90
|
+
throw new Error('Unable to find global client id when trying to dump the login page');
|
|
91
|
+
}
|
|
92
|
+
if (globalClient[0].custom_login_page) {
|
|
93
|
+
pages.push({
|
|
94
|
+
name: 'login',
|
|
95
|
+
enabled: !!globalClient[0].custom_login_page_on,
|
|
96
|
+
html: globalClient[0].custom_login_page,
|
|
96
97
|
});
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
}
|
|
99
|
+
const tenantSettings = await this.client.tenants.settings.get();
|
|
100
|
+
Object.entries(exports.pageNameMap).forEach(([key, name]) => {
|
|
101
|
+
const page = tenantSettings[name];
|
|
102
|
+
if (tenantSettings[name]) {
|
|
101
103
|
pages.push({
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
html: globalClient[0].custom_login_page,
|
|
104
|
+
...page,
|
|
105
|
+
name: key,
|
|
105
106
|
});
|
|
106
107
|
}
|
|
107
|
-
const { data: tenantSettings } = yield this.client.tenants.getSettings();
|
|
108
|
-
Object.entries(exports.pageNameMap).forEach(([key, name]) => {
|
|
109
|
-
const page = tenantSettings[name];
|
|
110
|
-
if (tenantSettings[name]) {
|
|
111
|
-
pages.push(Object.assign(Object.assign({}, page), { name: key }));
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
return pages;
|
|
115
108
|
});
|
|
109
|
+
return pages;
|
|
116
110
|
}
|
|
117
|
-
processChanges(assets) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
yield this.updatePages(pages.filter((p) => p.name !== 'login'));
|
|
130
|
-
});
|
|
111
|
+
async processChanges(assets) {
|
|
112
|
+
const { pages } = assets;
|
|
113
|
+
// Do nothing if not set
|
|
114
|
+
if (!pages)
|
|
115
|
+
return;
|
|
116
|
+
// Login page is handled via the global client
|
|
117
|
+
const loginPage = pages.find((p) => p.name === 'login');
|
|
118
|
+
if (loginPage !== undefined) {
|
|
119
|
+
await this.updateLoginPage(loginPage);
|
|
120
|
+
}
|
|
121
|
+
// Rest of pages are on tenant level settings
|
|
122
|
+
await this.updatePages(pages.filter((p) => p.name !== 'login'));
|
|
131
123
|
}
|
|
132
124
|
}
|
|
133
125
|
exports.default = PagesHandler;
|
|
134
|
-
//# sourceMappingURL=pages.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Management } from 'auth0';
|
|
2
2
|
import DefaultHandler from './default';
|
|
3
3
|
import { Assets } from '../../../types';
|
|
4
4
|
export declare const schema: {
|
|
@@ -55,7 +55,7 @@ export declare const schema: {
|
|
|
55
55
|
additionalProperties: boolean;
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
|
-
export type PhoneProvider =
|
|
58
|
+
export type PhoneProvider = Management.GetBrandingPhoneProviderResponseContent;
|
|
59
59
|
export default class PhoneProviderHandler extends DefaultHandler {
|
|
60
60
|
existing: PhoneProvider[] | null;
|
|
61
61
|
constructor(options: DefaultHandler);
|
|
@@ -38,15 +38,6 @@ 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
|
};
|
|
@@ -149,91 +140,87 @@ exports.schema = {
|
|
|
149
140
|
};
|
|
150
141
|
class PhoneProviderHandler extends default_1.default {
|
|
151
142
|
constructor(options) {
|
|
152
|
-
super(
|
|
143
|
+
super({
|
|
144
|
+
...options,
|
|
145
|
+
type: 'phoneProviders',
|
|
146
|
+
id: 'id',
|
|
147
|
+
});
|
|
153
148
|
}
|
|
154
149
|
objString(provider) {
|
|
155
|
-
return super.objString({ name: provider.name, disabled: provider.disabled });
|
|
150
|
+
return super.objString({ name: provider.name, disabled: provider.disabled });
|
|
156
151
|
}
|
|
157
|
-
getType() {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return this.existing;
|
|
163
|
-
});
|
|
152
|
+
async getType() {
|
|
153
|
+
if (!this.existing) {
|
|
154
|
+
this.existing = await this.getPhoneProviders();
|
|
155
|
+
}
|
|
156
|
+
return this.existing;
|
|
164
157
|
}
|
|
165
|
-
getPhoneProviders() {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const { data: response } = yield this.client.branding.getAllPhoneProviders();
|
|
169
|
-
return (_a = response.providers) !== null && _a !== void 0 ? _a : [];
|
|
170
|
-
});
|
|
158
|
+
async getPhoneProviders() {
|
|
159
|
+
const response = await this.client.branding.phone.providers.list();
|
|
160
|
+
return response.providers ?? [];
|
|
171
161
|
}
|
|
172
|
-
processChanges(assets) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
});
|
|
162
|
+
async processChanges(assets) {
|
|
163
|
+
const { phoneProviders } = assets;
|
|
164
|
+
// Non-existing section means themes doesn't need to be processed
|
|
165
|
+
if (!phoneProviders)
|
|
166
|
+
return;
|
|
167
|
+
// Empty array means themes should be deleted
|
|
168
|
+
if (phoneProviders.length === 0) {
|
|
169
|
+
await this.deletePhoneProviders();
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
await this.updatePhoneProviders(phoneProviders);
|
|
173
|
+
}
|
|
186
174
|
}
|
|
187
|
-
deletePhoneProviders() {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
});
|
|
175
|
+
async deletePhoneProviders() {
|
|
176
|
+
if (!this.config('AUTH0_ALLOW_DELETE')) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
// if phone providers exists we need to delete it
|
|
180
|
+
const currentProviders = await this.getPhoneProviders();
|
|
181
|
+
if (currentProviders === null || currentProviders.length === 0) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const currentProvider = currentProviders[0];
|
|
185
|
+
if (!currentProvider.id) {
|
|
186
|
+
throw new Error('Unable to find phone provider id when trying to delete');
|
|
187
|
+
}
|
|
188
|
+
await this.client.branding.phone.providers.delete(currentProvider.id);
|
|
189
|
+
this.deleted += 1;
|
|
190
|
+
this.didDelete(currentProvider);
|
|
204
191
|
}
|
|
205
|
-
updatePhoneProviders(phoneProviders) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
192
|
+
async updatePhoneProviders(phoneProviders) {
|
|
193
|
+
if (phoneProviders.length > 1) {
|
|
194
|
+
logger_1.default.warn('Currently only one phone provider is supported per tenant');
|
|
195
|
+
}
|
|
196
|
+
const currentProviders = await this.getPhoneProviders();
|
|
197
|
+
const providerReqPayload = (() => {
|
|
198
|
+
// Removing id from update and create payloads, otherwise API will error
|
|
199
|
+
// id may be required to handle if `--export_ids=true`
|
|
200
|
+
const payload = phoneProviders[0];
|
|
201
|
+
if (payload && 'id' in payload) {
|
|
202
|
+
delete payload.id;
|
|
209
203
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
// if provider does not exist, create it
|
|
222
|
-
this.created += 1;
|
|
223
|
-
yield this.client.branding.configurePhoneProvider(providerReqPayload);
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
const currentProvider = currentProviders[0];
|
|
227
|
-
// if provider exists, overwrite it
|
|
228
|
-
yield this.client.branding.updatePhoneProvider({ id: currentProvider.id }, providerReqPayload);
|
|
229
|
-
this.updated += 1;
|
|
230
|
-
this.didUpdate(phoneProviders[0]);
|
|
204
|
+
return payload;
|
|
205
|
+
})();
|
|
206
|
+
if (currentProviders === null || currentProviders.length === 0) {
|
|
207
|
+
// if provider does not exist, create it
|
|
208
|
+
this.created += 1;
|
|
209
|
+
await this.client.branding.phone.providers.create(providerReqPayload);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
const currentProvider = currentProviders[0];
|
|
213
|
+
if (!currentProvider.id) {
|
|
214
|
+
throw new Error('Unable to find phone provider id when trying to delete');
|
|
231
215
|
}
|
|
232
|
-
|
|
216
|
+
// if provider exists, overwrite it
|
|
217
|
+
await this.client.branding.phone.providers.update(currentProvider.id, providerReqPayload);
|
|
218
|
+
this.updated += 1;
|
|
219
|
+
this.didUpdate(phoneProviders[0]);
|
|
220
|
+
}
|
|
233
221
|
}
|
|
234
222
|
}
|
|
235
223
|
exports.default = PhoneProviderHandler;
|
|
236
224
|
__decorate([
|
|
237
225
|
(0, default_1.order)('60')
|
|
238
226
|
], PhoneProviderHandler.prototype, "processChanges", null);
|
|
239
|
-
//# sourceMappingURL=phoneProvider.js.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Management } from 'auth0';
|
|
2
|
+
import DefaultHandler from './default';
|
|
3
|
+
import { Asset, Assets, CalculatedChanges } from '../../../types';
|
|
4
|
+
export type PhoneTemplate = Management.PhoneTemplate;
|
|
5
|
+
export declare const schema: {
|
|
6
|
+
type: string;
|
|
7
|
+
description: string;
|
|
8
|
+
items: {
|
|
9
|
+
type: string;
|
|
10
|
+
properties: {
|
|
11
|
+
type: {
|
|
12
|
+
type: string;
|
|
13
|
+
description: string;
|
|
14
|
+
enum: string[];
|
|
15
|
+
};
|
|
16
|
+
disabled: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
content: {
|
|
21
|
+
type: string;
|
|
22
|
+
description: string;
|
|
23
|
+
properties: {
|
|
24
|
+
syntax: {
|
|
25
|
+
type: string;
|
|
26
|
+
description: string;
|
|
27
|
+
};
|
|
28
|
+
from: {
|
|
29
|
+
type: string;
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
body: {
|
|
33
|
+
type: string;
|
|
34
|
+
description: string;
|
|
35
|
+
properties: {
|
|
36
|
+
text: {
|
|
37
|
+
type: string;
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
voice: {
|
|
41
|
+
type: string;
|
|
42
|
+
description: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export default class PhoneTemplatesHandler extends DefaultHandler {
|
|
52
|
+
existing: PhoneTemplate[];
|
|
53
|
+
constructor(options: DefaultHandler);
|
|
54
|
+
objString(template: any): string;
|
|
55
|
+
getType(): Promise<PhoneTemplate[]>;
|
|
56
|
+
processChanges(assets: Assets): Promise<void>;
|
|
57
|
+
createPhoneTemplate(template: any): Promise<Asset>;
|
|
58
|
+
createPhoneTemplates(creates: CalculatedChanges['create']): Promise<void>;
|
|
59
|
+
updatePhoneTemplate(template: any): Promise<Asset>;
|
|
60
|
+
updatePhoneTemplates(updates: CalculatedChanges['update']): Promise<void>;
|
|
61
|
+
deletePhoneTemplate(template: any): Promise<void>;
|
|
62
|
+
deletePhoneTemplates(data: Asset[]): Promise<void>;
|
|
63
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
42
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.schema = void 0;
|
|
46
|
+
const default_1 = __importStar(require("./default"));
|
|
47
|
+
const logger_1 = __importDefault(require("../../../logger"));
|
|
48
|
+
exports.schema = {
|
|
49
|
+
type: 'array',
|
|
50
|
+
description: 'List of phone notification templates',
|
|
51
|
+
items: {
|
|
52
|
+
type: 'object',
|
|
53
|
+
properties: {
|
|
54
|
+
type: {
|
|
55
|
+
type: 'string',
|
|
56
|
+
description: 'Type of phone notification template',
|
|
57
|
+
enum: ['otp_verify', 'otp_enroll', 'change_password', 'blocked_account', 'password_breach'],
|
|
58
|
+
},
|
|
59
|
+
disabled: {
|
|
60
|
+
type: 'boolean',
|
|
61
|
+
description: 'Whether the template is enabled (false) or disabled (true).',
|
|
62
|
+
},
|
|
63
|
+
content: {
|
|
64
|
+
type: 'object',
|
|
65
|
+
description: 'Content of the phone template',
|
|
66
|
+
properties: {
|
|
67
|
+
syntax: {
|
|
68
|
+
type: 'string',
|
|
69
|
+
description: 'Syntax used for the template content',
|
|
70
|
+
},
|
|
71
|
+
from: {
|
|
72
|
+
type: 'string',
|
|
73
|
+
description: 'Default phone number to be used as "from" when sending a phone notification',
|
|
74
|
+
},
|
|
75
|
+
body: {
|
|
76
|
+
type: 'object',
|
|
77
|
+
description: 'Body content of the phone template',
|
|
78
|
+
properties: {
|
|
79
|
+
text: {
|
|
80
|
+
type: 'string',
|
|
81
|
+
description: 'Content of the phone template for text notifications',
|
|
82
|
+
},
|
|
83
|
+
voice: {
|
|
84
|
+
type: 'string',
|
|
85
|
+
description: 'Content of the phone template for voice notifications',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
class PhoneTemplatesHandler extends default_1.default {
|
|
95
|
+
constructor(options) {
|
|
96
|
+
super({
|
|
97
|
+
...options,
|
|
98
|
+
type: 'phoneTemplates',
|
|
99
|
+
identifiers: ['type'],
|
|
100
|
+
stripCreateFields: ['channel', 'customizable', 'tenant'],
|
|
101
|
+
stripUpdateFields: ['channel', 'customizable', 'tenant', 'type'],
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
objString(template) {
|
|
105
|
+
return super.objString({ type: template.type, disabled: template.disabled });
|
|
106
|
+
}
|
|
107
|
+
async getType() {
|
|
108
|
+
if (this.existing) {
|
|
109
|
+
return this.existing;
|
|
110
|
+
}
|
|
111
|
+
const response = await this.client.branding.phone.templates.list();
|
|
112
|
+
this.existing = response.templates ?? [];
|
|
113
|
+
return this.existing;
|
|
114
|
+
}
|
|
115
|
+
async processChanges(assets) {
|
|
116
|
+
const { phoneTemplates } = assets;
|
|
117
|
+
if (!phoneTemplates)
|
|
118
|
+
return;
|
|
119
|
+
const { del, update, create } = await this.calcChanges(assets);
|
|
120
|
+
logger_1.default.debug(`Start processChanges for phone templates [delete:${del.length}] [update:${update.length}], [create:${create.length}]`);
|
|
121
|
+
if (del.length > 0) {
|
|
122
|
+
await this.deletePhoneTemplates(del);
|
|
123
|
+
}
|
|
124
|
+
if (create.length > 0) {
|
|
125
|
+
await this.createPhoneTemplates(create);
|
|
126
|
+
}
|
|
127
|
+
if (update.length > 0) {
|
|
128
|
+
await this.updatePhoneTemplates(update);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
async createPhoneTemplate(template) {
|
|
132
|
+
const created = await this.client.branding.phone.templates.create(template);
|
|
133
|
+
return created;
|
|
134
|
+
}
|
|
135
|
+
async createPhoneTemplates(creates) {
|
|
136
|
+
await this.client.pool
|
|
137
|
+
.addEachTask({
|
|
138
|
+
data: creates || [],
|
|
139
|
+
generator: (item) => this.createPhoneTemplate(item)
|
|
140
|
+
.then((data) => {
|
|
141
|
+
this.didCreate(data);
|
|
142
|
+
this.created += 1;
|
|
143
|
+
})
|
|
144
|
+
.catch((err) => {
|
|
145
|
+
throw new Error(`Problem creating ${this.type} ${this.objString(item)}\n${err}`);
|
|
146
|
+
}),
|
|
147
|
+
})
|
|
148
|
+
.promise();
|
|
149
|
+
}
|
|
150
|
+
async updatePhoneTemplate(template) {
|
|
151
|
+
const { type } = template;
|
|
152
|
+
// Find the existing template to get its id
|
|
153
|
+
const existing = this.existing?.find((t) => t.type === type);
|
|
154
|
+
if (!existing?.id) {
|
|
155
|
+
logger_1.default.warn(`Skipping update for phone template type '${type}' as unable to find existing template ID`);
|
|
156
|
+
return template;
|
|
157
|
+
}
|
|
158
|
+
// stripUpdateFields does not support in sub modules
|
|
159
|
+
const stripUpdateFields = ['content.syntax'];
|
|
160
|
+
logger_1.default.debug(`Stripping ${this.type} create-only fields ${JSON.stringify(stripUpdateFields)}`);
|
|
161
|
+
const updatePayload = {
|
|
162
|
+
content: {
|
|
163
|
+
from: template.content?.from,
|
|
164
|
+
body: {
|
|
165
|
+
text: template.content?.body?.text,
|
|
166
|
+
voice: template.content?.body?.voice,
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
disabled: template.disabled,
|
|
170
|
+
};
|
|
171
|
+
const updated = await this.client.branding.phone.templates.update(existing.id, updatePayload);
|
|
172
|
+
return updated;
|
|
173
|
+
}
|
|
174
|
+
async updatePhoneTemplates(updates) {
|
|
175
|
+
await this.client.pool
|
|
176
|
+
.addEachTask({
|
|
177
|
+
data: updates || [],
|
|
178
|
+
generator: (item) => this.updatePhoneTemplate(item)
|
|
179
|
+
.then((data) => {
|
|
180
|
+
this.didUpdate(data);
|
|
181
|
+
this.updated += 1;
|
|
182
|
+
})
|
|
183
|
+
.catch((err) => {
|
|
184
|
+
throw new Error(`Problem updating ${this.type} ${this.objString(item)}\n${err}`);
|
|
185
|
+
}),
|
|
186
|
+
})
|
|
187
|
+
.promise();
|
|
188
|
+
}
|
|
189
|
+
async deletePhoneTemplate(template) {
|
|
190
|
+
if (!template.id) {
|
|
191
|
+
throw new Error(`Unable to find phone template id for type ${template.type} when trying to delete`);
|
|
192
|
+
}
|
|
193
|
+
await this.client.branding.phone.templates.delete(template.id);
|
|
194
|
+
}
|
|
195
|
+
async deletePhoneTemplates(data) {
|
|
196
|
+
if (this.config('AUTH0_ALLOW_DELETE') === 'true' ||
|
|
197
|
+
this.config('AUTH0_ALLOW_DELETE') === true) {
|
|
198
|
+
await this.client.pool
|
|
199
|
+
.addEachTask({
|
|
200
|
+
data: data || [],
|
|
201
|
+
generator: (item) => this.deletePhoneTemplate(item)
|
|
202
|
+
.then(() => {
|
|
203
|
+
this.didDelete(item);
|
|
204
|
+
this.deleted += 1;
|
|
205
|
+
})
|
|
206
|
+
.catch((err) => {
|
|
207
|
+
throw new Error(`Problem deleting ${this.type} ${this.objString(item)}\n${err}`);
|
|
208
|
+
}),
|
|
209
|
+
})
|
|
210
|
+
.promise();
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
logger_1.default.warn(`Detected the following phone templates should be deleted. Doing so may be destructive.\nYou can enable deletes by setting 'AUTH0_ALLOW_DELETE' to true in the config
|
|
214
|
+
\n${data.map((i) => this.objString(i)).join('\n')}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
exports.default = PhoneTemplatesHandler;
|
|
219
|
+
__decorate([
|
|
220
|
+
(0, default_1.order)('65')
|
|
221
|
+
], PhoneTemplatesHandler.prototype, "processChanges", null);
|