emailengine-app 2.79.1 → 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.
Files changed (81) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/CHANGELOG.md +40 -0
  3. package/bin/emailengine.js +8 -1
  4. package/config/default.toml +6 -0
  5. package/data/google-crawlers.json +1 -1
  6. package/lib/account.js +95 -18
  7. package/lib/api-routes/account-routes.js +13 -1
  8. package/lib/api-routes/index.js +12 -0
  9. package/lib/api-routes/mailbox-routes.js +6 -0
  10. package/lib/api-routes/mcp-oauth-routes.js +259 -0
  11. package/lib/api-routes/mcp-routes.js +172 -0
  12. package/lib/api-routes/message-routes.js +125 -4
  13. package/lib/api-routes/outbox-routes.js +7 -0
  14. package/lib/api-routes/permission-map.js +97 -1
  15. package/lib/api-routes/route-helpers.js +16 -4
  16. package/lib/api-routes/route-metadata.js +24 -4
  17. package/lib/api-routes/submit-routes.js +41 -0
  18. package/lib/api-routes/template-routes.js +7 -0
  19. package/lib/api-routes/token-routes.js +4 -2
  20. package/lib/consts.js +30 -1
  21. package/lib/email-client/base-client.js +102 -117
  22. package/lib/email-client/gmail-client.js +87 -22
  23. package/lib/email-client/imap/mailbox.js +140 -66
  24. package/lib/email-client/outlook-client.js +17 -14
  25. package/lib/enum-descriptions.js +2 -1
  26. package/lib/field-usage.js +17 -1
  27. package/lib/lua/s-list-accounts.lua +5 -2
  28. package/lib/mcp/index.js +29 -0
  29. package/lib/mcp/inject.js +70 -0
  30. package/lib/mcp/json-schema.js +120 -0
  31. package/lib/mcp/listen.js +171 -0
  32. package/lib/mcp/oauth.js +324 -0
  33. package/lib/mcp/protocol.js +489 -0
  34. package/lib/mcp/resources.js +139 -0
  35. package/lib/mcp/tools.js +655 -0
  36. package/lib/openapi/index.js +3 -1
  37. package/lib/response-stream.js +52 -21
  38. package/lib/routes-ui.js +4 -0
  39. package/lib/schemas.js +24 -3
  40. package/lib/token-permission-view.js +104 -8
  41. package/lib/tokens.js +34 -5
  42. package/lib/tools.js +96 -0
  43. package/lib/ui-routes/account-routes.js +43 -1
  44. package/lib/ui-routes/admin-config-routes.js +114 -1
  45. package/lib/ui-routes/admin-entities-routes.js +54 -5
  46. package/lib/ui-routes/auth-routes.js +13 -0
  47. package/lib/ui-routes/mcp-consent-routes.js +330 -0
  48. package/lib/ui-routes/route-helpers.js +116 -1
  49. package/lib/utils/network.js +9 -1
  50. package/lib/web-safe-html.js +61 -0
  51. package/lib/webhooks.js +3 -8
  52. package/package.json +9 -8
  53. package/sbom.json +1 -1
  54. package/scripts/README.md +25 -0
  55. package/scripts/build-icon.js +77 -0
  56. package/static/css/flyonui.css +1 -1
  57. package/static/css/src/app.tailwind.css +98 -0
  58. package/static/emailengine.ico +0 -0
  59. package/static/js/ui.js +465 -1
  60. package/static/licenses.html +42 -22
  61. package/translations/messages.pot +57 -57
  62. package/views/config/mcp.hbs +361 -0
  63. package/views/config/oauth/index.hbs +7 -0
  64. package/views/layout/prompt.hbs +62 -0
  65. package/views/mcp/authorize.hbs +136 -0
  66. package/views/partials/head_assets.hbs +3 -3
  67. package/views/partials/mcp_access_levels.hbs +13 -0
  68. package/views/partials/mcp_account_limit.hbs +14 -0
  69. package/views/partials/mcp_tool_count.hbs +19 -0
  70. package/views/partials/side_menu.hbs +1 -0
  71. package/views/partials/ui/account-picker.hbs +59 -0
  72. package/views/partials/ui/code-block.hbs +26 -0
  73. package/views/partials/ui/menu-item.hbs +5 -0
  74. package/views/partials/ui/radio.hbs +41 -0
  75. package/views/partials/ui/tab.hbs +15 -10
  76. package/views/partials/ui/tabs.hbs +8 -5
  77. package/views/templates/template.hbs +4 -3
  78. package/views/tokens/index.hbs +8 -2
  79. package/views/tokens/new.hbs +514 -243
  80. package/winconf.js +148 -48
  81. package/workers/api.js +198 -48
package/scripts/README.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # Scripts
2
2
 
