domma-cms 1.79.0 → 1.81.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.
Files changed (123) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/admin/css/site-settings.css +1 -1
  3. package/admin/js/lib/site-settings-arrange.js +3 -3
  4. package/admin/js/templates/docs/usage-site-settings.html +29 -3
  5. package/admin/js/templates/settings.html +94 -4
  6. package/admin/js/views/settings.js +3 -3
  7. package/docs/DommaFeatures.md +51 -2
  8. package/docs/plans/2026-11-19-brand-kit-design.md +1 -1
  9. package/docs/plugin-development.md +6 -0
  10. package/package.json +1 -1
  11. package/plugins/_lib/admin/mail/attach-arrange.js +132 -5
  12. package/plugins/_lib/admin/mail/body-menu.js +1 -1
  13. package/plugins/_lib/admin/mail/cms-attach.js +79 -7
  14. package/plugins/_lib/admin/mail/cms-host.js +1 -1
  15. package/plugins/_lib/admin/mail/compose-window.js +15 -5
  16. package/plugins/_lib/admin/mail/contacts.js +1 -1
  17. package/plugins/_lib/admin/mail/diagnostics-section.js +1 -1
  18. package/plugins/_lib/admin/mail/drag-drop.js +33 -1
  19. package/plugins/_lib/admin/mail/folder-tree.js +1 -1
  20. package/plugins/_lib/admin/mail/font-controls.js +1 -1
  21. package/plugins/_lib/admin/mail/fonts.js +1 -1
  22. package/plugins/_lib/admin/mail/host-context.js +1 -1
  23. package/plugins/_lib/admin/mail/identity.js +1 -1
  24. package/plugins/_lib/admin/mail/image-senders-section.js +1 -1
  25. package/plugins/_lib/admin/mail/keyboard.js +1 -1
  26. package/plugins/_lib/admin/mail/mail.html +1 -1
  27. package/plugins/_lib/admin/mail/message-actions.js +1 -1
  28. package/plugins/_lib/admin/mail/oauth-panel.js +1 -1
  29. package/plugins/_lib/admin/mail/panes.js +1 -1
  30. package/plugins/_lib/admin/mail/reader-kit.js +1 -1
  31. package/plugins/_lib/admin/mail/reader-runtime.js +119 -63
  32. package/plugins/_lib/admin/mail/reader-view.js +1 -1
  33. package/plugins/_lib/admin/mail/resizable.js +1 -1
  34. package/plugins/_lib/admin/mail/restore-spam.js +1 -1
  35. package/plugins/_lib/admin/mail/rules.js +1 -1
  36. package/plugins/_lib/admin/mail/scheduling.js +1 -1
  37. package/plugins/_lib/admin/mail/section-kit.js +1 -1
  38. package/plugins/_lib/admin/mail/security-note.js +1 -1
  39. package/plugins/_lib/admin/mail/settings-section.js +6 -3
  40. package/plugins/_lib/admin/mail/templates.js +1 -1
  41. package/plugins/_lib/admin/mail/threads.js +1 -1
  42. package/plugins/_lib/admin/mail/vacation.js +1 -1
  43. package/plugins/_lib/admin/mail/when-closed.js +1 -1
  44. package/plugins/_lib/admin/ui/dates.js +1 -1
  45. package/plugins/_lib/admin/ui/resizable.js +1 -1
  46. package/plugins/_lib/admin/ui/rich-field.js +1 -1
  47. package/plugins/_lib/domma-mail.lock.json +85 -85
  48. package/plugins/_lib/mail/accountFileStore.js +1 -1
  49. package/plugins/_lib/mail/accountRepository.js +41 -2
  50. package/plugins/_lib/mail/accountRoutes.js +1 -1
  51. package/plugins/_lib/mail/bodyTokenProvider.js +1 -1
  52. package/plugins/_lib/mail/bodyTokens.js +1 -1
  53. package/plugins/_lib/mail/compose.js +1 -1
  54. package/plugins/_lib/mail/defaults.js +1 -1
  55. package/plugins/_lib/mail/envelope.js +1 -1
  56. package/plugins/_lib/mail/folderActions.js +1 -1
  57. package/plugins/_lib/mail/folderRuntime.js +1 -1
  58. package/plugins/_lib/mail/folders.js +1 -1
  59. package/plugins/_lib/mail/imapPoolRuntime.js +1 -1
  60. package/plugins/_lib/mail/mbox.js +1 -1
  61. package/plugins/_lib/mail/message-action.js +1 -1
  62. package/plugins/_lib/mail/messageSecurity.js +1 -1
  63. package/plugins/_lib/mail/messageSecurityProvider.js +1 -1
  64. package/plugins/_lib/mail/networkAddresses.js +1 -1
  65. package/plugins/_lib/mail/networkPolicy.js +1 -1
  66. package/plugins/_lib/mail/oauthAccounts.js +1 -1
  67. package/plugins/_lib/mail/oauthRouteRuntime.js +1 -1
  68. package/plugins/_lib/mail/oauthRuntime.js +1 -1
  69. package/plugins/_lib/mail/pollSchedule.js +1 -1
  70. package/plugins/_lib/mail/poller.js +1 -1
  71. package/plugins/_lib/mail/pollerRuntime.js +1 -1
  72. package/plugins/_lib/mail/priority.js +1 -1
  73. package/plugins/_lib/mail/publicMailbox.js +1 -1
  74. package/plugins/_lib/mail/readRuntime.js +1 -1
  75. package/plugins/_lib/mail/render.js +1 -1
  76. package/plugins/_lib/mail/ruleRunner.js +1 -1
  77. package/plugins/_lib/mail/schedulerRuntime.js +1 -1
  78. package/plugins/_lib/mail/secretProvider.js +1 -1
  79. package/plugins/_lib/mail/secretbox.js +1 -1
  80. package/plugins/_lib/mail/senderAuth.js +1 -1
  81. package/plugins/_lib/mail/sieve.js +1 -1
  82. package/plugins/_lib/mail/smtpService.js +1 -1
  83. package/plugins/_lib/mail/snoozeRuntime.js +1 -1
  84. package/plugins/_lib/mail/store.js +1 -1
  85. package/plugins/_lib/mail/subscriptions.js +1 -1
  86. package/plugins/_lib/mail/syncPlan.js +1 -1
  87. package/plugins/_lib/mail/syncRuntime.js +1 -1
  88. package/plugins/_lib/mail/syncSelection.js +1 -1
  89. package/plugins/_lib/mail/unreadBadge.js +1 -1
  90. package/plugins/_lib/mail/unsubscribe.js +1 -1
  91. package/plugins/_lib/mail/vacationRuntime.js +1 -1
  92. package/plugins/_lib/mail/write.js +1 -1
  93. package/plugins/_lib/public/rich-text.mjs +1 -1
  94. package/plugins/_lib/rich-text.js +1 -1
  95. package/plugins/_lib/telegram/bot.js +120 -0
  96. package/plugins/free-tier.lock.json +26 -1
  97. package/plugins/telegram/CHANGELOG.md +5 -0
  98. package/plugins/telegram/CLAUDE.md +77 -0
  99. package/plugins/telegram/admin/css/index.css +68 -0
  100. package/plugins/telegram/admin/lib/arrange.js +103 -0
  101. package/plugins/telegram/admin/lib/kit.js +153 -0
  102. package/plugins/telegram/admin/templates/telegram.html +1 -0
  103. package/plugins/telegram/admin/views/chats.js +223 -0
  104. package/plugins/telegram/admin/views/connection.js +90 -0
  105. package/plugins/telegram/admin/views/telegram.js +89 -0
  106. package/plugins/telegram/admin/views/test.js +84 -0
  107. package/plugins/telegram/config.js +21 -0
  108. package/plugins/telegram/docs/guide.md +87 -0
  109. package/plugins/telegram/lib/messages.js +176 -0
  110. package/plugins/telegram/lib/queue.js +72 -0
  111. package/plugins/telegram/plugin.js +490 -0
  112. package/plugins/telegram/plugin.json +71 -0
  113. package/plugins/telegram/tests/api.test.js +381 -0
  114. package/plugins/telegram/tests/arrange.test.js +41 -0
  115. package/plugins/telegram/tests/messages.test.js +110 -0
  116. package/plugins/telegram/tests/queue.test.js +47 -0
  117. package/server/routes/api/brand-kit.js +55 -0
  118. package/server/routes/api/settings.js +17 -1
  119. package/server/server.js +2 -0
  120. package/server/services/brandKit.js +268 -0
  121. package/server/services/emailBrand.js +31 -13
  122. package/server/services/notify.js +20 -2
  123. package/server/services/plugins.js +3 -0
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/accountRepository.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/accountRepository.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  export const POLL_INTERVALS = Object.freeze([3, 5, 10, 15]);
4
4
  import {randomUUID} from 'node:crypto';
