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.
- package/.github/workflows/release.yaml +24 -19
- package/.github/workflows/test.yml +80 -0
- package/.ncurc.js +14 -2
- package/.release-please-manifest.json +3 -0
- package/CHANGELOG.md +54 -0
- package/README.md +1 -1
- package/bin/emailengine.js +1 -1
- package/data/google-crawlers.json +1 -1
- package/encrypt.js +72 -5
- package/lib/account/expected-identity.js +88 -0
- package/lib/account.js +75 -26
- package/lib/address-strategies.js +18 -0
- package/lib/api-reference/code-samples.js +194 -0
- package/lib/api-reference/format.js +193 -0
- package/lib/api-reference/index.js +222 -0
- package/lib/api-reference/model.js +338 -0
- package/lib/api-reference/schema-tree.js +366 -0
- package/lib/api-routes/account-routes.js +136 -39
- package/lib/api-routes/behavior-notes.js +57 -0
- package/lib/api-routes/blocklist-routes.js +9 -9
- package/lib/api-routes/changes-routes.js +6 -4
- package/lib/api-routes/chat-routes.js +3 -3
- package/lib/api-routes/delivery-test-routes.js +24 -6
- package/lib/api-routes/export-routes.js +14 -12
- package/lib/api-routes/gateway-routes.js +11 -11
- package/lib/api-routes/license-routes.js +7 -7
- package/lib/api-routes/mailbox-routes.js +18 -9
- package/lib/api-routes/message-routes.js +55 -35
- package/lib/api-routes/oauth2-app-routes.js +22 -16
- package/lib/api-routes/outbox-routes.js +7 -7
- package/lib/api-routes/pubsub-routes.js +3 -3
- package/lib/api-routes/settings-routes.js +10 -9
- package/lib/api-routes/stats-routes.js +3 -3
- package/lib/api-routes/submit-routes.js +58 -8
- package/lib/api-routes/template-routes.js +13 -13
- package/lib/api-routes/token-routes.js +15 -10
- package/lib/api-routes/webhook-route-routes.js +5 -5
- package/lib/append-list.js +3 -14
- package/lib/arf-detect.js +23 -1
- package/lib/autodetect-imap-settings.js +40 -16
- package/lib/base32.js +30 -0
- package/lib/bounce-detect.js +182 -62
- package/lib/consts.js +7 -0
- package/lib/egress-filter.js +89 -8
- package/lib/email-client/base-client.js +72 -82
- package/lib/email-client/gmail-client.js +3 -3
- package/lib/email-client/imap/listing-diff.js +3 -3
- package/lib/email-client/imap/mailbox.js +5 -69
- package/lib/email-client/imap-client.js +3 -2
- package/lib/email-client/message-builder.js +13 -13
- package/lib/email-client/outlook-client.js +1 -1
- package/lib/enum-descriptions.js +130 -0
- package/lib/export.js +1 -1
- package/lib/gateway.js +1 -1
- package/lib/get-raw-email.js +1 -1
- package/lib/imapproxy/imap-core/lib/imap-connection.js +2 -2
- package/lib/imapproxy/imap-core/lib/imap-server.js +2 -2
- package/lib/imapproxy/imap-server.js +42 -28
- package/lib/imapproxy/upstream-client.js +38 -0
- package/lib/license-beacon.js +1 -1
- package/lib/llm-pre-process.js +1 -1
- package/lib/msgpack.js +62 -0
- package/lib/oauth/decode-jwt-payload.js +39 -0
- package/lib/oauth/outlook-identity.js +61 -0
- package/lib/oauth/retry-setup.js +38 -0
- package/lib/oauth2-apps.js +10 -4
- package/lib/openapi/build-document.js +318 -0
- package/lib/openapi/index.js +95 -0
- package/lib/openapi/joi-schema.js +523 -0
- package/lib/outbox.js +66 -3
- package/lib/pre-process.js +1 -1
- package/lib/read-env-value.js +37 -0
- package/lib/routes-ui.js +5 -1
- package/lib/schemas.js +88 -17
- package/lib/swagger-options.js +173 -0
- package/lib/templates.js +1 -1
- package/lib/tokens.js +70 -6
- package/lib/tools.js +117 -48
- package/lib/totp.js +67 -0
- package/lib/ui-routes/account-routes.js +91 -15
- package/lib/ui-routes/admin-config-routes.js +2 -7
- package/lib/ui-routes/admin-entities-routes.js +3 -0
- package/lib/ui-routes/auth-routes.js +6 -24
- package/lib/ui-routes/dashboard-routes.js +2 -26
- package/lib/ui-routes/reference-routes.js +198 -0
- package/lib/ui-routes/route-helpers.js +39 -0
- package/lib/utils/is-email.js +34 -0
- package/lib/utils/to-camel-case.js +17 -0
- package/lib/webhook-egress.js +37 -0
- package/lib/webhooks.js +1 -1
- package/package.json +27 -31
- package/prepare-bundle-deps.sh +28 -0
- package/release-please-config.json +11 -0
- package/sbom.json +1 -1
- package/server.js +11 -3
- package/static/css/flyonui.css +1 -1
- package/static/css/public.css +3 -0
- package/static/css/src/app.tailwind.css +113 -0
- package/static/js/app.js +69 -0
- package/static/js/ee-client.js +238 -8
- package/static/js/reference.js +1021 -0
- package/static/js/ui.js +61 -33
- package/static/licenses.html +658 -1560
- package/translations/README.md +64 -0
- package/translations/de.mo +0 -0
- package/translations/de.po +164 -120
- package/translations/en.po +200 -161
- package/translations/et.mo +0 -0
- package/translations/et.po +163 -120
- package/translations/fr.mo +0 -0
- package/translations/fr.po +163 -120
- package/translations/ja.mo +0 -0
- package/translations/ja.po +163 -120
- package/translations/messages.pot +84 -54
- package/translations/nl.mo +0 -0
- package/translations/nl.po +164 -120
- package/translations/pl.mo +0 -0
- package/translations/pl.po +163 -120
- package/views/account-identity-error.hbs +34 -0
- package/views/accounts/edit.hbs +1 -0
- package/views/accounts/register/imap.hbs +12 -2
- package/views/config/ai.hbs +1 -1
- package/views/config/document-store/chat.hbs +5 -5
- package/views/config/document-store/index.hbs +2 -2
- package/views/config/document-store/pre-processing/index.hbs +1 -1
- package/views/config/email-processing.hbs +1 -1
- package/views/config/imap-proxy.hbs +1 -1
- package/views/config/license.hbs +1 -1
- package/views/config/oauth/index.hbs +3 -3
- package/views/config/security.hbs +1 -1
- package/views/config/smtp.hbs +2 -2
- package/views/dashboard.hbs +1 -1
- package/views/layout/app.hbs +43 -8
- package/views/oauth-scope-error.hbs +1 -1
- package/views/partials/oauth_form.hbs +4 -4
- package/views/partials/reference/anchor-link.hbs +20 -0
- package/views/partials/reference/disclosure.hbs +37 -0
- package/views/partials/reference/nav.hbs +120 -0
- package/views/partials/reference/operation.hbs +127 -0
- package/views/partials/reference/params.hbs +20 -0
- package/views/partials/reference/schema-node.hbs +99 -0
- package/views/partials/reference/schema.hbs +19 -0
- package/views/partials/reference/section-heading.hbs +16 -0
- package/views/partials/reference/token-alert.hbs +49 -0
- package/views/partials/reference/try-field.hbs +31 -0
- package/views/partials/reference/try-it.hbs +78 -0
- package/views/partials/side_menu.hbs +1 -1
- package/views/partials/ui/badge.hbs +4 -2
- package/views/partials/ui/page-header.hbs +1 -1
- package/views/partials/ui/search-input.hbs +31 -0
- package/views/partials/ui/setting-ref.hbs +1 -1
- package/views/partials/ui/stat-card.hbs +4 -2
- package/views/partials/ui/tab.hbs +6 -1
- package/views/partials/ui/tabs.hbs +2 -2
- package/views/reference/index.hbs +76 -0
- package/views/reference/redirect.hbs +49 -0
- package/views/reference/tag.hbs +28 -0
- package/views/reference/token.hbs +49 -0
- package/views/tokens/index.hbs +9 -1
- package/views/webhooks/index.hbs +3 -3
- package/workers/api.js +194 -302
- package/workers/imap.js +1 -1
- package/workers/submit.js +1 -1
- package/workers/webhooks.js +2 -13
- package/views/swagger/index.hbs +0 -82
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Admin UI routes for the server-rendered API reference.
|
|
4
|
+
//
|
|
5
|
+
// This replaced the bundled swagger-ui page, which shipped the OpenAPI document to the
|
|
6
|
+
// browser and let swagger-ui build the DOM. Here the whole page is HTML by the time it
|
|
7
|
+
// leaves the worker - see lib/api-reference/ for the model.
|
|
8
|
+
//
|
|
9
|
+
// This is the "API Reference" entry in the side menu. /admin/swagger is kept only as a
|
|
10
|
+
// redirect for deep links written against the old page.
|
|
11
|
+
|
|
12
|
+
const Joi = require('joi');
|
|
13
|
+
const Boom = require('@hapi/boom');
|
|
14
|
+
|
|
15
|
+
const { failAction } = require('../tools');
|
|
16
|
+
const { jsonErrorPayload } = require('./route-helpers');
|
|
17
|
+
const tokens = require('../tokens');
|
|
18
|
+
const { getIndexView, getTagView, getNavView, getRedirectView } = require('../api-reference');
|
|
19
|
+
|
|
20
|
+
// Lifetime of the throwaway tokens the reference page mints for its try-it panels. Long
|
|
21
|
+
// enough to read through the docs, short enough that a token left in a browser tab is
|
|
22
|
+
// not a lasting credential.
|
|
23
|
+
const TEMP_TOKEN_TTL = 60 * 60 * 1000;
|
|
24
|
+
|
|
25
|
+
// Only tokens carrying this description are revocable through the reference page. It is
|
|
26
|
+
// what the mint route sets, so a pasted token - which the user owns and may still need -
|
|
27
|
+
// can never be deleted by clearing the field.
|
|
28
|
+
const TEMP_TOKEN_DESCRIPTION = 'Temporary token for the API reference';
|
|
29
|
+
|
|
30
|
+
// Opts every reference page into the layout's second navigation column, rendered flush
|
|
31
|
+
// against the main sidebar (views/layout/app.hbs). The label names it where the column
|
|
32
|
+
// cannot be shown as a column - below lg it collapses to a single row carrying this text.
|
|
33
|
+
const SECONDARY_NAV = { secondaryNav: 'reference/nav', secondaryNavLabel: 'Endpoints' };
|
|
34
|
+
|
|
35
|
+
function init(args) {
|
|
36
|
+
const { server } = args;
|
|
37
|
+
|
|
38
|
+
server.route({
|
|
39
|
+
method: 'GET',
|
|
40
|
+
path: '/admin/reference',
|
|
41
|
+
async handler(request, h) {
|
|
42
|
+
const view = await getIndexView(request);
|
|
43
|
+
|
|
44
|
+
return h.view('reference/index', Object.assign({ pageTitle: 'API Reference', menuReference: true, ...SECONDARY_NAV }, view), {
|
|
45
|
+
layout: 'app'
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Access-token page. A literal segment, so hapi routes it ahead of /{tag} below - no
|
|
51
|
+
// tag slug may be `token` or it would be shadowed, which test/api-reference-test.js
|
|
52
|
+
// asserts against RESERVED_SLUGS.
|
|
53
|
+
server.route({
|
|
54
|
+
method: 'GET',
|
|
55
|
+
path: '/admin/reference/token',
|
|
56
|
+
async handler(request, h) {
|
|
57
|
+
const view = await getNavView(request);
|
|
58
|
+
|
|
59
|
+
return h.view('reference/token', Object.assign({ pageTitle: 'Access token', menuReference: true, ...SECONDARY_NAV }, view), {
|
|
60
|
+
layout: 'app'
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
server.route({
|
|
66
|
+
method: 'GET',
|
|
67
|
+
path: '/admin/reference/{tag}',
|
|
68
|
+
async handler(request, h) {
|
|
69
|
+
const view = await getTagView(request, request.params.tag);
|
|
70
|
+
|
|
71
|
+
if (!view) {
|
|
72
|
+
throw Boom.notFound('Unknown endpoint group');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return h.view('reference/tag', Object.assign({ pageTitle: `${view.tag.name} API`, menuReference: true, ...SECONDARY_NAV }, view), {
|
|
76
|
+
layout: 'app'
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
options: {
|
|
81
|
+
validate: {
|
|
82
|
+
options: {
|
|
83
|
+
stripUnknown: true,
|
|
84
|
+
abortEarly: false,
|
|
85
|
+
convert: true
|
|
86
|
+
},
|
|
87
|
+
failAction,
|
|
88
|
+
params: Joi.object({
|
|
89
|
+
// Slugs are generated by slugify() in lib/api-reference/format.js;
|
|
90
|
+
// anything else cannot match a tag and is rejected before the lookup
|
|
91
|
+
tag: Joi.string()
|
|
92
|
+
.max(64)
|
|
93
|
+
.pattern(/^[a-z0-9-]+$/)
|
|
94
|
+
.required()
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Compatibility shim for the retired swagger-ui page. Old versions of EmailEngine, and
|
|
101
|
+
// any bookmark, link here as /admin/swagger#/Tag/operationId; a fragment never reaches
|
|
102
|
+
// the server, so the page maps it in the browser. Links inside this version point at
|
|
103
|
+
// /admin/reference directly.
|
|
104
|
+
server.route({
|
|
105
|
+
method: 'GET',
|
|
106
|
+
path: '/admin/swagger',
|
|
107
|
+
async handler(request, h) {
|
|
108
|
+
const view = await getRedirectView(request);
|
|
109
|
+
|
|
110
|
+
return h.view('reference/redirect', Object.assign({ pageTitle: 'API Reference', menuReference: true }, view), { layout: 'app' });
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// Mints a short-lived, api-scoped token for the try-it panels, so trying an endpoint
|
|
115
|
+
// does not mean creating a permanent credential and remembering to delete it.
|
|
116
|
+
server.route({
|
|
117
|
+
method: 'POST',
|
|
118
|
+
path: '/admin/reference/token',
|
|
119
|
+
|
|
120
|
+
async handler(request) {
|
|
121
|
+
try {
|
|
122
|
+
// Same gate as POST /admin/tokens/new, for the same reason: a token is
|
|
123
|
+
// never invalidated once minted, so an unauthenticated caller must not be
|
|
124
|
+
// able to obtain one. `server.auth.default('session')` is applied
|
|
125
|
+
// conditionally and only in the worker that observed the password being
|
|
126
|
+
// set, so this keys on whether THIS request carries an admin session
|
|
127
|
+
// rather than on the global secured-state.
|
|
128
|
+
if (!request.auth.isAuthenticated) {
|
|
129
|
+
throw Boom.forbidden('Can not provision an access token without an authenticated admin session');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const expires = Date.now() + TEMP_TOKEN_TTL;
|
|
133
|
+
|
|
134
|
+
const token = await tokens.provision({
|
|
135
|
+
ip: request.app.ip,
|
|
136
|
+
remoteAddress: request.app.ip,
|
|
137
|
+
description: TEMP_TOKEN_DESCRIPTION,
|
|
138
|
+
scopes: ['api'],
|
|
139
|
+
expires
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
return { success: true, token, expires };
|
|
143
|
+
} catch (err) {
|
|
144
|
+
request.logger.error({ msg: 'Failed to mint a temporary reference token', err, remoteAddress: request.app.ip });
|
|
145
|
+
return jsonErrorPayload(err);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// Revokes a token minted above, so clearing it in the UI actually removes it rather
|
|
151
|
+
// than leaving a working credential in Redis until it expires on its own.
|
|
152
|
+
server.route({
|
|
153
|
+
method: 'POST',
|
|
154
|
+
path: '/admin/reference/token/revoke',
|
|
155
|
+
|
|
156
|
+
async handler(request) {
|
|
157
|
+
try {
|
|
158
|
+
if (!request.auth.isAuthenticated) {
|
|
159
|
+
throw Boom.forbidden('Can not revoke an access token without an authenticated admin session');
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Refuse anything this page did not mint. An admin can delete any token
|
|
163
|
+
// from the Access Tokens page anyway, so this is not a privilege boundary -
|
|
164
|
+
// it stops the reference page from destroying a token the user pasted in.
|
|
165
|
+
let tokenData;
|
|
166
|
+
try {
|
|
167
|
+
tokenData = await tokens.get(request.payload.token, false, { allowExpired: true });
|
|
168
|
+
} catch (err) {
|
|
169
|
+
// already gone, or never existed - nothing left to revoke
|
|
170
|
+
return { success: true, deleted: false };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (tokenData.description !== TEMP_TOKEN_DESCRIPTION) {
|
|
174
|
+
throw Boom.forbidden('Only tokens minted by the API reference can be revoked here');
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
await tokens.delete(request.payload.token, { remoteAddress: request.app.ip });
|
|
178
|
+
|
|
179
|
+
return { success: true, deleted: true };
|
|
180
|
+
} catch (err) {
|
|
181
|
+
request.logger.error({ msg: 'Failed to revoke a temporary reference token', err, remoteAddress: request.app.ip });
|
|
182
|
+
return jsonErrorPayload(err);
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
options: {
|
|
187
|
+
validate: {
|
|
188
|
+
options: { stripUnknown: true, abortEarly: false, convert: true },
|
|
189
|
+
failAction,
|
|
190
|
+
payload: Joi.object({
|
|
191
|
+
token: Joi.string().length(64).hex().required().description('The token to revoke')
|
|
192
|
+
})
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
module.exports = init;
|
|
@@ -326,7 +326,46 @@ function throwAsBoom(err) {
|
|
|
326
326
|
throw error;
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
+
// Shapes an error for the admin UI's JSON endpoints, which answer 200 with `success: false`
|
|
330
|
+
// rather than an HTTP error - the client branches on the body. Boom errors keep their status
|
|
331
|
+
// and message; anything else degrades to its code.
|
|
332
|
+
function jsonErrorPayload(err) {
|
|
333
|
+
if (Boom.isBoom(err)) {
|
|
334
|
+
return Object.assign({ success: false }, err.output.payload);
|
|
335
|
+
}
|
|
336
|
+
return { success: false, error: err.code || 'Error', message: err.message };
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// The "wrong account" page, shown when a setup link pinned to one address is completed as another.
|
|
340
|
+
// Rendered from both arms of the hosted form - the OAuth2 callback in workers/api.js and the IMAP arm in
|
|
341
|
+
// ./account-routes.js - which live in different workers, so the view name, the layout and the refusal
|
|
342
|
+
// status are kept here rather than written out twice. Only `retryUrl` is arm-specific: the OAuth arm
|
|
343
|
+
// sends the user back to the provider, the IMAP arm back to the form.
|
|
344
|
+
//
|
|
345
|
+
// 403 rather than the 200 that the sibling views/oauth-scope-error.hbs returns: this is a refused
|
|
346
|
+
// request, the surrounding refusals in the same flow already answer 403, and both call sites are plain
|
|
347
|
+
// form navigations, so the browser still renders the page.
|
|
348
|
+
function identityErrorView(request, h, { expectedEmail, actualEmail, retryUrl }) {
|
|
349
|
+
return h
|
|
350
|
+
.view(
|
|
351
|
+
'account-identity-error',
|
|
352
|
+
{
|
|
353
|
+
pageTitleFull: request.app.gt.gettext('Email Account Setup'),
|
|
354
|
+
templateLocale: request.app.locale,
|
|
355
|
+
expectedEmail,
|
|
356
|
+
actualEmail,
|
|
357
|
+
retryUrl
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
layout: 'public'
|
|
361
|
+
}
|
|
362
|
+
)
|
|
363
|
+
.code(403);
|
|
364
|
+
}
|
|
365
|
+
|
|
329
366
|
module.exports = {
|
|
367
|
+
jsonErrorPayload,
|
|
368
|
+
identityErrorView,
|
|
330
369
|
OPEN_AI_MODELS,
|
|
331
370
|
cachedTemplates,
|
|
332
371
|
getOpenAiModels,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const Joi = require('joi');
|
|
4
|
+
|
|
5
|
+
// Built once. joi schemas are immutable and meant to be reused, and compiling this per call measured
|
|
6
|
+
// ~5x slower - which matters because unserializeAccountData() calls isEmail() for every OAuth2 account
|
|
7
|
+
// that has no stored email, and the account listing maps that over every row of a page.
|
|
8
|
+
const emailSchema = Joi.object({
|
|
9
|
+
email: Joi.string().email().required()
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const validateOptions = {
|
|
13
|
+
abortEarly: false,
|
|
14
|
+
stripUnknown: true,
|
|
15
|
+
convert: true
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// Syntactic check only - it says the string is shaped like an address, never that the address is real
|
|
19
|
+
// or that whoever supplied it controls it. Trust decisions belong to the caller.
|
|
20
|
+
//
|
|
21
|
+
// Lives here rather than in lib/tools.js so the pure modules that need it (lib/oauth/outlook-identity.js)
|
|
22
|
+
// do not have to require tools, which pulls in settings and a Redis connection. lib/tools.js re-exports
|
|
23
|
+
// this function, so every existing caller is unaffected.
|
|
24
|
+
function isEmail(str) {
|
|
25
|
+
const { error, value } = emailSchema.validate({ email: str }, validateOptions);
|
|
26
|
+
|
|
27
|
+
if (error) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return value.email;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = { isEmail };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Lives here rather than in lib/tools.js so that pure modules can use it: tools.js opens Redis,
|
|
4
|
+
// which hangs a unit test that only wants to parse a message. tools.js re-exports it, so the
|
|
5
|
+
// existing `require('../tools')` consumers are unaffected.
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Converts a kebab-case header name into the camelCase key used in payloads,
|
|
9
|
+
* eg. "final-recipient" into "finalRecipient"
|
|
10
|
+
* @param {String} key Header name
|
|
11
|
+
* @returns {String} camelCased key
|
|
12
|
+
*/
|
|
13
|
+
function toCamelCase(key) {
|
|
14
|
+
return key.replace(/-(.)/g, (m, c) => c.toUpperCase());
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = { toCamelCase };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Owns the webhook egress policy: where it is read from, what "off" means, and the two forms the
|
|
4
|
+
// rest of the system consumes it in. Previously each consumer resolved the environment variable
|
|
5
|
+
// itself and re-derived the off-switch, which meant the pre-check and the connect-time binding
|
|
6
|
+
// could disagree about what was configured - the same split-brain the binding exists to prevent.
|
|
7
|
+
|
|
8
|
+
const { readEnvValue } = require('./read-env-value');
|
|
9
|
+
const { assertAllowedUrl, createEgressLookup, normalizePolicy, POLICY_OFF } = require('./egress-filter');
|
|
10
|
+
|
|
11
|
+
// Which destinations webhook deliveries may reach. An account-scoped API token can set both the
|
|
12
|
+
// webhook URL and its custom headers, so without this the least-privileged credential in the
|
|
13
|
+
// system can aim EmailEngine at anything its host can route to. Defaults to blocking the
|
|
14
|
+
// link-local range (cloud instance metadata); `private` also blocks RFC1918 and friends, `off`
|
|
15
|
+
// disables the check and restores redirect following. See lib/egress-filter.js
|
|
16
|
+
const WEBHOOK_EGRESS_POLICY = normalizePolicy(readEnvValue('EENGINE_WEBHOOK_EGRESS_POLICY'));
|
|
17
|
+
|
|
18
|
+
const policyEnabled = WEBHOOK_EGRESS_POLICY !== POLICY_OFF;
|
|
19
|
+
|
|
20
|
+
// Built once rather than per delivery. Null when the policy is off, which is also what tells
|
|
21
|
+
// sendWebhookRequest() to keep following redirects.
|
|
22
|
+
const validateWebhookTarget = policyEnabled ? target => assertAllowedUrl(target, { policy: WEBHOOK_EGRESS_POLICY }) : null;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Builds the connect-time half of the guard, for use as an undici Agent's `connect.lookup`.
|
|
26
|
+
*
|
|
27
|
+
* @returns {Function|null} A lookup enforcing the policy, or null when the policy is off
|
|
28
|
+
*/
|
|
29
|
+
function createWebhookLookup() {
|
|
30
|
+
return policyEnabled ? createEgressLookup(WEBHOOK_EGRESS_POLICY) : null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = {
|
|
34
|
+
WEBHOOK_EGRESS_POLICY,
|
|
35
|
+
validateWebhookTarget,
|
|
36
|
+
createWebhookLookup
|
|
37
|
+
};
|
package/lib/webhooks.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { randomUUID: uuid } = require('crypto');
|
|
4
4
|
const { redis, notifyQueue } = require('./db');
|
|
5
|
-
const msgpack = require('
|
|
5
|
+
const msgpack = require('./msgpack');
|
|
6
6
|
const logger = require('./logger');
|
|
7
7
|
const { REDIS_PREFIX, MESSAGE_NEW_NOTIFY } = require('./consts');
|
|
8
8
|
const { SubScript } = require('./sub-script');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "emailengine-app",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.78.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"productTitle": "EmailEngine",
|
|
6
6
|
"description": "Email Sync Engine",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"lint:src": "npx eslint 'lib/**/*.js' 'workers/**/*.js' server.js",
|
|
22
22
|
"swagger": "./getswagger.sh",
|
|
23
23
|
"build:css": "tailwindcss -i static/css/src/app.tailwind.css -o static/css/flyonui.css --minify",
|
|
24
|
-
"build-source": "rm -rf node_modules && npm install && rm -rf node_modules && npm ci --omit=dev && rm -rf node_modules/ace-builds node_modules/@postalsys/ee-client && ./update-info.sh",
|
|
24
|
+
"build-source": "rm -rf node_modules && npm install && rm -rf node_modules && npm ci --omit=dev && rm -rf node_modules/ace-builds node_modules/@postalsys/ee-client && ./prepare-bundle-deps.sh && ./update-info.sh",
|
|
25
25
|
"build-dist": "pkg --compress Brotli package.json && npm install && node winconf.js",
|
|
26
26
|
"build-dist-fast": "pkg --debug package.json && npm install && node winconf.js",
|
|
27
27
|
"licenses": "node list-generate.js",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
},
|
|
51
51
|
"homepage": "https://emailengine.app/",
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@bull-board/api": "8.
|
|
54
|
-
"@bull-board/hapi": "8.
|
|
53
|
+
"@bull-board/api": "8.6.0",
|
|
54
|
+
"@bull-board/hapi": "8.6.0",
|
|
55
55
|
"@elastic/elasticsearch": "8.15.3",
|
|
56
56
|
"@hapi/accept": "6.0.3",
|
|
57
57
|
"@hapi/bell": "13.1.0",
|
|
@@ -61,76 +61,73 @@
|
|
|
61
61
|
"@hapi/hapi": "21.4.10",
|
|
62
62
|
"@hapi/inert": "7.1.2",
|
|
63
63
|
"@hapi/vision": "7.0.3",
|
|
64
|
+
"@msgpack/msgpack": "3.1.3",
|
|
64
65
|
"@phc/pbkdf2": "1.1.14",
|
|
65
66
|
"@postalsys/bounce-classifier": "3.0.0",
|
|
66
|
-
"@postalsys/certs": "1.0.
|
|
67
|
-
"@postalsys/ee-client": "1.
|
|
68
|
-
"@postalsys/email-ai-tools": "1.13.
|
|
69
|
-
"@postalsys/email-content": "0.1.
|
|
70
|
-
"@postalsys/email-text-tools": "2.4.
|
|
67
|
+
"@postalsys/certs": "1.0.17",
|
|
68
|
+
"@postalsys/ee-client": "1.7.0",
|
|
69
|
+
"@postalsys/email-ai-tools": "1.13.17",
|
|
70
|
+
"@postalsys/email-content": "0.1.3",
|
|
71
|
+
"@postalsys/email-text-tools": "2.4.12",
|
|
71
72
|
"@postalsys/gettext": "4.1.1",
|
|
72
73
|
"@postalsys/joi-messages": "1.0.5",
|
|
73
|
-
"@postalsys/templates": "2.0.
|
|
74
|
-
"@sentry/node": "10.
|
|
74
|
+
"@postalsys/templates": "2.0.2",
|
|
75
|
+
"@sentry/node": "10.70.0",
|
|
75
76
|
"@simplewebauthn/browser": "13.3.0",
|
|
76
77
|
"@simplewebauthn/server": "13.3.2",
|
|
77
|
-
"@zone-eu/mailsplit": "5.4.
|
|
78
|
+
"@zone-eu/mailsplit": "5.4.15",
|
|
78
79
|
"@zone-eu/wild-config": "1.7.6",
|
|
79
80
|
"ace-builds": "1.44.0",
|
|
80
|
-
"
|
|
81
|
-
"bullmq": "5.81.2",
|
|
81
|
+
"bullmq": "5.81.3",
|
|
82
82
|
"compare-versions": "6.1.1",
|
|
83
83
|
"dotenv": "17.4.2",
|
|
84
84
|
"encoding-japanese": "2.2.0",
|
|
85
85
|
"exponential-backoff": "3.1.3",
|
|
86
|
+
"fast-xml-parser": "5.10.1",
|
|
86
87
|
"gettext-parser": "7.0.1",
|
|
87
88
|
"handlebars": "4.7.9",
|
|
88
89
|
"hapi-auth-bearer-token": "8.0.0",
|
|
89
90
|
"hapi-pino": "13.0.0",
|
|
90
|
-
"hapi-swagger": "17.3.2",
|
|
91
91
|
"he": "1.2.0",
|
|
92
92
|
"html-to-text": "10.0.0",
|
|
93
93
|
"ical.js": "1.5.0",
|
|
94
94
|
"iconv-lite": "0.7.3",
|
|
95
|
-
"imapflow": "1.
|
|
95
|
+
"imapflow": "1.7.0",
|
|
96
96
|
"ioredfour": "1.4.2",
|
|
97
97
|
"ioredis": "5.11.1",
|
|
98
|
-
"ipaddr.js": "2.
|
|
99
|
-
"joi": "
|
|
98
|
+
"ipaddr.js": "2.5.0",
|
|
99
|
+
"joi": "18.2.3",
|
|
100
100
|
"libbase64": "1.3.0",
|
|
101
|
-
"libmime": "5.4.
|
|
101
|
+
"libmime": "5.4.2",
|
|
102
102
|
"libqp": "2.1.1",
|
|
103
|
-
"mailparser": "3.9.
|
|
103
|
+
"mailparser": "3.9.15",
|
|
104
104
|
"marked": "15.0.12",
|
|
105
105
|
"minimist": "1.2.8",
|
|
106
|
-
"msgpack5": "6.0.2",
|
|
107
106
|
"murmurhash": "2.0.1",
|
|
108
|
-
"nanoid": "3.3.
|
|
109
|
-
"nodemailer": "9.0.
|
|
107
|
+
"nanoid": "3.3.18",
|
|
108
|
+
"nodemailer": "9.0.5",
|
|
110
109
|
"pino": "10.3.1",
|
|
111
110
|
"prom-client": "15.1.3",
|
|
112
111
|
"psl": "1.15.0",
|
|
113
|
-
"pubface": "1.1.
|
|
112
|
+
"pubface": "1.1.6",
|
|
114
113
|
"punycode.js": "2.3.1",
|
|
115
114
|
"qrcode": "1.5.4",
|
|
116
|
-
"smtp-server": "3.19.
|
|
115
|
+
"smtp-server": "3.19.3",
|
|
117
116
|
"socks": "2.8.9",
|
|
118
|
-
"speakeasy": "2.0.0",
|
|
119
117
|
"timezones-list": "3.1.0",
|
|
120
|
-
"undici": "7.29.0"
|
|
121
|
-
"xml2js": "0.6.2"
|
|
118
|
+
"undici": "7.29.0"
|
|
122
119
|
},
|
|
123
120
|
"devDependencies": {
|
|
124
121
|
"@eslint/js": "10.0.1",
|
|
125
122
|
"@iconify-json/tabler": "1.2.38",
|
|
126
123
|
"@iconify/tailwind4": "1.2.3",
|
|
127
|
-
"@playwright/test": "1.62.
|
|
124
|
+
"@playwright/test": "1.62.1",
|
|
128
125
|
"@tailwindcss/cli": "4.3.3",
|
|
129
126
|
"acorn": "8.18.0",
|
|
130
127
|
"acorn-walk": "8.3.5",
|
|
131
128
|
"chai": "4.5.0",
|
|
132
129
|
"eerawlog": "1.5.5",
|
|
133
|
-
"eslint": "10.8.
|
|
130
|
+
"eslint": "10.8.1",
|
|
134
131
|
"flyonui": "2.4.1",
|
|
135
132
|
"pino-pretty": "13.1.3",
|
|
136
133
|
"prettier": "3.9.6",
|
|
@@ -159,7 +156,6 @@
|
|
|
159
156
|
"views/**/*",
|
|
160
157
|
"lib/lua/**/*",
|
|
161
158
|
"node_modules/bull/lib/commands/**/*",
|
|
162
|
-
"node_modules/swagger-ui-dist/**/*",
|
|
163
159
|
"translations/**/*",
|
|
164
160
|
"node_modules/@postalsys/joi-messages/translations/*",
|
|
165
161
|
"node_modules/@postalsys/bounce-classifier/model/**/*",
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
# Fixups applied to the production node_modules tree before pkg bundles it.
|
|
4
|
+
#
|
|
5
|
+
# pkg walks every file a package's `exports` map points at and runs it through esbuild.
|
|
6
|
+
# A file esbuild transforms to nothing leaves pkg dereferencing an undefined result, and
|
|
7
|
+
# it dies with "Cannot read properties of undefined (reading 'tokens')" naming whichever
|
|
8
|
+
# of our own files happened to pull the package in - which points at the wrong place
|
|
9
|
+
# entirely. Fixed upstream in neither pkg 6.21 nor 6.22.
|
|
10
|
+
#
|
|
11
|
+
# Run from npm run build-source, after `npm ci --omit=dev` has produced the tree that
|
|
12
|
+
# actually gets bundled.
|
|
13
|
+
|
|
14
|
+
set -e
|
|
15
|
+
|
|
16
|
+
# @standard-schema/spec (joi >=18) is a types-only package: its runtime export is
|
|
17
|
+
# literally `{}` (see dist/index.cjs) and joi names it only in an `import type` inside
|
|
18
|
+
# lib/index.d.ts, which TypeScript erases. Its ESM entry point dist/index.js is therefore
|
|
19
|
+
# a 0-byte file, which is the one pkg cannot swallow.
|
|
20
|
+
#
|
|
21
|
+
# The file is restored to what an empty ES module should look like rather than deleted:
|
|
22
|
+
# the package stays resolvable, so a future joi that does require it at runtime keeps
|
|
23
|
+
# working instead of failing inside a shipped binary.
|
|
24
|
+
EMPTY_ESM="node_modules/@standard-schema/spec/dist/index.js"
|
|
25
|
+
if [ -f "$EMPTY_ESM" ] && [ ! -s "$EMPTY_ESM" ]; then
|
|
26
|
+
echo "export {};" >"$EMPTY_ESM"
|
|
27
|
+
echo "patched empty ESM entry point: $EMPTY_ESM"
|
|
28
|
+
fi
|