emailengine-app 2.72.2 → 2.72.4
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/CHANGELOG.md +52 -0
- package/Gruntfile.js +4 -1
- package/data/google-crawlers.json +1 -1
- package/lib/account.js +4 -3
- package/lib/autodetect-imap-settings.js +60 -11
- package/lib/consts.js +7 -0
- package/lib/email-client/gmail-client.js +4 -1
- package/lib/email-client/imap/mailbox.js +137 -30
- package/lib/email-client/imap/subconnection.js +105 -36
- package/lib/email-client/imap-client.js +331 -165
- package/lib/email-client/outlook/graph-api.js +3 -1
- package/lib/email-client/reconnect-backoff.js +38 -0
- package/lib/export.js +3 -2
- package/lib/imap-proxy-auth.js +2 -1
- package/lib/schemas.js +14 -0
- package/lib/settings.js +42 -11
- package/lib/smtp-auth.js +2 -1
- package/lib/sub-script.js +14 -3
- package/lib/tokens.js +2 -1
- package/lib/tools.js +122 -12
- package/lib/ui-routes/account-routes.js +340 -121
- package/lib/ui-routes/admin-config-routes.js +11 -1
- package/lib/ui-routes/unsubscribe-routes.js +69 -49
- package/package.json +23 -20
- package/sbom.json +1 -1
- package/static/js/ee-client.js +198 -140
- package/static/licenses.html +63 -73
- package/translations/messages.pot +106 -96
- package/views/accounts/register/imap-server.hbs +87 -17
- package/views/partials/oauth_form.hbs +4 -4
- package/views/unsubscribe.hbs +8 -17
- package/workers/api.js +124 -53
|
@@ -9,8 +9,9 @@ const Joi = require('joi');
|
|
|
9
9
|
const Boom = require('@hapi/boom');
|
|
10
10
|
const { Account } = require('../account');
|
|
11
11
|
const { redis } = require('../db');
|
|
12
|
-
const { accountIdSchema } = require('../schemas');
|
|
13
12
|
const { REDIS_PREFIX } = require('../consts');
|
|
13
|
+
const { parseSignedFormData } = require('../tools');
|
|
14
|
+
const { signedFormBlobFields } = require('../schemas');
|
|
14
15
|
|
|
15
16
|
function init(args) {
|
|
16
17
|
const { server, call } = args;
|
|
@@ -19,10 +20,9 @@ function init(args) {
|
|
|
19
20
|
method: 'GET',
|
|
20
21
|
path: '/unsubscribe',
|
|
21
22
|
async handler(request, h) {
|
|
22
|
-
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
data = JSON.parse(data);
|
|
23
|
+
// Verify the HMAC signature over the signed payload before acting on it, and read every
|
|
24
|
+
// field from the signed data - never from unsigned query input (security review M7).
|
|
25
|
+
let data = await parseSignedFormData(redis, { data: request.query.data, sig: request.query.sig }, request.app.gt);
|
|
26
26
|
|
|
27
27
|
if (!data || typeof data !== 'object' || data.act !== 'unsub') {
|
|
28
28
|
throw new Error(request.app.gt.gettext('Invalid input'));
|
|
@@ -42,7 +42,10 @@ function init(args) {
|
|
|
42
42
|
listId: data.list,
|
|
43
43
|
account: data.acc,
|
|
44
44
|
messageId: data.msg,
|
|
45
|
-
email: data.rcpt
|
|
45
|
+
email: data.rcpt,
|
|
46
|
+
// carry the signed payload through so the submit step can re-verify it (M7)
|
|
47
|
+
data: request.query.data,
|
|
48
|
+
sig: request.query.sig
|
|
46
49
|
}
|
|
47
50
|
},
|
|
48
51
|
{
|
|
@@ -70,8 +73,7 @@ function init(args) {
|
|
|
70
73
|
},
|
|
71
74
|
|
|
72
75
|
query: Joi.object({
|
|
73
|
-
|
|
74
|
-
sig: Joi.string().base64({ paddingRequired: false, urlSafe: true })
|
|
76
|
+
...signedFormBlobFields
|
|
75
77
|
})
|
|
76
78
|
}
|
|
77
79
|
}
|
|
@@ -82,25 +84,60 @@ function init(args) {
|
|
|
82
84
|
path: '/unsubscribe/address',
|
|
83
85
|
async handler(request, h) {
|
|
84
86
|
try {
|
|
87
|
+
// Verify the signature and read account/list/recipient from the SIGNED payload -
|
|
88
|
+
// never from client-supplied fields - so subscribe/unsubscribe cannot be forged (M7).
|
|
89
|
+
let signed = await parseSignedFormData(redis, { data: request.payload.data, sig: request.payload.sig }, request.app.gt);
|
|
90
|
+
|
|
91
|
+
if (!signed || typeof signed !== 'object' || signed.act !== 'unsub') {
|
|
92
|
+
throw Boom.boomify(new Error(request.app.gt.gettext('Invalid input')), { statusCode: 400 });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let account = signed.acc;
|
|
96
|
+
let listId = signed.list;
|
|
97
|
+
let email = signed.rcpt;
|
|
98
|
+
let messageId = signed.msg;
|
|
99
|
+
|
|
85
100
|
// throws if account does not exist
|
|
86
|
-
let accountObject = new Account({ redis, account
|
|
101
|
+
let accountObject = new Account({ redis, account });
|
|
87
102
|
await accountObject.loadAccountData();
|
|
88
103
|
|
|
89
104
|
let reSubscribed = false;
|
|
90
105
|
|
|
106
|
+
// Best-effort notify: the list state (eeListAdd/eeListRemove) is already committed, so a
|
|
107
|
+
// failed dispatch must not fail the request. The outer catch would show a generic error and
|
|
108
|
+
// the idempotent retry returns isNew/removed=false, so the event would be lost forever. Log
|
|
109
|
+
// and continue (mirrors the one-click endpoint in workers/api.js).
|
|
110
|
+
const dispatchListEvent = async cmd => {
|
|
111
|
+
try {
|
|
112
|
+
await call({
|
|
113
|
+
cmd,
|
|
114
|
+
account,
|
|
115
|
+
payload: {
|
|
116
|
+
recipient: email,
|
|
117
|
+
messageId,
|
|
118
|
+
listId,
|
|
119
|
+
remoteAddress: request.info.remoteAddress,
|
|
120
|
+
userAgent: request.headers['user-agent']
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
} catch (err) {
|
|
124
|
+
request.logger.error({ msg: `Failed to dispatch ${cmd} event`, account, listId, err });
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
91
128
|
switch (request.payload.action) {
|
|
92
129
|
case 'unsubscribe': {
|
|
93
130
|
let isNew = await redis.eeListAdd(
|
|
94
131
|
`${REDIS_PREFIX}lists:unsub:lists`,
|
|
95
|
-
`${REDIS_PREFIX}lists:unsub:entries:${
|
|
96
|
-
|
|
97
|
-
|
|
132
|
+
`${REDIS_PREFIX}lists:unsub:entries:${listId}`,
|
|
133
|
+
listId,
|
|
134
|
+
email.toLowerCase().trim(),
|
|
98
135
|
JSON.stringify({
|
|
99
|
-
recipient:
|
|
100
|
-
account
|
|
136
|
+
recipient: email,
|
|
137
|
+
account,
|
|
101
138
|
source: 'form',
|
|
102
139
|
reason: 'unsubscribe',
|
|
103
|
-
messageId
|
|
140
|
+
messageId,
|
|
104
141
|
remoteAddress: request.info.remoteAddress,
|
|
105
142
|
userAgent: request.headers['user-agent'],
|
|
106
143
|
created: new Date().toISOString()
|
|
@@ -108,17 +145,7 @@ function init(args) {
|
|
|
108
145
|
);
|
|
109
146
|
|
|
110
147
|
if (isNew) {
|
|
111
|
-
await
|
|
112
|
-
cmd: 'unsubscribe',
|
|
113
|
-
account: request.payload.account,
|
|
114
|
-
payload: {
|
|
115
|
-
recipient: request.payload.email,
|
|
116
|
-
messageId: request.payload.messageId,
|
|
117
|
-
listId: request.payload.listId,
|
|
118
|
-
remoteAddress: request.info.remoteAddress,
|
|
119
|
-
userAgent: request.headers['user-agent']
|
|
120
|
-
}
|
|
121
|
-
});
|
|
148
|
+
await dispatchListEvent('unsubscribe');
|
|
122
149
|
}
|
|
123
150
|
break;
|
|
124
151
|
}
|
|
@@ -126,23 +153,13 @@ function init(args) {
|
|
|
126
153
|
case 'subscribe': {
|
|
127
154
|
let removed = await redis.eeListRemove(
|
|
128
155
|
`${REDIS_PREFIX}lists:unsub:lists`,
|
|
129
|
-
`${REDIS_PREFIX}lists:unsub:entries:${
|
|
130
|
-
|
|
131
|
-
|
|
156
|
+
`${REDIS_PREFIX}lists:unsub:entries:${listId}`,
|
|
157
|
+
listId,
|
|
158
|
+
email.toLowerCase().trim()
|
|
132
159
|
);
|
|
133
160
|
|
|
134
161
|
if (removed) {
|
|
135
|
-
await
|
|
136
|
-
cmd: 'subscribe',
|
|
137
|
-
account: request.payload.account,
|
|
138
|
-
payload: {
|
|
139
|
-
recipient: request.payload.email,
|
|
140
|
-
messageId: request.payload.messageId,
|
|
141
|
-
listId: request.payload.listId,
|
|
142
|
-
remoteAddress: request.info.remoteAddress,
|
|
143
|
-
userAgent: request.headers['user-agent']
|
|
144
|
-
}
|
|
145
|
-
});
|
|
162
|
+
await dispatchListEvent('subscribe');
|
|
146
163
|
}
|
|
147
164
|
|
|
148
165
|
reSubscribed = true;
|
|
@@ -155,8 +172,16 @@ function init(args) {
|
|
|
155
172
|
{
|
|
156
173
|
pageTitleFull: request.app.gt.gettext('Subscription Management'),
|
|
157
174
|
|
|
158
|
-
unsubscribed: await redis.hexists(`${REDIS_PREFIX}lists:unsub:entries:${
|
|
159
|
-
values:
|
|
175
|
+
unsubscribed: await redis.hexists(`${REDIS_PREFIX}lists:unsub:entries:${listId}`, email),
|
|
176
|
+
values: {
|
|
177
|
+
listId,
|
|
178
|
+
account,
|
|
179
|
+
messageId,
|
|
180
|
+
email,
|
|
181
|
+
// carry the signed payload through for the re-subscribe form (M7)
|
|
182
|
+
data: request.payload.data,
|
|
183
|
+
sig: request.payload.sig
|
|
184
|
+
},
|
|
160
185
|
reSubscribed
|
|
161
186
|
},
|
|
162
187
|
{
|
|
@@ -170,8 +195,7 @@ function init(args) {
|
|
|
170
195
|
return h.view(
|
|
171
196
|
'unsubscribe',
|
|
172
197
|
{
|
|
173
|
-
pageTitleFull: request.app.gt.gettext('Subscription Management')
|
|
174
|
-
unsubscribed: await redis.hexists(`${REDIS_PREFIX}lists:unsub:entries:${request.payload.listId}`, request.payload.email)
|
|
198
|
+
pageTitleFull: request.app.gt.gettext('Subscription Management')
|
|
175
199
|
},
|
|
176
200
|
{
|
|
177
201
|
layout: 'public'
|
|
@@ -207,7 +231,6 @@ function init(args) {
|
|
|
207
231
|
'unsubscribe',
|
|
208
232
|
{
|
|
209
233
|
pageTitleFull: request.app.gt.gettext('Subscription Management'),
|
|
210
|
-
unsubscribed: await redis.hexists(`${REDIS_PREFIX}lists:unsub:entries:${request.payload.listId}`, request.payload.email),
|
|
211
234
|
errors
|
|
212
235
|
},
|
|
213
236
|
{
|
|
@@ -219,10 +242,7 @@ function init(args) {
|
|
|
219
242
|
|
|
220
243
|
payload: Joi.object({
|
|
221
244
|
action: Joi.string().valid('subscribe', 'unsubscribe').required(),
|
|
222
|
-
|
|
223
|
-
listId: Joi.string().hostname().empty('').example('test-list').label('List ID').required(),
|
|
224
|
-
email: Joi.string().email().empty('').required().description('Email address').required(),
|
|
225
|
-
messageId: Joi.string().empty('').max(996).example('<test123@example.com>').description('Message ID')
|
|
245
|
+
...signedFormBlobFields
|
|
226
246
|
})
|
|
227
247
|
}
|
|
228
248
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "emailengine-app",
|
|
3
|
-
"version": "2.72.
|
|
3
|
+
"version": "2.72.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"productTitle": "EmailEngine",
|
|
6
6
|
"description": "Email Sync Engine",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
},
|
|
48
48
|
"homepage": "https://emailengine.app/",
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@bull-board/api": "8.
|
|
51
|
-
"@bull-board/hapi": "8.
|
|
50
|
+
"@bull-board/api": "8.1.2",
|
|
51
|
+
"@bull-board/hapi": "8.1.2",
|
|
52
52
|
"@elastic/elasticsearch": "8.15.3",
|
|
53
53
|
"@hapi/accept": "6.0.3",
|
|
54
54
|
"@hapi/bell": "13.1.0",
|
|
@@ -61,20 +61,20 @@
|
|
|
61
61
|
"@phc/pbkdf2": "1.1.14",
|
|
62
62
|
"@postalsys/bounce-classifier": "3.0.0",
|
|
63
63
|
"@postalsys/certs": "1.0.15",
|
|
64
|
-
"@postalsys/ee-client": "1.
|
|
65
|
-
"@postalsys/email-ai-tools": "1.13.
|
|
66
|
-
"@postalsys/email-text-tools": "2.4.
|
|
64
|
+
"@postalsys/ee-client": "1.4.0",
|
|
65
|
+
"@postalsys/email-ai-tools": "1.13.12",
|
|
66
|
+
"@postalsys/email-text-tools": "2.4.10",
|
|
67
67
|
"@postalsys/gettext": "4.1.1",
|
|
68
68
|
"@postalsys/joi-messages": "1.0.5",
|
|
69
69
|
"@postalsys/templates": "2.0.1",
|
|
70
|
-
"@sentry/node": "10.
|
|
70
|
+
"@sentry/node": "10.64.0",
|
|
71
71
|
"@simplewebauthn/browser": "13.3.0",
|
|
72
72
|
"@simplewebauthn/server": "13.3.2",
|
|
73
|
-
"@zone-eu/mailsplit": "5.4.
|
|
73
|
+
"@zone-eu/mailsplit": "5.4.14",
|
|
74
74
|
"@zone-eu/wild-config": "1.7.5",
|
|
75
75
|
"ace-builds": "1.44.0",
|
|
76
76
|
"base32.js": "0.1.0",
|
|
77
|
-
"bullmq": "5.
|
|
77
|
+
"bullmq": "5.80.0",
|
|
78
78
|
"compare-versions": "6.1.1",
|
|
79
79
|
"dotenv": "17.4.2",
|
|
80
80
|
"encoding-japanese": "2.2.0",
|
|
@@ -87,32 +87,32 @@
|
|
|
87
87
|
"he": "1.2.0",
|
|
88
88
|
"html-to-text": "10.0.0",
|
|
89
89
|
"ical.js": "1.5.0",
|
|
90
|
-
"iconv-lite": "0.7.
|
|
91
|
-
"imapflow": "1.4.
|
|
90
|
+
"iconv-lite": "0.7.3",
|
|
91
|
+
"imapflow": "1.4.7",
|
|
92
92
|
"ioredfour": "1.4.1",
|
|
93
93
|
"ioredis": "5.11.1",
|
|
94
94
|
"ipaddr.js": "2.4.0",
|
|
95
95
|
"joi": "17.13.4",
|
|
96
96
|
"jquery": "4.0.0",
|
|
97
97
|
"libbase64": "1.3.0",
|
|
98
|
-
"libmime": "5.4.
|
|
98
|
+
"libmime": "5.4.1",
|
|
99
99
|
"libqp": "2.1.1",
|
|
100
100
|
"license-checker": "25.0.1",
|
|
101
|
-
"mailparser": "3.9.
|
|
101
|
+
"mailparser": "3.9.14",
|
|
102
102
|
"marked": "15.0.12",
|
|
103
103
|
"minimist": "1.2.8",
|
|
104
104
|
"msgpack5": "6.0.2",
|
|
105
105
|
"murmurhash": "2.0.1",
|
|
106
106
|
"nanoid": "3.3.15",
|
|
107
|
-
"nodemailer": "9.0.
|
|
107
|
+
"nodemailer": "9.0.3",
|
|
108
108
|
"pino": "10.3.1",
|
|
109
109
|
"popper.js": "1.16.1",
|
|
110
110
|
"prom-client": "15.1.3",
|
|
111
111
|
"psl": "1.15.0",
|
|
112
|
-
"pubface": "1.1.
|
|
112
|
+
"pubface": "1.1.5",
|
|
113
113
|
"punycode.js": "2.3.1",
|
|
114
114
|
"qrcode": "1.5.4",
|
|
115
|
-
"smtp-server": "3.19.
|
|
115
|
+
"smtp-server": "3.19.2",
|
|
116
116
|
"socks": "2.8.9",
|
|
117
117
|
"speakeasy": "2.0.0",
|
|
118
118
|
"startbootstrap-sb-admin-2": "3.3.7",
|
|
@@ -126,20 +126,23 @@
|
|
|
126
126
|
"acorn": "8.17.0",
|
|
127
127
|
"acorn-walk": "8.3.5",
|
|
128
128
|
"chai": "4.5.0",
|
|
129
|
-
"eerawlog": "1.5.
|
|
130
|
-
"eslint": "10.
|
|
129
|
+
"eerawlog": "1.5.4",
|
|
130
|
+
"eslint": "10.6.0",
|
|
131
131
|
"grunt": "1.6.2",
|
|
132
132
|
"grunt-cli": "1.5.0",
|
|
133
133
|
"grunt-shell-spawn": "0.5.0",
|
|
134
134
|
"pino-pretty": "13.1.3",
|
|
135
|
-
"prettier": "3.
|
|
135
|
+
"prettier": "3.9.5",
|
|
136
136
|
"resedit": "3.0.2",
|
|
137
137
|
"spdx-satisfies": "6.0.0",
|
|
138
138
|
"supertest": "7.2.2",
|
|
139
139
|
"xgettext-template": "5.0.0"
|
|
140
140
|
},
|
|
141
141
|
"overrides": {
|
|
142
|
-
"@asamuzakjp/css-color": "4.1.1"
|
|
142
|
+
"@asamuzakjp/css-color": "4.1.1",
|
|
143
|
+
"grunt": {
|
|
144
|
+
"js-yaml": "3.15.0"
|
|
145
|
+
}
|
|
143
146
|
},
|
|
144
147
|
"engines": {
|
|
145
148
|
"node": ">=20.x"
|