@@ -9,6 +9,27 @@ import {activeAwayId, normaliseAwayMessages, normaliseVacation} from '../admin/m
9
9
  import {normaliseUndoSeconds} from '../admin/mail/scheduling.js';
10
10
  import {normaliseRules, normaliseRuleGroups, rulesInEffect} from '../admin/mail/rules.js';
11
11
 
12
+ export const COMPOSE_DEFAULTS = Object.freeze({
13
+ readReceipt: false,
14
+ deliveryReceipt: false,
15
+ sign: false,
16
+ encrypt: false,
17
+ repliesInSourceFolder: false,
18
+ requireSecureDelivery: false
19
+ });
20
+
21
+ /**
22
+ * This mailbox's compose options, every key present.
23
+ *
24
+ * @param {object|null} account
25
+ * @returns {typeof COMPOSE_DEFAULTS}
26
+ */
27
+ export function composeOptions(account) {
28
+ const stored = account?.compose && typeof account.compose === 'object' ? account.compose : {};
29
+ return Object.fromEntries(Object.keys(COMPOSE_DEFAULTS)
30
+ .map(key => [key, stored[key] === true]));
31
+ }
32
+
12
33
  /** Shared lifecycle extracted unchanged from the matching CMS and DCM account implementations. */
13
34
  export function createAccountRepository({store, secrets, isOAuth = account => account?.auth === 'oauth' && !!account.oauth, oauthConnection} = {}) {
14
35
  if (!store || !secrets) throw new Error('Mail storage and a secret provider are required.');
@@ -696,5 +717,23 @@ export function createAccountRepository({store, secrets, isOAuth = account => ac
696
717
  return all[index];
697
718
  });
698
719
  }
