emailengine-app 2.79.0 → 2.79.2
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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +79 -0
- package/bin/emailengine.js +8 -1
- package/config/default.toml +6 -0
- package/data/google-crawlers.json +1 -1
- package/lib/account.js +137 -19
- package/lib/api-routes/account-routes.js +13 -1
- package/lib/api-routes/index.js +12 -0
- package/lib/api-routes/mailbox-routes.js +6 -0
- package/lib/api-routes/mcp-oauth-routes.js +259 -0
- package/lib/api-routes/mcp-routes.js +172 -0
- package/lib/api-routes/message-routes.js +125 -4
- package/lib/api-routes/outbox-routes.js +7 -0
- package/lib/api-routes/permission-map.js +101 -1
- package/lib/api-routes/route-helpers.js +87 -4
- package/lib/api-routes/route-metadata.js +24 -4
- package/lib/api-routes/settings-routes.js +37 -14
- package/lib/api-routes/submit-routes.js +41 -0
- package/lib/api-routes/template-routes.js +7 -0
- package/lib/api-routes/token-routes.js +292 -122
- package/lib/arf-detect.js +17 -4
- package/lib/bounce-detect.js +28 -17
- package/lib/consts.js +36 -1
- package/lib/db.js +6 -0
- package/lib/email-client/base-client.js +102 -117
- package/lib/email-client/gmail-client.js +91 -29
- package/lib/email-client/imap/mailbox.js +175 -101
- package/lib/email-client/imap-client.js +49 -2
- package/lib/email-client/outlook-client.js +20 -24
- package/lib/enum-descriptions.js +2 -1
- package/lib/field-usage.js +17 -1
- package/lib/lua/h-set-new-mark.lua +36 -0
- package/lib/lua/s-list-accounts.lua +5 -2
- package/lib/mcp/index.js +29 -0
- package/lib/mcp/inject.js +70 -0
- package/lib/mcp/json-schema.js +120 -0
- package/lib/mcp/listen.js +171 -0
- package/lib/mcp/oauth.js +324 -0
- package/lib/mcp/protocol.js +489 -0
- package/lib/mcp/resources.js +139 -0
- package/lib/mcp/tools.js +655 -0
- package/lib/message-port-stream.js +84 -1
- package/lib/oauth2-apps.js +84 -15
- package/lib/openapi/build-document.js +5 -1
- package/lib/openapi/index.js +3 -1
- package/lib/response-stream.js +52 -21
- package/lib/routes-ui.js +4 -0
- package/lib/schemas.js +26 -5
- package/lib/settings.js +23 -9
- package/lib/token-audit-log.js +32 -9
- package/lib/token-permission-view.js +104 -8
- package/lib/tokens.js +194 -68
- package/lib/tools.js +96 -0
- package/lib/ui-routes/account-routes.js +55 -6
- package/lib/ui-routes/admin-config-routes.js +114 -1
- package/lib/ui-routes/admin-entities-routes.js +103 -19
- package/lib/ui-routes/auth-routes.js +13 -0
- package/lib/ui-routes/mcp-consent-routes.js +330 -0
- package/lib/ui-routes/oauth-config-routes.js +7 -7
- package/lib/ui-routes/route-helpers.js +143 -1
- package/lib/ui-routes/suppression-list-routes.js +14 -9
- package/lib/utils/decode-headers.js +42 -0
- package/lib/utils/header-map.js +48 -0
- package/lib/utils/network.js +9 -1
- package/lib/utils/unsafe-key.js +59 -0
- package/lib/web-safe-html.js +61 -0
- package/lib/webhook-routing.js +6 -2
- package/lib/webhooks.js +31 -8
- package/package.json +9 -8
- package/sbom.json +1 -1
- package/scripts/README.md +25 -0
- package/scripts/build-icon.js +77 -0
- package/server.js +39 -17
- package/static/css/flyonui.css +1 -1
- package/static/css/src/app.tailwind.css +98 -0
- package/static/emailengine.ico +0 -0
- package/static/js/ui.js +465 -1
- package/static/licenses.html +42 -22
- package/translations/messages.pot +57 -57
- package/views/accounts/account.hbs +8 -8
- package/views/accounts/browse.hbs +1 -1
- package/views/accounts/edit.hbs +2 -2
- package/views/config/mcp.hbs +361 -0
- package/views/config/oauth/index.hbs +7 -0
- package/views/gateways/edit.hbs +1 -1
- package/views/gateways/gateway.hbs +2 -2
- package/views/gateways/index.hbs +7 -7
- package/views/layout/prompt.hbs +62 -0
- package/views/mcp/authorize.hbs +136 -0
- package/views/partials/accounts_table.hbs +7 -7
- package/views/partials/head_assets.hbs +3 -3
- package/views/partials/mcp_access_levels.hbs +13 -0
- package/views/partials/mcp_account_limit.hbs +14 -0
- package/views/partials/mcp_tool_count.hbs +19 -0
- package/views/partials/side_menu.hbs +1 -0
- package/views/partials/ui/account-picker.hbs +59 -0
- package/views/partials/ui/code-block.hbs +26 -0
- package/views/partials/ui/menu-item.hbs +5 -0
- package/views/partials/ui/radio.hbs +41 -0
- package/views/partials/ui/tab.hbs +15 -10
- package/views/partials/ui/tabs.hbs +8 -5
- package/views/suppression-lists/list.hbs +1 -1
- package/views/templates/index.hbs +2 -2
- package/views/templates/template.hbs +5 -4
- package/views/tokens/index.hbs +30 -4
- package/views/tokens/new.hbs +517 -239
- package/winconf.js +148 -48
- package/workers/api.js +239 -95
- package/workers/imap.js +65 -72
- package/workers/webhooks.js +21 -1
package/winconf.js
CHANGED
|
@@ -3,17 +3,42 @@
|
|
|
3
3
|
const { load } = require('resedit/cjs');
|
|
4
4
|
const PackageData = require('./package.json');
|
|
5
5
|
|
|
6
|
-
const { readFileSync, writeFileSync, existsSync } = require('fs');
|
|
6
|
+
const { readFileSync, writeFileSync, renameSync, existsSync } = require('fs');
|
|
7
|
+
|
|
8
|
+
// Windows reads this as the file's "Company". Leaving it unset is not neutral: the exe then
|
|
9
|
+
// inherits "Node.js" from the pkg base binary the build starts from, and that is what every
|
|
10
|
+
// release up to 2.79.1 shipped.
|
|
11
|
+
const COMPANY = 'Postal Systems OÜ';
|
|
12
|
+
|
|
13
|
+
// pkg writes <name>-<target minus its node prefix>.exe into pkg.outputPath, so the file this
|
|
14
|
+
// script rewrites is derived from the same config pkg built it from and cannot drift out of it.
|
|
15
|
+
const winTarget = PackageData.pkg.targets.find(target => /-win-/.test(target));
|
|
16
|
+
if (!winTarget) {
|
|
17
|
+
throw new Error('No Windows target found in package.json pkg.targets');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// The command this binary is installed as, which is what OriginalFilename and InternalName are
|
|
21
|
+
// supposed to name.
|
|
22
|
+
const binName = Object.keys(PackageData.bin)[0];
|
|
7
23
|
|
|
8
24
|
const options = {
|
|
9
|
-
|
|
10
|
-
out: './ee-dist/emailengine-app-win-x64.exe',
|
|
25
|
+
exe: `./${PackageData.pkg.outputPath}/${PackageData.name}-${winTarget.replace(/^node\d+-/, '')}.exe`,
|
|
11
26
|
version: PackageData.version,
|
|
12
27
|
properties: {
|
|
13
|
-
|
|
28
|
+
CompanyName: COMPANY,
|
|
29
|
+
LegalCopyright: `Copyright (c) ${COMPANY}`,
|
|
14
30
|
FileDescription: 'EmailEngine allows access to email accounts using REST API',
|
|
15
|
-
ProductName:
|
|
31
|
+
ProductName: PackageData.productTitle,
|
|
32
|
+
// These describe the file as it actually ships. pkg leaves node.exe's own values here,
|
|
33
|
+
// which the previous revision of this script deleted outright rather than correcting.
|
|
34
|
+
OriginalFilename: `${binName}.exe`,
|
|
35
|
+
InternalName: binName,
|
|
36
|
+
// setProductVersion() below writes the four-part numeric form into this string as well.
|
|
37
|
+
// Restating it here puts the exact package version back, which is the only place a
|
|
38
|
+
// prerelease suffix can survive and the field the properties dialog shows.
|
|
39
|
+
ProductVersion: PackageData.version
|
|
16
40
|
},
|
|
41
|
+
// Rebuilt by scripts/build-icon.js, which keeps it small enough for the check below
|
|
17
42
|
icon: 'static/emailengine.ico'
|
|
18
43
|
};
|
|
19
44
|
|
|
@@ -22,16 +47,62 @@ const language = {
|
|
|
22
47
|
codepage: 1200
|
|
23
48
|
};
|
|
24
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Offset of the payload pkg appends after the last PE section.
|
|
52
|
+
*
|
|
53
|
+
* pkg addresses that payload by absolute file offset, so rewriting resources is only safe while
|
|
54
|
+
* .rsrc still fits the raw allocation the linker gave it. Once it does not, the section grows,
|
|
55
|
+
* every later section and the payload slide down the file, and the binary dies on startup with
|
|
56
|
+
* "SyntaxError: Invalid or unexpected token" out of readPrelude. The icon is the only input here
|
|
57
|
+
* big enough to cross that line - an .ico whose large members are uncompressed BMP rather than
|
|
58
|
+
* PNG is several hundred KB on its own - and nothing downstream would catch it: the exe is still
|
|
59
|
+
* well formed, its icons and version strings still read back correctly, and it still signs and
|
|
60
|
+
* hashes like a good build.
|
|
61
|
+
*
|
|
62
|
+
* Reads the section table off the parsed executable, which reflects the edit as soon as
|
|
63
|
+
* outputResource() has run, so the same call answers for both the before and the after image.
|
|
64
|
+
*/
|
|
65
|
+
function payloadOffset(executable) {
|
|
66
|
+
return executable.getAllSections().reduce((offset, section) => Math.max(offset, section.info.pointerToRawData + section.info.sizeOfRawData), 0);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function resourceSection(executable) {
|
|
70
|
+
return executable.getAllSections().find(section => section.info.name === '.rsrc');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* A Windows version resource is four 16-bit numbers, and semver does not map onto it - the
|
|
75
|
+
* prerelease and build parts have nowhere to go. Take the leading integer of each of the first
|
|
76
|
+
* four dot-separated components. The string overload of setFileVersion() is used rather than the
|
|
77
|
+
* numeric one because a tuple shorter than four slides the language argument into the revision
|
|
78
|
+
* slot, so a two-part version would be stamped as 2.79.0.1033.
|
|
79
|
+
*/
|
|
80
|
+
function toWindowsVersion(version) {
|
|
81
|
+
const parts = String(version || '').split('.');
|
|
82
|
+
|
|
83
|
+
// Indexing fixed slots rather than padding: a missing component and an unparseable one both
|
|
84
|
+
// have to end up as 0, and parseInt(undefined) is NaN just like parseInt('x')
|
|
85
|
+
return [0, 1, 2, 3]
|
|
86
|
+
.map(index => parseInt(parts[index], 10))
|
|
87
|
+
.map(value => (value >= 0 ? Math.min(value, 0xffff) : 0))
|
|
88
|
+
.join('.');
|
|
89
|
+
}
|
|
90
|
+
|
|
25
91
|
load()
|
|
26
92
|
.then(ResEdit => {
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
93
|
+
// Both inputs checked up front, so a missing one is reported as itself rather than as
|
|
94
|
+
// whatever readFileSync happens to throw further down
|
|
95
|
+
if (!existsSync(options.exe)) {
|
|
96
|
+
throw new Error(`Input file not found: ${options.exe}`);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (!existsSync(options.icon)) {
|
|
100
|
+
throw new Error(`Icon file not found: ${options.icon}`);
|
|
30
101
|
}
|
|
31
102
|
|
|
32
103
|
// Modify .exe w/ ResEdit
|
|
33
|
-
const
|
|
34
|
-
const executable = ResEdit.NtExecutable.from(
|
|
104
|
+
const original = readFileSync(options.exe);
|
|
105
|
+
const executable = ResEdit.NtExecutable.from(original);
|
|
35
106
|
const res = ResEdit.NtExecutableResource.from(executable);
|
|
36
107
|
const versionInfos = ResEdit.Resource.VersionInfo.fromEntries(res.entries);
|
|
37
108
|
|
|
@@ -41,53 +112,82 @@ load()
|
|
|
41
112
|
|
|
42
113
|
const vi = versionInfos[0];
|
|
43
114
|
|
|
44
|
-
|
|
45
|
-
vi.
|
|
46
|
-
vi.
|
|
47
|
-
|
|
48
|
-
// Product version
|
|
49
|
-
if (options.version) {
|
|
50
|
-
// Convert version to tuple of 3 numbers
|
|
51
|
-
const version = options.version
|
|
52
|
-
.split('.')
|
|
53
|
-
.map(v => Number(v) || 0)
|
|
54
|
-
.slice(0, 3);
|
|
55
|
-
|
|
56
|
-
// Update versions
|
|
57
|
-
vi.setProductVersion(...version, 0, language.lang);
|
|
58
|
-
vi.setFileVersion(...version, 0, language.lang);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Add additional user specified properties
|
|
62
|
-
if (options.properties) {
|
|
63
|
-
vi.setStringValues(language, options.properties);
|
|
64
|
-
}
|
|
115
|
+
const fileVersion = toWindowsVersion(options.version);
|
|
116
|
+
vi.setFileVersion(fileVersion, language.lang);
|
|
117
|
+
vi.setProductVersion(fileVersion, language.lang);
|
|
65
118
|
|
|
119
|
+
vi.setStringValues(language, options.properties);
|
|
66
120
|
vi.outputToResourceEntries(res.entries);
|
|
67
121
|
|
|
68
122
|
// Add icon
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
123
|
+
const iconFile = ResEdit.Data.IconFile.from(readFileSync(options.icon));
|
|
124
|
+
ResEdit.Resource.IconGroupEntry.replaceIconsForResource(
|
|
125
|
+
res.entries,
|
|
126
|
+
1,
|
|
127
|
+
language.lang,
|
|
128
|
+
iconFile.icons.map(item => item.data)
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
// Regenerate the .exe. The allocation is read before the edit because that is the budget
|
|
132
|
+
// the linker set; once the section has grown, it has already grown to fit
|
|
133
|
+
const offsetBefore = payloadOffset(executable);
|
|
134
|
+
const allocated = resourceSection(executable).info.sizeOfRawData;
|
|
135
|
+
res.outputResource(executable);
|
|
136
|
+
const offsetAfter = payloadOffset(executable);
|
|
137
|
+
const rsrc = resourceSection(executable);
|
|
138
|
+
const updated = Buffer.from(executable.generate());
|
|
139
|
+
|
|
140
|
+
// Refuse to write a binary whose payload moved - see payloadOffset() above. Checked
|
|
141
|
+
// before the write so a build that would not start never reaches the disk at all
|
|
142
|
+
if (offsetAfter !== offsetBefore || !original.subarray(offsetBefore).equals(updated.subarray(offsetAfter))) {
|
|
143
|
+
throw new Error(
|
|
144
|
+
`Rewriting the resources moved the appended pkg payload (${offsetBefore} -> ${offsetAfter}), which produces an executable that cannot start. ` +
|
|
145
|
+
`The resources need ${rsrc.info.virtualSize} bytes but only ${allocated} are allocated for .rsrc - ` +
|
|
146
|
+
`shrink ${options.icon} by at least ${rsrc.info.virtualSize - allocated} bytes, PNG-compressing its largest members.`
|
|
79
147
|
);
|
|
80
148
|
}
|
|
81
149
|
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
|
|
150
|
+
// Written beside the target and renamed into place, as a half-written 140MB exe would
|
|
151
|
+
// otherwise look like a finished build to every later step
|
|
152
|
+
const tmpPath = `${options.exe}.tmp`;
|
|
153
|
+
writeFileSync(tmpPath, updated);
|
|
154
|
+
renameSync(tmpPath, options.exe);
|
|
155
|
+
|
|
156
|
+
// Read back what was written. Signing, hashing and the release upload all treat this
|
|
157
|
+
// file as final, so a resource edit that silently did not apply has no later chance of
|
|
158
|
+
// being caught
|
|
159
|
+
const writtenRes = ResEdit.NtExecutableResource.from(ResEdit.NtExecutable.from(readFileSync(options.exe)));
|
|
160
|
+
const writtenInfo = ResEdit.Resource.VersionInfo.fromEntries(writtenRes.entries)[0];
|
|
161
|
+
const written = writtenInfo ? writtenInfo.getStringValues(language) : {};
|
|
162
|
+
|
|
163
|
+
const expected = Object.assign({ FileVersion: fileVersion }, options.properties);
|
|
164
|
+
for (const [key, value] of Object.entries(expected)) {
|
|
165
|
+
if (written[key] !== value) {
|
|
166
|
+
throw new Error(`Property ${key} did not apply, expected ${JSON.stringify(value)} but found ${JSON.stringify(written[key])}`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
85
169
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
console.log(`
|
|
170
|
+
const iconSizes = iconFile.icons.map(icon => `${icon.width || 256}x${icon.height || 256}`);
|
|
171
|
+
|
|
172
|
+
console.log(`Successfully updated ${options.exe}`);
|
|
173
|
+
console.log(` Version: ${options.version} (resource ${fileVersion})`);
|
|
174
|
+
console.log(` Company: ${options.properties.CompanyName}`);
|
|
175
|
+
console.log(` Icon: ${options.icon} (${iconSizes.join(', ')})`);
|
|
176
|
+
|
|
177
|
+
// The margin the payload check above depends on. Reported on every build so it is a
|
|
178
|
+
// visible gauge rather than a cliff that a slightly larger icon walks off
|
|
179
|
+
console.log(
|
|
180
|
+
` Resources: ${rsrc.info.virtualSize} of ${rsrc.info.sizeOfRawData} bytes allocated for .rsrc (${rsrc.info.sizeOfRawData - rsrc.info.virtualSize} spare)`
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
// Windows picks the closest image out of the group and scales it down. Without a small
|
|
184
|
+
// one, the Explorer list view, the title bar and the taskbar all show a resampled 256px
|
|
185
|
+
// image, which is visibly softer than a purpose-drawn 16x16
|
|
186
|
+
if (!iconFile.icons.some(icon => (icon.width || 256) <= 48)) {
|
|
187
|
+
console.log(' Note: the icon has no image at 48x48 or smaller, Windows will downscale the largest one');
|
|
188
|
+
}
|
|
89
189
|
})
|
|
90
190
|
.catch(err => {
|
|
91
|
-
console.error('Error modifying Windows executable:', err
|
|
191
|
+
console.error('Error modifying Windows executable:', err);
|
|
92
192
|
process.exit(1);
|
|
93
193
|
});
|