3
+ ## build-icon.js
4
+
5
+ Regenerates `static/emailengine.ico` from `static/logo.png`. The result is committed, so run
6
+ this only when the logo artwork changes - a normal build does not need ImageMagick.
7
+
8
+ ### Usage
9
+
10
+ ```bash
11
+ brew install imagemagick
12
+ npm run build:icon
13
+ ```
14
+
15
+ ### What it does
16
+
17
+ Builds a 7-image icon (256, 128, 64, 48, 32, 24, 16), PNG-compressing the two largest members
18
+ and using uncompressed 32-bit DIBs for the rest.
19
+
20
+ ### Notes
21
+
22
+ - Do not replace it with a plain `magick -define icon:auto-resize=...` call. ImageMagick writes
23
+ every member as an uncompressed BMP, and the resulting icon is large enough to break the
24
+ packaged Windows executable outright. The header comment in the script explains why.
25
+ - `winconf.js` prints the remaining `.rsrc` headroom on every build. That number is the budget
26
+ for any future icon or resource change.
27
+
3
28
  ## refresh-test-tokens.js
4
29
 
5
30
  Helper script to refresh OAuth2 tokens for Gmail test accounts.
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ // Regenerates static/emailengine.ico, the icon winconf.js stamps into the Windows executable.
5
+ // Run it when the logo artwork changes; the result is committed, so a normal build needs
6
+ // neither this script nor ImageMagick.
7
+ //
8
+ // The members are assembled here rather than by a single `magick -define icon:auto-resize=...`
9
+ // call because ImageMagick writes every one of them as an uncompressed BMP, and a 256x256 BMP
10
+ // alone is 270KB. The resulting icon is large enough to break the packaged exe - see the comment
11
+ // on payloadOffset() in winconf.js - so the two biggest sizes are PNG-compressed instead, which
12
+ // keeps the whole file around 63KB.
13
+
14
+ const { load } = require('resedit/cjs');
15
+ const { execFileSync } = require('child_process');
16
+ const { mkdtempSync, readFileSync, writeFileSync, rmSync } = require('fs');
17
+ const { tmpdir } = require('os');
18
+ const { join, resolve } = require('path');
19
+
20
+ const SOURCE = resolve(__dirname, '../static/logo.png');
21
+ const TARGET = resolve(__dirname, '../static/emailengine.ico');
22
+
23
+ // Windows renders the icon at all of these: 16 in the Explorer list view and the title bar, 32
24
+ // and 48 in the larger views, 256 for the extra large one. PNG for the two biggest, an
25
+ // uncompressed 32-bit DIB for the rest, which is the convention Windows has read since Vista
26
+ const PNG_SIZES = [256, 128];
27
+ const BMP_SIZES = [64, 48, 32, 24, 16];
28
+
29
+ function magick(args) {
30
+ try {
31
+ execFileSync('magick', args, { stdio: ['ignore', 'ignore', 'pipe'] });
32
+ } catch (err) {
33
+ if (err.code === 'ENOENT') {
34
+ throw new Error('ImageMagick is required to rebuild the icon: brew install imagemagick', { cause: err });
35
+ }
36
+ throw new Error(`magick ${args.join(' ')} failed: ${String(err.stderr || err.message).trim()}`, { cause: err });
37
+ }
38
+ }
39
+
40
+ load()
41
+ .then(ResEdit => {
42
+ const workDir = mkdtempSync(join(tmpdir(), 'ee-icon-'));
43
+
44
+ try {
45
+ const icons = [];
46
+
47
+ for (let size of PNG_SIZES) {
48
+ const file = join(workDir, `png-${size}.png`);
49
+ magick([SOURCE, '-background', 'none', '-resize', `${size}x${size}`, '-strip', '-define', 'png:compression-level=9', file]);
50
+ // The dimensions have to be passed in: RawIconItem does not read them out of the
51
+ // PNG header, and without them the directory entry is written as 0x0 at 0bpp
52
+ icons.push({ data: ResEdit.Data.RawIconItem.from(readFileSync(file), size, size, 32) });
53
+ }
54
+
55
+ // ImageMagick's own DIB members are well formed, so the small sizes are taken from an
56
+ // ico it builds rather than encoded here
57
+ const smallIco = join(workDir, 'small.ico');
58
+ magick([SOURCE, '-background', 'none', '-define', `icon:auto-resize=${BMP_SIZES.join(',')}`, smallIco]);
59
+ icons.push(...ResEdit.Data.IconFile.from(readFileSync(smallIco)).icons);
60
+
61
+ const iconFile = new ResEdit.Data.IconFile();
62
+ iconFile.icons = icons;
63
+
64
+ const ico = Buffer.from(iconFile.generate());
65
+ writeFileSync(TARGET, ico);
66
+
67
+ console.log(`Wrote ${TARGET}`);
68
+ console.log(` ${icons.length} images: ${icons.map(icon => `${icon.data.width}x${icon.data.height}`).join(', ')}`);
69
+ console.log(` ${ico.length} bytes`);
70
+ } finally {
71
+ rmSync(workDir, { recursive: true, force: true });
72
+ }
73
+ })
74
+ .catch(err => {
75
+ console.error('Error building the icon:', err);
76
+ process.exit(1);
77
+ });