@budibase/worker 3.23.1 → 3.23.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/worker",
3
3
  "email": "hi@budibase.com",
4
- "version": "3.23.1",
4
+ "version": "3.23.2",
5
5
  "description": "Budibase background service",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -109,5 +109,5 @@
109
109
  }
110
110
  }
111
111
  },
112
- "gitHead": "ade970d3ee9b56413873984aefa4b39297002204"
112
+ "gitHead": "938751f16b9c7ada6baba3dd5525b3cd6256a604"
113
113
  }
@@ -16,6 +16,7 @@ import {
16
16
  ConfigChecklistResponse,
17
17
  ConfigType,
18
18
  Ctx,
19
+ IMAPInnerConfig,
19
20
  DeleteConfigResponse,
20
21
  FindConfigResponse,
21
22
  GetPublicOIDCConfigResponse,
@@ -23,6 +24,7 @@ import {
23
24
  GoogleInnerConfig,
24
25
  isAIConfig,
25
26
  isGoogleConfig,
27
+ isIMAPConfig,
26
28
  isOIDCConfig,
27
29
  isRecaptchaConfig,
28
30
  isSettingsConfig,
@@ -177,6 +179,19 @@ async function processSMTPConfig(
177
179
  }
178
180
  }
179
181
 
182
+ async function processIMAPConfig(
183
+ config: IMAPInnerConfig,
184
+ existingConfig?: IMAPInnerConfig
185
+ ) {
186
+ if (config.auth?.pass === PASSWORD_REPLACEMENT) {
187
+ if (existingConfig && existingConfig.auth?.pass) {
188
+ config.auth.pass = existingConfig.auth.pass
189
+ } else {
190
+ throw new BadRequestError("IMAP password is required")
191
+ }
192
+ }
193
+ }
194
+
180
195
  async function processSettingsConfig(
181
196
  config: SettingsInnerConfig & SettingsBrandingConfig,
182
197
  existingConfig?: SettingsInnerConfig & SettingsBrandingConfig
@@ -317,6 +332,9 @@ export async function save(
317
332
  case ConfigType.SMTP:
318
333
  await processSMTPConfig(config, existingConfig?.config)
319
334
  break
335
+ case ConfigType.IMAP:
336
+ await processIMAPConfig(config, existingConfig?.config)
337
+ break
320
338
  case ConfigType.SETTINGS:
321
339
  await processSettingsConfig(config, existingConfig?.config)
322
340
  break
@@ -450,6 +468,10 @@ function stripSecrets(config: Config) {
450
468
  if (config.config.auth?.pass) {
451
469
  config.config.auth.pass = PASSWORD_REPLACEMENT
452
470
  }
471
+ } else if (isIMAPConfig(config)) {
472
+ if (config.config.auth?.pass) {
473
+ config.config.auth.pass = PASSWORD_REPLACEMENT
474
+ }
453
475
  } else if (isGoogleConfig(config)) {
454
476
  config.config.clientSecret = PASSWORD_REPLACEMENT
455
477
  } else if (isOIDCConfig(config)) {
@@ -19,6 +19,21 @@ function smtpValidation() {
19
19
  }).unknown(true)
20
20
  }
21
21
 
22
+ function imapValidation() {
23
+ // prettier-ignore
24
+ return Joi.object({
25
+ port: Joi.number().required(),
26
+ host: Joi.string().required(),
27
+ secure: Joi.boolean().optional(),
28
+ mailbox: Joi.string().optional(),
29
+ auth: Joi.object({
30
+ type: Joi.string().valid("login", null),
31
+ user: Joi.string().required(),
32
+ pass: Joi.string().allow("", null),
33
+ }).optional(),
34
+ }).unknown(true)
35
+ }
36
+
22
37
  function settingValidation() {
23
38
  // prettier-ignore
24
39
  return Joi.object({
@@ -100,6 +115,7 @@ function buildConfigSaveValidation() {
100
115
  .conditional("type", {
101
116
  switch: [
102
117
  { is: ConfigType.SMTP, then: smtpValidation() },
118
+ { is: ConfigType.IMAP, then: imapValidation() },
103
119
  { is: ConfigType.SETTINGS, then: settingValidation() },
104
120
  { is: ConfigType.ACCOUNT, then: Joi.object().unknown(true) },
105
121
  { is: ConfigType.GOOGLE, then: googleValidation() },