emailengine-app 2.81.2 → 2.82.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 +12 -11
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +27 -0
- package/Dockerfile +2 -0
- package/bin/emailengine.js +28 -18
- package/config/default.toml +0 -5
- package/config/test.toml +0 -5
- package/data/google-crawlers.json +1 -1
- package/encrypt.js +70 -42
- package/getswagger.sh +0 -4
- package/lib/account/account-state.js +2 -110
- package/lib/account/expected-identity.js +1 -1
- package/lib/account-assignment.js +138 -1
- package/lib/account.js +254 -859
- package/lib/api-reference/index.js +2 -3
- package/lib/api-reference/schema-tree.js +53 -3
- package/lib/api-routes/account-routes.js +18 -29
- package/lib/api-routes/blocklist-routes.js +2 -2
- package/lib/api-routes/bull-board-routes.js +1 -6
- package/lib/api-routes/export-routes.js +2 -22
- package/lib/api-routes/gateway-routes.js +5 -14
- package/lib/api-routes/index.js +1 -13
- package/lib/api-routes/mailbox-routes.js +2 -7
- package/lib/api-routes/mcp-oauth-routes.js +2 -1
- package/lib/api-routes/mcp-routes.js +7 -7
- package/lib/api-routes/message-routes.js +40 -235
- package/lib/api-routes/mint-bounds.js +110 -0
- package/lib/api-routes/oauth2-app-routes.js +23 -32
- package/lib/api-routes/operation-impact.js +1 -1
- package/lib/api-routes/outbox-routes.js +2 -2
- package/lib/api-routes/permission-map.js +1 -7
- package/lib/api-routes/route-helpers.js +11 -5
- package/lib/api-routes/settings-routes.js +19 -19
- package/lib/api-routes/stats-routes.js +1 -1
- package/lib/api-routes/submit-routes.js +17 -18
- package/lib/api-routes/template-routes.js +4 -9
- package/lib/api-routes/token-routes.js +27 -5
- package/lib/api-token-scheme.js +71 -0
- package/lib/arf-detect.js +33 -6
- package/lib/auth-token.js +44 -24
- package/lib/autodetect-imap-settings.js +163 -123
- package/lib/bounce-detect.js +25 -16
- package/lib/calendar-event.js +78 -0
- package/lib/consts.js +42 -5
- package/lib/create-imap-client.js +24 -0
- package/lib/db.js +76 -11
- package/lib/delivery-error.js +2 -1
- package/lib/egress-fetch.js +54 -3
- package/lib/egress-filter.js +11 -0
- package/lib/email-client/api-retry.js +147 -0
- package/lib/email-client/base-client.js +377 -523
- package/lib/email-client/gmail/gmail-api.js +38 -125
- package/lib/email-client/gmail/send-request.js +1 -1
- package/lib/email-client/gmail-client.js +76 -50
- package/lib/email-client/imap/mailbox.js +158 -324
- package/lib/email-client/imap/stale-view.js +109 -0
- package/lib/email-client/imap/subconnection.js +46 -9
- package/lib/email-client/imap/sync-operations.js +5 -37
- package/lib/email-client/imap-client.js +188 -64
- package/lib/email-client/message-builder.js +9 -14
- package/lib/email-client/notification-handler.js +5 -219
- package/lib/email-client/outlook/graph-api.js +147 -126
- package/lib/email-client/outlook/send-request.js +10 -4
- package/lib/email-client/outlook-client.js +194 -397
- package/lib/email-client/smtp-pool-manager.js +3 -2
- package/lib/encrypt.js +184 -19
- package/lib/enum-descriptions.js +1 -2
- package/lib/export.js +133 -39
- package/lib/gateway.js +20 -6
- package/lib/get-raw-email.js +26 -44
- package/lib/handlebars-helpers.js +31 -10
- package/lib/imap-proxy-auth.js +13 -29
- package/lib/imapproxy/imap-core/README.md +1 -0
- package/lib/imapproxy/imap-core/lib/handler/imap-parser.js +12 -0
- package/lib/imapproxy/imap-core/lib/imap-command.js +74 -10
- package/lib/imapproxy/imap-core/lib/imap-connection.js +9 -1
- package/lib/imapproxy/imap-core/lib/imap-server.js +112 -26
- package/lib/imapproxy/imap-core/lib/imap-stream.js +41 -1
- package/lib/imapproxy/imap-core/lib/imap-tools.js +10 -2
- package/lib/imapproxy/imap-core/lib/indexer/indexer.js +4 -2
- package/lib/imapproxy/imap-server.js +17 -177
- package/lib/imapproxy/proxy-handoff.js +235 -0
- package/lib/imapproxy/response-error.js +33 -0
- package/lib/imapproxy/upstream-client.js +2 -2
- package/lib/license-beacon.js +3 -9
- package/lib/llm-pre-process.js +182 -43
- package/lib/logger.js +1 -1
- package/lib/lua/ee-export-queue-add.lua +39 -0
- package/lib/lua/ee-get-idempotency.lua +15 -3
- package/lib/lua/ee-release-attempts.lua +23 -0
- package/lib/lua/ee-reserve-attempts.lua +42 -0
- package/lib/lua/h-set-bigger.lua +12 -2
- package/lib/lua/s-list-accounts.lua +6 -3
- package/lib/mcp/index.js +1 -2
- package/lib/mcp/listen.js +221 -18
- package/lib/mcp/oauth.js +44 -5
- package/lib/mcp/resources.js +8 -2
- package/lib/mcp/tools.js +13 -0
- package/lib/message-port-stream.js +64 -6
- package/lib/oauth/external-account-signer.js +16 -13
- package/lib/oauth/gmail.js +22 -20
- package/lib/oauth/outlook.js +19 -16
- package/lib/oauth/pubsub/google.js +38 -2
- package/lib/oauth/scope-checker.js +4 -7
- package/lib/oauth/verify-app.js +2 -2
- package/lib/oauth2-apps.js +139 -44
- package/lib/openapi/build-document.js +1 -1
- package/lib/openapi/joi-schema.js +78 -9
- package/lib/parse-message.js +21 -0
- package/lib/payload-examples-webhooks.json +4 -7
- package/lib/pbkdf2-phc.js +101 -0
- package/lib/privileged-settings.js +0 -14
- package/lib/rate-limit.js +54 -15
- package/lib/redis-scan-delete.js +56 -29
- package/lib/redis-url.js +3 -1
- package/lib/respawn-backoff.js +5 -4
- package/lib/response-stream.js +25 -4
- package/lib/rewrite-text-nodes.js +27 -40
- package/lib/routes-ui.js +0 -5
- package/lib/schemas.js +122 -242
- package/lib/sentry.js +21 -5
- package/lib/settings.js +58 -59
- package/lib/smtp-auth.js +6 -2
- package/lib/smtp-message-processor.js +28 -7
- package/lib/sso.js +7 -3
- package/lib/stream-encrypt.js +14 -13
- package/lib/swagger-options.js +3 -1
- package/lib/tls/provision.js +69 -3
- package/lib/tls/store.js +14 -1
- package/lib/tools.js +113 -52
- package/lib/totp.js +16 -1
- package/lib/ui-routes/account-routes.js +27 -63
- package/lib/ui-routes/admin-config-routes.js +111 -134
- package/lib/ui-routes/admin-entities-routes.js +101 -191
- package/lib/ui-routes/ai-options.js +104 -0
- package/lib/ui-routes/auth-routes.js +98 -18
- package/lib/ui-routes/export-routes.js +3 -23
- package/lib/ui-routes/internals-routes.js +12 -9
- package/lib/ui-routes/network-config-routes.js +8 -18
- package/lib/ui-routes/oauth-config-routes.js +80 -214
- package/lib/ui-routes/route-helpers.js +40 -44
- package/lib/ui-routes/unsubscribe-routes.js +2 -2
- package/lib/utils/decode-headers.js +32 -5
- package/lib/utils/header-map.js +62 -1
- package/lib/utils/network.js +2 -0
- package/lib/web-safe-html.js +77 -4
- package/lib/webhook-request.js +9 -1
- package/lib/webhook-routing.js +27 -1
- package/lib/webhooks.js +120 -43
- package/lib/worker-rpc-error.js +43 -2
- package/list-generate.js +13 -2
- package/package.json +33 -41
- package/sbom.json +1 -1
- package/scripts/refresh-test-tokens.js +42 -14
- package/server.js +317 -289
- package/static/css/flyonui.css +1 -1
- package/static/css/src/app.tailwind.css +7 -8
- package/static/js/ee-client.js +145 -70
- package/static/js/ui.js +350 -154
- package/static/licenses.html +434 -1835
- package/translations/messages.pot +97 -97
- package/views/accounts/browse.hbs +10 -4
- package/views/config/ai.hbs +49 -41
- package/views/config/oauth/app.hbs +2 -1
- package/views/dashboard.hbs +18 -16
- package/views/layout/app.hbs +0 -22
- package/views/layout/login.hbs +2 -1
- package/views/partials/filter_editor_js.hbs +4 -3
- package/views/partials/side_menu.hbs +0 -4
- package/views/partials/ui/account-picker.hbs +6 -32
- package/views/partials/ui/model-picker.hbs +31 -0
- package/views/partials/ui/pagination.hbs +6 -1
- package/views/partials/ui/picker.hbs +47 -0
- package/views/unsubscribe.hbs +1 -1
- package/workers/api.js +20 -20
- package/workers/export.js +55 -60
- package/workers/imap.js +126 -46
- package/workers/submit.js +3 -1
- package/workers/webhooks.js +46 -27
- package/.githooks/pre-commit +0 -80
- package/.github/CODE_OF_CONDUCT.md +0 -76
- package/.github/contributing.md +0 -17
- package/.github/dependabot.yml +0 -22
- package/.github/docker-smoke-test.sh +0 -61
- package/.github/workflows/deploy.yml +0 -215
- package/.github/workflows/e2e.yml +0 -55
- package/.github/workflows/release.yaml +0 -217
- package/.github/workflows/test.yml +0 -307
- package/lib/api-routes/chat-routes.js +0 -535
- package/lib/document-store.js +0 -75
- package/lib/es.js +0 -757
- package/lib/generate-text-preview.js +0 -61
- package/lib/imapproxy/imap-core/memory-notifier.js +0 -129
- package/lib/pre-process.js +0 -196
- package/lib/threads.js +0 -155
- package/lib/ui-routes/document-store-routes.js +0 -806
- package/playwright.config.js +0 -47
- package/views/config/document-store/chat.hbs +0 -286
- package/views/config/document-store/index.hbs +0 -146
- package/views/config/document-store/mappings/index.hbs +0 -108
- package/views/config/document-store/mappings/new.hbs +0 -68
- package/views/config/document-store/pre-processing/index.hbs +0 -103
- package/views/partials/document_store_header.hbs +0 -30
- package/workers/documents.js +0 -1128
|
@@ -145,9 +145,8 @@ function jsonForScript(value) {
|
|
|
145
145
|
// halves the payload since the operation id is already the key.
|
|
146
146
|
//
|
|
147
147
|
// The lookup is keyed on the operation id alone, deliberately ignoring the tag in the old
|
|
148
|
-
// hash - tags get renamed
|
|
149
|
-
//
|
|
150
|
-
// second chance for a link whose operation no longer exists but whose group still does.
|
|
148
|
+
// hash - tags get renamed, which would strand every link that named the old one. The tag table
|
|
149
|
+
// is only a second chance for a link whose operation no longer exists but whose group still does.
|
|
151
150
|
let redirectMapJson;
|
|
152
151
|
|
|
153
152
|
async function getRedirectView(request) {
|
|
@@ -65,6 +65,34 @@ function lookupRef(spec, ref) {
|
|
|
65
65
|
return (spec.components && spec.components.schemas && spec.components.schemas[name]) || null;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
// A branch that only lists primitive values of one type, as lib/openapi/joi-schema.js
|
|
69
|
+
// withForeignValues() emits for an allowed value of another type than the schema's own
|
|
70
|
+
function isSentinelBranch(branch) {
|
|
71
|
+
return (
|
|
72
|
+
!!branch &&
|
|
73
|
+
typeof branch === 'object' &&
|
|
74
|
+
Object.keys(branch).length === 2 &&
|
|
75
|
+
['boolean', 'number', 'string'].includes(branch.type) &&
|
|
76
|
+
Array.isArray(branch.enum) &&
|
|
77
|
+
branch.enum.length > 0
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Splits `anyOf: [schema, ...sentinel branches]` into the schema and the sentinel values, or
|
|
82
|
+
// returns null for any other shape (a real alternatives list stays a list of variants)
|
|
83
|
+
function sentinelFold(schema) {
|
|
84
|
+
if (!schema || typeof schema !== 'object' || !Array.isArray(schema.anyOf) || schema.anyOf.length < 2) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const [main, ...rest] = schema.anyOf;
|
|
89
|
+
if (isSentinelBranch(main) || !rest.every(isSentinelBranch)) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return { main, sentinels: rest.flatMap(branch => branch.enum) };
|
|
94
|
+
}
|
|
95
|
+
|
|
68
96
|
// Follows a $ref chain to the underlying schema. `refStack` carries the refs already
|
|
69
97
|
// visited on the current branch; revisiting one means the document is recursive, which
|
|
70
98
|
// is reported rather than followed.
|
|
@@ -87,6 +115,28 @@ function resolve(spec, schema, refStack) {
|
|
|
87
115
|
current = target;
|
|
88
116
|
}
|
|
89
117
|
|
|
118
|
+
// The generator publishes `.allow(false)` beside an object or a string as
|
|
119
|
+
// `anyOf: [schema, {type: 'boolean', enum: [false]}]`, which is what a strict validator
|
|
120
|
+
// needs. A reader is better served by the schema itself with the sentinel on its own
|
|
121
|
+
// "also accepts" line, so the pair is folded back into the enum form enumInfo() splits.
|
|
122
|
+
const fold = sentinelFold(current);
|
|
123
|
+
if (fold) {
|
|
124
|
+
const inner = resolve(spec, fold.main, stack);
|
|
125
|
+
if (!inner.schema || typeof inner.schema !== 'object') {
|
|
126
|
+
return inner;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const merged = Object.assign({}, inner.schema);
|
|
130
|
+
for (const key of Object.keys(current)) {
|
|
131
|
+
if (key !== 'anyOf') {
|
|
132
|
+
merged[key] = current[key];
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
merged.enum = (Array.isArray(inner.schema.enum) ? inner.schema.enum : []).concat(fold.sentinels);
|
|
136
|
+
|
|
137
|
+
return { schema: merged, refStack: inner.refStack };
|
|
138
|
+
}
|
|
139
|
+
|
|
90
140
|
return { schema: current, refStack: stack };
|
|
91
141
|
}
|
|
92
142
|
|
|
@@ -147,9 +197,9 @@ function matchesType(type, value) {
|
|
|
147
197
|
// Returns null when the schema is not an enum, so callers can assign both fields in one go.
|
|
148
198
|
//
|
|
149
199
|
// The enum is split by whether a value can be an instance of the schema's own type.
|
|
150
|
-
//
|
|
151
|
-
//
|
|
152
|
-
//
|
|
200
|
+
// A joi `.allow(false)` beside a `string`, `integer` or `object` type reaches here in the enum:
|
|
201
|
+
// the document publishes it as a separate anyOf branch, which resolve() folds back into the
|
|
202
|
+
// enum for rendering. Those are sentinels standing next to the type, not
|
|
153
203
|
// its value domain: `false` clears the block on an update payload and means "not available"
|
|
154
204
|
// on a response. Rendered through the normal "Allowed" row they claimed the only value an
|
|
155
205
|
// IMAP configuration object accepts is `false`. `alsoAccepts` gets its own line instead.
|
|
@@ -30,7 +30,8 @@ const {
|
|
|
30
30
|
shortMailboxesSchema,
|
|
31
31
|
ACCOUNT_DISPLAY_STATES,
|
|
32
32
|
apiResponses,
|
|
33
|
-
ENUM_DESCRIPTIONS
|
|
33
|
+
ENUM_DESCRIPTIONS,
|
|
34
|
+
apiBoolean
|
|
34
35
|
} = require('../schemas');
|
|
35
36
|
|
|
36
37
|
const { REDIS_PREFIX, MAX_FORM_TTL, NONCE_BYTES, MCP_MAX_PAGE_SIZE } = require('../consts');
|
|
@@ -158,7 +159,6 @@ async function init(args) {
|
|
|
158
159
|
const {
|
|
159
160
|
server,
|
|
160
161
|
call,
|
|
161
|
-
documentsQueue,
|
|
162
162
|
oauth2Schema: oauth2SchemaArg,
|
|
163
163
|
imapSchema: imapSchemaArg,
|
|
164
164
|
smtpSchema: smtpSchemaArg,
|
|
@@ -338,7 +338,7 @@ async function init(args) {
|
|
|
338
338
|
logs: Joi.boolean().example(false).description('Store recent logs').default(false),
|
|
339
339
|
|
|
340
340
|
notifyFrom: accountSchemas.notifyFrom.default('now'),
|
|
341
|
-
syncFrom: accountSchemas.syncFrom
|
|
341
|
+
syncFrom: accountSchemas.syncFrom,
|
|
342
342
|
|
|
343
343
|
proxy: settingsSchema.proxyUrl,
|
|
344
344
|
smtpEhloName: settingsSchema.smtpEhloName,
|
|
@@ -621,13 +621,13 @@ async function init(args) {
|
|
|
621
621
|
}),
|
|
622
622
|
|
|
623
623
|
payload: Joi.object({
|
|
624
|
-
reconnect:
|
|
624
|
+
reconnect: apiBoolean().default(false).description('Only reconnect if true')
|
|
625
625
|
}).label('RequestReconnect')
|
|
626
626
|
},
|
|
627
627
|
|
|
628
628
|
response: {
|
|
629
629
|
schema: Joi.object({
|
|
630
|
-
reconnect:
|
|
630
|
+
reconnect: apiBoolean().default(false).description('Reconnection status')
|
|
631
631
|
}).label('RequestReconnectResponse'),
|
|
632
632
|
failAction: 'log'
|
|
633
633
|
}
|
|
@@ -700,13 +700,13 @@ async function init(args) {
|
|
|
700
700
|
}),
|
|
701
701
|
|
|
702
702
|
payload: Joi.object({
|
|
703
|
-
sync:
|
|
703
|
+
sync: apiBoolean().default(false).description('Only sync if true')
|
|
704
704
|
}).label('RequestSync')
|
|
705
705
|
},
|
|
706
706
|
|
|
707
707
|
response: {
|
|
708
708
|
schema: Joi.object({
|
|
709
|
-
sync:
|
|
709
|
+
sync: apiBoolean().default(false).description('Sync status')
|
|
710
710
|
}).label('RequestSyncResponse'),
|
|
711
711
|
failAction: 'log'
|
|
712
712
|
}
|
|
@@ -722,7 +722,6 @@ async function init(args) {
|
|
|
722
722
|
let accountObject = new Account({
|
|
723
723
|
redis,
|
|
724
724
|
account: request.params.account,
|
|
725
|
-
documentsQueue,
|
|
726
725
|
call,
|
|
727
726
|
secret: await getSecret(),
|
|
728
727
|
timeout: request.headers['x-ee-timeout']
|
|
@@ -784,9 +783,7 @@ async function init(args) {
|
|
|
784
783
|
}),
|
|
785
784
|
|
|
786
785
|
query: Joi.object({
|
|
787
|
-
revoke:
|
|
788
|
-
.truthy('Y', 'true', '1')
|
|
789
|
-
.falsy('N', 'false', 0)
|
|
786
|
+
revoke: apiBoolean()
|
|
790
787
|
.default(false)
|
|
791
788
|
.description('Revoke the upstream OAuth2 grant at the provider before deleting the account')
|
|
792
789
|
.meta({ usage: FIELD_USAGE.revokeGrant })
|
|
@@ -796,7 +793,7 @@ async function init(args) {
|
|
|
796
793
|
response: {
|
|
797
794
|
schema: Joi.object({
|
|
798
795
|
account: accountIdSchema.required(),
|
|
799
|
-
deleted:
|
|
796
|
+
deleted: apiBoolean().default(true).description('Was the account deleted')
|
|
800
797
|
}).label('DeleteAccountResponse'),
|
|
801
798
|
failAction: 'log'
|
|
802
799
|
}
|
|
@@ -808,13 +805,12 @@ async function init(args) {
|
|
|
808
805
|
method: 'PUT',
|
|
809
806
|
path: '/v1/account/{account}/flush',
|
|
810
807
|
|
|
811
|
-
async handler(request
|
|
808
|
+
async handler(request) {
|
|
812
809
|
let accountObject = new Account({
|
|
813
810
|
redis,
|
|
814
811
|
account: request.params.account,
|
|
815
812
|
call,
|
|
816
813
|
secret: await getSecret(),
|
|
817
|
-
esClient: await h.getESClient(request.logger),
|
|
818
814
|
timeout: request.headers['x-ee-timeout']
|
|
819
815
|
});
|
|
820
816
|
|
|
@@ -827,7 +823,7 @@ async function init(args) {
|
|
|
827
823
|
options: {
|
|
828
824
|
description: 'Request account flush',
|
|
829
825
|
notes: [
|
|
830
|
-
'Deletes all email indexes from Redis and
|
|
826
|
+
'Deletes all email indexes from Redis and re-creates the index for that account. You can only run a single flush operation at a time, so you must wait until the previous flush has finished before initiating a new one.',
|
|
831
827
|
BEHAVIOR.SCHEDULED_ON_WORKER
|
|
832
828
|
],
|
|
833
829
|
tags: ['api', 'Account'],
|
|
@@ -875,7 +871,7 @@ async function init(args) {
|
|
|
875
871
|
}),
|
|
876
872
|
|
|
877
873
|
payload: Joi.object({
|
|
878
|
-
flush:
|
|
874
|
+
flush: apiBoolean().default(false).description('Only flush the account if true'),
|
|
879
875
|
notifyFrom: accountSchemas.notifyFrom.default('now'),
|
|
880
876
|
imapIndexer: accountSchemas.imapIndexer,
|
|
881
877
|
syncFrom: accountSchemas.syncFrom
|
|
@@ -884,7 +880,7 @@ async function init(args) {
|
|
|
884
880
|
|
|
885
881
|
response: {
|
|
886
882
|
schema: Joi.object({
|
|
887
|
-
flush:
|
|
883
|
+
flush: apiBoolean().default(false).description('Flush status')
|
|
888
884
|
}).label('RequestFlushResponse'),
|
|
889
885
|
failAction: 'log'
|
|
890
886
|
}
|
|
@@ -1080,7 +1076,6 @@ async function init(args) {
|
|
|
1080
1076
|
'copy',
|
|
1081
1077
|
'logs',
|
|
1082
1078
|
'notifyFrom',
|
|
1083
|
-
'syncFrom',
|
|
1084
1079
|
'path',
|
|
1085
1080
|
'subconnections',
|
|
1086
1081
|
'webhooks',
|
|
@@ -1120,7 +1115,7 @@ async function init(args) {
|
|
|
1120
1115
|
}
|
|
1121
1116
|
|
|
1122
1117
|
// default null
|
|
1123
|
-
for (let key of ['notifyFrom', '
|
|
1118
|
+
for (let key of ['notifyFrom', 'lastError', 'smtpStatus']) {
|
|
1124
1119
|
result[key] = result[key] || null;
|
|
1125
1120
|
}
|
|
1126
1121
|
|
|
@@ -1219,12 +1214,7 @@ async function init(args) {
|
|
|
1219
1214
|
}),
|
|
1220
1215
|
|
|
1221
1216
|
query: Joi.object({
|
|
1222
|
-
quota:
|
|
1223
|
-
.truthy('Y', 'true', '1')
|
|
1224
|
-
.falsy('N', 'false', 0)
|
|
1225
|
-
.default(false)
|
|
1226
|
-
.description('If true, then include quota information in the response')
|
|
1227
|
-
.label('AccountQuota')
|
|
1217
|
+
quota: apiBoolean().default(false).description('If true, then include quota information in the response').label('AccountQuota')
|
|
1228
1218
|
})
|
|
1229
1219
|
},
|
|
1230
1220
|
|
|
@@ -1583,7 +1573,6 @@ async function init(args) {
|
|
|
1583
1573
|
name: request.payload.name,
|
|
1584
1574
|
email: request.payload.email,
|
|
1585
1575
|
expectedEmail: request.payload.expectedEmail,
|
|
1586
|
-
syncFrom: request.payload.syncFrom,
|
|
1587
1576
|
notifyFrom: request.payload.notifyFrom,
|
|
1588
1577
|
subconnections: request.payload.subconnections,
|
|
1589
1578
|
redirectUrl: request.payload.redirectUrl,
|
|
@@ -1697,21 +1686,21 @@ async function init(args) {
|
|
|
1697
1686
|
delegated: Joi.boolean()
|
|
1698
1687
|
.empty('')
|
|
1699
1688
|
.truthy('Y', 'true', '1')
|
|
1700
|
-
.falsy('N', 'false', 0)
|
|
1689
|
+
.falsy('N', 'false', '0', 0)
|
|
1701
1690
|
.default(false)
|
|
1702
1691
|
.description('If true, configures this account as a shared mailbox. Currently supported by MS365 OAuth2 accounts'),
|
|
1703
1692
|
|
|
1704
1693
|
skipServerSettings: Joi.boolean()
|
|
1705
1694
|
.empty('')
|
|
1706
1695
|
.truthy('Y', 'true', '1')
|
|
1707
|
-
.falsy('N', 'false', 0)
|
|
1696
|
+
.falsy('N', 'false', '0', 0)
|
|
1708
1697
|
.default(true)
|
|
1709
1698
|
.description(
|
|
1710
1699
|
'If true, the mail server settings step is skipped whenever the IMAP and SMTP settings for the address can both be discovered and verified with the password the user enters. The step is still shown if discovery or verification does not fully succeed. Set to false to always ask the user for the server settings. Applies to the IMAP setup path only.'
|
|
1711
1700
|
),
|
|
1712
1701
|
|
|
1713
|
-
syncFrom: accountSchemas.syncFrom,
|
|
1714
1702
|
notifyFrom: accountSchemas.notifyFrom,
|
|
1703
|
+
syncFrom: accountSchemas.syncFrom,
|
|
1715
1704
|
|
|
1716
1705
|
subconnections: accountSchemas.subconnections,
|
|
1717
1706
|
|
|
@@ -8,7 +8,7 @@ const getSecret = require('../get-secret');
|
|
|
8
8
|
const { lists } = require('../lists');
|
|
9
9
|
const { failAction } = require('../tools');
|
|
10
10
|
const { handleError } = require('./route-helpers');
|
|
11
|
-
const { accountIdSchema, blocklistListIdSchema, apiResponses } = require('../schemas');
|
|
11
|
+
const { accountIdSchema, blocklistListIdSchema, apiResponses, apiBoolean } = require('../schemas');
|
|
12
12
|
const { IMPACT } = require('./operation-impact');
|
|
13
13
|
const { MCP_MAX_PAGE_SIZE } = require('../consts');
|
|
14
14
|
|
|
@@ -331,7 +331,7 @@ async function init(args) {
|
|
|
331
331
|
|
|
332
332
|
response: {
|
|
333
333
|
schema: Joi.object({
|
|
334
|
-
deleted:
|
|
334
|
+
deleted: apiBoolean().default(true).description('Was the address removed from the list')
|
|
335
335
|
}).label('DeleteBlocklistResponse'),
|
|
336
336
|
failAction: 'log'
|
|
337
337
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const { createBullBoard } = require('@bull-board/api');
|
|
4
4
|
const { BullMQAdapter } = require('@bull-board/api/bullMQAdapter');
|
|
5
5
|
const { HapiAdapter } = require('@bull-board/hapi');
|
|
6
|
-
const { notifyQueue, submitQueue
|
|
6
|
+
const { notifyQueue, submitQueue } = require('../db');
|
|
7
7
|
const { BULL_BOARD_BASE_PATH } = require('../consts');
|
|
8
8
|
|
|
9
9
|
async function init(args) {
|
|
@@ -21,11 +21,6 @@ async function init(args) {
|
|
|
21
21
|
queue: submitQueue,
|
|
22
22
|
prefix: 'Submission Queue - ',
|
|
23
23
|
description: 'This queue contains emails that are scheduled to be sent.'
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
queue: documentsQueue,
|
|
27
|
-
prefix: 'Document Queue - ',
|
|
28
|
-
description: '(Deprecated) This queue was used for indexing email information in the Document Store'
|
|
29
24
|
}
|
|
30
25
|
];
|
|
31
26
|
let queueAdapters = queues.map(queue => {
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const { Export } = require('../export');
|
|
3
|
+
const { Export, openExportReadStream } = require('../export');
|
|
5
4
|
const Boom = require('@hapi/boom');
|
|
6
5
|
const Joi = require('joi');
|
|
7
6
|
const { failAction } = require('../tools');
|
|
8
7
|
const { accountIdSchema, exportRequestSchema, exportStatusSchema, exportListSchema, exportIdSchema, apiResponses } = require('../schemas');
|
|
9
|
-
const getSecret = require('../get-secret');
|
|
10
|
-
const { createDecryptStream } = require('../stream-encrypt');
|
|
11
8
|
const { handleError } = require('./route-helpers');
|
|
12
9
|
const BEHAVIOR = require('./behavior-notes');
|
|
13
10
|
const { IMPACT } = require('./operation-impact');
|
|
@@ -144,27 +141,10 @@ async function init(args) {
|
|
|
144
141
|
throw Boom.notFound('Export not found');
|
|
145
142
|
}
|
|
146
143
|
|
|
147
|
-
const
|
|
148
|
-
let stream = fileReadStream;
|
|
149
|
-
|
|
150
|
-
stream.on('error', err => {
|
|
144
|
+
const stream = await openExportReadStream(fileInfo, err => {
|
|
151
145
|
request.logger.error({ msg: 'Export download stream error', exportId, err });
|
|
152
146
|
});
|
|
153
147
|
|
|
154
|
-
if (fileInfo.isEncrypted) {
|
|
155
|
-
const secret = await getSecret();
|
|
156
|
-
if (!secret) {
|
|
157
|
-
fileReadStream.destroy();
|
|
158
|
-
throw Boom.serverUnavailable('Encryption secret not available for decryption');
|
|
159
|
-
}
|
|
160
|
-
const decryptStream = await createDecryptStream(secret);
|
|
161
|
-
decryptStream.on('error', err => {
|
|
162
|
-
request.logger.error({ msg: 'Export decryption error', exportId, err });
|
|
163
|
-
fileReadStream.destroy();
|
|
164
|
-
});
|
|
165
|
-
stream = fileReadStream.pipe(decryptStream);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
148
|
return h
|
|
169
149
|
.response(stream)
|
|
170
150
|
.type('application/gzip')
|
|
@@ -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, maskSecrets, MASKED, MASK_NOTE } = require('./route-helpers');
|
|
9
|
-
const { apiResponses } = require('../schemas');
|
|
9
|
+
const { apiResponses, apiBoolean, formBoolean } = require('../schemas');
|
|
10
10
|
const { ENUM_DESCRIPTIONS } = require('../enum-descriptions');
|
|
11
11
|
const { IMPACT } = require('./operation-impact');
|
|
12
12
|
const { MCP_MAX_PAGE_SIZE } = require('../consts');
|
|
@@ -229,9 +229,7 @@ async function init(args) {
|
|
|
229
229
|
.description('Service port number')
|
|
230
230
|
.label('Port'),
|
|
231
231
|
|
|
232
|
-
secure:
|
|
233
|
-
.truthy('Y', 'true', '1', 'on')
|
|
234
|
-
.falsy('N', 'false', 0, '')
|
|
232
|
+
secure: formBoolean()
|
|
235
233
|
.allow(null)
|
|
236
234
|
.default(false)
|
|
237
235
|
.example(true)
|
|
@@ -316,9 +314,7 @@ async function init(args) {
|
|
|
316
314
|
.label('Port')
|
|
317
315
|
.required(),
|
|
318
316
|
|
|
319
|
-
secure:
|
|
320
|
-
.truthy('Y', 'true', '1', 'on')
|
|
321
|
-
.falsy('N', 'false', 0, '')
|
|
317
|
+
secure: formBoolean()
|
|
322
318
|
.default(false)
|
|
323
319
|
.example(true)
|
|
324
320
|
.description('Should connection use TLS. Usually true for port 465')
|
|
@@ -413,12 +409,7 @@ async function init(args) {
|
|
|
413
409
|
.description('Service port number')
|
|
414
410
|
.label('Port'),
|
|
415
411
|
|
|
416
|
-
secure:
|
|
417
|
-
.truthy('Y', 'true', '1', 'on')
|
|
418
|
-
.falsy('N', 'false', 0, '')
|
|
419
|
-
.example(true)
|
|
420
|
-
.description('Should connection use TLS. Usually true for port 465')
|
|
421
|
-
.label('GatewayUpdateTlsOptions')
|
|
412
|
+
secure: formBoolean().example(true).description('Should connection use TLS. Usually true for port 465').label('GatewayUpdateTlsOptions')
|
|
422
413
|
}).label('UpdateGateway')
|
|
423
414
|
},
|
|
424
415
|
|
|
@@ -487,7 +478,7 @@ async function init(args) {
|
|
|
487
478
|
response: {
|
|
488
479
|
schema: Joi.object({
|
|
489
480
|
gateway: Joi.string().max(256).required().example('example').description('Gateway ID'),
|
|
490
|
-
deleted:
|
|
481
|
+
deleted: apiBoolean().default(true).description('Was the gateway deleted')
|
|
491
482
|
}).label('DeleteGatewayResponse'),
|
|
492
483
|
failAction: 'log'
|
|
493
484
|
}
|
package/lib/api-routes/index.js
CHANGED
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
// them the same bag hides which module depends on what, and hides it from the route-table test too.
|
|
14
14
|
|
|
15
15
|
const templateRoutes = require('./template-routes');
|
|
16
|
-
const chatRoutes = require('./chat-routes');
|
|
17
16
|
const accountRoutes = require('./account-routes');
|
|
18
17
|
const messageRoutes = require('./message-routes');
|
|
19
18
|
const exportRoutes = require('./export-routes');
|
|
@@ -41,7 +40,6 @@ const mcpOauthRoutes = require('./mcp-oauth-routes');
|
|
|
41
40
|
* @param {Object} args.server - Hapi server (or a route-recording mock)
|
|
42
41
|
* @param {Function} args.call - RPC helper for talking to the main thread
|
|
43
42
|
* @param {Object} args.notify - notify (webhooks) BullMQ queue
|
|
44
|
-
* @param {Object} args.documentsQueue - documents BullMQ queue
|
|
45
43
|
* @param {Object} args.metrics - Prometheus metrics registry
|
|
46
44
|
* @param {Object|Boolean} args.CORS_CONFIG
|
|
47
45
|
* @param {Array} args.FLAG_SORT_ORDER
|
|
@@ -49,7 +47,6 @@ const mcpOauthRoutes = require('./mcp-oauth-routes');
|
|
|
49
47
|
* @param {Number} args.MAX_ATTACHMENT_SIZE
|
|
50
48
|
* @param {Number} args.MAX_BODY_SIZE
|
|
51
49
|
* @param {Number} args.MAX_PAYLOAD_TIMEOUT
|
|
52
|
-
* @param {Boolean} args.documentStoreFeatureEnabled - gate for the deprecated Document Store
|
|
53
50
|
* @param {Boolean} args.mcpFeatureEnabled - gate for the MCP endpoint
|
|
54
51
|
* @param {Object} args.oauth2Schema
|
|
55
52
|
* @param {Object} args.imapSchema
|
|
@@ -62,7 +59,6 @@ async function registerApiRoutes(args) {
|
|
|
62
59
|
server,
|
|
63
60
|
call,
|
|
64
61
|
notify,
|
|
65
|
-
documentsQueue,
|
|
66
62
|
metrics,
|
|
67
63
|
CORS_CONFIG,
|
|
68
64
|
FLAG_SORT_ORDER,
|
|
@@ -70,7 +66,6 @@ async function registerApiRoutes(args) {
|
|
|
70
66
|
MAX_ATTACHMENT_SIZE,
|
|
71
67
|
MAX_BODY_SIZE,
|
|
72
68
|
MAX_PAYLOAD_TIMEOUT,
|
|
73
|
-
documentStoreFeatureEnabled,
|
|
74
69
|
mcpFeatureEnabled,
|
|
75
70
|
oauth2Schema,
|
|
76
71
|
imapSchema,
|
|
@@ -82,16 +77,10 @@ async function registerApiRoutes(args) {
|
|
|
82
77
|
// setup template routes
|
|
83
78
|
await templateRoutes({ server, call, CORS_CONFIG });
|
|
84
79
|
|
|
85
|
-
// setup "chat with email" routes (deprecated Document Store feature; only when enabled)
|
|
86
|
-
if (documentStoreFeatureEnabled) {
|
|
87
|
-
await chatRoutes({ server, call, CORS_CONFIG });
|
|
88
|
-
}
|
|
89
|
-
|
|
90
80
|
// setup account CRUD routes
|
|
91
81
|
await accountRoutes({
|
|
92
82
|
server,
|
|
93
83
|
call,
|
|
94
|
-
documentsQueue,
|
|
95
84
|
oauth2Schema,
|
|
96
85
|
imapSchema,
|
|
97
86
|
smtpSchema,
|
|
@@ -108,8 +97,7 @@ async function registerApiRoutes(args) {
|
|
|
108
97
|
CORS_CONFIG,
|
|
109
98
|
MAX_ATTACHMENT_SIZE,
|
|
110
99
|
MAX_BODY_SIZE,
|
|
111
|
-
MAX_PAYLOAD_TIMEOUT
|
|
112
|
-
documentStoreFeatureEnabled
|
|
100
|
+
MAX_PAYLOAD_TIMEOUT
|
|
113
101
|
});
|
|
114
102
|
|
|
115
103
|
// setup export routes
|
|
@@ -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, logApiError } = require('./route-helpers');
|
|
10
|
-
const { accountIdSchema, mailboxesSchema, apiResponses } = require('../schemas');
|
|
10
|
+
const { accountIdSchema, mailboxesSchema, apiResponses, apiBoolean } = require('../schemas');
|
|
11
11
|
const { IMPACT } = require('./operation-impact');
|
|
12
12
|
const { FIELD_USAGE } = require('../field-usage');
|
|
13
13
|
|
|
@@ -118,12 +118,7 @@ async function init(args) {
|
|
|
118
118
|
}),
|
|
119
119
|
|
|
120
120
|
query: Joi.object({
|
|
121
|
-
counters:
|
|
122
|
-
.truthy('Y', 'true', '1')
|
|
123
|
-
.falsy('N', 'false', 0)
|
|
124
|
-
.default(false)
|
|
125
|
-
.description('If true, then includes message counters in the response')
|
|
126
|
-
.label('MailboxCounters')
|
|
121
|
+
counters: apiBoolean().default(false).description('If true, then includes message counters in the response').label('MailboxCounters')
|
|
127
122
|
}).label('MailboxListQuery')
|
|
128
123
|
},
|
|
129
124
|
|
|
@@ -160,7 +160,8 @@ async function init(args) {
|
|
|
160
160
|
return h.response(client).code(201);
|
|
161
161
|
} catch (err) {
|
|
162
162
|
if (err.oauthError) {
|
|
163
|
-
|
|
163
|
+
// 503 for the instance-wide cap on registrations waiting for consent
|
|
164
|
+
return oauthErrorResponse(h, err.statusCode || 400, err.oauthError, err.message);
|
|
164
165
|
}
|
|
165
166
|
throw err;
|
|
166
167
|
}
|
|
@@ -23,7 +23,7 @@ const { isMcpEnabled, MCP_DISABLED_MESSAGE } = require('../mcp');
|
|
|
23
23
|
const { processMcpRequest, isAllowedOrigin, acceptsEventStream, rpcError, ERROR_CODES, serverInstructions } = require('../mcp/protocol');
|
|
24
24
|
const { getToolRegistry, callTool, listToolsFor, catalogSurfaces } = require('../mcp/tools');
|
|
25
25
|
const { listResources, readResource } = require('../mcp/resources');
|
|
26
|
-
const {
|
|
26
|
+
const { handleListen, MAX_STREAMS_PER_CREDENTIAL } = require('../mcp/listen');
|
|
27
27
|
|
|
28
28
|
async function init(args) {
|
|
29
29
|
const { server, CORS_CONFIG, MAX_BODY_SIZE, MAX_PAYLOAD_TIMEOUT } = args;
|
|
@@ -111,9 +111,11 @@ async function init(args) {
|
|
|
111
111
|
const outcome = await processMcpRequest({ body: request.payload, headers: request.headers, ctx });
|
|
112
112
|
|
|
113
113
|
if (outcome.listen) {
|
|
114
|
-
//
|
|
115
|
-
// its stream budget cannot spend the instance's
|
|
116
|
-
|
|
114
|
+
// The stream cap is checked, and a slot reserved, before the authorization fan-out,
|
|
115
|
+
// so a client that is already at its stream budget cannot spend the instance's
|
|
116
|
+
// Redis round trips discovering it, concurrent requests included
|
|
117
|
+
const response = await handleListen({ h, server, request, subscriptionId: outcome.listen.id, filter: outcome.listen.filter });
|
|
118
|
+
if (!response) {
|
|
117
119
|
return h.response(
|
|
118
120
|
rpcError(
|
|
119
121
|
outcome.listen.id,
|
|
@@ -122,9 +124,7 @@ async function init(args) {
|
|
|
122
124
|
)
|
|
123
125
|
);
|
|
124
126
|
}
|
|
125
|
-
|
|
126
|
-
const accepted = await acceptFilter({ server, request, filter: outcome.listen.filter });
|
|
127
|
-
return openListenStream({ h, request, subscriptionId: outcome.listen.id, accepted });
|
|
127
|
+
return response;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
if (!outcome.body) {
|