@repa/mail 0.0.0-stage → 0.1.0-alpha.20
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/LICENSE +36 -0
- package/README.md +172 -2
- package/dist/browser-denied.d.ts +7 -0
- package/dist/browser-denied.js +14 -0
- package/dist/chunk-CXNVFCRT.js +879 -0
- package/dist/chunk-XW4CRZRY.js +47 -0
- package/dist/contracts.d.ts +1278 -0
- package/dist/contracts.js +1 -0
- package/dist/errors-B_W1C1Hu.d.ts +115 -0
- package/dist/index.d.ts +947 -0
- package/dist/index.js +275 -0
- package/dist/operations-14iYfteB.d.ts +3699 -0
- package/package.json +57 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Repa SDK Pre-Release Evaluation License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Repa. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Subject to the restrictions below, Repa grants you a limited, revocable,
|
|
6
|
+
non-exclusive, non-transferable, non-sublicensable license to install and use
|
|
7
|
+
this pre-release SDK solely to evaluate Repa and to develop and test
|
|
8
|
+
integrations that communicate with Repa services using credentials you are
|
|
9
|
+
authorized to use.
|
|
10
|
+
|
|
11
|
+
You may not:
|
|
12
|
+
|
|
13
|
+
1. use the SDK in production or provide it as part of a production service;
|
|
14
|
+
2. copy, publish, redistribute, sublicense, sell, rent, lease, or otherwise
|
|
15
|
+
make the SDK available to another party;
|
|
16
|
+
3. modify the SDK, create derivative works from it, or reverse engineer,
|
|
17
|
+
decompile, or disassemble it, except to the limited extent applicable law
|
|
18
|
+
expressly prohibits this restriction;
|
|
19
|
+
4. use the SDK or information derived from it to create or improve a product
|
|
20
|
+
or service that competes with Repa; or
|
|
21
|
+
5. remove or alter proprietary notices.
|
|
22
|
+
|
|
23
|
+
Repa and its licensors retain all ownership and intellectual-property rights
|
|
24
|
+
in the SDK. No rights are granted except those stated expressly in this
|
|
25
|
+
license. Access to Repa services remains subject to the applicable service
|
|
26
|
+
terms and may be suspended or terminated independently of this license.
|
|
27
|
+
|
|
28
|
+
This license terminates automatically if you breach it or when Repa replaces
|
|
29
|
+
this pre-release license for the SDK version you use. On termination, you must
|
|
30
|
+
stop using and delete the SDK.
|
|
31
|
+
|
|
32
|
+
THE SDK IS PRE-RELEASE SOFTWARE PROVIDED "AS IS" AND "AS AVAILABLE", WITHOUT
|
|
33
|
+
WARRANTIES OR CONDITIONS OF ANY KIND. TO THE MAXIMUM EXTENT PERMITTED BY LAW,
|
|
34
|
+
REPA WILL NOT BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL,
|
|
35
|
+
OR EXEMPLARY DAMAGES, OR FOR LOSS OF DATA, PROFITS, REVENUE, OR BUSINESS,
|
|
36
|
+
ARISING FROM OR RELATED TO THE SDK.
|
package/README.md
CHANGED
|
@@ -1,3 +1,173 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @repa/mail
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Server-only ESM TypeScript client for repa mail, on Node 22.12+ within
|
|
4
|
+
Node 22 and Node 24. Root exports reject browsers/workers. `/contracts` is
|
|
5
|
+
browser-safe. This package uses the repa evaluation licence; no public
|
|
6
|
+
production SLA or stable production-use terms are promised.
|
|
7
|
+
|
|
8
|
+
Published on npm: **0.1.0-alpha.19** on the `alpha` channel (first publication
|
|
9
|
+
0.1.0-alpha.18 on 2026-11-08, EMAIL-D226). Pin the exact version; a matching mail service
|
|
10
|
+
deployment is qualified separately.
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install @repa/mail@0.1.0-alpha.19
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
This package was named `@repa/email-server` until 0.1.0-alpha.17 (EMAIL-D226).
|
|
17
|
+
Only the package name changed: every export keeps its name, so an existing
|
|
18
|
+
integration changes only its import specifier.
|
|
19
|
+
|
|
20
|
+
## Send a first message
|
|
21
|
+
|
|
22
|
+
Create an integration in mail Settings → Integrations and grant its sender.
|
|
23
|
+
Keep its key in a backend secret store; ordinary workspace API keys cannot send
|
|
24
|
+
mail. Verify the sender domain and use an owned recipient for a first test.
|
|
25
|
+
|
|
26
|
+
Save one durable job before sending: its UUID `idempotencyKey`, opaque host
|
|
27
|
+
`subject` and frozen `message`. A message contains `from` (one authorized address
|
|
28
|
+
string, optionally `Accounts <receipts@example.com>`), `to`/`cc`/`bcc`, `subject`,
|
|
29
|
+
`text` and/or `html`, and optional base64 attachments. `senderId` and
|
|
30
|
+
`sentAccountId` are not structured-send inputs. Then pass the saved job to:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { createEmailClient, type EmailMessage } from '@repa/mail';
|
|
34
|
+
|
|
35
|
+
export async function sendSavedMessage(job: {
|
|
36
|
+
subject: string; idempotencyKey: string; message: EmailMessage;
|
|
37
|
+
}, apiKey: string) {
|
|
38
|
+
const mail = createEmailClient({ apiKey, subject: job.subject });
|
|
39
|
+
return mail.send(job.message, { idempotencyKey: job.idempotencyKey });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The SDK makes one HTTP attempt. Keep its `operationId`. After a timeout or lost
|
|
45
|
+
connection recover the same key with the same integration and subject:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { createEmailClient } from '@repa/mail';
|
|
49
|
+
|
|
50
|
+
export async function checkSavedMessage(apiKey: string, subject: string, key: string) {
|
|
51
|
+
const mail = createEmailClient({ apiKey, subject });
|
|
52
|
+
const receipt = await mail.findSubmissionByKey(key);
|
|
53
|
+
return mail.getSubmission(receipt.operationId);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
A definitive `NOT_FOUND`, or `preparing`, permits exact replay of the original
|
|
59
|
+
message and key. Changed input is `CONFLICT`. Never generate another UUID to
|
|
60
|
+
recover uncertain work. `queued` proves durable repa acceptance;
|
|
61
|
+
`provider_accepted` proves sending-service acceptance, not delivery;
|
|
62
|
+
`acceptance_unknown` needs reconciliation without resending.
|
|
63
|
+
|
|
64
|
+
The nine submission states are `preparing`, `pending`, `accepted`, `queued`,
|
|
65
|
+
`dispatching`, `acceptance_unknown`, `provider_accepted`, `failed`, `cancelled`.
|
|
66
|
+
`recipients` reports original envelope ordinals and independent feedback facts
|
|
67
|
+
(`Send`, `Delivery`, `Bounce`, `Complaint`, `Reject`, `Rendering Failure`,
|
|
68
|
+
`DeliveryDelay`), without recipient addresses. Delivery proves acceptance by the
|
|
69
|
+
recipient server, never inbox placement or reading. There is no open tracking.
|
|
70
|
+
The mail product's richer delivery display is not a public client method.
|
|
71
|
+
|
|
72
|
+
## Verify and commit webhooks
|
|
73
|
+
|
|
74
|
+
Keep raw bytes. Resolve endpoint ID and versioned secrets from trusted
|
|
75
|
+
configuration. Enforce a 16,384-byte HTTP body limit and a request deadline in
|
|
76
|
+
your host before reading the body. Verify before parsing, and return success
|
|
77
|
+
only after committing:
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { verifyEmailWebhook, type EmailWebhookEvent } from '@repa/mail';
|
|
81
|
+
|
|
82
|
+
export async function receiveMailEvent(request: Request, config: {
|
|
83
|
+
endpointId: string; secrets: Record<number, string>;
|
|
84
|
+
}, commitOnce: (event: EmailWebhookEvent) => Promise<void>) {
|
|
85
|
+
const event = verifyEmailWebhook({
|
|
86
|
+
body: new Uint8Array(await request.arrayBuffer()),
|
|
87
|
+
headers: request.headers, ...config,
|
|
88
|
+
});
|
|
89
|
+
await commitOnce(event);
|
|
90
|
+
return new Response(null, { status: 204 });
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`commitOnce` must save event ID and effect atomically and succeed for duplicates.
|
|
96
|
+
A failed signature/commit must not return success. Default timestamp tolerance is
|
|
97
|
+
300 seconds. Keep old secrets until pinned deliveries drain during rotation;
|
|
98
|
+
remove revoked secrets. Deduplicate stable event IDs across history and webhooks.
|
|
99
|
+
`listEvents({after, limit})` returns at most 100 events and `next`; commit that
|
|
100
|
+
cursor with the page's durable effects. Arrival order is not guaranteed.
|
|
101
|
+
History and webhook payloads last 30 days. Retries: at most 12 over seven days;
|
|
102
|
+
explicit redelivery: at most three per event/endpoint within 30 days.
|
|
103
|
+
|
|
104
|
+
## Headless mailboxes and rules
|
|
105
|
+
|
|
106
|
+
Your host backend authenticates users, derives the subject from its session,
|
|
107
|
+
and checks the mailbox/action on every request and download. Subjects grant no
|
|
108
|
+
additional authority. Keys never enter browser code, URLs, public env variables
|
|
109
|
+
or logs. Users do not need repa accounts.
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
import { createEmailClient, createMailTransport } from '@repa/mail';
|
|
113
|
+
|
|
114
|
+
export async function openAllowedMailbox(apiKey: string, authenticatedSubject: string,
|
|
115
|
+
allowedAccountId: string, signal: AbortSignal) {
|
|
116
|
+
const mail = createEmailClient({ apiKey, subject: authenticatedSubject });
|
|
117
|
+
return createMailTransport(mail).open(allowedAccountId, signal);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Exports include `createEmailClient`, `createMailTransport`, `verifyEmailWebhook`,
|
|
123
|
+
`EmailError`, the client/message/request types and browser-safe `/contracts`.
|
|
124
|
+
Client methods cover mailbox discovery/open, message/conversation list/read,
|
|
125
|
+
downloads, message changes, folder create/rename/delete, storage, raw submission,
|
|
126
|
+
drafts and rules. Sanitize read HTML and display safety warnings before content.
|
|
127
|
+
|
|
128
|
+
Rules require “Read and organize” or higher. `getRules`/`checkRules` are reads;
|
|
129
|
+
`saveRules` takes exactly one of `items` or `script`; `changeRules` performs one
|
|
130
|
+
`put`, `move`, `toggle` or `delete`. Both writes compare `expectedRevision`
|
|
131
|
+
without an operation UUID or Idempotency-Key. After response loss read again;
|
|
132
|
+
a stale revision is `CONFLICT`, while a refused change resolves
|
|
133
|
+
`{status: 'rejected', problems}`. Integrations cannot alter automatic replies,
|
|
134
|
+
forwarding or blocks that send mail. A script is at most 65,536 bytes.
|
|
135
|
+
|
|
136
|
+
The builder condition `{field: "tag", operator: "is", negate: false, value: "shop"}`
|
|
137
|
+
checks the original envelope recipient with Sieve `envelope :detail`. An exact
|
|
138
|
+
receiving address always wins over plus fallback. Tag reception grants no sender
|
|
139
|
+
authority.
|
|
140
|
+
|
|
141
|
+
Draft get/list/save/prepare/discard is private to integration + subject. Prepare
|
|
142
|
+
freezes the message; send reconciles the original draft ID. After a lost reply,
|
|
143
|
+
read the same draft and reuse that identity. Scheduling/unscheduling is refused
|
|
144
|
+
for integration subjects. Rotation preserves ownership, but queued first dispatch
|
|
145
|
+
still checks the original key; keep it valid until its work drains. Revocation
|
|
146
|
+
cannot recall provider-accepted mail.
|
|
147
|
+
|
|
148
|
+
## Limits and errors
|
|
149
|
+
|
|
150
|
+
- 60 requests per minute per integration; workspace sending/storage allowances also apply.
|
|
151
|
+
- 50 recipient entries before deduplication; at most 20 attachments.
|
|
152
|
+
- Encoded outgoing message: 26.2 MB (26,214,400 bytes); sending JSON: 35.0 MB
|
|
153
|
+
(34,968,920 bytes). No separate attachment-byte cap.
|
|
154
|
+
- Text/HTML each: 1.05 MB (1,048,576 bytes).
|
|
155
|
+
- Mailbox discovery: 100 per page; message/conversation lists: 20 per page.
|
|
156
|
+
- Public reads: 10 seconds; uploads: 40 seconds. SDK timeout: 45 seconds by
|
|
157
|
+
default, at most 120 seconds. Options accept `signal`, `timeoutMs`, `subject`.
|
|
158
|
+
- Initial lifetime journal: 10,000 distinct send keys per workspace; full returns
|
|
159
|
+
`LIMIT`, while exact retries keep their slot.
|
|
160
|
+
|
|
161
|
+
`EmailError` has closed `code` and optional `status`, `requestId`,
|
|
162
|
+
`retryAfterSeconds`, `idempotencyKey`, `operationId`. Size errors preserve
|
|
163
|
+
`limitBytes`, `attachmentBytes`, `attachmentCapacityBytes` when supplied.
|
|
164
|
+
`TIMEOUT`, `CONNECTION`, `ABORTED` never prove rollback. Mutations are never
|
|
165
|
+
retried automatically; redirects are refused. Inject `fetch` for your transport.
|
|
166
|
+
|
|
167
|
+
Full guide: [server SDK](../../solutions/email/docs/developer/mail-sdk.md) and
|
|
168
|
+
[mail HTTP API](../../solutions/email/docs/developer/mail-api.md). The source public route
|
|
169
|
+
manifest is `scripts/public-api-contract/mail-contract.mjs`; package exports
|
|
170
|
+
and current declarations define the available client. Historical
|
|
171
|
+
[send/webhook](https://github.com/devcited-labs/repa/blob/main/solutions/email/docs/public-api-acceptance-20261018.md)
|
|
172
|
+
and [own-IAM](https://github.com/devcited-labs/repa/blob/main/solutions/email/docs/headless-acceptance-20261018.md)
|
|
173
|
+
records qualify their dated contracts, not this unreleased source.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { j as EmailAttachment, E as EmailClientOptions, m as EmailDomainSendScope, l as EmailDomainSender, h as EmailError, q as EmailEvent, f as EmailEventPage, p as EmailEventType, k as EmailExactSender, o as EmailFeedbackType, c as EmailMessage, a as EmailRequestOptions, d as EmailSendOptions, b as EmailSender, e as EmailSubmission, n as EmailSubmissionState, g as EmailWebhookEvent } from './errors-B_W1C1Hu.js';
|
|
2
|
+
|
|
3
|
+
declare function createEmailClient(): never;
|
|
4
|
+
declare function createMailTransport(): never;
|
|
5
|
+
declare function verifyEmailWebhook(): never;
|
|
6
|
+
|
|
7
|
+
export { createEmailClient, createMailTransport, verifyEmailWebhook };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { EmailError } from './chunk-XW4CRZRY.js';
|
|
2
|
+
|
|
3
|
+
// src/browser-denied.ts
|
|
4
|
+
function createEmailClient() {
|
|
5
|
+
throw new Error("@repa/mail is server-only. Keep integration keys in your backend.");
|
|
6
|
+
}
|
|
7
|
+
function createMailTransport() {
|
|
8
|
+
throw new Error("@repa/mail is server-only. Keep integration keys in your backend.");
|
|
9
|
+
}
|
|
10
|
+
function verifyEmailWebhook() {
|
|
11
|
+
throw new Error("Webhook verification belongs in your backend.");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { createEmailClient, createMailTransport, verifyEmailWebhook };
|