emailengine-app 2.76.0 → 2.78.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/.github/workflows/release.yaml +24 -19
  2. package/.github/workflows/test.yml +80 -0
  3. package/.ncurc.js +14 -2
  4. package/.release-please-manifest.json +3 -0
  5. package/CHANGELOG.md +54 -0
  6. package/README.md +1 -1
  7. package/bin/emailengine.js +1 -1
  8. package/data/google-crawlers.json +1 -1
  9. package/encrypt.js +72 -5
  10. package/lib/account/expected-identity.js +88 -0
  11. package/lib/account.js +75 -26
  12. package/lib/address-strategies.js +18 -0
  13. package/lib/api-reference/code-samples.js +194 -0
  14. package/lib/api-reference/format.js +193 -0
  15. package/lib/api-reference/index.js +222 -0
  16. package/lib/api-reference/model.js +338 -0
  17. package/lib/api-reference/schema-tree.js +366 -0
  18. package/lib/api-routes/account-routes.js +136 -39
  19. package/lib/api-routes/behavior-notes.js +57 -0
  20. package/lib/api-routes/blocklist-routes.js +9 -9
  21. package/lib/api-routes/changes-routes.js +6 -4
  22. package/lib/api-routes/chat-routes.js +3 -3
  23. package/lib/api-routes/delivery-test-routes.js +24 -6
  24. package/lib/api-routes/export-routes.js +14 -12
  25. package/lib/api-routes/gateway-routes.js +11 -11
  26. package/lib/api-routes/license-routes.js +7 -7
  27. package/lib/api-routes/mailbox-routes.js +18 -9
  28. package/lib/api-routes/message-routes.js +55 -35
  29. package/lib/api-routes/oauth2-app-routes.js +22 -16
  30. package/lib/api-routes/outbox-routes.js +7 -7
  31. package/lib/api-routes/pubsub-routes.js +3 -3
  32. package/lib/api-routes/settings-routes.js +10 -9
  33. package/lib/api-routes/stats-routes.js +3 -3
  34. package/lib/api-routes/submit-routes.js +58 -8
  35. package/lib/api-routes/template-routes.js +13 -13
  36. package/lib/api-routes/token-routes.js +15 -10
  37. package/lib/api-routes/webhook-route-routes.js +5 -5
  38. package/lib/append-list.js +3 -14
  39. package/lib/arf-detect.js +23 -1
  40. package/lib/autodetect-imap-settings.js +40 -16
  41. package/lib/base32.js +30 -0
  42. package/lib/bounce-detect.js +182 -62
  43. package/lib/consts.js +7 -0
  44. package/lib/egress-filter.js +89 -8
  45. package/lib/email-client/base-client.js +72 -82
  46. package/lib/email-client/gmail-client.js +3 -3
  47. package/lib/email-client/imap/listing-diff.js +3 -3
  48. package/lib/email-client/imap/mailbox.js +5 -69
  49. package/lib/email-client/imap-client.js +3 -2
  50. package/lib/email-client/message-builder.js +13 -13
  51. package/lib/email-client/outlook-client.js +1 -1
  52. package/lib/enum-descriptions.js +130 -0
  53. package/lib/export.js +1 -1
  54. package/lib/gateway.js +1 -1
  55. package/lib/get-raw-email.js +1 -1
  56. package/lib/imapproxy/imap-core/lib/imap-connection.js +2 -2
  57. package/lib/imapproxy/imap-core/lib/imap-server.js +2 -2
  58. package/lib/imapproxy/imap-server.js +42 -28
  59. package/lib/imapproxy/upstream-client.js +38 -0
  60. package/lib/license-beacon.js +1 -1
  61. package/lib/llm-pre-process.js +1 -1
  62. package/lib/msgpack.js +62 -0
  63. package/lib/oauth/decode-jwt-payload.js +39 -0
  64. package/lib/oauth/outlook-identity.js +61 -0
  65. package/lib/oauth/retry-setup.js +38 -0
  66. package/lib/oauth2-apps.js +10 -4
  67. package/lib/openapi/build-document.js +318 -0
  68. package/lib/openapi/index.js +95 -0
  69. package/lib/openapi/joi-schema.js +523 -0
  70. package/lib/outbox.js +66 -3
  71. package/lib/pre-process.js +1 -1
  72. package/lib/read-env-value.js +37 -0
  73. package/lib/routes-ui.js +5 -1
  74. package/lib/schemas.js +88 -17
  75. package/lib/swagger-options.js +173 -0
  76. package/lib/templates.js +1 -1
  77. package/lib/tokens.js +70 -6
  78. package/lib/tools.js +117 -48
  79. package/lib/totp.js +67 -0
  80. package/lib/ui-routes/account-routes.js +91 -15
  81. package/lib/ui-routes/admin-config-routes.js +2 -7
  82. package/lib/ui-routes/admin-entities-routes.js +3 -0
  83. package/lib/ui-routes/auth-routes.js +6 -24
  84. package/lib/ui-routes/dashboard-routes.js +2 -26
  85. package/lib/ui-routes/reference-routes.js +198 -0
  86. package/lib/ui-routes/route-helpers.js +39 -0
  87. package/lib/utils/is-email.js +34 -0
  88. package/lib/utils/to-camel-case.js +17 -0
  89. package/lib/webhook-egress.js +37 -0
  90. package/lib/webhooks.js +1 -1
  91. package/package.json +27 -31
  92. package/prepare-bundle-deps.sh +28 -0
  93. package/release-please-config.json +11 -0
  94. package/sbom.json +1 -1
  95. package/server.js +11 -3
  96. package/static/css/flyonui.css +1 -1
  97. package/static/css/public.css +3 -0
  98. package/static/css/src/app.tailwind.css +113 -0
  99. package/static/js/app.js +69 -0
  100. package/static/js/ee-client.js +238 -8
  101. package/static/js/reference.js +1021 -0
  102. package/static/js/ui.js +61 -33
  103. package/static/licenses.html +658 -1560
  104. package/translations/README.md +64 -0
  105. package/translations/de.mo +0 -0
  106. package/translations/de.po +164 -120
  107. package/translations/en.po +200 -161
  108. package/translations/et.mo +0 -0
  109. package/translations/et.po +163 -120
  110. package/translations/fr.mo +0 -0
  111. package/translations/fr.po +163 -120
  112. package/translations/ja.mo +0 -0
  113. package/translations/ja.po +163 -120
  114. package/translations/messages.pot +84 -54
  115. package/translations/nl.mo +0 -0
  116. package/translations/nl.po +164 -120
  117. package/translations/pl.mo +0 -0
  118. package/translations/pl.po +163 -120
  119. package/views/account-identity-error.hbs +34 -0
  120. package/views/accounts/edit.hbs +1 -0
  121. package/views/accounts/register/imap.hbs +12 -2
  122. package/views/config/ai.hbs +1 -1
  123. package/views/config/document-store/chat.hbs +5 -5
  124. package/views/config/document-store/index.hbs +2 -2
  125. package/views/config/document-store/pre-processing/index.hbs +1 -1
  126. package/views/config/email-processing.hbs +1 -1
  127. package/views/config/imap-proxy.hbs +1 -1
  128. package/views/config/license.hbs +1 -1
  129. package/views/config/oauth/index.hbs +3 -3
  130. package/views/config/security.hbs +1 -1
  131. package/views/config/smtp.hbs +2 -2
  132. package/views/dashboard.hbs +1 -1
  133. package/views/layout/app.hbs +43 -8
  134. package/views/oauth-scope-error.hbs +1 -1
  135. package/views/partials/oauth_form.hbs +4 -4
  136. package/views/partials/reference/anchor-link.hbs +20 -0
  137. package/views/partials/reference/disclosure.hbs +37 -0
  138. package/views/partials/reference/nav.hbs +120 -0
  139. package/views/partials/reference/operation.hbs +127 -0
  140. package/views/partials/reference/params.hbs +20 -0
  141. package/views/partials/reference/schema-node.hbs +99 -0
  142. package/views/partials/reference/schema.hbs +19 -0
  143. package/views/partials/reference/section-heading.hbs +16 -0
  144. package/views/partials/reference/token-alert.hbs +49 -0
  145. package/views/partials/reference/try-field.hbs +31 -0
  146. package/views/partials/reference/try-it.hbs +78 -0
  147. package/views/partials/side_menu.hbs +1 -1
  148. package/views/partials/ui/badge.hbs +4 -2
  149. package/views/partials/ui/page-header.hbs +1 -1
  150. package/views/partials/ui/search-input.hbs +31 -0
  151. package/views/partials/ui/setting-ref.hbs +1 -1
  152. package/views/partials/ui/stat-card.hbs +4 -2
  153. package/views/partials/ui/tab.hbs +6 -1
  154. package/views/partials/ui/tabs.hbs +2 -2
  155. package/views/reference/index.hbs +76 -0
  156. package/views/reference/redirect.hbs +49 -0
  157. package/views/reference/tag.hbs +28 -0
  158. package/views/reference/token.hbs +49 -0
  159. package/views/tokens/index.hbs +9 -1
  160. package/views/webhooks/index.hbs +3 -3
  161. package/workers/api.js +194 -302
  162. package/workers/imap.js +1 -1
  163. package/workers/submit.js +1 -1
  164. package/workers/webhooks.js +2 -13
  165. package/views/swagger/index.hbs +0 -82