699
- return {sieveToPublic, setSieve, vacationToPublic, awayMessagesToPublic, setAwayMessages, sendingAddresses, setVacation, snoozeFolder, undoSendSeconds, setSendingOptions, rulesToPublic, ruleGroupsToPublic, rulesToRun, ruleFolders, setRules, rewriteFolderPaths, setIdentities, setTemplates, listAllAccounts, setPollInterval, setSyncFolders, setNotificationFolders, isOAuth, validate, listAccounts, setDefaultAccount, getAccount, saveAccount, deleteAccount, deleteAccountsForUser, pruneOrphans, toConnection, setSmtp, toSmtpConnection, smtpToPublic, trustImageSender, untrustImageSender, setRememberImageSenders, sendersImagesTrusted, setContactImages, contactImagesAllowed};
720
+
721
+ async function setComposeOptions(userId, accountId, options) {
722
+ return withStoreLock(async () => {
723
+ const all = await readAll();
724
+ const index = all.findIndex(a => a.id === accountId && a.userId === userId);
725
+ if (index === -1) return null;
726
+
727
+ const next = composeOptions(all[index]);
728
+ for (const key of Object.keys(COMPOSE_DEFAULTS)) {
729
+ if (typeof options?.[key] === 'boolean') next[key] = options[key];
730
+ }
731
+ all[index] = {...all[index], compose: next, updatedAt: new Date().toISOString()};
732
+ await writeAll(all);
733
+ return all[index];
734
+ });
735
+ }
736
+
737
+
738
+ return {composeOptions, setComposeOptions, sieveToPublic, setSieve, vacationToPublic, awayMessagesToPublic, setAwayMessages, sendingAddresses, setVacation, snoozeFolder, undoSendSeconds, setSendingOptions, rulesToPublic, ruleGroupsToPublic, rulesToRun, ruleFolders, setRules, rewriteFolderPaths, setIdentities, setTemplates, listAllAccounts, setPollInterval, setSyncFolders, setNotificationFolders, isOAuth, validate, listAccounts, setDefaultAccount, getAccount, saveAccount, deleteAccount, deleteAccountsForUser, pruneOrphans, toConnection, setSmtp, toSmtpConnection, smtpToPublic, trustImageSender, untrustImageSender, setRememberImageSenders, sendersImagesTrusted, setContactImages, contactImagesAllowed};
700
739
  }
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/accountRoutes.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/accountRoutes.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import {MailKeyError} from './secretProvider.js';
4
4
 
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/bodyTokenProvider.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/bodyTokenProvider.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import {createHmac, timingSafeEqual} from 'node:crypto';
4
4
 
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/bodyTokens.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/bodyTokens.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** CMS compatibility entry point for the existing iframe grant API. */
4
4
  import {resolveKeySource} from './secretbox.js';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/compose.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/compose.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Turning a message into a reply, and a reply into something sendable.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/defaults.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/defaults.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Reading defaults, shared by every edition.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/envelope.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/envelope.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The shape the mirror holds one message in.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/folderActions.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/folderActions.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Whole-folder operations use a snapshot of UIDs, never the visible page or a moving '*'. */
