auth0-deploy-cli 7.5.2 → 7.7.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/.eslintrc +7 -41
- package/.husky/pre-commit +4 -0
- package/.husky/pre-push +3 -1
- package/.prettierignore +10 -0
- package/.prettierrc.json +4 -0
- package/CHANGELOG.md +219 -7
- package/CONTRIBUTING.md +2 -2
- package/README.md +3 -0
- package/lib/args.js +16 -17
- package/lib/commands/export.js +3 -3
- package/lib/commands/import.js +7 -6
- package/lib/commands/index.js +1 -1
- package/lib/configFactory.js +5 -1
- package/lib/context/defaults.js +4 -3
- package/lib/context/directory/handlers/actions.js +6 -5
- package/lib/context/directory/handlers/attackProtection.js +10 -9
- package/lib/context/directory/handlers/branding.js +60 -0
- package/lib/context/directory/handlers/clientGrants.js +6 -4
- package/lib/context/directory/handlers/clients.js +4 -3
- package/lib/context/directory/handlers/connections.js +7 -4
- package/lib/context/directory/handlers/databases.js +30 -22
- package/lib/context/directory/handlers/emailProvider.js +6 -4
- package/lib/context/directory/handlers/emailTemplates.js +13 -11
- package/lib/context/directory/handlers/guardianFactorProviders.js +6 -4
- package/lib/context/directory/handlers/guardianFactorTemplates.js +6 -4
- package/lib/context/directory/handlers/guardianFactors.js +6 -4
- package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.js +4 -3
- package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.js +4 -3
- package/lib/context/directory/handlers/guardianPolicies.js +4 -3
- package/lib/context/directory/handlers/hooks.js +5 -4
- package/lib/context/directory/handlers/index.js +5 -2
- package/lib/context/directory/handlers/migrations.js +8 -8
- package/lib/context/directory/handlers/organizations.js +4 -3
- package/lib/context/directory/handlers/pages.js +20 -20
- package/lib/context/directory/handlers/resourceServers.js +6 -4
- package/lib/context/directory/handlers/roles.js +4 -3
- package/lib/context/directory/handlers/rules.js +5 -4
- package/lib/context/directory/handlers/rulesConfigs.js +7 -5
- package/lib/context/directory/handlers/tenant.js +7 -4
- package/lib/context/directory/handlers/triggers.js +3 -2
- package/lib/context/directory/index.js +23 -22
- package/lib/context/index.js +83 -61
- package/lib/context/yaml/handlers/actions.js +12 -8
- package/lib/context/yaml/handlers/attackProtection.js +6 -12
- package/lib/context/yaml/handlers/branding.js +66 -0
- package/lib/context/yaml/handlers/clientGrants.js +5 -4
- package/lib/context/yaml/handlers/clients.js +9 -6
- package/lib/context/yaml/handlers/connections.js +10 -7
- package/lib/context/yaml/handlers/databases.js +15 -10
- package/lib/context/yaml/handlers/emailProvider.js +7 -5
- package/lib/context/yaml/handlers/emailTemplates.js +6 -5
- package/lib/context/yaml/handlers/guardianFactorProviders.js +6 -13
- package/lib/context/yaml/handlers/guardianFactorTemplates.js +6 -13
- package/lib/context/yaml/handlers/guardianFactors.js +6 -13
- package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.js +6 -13
- package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.js +6 -13
- package/lib/context/yaml/handlers/guardianPolicies.js +6 -13
- package/lib/context/yaml/handlers/hooks.js +7 -5
- package/lib/context/yaml/handlers/index.js +5 -2
- package/lib/context/yaml/handlers/migrations.js +3 -2
- package/lib/context/yaml/handlers/organizations.js +6 -5
- package/lib/context/yaml/handlers/pages.js +6 -5
- package/lib/context/yaml/handlers/resourceServers.js +5 -4
- package/lib/context/yaml/handlers/roles.js +6 -5
- package/lib/context/yaml/handlers/rules.js +6 -5
- package/lib/context/yaml/handlers/rulesConfigs.js +6 -5
- package/lib/context/yaml/handlers/tenant.js +7 -5
- package/lib/context/yaml/handlers/triggers.js +5 -4
- package/lib/context/yaml/index.js +33 -24
- package/lib/index.js +20 -15
- package/lib/logger.js +4 -3
- package/lib/readonly.js +11 -16
- package/lib/sessionDurationsToMinutes.js +15 -0
- package/lib/tools/auth0/client.js +12 -12
- package/lib/tools/auth0/handlers/actions.js +21 -23
- package/lib/tools/auth0/handlers/attackProtection.js +14 -17
- package/lib/tools/auth0/handlers/branding.js +71 -13
- package/lib/tools/auth0/handlers/clientGrants.js +17 -10
- package/lib/tools/auth0/handlers/clients.js +15 -8
- package/lib/tools/auth0/handlers/connections.js +30 -10
- package/lib/tools/auth0/handlers/databases.js +25 -13
- package/lib/tools/auth0/handlers/default.js +46 -28
- package/lib/tools/auth0/handlers/emailTemplates.js +8 -10
- package/lib/tools/auth0/handlers/guardianFactorProviders.js +3 -3
- package/lib/tools/auth0/handlers/guardianFactorTemplates.js +3 -3
- package/lib/tools/auth0/handlers/guardianFactors.js +3 -3
- package/lib/tools/auth0/handlers/guardianPhoneFactorMessageTypes.js +11 -10
- package/lib/tools/auth0/handlers/guardianPhoneFactorSelectedProvider.js +10 -9
- package/lib/tools/auth0/handlers/guardianPolicies.js +5 -4
- package/lib/tools/auth0/handlers/hooks.js +34 -21
- package/lib/tools/auth0/handlers/index.js +31 -27
- package/lib/tools/auth0/handlers/migrations.js +2 -1
- package/lib/tools/auth0/handlers/organizations.js +67 -32
- package/lib/tools/auth0/handlers/pages.js +20 -14
- package/lib/tools/auth0/handlers/prompts.js +1 -0
- package/lib/tools/auth0/handlers/resourceServers.js +28 -15
- package/lib/tools/auth0/handlers/roles.js +61 -32
- package/lib/tools/auth0/handlers/rules.js +58 -35
- package/lib/tools/auth0/handlers/rulesConfigs.js +12 -6
- package/lib/tools/auth0/handlers/tenant.js +8 -4
- package/lib/tools/auth0/handlers/triggers.js +11 -12
- package/lib/tools/auth0/index.js +15 -31
- package/lib/tools/auth0/schema.js +7 -27
- package/lib/tools/calculateChanges.js +149 -0
- package/lib/tools/constants.js +162 -154
- package/lib/tools/deploy.js +1 -1
- package/lib/tools/index.js +1 -1
- package/lib/tools/logger.js +14 -8
- package/lib/tools/utils.js +34 -150
- package/lib/tools/{ValidationError.js → validationError.js} +3 -1
- package/lib/types.js +2 -0
- package/lib/utils.js +18 -25
- package/package.json +11 -2
- package/tsconfig.json +2 -3
- package/typescript-migration-progress.sh +1 -1
package/lib/tools/constants.js
CHANGED
|
@@ -1,158 +1,166 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
];
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
'
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
]
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
'
|
|
91
|
-
'
|
|
92
|
-
'
|
|
93
|
-
'
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
'
|
|
105
|
-
'
|
|
106
|
-
'
|
|
107
|
-
'
|
|
108
|
-
|
|
109
|
-
]
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
]
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
3
|
+
const PAGE_GUARDIAN_MULTIFACTOR = 'guardian_multifactor';
|
|
4
|
+
const PAGE_PASSWORD_RESET = 'password_reset';
|
|
5
|
+
const PAGE_LOGIN = 'login';
|
|
6
|
+
const PAGE_ERROR = 'error_page';
|
|
7
|
+
const RULES_STAGES = ['login_success'];
|
|
8
|
+
const DATABASE_SCRIPTS_GET_USER = 'get_user';
|
|
9
|
+
const DATABASE_SCRIPTS_CHANGE_EMAIL = 'change_email';
|
|
10
|
+
const EMAIL_VERIFY = 'verify_email';
|
|
11
|
+
const EMAIL_VERIFY_BY_CODE = 'verify_email_by_code';
|
|
12
|
+
const EMAIL_RESET = 'reset_email';
|
|
13
|
+
const EMAIL_WELCOME = 'welcome_email';
|
|
14
|
+
const EMAIL_BLOCKED = 'blocked_account';
|
|
15
|
+
const EMAIL_STOLEN_CREDENTIALS = 'stolen_credentials';
|
|
16
|
+
const EMAIL_ENROLLMENT = 'enrollment_email';
|
|
17
|
+
const EMAIL_CHANGE_PASSWORD = 'change_password';
|
|
18
|
+
const EMAIL_PASSWORD_RESET = 'password_reset';
|
|
19
|
+
const EMAIL_MFA_OOB_CODE = 'mfa_oob_code';
|
|
20
|
+
const EMAIL_USER_INVITATION = 'user_invitation';
|
|
21
|
+
const UNIVERSAL_LOGIN_TEMPLATE = 'universal_login';
|
|
22
|
+
const constants = {
|
|
23
|
+
CONCURRENT_CALLS: 5,
|
|
24
|
+
RULES_DIRECTORY: 'rules',
|
|
25
|
+
RULES_STAGES,
|
|
26
|
+
DEFAULT_RULE_STAGE: RULES_STAGES[0],
|
|
27
|
+
HOOKS_HIDDEN_SECRET_VALUE: '_VALUE_NOT_SHOWN_',
|
|
28
|
+
HOOKS_DIRECTORY: 'hooks',
|
|
29
|
+
ACTIONS_DIRECTORY: 'actions',
|
|
30
|
+
TRIGGERS_DIRECTORY: 'triggers',
|
|
31
|
+
RULES_CONFIGS_DIRECTORY: 'rules-configs',
|
|
32
|
+
PAGES_DIRECTORY: 'pages',
|
|
33
|
+
PAGE_LOGIN,
|
|
34
|
+
PAGE_GUARDIAN_MULTIFACTOR,
|
|
35
|
+
PAGE_PASSWORD_RESET,
|
|
36
|
+
PAGE_ERROR,
|
|
37
|
+
DATABASE_CONNECTIONS_DIRECTORY: 'database-connections',
|
|
38
|
+
DATABASE_SCRIPTS_CHANGE_EMAIL,
|
|
39
|
+
DATABASE_SCRIPTS_GET_USER,
|
|
40
|
+
EMAIL_TEMPLATES_TYPES: [
|
|
41
|
+
'verify_email',
|
|
42
|
+
'verify_email_by_code',
|
|
43
|
+
'reset_email',
|
|
44
|
+
'welcome_email',
|
|
45
|
+
'blocked_account',
|
|
46
|
+
'stolen_credentials',
|
|
47
|
+
'enrollment_email',
|
|
48
|
+
'mfa_oob_code',
|
|
49
|
+
'change_password',
|
|
50
|
+
'password_reset',
|
|
51
|
+
'user_invitation',
|
|
52
|
+
],
|
|
53
|
+
ACTIONS_TRIGGERS: [
|
|
54
|
+
'post-login',
|
|
55
|
+
'credentials-exchange',
|
|
56
|
+
'pre-user-registration',
|
|
57
|
+
'post-user-registration',
|
|
58
|
+
'post-change-password',
|
|
59
|
+
'send-phone-message',
|
|
60
|
+
],
|
|
61
|
+
EMAIL_TEMPLATES_DIRECTORY: 'emails',
|
|
62
|
+
EMAIL_VERIFY,
|
|
63
|
+
EMAIL_VERIFY_BY_CODE,
|
|
64
|
+
EMAIL_RESET,
|
|
65
|
+
EMAIL_WELCOME,
|
|
66
|
+
EMAIL_BLOCKED,
|
|
67
|
+
EMAIL_STOLEN_CREDENTIALS,
|
|
68
|
+
EMAIL_ENROLLMENT,
|
|
69
|
+
EMAIL_CHANGE_PASSWORD,
|
|
70
|
+
EMAIL_PASSWORD_RESET,
|
|
71
|
+
EMAIL_MFA_OOB_CODE,
|
|
72
|
+
EMAIL_USER_INVITATION,
|
|
73
|
+
GUARDIAN_DIRECTORY: 'guardian',
|
|
74
|
+
GUARDIAN_FACTORS_DIRECTORY: 'factors',
|
|
75
|
+
GUARDIAN_PROVIDERS_DIRECTORY: 'providers',
|
|
76
|
+
GUARDIAN_TEMPLATES_DIRECTORY: 'templates',
|
|
77
|
+
UNIVERSAL_LOGIN_TEMPLATE,
|
|
78
|
+
RESOURCE_SERVERS_DIRECTORY: 'resource-servers',
|
|
79
|
+
RESOURCE_SERVERS_CLIENT_NAME: 'resourceServers',
|
|
80
|
+
RESOURCE_SERVERS_MANAGEMENT_API_NAME: 'Auth0 Management API',
|
|
81
|
+
RESOURCE_SERVERS_ID_NAME: 'id',
|
|
82
|
+
CLIENTS_DIRECTORY: 'clients',
|
|
83
|
+
CLIENTS_GRANTS_DIRECTORY: 'grants',
|
|
84
|
+
BRANDING_DIRECTORY: 'branding',
|
|
85
|
+
BRANDING_TEMPLATES_DIRECTORY: 'templates',
|
|
86
|
+
BRANDING_TEMPLATES_YAML_DIRECTORY: 'branding_templates',
|
|
87
|
+
CLIENTS_CLIENT_NAME: 'clients',
|
|
88
|
+
CLIENTS_CLIENT_ID_NAME: 'client_id',
|
|
89
|
+
CONNECTIONS_DIRECTORY: 'connections',
|
|
90
|
+
CONNECTIONS_CLIENT_NAME: 'connections',
|
|
91
|
+
CONNECTIONS_ID_NAME: 'id',
|
|
92
|
+
ROLES_DIRECTORY: 'roles',
|
|
93
|
+
ATTACK_PROTECTION_DIRECTORY: 'attack-protection',
|
|
94
|
+
GUARDIAN_FACTORS: [
|
|
95
|
+
'sms',
|
|
96
|
+
'push-notification',
|
|
97
|
+
'otp',
|
|
98
|
+
'email',
|
|
99
|
+
'duo',
|
|
100
|
+
'webauthn-roaming',
|
|
101
|
+
'webauthn-platform',
|
|
102
|
+
'recovery-code',
|
|
103
|
+
],
|
|
104
|
+
GUARDIAN_POLICIES: ['all-applications', 'confidence-score'],
|
|
105
|
+
GUARDIAN_PHONE_PROVIDERS: ['auth0', 'twilio', 'phone-message-hook'],
|
|
106
|
+
GUARDIAN_PHONE_MESSAGE_TYPES: ['sms', 'voice'],
|
|
107
|
+
GUARDIAN_FACTOR_TEMPLATES: ['sms'],
|
|
108
|
+
GUARDIAN_FACTOR_PROVIDERS: {
|
|
109
|
+
sms: ['twilio'],
|
|
110
|
+
'push-notification': ['sns'],
|
|
111
|
+
},
|
|
112
|
+
PAGE_NAMES: [
|
|
113
|
+
`${PAGE_GUARDIAN_MULTIFACTOR}.html`,
|
|
114
|
+
`${PAGE_GUARDIAN_MULTIFACTOR}.json`,
|
|
115
|
+
`${PAGE_PASSWORD_RESET}.html`,
|
|
116
|
+
`${PAGE_PASSWORD_RESET}.json`,
|
|
117
|
+
`${PAGE_LOGIN}.html`,
|
|
118
|
+
`${PAGE_LOGIN}.json`,
|
|
119
|
+
`${PAGE_ERROR}.html`,
|
|
120
|
+
`${PAGE_ERROR}.json`,
|
|
121
|
+
],
|
|
122
|
+
DATABASE_SCRIPTS: [
|
|
123
|
+
DATABASE_SCRIPTS_GET_USER,
|
|
124
|
+
'create',
|
|
125
|
+
'verify',
|
|
126
|
+
'login',
|
|
127
|
+
'change_password',
|
|
128
|
+
'delete',
|
|
129
|
+
DATABASE_SCRIPTS_CHANGE_EMAIL,
|
|
130
|
+
],
|
|
131
|
+
DATABASE_SCRIPTS_NO_IMPORT: [
|
|
132
|
+
DATABASE_SCRIPTS_GET_USER,
|
|
133
|
+
'create',
|
|
134
|
+
'verify',
|
|
135
|
+
'login',
|
|
136
|
+
'change_password',
|
|
137
|
+
'delete',
|
|
138
|
+
],
|
|
139
|
+
DATABASE_SCRIPTS_IMPORT: [DATABASE_SCRIPTS_GET_USER, 'login'],
|
|
140
|
+
EMAIL_TEMPLATES_NAMES: [
|
|
141
|
+
`${EMAIL_VERIFY}.json`,
|
|
142
|
+
`${EMAIL_VERIFY}.html`,
|
|
143
|
+
`${EMAIL_VERIFY_BY_CODE}.json`,
|
|
144
|
+
`${EMAIL_VERIFY_BY_CODE}.html`,
|
|
145
|
+
`${EMAIL_RESET}.json`,
|
|
146
|
+
`${EMAIL_RESET}.html`,
|
|
147
|
+
`${EMAIL_WELCOME}.json`,
|
|
148
|
+
`${EMAIL_WELCOME}.html`,
|
|
149
|
+
`${EMAIL_BLOCKED}.json`,
|
|
150
|
+
`${EMAIL_BLOCKED}.html`,
|
|
151
|
+
`${EMAIL_STOLEN_CREDENTIALS}.json`,
|
|
152
|
+
`${EMAIL_STOLEN_CREDENTIALS}.html`,
|
|
153
|
+
`${EMAIL_ENROLLMENT}.json`,
|
|
154
|
+
`${EMAIL_ENROLLMENT}.html`,
|
|
155
|
+
`${EMAIL_CHANGE_PASSWORD}.json`,
|
|
156
|
+
`${EMAIL_CHANGE_PASSWORD}.html`,
|
|
157
|
+
`${EMAIL_PASSWORD_RESET}.json`,
|
|
158
|
+
`${EMAIL_PASSWORD_RESET}.html`,
|
|
159
|
+
`${EMAIL_MFA_OOB_CODE}.json`,
|
|
160
|
+
`${EMAIL_MFA_OOB_CODE}.html`,
|
|
161
|
+
`${EMAIL_USER_INVITATION}.json`,
|
|
162
|
+
`${EMAIL_USER_INVITATION}.html`,
|
|
163
|
+
],
|
|
164
|
+
SUPPORTED_BRANDING_TEMPLATES: [UNIVERSAL_LOGIN_TEMPLATE],
|
|
143
165
|
};
|
|
144
|
-
constants.RESOURCE_SERVERS_DIRECTORY = 'resource-servers';
|
|
145
|
-
constants.RESOURCE_SERVERS_CLIENT_NAME = 'resourceServers';
|
|
146
|
-
constants.RESOURCE_SERVERS_MANAGEMENT_API_NAME = 'Auth0 Management API';
|
|
147
|
-
constants.RESOURCE_SERVERS_ID_NAME = 'id';
|
|
148
|
-
constants.CLIENTS_DIRECTORY = 'clients';
|
|
149
|
-
constants.CLIENTS_GRANTS_DIRECTORY = 'grants';
|
|
150
|
-
constants.CLIENTS_CLIENT_NAME = 'clients';
|
|
151
|
-
constants.CLIENTS_CLIENT_ID_NAME = 'client_id';
|
|
152
|
-
constants.CONNECTIONS_DIRECTORY = 'connections';
|
|
153
|
-
constants.CONNECTIONS_CLIENT_NAME = 'connections';
|
|
154
|
-
constants.CONNECTIONS_ID_NAME = 'id';
|
|
155
|
-
constants.CONCURRENT_CALLS = 5;
|
|
156
|
-
constants.ROLES_DIRECTORY = 'roles';
|
|
157
|
-
constants.ATTACK_PROTECTION_DIRECTORY = 'attack-protection';
|
|
158
166
|
exports.default = constants;
|
package/lib/tools/deploy.js
CHANGED
package/lib/tools/index.js
CHANGED
package/lib/tools/logger.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const winston_1 = __importDefault(require("winston"));
|
|
7
|
+
//@ts-ignore because emitErrs is still supported
|
|
8
|
+
winston_1.default.emitErrs = true;
|
|
9
|
+
const logger = new winston_1.default.Logger({
|
|
4
10
|
transports: [
|
|
5
|
-
new
|
|
11
|
+
new winston_1.default.transports.Console({
|
|
6
12
|
timestamp: true,
|
|
7
13
|
level: 'info',
|
|
8
14
|
handleExceptions: true,
|
|
9
15
|
json: false,
|
|
10
|
-
colorize: true
|
|
11
|
-
})
|
|
16
|
+
colorize: true,
|
|
17
|
+
}),
|
|
12
18
|
],
|
|
13
|
-
exitOnError: false
|
|
19
|
+
exitOnError: false,
|
|
14
20
|
});
|
|
15
|
-
|
|
21
|
+
exports.default = logger;
|
package/lib/tools/utils.js
CHANGED
|
@@ -1,11 +1,34 @@
|
|
|
1
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 __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.areArraysEquals = exports.filterExcluded = exports.duplicateItems = exports.getEnabledClients = exports.stripFields = exports.
|
|
29
|
+
exports.areArraysEquals = exports.filterExcluded = exports.duplicateItems = exports.getEnabledClients = exports.stripFields = exports.convertJsonToString = exports.flatten = exports.loadFileAndReplaceKeywords = exports.convertClientNamesToIds = exports.convertClientNameToId = exports.keywordReplace = exports.keywordStringReplace = exports.keywordArrayReplace = void 0;
|
|
7
30
|
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const fs_1 =
|
|
31
|
+
const fs_1 = __importStar(require("fs"));
|
|
9
32
|
const dot_prop_1 = __importDefault(require("dot-prop"));
|
|
10
33
|
const lodash_1 = __importDefault(require("lodash"));
|
|
11
34
|
const logger_1 = __importDefault(require("./logger"));
|
|
@@ -23,6 +46,7 @@ exports.keywordArrayReplace = keywordArrayReplace;
|
|
|
23
46
|
function keywordStringReplace(input, mappings) {
|
|
24
47
|
Object.keys(mappings).forEach(function (key) {
|
|
25
48
|
const regex = new RegExp(`##${key}##`, 'g');
|
|
49
|
+
// @ts-ignore TODO: come back and distinguish strings vs array replacement.
|
|
26
50
|
input = input.replace(regex, mappings[key]);
|
|
27
51
|
});
|
|
28
52
|
return input;
|
|
@@ -48,11 +72,12 @@ function convertClientNamesToIds(names, clients) {
|
|
|
48
72
|
if (names.includes(client.name)) {
|
|
49
73
|
const index = resolvedNames.findIndex((item) => item.name === client.name);
|
|
50
74
|
resolvedNames[index].resolved = true;
|
|
51
|
-
acc
|
|
75
|
+
return [...acc, client.client_id];
|
|
52
76
|
}
|
|
53
|
-
return acc;
|
|
77
|
+
return [...acc];
|
|
54
78
|
}, []);
|
|
55
79
|
const unresolved = resolvedNames.filter((item) => !item.resolved).map((item) => item.name);
|
|
80
|
+
// @ts-ignore TODO: come back and refactor to use map instead of reduce.
|
|
56
81
|
return [...unresolved, ...result];
|
|
57
82
|
}
|
|
58
83
|
exports.convertClientNamesToIds = convertClientNamesToIds;
|
|
@@ -60,7 +85,7 @@ function loadFileAndReplaceKeywords(file, mappings) {
|
|
|
60
85
|
// Load file and replace keyword mappings
|
|
61
86
|
const f = path_1.default.resolve(file);
|
|
62
87
|
try {
|
|
63
|
-
fs_1.default.accessSync(f, fs_1.
|
|
88
|
+
fs_1.default.accessSync(f, fs_1.constants.F_OK);
|
|
64
89
|
if (mappings) {
|
|
65
90
|
return keywordReplace(fs_1.default.readFileSync(f, 'utf8'), mappings);
|
|
66
91
|
}
|
|
@@ -76,151 +101,10 @@ function flatten(list) {
|
|
|
76
101
|
return list.reduce((a, b) => a.concat(Array.isArray(b) ? flatten(b) : b), []);
|
|
77
102
|
}
|
|
78
103
|
exports.flatten = flatten;
|
|
79
|
-
function
|
|
104
|
+
function convertJsonToString(obj, spacing = 0) {
|
|
80
105
|
return JSON.stringify(obj, null, spacing);
|
|
81
106
|
}
|
|
82
|
-
exports.
|
|
83
|
-
/**
|
|
84
|
-
* @template T
|
|
85
|
-
* @param {typeof import('./auth0/handlers/default').default} handler
|
|
86
|
-
* @param {T} desiredAssetState
|
|
87
|
-
* @param {T} currentAssetState
|
|
88
|
-
* @param {string[]} [objectFields=[]]
|
|
89
|
-
* @param {boolean} [allowDelete=false]
|
|
90
|
-
* @returns T
|
|
91
|
-
*/
|
|
92
|
-
function processChangedObjectFields({ handler, desiredAssetState, currentAssetState, allowDelete = false }) {
|
|
93
|
-
const desiredAssetStateWithChanges = Object.assign({}, desiredAssetState);
|
|
94
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
95
|
-
for (const fieldName of handler.objectFields) {
|
|
96
|
-
const areDesiredStateAndCurrentStateEmpty = Object.keys(desiredAssetState[fieldName] || {}).length === 0 && Object.keys(currentAssetState[fieldName] || {}).length === 0;
|
|
97
|
-
if (areDesiredStateAndCurrentStateEmpty) {
|
|
98
|
-
// If both the desired state and current state for a given object is empty, it is a no-op and can skip
|
|
99
|
-
// eslint-disable-next-line no-continue
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
// A desired state that omits the objectField OR that has it as an empty object should
|
|
103
|
-
// signal that all fields should be removed (subject to ALLOW_DELETE).
|
|
104
|
-
if (desiredAssetState[fieldName] && Object.keys(desiredAssetState[fieldName]).length) {
|
|
105
|
-
// Both the current and desired state have the object field. Here's where we need to map
|
|
106
|
-
// to the APIv2 protocol of setting `null` values for deleted fields.
|
|
107
|
-
// For new and modified properties of the object field, we can just pass them through to
|
|
108
|
-
// APIv2.
|
|
109
|
-
if (currentAssetState[fieldName]) {
|
|
110
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
111
|
-
for (const currentObjectFieldPropertyName of Object.keys(currentAssetState[fieldName])) {
|
|
112
|
-
// Loop through each object property that exists currently
|
|
113
|
-
if (desiredAssetState[fieldName][currentObjectFieldPropertyName] === undefined) {
|
|
114
|
-
// If the object has a property that exists now but doesn't exist in the proposed state
|
|
115
|
-
if (allowDelete) {
|
|
116
|
-
desiredAssetStateWithChanges[fieldName][currentObjectFieldPropertyName] = null;
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
// If deletes aren't allowed, do outright delete the property within the object
|
|
120
|
-
logger_1.default.warn(`Detected that the ${fieldName} of the following ${handler.name || handler.id || ''} should be deleted. Doing so may be destructive.\nYou can enable deletes by setting 'AUTH0_ALLOW_DELETE' to true in the config\n${handler.objString(currentAssetState)}`);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
else if (allowDelete) {
|
|
127
|
-
// If the desired state does not have the object field and the current state does, we
|
|
128
|
-
// should mark *all* properties for deletion by specifying an empty object.
|
|
129
|
-
//
|
|
130
|
-
// See: https://auth0.com/docs/users/metadata/manage-metadata-api#delete-user-metadata
|
|
131
|
-
desiredAssetStateWithChanges[fieldName] = {};
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
delete desiredAssetStateWithChanges[fieldName];
|
|
135
|
-
logger_1.default.warn(`Detected that the ${fieldName} of the following ${handler.name || handler.id || ''} should be emptied. Doing so may be destructive.\nYou can enable deletes by setting 'AUTH0_ALLOW_DELETE' to true in the config\n${handler.objString(currentAssetState)}`);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return desiredAssetStateWithChanges;
|
|
139
|
-
}
|
|
140
|
-
exports.processChangedObjectFields = processChangedObjectFields;
|
|
141
|
-
function calcChanges(handler, assets, existing, identifiers = ['id', 'name'], allowDelete = false) {
|
|
142
|
-
// Calculate the changes required between two sets of assets.
|
|
143
|
-
const update = [];
|
|
144
|
-
let del = [...existing];
|
|
145
|
-
let create = [...assets];
|
|
146
|
-
const conflicts = [];
|
|
147
|
-
const findByKeyValue = (key, value, arr) => arr.find((e) => {
|
|
148
|
-
if (Array.isArray(key)) {
|
|
149
|
-
const values = key.map((k) => e[k]);
|
|
150
|
-
if (values.every((v) => v)) {
|
|
151
|
-
return value === values.join('-');
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
return e[key] === value;
|
|
156
|
-
}
|
|
157
|
-
return false;
|
|
158
|
-
});
|
|
159
|
-
const processAssets = (id, arr) => {
|
|
160
|
-
arr.forEach((asset) => {
|
|
161
|
-
let assetIdValue;
|
|
162
|
-
if (Array.isArray(id)) {
|
|
163
|
-
const values = id.map((i) => asset[i]);
|
|
164
|
-
if (values.every((v) => v)) {
|
|
165
|
-
assetIdValue = values.join('-');
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
assetIdValue = asset[id];
|
|
170
|
-
}
|
|
171
|
-
if (assetIdValue) {
|
|
172
|
-
const found = findByKeyValue(id, assetIdValue, del);
|
|
173
|
-
if (found) {
|
|
174
|
-
// Delete from existing
|
|
175
|
-
del = del.filter((e) => e !== found);
|
|
176
|
-
// Delete from create as it's an update
|
|
177
|
-
create = create.filter((e) => e !== asset);
|
|
178
|
-
// Append identifiers to asset
|
|
179
|
-
update.push(Object.assign(Object.assign({}, identifiers.reduce((obj, i) => {
|
|
180
|
-
if (found[i])
|
|
181
|
-
obj[i] = found[i];
|
|
182
|
-
return obj;
|
|
183
|
-
}, {})), (handler.objectFields.length
|
|
184
|
-
? processChangedObjectFields({
|
|
185
|
-
handler, desiredAssetState: asset, currentAssetState: found, allowDelete
|
|
186
|
-
})
|
|
187
|
-
: asset)));
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
};
|
|
192
|
-
// Loop through identifiers (in order) to try match assets to existing
|
|
193
|
-
// If existing then update if not create
|
|
194
|
-
// The remainder will be deleted
|
|
195
|
-
for (const id of identifiers) { // eslint-disable-line
|
|
196
|
-
processAssets(id, [...create]);
|
|
197
|
-
}
|
|
198
|
-
// Check if there are assets with names that will conflict with existing names during the update process
|
|
199
|
-
// This will rename those assets to a temp random name first
|
|
200
|
-
// This assumes the first identifiers is the unique identifier
|
|
201
|
-
if (identifiers.includes('name')) {
|
|
202
|
-
const uniqueID = identifiers[0];
|
|
203
|
-
const futureAssets = [...create, ...update];
|
|
204
|
-
futureAssets.forEach((a) => {
|
|
205
|
-
// If the conflicting item is going to be deleted then skip
|
|
206
|
-
const inDeleted = del.filter((e) => e.name === a.name && e[uniqueID] !== a[uniqueID])[0];
|
|
207
|
-
if (!inDeleted) {
|
|
208
|
-
const conflict = existing.filter((e) => e.name === a.name && e[uniqueID] !== a[uniqueID])[0];
|
|
209
|
-
if (conflict) {
|
|
210
|
-
const temp = Math.random().toString(36).substr(2, 5);
|
|
211
|
-
conflicts.push(Object.assign(Object.assign({}, conflict), { name: `${conflict.name}-${temp}` }));
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
return {
|
|
217
|
-
del,
|
|
218
|
-
update,
|
|
219
|
-
conflicts,
|
|
220
|
-
create
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
exports.calcChanges = calcChanges;
|
|
107
|
+
exports.convertJsonToString = convertJsonToString;
|
|
224
108
|
function stripFields(obj, fields) {
|
|
225
109
|
// Strip object fields supporting dot notation (ie: a.deep.field)
|
|
226
110
|
const stripped = [];
|
|
@@ -243,7 +127,7 @@ function getEnabledClients(assets, connection, existing, clients) {
|
|
|
243
127
|
const excludedClientsByNames = (assets.exclude && assets.exclude.clients) || [];
|
|
244
128
|
const excludedClients = convertClientNamesToIds(excludedClientsByNames, clients);
|
|
245
129
|
const enabledClients = [
|
|
246
|
-
...convertClientNamesToIds(connection.enabled_clients || [], clients).filter((item) => ![...excludedClientsByNames, ...excludedClients].includes(item))
|
|
130
|
+
...convertClientNamesToIds(connection.enabled_clients || [], clients).filter((item) => ![...excludedClientsByNames, ...excludedClients].includes(item)),
|
|
247
131
|
];
|
|
248
132
|
// If client is excluded and in the existing connection this client is enabled, it should keep enabled
|
|
249
133
|
// If client is excluded and in the existing connection this client is disabled, it should keep disabled
|
|
@@ -283,7 +167,7 @@ function filterExcluded(changes, exclude) {
|
|
|
283
167
|
del: filter(del),
|
|
284
168
|
update: filter(update),
|
|
285
169
|
create: filter(create),
|
|
286
|
-
conflicts: filter(conflicts)
|
|
170
|
+
conflicts: filter(conflicts),
|
|
287
171
|
};
|
|
288
172
|
}
|
|
289
173
|
exports.filterExcluded = filterExcluded;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
3
|
function ValidationError(message) {
|
|
2
4
|
Error.call(this, message);
|
|
3
5
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -9,4 +11,4 @@ function ValidationError(message) {
|
|
|
9
11
|
}
|
|
10
12
|
ValidationError.prototype = Object.create(Error.prototype);
|
|
11
13
|
ValidationError.prototype.constructor = ValidationError;
|
|
12
|
-
|
|
14
|
+
exports.default = ValidationError;
|
package/lib/types.js
ADDED