@@ -5,10 +5,11 @@ const { Export } = require('../export');
5
5
  const Boom = require('@hapi/boom');
6
6
  const Joi = require('joi');
7
7
  const { failAction } = require('../tools');
8
- const { accountIdSchema, exportRequestSchema, exportStatusSchema, exportListSchema, exportIdSchema, errorResponses } = require('../schemas');
8
+ const { accountIdSchema, exportRequestSchema, exportStatusSchema, exportListSchema, exportIdSchema, apiResponses } = require('../schemas');
9
9
  const getSecret = require('../get-secret');
10
10
  const { createDecryptStream } = require('../stream-encrypt');
11
11
  const { handleError } = require('./route-helpers');
12
+ const BEHAVIOR = require('./behavior-notes');
12
13
 
13
14
  async function init(args) {
14
15
  const { server, CORS_CONFIG } = args;
@@ -34,12 +35,13 @@ async function init(args) {
34
35
 
35
36
  options: {
36
37
  description: 'Create export',
37
- notes: 'Creates a new bulk message export job. The export runs asynchronously and notifies via webhook when complete.',
38
+ notes: ['Creates a new bulk message export job. The export runs asynchronously and notifies via webhook when complete.', BEHAVIOR.BACKGROUND_JOB],
38
39
  tags: ['api', 'Export (Beta)'],
39
40
 
40
41
  plugins: {
41
- 'hapi-swagger': {
42
- responses: errorResponses(400, 401, 403, 404, 429, 500)
42
+ openapi: {
43
+ 'x-ee-behavior': [BEHAVIOR.BACKGROUND_JOB],
44
+ responses: apiResponses('Returns the ID of the started export. Poll the status endpoint until it completes.', 400, 401, 403, 404, 429, 500)
43
45
  }
44
46
  },
45
47
 
@@ -97,8 +99,8 @@ async function init(args) {
97
99
  tags: ['api', 'Export (Beta)'],
98
100
 
99
101
  plugins: {
100
- 'hapi-swagger': {
101
- responses: errorResponses(400, 401, 403, 404, 429, 500)
102
+ openapi: {
103
+ responses: apiResponses('Returns the export progress, and the download size once it has completed.', 400, 401, 403, 404, 429, 500)
102
104
  }
103
105
  },
104
106
 
@@ -178,9 +180,9 @@ async function init(args) {
178
180
  tags: ['api', 'Export (Beta)'],
179
181
 
180
182
  plugins: {
181
- 'hapi-swagger': {
183
+ openapi: {
182
184
  produces: ['application/gzip'],
183
- responses: errorResponses(400, 401, 403, 404, 429, 500, 503)
185
+ responses: apiResponses('Returns the export archive as gzip-compressed NDJSON.', 400, 401, 403, 404, 429, 500, 503)
184
186
  }
185
187
  },
186
188
 
@@ -228,8 +230,8 @@ async function init(args) {
228
230
  tags: ['api', 'Export (Beta)'],
229
231
 
230
232
  plugins: {
231
- 'hapi-swagger': {
232
- responses: errorResponses(400, 401, 403, 404, 429, 500)
233
+ openapi: {
234
+ responses: apiResponses('Returns a deletion marker. Any partially written export file is removed.', 400, 401, 403, 404, 429, 500)
233
235
  }
234
236
  },
235
237
 
@@ -283,8 +285,8 @@ async function init(args) {
283
285
  tags: ['api', 'Export (Beta)'],
284
286
 
285
287
  plugins: {
286
- 'hapi-swagger': {
287
- responses: errorResponses(400, 401, 403, 429, 500)
288
+ openapi: {
289
+ responses: apiResponses('Returns the exports for the account with their progress.', 400, 401, 403, 429, 500)
288
290
  }
289
291
  },
290
292
 
@@ -6,7 +6,7 @@ const { Gateway } = require('../gateway');
6
6
  const getSecret = require('../get-secret');
7
7
  const { failAction } = require('../tools');
8
8
  const { handleError } = require('./route-helpers');
9
- const { errorResponses } = require('../schemas');
9
+ const { apiResponses } = require('../schemas');
10
10
 
11
11
  // Gateways store SMTP delivery errors, not OAuth2 errors, so the error shape differs from the
12
12
  // account-level lastErrorSchema
@@ -47,8 +47,8 @@ async function init(args) {
47
47
  tags: ['api', 'SMTP Gateway'],
48
48
 
49
49
  plugins: {
50
- 'hapi-swagger': {
51
- responses: errorResponses(400, 401, 403, 429, 500)
50
+ openapi: {
51
+ responses: apiResponses('Returns a page of configured SMTP gateways.', 400, 401, 403, 429, 500)
52
52
  }
53
53
  },
54
54
 
@@ -139,8 +139,8 @@ async function init(args) {
139
139
  tags: ['api', 'SMTP Gateway'],
140
140
 
141
141
  plugins: {
142
- 'hapi-swagger': {
143
- responses: errorResponses(400, 401, 403, 404, 429, 500)
142
+ openapi: {
143
+ responses: apiResponses('Returns the gateway configuration. The password is masked.', 400, 401, 403, 404, 429, 500)
144
144
  }
145
145
  },
146
146
 
@@ -228,8 +228,8 @@ async function init(args) {
228
228
  tags: ['api', 'SMTP Gateway'],
229
229
 
230
230
  plugins: {
231
- 'hapi-swagger': {
232
- responses: errorResponses(400, 401, 403, 429, 500)
231
+ openapi: {
232
+ responses: apiResponses('Returns the registered gateway.', 400, 401, 403, 429, 500)
233
233
  }
234
234
  },
235
235
 
@@ -309,8 +309,8 @@ async function init(args) {
309
309
  tags: ['api', 'SMTP Gateway'],
310
310
 
311
311
  plugins: {
312
- 'hapi-swagger': {
313
- responses: errorResponses(400, 401, 403, 404, 429, 500)
312
+ openapi: {
313
+ responses: apiResponses('Returns the updated gateway.', 400, 401, 403, 404, 429, 500)
314
314
  }
315
315
  },
316
316
 
@@ -389,8 +389,8 @@ async function init(args) {
389
389
  tags: ['api', 'SMTP Gateway'],
390
390
 
391
391
  plugins: {
392
- 'hapi-swagger': {
393
- responses: errorResponses(400, 401, 403, 404, 429, 500)
392
+ openapi: {
393
+ responses: apiResponses('Returns a deletion marker.', 400, 401, 403, 404, 429, 500)
394
394
  }
395
395
  },
396
396
 
@@ -3,7 +3,7 @@
3
3
  const Joi = require('joi');
4
4
  const { failAction } = require('../tools');
5
5
  const { handleError } = require('./route-helpers');
6
- const { licenseSchema, errorResponses } = require('../schemas');
6
+ const { licenseSchema, apiResponses } = require('../schemas');
7
7
 
8
8
  async function init(args) {
9
9
  const { server, call, CORS_CONFIG } = args;
@@ -31,8 +31,8 @@ async function init(args) {
31
31
  tags: ['api', 'License'],
32
32
 
33
33
  plugins: {
34
- 'hapi-swagger': {
35
- responses: errorResponses(401, 403, 429, 500)
34
+ openapi: {
35
+ responses: apiResponses('Returns the active license and its expiry, or an empty object when unlicensed.', 401, 403, 429, 500)
36
36
  }
37
37
  },
38
38
 
@@ -72,8 +72,8 @@ async function init(args) {
72
72
  tags: ['api', 'License'],
73
73
 
74
74
  plugins: {
75
- 'hapi-swagger': {
76
- responses: errorResponses(401, 403, 429, 500)
75
+ openapi: {
76
+ responses: apiResponses('Returns an empty license object. EmailEngine drops to limited mode.', 401, 403, 429, 500)
77
77
  }
78
78
  },
79
79
 
@@ -117,8 +117,8 @@ async function init(args) {
117
117
  tags: ['api', 'License'],
118
118
 
119
119
  plugins: {
120
- 'hapi-swagger': {
121
- responses: errorResponses(400, 401, 403, 429, 500)
120
+ openapi: {
121
+ responses: apiResponses('Returns the registered license.', 400, 401, 403, 429, 500)
122
122
  }
123
123
  },
124
124
 
@@ -7,7 +7,7 @@ const { Account } = require('../account');
7
7
  const getSecret = require('../get-secret');
8
8
  const { failAction } = require('../tools');
9
9
  const { handleError } = require('./route-helpers');
10
- const { accountIdSchema, mailboxesSchema, errorResponses } = require('../schemas');
10
+ const { accountIdSchema, mailboxesSchema, apiResponses } = require('../schemas');
11
11
 
12
12
  async function init(args) {
13
13
  const { server, call, CORS_CONFIG, FLAG_SORT_ORDER } = args;
@@ -56,8 +56,17 @@ async function init(args) {
56
56
  tags: ['api', 'Mailbox'],
57
57
 
58
58
  plugins: {
59
- 'hapi-swagger': {
60
- responses: errorResponses(400, 401, 403, 404, 429, 500, 503)
59
+ openapi: {
60
+ responses: apiResponses(
61
+ 'Returns the account folder tree, including special-use designations and message counts.',
62
+ 400,
63
+ 401,
64
+ 403,
65
+ 404,
66
+ 429,
67
+ 500,
68
+ 503
69
+ )
61
70
  }
62
71
  },
63
72
 
@@ -135,8 +144,8 @@ async function init(args) {
135
144
  tags: ['api', 'Mailbox'],
136
145
 
137
146
  plugins: {
138
- 'hapi-swagger': {
139
- responses: errorResponses(400, 401, 403, 404, 429, 500, 503)
147
+ openapi: {
148
+ responses: apiResponses('Returns the created folder and its path.', 400, 401, 403, 404, 429, 500, 503)
140
149
  }
141
150
  },
142
151
 
@@ -216,8 +225,8 @@ async function init(args) {
216
225
  tags: ['api', 'Mailbox'],
217
226
 
218
227
  plugins: {
219
- 'hapi-swagger': {
220
- responses: errorResponses(400, 401, 403, 404, 429, 500, 503)
228
+ openapi: {
229
+ responses: apiResponses('Returns the renamed folder with its old and new paths.', 400, 401, 403, 404, 429, 500, 503)
221
230
  }
222
231
  },
223
232
 
@@ -298,8 +307,8 @@ async function init(args) {
298
307
  tags: ['api', 'Mailbox'],
299
308
 
300
309
  plugins: {
301
- 'hapi-swagger': {
302
- responses: errorResponses(400, 401, 403, 404, 429, 500, 503)
310
+ openapi: {
311
+ responses: apiResponses('Returns the deleted folder path.', 400, 401, 403, 404, 429, 500, 503)
303
312
  }
304
313
  },
305
314
 
@@ -8,6 +8,7 @@ const Joi = require('joi');
8
8
  const { failAction } = require('../tools');
9
9
  const { COLLAPSE_CLASS } = require('../consts');
10
10
  const { handleError } = require('./route-helpers');
11
+ const BEHAVIOR = require('./behavior-notes');
11
12
 
12
13
  const {
13
14
  accountIdSchema,
@@ -23,7 +24,8 @@ const {
23
24
  messageReferenceSchema,
24
25
  emailIdSchema,
25
26
  threadIdSchema,
26
- errorResponses
27
+ apiResponses,
28
+ ENUM_DESCRIPTIONS
27
29
  } = require('../schemas');
28
30
 
29
31
  const listMessageFolderPathDescription =
@@ -82,9 +84,9 @@ async function init(args) {
82
84
  cors: CORS_CONFIG,
83
85
 
84
86
  plugins: {
85
- 'hapi-swagger': {
87
+ openapi: {
86
88
  produces: ['message/rfc822'],
87
- responses: errorResponses(400, 401, 403, 404, 429, 500, 503)
89
+ responses: apiResponses('Returns the raw RFC822 message source.', 400, 401, 403, 404, 429, 500, 503)
88
90
  }
89
91
  },
90
92
 
@@ -131,8 +133,17 @@ async function init(args) {
131
133
  tags: ['api', 'Message'],
132
134
 
133
135
  plugins: {
134
- 'hapi-swagger': {
135
- responses: errorResponses(400, 401, 403, 404, 429, 500, 503)
136
+ openapi: {
137
+ responses: apiResponses(
138
+ 'Returns the message envelope and structure. Text content is only included when requested.',
139
+ 400,
140
+ 401,
141
+ 403,
142
+ 404,
143
+ 429,
144
+ 500,
145
+ 503
146
+ )
136
147
  }
137
148
  },
138
149
 
@@ -238,12 +249,13 @@ async function init(args) {
238
249
  },
239
250
 
240
251
  description: 'Upload message',
241
- notes: 'Upload a message structure, compile it into an EML file and store it into selected mailbox.',
252
+ notes: ['Upload a message structure, compile it into an EML file and store it into selected mailbox.', BEHAVIOR.UPLOAD_DRAFTS_ONLY_GRAPH],
242
253
  tags: ['api', 'Message'],
243
254
 
244
255
  plugins: {
245
- 'hapi-swagger': {
246
- responses: errorResponses(400, 401, 403, 404, 429, 500, 503)
256
+ openapi: {
257
+ 'x-ee-behavior': [BEHAVIOR.UPLOAD_DRAFTS_ONLY_GRAPH],
258
+ responses: apiResponses('Returns the uploaded message with the identifiers the provider assigned to it.', 400, 401, 403, 404, 429, 500, 503)
247
259
  }
248
260
  },
249
261
 
@@ -322,7 +334,11 @@ async function init(args) {
322
334
  }),
323
335
 
324
336
  contentType: Joi.string().lowercase().max(256).example('image/gif'),
325
- contentDisposition: Joi.string().lowercase().valid('inline', 'attachment').label('MsgUploadContentDisposition'),
337
+ contentDisposition: Joi.string()
338
+ .lowercase()
339
+ .valid('inline', 'attachment')
340
+ .meta({ enumDescriptions: ENUM_DESCRIPTIONS.messageUploadDisposition })
341
+ .label('MsgUploadContentDisposition'),
326
342
  cid: Joi.string().max(256).example('unique-image-id@localhost').description('Content-ID value for embedded images'),
327
343
  encoding: Joi.string().valid('base64').default('base64').label('MsgUploadEncoding'),
328
344
 
@@ -408,12 +424,13 @@ async function init(args) {
408
424
  },
409
425
  options: {
410
426
  description: 'Update message',
411
- notes: 'Update message information. Mainly this means changing message flag values',
427
+ notes: ['Update message information. Mainly this means changing message flag values', BEHAVIOR.NO_LABEL_SET_ON_GMAIL],
412
428
  tags: ['api', 'Message'],
413
429
 
414
430
  plugins: {
415
- 'hapi-swagger': {
416
- responses: errorResponses(400, 401, 403, 404, 429, 500, 503)
431
+ openapi: {
432
+ 'x-ee-behavior': [BEHAVIOR.NO_LABEL_SET_ON_GMAIL],
433
+ responses: apiResponses('Returns which flag and label changes were applied.', 400, 401, 403, 404, 429, 500, 503)
417
434
  }
418
435
  },
419
436
 
@@ -488,12 +505,13 @@ async function init(args) {
488
505
  },
489
506
  options: {
490
507
  description: 'Update messages',
491
- notes: 'Update message information for matching emails',
508
+ notes: ['Update message information for matching emails', BEHAVIOR.NO_LABEL_SET_ON_GMAIL],
492
509
  tags: ['api', 'Multi Message Actions'],
493
510
 
494
511
  plugins: {
495
- 'hapi-swagger': {
496
- responses: errorResponses(400, 401, 403, 404, 429, 500, 503)
512
+ openapi: {
513
+ 'x-ee-behavior': [BEHAVIOR.NO_LABEL_SET_ON_GMAIL],
514
+ responses: apiResponses('Returns which flag and label changes were applied to the matching messages.', 400, 401, 403, 404, 429, 500, 503)
497
515
  }
498
516
  },
499
517
 
@@ -576,8 +594,8 @@ async function init(args) {
576
594
  tags: ['api', 'Message'],
577
595
 
578
596
  plugins: {
579
- 'hapi-swagger': {
580
- responses: errorResponses(400, 401, 403, 404, 429, 500, 503)
597
+ openapi: {
598
+ responses: apiResponses('Returns the message identifiers in the target folder.', 400, 401, 403, 404, 429, 500, 503)
581
599
  }
582
600
  },
583
601
 
@@ -650,8 +668,8 @@ async function init(args) {
650
668
  tags: ['api', 'Multi Message Actions'],
651
669
 
652
670
  plugins: {
653
- 'hapi-swagger': {
654
- responses: errorResponses(400, 401, 403, 404, 429, 500, 503)
671
+ openapi: {
672
+ responses: apiResponses('Returns the number of messages moved.', 400, 401, 403, 404, 429, 500, 503)
655
673
  }
656
674
  },
657
675
 
@@ -724,12 +742,13 @@ async function init(args) {
724
742
  },
725
743
  options: {
726
744
  description: 'Delete message',
727
- notes: 'Move message to Trash or delete it if already in Trash',
745
+ notes: ['Move message to Trash or delete it if already in Trash', BEHAVIOR.GMAIL_DELETE_IS_TRASH],
728
746
  tags: ['api', 'Message'],
729
747
 
730
748
  plugins: {
731
- 'hapi-swagger': {
732
- responses: errorResponses(400, 401, 403, 404, 429, 500, 503)
749
+ openapi: {
750
+ 'x-ee-behavior': [BEHAVIOR.GMAIL_DELETE_IS_TRASH],
751
+ responses: apiResponses('Returns whether the message was moved to Trash or permanently deleted.', 400, 401, 403, 404, 429, 500, 503)
733
752
  }
734
753
  },
735
754
 
@@ -808,12 +827,13 @@ async function init(args) {
808
827
  },
809
828
  options: {
810
829
  description: 'Delete messages',
811
- notes: 'Move messages to Trash or delete these if already in Trash',
830
+ notes: ['Move messages to Trash or delete these if already in Trash', BEHAVIOR.GMAIL_DELETE_IS_TRASH],
812
831
  tags: ['api', 'Multi Message Actions'],
813
832
 
814
833
  plugins: {
815
- 'hapi-swagger': {
816
- responses: errorResponses(400, 401, 403, 404, 429, 500, 503)
834
+ openapi: {
835
+ 'x-ee-behavior': [BEHAVIOR.GMAIL_DELETE_IS_TRASH],
836
+ responses: apiResponses('Returns the number of messages deleted.', 400, 401, 403, 404, 429, 500, 503)
817
837
  }
818
838
  },
819
839
 
@@ -912,8 +932,8 @@ async function init(args) {
912
932
  tags: ['api', 'Message'],
913
933
 
914
934
  plugins: {
915
- 'hapi-swagger': {
916
- responses: errorResponses(400, 401, 403, 404, 429, 500, 503)
935
+ openapi: {
936
+ responses: apiResponses('Returns a page of messages from the folder, newest first.', 400, 401, 403, 404, 429, 500, 503)
917
937
  }
918
938
  },
919
939
 
@@ -1017,8 +1037,8 @@ async function init(args) {
1017
1037
  tags: ['api', 'Message'],
1018
1038
 
1019
1039
  plugins: {
1020
- 'hapi-swagger': {
1021
- responses: errorResponses(400, 401, 403, 404, 422, 429, 500, 503)
1040
+ openapi: {
1041
+ responses: apiResponses('Returns a page of matching messages, newest first.', 400, 401, 403, 404, 422, 429, 500, 503)
1022
1042
  }
1023
1043
  },
1024
1044
 
@@ -1184,8 +1204,8 @@ async function init(args) {
1184
1204
  tags: ['api', 'Deprecated endpoints (Document Store)'],
1185
1205
 
1186
1206
  plugins: {
1187
- 'hapi-swagger': {
1188
- responses: errorResponses(400, 401, 403, 429, 500)
1207
+ openapi: {
1208
+ responses: apiResponses('Returns matching messages across all indexed accounts.', 400, 401, 403, 429, 500)
1189
1209
  }
1190
1210
  },
1191
1211
 
@@ -1299,8 +1319,8 @@ async function init(args) {
1299
1319
  tags: ['api', 'Message'],
1300
1320
 
1301
1321
  plugins: {
1302
- 'hapi-swagger': {
1303
- responses: errorResponses(400, 401, 403, 404, 429, 500, 503)
1322
+ openapi: {
1323
+ responses: apiResponses('Returns the message text content in the requested formats.', 400, 401, 403, 404, 429, 500, 503)
1304
1324
  }
1305
1325
  },
1306
1326
 
@@ -1391,9 +1411,9 @@ async function init(args) {
1391
1411
  cors: CORS_CONFIG,
1392
1412
 
1393
1413
  plugins: {
1394
- 'hapi-swagger': {
1414
+ openapi: {
1395
1415
  produces: ['application/octet-stream'],
1396
- responses: errorResponses(400, 401, 403, 404, 429, 500, 503)
1416
+ responses: apiResponses('Returns the attachment content as a binary stream.', 400, 401, 403, 404, 429, 500, 503)
1397
1417
  }
1398
1418
  },
1399
1419
 
@@ -12,9 +12,11 @@ const {
12
12
  googleWorkspaceAccountsSchema,
13
13
  googleTopicNameSchema,
14
14
  googleSubscriptionNameSchema,
15
- errorResponses
15
+ apiResponses,
16
+ ENUM_DESCRIPTIONS
16
17
  } = require('../schemas');
17
18
  const { handleError, throwNotFound, flattenOAuthAppMeta } = require('./route-helpers');
19
+ const { ENCRYPTED_APP_KEYS } = require('../consts');
18
20
 
19
21
  // Stored fields that are returned on OAuth2 application objects in addition to the basic fields
20
22
  const oauth2AppExtraFields = {
@@ -26,7 +28,10 @@ const oauth2AppExtraFields = {
26
28
  .items(Joi.string().example('SMTP.Send').label('SkipScopeEntry'))
27
29
  .description('OAuth2 scopes excluded from the defaults for this app')
28
30
  .label('AppSkipScopes'),
29
- baseScopes: oauthCreateSchema.baseScopes.description('OAuth2 base scopes for this app').label('AppBaseScopes'),
31
+ baseScopes: oauthCreateSchema.baseScopes
32
+ .description('OAuth2 base scopes for this app')
33
+ .meta({ enumDescriptions: ENUM_DESCRIPTIONS.appBaseScopes })
34
+ .label('AppBaseScopes'),
30
35
  pubSubApp: oauthCreateSchema.pubSubApp.description('Cloud Pub/Sub app ID used for Gmail change notifications').label('AppPubSubApp'),
31
36
  authMethod: Joi.string().example('serviceKey').description('Authentication method for Gmail service accounts'),
32
37
  cloud: Joi.string().example('global').description('Azure cloud type for Outlook OAuth2 applications'),
@@ -66,7 +71,7 @@ async function init(args) {
66
71
  let response = await oauth2Apps.list(request.query.page, request.query.pageSize);
67
72
 
68
73
  for (let app of response.apps) {
69
- for (let secretKey of ['clientSecret', 'serviceKey', 'accessToken', 'externalAccount']) {
74
+ for (let secretKey of ENCRYPTED_APP_KEYS) {
70
75
  if (app[secretKey]) {
71
76
  app[secretKey] = '******';
72
77
  }
@@ -95,8 +100,8 @@ async function init(args) {
95
100
  tags: ['api', 'OAuth2 Applications'],
96
101
 
97
102
  plugins: {
98
- 'hapi-swagger': {
99
- responses: errorResponses(400, 401, 403, 429, 500)
103
+ openapi: {
104
+ responses: apiResponses('Returns a page of OAuth2 applications.', 400, 401, 403, 429, 500)
100
105
  }
101
106
  },
102
107
 
@@ -224,7 +229,7 @@ async function init(args) {
224
229
  }
225
230
 
226
231
  // remove secrets
227
- for (let secretKey of ['clientSecret', 'serviceKey', 'accessToken', 'externalAccount']) {
232
+ for (let secretKey of ENCRYPTED_APP_KEYS) {
228
233
  if (app[secretKey]) {
229
234
  app[secretKey] = '******';
230
235
  }
@@ -251,8 +256,8 @@ async function init(args) {
251
256
  tags: ['api', 'OAuth2 Applications'],
252
257
 
253
258
  plugins: {
254
- 'hapi-swagger': {
255
- responses: errorResponses(400, 401, 403, 404, 429, 500)
259
+ openapi: {
260
+ responses: apiResponses('Returns the OAuth2 application. Client secrets are masked.', 400, 401, 403, 404, 429, 500)
256
261
  }
257
262
  },
258
263
 
@@ -369,8 +374,8 @@ async function init(args) {
369
374
  tags: ['api', 'OAuth2 Applications'],
370
375
 
371
376
  plugins: {
372
- 'hapi-swagger': {
373
- responses: errorResponses(400, 401, 403, 429, 500)
377
+ openapi: {
378
+ responses: apiResponses('Returns the registered OAuth2 application.', 400, 401, 403, 429, 500)
374
379
  }
375
380
  },
376
381
 
@@ -419,8 +424,8 @@ async function init(args) {
419
424
  tags: ['api', 'OAuth2 Applications'],
420
425
 
421
426
  plugins: {
422
- 'hapi-swagger': {
423
- responses: errorResponses(400, 401, 403, 404, 429, 500)
427
+ openapi: {
428
+ responses: apiResponses('Returns the updated OAuth2 application.', 400, 401, 403, 404, 429, 500)
424
429
  }
425
430
  },
426
431
 
@@ -521,6 +526,7 @@ async function init(args) {
521
526
  .valid('global', 'gcc-high', 'dod', 'china')
522
527
  .example('global')
523
528
  .description('Azure cloud type for Outlook OAuth2 applications')
529
+ .meta({ enumDescriptions: ENUM_DESCRIPTIONS.azureCloud })
524
530
  .label('AzureCloud'),
525
531
 
526
532
  tenant: Joi.string().trim().empty('').max(1024).example('f8cdef31-a31e-4b4a-93e4-5f571e91255a').label('Directorytenant'),
@@ -570,8 +576,8 @@ async function init(args) {
570
576
  tags: ['api', 'OAuth2 Applications'],
571
577
 
572
578
  plugins: {
573
- 'hapi-swagger': {
574
- responses: errorResponses(400, 401, 403, 404, 429, 500)
579
+ openapi: {
580
+ responses: apiResponses('Returns a deletion marker.', 400, 401, 403, 404, 429, 500)
575
581
  }
576
582
  },
577
583
 
@@ -629,8 +635,8 @@ async function init(args) {
629
635
  tags: ['api', 'OAuth2 Applications'],
630
636
 
631
637
  plugins: {
632
- 'hapi-swagger': {
633
- responses: errorResponses(400, 401, 403, 404, 429, 500)
638
+ openapi: {
639
+ responses: apiResponses('Returns the outcome of the credential check against the provider.', 400, 401, 403, 404, 429, 500)
634
640
  }
635
641
  },
636
642
 
@@ -6,7 +6,7 @@ const logger = require('../logger');
6
6
  const outbox = require('../outbox');
7
7
  const { failAction } = require('../tools');
8
8
  const { handleError } = require('./route-helpers');
9
- const { outboxEntrySchema, errorResponses } = require('../schemas');
9
+ const { outboxEntrySchema, apiResponses } = require('../schemas');
10
10
 
11
11
  async function init(args) {
12
12
  const { server, CORS_CONFIG } = args;
@@ -29,8 +29,8 @@ async function init(args) {
29
29
  tags: ['api', 'Outbox'],
30
30
 
31
31
  plugins: {
32
- 'hapi-swagger': {
33
- responses: errorResponses(400, 401, 403, 429, 500)
32
+ openapi: {
33
+ responses: apiResponses('Returns the messages currently queued for delivery.', 400, 401, 403, 429, 500)
34
34
  }
35
35
  },
36
36
 
@@ -98,8 +98,8 @@ async function init(args) {
98
98
  tags: ['api', 'Outbox'],
99
99
 
100
100
  plugins: {
101
- 'hapi-swagger': {
102
- responses: errorResponses(400, 401, 403, 404, 429, 500)
101
+ openapi: {
102
+ responses: apiResponses('Returns the queued message, including its delivery attempts and last error.', 400, 401, 403, 404, 429, 500)
103
103
  }
104
104
  },
105
105
 
@@ -148,8 +148,8 @@ async function init(args) {
148
148
  tags: ['api', 'Outbox'],
149
149
 
150
150
  plugins: {
151
- 'hapi-swagger': {
152
- responses: errorResponses(400, 401, 403, 429, 500)
151
+ openapi: {
152
+ responses: apiResponses('Returns a deletion marker. A message already being delivered cannot be removed.', 400, 401, 403, 429, 500)
153
153
  }
154
154
  },
155
155
 
@@ -3,7 +3,7 @@
3
3
  const Joi = require('joi');
4
4
  const { failAction } = require('../tools');
5
5
  const { oauth2Apps } = require('../oauth2-apps');
6
- const { pubSubErrorSchema, errorResponses } = require('../schemas');
6
+ const { pubSubErrorSchema, apiResponses } = require('../schemas');
7
7
  const { handleError, flattenOAuthAppMeta } = require('./route-helpers');
8
8
 
9
9
  async function init(args) {
@@ -39,8 +39,8 @@ async function init(args) {
39
39
  tags: ['api', 'OAuth2 Applications'],
40
40
 
41
41
  plugins: {
42
- 'hapi-swagger': {
43
- responses: errorResponses(400, 401, 403, 429, 500)
42
+ openapi: {
43
+ responses: apiResponses('Returns the Pub/Sub subscription state for each configured Gmail application.', 400, 401, 403, 429, 500)
44
44
  }
45
45
  },
46
46