4
4
  import {moveBulk, setFlagsBulk} from './write.js';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/folderRuntime.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/folderRuntime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Portable folder operations. Hosts supply ownership, serialization and metadata updates. */
4
4
  import {validateFolderName, buildFolderPath, renameTarget, canModifyFolder, descendantsOf, moveTarget, resolveSubscriptions} from './folders.js';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/folders.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/folders.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import {resolveSubscriptions} from './subscriptions.js';
4
4
  /**
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/imapPoolRuntime.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/imapPoolRuntime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * IMAP connection pool for the Mail Reader plugin.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/mbox.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/mbox.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Exporting a folder as mbox.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/message-action.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/message-action.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Remember replies and forwards on the original message after delivery. */
4
4
  export const SOURCE_HEADER = 'X-Domma-Message-Source';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/messageSecurity.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/messageSecurity.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import {createMessageSecurity} from './messageSecurityProvider.js';
4
4
  export const {setMessageSecurity, canProtect, protectRaw, protectDraftRaw, unwrapRaw, parseReadable} = createMessageSecurity();
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/messageSecurityProvider.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/messageSecurityProvider.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Where signing and encryption plug into the mail core.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/networkAddresses.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/networkAddresses.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Address classification from the CMS outbound policy, MIT licensed. */
4
4
  import net from 'node:net';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/networkPolicy.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/networkPolicy.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import dns from 'node:dns/promises';
4
4
  import net from 'node:net';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/oauthAccounts.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/oauthAccounts.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import {randomUUID} from 'node:crypto';
4
4
  import {MailKeyError} from './secretProvider.js';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/oauthRouteRuntime.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/oauthRouteRuntime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The OAuth2 sign-in routes for mailboxes: Connect, the provider's callback,
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/oauthRuntime.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/oauthRuntime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * OAuth2 sign-in for mailboxes (XOAUTH2) - Microsoft 365 / Outlook.com and Gmail.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/pollSchedule.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/pollSchedule.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Deciding which mailboxes are due a poll.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/poller.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/poller.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Compatibility entry point for the shared mail poller. */
4
4
  export {createPoller} from './pollerRuntime.js';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/pollerRuntime.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/pollerRuntime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The background poller.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/priority.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/priority.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * How urgent a sender said a message was.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/publicMailbox.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/publicMailbox.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Standalone mailbox summary. Explicit fields keep credentials out of responses. */
