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
|
@@ -462,6 +462,88 @@ async function resolveUsingSRV(email, ctx, domain, source) {
|
|
|
462
462
|
return { smtp, imap, _source: source || 'srv' };
|
|
463
463
|
}
|
|
464
464
|
|
|
465
|
+
// A fixed answer for a provider whose servers are the same for every custom domain. IMAP is always
|
|
466
|
+
// implicit TLS on 993; SMTP is implicit TLS on 465 and STARTTLS on 587.
|
|
467
|
+
function staticConfig(imapHost, smtpHost, smtpPort) {
|
|
468
|
+
return {
|
|
469
|
+
imap: {
|
|
470
|
+
host: imapHost,
|
|
471
|
+
port: 993,
|
|
472
|
+
secure: true
|
|
473
|
+
},
|
|
474
|
+
smtp: {
|
|
475
|
+
host: smtpHost,
|
|
476
|
+
port: smtpPort,
|
|
477
|
+
secure: smtpPort === 465
|
|
478
|
+
},
|
|
479
|
+
_source: 'mx'
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
// Well known MX servers, checked in order and the first match wins. `match` is a pattern, or a
|
|
484
|
+
// string the exchange has to equal. An entry answers with `config` (static, built fresh for every
|
|
485
|
+
// lookup), `resolve` (delegates to another resolver) or `build` (derived from the match).
|
|
486
|
+
const MX_PROVIDERS = [
|
|
487
|
+
{ match: /\bl\.google\.com$/i, resolve: (email, ctx) => resolveUsingSRV(email, ctx, 'gmail.com', 'mx') },
|
|
488
|
+
{ match: /\bmx\.yandex\.net$/i, resolve: (email, ctx) => resolveUsingAutoconfig(email, ctx, 'yandex.ru', 'mx') },
|
|
489
|
+
// Zone.eu
|
|
490
|
+
{ match: /^mx\d*\.zone\.eu$/i, config: ['mail.zone.ee', 'smtp.zone.ee', 465] },
|
|
491
|
+
// Lark Mail / ByteDance
|
|
492
|
+
{ match: /\blarksuite\.com$/i, config: ['imap.larksuite.com', 'smtp.larksuite.com', 465] },
|
|
493
|
+
{ match: /\bzonemx\.eu$/i, resolve: (email, ctx) => resolveUsingAutoconfig(email, ctx, 'zone.ee', 'mx') },
|
|
494
|
+
// AWS WorkMail
|
|
495
|
+
{
|
|
496
|
+
match: /^inbound-smtp\.([^.]+)\.amazonaws\.com$/,
|
|
497
|
+
build: awsMatch => {
|
|
498
|
+
let region = awsMatch[1].toLowerCase().trim();
|
|
499
|
+
return staticConfig(`imap.mail.${region}.awsapps.com`, `smtp.mail.${region}.awsapps.com`, 465);
|
|
500
|
+
}
|
|
501
|
+
},
|
|
502
|
+
// Zoho custom domain in EU
|
|
503
|
+
{ match: /^mx\d*\.zoho\.eu$/i, config: ['imappro.zoho.eu', 'smtppro.zoho.eu', 465] },
|
|
504
|
+
// Zoho custom domain not in EU
|
|
505
|
+
{ match: /^mx\d*\.zoho\.com$/i, config: ['imappro.zoho.com', 'smtppro.zoho.com', 465] },
|
|
506
|
+
// MS365: as autodiscovery is currently (2021-11-17) closed use a fixed response
|
|
507
|
+
{ match: /\bprotection\.outlook\.com$/i, config: ['outlook.office365.com', 'smtp.office365.com', 587] },
|
|
508
|
+
// Inbox.com
|
|
509
|
+
{ match: 'mx.dka.mailcore.net', config: ['imap.dka.mailcore.net', 'smtp.dka.mailcore.net', 587] },
|
|
510
|
+
{ match: 'ekiri.ee', config: ['turvaline.ekiri.ee', 'turvaline.ekiri.ee', 465] },
|
|
511
|
+
// Alibaba Mail
|
|
512
|
+
{ match: /^mx\d*\.sg\.aliyun\.com$/i, config: ['imap.sg.aliyun.com', 'smtp.sg.aliyun.com', 465] },
|
|
513
|
+
// ATT
|
|
514
|
+
{ match: /mx-vip\d*\.prodigy\.net$/i, config: ['imap.mail.att.net', 'smtp.mail.att.net', 465] },
|
|
515
|
+
// Naver (kr)
|
|
516
|
+
{ match: /^mx\d*\.naver\.com$/i, config: ['imap.naver.com', 'smtp.naver.com', 587] },
|
|
517
|
+
// QQ enterprise
|
|
518
|
+
{ match: /^mxbiz\d*\.qq\.com$/i, config: ['imap.exmail.qq.com', 'smtp.exmail.qq.com', 465] }
|
|
519
|
+
];
|
|
520
|
+
|
|
521
|
+
function matchMxProvider(provider, exchange) {
|
|
522
|
+
if (typeof provider.match === 'string') {
|
|
523
|
+
return exchange === provider.match ? [exchange] : null;
|
|
524
|
+
}
|
|
525
|
+
return provider.match.exec(exchange);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// Resolves the configuration of the first provider the exchange matches, or throws "Nothing found"
|
|
529
|
+
// carrying the exchange, which is what the app-password hint is matched on
|
|
530
|
+
async function resolveMxProviderConfig(email, ctx, exchange) {
|
|
531
|
+
const provider = MX_PROVIDERS.find(entry => matchMxProvider(entry, exchange));
|
|
532
|
+
if (!provider) {
|
|
533
|
+
let error = new Error('Nothing found');
|
|
534
|
+
error.exchange = exchange;
|
|
535
|
+
throw error;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
if (provider.resolve) {
|
|
539
|
+
return await provider.resolve(email, ctx);
|
|
540
|
+
}
|
|
541
|
+
if (provider.build) {
|
|
542
|
+
return provider.build(matchMxProvider(provider, exchange));
|
|
543
|
+
}
|
|
544
|
+
return staticConfig(...provider.config);
|
|
545
|
+
}
|
|
546
|
+
|
|
465
547
|
async function resolveUsingMX(email, ctx, gt) {
|
|
466
548
|
let domain = email.split('@').pop().trim().toLowerCase();
|
|
467
549
|
|
|
@@ -474,240 +556,7 @@ async function resolveUsingMX(email, ctx, gt) {
|
|
|
474
556
|
// do not catch potential error as there's nothing to do if we do not find the MX record
|
|
475
557
|
let exchange = await resolveExchange(domain, ctx.dns);
|
|
476
558
|
|
|
477
|
-
let
|
|
478
|
-
// look for some well known MX servers
|
|
479
|
-
if (/\bl\.google\.com$/i.test(exchange)) {
|
|
480
|
-
return await resolveUsingSRV(email, ctx, 'gmail.com', 'mx');
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
if (/\bmx\.yandex\.net$/i.test(exchange)) {
|
|
484
|
-
return await resolveUsingAutoconfig(email, ctx, 'yandex.ru', 'mx');
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
if (/^mx\d*\.zone\.eu$/i.test(exchange)) {
|
|
488
|
-
// Zoho custom domain not in EU
|
|
489
|
-
return {
|
|
490
|
-
imap: {
|
|
491
|
-
host: 'mail.zone.ee',
|
|
492
|
-
port: 993,
|
|
493
|
-
secure: true
|
|
494
|
-
},
|
|
495
|
-
smtp: {
|
|
496
|
-
host: 'smtp.zone.ee',
|
|
497
|
-
port: 465,
|
|
498
|
-
secure: true
|
|
499
|
-
},
|
|
500
|
-
_source: 'mx'
|
|
501
|
-
};
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
if (/\blarksuite\.com$/i.test(exchange)) {
|
|
505
|
-
// Lark Mail / ByteDance
|
|
506
|
-
return {
|
|
507
|
-
imap: {
|
|
508
|
-
host: 'imap.larksuite.com',
|
|
509
|
-
port: 993,
|
|
510
|
-
secure: true
|
|
511
|
-
},
|
|
512
|
-
smtp: {
|
|
513
|
-
host: 'smtp.larksuite.com',
|
|
514
|
-
port: 465,
|
|
515
|
-
secure: true
|
|
516
|
-
},
|
|
517
|
-
_source: 'mx'
|
|
518
|
-
};
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
if (/\bzonemx\.eu$/i.test(exchange)) {
|
|
522
|
-
return await resolveUsingAutoconfig(email, ctx, 'zone.ee', 'mx');
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
// AWS WorkMail
|
|
526
|
-
let awsMatch = exchange.match(/inbound-smtp\.([^.]+)\.amazonaws.com/);
|
|
527
|
-
if (awsMatch) {
|
|
528
|
-
let region = awsMatch[1].toLowerCase().trim();
|
|
529
|
-
return {
|
|
530
|
-
imap: {
|
|
531
|
-
host: `imap.mail.${region}.awsapps.com`,
|
|
532
|
-
port: 993,
|
|
533
|
-
secure: true
|
|
534
|
-
},
|
|
535
|
-
smtp: {
|
|
536
|
-
host: `smtp.mail.${region}.awsapps.com`,
|
|
537
|
-
port: 465,
|
|
538
|
-
secure: true
|
|
539
|
-
},
|
|
540
|
-
_source: 'mx'
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
// Zoho EU
|
|
545
|
-
if (/^mx\d*\.zoho\.eu$/i.test(exchange)) {
|
|
546
|
-
// Zoho custom domain in EU
|
|
547
|
-
return {
|
|
548
|
-
imap: {
|
|
549
|
-
host: 'imappro.zoho.eu',
|
|
550
|
-
port: 993,
|
|
551
|
-
secure: true
|
|
552
|
-
},
|
|
553
|
-
smtp: {
|
|
554
|
-
host: 'smtppro.zoho.eu',
|
|
555
|
-
port: 465,
|
|
556
|
-
secure: true
|
|
557
|
-
},
|
|
558
|
-
_source: 'mx'
|
|
559
|
-
};
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
// Zoho international
|
|
563
|
-
if (/^mx\d*\.zoho\.com$/i.test(exchange)) {
|
|
564
|
-
// Zoho custom domain not in EU
|
|
565
|
-
return {
|
|
566
|
-
imap: {
|
|
567
|
-
host: 'imappro.zoho.com',
|
|
568
|
-
port: 993,
|
|
569
|
-
secure: true
|
|
570
|
-
},
|
|
571
|
-
smtp: {
|
|
572
|
-
host: 'smtppro.zoho.com',
|
|
573
|
-
port: 465,
|
|
574
|
-
secure: true
|
|
575
|
-
},
|
|
576
|
-
_source: 'mx'
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
// MS365
|
|
581
|
-
if (/\bprotection\.outlook\.com$/i.test(exchange)) {
|
|
582
|
-
// outlook
|
|
583
|
-
// as autodiscovery is currently (2021-11-17) closed use a fixed response
|
|
584
|
-
return {
|
|
585
|
-
imap: {
|
|
586
|
-
host: 'outlook.office365.com',
|
|
587
|
-
port: 993,
|
|
588
|
-
secure: true
|
|
589
|
-
},
|
|
590
|
-
smtp: {
|
|
591
|
-
host: 'smtp.office365.com',
|
|
592
|
-
port: 587,
|
|
593
|
-
secure: false
|
|
594
|
-
},
|
|
595
|
-
_source: 'mx'
|
|
596
|
-
};
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
// Inbox.com
|
|
600
|
-
if (exchange === 'mx.dka.mailcore.net') {
|
|
601
|
-
return {
|
|
602
|
-
imap: {
|
|
603
|
-
host: 'imap.dka.mailcore.net',
|
|
604
|
-
port: 993,
|
|
605
|
-
secure: true
|
|
606
|
-
},
|
|
607
|
-
smtp: {
|
|
608
|
-
host: 'smtp.dka.mailcore.net',
|
|
609
|
-
port: 587,
|
|
610
|
-
secure: false
|
|
611
|
-
},
|
|
612
|
-
_source: 'mx'
|
|
613
|
-
};
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
if (exchange === 'ekiri.ee') {
|
|
617
|
-
return {
|
|
618
|
-
imap: {
|
|
619
|
-
host: `turvaline.ekiri.ee`,
|
|
620
|
-
port: 993,
|
|
621
|
-
secure: true
|
|
622
|
-
},
|
|
623
|
-
smtp: {
|
|
624
|
-
host: `turvaline.ekiri.ee`,
|
|
625
|
-
port: 465,
|
|
626
|
-
secure: true
|
|
627
|
-
},
|
|
628
|
-
_source: 'mx'
|
|
629
|
-
};
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
// Alibaba Mail
|
|
633
|
-
if (/^mx\d*\.sg\.aliyun\.com$/i.test(exchange)) {
|
|
634
|
-
// Naver.com
|
|
635
|
-
return {
|
|
636
|
-
imap: {
|
|
637
|
-
host: 'imap.sg.aliyun.com',
|
|
638
|
-
port: 993,
|
|
639
|
-
secure: true
|
|
640
|
-
},
|
|
641
|
-
smtp: {
|
|
642
|
-
host: 'smtp.sg.aliyun.com',
|
|
643
|
-
port: 465,
|
|
644
|
-
secure: true
|
|
645
|
-
},
|
|
646
|
-
_source: 'mx'
|
|
647
|
-
};
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
// ATT
|
|
651
|
-
if (/mx-vip\d*\.prodigy\.net$/i.test(exchange)) {
|
|
652
|
-
// ATT
|
|
653
|
-
return {
|
|
654
|
-
imap: {
|
|
655
|
-
host: 'imap.mail.att.net',
|
|
656
|
-
port: 993,
|
|
657
|
-
secure: true
|
|
658
|
-
},
|
|
659
|
-
smtp: {
|
|
660
|
-
host: 'smtp.mail.att.net',
|
|
661
|
-
port: 465,
|
|
662
|
-
secure: true
|
|
663
|
-
},
|
|
664
|
-
_source: 'mx'
|
|
665
|
-
};
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
// Naver (kr)
|
|
669
|
-
if (/^mx\d*\.naver\.com$/i.test(exchange)) {
|
|
670
|
-
// Naver.com
|
|
671
|
-
return {
|
|
672
|
-
imap: {
|
|
673
|
-
host: 'imap.naver.com',
|
|
674
|
-
port: 993,
|
|
675
|
-
secure: true
|
|
676
|
-
},
|
|
677
|
-
smtp: {
|
|
678
|
-
host: 'smtp.naver.com',
|
|
679
|
-
port: 587,
|
|
680
|
-
secure: false
|
|
681
|
-
},
|
|
682
|
-
_source: 'mx'
|
|
683
|
-
};
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
// QQ enterprise
|
|
687
|
-
if (/^mxbiz\d*\.qq\.com$/i.test(exchange)) {
|
|
688
|
-
// Naver.com
|
|
689
|
-
return {
|
|
690
|
-
imap: {
|
|
691
|
-
host: 'imap.exmail.qq.com',
|
|
692
|
-
port: 993,
|
|
693
|
-
secure: true
|
|
694
|
-
},
|
|
695
|
-
smtp: {
|
|
696
|
-
host: 'smtp.exmail.qq.com',
|
|
697
|
-
port: 465,
|
|
698
|
-
secure: true
|
|
699
|
-
},
|
|
700
|
-
_source: 'mx'
|
|
701
|
-
};
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
let error = new Error('Nothing found');
|
|
705
|
-
error.exchange = exchange;
|
|
706
|
-
|
|
707
|
-
throw error;
|
|
708
|
-
};
|
|
709
|
-
|
|
710
|
-
let accountConfig = await resolveConfig();
|
|
559
|
+
let accountConfig = await resolveMxProviderConfig(email, ctx, exchange);
|
|
711
560
|
|
|
712
561
|
if (!hasResolvedHost(accountConfig)) {
|
|
713
562
|
// The exchange matched, but the config it delegated to named no server: the Gmail branch
|
package/lib/consts.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const dotenv = require('dotenv');
|
|
4
3
|
const { readEnvValue } = require('./read-env-value');
|
|
5
4
|
const { REDACTED_LOG_KEYS, TRANSIENT_NETWORK_CODES } = require('./logger-consts');
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
dotenv.config({ quiet: true });
|
|
9
|
-
process.env.EE_ENV_LOADED = 'true';
|
|
10
|
-
}
|
|
6
|
+
require('./load-env').loadEnvOnce();
|
|
11
7
|
|
|
12
8
|
module.exports = {
|
|
13
9
|
MESSAGE_NEW_NOTIFY: 'messageNew',
|
package/lib/db.js
CHANGED