emailengine-app 2.89.0 → 2.90.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/.ncurc.js +19 -8
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +44 -0
- package/Dockerfile +5 -1
- package/bin/healthcheck.js +1 -1
- package/copy-static-files.sh +0 -8
- package/data/google-crawlers.json +1 -1
- package/encrypt.js +1 -4
- package/lib/account/field-codec.js +396 -0
- package/lib/account.js +158 -453
- package/lib/api-routes/account-routes.js +42 -6
- package/lib/api-routes/route-metadata.js +5 -2
- package/lib/api-routes/submit-routes.js +15 -2
- package/lib/api-token-auth.js +342 -274
- package/lib/arf-detect.js +174 -149
- package/lib/attachment-size.js +29 -0
- package/lib/autodetect-imap-settings.js +83 -234
- package/lib/consts.js +1 -5
- package/lib/db.js +1 -4
- package/lib/email-client/base-client.js +907 -780
- package/lib/email-client/gmail-client.js +557 -450
- package/lib/email-client/imap/cid-parts.js +61 -0
- package/lib/email-client/imap/mailbox.js +376 -422
- package/lib/email-client/imap/sync-operations.js +239 -178
- package/lib/email-client/new-message-steps.js +168 -2
- package/lib/email-client/outlook/graph-message.js +266 -0
- package/lib/email-client/outlook/subscription-expiry.js +30 -0
- package/lib/email-client/outlook-client.js +652 -808
- package/lib/get-raw-email.js +338 -232
- package/lib/get-secret.js +1 -4
- package/lib/license-subscription.js +60 -0
- package/lib/load-env.js +48 -0
- package/lib/logger.js +1 -4
- package/lib/mcp/tools.js +244 -207
- package/lib/metric-values.js +76 -0
- package/lib/metrics.js +320 -0
- package/lib/oauth/gmail.js +39 -120
- package/lib/oauth/http-request.js +195 -0
- package/lib/oauth/mail-ru.js +24 -58
- package/lib/oauth/outlook.js +37 -137
- package/lib/oauth/pubsub/google.js +176 -117
- package/lib/oauth2-apps.js +440 -463
- package/lib/openapi/build-document.js +10 -10
- package/lib/read-env-value.js +1 -1
- package/lib/route-descriptors.js +78 -0
- package/lib/schemas.js +10 -1
- package/lib/sentry-integrations.js +299 -0
- package/lib/sentry.js +75 -27
- package/lib/sso-routes.js +249 -0
- package/lib/sso.js +29 -6
- package/lib/ui-routes/account-edit-form.js +198 -0
- package/lib/ui-routes/account-page.js +241 -0
- package/lib/ui-routes/account-routes.js +12 -318
- package/lib/ui-routes/auth-routes.js +10 -10
- package/lib/ui-view-context.js +328 -0
- package/lib/utils/public-suffix.js +22 -101
- package/lib/web-safe-html.js +20 -7
- package/lib/worker-metrics.js +82 -0
- package/list-generate.js +2 -5
- package/package.json +23 -19
- package/sbom.json +267 -908
- package/scripts/refresh-test-tokens.js +1 -1
- package/server.js +320 -676
- package/static/css/flyonui.css +1 -1
- package/static/css/src/app.tailwind.css +18 -0
- package/static/js/ee-client.js +2619 -645
- package/static/js/ui.js +12 -2
- package/static/licenses.html +219 -737
- package/translations/messages.pot +64 -53
- package/views/accounts/browse.hbs +19 -1
- package/workers/api.js +20 -451
- package/data/public_suffix_list.dat +0 -16698
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
* removed when they run out, which is how every earlier release behaved.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
const { compareVersions, parseVersion } = require('./utils/version');
|
|
20
|
+
|
|
19
21
|
const HOUR = 60 * 60 * 1000;
|
|
20
22
|
const DAY = 24 * HOUR;
|
|
21
23
|
|
|
@@ -154,6 +156,61 @@ function expiredSuspension(subexp, subsusp, now) {
|
|
|
154
156
|
return { code: 'SubscriptionInactive', error: 'Subscription inactive', since: new Date(deadline).toISOString() };
|
|
155
157
|
}
|
|
156
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Whether the record of the last successful validation no longer covers this instance, so the
|
|
161
|
+
* scheduled online check is allowed to run. It is covered while the version that validated (kv,
|
|
162
|
+
* hex) is this release or a later one and the record's own expiry (ks, hex ms) has not passed;
|
|
163
|
+
* an unreadable or missing record means checking again, which also rewrites it
|
|
164
|
+
* @param {Object} input
|
|
165
|
+
* @param {string|null} input.kv - the stored validated version
|
|
166
|
+
* @param {string|null} input.ks - the stored record expiry
|
|
167
|
+
* @param {string} input.version - the running version
|
|
168
|
+
* @param {number} input.now
|
|
169
|
+
* @returns {boolean}
|
|
170
|
+
*/
|
|
171
|
+
function needsVersionRecheck({ kv, ks, version, now }) {
|
|
172
|
+
if (!ks || typeof ks !== 'string' || new Date(parseInt(ks, 16)) < now) {
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
let validatedVersion = kv && typeof kv === 'string' ? Buffer.from(kv, 'hex').toString() : null;
|
|
176
|
+
return !(parseVersion(validatedVersion) && compareVersions(version, validatedVersion) <= 0);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Which license the periodic check concerns, and whether a passed deadline suspends it before
|
|
181
|
+
* the license server is asked
|
|
182
|
+
* @param {Object} licenseInfo - the running license state (`active`, `suspension`, `details`)
|
|
183
|
+
* @param {Object} input
|
|
184
|
+
* @param {number|string|null} input.subexp - the stored deadline
|
|
185
|
+
* @param {string|null} input.subsusp - the stored suspension
|
|
186
|
+
* @param {number} input.now
|
|
187
|
+
* @returns {{subscriptionLicense: boolean, localSuspension: (Object|null)}} subscriptionLicense says
|
|
188
|
+
* the online check applies (a suspended license is still registered and still checked, which is
|
|
189
|
+
* how it resumes); localSuspension is the suspension record to apply now, or null
|
|
190
|
+
*/
|
|
191
|
+
function subscriptionCheckState(licenseInfo, { subexp, subsusp, now }) {
|
|
192
|
+
let subscriptionLicense = (licenseInfo.active || !!licenseInfo.suspension) && isSubscriptionLicense(licenseInfo.details);
|
|
193
|
+
let localSuspension = subscriptionLicense && !licenseInfo.suspension ? expiredSuspension(subexp, subsusp, now) : null;
|
|
194
|
+
return { subscriptionLicense, localSuspension };
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* What a license check does to the licensed workers
|
|
199
|
+
* @param {boolean} licenseActive
|
|
200
|
+
* @param {number} suspendedTypes - how many worker types are suspended now
|
|
201
|
+
* @returns {'suspend'|'resume'|null} suspend every licensed worker type, respawn the suspended
|
|
202
|
+
* ones, or leave them as they are
|
|
203
|
+
*/
|
|
204
|
+
function workerSuspensionChange(licenseActive, suspendedTypes) {
|
|
205
|
+
if (!licenseActive && !suspendedTypes) {
|
|
206
|
+
return 'suspend';
|
|
207
|
+
}
|
|
208
|
+
if (licenseActive && suspendedTypes) {
|
|
209
|
+
return 'resume';
|
|
210
|
+
}
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
|
|
157
214
|
/**
|
|
158
215
|
* What a start of EmailEngine does before any worker runs
|
|
159
216
|
* @param {Object} input
|
|
@@ -230,6 +287,9 @@ module.exports = {
|
|
|
230
287
|
decide,
|
|
231
288
|
startupPlan,
|
|
232
289
|
expiredSuspension,
|
|
290
|
+
needsVersionRecheck,
|
|
291
|
+
subscriptionCheckState,
|
|
292
|
+
workerSuspensionChange,
|
|
233
293
|
checkInterval,
|
|
234
294
|
subscriptionView,
|
|
235
295
|
isSuspended,
|
package/lib/load-env.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Loads `.env` from the working directory into process.env with Node's own parser
|
|
4
|
+
// (process.loadEnvFile, Node 21.7+), which replaced the dotenv package. Variables that are
|
|
5
|
+
// already set are never overwritten, the same as dotenv did.
|
|
6
|
+
//
|
|
7
|
+
// Dependency-free on purpose: server.js loads it before it checks the Node.js version, so it has
|
|
8
|
+
// to load on any release. On a release without process.loadEnvFile it does nothing, and the
|
|
9
|
+
// version check that follows tells the operator to upgrade.
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Loads an env file, if there is one.
|
|
13
|
+
*
|
|
14
|
+
* A missing file is the normal case and is silent. A file that exists but cannot be read is
|
|
15
|
+
* reported on stderr and otherwise ignored, as dotenv ignored it: the instance then starts with
|
|
16
|
+
* the environment it was given rather than not at all.
|
|
17
|
+
*
|
|
18
|
+
* @param {string} [path='.env'] Resolved against the working directory
|
|
19
|
+
* @returns {boolean} Whether a file was loaded
|
|
20
|
+
*/
|
|
21
|
+
function loadEnvFile(path = '.env') {
|
|
22
|
+
if (typeof process.loadEnvFile !== 'function') {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
process.loadEnvFile(path);
|
|
27
|
+
return true;
|
|
28
|
+
} catch (err) {
|
|
29
|
+
if (err.code !== 'ENOENT') {
|
|
30
|
+
process.stderr.write(`Could not load ${path}: ${err.message}\n`);
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Loads `.env` once per process, however many modules ask. A worker thread starts with a copy of
|
|
38
|
+
* the main thread's process.env, marker included, so it does not load the file again; the tests set
|
|
39
|
+
* the marker themselves to keep a developer's own .env out of a child process.
|
|
40
|
+
*/
|
|
41
|
+
function loadEnvOnce() {
|
|
42
|
+
if (!process.env.EE_ENV_LOADED) {
|
|
43
|
+
loadEnvFile();
|
|
44
|
+
process.env.EE_ENV_LOADED = 'true';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = { loadEnvFile, loadEnvOnce };
|
package/lib/logger.js
CHANGED