4
4
  export function publicMailbox(account) {
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/readRuntime.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/readRuntime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import {registerAccountRoutes} from './accountRoutes.js';
4
4
  import {ENVELOPE_QUERY, hasAttachment, parseHeaderBlock} from './envelope.js';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/render.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/render.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Message rendering for the Mail Reader plugin.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/ruleRunner.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/ruleRunner.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Carrying out what the rules decided.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/schedulerRuntime.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/schedulerRuntime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The worker behind "send later", "undo send" and "snooze".
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/secretProvider.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/secretProvider.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import {createCipheriv, createDecipheriv, createHash, randomBytes, scryptSync} from 'node:crypto';
4
4
  import fs from 'node:fs';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/secretbox.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/secretbox.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** CMS compatibility entry point. Standalone hosts create their own secret box. */
4
4
  import path from 'node:path';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/senderAuth.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/senderAuth.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Did this message really come from the address in its From line?
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/sieve.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/sieve.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** ManageSieve (RFC 5804). One bounded, TLS-verified session per operation. */
4
4
  import net from 'node:net';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/smtpService.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/smtpService.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Sending, and keeping a copy where the rest of your clients will find it.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/snoozeRuntime.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/snoozeRuntime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import {safeWritePool, moveMessage} from './write.js';
4
4
 
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/store.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/store.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The synchronised message store.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/subscriptions.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/subscriptions.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  export function resolveSubscriptions(boxes) {
4
4
  const list = boxes ?? [];
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/syncPlan.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/syncPlan.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Deciding what a folder sync needs to do.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/syncRuntime.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/syncRuntime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import {missingUids, planFolderSync} from './syncPlan.js';
4
4
  import {resolveSyncFolders} from './syncSelection.js';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/syncSelection.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/syncSelection.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Which folders a mailbox keeps mirrored.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/unreadBadge.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/unreadBadge.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The free reader's sidebar badge - unread mail in each mailbox's INBOX.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/unsubscribe.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/unsubscribe.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Getting off a mailing list.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/vacationRuntime.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/vacationRuntime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  import {randomUUID} from 'node:crypto';
4
4
  import {autoReplyHeaders, isActive, normaliseVacation, replySubject, shouldAutoReply, replyHistory} from '../admin/mail/vacation.js';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/mail/write.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/mail/write.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Changing mail, rather than reading it.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/public/rich-text.mjs.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/public/rich-text.mjs.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Rich text in a Description field - the pure part, shared by the server, the
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.36.0, packages/core/src/rich-text.js.
1
+ // Source: @domma-mail/core 0.38.0, packages/core/src/rich-text.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Rich text Description fields - cleaning what is saved and what is shown.
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Telegram: the Bot API over fetch (no SDK) - the parts any Tool needs.
3
+ *
4
+ * Lifted from Takeaway's lib/telegram.js (which keeps its own copy and its kitchen and customer wording) for the
5
+ * Telegram and Telegram Pro Tools. A bot is made by the site owner with @BotFather; its token is a secret the Tool
6
+ * keeps on the server and never sends back to the browser. Telegram reaches a Tool through a webhook carrying
7
+ * `X-Telegram-Bot-Api-Secret-Token` (the Tool's own random secret) - check it with `sameSecret`.
8
+ *
9
+ * Nothing here throws at the caller: every call has a timeout, and `call` answers {ok: false, description}.
10
+ * Tests swap the transport with `setTelegram()`, so no test ever reaches Telegram.
11
+ *
12
+ * @module _lib/telegram/bot
13
+ */
14
+ import {randomInt, timingSafeEqual} from 'crypto';
15
+
16
+ const API = 'https://api.telegram.org';
17
+ let transport = null;
18
+
19
+ /** Tests only: `fn(method, body, token)` answers instead of Telegram. Pass null to restore. */
20
+ export function setTelegram(fn) { transport = typeof fn === 'function' ? fn : null; }
21
+
22
+ /**
23
+ * One Bot API call.
24
+ * @param {string} token
25
+ * @param {string} method - 'getMe', 'sendMessage', 'setWebhook', …
26
+ * @param {object} [body]
27
+ * @returns {Promise<{ok: boolean, result?: any, description?: string, error_code?: number, parameters?: object}>}
28
+ */
29
+ export async function call(token, method, body = {}) {
30
+ if (!token) return {ok: false, description: 'No bot token.'};
31
+ try {
32
+ if (transport) return (await transport(method, body, token)) || {ok: false, description: 'No answer.'};
33
+ const res = await fetch(`${API}/bot${token}/${method}`, {method: 'POST', headers: {'Content-Type': 'application/json'},
34
+ body: JSON.stringify(body), signal: AbortSignal.timeout(8000)});
35
+ const json = await res.json().catch(() => ({ok: false, description: `Telegram answered ${res.status}`}));
36
+ return json && typeof json === 'object' ? json : {ok: false, description: 'Telegram sent nothing back.'};
37
+ } catch (err) {
38
+ return {ok: false, description: err?.name === 'TimeoutError' ? 'Telegram did not answer in time.' : (err?.message || String(err))};
39
+ }
40
+ }
41
+
42
+ /** A bot token's shape (123456789:AA…). */
43
+ export const tokenShape = (t) => /^\d{5,15}:[A-Za-z0-9_-]{30,60}$/.test(String(t || '').trim());
44
+
45
+ /** Telegram's HTML is a short whitelist; everything of ours is escaped. Quotes too, for attribute values. */
46
+ export const esc = (s) => String(s ?? '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
47
+
48
+ /**
49
+ * Telegram refuses a message over 4096 characters, and refuses the whole message when its HTML does not parse.
50
+ * So text is cut BEFORE it becomes HTML, never after: `escFit` escapes a plain string and stops while the
51
+ * escaped result still fits `max`; `fitLines` joins finished HTML lines whole, dropping the ones that do not fit.
52
+ */
53
+ export const MAX_TEXT = 4000;
54
+
55
+ /** `s` escaped, cut (with "…") so the escaped text is at most `max` characters. Never splits an entity. */
56
+ export function escFit(s, max = MAX_TEXT) {
57
+ const raw = String(s ?? '');
58
+ const whole = esc(raw);
59
+ if (whole.length <= max) return whole;
60
+ let out = '';
61
+ for (const ch of raw) {
62
+ const e = esc(ch);
63
+ if (out.length + e.length > max - 1) break;
64
+ out += e;
65
+ }
66
+ return `${out}…`;
67
+ }
68
+
69
+ /**
70
+ * Finished HTML lines joined with newlines, at most `max` characters. `keep` lines (a link, say) always stay
71
+ * at the end; the others are taken in order while they fit, and a `more` line says something was left out.
72
+ */
73
+ export function fitLines(lines, {max = MAX_TEXT, keep = [], more = '…'} = {}) {
74
+ const tail = keep.filter(Boolean);
75
+ let budget = max - tail.reduce((n, l) => n + l.length + 1, 0);
76
+ const out = [];
77
+ for (let i = 0; i < lines.length; i++) {
78
+ const l = String(lines[i] ?? '');
79
+ const room = budget - (l.length + 1);
80
+ if (room < (i < lines.length - 1 ? more.length + 1 : 0)) { out.push(more); break; }
81
+ out.push(l);
82
+ budget = room;
83
+ }
84
+ return [...out, ...tail].join('\n');
85
+ }
86
+
87
+ /** Plain text cut to `max` characters (for text that is not HTML). */
88
+ export function clip(text, max = MAX_TEXT) {
89
+ const s = String(text ?? '');
90
+ return s.length <= max ? s : `${s.slice(0, max - 1)}…`;
91
+ }
92
+
93
+ export const sendMessage = (token, chatId, text, extra = {}) => call(token, 'sendMessage', {chat_id: chatId, text, parse_mode: 'HTML', disable_web_page_preview: true, ...extra});
94
+
95
+ /**
96
+ * A one-time code: letters and digits only (no look-alikes), as /start payloads and typing allow. From the
97
+ * CSPRNG, never Math.random - a guessed link code would let a stranger's chat receive what the site sends.
98
+ */
99
+ const CODE_CHARS = 'abcdefghjkmnpqrstuvwxyz23456789';
100
+ export const randomCode = (n = 16) => Array.from({length: n}, () => CODE_CHARS[randomInt(CODE_CHARS.length)]).join('');
101
+
102
+ /** "/start o7xk2…" -> {command: 'start', arg: 'o7xk2…'}; also "/link@MyBot code". Not a command -> null. */
103
+ export function parseCommand(text) {
104
+ const m = /^\/([a-z_]+)(?:@\w+)?(?:\s+(\S+))?/i.exec(String(text || '').trim());
105
+ return m ? {command: m[1].toLowerCase(), arg: m[2] || ''} : null;
106
+ }
107
+
108
+ /** Timing-safe: is `given` the non-empty secret `want`? For the webhook header and link codes. */
109
+ export function sameSecret(given, want) {
110
+ const a = Buffer.from(String(given ?? ''));
111
+ const b = Buffer.from(String(want ?? ''));
112
+ return b.length > 0 && a.length === b.length && timingSafeEqual(a, b);
113
+ }
114
+
115
+ /** A chat's name for the admin: the group's title, else the person's name, else @username. */
116
+ export function chatName(chat) {
117
+ if (!chat) return '';
118
+ const s = chat.title || [chat.first_name, chat.last_name].filter(Boolean).join(' ') || (chat.username ? `@${chat.username}` : '') || 'this chat';
119
+ return String(s).slice(0, 80);
120
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "note": "Written by `make sync-free-tier` in dcms-marketplace. Do not edit these plugins here - edit them there and sync.",
3
- "source": "dcms-marketplace@5d5eabe5",
3
+ "source": "dcms-marketplace@fc42d294",
4
4
  "plugins": {
5
5
  "blog": {
6
6
  "version": "1.11.0",
@@ -347,6 +347,31 @@
347
347
  "tests/shape.test.js": "7866c6c1d140716bf0817449937d6d711d7c3b97be1db1e1eb33bde341e36296"
348
348
  }
349
349
  },
350
+ "telegram": {
351
+ "version": "0.1.0",
352
+ "files": {
353
+ "CHANGELOG.md": "ea40431f37d2e1fad82169952197ae7a3636c8a0e16334c29af171037e13eaae",
354
+ "CLAUDE.md": "620e8133a023bf861b7f4a4b07dd47876ca0622f75f08313b07fd22d2dbbef0b",
355
+ "admin/css/index.css": "39eba0652bf8aad92296f3916d9870c4c6c682a4a6f6183d85c4045992c661e8",
356
+ "admin/lib/arrange.js": "9479d259020b58c40478e37c771efbf7932396df87829333d8cbb6d42bea5f28",
357
+ "admin/lib/kit.js": "63bb373dbb6dd082432470db9f1df155f5322f89f4586c731639c33e863beacf",
358
+ "admin/templates/telegram.html": "081efacde0d270fe8382f5d0bcfe4cac59e5015e8e2193787d0d684fa499b493",
359
+ "admin/views/chats.js": "b5d533e3a0952dbd88a323f08b7e74130e2f5ce410dac6b10f4ed22232ee8573",
360
+ "admin/views/connection.js": "d39834f2c5e3827b083cc56706cd08c87457937ea6e12706df8cea0be1ee38ba",
361
+ "admin/views/telegram.js": "ff38bddd2ae5908874f400750fab8ba8e4080c308444dce7528f12a1373a37ec",
362
+ "admin/views/test.js": "5417a8b0a7427cc1f874886dddbe56d8625652619835b864f6e968eb95c419a7",
363
+ "config.js": "eb508631684a4bf4fc9dd28f0c7837d04b6e54458d8795d01405908cae51b379",
364
+ "docs/guide.md": "c44a50c844e372bcdec9734198ea68c796048cffb6e4fcfa7f9aa874a5cb8a20",
365
+ "lib/messages.js": "5e4eb97a9e48fc8eb89c8c2ad05360e9b46aa909f9cab94147ee46ccf74bd9c5",
366
+ "lib/queue.js": "be269c6b2c4f3a6dfbe23ffd92170aefb70a1d7e27467ec7493ddb022cdebdcb",
367
+ "plugin.js": "fa1b583984b4afda03e553a5c9096ac30734f60203c48874a3631972d22ec670",
368
+ "plugin.json": "93c32b7a419e704fef4ec8791a23bc5f63e0d1bc7b963a1363126b7a8c40142c",
369
+ "tests/api.test.js": "bf1d9842adb8140f018a5ac9f7323dec01e7ee771cba0c52480e074656f87fe6",
370
+ "tests/arrange.test.js": "d90880c4566bde57f59f3a3385a0e9aabfb5b5725b954a06f94ec687a904b56b",
371
+ "tests/messages.test.js": "77b5cb5b700710766a9512a51f3b0dc2bcdb57962f5a325cdf91f68e9f98bc68",
372
+ "tests/queue.test.js": "119217c78be85739b2f4330b6d4026b7c281d7b7e81d4b1f85e13f79163dad51"
373
+ }
374
+ },
350
375
  "theme-roller": {
351
376
  "version": "1.3.0",
352
377
  "files": {
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## [0.1.0] - 2026-11-19
4
+
5
+ - **New Tool: Telegram (free).** Connect your own Telegram bot and link any number of chats - your team's group or one person's chat with the bot - with a one-time code. Each chat chooses which alerts it gets (how serious, from which Tools) and which forms; a form submission arrives with its answers, or with the form's title and a link only. Passwords, files, images and hidden fields are never sent, nor notifications meant for one person, and a chat gets only what the person who set it up may see in the admin. Tabs: Connection, Chats, Test.