@sayedhfatimi/convex-email 0.1.2 → 0.1.3
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/README.md +18 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/sayedhfatimi/convex-email/main/docs/brand/convex-email.on-dark.svg">
|
|
4
|
+
<img alt="convex-email, a Valeon project" src="https://raw.githubusercontent.com/sayedhfatimi/convex-email/main/docs/brand/convex-email.svg" width="440">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p align="center"><strong>Email for Convex, both ways.</strong></p>
|
|
9
|
+
|
|
1
10
|
# @sayedhfatimi/convex-email
|
|
2
11
|
|
|
3
12
|
Send **and receive** email in [Convex](https://convex.dev), on Resend or Amazon SES, so you can build inboxes, support desks and reply-by-email into your app. One client class, `Email`, stores every message and delivery event and keeps suppressions, unsubscribes and threads in one place, so you can move from one provider to the other without losing any of it.
|
|
4
13
|
|
|
5
|
-
Live demo: [convex-email.dev](https://convex-email.dev) (
|
|
14
|
+
Live demo: [convex-email.dev](https://convex-email.dev) is a public inbox: email it and watch your message arrive, parsed and verified, grouped into tickets by thread. It also sends to Resend's test addresses. Its source is [convex-email-demo](https://github.com/sayedhfatimi/convex-email-demo).
|
|
15
|
+
|
|
16
|
+
Guides: [build a support desk, reply-by-email and a team inbox per tenant](https://github.com/sayedhfatimi/convex-email/blob/main/docs/guides/README.md).
|
|
6
17
|
|
|
7
18
|
## Why convex-email
|
|
8
19
|
|
|
@@ -242,6 +253,8 @@ export const filteredResendWebhook = httpAction(async (ctx, request) => {
|
|
|
242
253
|
|
|
243
254
|
## Build a mailbox
|
|
244
255
|
|
|
256
|
+
The [guides](https://github.com/sayedhfatimi/convex-email/blob/main/docs/guides/README.md) go further, starting with the [support desk walkthrough](https://github.com/sayedhfatimi/convex-email/blob/main/docs/guides/support-desk.md).
|
|
257
|
+
|
|
245
258
|
With the set-up above, an inbox, a support desk or reply-by-email is a table of your own plus a few functions. Your `onInbound` mutation files each message under its `threadId`; your queries list a thread; replies go out with `inReplyTo`, which puts them in the same thread.
|
|
246
259
|
|
|
247
260
|
The table, and the `onInbound` mutation that fills it (set it as `onInbound` in the `Email` options):
|
|
@@ -331,7 +344,7 @@ export const messageBody = action({
|
|
|
331
344
|
},
|
|
332
345
|
});
|
|
333
346
|
|
|
334
|
-
/** A
|
|
347
|
+
/** A download URL for one attachment, which serves it while it is stored. */
|
|
335
348
|
export const attachmentLink = query({
|
|
336
349
|
args: { messageId: v.string(), attachmentId: v.string() },
|
|
337
350
|
handler: async (ctx, { messageId, attachmentId }): Promise<string | null> => {
|
|
@@ -515,7 +528,7 @@ export const finishUpload = mutation({
|
|
|
515
528
|
|
|
516
529
|
### Statuses
|
|
517
530
|
|
|
518
|
-
A message's `status` is one of `queued`, `test`, `suppressed`, `sending`, `sent`, `delivery_delayed`, `delivered`, `bounced`, `complained`, `failed`, `rejected` (and `received` for inbound mail). It only moves forward, so events that arrive out of order cannot undo a later state. `mail.status(ctx, id)` returns it; `mail.get(ctx, id)` returns the message with its attachments, events and
|
|
531
|
+
A message's `status` is one of `queued`, `test`, `suppressed`, `sending`, `sent`, `delivery_delayed`, `delivered`, `bounced`, `complained`, `failed`, `rejected` (and `received` for inbound mail). It only moves forward, so events that arrive out of order cannot undo a later state. `mail.status(ctx, id)` returns it; `mail.get(ctx, id)` returns the message with its attachments, events and URLs that serve the stored bodies while they are stored (`null` once `cleanup` has removed them).
|
|
519
532
|
|
|
520
533
|
Delivery to the provider is retried when the failure is transient (8 attempts, backing off from 5 s and doubling: about ten minutes in all), and recorded as `failed` with an error text when it is not or when the attempts run out. A provider 5xx counts as a possible acceptance: the message is marked `deliveryAmbiguous` (and is still retried). Resend's daily or monthly quota error fails at once, without retries. The error text never contains a credential and is cut to 1000 characters. The transactional queue runs 4 sends at a time, the bulk queue 2.
|
|
521
534
|
|
|
@@ -750,9 +763,9 @@ export const routeInbound = internalMutation({
|
|
|
750
763
|
|
|
751
764
|
What the handler receives (`InboundForApp`): `messageId`, `tenant`, `provider` (`"resend"`, `"ses"` or `"raw"`), `from`, `to`, `cc`, `subject`, `text`, `textFromHtml`, cleaned `html`, `bodyByReference`, `hasRemoteImages`, `attachments` (`id`, `filename`, `contentType`, `size`), `verdicts` (`spf`, `dkim`, `dmarc`), `threadId`, `parent`, `truncated`, `tenantAdopted`, and the stored `headers`. The `note` you return is kept on the inbound row (`appNote` in `listUnhandled`), handled or not.
|
|
752
765
|
|
|
753
|
-
- **Bodies.** Text plus HTML over 256 KiB are not passed inline (`bodyByReference: true`); read them in an action with `mail.inboundBody(ctx, messageId)`. Attachment bytes: `mail.attachmentUrl(ctx, attachmentId)` returns a
|
|
766
|
+
- **Bodies.** Text plus HTML over 256 KiB are not passed inline (`bodyByReference: true`); read them in an action with `mail.inboundBody(ctx, messageId)`. Attachment bytes: `mail.attachmentUrl(ctx, attachmentId)` returns a URL that serves the file while it is stored. Treat these URLs, and `get`'s body URLs, as secrets: anyone with one can fetch the file until `cleanup` deletes it, so hand them only to authorised users.
|
|
754
767
|
- **Text.** `text` is present whenever the message had any body. When the sender sent no text part (absent, empty or only whitespace) but did send HTML (common for automated senders), the component derives `text` from the HTML (read before cleaning, so `<title>`, `<noscript>`, `<template>`, `<svg>`, `hidden` and `display:none` content such as preheaders is left out) and sets `textFromHtml: true` on the `onInbound` message and on the `get` view. Blocks and `<br>` become line breaks, list items get `- `, a link reads `text [url]` (just the text when it equals the URL), entities are decoded, and images, styles, scripts, zero-width padding and tracking pixels are dropped. A real text part is kept verbatim and `textFromHtml` is absent. A message with no readable content in either part has no `text`. Derived text is cut at 1 MiB (and the message marked `truncated`), and the HTML it is read from at 2 MiB.
|
|
755
|
-
- **HTML** is cleaned with an allow-list. Remote images are kept but flagged (`hasRemoteImages`, and each one carries `data-remote-image`) so you can block or allow them; block them by default. Inline raster `data:` images (png, jpeg, gif, webp; base64 only) are kept and not flagged, since Resend's Receiving API may inline `cid:` images as data URIs; every other `data:` source is dropped. Bodies and attachments served by
|
|
768
|
+
- **HTML** is cleaned with an allow-list. Remote images are kept but flagged (`hasRemoteImages`, and each one carries `data-remote-image`) so you can block or allow them; block them by default. Inline raster `data:` images (png, jpeg, gif, webp; base64 only) are kept and not flagged, since Resend's Receiving API may inline `cid:` images as data URIs; every other `data:` source is dropped. Bodies and attachments served by these URLs come from the deployment's storage origin with the sender's content type: never open them on a sensitive origin (one that holds your session).
|
|
756
769
|
- **Parent.** When the message answers one of ours, `parent` has the outbound message id and its `tags`. `senderWasRecipient` is `true` only when the inbound `From` was one of that message's recipients; check it before trusting `parent.tags` (ticket ids, say), because anyone can quote our Message-ID.
|
|
757
770
|
- **Adopted tenant.** `tenantAdopted: true` (also readable from `get`) means the message arrived with no tenant (an account-level route) and took `tenant` from the outbound message it answers, because its `From` was one of that message's recipients. `From` is not authenticated by itself: check `verdicts` (DMARC) before acting on an adopted tenant.
|
|
758
771
|
- **Message-IDs** are stored in `<…>` form whatever the provider hands over, so replies thread to your outbound mail on every adapter.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sayedhfatimi/convex-email",
|
|
3
3
|
"description": "A provider-neutral email component for Convex, with Resend and Amazon SES adapters.",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.3",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "sayedhfatimi",
|
|
7
7
|
"homepage": "https://github.com/sayedhfatimi/convex-email#readme",
|