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
|
};
|
|
@@ -28,6 +19,50 @@ function order(value) {
|
|
|
28
19
|
return descriptor;
|
|
29
20
|
};
|
|
30
21
|
}
|
|
22
|
+
// Retry configuration constants
|
|
23
|
+
const DEFAULT_MAX_RETRIES = 3;
|
|
24
|
+
const DEFAULT_INITIAL_DELAY_MS = 1000; // 1 second
|
|
25
|
+
const DEFAULT_MAX_DELAY_MS = 30000; // 30 seconds
|
|
26
|
+
/**
|
|
27
|
+
* Executes a function with exponential backoff retry logic for rate limit errors (429).
|
|
28
|
+
*
|
|
29
|
+
* @param fn - The function to execute with retry logic
|
|
30
|
+
* @param options - Configuration options for retry behavior
|
|
31
|
+
* @returns Promise that resolves with the function result or rejects after max retries
|
|
32
|
+
*/
|
|
33
|
+
async function retryWithExponentialBackoff(fn, options = {}) {
|
|
34
|
+
const { maxRetries = DEFAULT_MAX_RETRIES, initialDelay = DEFAULT_INITIAL_DELAY_MS, maxDelay = DEFAULT_MAX_DELAY_MS, onRetry = () => { }, } = options;
|
|
35
|
+
let lastError;
|
|
36
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
37
|
+
try {
|
|
38
|
+
return await fn();
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
lastError = error;
|
|
42
|
+
// Only retry on rate limit errors (429)
|
|
43
|
+
const isRateLimitError = error?.statusCode === 429 ||
|
|
44
|
+
error?.message?.includes('429') ||
|
|
45
|
+
error?.message?.includes('Too Many Requests') ||
|
|
46
|
+
error?.message?.includes('TooManyRequestsError') ||
|
|
47
|
+
error?.message?.includes('Global limit has been reached');
|
|
48
|
+
if (!isRateLimitError || attempt === maxRetries) {
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
// Calculate delay with exponential backoff and jitter
|
|
52
|
+
const exponentialDelay = initialDelay * 2 ** attempt;
|
|
53
|
+
const jitter = Math.random() * 1000; // 0-1s randomization to prevent thundering herd
|
|
54
|
+
const delay = Math.min(exponentialDelay + jitter, maxDelay);
|
|
55
|
+
// Check for Retry-After header (if available in error response)
|
|
56
|
+
const retryAfter = error?.rawResponse?.headers?.get('retry-after');
|
|
57
|
+
const finalDelay = retryAfter ? parseInt(retryAfter, 10) * 1000 : delay;
|
|
58
|
+
onRetry(error, attempt + 1, finalDelay);
|
|
59
|
+
await new Promise((resolve) => {
|
|
60
|
+
setTimeout(resolve, finalDelay);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
throw lastError;
|
|
65
|
+
}
|
|
31
66
|
class APIHandler {
|
|
32
67
|
constructor(options) {
|
|
33
68
|
this.config = options.config;
|
|
@@ -40,7 +75,13 @@ class APIHandler {
|
|
|
40
75
|
this.stripUpdateFields = [...(options.stripUpdateFields || []), this.id];
|
|
41
76
|
this.sensitiveFieldsToObfuscate = options.sensitiveFieldsToObfuscate || [];
|
|
42
77
|
this.stripCreateFields = options.stripCreateFields || [];
|
|
43
|
-
this.functions =
|
|
78
|
+
this.functions = {
|
|
79
|
+
list: 'list',
|
|
80
|
+
create: 'create',
|
|
81
|
+
delete: 'delete',
|
|
82
|
+
update: 'update',
|
|
83
|
+
...(options.functions || {}),
|
|
84
|
+
};
|
|
44
85
|
this.updated = 0;
|
|
45
86
|
this.created = 0;
|
|
46
87
|
this.deleted = 0;
|
|
@@ -57,7 +98,7 @@ class APIHandler {
|
|
|
57
98
|
}
|
|
58
99
|
didCreate(item) {
|
|
59
100
|
if (typeof item === 'object' && item instanceof auth0_1.JSONApiResponse) {
|
|
60
|
-
logger_1.default.info(`Created [${this.type}]: ${this.objString(item
|
|
101
|
+
logger_1.default.info(`Created [${this.type}]: ${this.objString(item?.data)}`);
|
|
61
102
|
}
|
|
62
103
|
else {
|
|
63
104
|
logger_1.default.info(`Created [${this.type}]: ${this.objString(item)}`);
|
|
@@ -65,7 +106,7 @@ class APIHandler {
|
|
|
65
106
|
}
|
|
66
107
|
didUpdate(item) {
|
|
67
108
|
if (typeof item === 'object' && item instanceof auth0_1.JSONApiResponse) {
|
|
68
|
-
logger_1.default.info(`Updated [${this.type}]: ${this.objString(item
|
|
109
|
+
logger_1.default.info(`Updated [${this.type}]: ${this.objString(item?.data)}`);
|
|
69
110
|
}
|
|
70
111
|
else {
|
|
71
112
|
logger_1.default.info(`Updated [${this.type}]: ${this.objString(item)}`);
|
|
@@ -74,181 +115,179 @@ class APIHandler {
|
|
|
74
115
|
objString(item) {
|
|
75
116
|
return (0, utils_1.convertJsonToString)(item);
|
|
76
117
|
}
|
|
77
|
-
getType() {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
throw new Error(`Must implement getType for type ${this.type}`);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
load() {
|
|
84
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
// Load Asset from Tenant
|
|
86
|
-
const data = yield (() => __awaiter(this, void 0, void 0, function* () {
|
|
87
|
-
const { data, hadSufficientScopes, requiredScopes } = yield (0, utils_1.detectInsufficientScopeError)(this.getType.bind(this));
|
|
88
|
-
if (!hadSufficientScopes) {
|
|
89
|
-
logger_1.default.warn(`Cannot retrieve ${this.type} due to missing scopes: ${requiredScopes}`);
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
logger_1.default.info(`Retrieving ${this.type} data from Auth0`);
|
|
93
|
-
return data;
|
|
94
|
-
}))();
|
|
95
|
-
this.existing = (0, utils_1.obfuscateSensitiveValues)(data, this.sensitiveFieldsToObfuscate);
|
|
96
|
-
return { [this.type]: this.existing };
|
|
97
|
-
});
|
|
118
|
+
async getType() {
|
|
119
|
+
// Each type to impl how to get the existing as its not consistent across the mgnt api.
|
|
120
|
+
throw new Error(`Must implement getType for type ${this.type}`);
|
|
98
121
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (!
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
create: [],
|
|
107
|
-
conflicts: [],
|
|
108
|
-
update: [],
|
|
109
|
-
};
|
|
122
|
+
async load() {
|
|
123
|
+
// Load Asset from Tenant
|
|
124
|
+
const data = await (async () => {
|
|
125
|
+
const { data, hadSufficientScopes, requiredScopes } = await (0, utils_1.detectInsufficientScopeError)(this.getType.bind(this));
|
|
126
|
+
if (!hadSufficientScopes) {
|
|
127
|
+
logger_1.default.warn(`Cannot retrieve ${this.type} due to missing scopes: ${requiredScopes}`);
|
|
128
|
+
return null;
|
|
110
129
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
130
|
+
logger_1.default.info(`Retrieving ${this.type} data from Auth0`);
|
|
131
|
+
return data;
|
|
132
|
+
})();
|
|
133
|
+
this.existing = (0, utils_1.obfuscateSensitiveValues)(data, this.sensitiveFieldsToObfuscate);
|
|
134
|
+
return { [this.type]: this.existing };
|
|
135
|
+
}
|
|
136
|
+
async calcChanges(assets) {
|
|
137
|
+
const typeAssets = assets[this.type];
|
|
138
|
+
// Do nothing if not set
|
|
139
|
+
if (!typeAssets) {
|
|
140
|
+
return {
|
|
141
|
+
del: [],
|
|
142
|
+
create: [],
|
|
143
|
+
conflicts: [],
|
|
144
|
+
update: [],
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
const existing = await this.getType();
|
|
148
|
+
// Figure out what needs to be updated vs created
|
|
149
|
+
return (0, calculateChanges_1.calculateChanges)({
|
|
150
|
+
handler: this,
|
|
151
|
+
assets: typeAssets,
|
|
152
|
+
allowDelete: !!this.config('AUTH0_ALLOW_DELETE'),
|
|
153
|
+
//@ts-ignore TODO: investigate what happens when `existing` is null
|
|
154
|
+
existing,
|
|
155
|
+
identifiers: this.identifiers,
|
|
121
156
|
});
|
|
122
157
|
}
|
|
123
|
-
validate(assets) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
throw new validationError_1.default(`There are multiple ${this.type} with the same name combinations
|
|
158
|
+
async validate(assets) {
|
|
159
|
+
// Ensure no duplication in id and name
|
|
160
|
+
const typeAssets = assets[this.type];
|
|
161
|
+
// Do nothing if not set
|
|
162
|
+
if (!Array.isArray(typeAssets))
|
|
163
|
+
return;
|
|
164
|
+
// Do not allow items with same name
|
|
165
|
+
const duplicateNames = (0, utils_1.duplicateItems)(typeAssets, 'name');
|
|
166
|
+
if (duplicateNames.length > 0) {
|
|
167
|
+
const formatted = duplicateNames.map((dups) => dups.map((d) => `${d.name}`));
|
|
168
|
+
throw new validationError_1.default(`There are multiple ${this.type} with the same name combinations
|
|
135
169
|
${(0, utils_1.convertJsonToString)(formatted)}.
|
|
136
170
|
Names must be unique.`);
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
171
|
+
}
|
|
172
|
+
// Do not allow items with same id
|
|
173
|
+
const duplicateIDs = (0, utils_1.duplicateItems)(typeAssets, this.id);
|
|
174
|
+
if (duplicateIDs.length > 0) {
|
|
175
|
+
const formatted = duplicateIDs.map((dups) => dups.map((d) => `${d[this.id]}`));
|
|
176
|
+
throw new validationError_1.default(`There are multiple ${this.type} for the following stage-order combinations
|
|
143
177
|
${(0, utils_1.convertJsonToString)(formatted)}.
|
|
144
178
|
Only one rule must be defined for the same order number in a stage.`);
|
|
145
|
-
|
|
146
|
-
});
|
|
179
|
+
}
|
|
147
180
|
}
|
|
148
|
-
processChanges(assets, changes) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
181
|
+
async processChanges(assets, changes) {
|
|
182
|
+
if (!changes) {
|
|
183
|
+
changes = await this.calcChanges(assets);
|
|
184
|
+
}
|
|
185
|
+
const del = changes.del || [];
|
|
186
|
+
const update = changes.update || [];
|
|
187
|
+
const create = changes.create || [];
|
|
188
|
+
const conflicts = changes.conflicts || [];
|
|
189
|
+
logger_1.default.debug(`Start processChanges for ${this.type} [delete:${del.length}] [update:${update.length}], [create:${create.length}], [conflicts:${conflicts.length}]`);
|
|
190
|
+
// Set retry configuration from config
|
|
191
|
+
const retryConfig = {
|
|
192
|
+
maxRetries: this.config('AUTH0_MAX_RETRIES') || DEFAULT_MAX_RETRIES,
|
|
193
|
+
initialDelay: this.config('AUTH0_RETRY_INITIAL_DELAY_MS') || DEFAULT_INITIAL_DELAY_MS,
|
|
194
|
+
maxDelay: this.config('AUTH0_RETRY_MAX_DELAY_MS') || DEFAULT_MAX_DELAY_MS,
|
|
195
|
+
onRetry: (error, attempt, delay) => {
|
|
196
|
+
logger_1.default.warn(`Rate limit hit for [${this.type}]. Retrying attempt ${attempt}/${retryConfig.maxRetries} after ${Math.round(delay / 1000)}s...`);
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
// Process Deleted
|
|
200
|
+
if (del.length > 0) {
|
|
201
|
+
const allowDelete = this.config('AUTH0_ALLOW_DELETE') === 'true' || this.config('AUTH0_ALLOW_DELETE') === true;
|
|
202
|
+
const byExtension = this.config('EXTENSION_SECRET') &&
|
|
203
|
+
(this.type === 'rules' || this.type === 'resourceServers');
|
|
204
|
+
const shouldDelete = allowDelete || byExtension;
|
|
205
|
+
if (!shouldDelete) {
|
|
206
|
+
logger_1.default.warn(`Detected the following ${this.type} should be deleted. Doing so may be destructive.\nYou can enable deletes by setting 'AUTH0_ALLOW_DELETE' to true in the config
|
|
166
207
|
\n${changes.del.map((i) => this.objString(i)).join('\n')}
|
|
167
208
|
`);
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
yield this.client.pool
|
|
171
|
-
.addEachTask({
|
|
172
|
-
data: del || [],
|
|
173
|
-
generator: (delItem) => {
|
|
174
|
-
const delFunction = this.getClientFN(this.functions.delete);
|
|
175
|
-
return delFunction({ [this.id]: delItem[this.id] })
|
|
176
|
-
.then(() => {
|
|
177
|
-
this.didDelete(delItem);
|
|
178
|
-
this.deleted += 1;
|
|
179
|
-
})
|
|
180
|
-
.catch((err) => {
|
|
181
|
-
throw new Error(`Problem deleting ${this.type} ${this.objString(delItem)}\n${err}`);
|
|
182
|
-
});
|
|
183
|
-
},
|
|
184
|
-
})
|
|
185
|
-
.promise();
|
|
186
|
-
}
|
|
187
209
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return updateFN(params, updatePayload)
|
|
200
|
-
.then((data) => this.didUpdate(data))
|
|
201
|
-
.catch((err) => {
|
|
202
|
-
throw new Error(`Problem updating ${this.type} ${this.objString(updateItem)}\n${err}`);
|
|
203
|
-
});
|
|
204
|
-
},
|
|
205
|
-
})
|
|
206
|
-
.promise();
|
|
207
|
-
// Process Creations
|
|
208
|
-
yield this.client.pool
|
|
209
|
-
.addEachTask({
|
|
210
|
-
data: create || [],
|
|
211
|
-
generator: (createItem) => {
|
|
212
|
-
const createFunction = this.getClientFN(this.functions.create);
|
|
213
|
-
const createPayload = (() => {
|
|
214
|
-
const strippedPayload = (0, utils_1.stripFields)(createItem, this.stripCreateFields);
|
|
215
|
-
return (0, utils_1.stripObfuscatedFieldsFromPayload)(strippedPayload, this.sensitiveFieldsToObfuscate);
|
|
216
|
-
})();
|
|
217
|
-
return createFunction(createPayload)
|
|
218
|
-
.then((data) => {
|
|
219
|
-
this.didCreate(data);
|
|
220
|
-
this.created += 1;
|
|
210
|
+
else {
|
|
211
|
+
await this.client.pool
|
|
212
|
+
.addEachTask({
|
|
213
|
+
data: del || [],
|
|
214
|
+
generator: (delItem) => retryWithExponentialBackoff(() => {
|
|
215
|
+
const delFunction = this.getClientFN(this.functions.delete);
|
|
216
|
+
return delFunction(delItem[this.id]);
|
|
217
|
+
}, retryConfig)
|
|
218
|
+
.then(() => {
|
|
219
|
+
this.didDelete(delItem);
|
|
220
|
+
this.deleted += 1;
|
|
221
221
|
})
|
|
222
222
|
.catch((err) => {
|
|
223
|
-
throw new Error(`Problem
|
|
224
|
-
})
|
|
225
|
-
}
|
|
223
|
+
throw new Error(`Problem deleting ${this.type} ${this.objString(delItem)}\n${err}`);
|
|
224
|
+
}),
|
|
225
|
+
})
|
|
226
|
+
.promise();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
// Process Renaming Entries Temp due to conflicts in names
|
|
230
|
+
await this.client.pool
|
|
231
|
+
.addEachTask({
|
|
232
|
+
data: conflicts || [],
|
|
233
|
+
generator: (updateItem) => retryWithExponentialBackoff(() => {
|
|
234
|
+
const updateFN = this.getClientFN(this.functions.update);
|
|
235
|
+
const params = { [this.id]: updateItem[this.id] };
|
|
236
|
+
const updatePayload = (() => {
|
|
237
|
+
const data = (0, utils_1.stripFields)({ ...updateItem }, this.stripUpdateFields);
|
|
238
|
+
return (0, utils_1.stripObfuscatedFieldsFromPayload)(data, this.sensitiveFieldsToObfuscate);
|
|
239
|
+
})();
|
|
240
|
+
return updateFN(params, updatePayload);
|
|
241
|
+
}, retryConfig)
|
|
242
|
+
.then((data) => this.didUpdate(data))
|
|
243
|
+
.catch((err) => {
|
|
244
|
+
throw new Error(`Problem updating ${this.type} ${this.objString(updateItem)}\n${err}`);
|
|
245
|
+
}),
|
|
246
|
+
})
|
|
247
|
+
.promise();
|
|
248
|
+
// Process Creations
|
|
249
|
+
await this.client.pool
|
|
250
|
+
.addEachTask({
|
|
251
|
+
data: create || [],
|
|
252
|
+
generator: (createItem) => retryWithExponentialBackoff(() => {
|
|
253
|
+
const createFunction = this.getClientFN(this.functions.create);
|
|
254
|
+
const createPayload = (() => {
|
|
255
|
+
const strippedPayload = (0, utils_1.stripFields)(createItem, this.stripCreateFields);
|
|
256
|
+
return (0, utils_1.stripObfuscatedFieldsFromPayload)(strippedPayload, this.sensitiveFieldsToObfuscate);
|
|
257
|
+
})();
|
|
258
|
+
return createFunction(createPayload);
|
|
259
|
+
}, retryConfig)
|
|
260
|
+
.then((data) => {
|
|
261
|
+
this.didCreate(data);
|
|
262
|
+
this.created += 1;
|
|
226
263
|
})
|
|
227
|
-
.
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
264
|
+
.catch((err) => {
|
|
265
|
+
throw new Error(`Problem creating ${this.type} ${this.objString(createItem)}\n${err}`);
|
|
266
|
+
}),
|
|
267
|
+
})
|
|
268
|
+
.promise();
|
|
269
|
+
// Process Updates and strip fields not allowed in updates
|
|
270
|
+
await this.client.pool
|
|
271
|
+
.addEachTask({
|
|
272
|
+
data: update || [],
|
|
273
|
+
generator: (updateItem) => retryWithExponentialBackoff(() => {
|
|
274
|
+
const updateFN = this.getClientFN(this.functions.update);
|
|
275
|
+
const params = { [this.id]: updateItem[this.id] };
|
|
276
|
+
const updatePayload = (() => {
|
|
277
|
+
const data = (0, utils_1.stripFields)({ ...updateItem }, this.stripUpdateFields);
|
|
278
|
+
return (0, utils_1.stripObfuscatedFieldsFromPayload)(data, this.sensitiveFieldsToObfuscate);
|
|
279
|
+
})();
|
|
280
|
+
return updateFN(params, updatePayload);
|
|
281
|
+
}, retryConfig)
|
|
282
|
+
.then((data) => {
|
|
283
|
+
this.didUpdate(data);
|
|
284
|
+
this.updated += 1;
|
|
248
285
|
})
|
|
249
|
-
.
|
|
250
|
-
|
|
286
|
+
.catch((err) => {
|
|
287
|
+
throw new Error(`Problem updating ${this.type} ${this.objString(updateItem)}\n${err}`);
|
|
288
|
+
}),
|
|
289
|
+
})
|
|
290
|
+
.promise();
|
|
251
291
|
}
|
|
252
292
|
}
|
|
253
293
|
exports.default = APIHandler;
|
|
254
|
-
//# sourceMappingURL=default.js.map
|
|
@@ -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
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
42
|
exports.schema = void 0;
|
|
52
43
|
const lodash_1 = require("lodash");
|
|
@@ -56,61 +47,59 @@ exports.schema = { type: 'object' };
|
|
|
56
47
|
const defaultFields = ['name', 'enabled', 'credentials', 'settings', 'default_from_address'];
|
|
57
48
|
class EmailProviderHandler extends default_1.default {
|
|
58
49
|
constructor(options) {
|
|
59
|
-
super(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
try {
|
|
64
|
-
const { data } = yield this.client.emails.get({
|
|
65
|
-
include_fields: true,
|
|
66
|
-
fields: defaultFields.join(','),
|
|
67
|
-
});
|
|
68
|
-
return data;
|
|
69
|
-
}
|
|
70
|
-
catch (err) {
|
|
71
|
-
if (err.statusCode === 404)
|
|
72
|
-
return {};
|
|
73
|
-
throw err;
|
|
74
|
-
}
|
|
50
|
+
super({
|
|
51
|
+
...options,
|
|
52
|
+
type: 'emailProvider',
|
|
75
53
|
});
|
|
76
54
|
}
|
|
55
|
+
async getType() {
|
|
56
|
+
try {
|
|
57
|
+
const emailProvider = await this.client.emails.provider.get({
|
|
58
|
+
include_fields: true,
|
|
59
|
+
fields: defaultFields.join(','),
|
|
60
|
+
});
|
|
61
|
+
return emailProvider;
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
if (err.statusCode === 404)
|
|
65
|
+
return {};
|
|
66
|
+
throw err;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
77
69
|
objString(provider) {
|
|
78
70
|
return super.objString({ name: provider.name, enabled: provider.enabled });
|
|
79
71
|
}
|
|
80
|
-
processChanges(assets) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
delete existing.credentials;
|
|
92
|
-
}
|
|
93
|
-
const updated = yield this.client.emails.update(existing);
|
|
94
|
-
this.updated += 1;
|
|
95
|
-
this.didUpdate(updated);
|
|
72
|
+
async processChanges(assets) {
|
|
73
|
+
const { emailProvider } = assets;
|
|
74
|
+
if (!emailProvider)
|
|
75
|
+
return;
|
|
76
|
+
const existing = await this.getType();
|
|
77
|
+
// HTTP DELETE on emails/provider is not supported, as this is not part of our vNext SDK.
|
|
78
|
+
if (Object.keys(emailProvider).length === 0) {
|
|
79
|
+
if (this.config('AUTH0_ALLOW_DELETE') === true) {
|
|
80
|
+
// await this.client.emails.delete(); is not supported
|
|
81
|
+
if ((0, lodash_1.isEmpty)(existing.credentials)) {
|
|
82
|
+
delete existing.credentials;
|
|
96
83
|
}
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
if (existing.name) {
|
|
100
|
-
const updated = yield this.client.emails.update(emailProvider);
|
|
84
|
+
const updated = await this.client.emails.provider.update(existing);
|
|
101
85
|
this.updated += 1;
|
|
102
86
|
this.didUpdate(updated);
|
|
103
87
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (existing.name) {
|
|
91
|
+
const updated = await this.client.emails.provider.update(emailProvider);
|
|
92
|
+
this.updated += 1;
|
|
93
|
+
this.didUpdate(updated);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
const created = await this.client.emails.provider.create(emailProvider);
|
|
97
|
+
this.created += 1;
|
|
98
|
+
this.didCreate(created);
|
|
99
|
+
}
|
|
110
100
|
}
|
|
111
101
|
}
|
|
112
102
|
exports.default = EmailProviderHandler;
|
|
113
103
|
__decorate([
|
|
114
104
|
(0, default_1.order)('60')
|
|
115
105
|
], EmailProviderHandler.prototype, "processChanges", null);
|
|
116
|
-
//# sourceMappingURL=emailProvider.js.map
|
|
@@ -20,6 +20,7 @@ export declare const schema: {
|
|
|
20
20
|
};
|
|
21
21
|
export default class EmailTemplateHandler extends DefaultHandler {
|
|
22
22
|
constructor(options: DefaultHandler);
|
|
23
|
+
objString(item: any): string;
|
|
23
24
|
getType(): Promise<Asset>;
|
|
24
25
|
updateOrCreate(emailTemplate: any): Promise<void>;
|
|
25
26
|
processChanges(assets: Assets): Promise<void>;
|