@schemavaults/send-email 0.3.1 → 0.4.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @schemavaults/send-email
2
2
 
3
- TypeScript client for sending emails via the `@schemavaults/mail-server` API. Provides request body validation (via Zod), environment-aware server URL resolution, and helpers for sending to individual recipients, mailing lists, and listing available email templates.
3
+ TypeScript client for sending emails via the `@schemavaults/mail-server` API. Provides request body validation (via Zod), environment-aware server URL resolution, and helpers for sending to individual recipients, mailing lists, attaching files, and listing available email templates.
4
4
 
5
5
  ## Installation
6
6
 
@@ -81,6 +81,59 @@ bunx schemavaults-send-email --transport smtp-primary send \
81
81
 
82
82
  Transport names are defined by whoever configures the mail-server; this package only validates that the value looks like an identifier. An unknown transport name is rejected by the mail-server, not by the client.
83
83
 
84
+ ### Attach files
85
+
86
+ Request bodies are JSON, so each attachment's bytes travel as a base64 string under `body.attachments`. You rarely need to encode anything yourself: the `attachments` option on `sendEmail()` (and `sendEmailToMailingList()`) accepts raw bytes, plain text, or already-encoded attachments and base64-encodes them for you before appending them to `body.attachments`.
87
+
88
+ ```ts
89
+ import { sendEmail } from "@schemavaults/send-email";
90
+ // Node/Bun only -- reads from disk, so it lives on its own subpath
91
+ import { createEmailAttachmentFromFile } from "@schemavaults/send-email/create-email-attachment-from-file";
92
+
93
+ await sendEmail({
94
+ body: {
95
+ to: "user@example.com",
96
+ subject: "Your invoice",
97
+ message: { text: "Invoice attached.", html: "<p>Invoice attached.</p>" },
98
+ },
99
+ attachments: [
100
+ // Binary: any Uint8Array / Buffer / ArrayBuffer
101
+ { filename: "invoice.pdf", content: pdfBytes, contentType: "application/pdf" },
102
+ // Plain text: say so, otherwise a string is assumed to be base64 already
103
+ { filename: "summary.txt", content: "Thanks for your order!", encoding: "utf8" },
104
+ // A file on disk; the basename becomes the attachment filename
105
+ await createEmailAttachmentFromFile("./reports/q3.csv"),
106
+ ],
107
+ });
108
+ ```
109
+
110
+ To build the wire shape yourself -- for example to validate it up front or to put it in `body.attachments` directly -- use `createEmailAttachment()`, which takes the same input and returns a validated `EmailAttachment`:
111
+
112
+ ```ts
113
+ import { createEmailAttachment } from "@schemavaults/send-email";
114
+
115
+ const attachment = createEmailAttachment({
116
+ filename: "logo.png",
117
+ content: logoBytes,
118
+ contentType: "image/png",
119
+ contentId: "logo", // inline image: reference it as <img src="cid:logo"> in the HTML body
120
+ });
121
+ // => { filename: "logo.png", content: "iVBORw0KGgo...", contentType: "image/png", contentId: "logo" }
122
+ ```
123
+
124
+ Setting `contentId` marks the attachment as inline so the HTML body can embed it via a `cid:` URL; pass the bare identifier without angle brackets. `contentType` is optional -- when omitted, the mail-server's transport derives it from the filename's extension.
125
+
126
+ Limits enforced client-side (and exported as `MAX_ATTACHMENTS_PER_EMAIL` / `MAX_TOTAL_ATTACHMENT_BYTES`): at most 20 attachments per email, totalling at most 25 MiB once decoded. Filenames may not contain path separators or control characters. The mail-server, its hosting platform, and the receiving mail systems may enforce lower limits of their own.
127
+
128
+ From the CLI, `--attach <path>` is repeatable on both `send` and `send-to-mailing-list`, and may be combined with `--body-file` (the files are appended to any `attachments` already in the JSON):
129
+
130
+ ```bash
131
+ bunx schemavaults-send-email send \
132
+ --to user@example.com --subject "Your invoice" \
133
+ --text "Invoice attached." --html "<p>Invoice attached.</p>" \
134
+ --attach ./invoice.pdf --attach ./reports/q3.csv
135
+ ```
136
+
84
137
  ### Send to a mailing list
85
138
 
86
139
  ```ts
@@ -141,6 +194,7 @@ interface ISendEmailOpts {
141
194
  environment?: "production" | "development" | "staging";
142
195
  dryRun?: boolean; // convenience; sets body.dryRun
143
196
  transport?: string; // convenience; sets body.transport
197
+ attachments?: EmailAttachmentInput[]; // convenience; encoded + appended to body.attachments
144
198
  }
145
199
  ```
146
200
 
@@ -157,9 +211,30 @@ interface ISendEmailToMailingListOpts {
157
211
  environment?: "production" | "development" | "staging";
158
212
  dryRun?: boolean; // convenience; sets body.dryRun
159
213
  transport?: string; // convenience; sets body.transport
214
+ attachments?: EmailAttachmentInput[]; // convenience; encoded + appended to body.attachments
215
+ }
216
+ ```
217
+
218
+ ### `createEmailAttachment(input)`
219
+
220
+ Builds a validated `EmailAttachment` (the wire shape used in `body.attachments`), base64-encoding the content for you. Throws a `TypeError` describing the problem when the result is invalid.
221
+
222
+ ```ts
223
+ interface EmailAttachmentInput {
224
+ filename: string; // shown to the recipient; no path separators
225
+ content: string | Uint8Array | ArrayBuffer; // bytes, or a string (see `encoding`)
226
+ encoding?: "base64" | "utf8"; // how to read a string `content`; default "base64"
227
+ contentType?: string; // MIME type; derived from the filename when omitted
228
+ contentId?: string; // set to embed inline via cid: in the HTML body
160
229
  }
161
230
  ```
162
231
 
232
+ An `EmailAttachment` is itself valid `EmailAttachmentInput` (its `content` is base64), so pre-built attachments and raw inputs can be mixed freely.
233
+
234
+ ### `createEmailAttachmentFromFile(path, opts?)`
235
+
236
+ Node/Bun only. Reads a file from disk and returns a validated `EmailAttachment`; the file's basename is the attachment filename unless `opts.filename` overrides it. `opts` may also set `contentType` and `contentId`. Imported from the `@schemavaults/send-email/create-email-attachment-from-file` subpath so the package's main entry stays free of filesystem imports.
237
+
163
238
  ### `listEmailTemplates(opts?)`
164
239
 
165
240
  Returns the list of registered email templates from the mail-server catalog.
@@ -197,6 +272,10 @@ Zod schema for validating template IDs: lowercase alphanumeric with hyphens/unde
197
272
 
198
273
  Zod schema for validating transport names: lowercase alphanumeric with hyphens/underscores, 1-64 characters, must start with a lowercase letter and end with a lowercase alphanumeric character. Whether a well-formed name corresponds to a transport the mail-server actually has configured is decided server-side.
199
274
 
275
+ ### `emailAttachmentSchema` / `emailAttachmentsSchema`
276
+
277
+ Zod schemas for a single attachment and for the `attachments` array respectively. The array schema enforces the count (`MAX_ATTACHMENTS_PER_EMAIL`, 20) and total decoded size (`MAX_TOTAL_ATTACHMENT_BYTES`, 25 MiB) limits; both constants are exported.
278
+
200
279
  ## Request body shape
201
280
 
202
281
  The `message` field accepts either a template reference or raw content:
@@ -206,6 +285,13 @@ type Message =
206
285
  | { template_id: string; template_props?: unknown }
207
286
  | { text: string; html: string }; // both required
208
287
 
288
+ type EmailAttachment = {
289
+ filename: string; // 1-255 chars; no path separators or control characters
290
+ content: string; // base64-encoded bytes (standard alphabet, padded)
291
+ contentType?: string; // MIME type; derived from the filename when omitted
292
+ contentId?: string; // marks the attachment inline; reference as cid:<contentId>
293
+ };
294
+
209
295
  type SendEmailRequestBody = {
210
296
  to: string | string[]; // email address(es) or mailing list UUID
211
297
  subject: string;
@@ -216,6 +302,7 @@ type SendEmailRequestBody = {
216
302
  bcc?: string | string[];
217
303
  dryRun?: boolean; // server validates without dispatching
218
304
  transport?: string; // which mail-server transport delivers this email
305
+ attachments?: EmailAttachment[]; // 1-20 files, at most 25 MiB in total once decoded
219
306
  };
220
307
  ```
221
308
 
@@ -228,3 +315,9 @@ bun test
228
315
  bun run typecheck
229
316
  bun run lint
230
317
  ```
318
+
319
+ ### Keeping the package root browser-safe
320
+
321
+ Consumers bundle the package root for the browser (the mail-server's admin UI imports `sendEmail` from a client component), so nothing reachable from `src/index.ts` may need a Node/Bun runtime. `src/browser-compatibility.test.ts` enforces this on every `bun test`: it bundles the root with esbuild for the browser platform, asserts no Node built-in is imported anywhere in the graph, and evaluates the bundle in a `node:vm` context with no `process` / `Buffer` / `require` before exercising the public API.
322
+
323
+ Anything that does need Node or Bun -- filesystem access, for example -- goes in its own module exposed through a package subpath (as `create-email-attachment-from-file` is) and is added to that test's `NODE_ONLY_MODULES` list, which both checks the root never imports it and confirms it really is not browser-safe.
package/dist/cli.js CHANGED
@@ -18008,6 +18008,67 @@ var transportIdSchema = external_exports.string().min(1, "Transport ID must be n
18008
18008
  "Transport ID must start with a lowercase letter and end with a lowercase alphanumeric character, and may only contain lowercase alphanumeric characters, hyphens and underscores."
18009
18009
  );
18010
18010
 
18011
+ // src/validators/email-attachment-schema.ts
18012
+ var MAX_ATTACHMENTS_PER_EMAIL = 20;
18013
+ var MAX_TOTAL_ATTACHMENT_BYTES = 25 * 1024 * 1024;
18014
+ function base64DecodedByteLength(base643) {
18015
+ if (base643.length === 0) return 0;
18016
+ let padding = 0;
18017
+ if (base643.endsWith("==")) padding = 2;
18018
+ else if (base643.endsWith("=")) padding = 1;
18019
+ return Math.floor(base643.length * 3 / 4) - padding;
18020
+ }
18021
+ function hasControlCharacters(value) {
18022
+ for (let i = 0; i < value.length; i++) {
18023
+ const code = value.charCodeAt(i);
18024
+ if (code < 32 || code === 127) return true;
18025
+ }
18026
+ return false;
18027
+ }
18028
+ var attachmentFilenameSchema = external_exports.string().min(1, "Attachment filename must be non-empty!").max(255, "Attachment filename must be at most 255 characters!").refine((name) => name !== "." && name !== "..", {
18029
+ message: "Attachment filename must not be '.' or '..'!"
18030
+ }).refine((name) => !name.includes("/") && !name.includes("\\"), {
18031
+ message: "Attachment filename must not contain path separators!"
18032
+ }).refine((name) => !hasControlCharacters(name), {
18033
+ message: "Attachment filename must not contain control characters!"
18034
+ });
18035
+ var attachmentContentSchema = external_exports.base64("Attachment content must be base64-encoded!").min(1, "Attachment content must not be empty!");
18036
+ var MIME_TOKEN = "[A-Za-z0-9!#$&^_.+-]+";
18037
+ var attachmentContentTypeSchema = external_exports.string().min(1, "Attachment content type must be non-empty!").max(255, "Attachment content type must be at most 255 characters!").regex(
18038
+ new RegExp(
18039
+ `^${MIME_TOKEN}\\/${MIME_TOKEN}(?:\\s*;\\s*${MIME_TOKEN}=(?:"[^"]*"|[^\\s;"]+))*$`
18040
+ ),
18041
+ "Attachment content type must be a MIME type such as 'application/pdf'!"
18042
+ );
18043
+ var attachmentContentIdSchema = external_exports.string().min(1, "Attachment content ID must be non-empty!").max(255, "Attachment content ID must be at most 255 characters!").regex(
18044
+ /^[^\s<>]+$/,
18045
+ "Attachment content ID must not contain whitespace or angle brackets!"
18046
+ );
18047
+ var emailAttachmentSchema = external_exports.object({
18048
+ filename: attachmentFilenameSchema,
18049
+ content: attachmentContentSchema,
18050
+ contentType: attachmentContentTypeSchema.optional(),
18051
+ contentId: attachmentContentIdSchema.optional()
18052
+ }).required({
18053
+ filename: true,
18054
+ content: true
18055
+ }).strict();
18056
+ var emailAttachmentsSchema = external_exports.array(emailAttachmentSchema).min(1, "Provide at least one attachment, or omit 'attachments' entirely!").max(
18057
+ MAX_ATTACHMENTS_PER_EMAIL,
18058
+ `An email may have at most ${MAX_ATTACHMENTS_PER_EMAIL} attachments!`
18059
+ ).superRefine((attachments, ctx) => {
18060
+ let totalBytes = 0;
18061
+ for (const attachment of attachments) {
18062
+ totalBytes += base64DecodedByteLength(attachment.content);
18063
+ }
18064
+ if (totalBytes > MAX_TOTAL_ATTACHMENT_BYTES) {
18065
+ ctx.addIssue({
18066
+ code: "custom",
18067
+ message: `Attachments must total at most ${MAX_TOTAL_ATTACHMENT_BYTES} bytes (${MAX_TOTAL_ATTACHMENT_BYTES / (1024 * 1024)} MiB) once decoded; received ${totalBytes} bytes.`
18068
+ });
18069
+ }
18070
+ });
18071
+
18011
18072
  // src/send-email-request-body-schema.ts
18012
18073
  var sendEmailTemplateOptions = external_exports.object({
18013
18074
  template_id: emailTemplateIdSchema,
@@ -18064,7 +18125,15 @@ function createSendEmailRequestBodySchema(allow_mailing_list_ids_as_recipients =
18064
18125
  * instance has more than one transport configured; when omitted, the
18065
18126
  * mail-server picks its own default transport.
18066
18127
  */
18067
- transport: transportIdSchema.optional()
18128
+ transport: transportIdSchema.optional(),
18129
+ /**
18130
+ * Files to attach to the email. Each attachment carries its bytes as a
18131
+ * base64 string (request bodies are JSON); see `createEmailAttachment`
18132
+ * for encoding binary or plain-text content. Between 1 and
18133
+ * `MAX_ATTACHMENTS_PER_EMAIL` files, totalling at most
18134
+ * `MAX_TOTAL_ATTACHMENT_BYTES` once decoded. Omit when there are none.
18135
+ */
18136
+ attachments: emailAttachmentsSchema.optional()
18068
18137
  }).required({
18069
18138
  to: true,
18070
18139
  message: true,
@@ -18073,6 +18142,48 @@ function createSendEmailRequestBodySchema(allow_mailing_list_ids_as_recipients =
18073
18142
  }
18074
18143
  var sendEmailRequestBodySchema = createSendEmailRequestBodySchema();
18075
18144
 
18145
+ // src/create-email-attachment.ts
18146
+ function encodeBytesAsBase64(bytes) {
18147
+ if (typeof Buffer !== "undefined" && typeof Buffer.from === "function") {
18148
+ return Buffer.from(bytes).toString("base64");
18149
+ }
18150
+ let binary = "";
18151
+ const CHUNK_SIZE = 32768;
18152
+ for (let i = 0; i < bytes.length; i += CHUNK_SIZE) {
18153
+ binary += String.fromCharCode(...bytes.subarray(i, i + CHUNK_SIZE));
18154
+ }
18155
+ return btoa(binary);
18156
+ }
18157
+ function createEmailAttachment(input) {
18158
+ let content;
18159
+ if (typeof input.content === "string") {
18160
+ content = input.encoding === "utf8" ? encodeBytesAsBase64(new TextEncoder().encode(input.content)) : input.content;
18161
+ } else if (input.content instanceof Uint8Array) {
18162
+ content = encodeBytesAsBase64(input.content);
18163
+ } else if (input.content instanceof ArrayBuffer) {
18164
+ content = encodeBytesAsBase64(new Uint8Array(input.content));
18165
+ } else {
18166
+ throw new TypeError(
18167
+ "Expected attachment 'content' to be a string, Uint8Array or ArrayBuffer!",
18168
+ { cause: `Received type '${typeof input.content}'` }
18169
+ );
18170
+ }
18171
+ const candidate = {
18172
+ filename: input.filename,
18173
+ content,
18174
+ ...input.contentType !== void 0 ? { contentType: input.contentType } : {},
18175
+ ...input.contentId !== void 0 ? { contentId: input.contentId } : {}
18176
+ };
18177
+ const parsed = emailAttachmentSchema.safeParse(candidate);
18178
+ if (!parsed.success) {
18179
+ const reasons = parsed.error.issues.map((issue2) => issue2.message);
18180
+ throw new TypeError(
18181
+ `Invalid email attachment '${String(input.filename)}': ${reasons.join(" ")}`
18182
+ );
18183
+ }
18184
+ return parsed.data;
18185
+ }
18186
+
18076
18187
  // src/env/get-api-key.ts
18077
18188
  function getSchemaVaultsMailApiKey() {
18078
18189
  if (!process.env.SCHEMAVAULTS_MAIL_API_KEY || typeof process.env.SCHEMAVAULTS_MAIL_API_KEY !== "string") {
@@ -18134,10 +18245,16 @@ async function sendEmail({
18134
18245
  body,
18135
18246
  ...opts
18136
18247
  }) {
18248
+ const { attachments: bodyAttachments, ...bodyWithoutAttachments } = body;
18249
+ const attachments = [
18250
+ ...bodyAttachments ?? [],
18251
+ ...(opts.attachments ?? []).map(createEmailAttachment)
18252
+ ];
18137
18253
  const effectiveBody = {
18138
- ...body,
18254
+ ...bodyWithoutAttachments,
18139
18255
  ...typeof opts.dryRun === "boolean" ? { dryRun: opts.dryRun } : {},
18140
- ...typeof opts.transport === "string" ? { transport: opts.transport } : {}
18256
+ ...typeof opts.transport === "string" ? { transport: opts.transport } : {},
18257
+ ...attachments.length > 0 ? { attachments } : {}
18141
18258
  };
18142
18259
  const parsed = await body_schema.safeParseAsync(effectiveBody);
18143
18260
  if (!parsed.success) {
@@ -18265,6 +18382,20 @@ async function listEmailTemplates(opts = {}) {
18265
18382
  }
18266
18383
  var list_email_templates_default = listEmailTemplates;
18267
18384
 
18385
+ // src/create-email-attachment-from-file.ts
18386
+ import { readFile } from "node:fs/promises";
18387
+ import { basename } from "node:path";
18388
+ async function createEmailAttachmentFromFile(path, opts = {}) {
18389
+ const bytes = await readFile(path);
18390
+ return createEmailAttachment({
18391
+ filename: opts.filename ?? basename(path),
18392
+ content: bytes,
18393
+ ...opts.contentType !== void 0 ? { contentType: opts.contentType } : {},
18394
+ ...opts.contentId !== void 0 ? { contentId: opts.contentId } : {}
18395
+ });
18396
+ }
18397
+ var create_email_attachment_from_file_default = createEmailAttachmentFromFile;
18398
+
18268
18399
  // src/cli.ts
18269
18400
  function readTextFile(path) {
18270
18401
  return readFileSync(path, "utf8");
@@ -18301,6 +18432,12 @@ function loadBodyFile(path) {
18301
18432
  throw new Error(`Failed to parse ${path} as JSON: ${msg}`);
18302
18433
  }
18303
18434
  }
18435
+ async function loadAttachments(paths) {
18436
+ if (!paths || paths.length === 0) return [];
18437
+ return await Promise.all(
18438
+ paths.map((path) => create_email_attachment_from_file_default(path))
18439
+ );
18440
+ }
18304
18441
  async function withErrorHandling(fn) {
18305
18442
  try {
18306
18443
  await fn();
@@ -18320,8 +18457,11 @@ function attachBodyOptions(cmd) {
18320
18457
  "--text-file <path>",
18321
18458
  "Path to a file containing the plain-text body"
18322
18459
  ).option("--html-file <path>", "Path to a file containing the HTML body").option(
18460
+ "--attach <path...>",
18461
+ "Path to a file to attach (repeatable); its basename becomes the attachment filename"
18462
+ ).option(
18323
18463
  "--body-file <path>",
18324
- "Path to a JSON file containing the full request body (overrides other body flags)"
18464
+ "Path to a JSON file containing the full request body (overrides other body flags, except --attach which is appended)"
18325
18465
  );
18326
18466
  }
18327
18467
  var program2 = new Command();
@@ -18365,8 +18505,10 @@ attachBodyOptions(
18365
18505
  ...opts.bcc && opts.bcc.length > 0 ? { bcc: opts.bcc.length === 1 ? opts.bcc[0] : opts.bcc } : {}
18366
18506
  };
18367
18507
  }
18508
+ const attachments = await loadAttachments(opts.attach);
18368
18509
  await send_email_default({
18369
18510
  body,
18511
+ ...attachments.length > 0 ? { attachments } : {},
18370
18512
  ...global.apiKey ? { bearerToken: global.apiKey } : {},
18371
18513
  ...global.dryRun ? { dryRun: true } : {},
18372
18514
  ...global.transport ? { transport: global.transport } : {}
@@ -18392,7 +18534,8 @@ attachBodyOptions(
18392
18534
  message: fullBody.message,
18393
18535
  ...fullBody.from ? { from: fullBody.from } : {},
18394
18536
  ...fullBody.replyTo ? { replyTo: fullBody.replyTo } : {},
18395
- ...fullBody.transport ? { transport: fullBody.transport } : {}
18537
+ ...fullBody.transport ? { transport: fullBody.transport } : {},
18538
+ ...fullBody.attachments ? { attachments: fullBody.attachments } : {}
18396
18539
  };
18397
18540
  } else {
18398
18541
  if (!opts.subject) {
@@ -18405,8 +18548,10 @@ attachBodyOptions(
18405
18548
  ...opts.replyTo ? { replyTo: opts.replyTo } : {}
18406
18549
  };
18407
18550
  }
18551
+ const attachments = await loadAttachments(opts.attach);
18408
18552
  await send_email_to_mailing_list_default({
18409
18553
  body,
18554
+ ...attachments.length > 0 ? { attachments } : {},
18410
18555
  ...opts.mailingListId ? { mailingListId: opts.mailingListId } : {},
18411
18556
  ...global.apiKey ? { bearerToken: global.apiKey } : {},
18412
18557
  ...global.dryRun ? { dryRun: true } : {},
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,SAAS;AAET,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,sBAAsB,MAAM,8BAA8B,CAAC;AAClE,OAAO,kBAAkB,MAAM,wBAAwB,CAAC;AAwCxD,SAAS,YAAY,CAAC,IAAY;IAChC,OAAO,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACpC,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAuB;IACjD,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACxC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7D,MAAM,IAAI,KAAK,CAAC,6CAA6C,GAAG,EAAE,CAAC,CAAC;IACtE,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,IAAiB;IACrC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QACpB,MAAM,KAAK,GAAG,kBAAkB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACrD,OAAO,KAAK,KAAK,SAAS;YACxB,CAAC,CAAC,EAAE,WA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}
@@ -0,0 +1,9 @@
1
+ import { type EmailAttachmentInput } from "./create-email-attachment.js";
2
+ import type { EmailAttachment } from "./validators/email-attachment-schema.js";
3
+ export type ICreateEmailAttachmentFromFileOpts = Partial<Pick<EmailAttachmentInput, "filename" | "contentType" | "contentId">>;
4
+ /**
5
+ * Read a file from disk and turn it into a validated {@link EmailAttachment}.
6
+ * The file's basename is used as the attachment filename unless overridden.
7
+ */
8
+ export declare function createEmailAttachmentFromFile(path: string, opts?: ICreateEmailAttachmentFromFileOpts): Promise<EmailAttachment>;
9
+ export default createEmailAttachmentFromFile;
@@ -0,0 +1,27 @@
1
+ // create-email-attachment-from-file.ts
2
+ //
3
+ // Node/Bun only: reads from the filesystem. Deliberately NOT re-exported from
4
+ // the package's main entry point, which must stay free of `node:` imports so
5
+ // it can be bundled for environments without a filesystem. Import it via the
6
+ // "@schemavaults/send-email/create-email-attachment-from-file" subpath.
7
+ // `src/browser-compatibility.test.ts` enforces this separation.
8
+ import { readFile } from "node:fs/promises";
9
+ import { basename } from "node:path";
10
+ import { createEmailAttachment, } from "./create-email-attachment.js";
11
+ /**
12
+ * Read a file from disk and turn it into a validated {@link EmailAttachment}.
13
+ * The file's basename is used as the attachment filename unless overridden.
14
+ */
15
+ export async function createEmailAttachmentFromFile(path, opts = {}) {
16
+ const bytes = await readFile(path);
17
+ return createEmailAttachment({
18
+ filename: opts.filename ?? basename(path),
19
+ content: bytes,
20
+ ...(opts.contentType !== undefined
21
+ ? { contentType: opts.contentType }
22
+ : {}),
23
+ ...(opts.contentId !== undefined ? { contentId: opts.contentId } : {}),
24
+ });
25
+ }
26
+ export default createEmailAttachmentFromFile;
27
+ //# sourceMappingURL=create-email-attachment-from-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-email-attachment-from-file.js","sourceRoot":"","sources":["../src/create-email-attachment-from-file.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,EAAE;AACF,8EAA8E;AAC9E,6EAA6E;AAC7E,6EAA6E;AAC7E,wEAAwE;AACxE,gEAAgE;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EACL,qBAAqB,GAEtB,MAAM,2BAA2B,CAAC;AAOnC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,IAAY,EACZ,OAA2C,EAAE;IAE7C,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;IACnC,OAAO,qBAAqB,CAAC;QAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,CAAC;QACzC,OAAO,EAAE,KAAK;QACd,GAAG,CAAC,IAAI,CAAC,WAAW,KAAK,SAAS;YAChC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;YACnC,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACvE,CAAC,CAAC;AACL,CAAC;AAED,eAAe,6BAA6B,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { type EmailAttachment } from "./validators/email-attachment-schema.js";
2
+ /**
3
+ * Input accepted by {@link createEmailAttachment}. A ready-made
4
+ * {@link EmailAttachment} is also valid input (its `content` is base64,
5
+ * which is the default string interpretation), so the two can be mixed
6
+ * freely in `ISendEmailOpts.attachments`.
7
+ */
8
+ export interface EmailAttachmentInput {
9
+ /** Name the recipient's mail client shows for the file. */
10
+ filename: string;
11
+ /**
12
+ * The file's bytes. Binary data may be passed as a `Uint8Array` (Node's
13
+ * `Buffer` included) or an `ArrayBuffer`. A string is treated as
14
+ * base64-encoded bytes -- the request body's wire format -- unless
15
+ * `encoding` is set to "utf8", in which case the string itself is the
16
+ * file's (plain-text) content.
17
+ */
18
+ content: string | Uint8Array | ArrayBuffer;
19
+ /**
20
+ * How to interpret a string `content`. Ignored for binary content.
21
+ * - "base64" (default): `content` is already base64-encoded.
22
+ * - "utf8": `content` is the file's text and will be encoded here.
23
+ */
24
+ encoding?: "base64" | "utf8";
25
+ /** MIME type; derived from the filename's extension when omitted. */
26
+ contentType?: string;
27
+ /** Content-ID for inline use via `cid:` references in the HTML body. */
28
+ contentId?: string;
29
+ }
30
+ /**
31
+ * Base64-encode raw bytes, with the standard alphabet and padding. Uses
32
+ * `Buffer` where available (Node, Bun) and falls back to `btoa` elsewhere.
33
+ */
34
+ export declare function encodeBytesAsBase64(bytes: Uint8Array): string;
35
+ /**
36
+ * Build a validated {@link EmailAttachment} for `body.attachments`, taking
37
+ * care of base64-encoding binary or plain-text content.
38
+ *
39
+ * @throws TypeError when the resulting attachment fails validation (bad
40
+ * filename, malformed base64, unsupported content type, ...).
41
+ */
42
+ export declare function createEmailAttachment(input: EmailAttachmentInput): EmailAttachment;
43
+ export default createEmailAttachment;
@@ -0,0 +1,58 @@
1
+ // create-email-attachment.ts
2
+ import { emailAttachmentSchema, } from "./validators/email-attachment-schema.js";
3
+ /**
4
+ * Base64-encode raw bytes, with the standard alphabet and padding. Uses
5
+ * `Buffer` where available (Node, Bun) and falls back to `btoa` elsewhere.
6
+ */
7
+ export function encodeBytesAsBase64(bytes) {
8
+ if (typeof Buffer !== "undefined" && typeof Buffer.from === "function") {
9
+ return Buffer.from(bytes).toString("base64");
10
+ }
11
+ let binary = "";
12
+ const CHUNK_SIZE = 0x8000;
13
+ for (let i = 0; i < bytes.length; i += CHUNK_SIZE) {
14
+ binary += String.fromCharCode(...bytes.subarray(i, i + CHUNK_SIZE));
15
+ }
16
+ return btoa(binary);
17
+ }
18
+ /**
19
+ * Build a validated {@link EmailAttachment} for `body.attachments`, taking
20
+ * care of base64-encoding binary or plain-text content.
21
+ *
22
+ * @throws TypeError when the resulting attachment fails validation (bad
23
+ * filename, malformed base64, unsupported content type, ...).
24
+ */
25
+ export function createEmailAttachment(input) {
26
+ let content;
27
+ if (typeof input.content === "string") {
28
+ content =
29
+ input.encoding === "utf8"
30
+ ? encodeBytesAsBase64(new TextEncoder().encode(input.content))
31
+ : input.content;
32
+ }
33
+ else if (input.content instanceof Uint8Array) {
34
+ content = encodeBytesAsBase64(input.content);
35
+ }
36
+ else if (input.content instanceof ArrayBuffer) {
37
+ content = encodeBytesAsBase64(new Uint8Array(input.content));
38
+ }
39
+ else {
40
+ throw new TypeError("Expected attachment 'content' to be a string, Uint8Array or ArrayBuffer!", { cause: `Received type '${typeof input.content}'` });
41
+ }
42
+ const candidate = {
43
+ filename: input.filename,
44
+ content,
45
+ ...(input.contentType !== undefined
46
+ ? { contentType: input.contentType }
47
+ : {}),
48
+ ...(input.contentId !== undefined ? { contentId: input.contentId } : {}),
49
+ };
50
+ const parsed = emailAttachmentSchema.safeParse(candidate);
51
+ if (!parsed.success) {
52
+ const reasons = parsed.error.issues.map((issue) => issue.message);
53
+ throw new TypeError(`Invalid email attachment '${String(input.filename)}': ${reasons.join(" ")}`);
54
+ }
55
+ return parsed.data;
56
+ }
57
+ export default createEmailAttachment;
58
+ //# sourceMappingURL=create-email-attachment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-email-attachment.js","sourceRoot":"","sources":["../src/create-email-attachment.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAE7B,OAAO,EAEL,qBAAqB,GACtB,MAAM,sCAAsC,CAAC;AA+B9C;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAiB;IACnD,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACvE,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;IACD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,MAAM,UAAU,GAAG,MAAM,C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,KAAK,CAAC,WAAW,EAAE;YACpC,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACzE,CAAC;IAEF,MAAM,MAAM,GAAG,qBAAqB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAC1D,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAClE,MAAM,IAAI,SAAS,CACjB,6BAA6B,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAC7E,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAED,eAAe,qBAAqB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -2,6 +2,10 @@ export { sendEmailRequestBodySchema, createSendEmailRequestBodySchema, } from ".
2
2
  export type { SendEmailRequestBody } from "./send-email-request-body-schema.js";
3
3
  export { emailTemplateIdSchema } from "./validators/email-template-id-schema.js";
4
4
  export { transportIdSchema } from "./validators/transport-id-schema.js";
5
+ export { emailAttachmentSchema, emailAttachmentsSchema, MAX_ATTACHMENTS_PER_EMAIL, MAX_TOTAL_ATTACHMENT_BYTES, } from "./validators/email-attachment-schema.js";
6
+ export type { EmailAttachment } from "./validators/email-attachment-schema.js";
7
+ export { createEmailAttachment } from "./create-email-attachment.js";
8
+ export type { EmailAttachmentInput } from "./create-email-attachment.js";
5
9
  export { sendEmail, sendEmail as default, } from "./send-email.js";
6
10
  export type { ISendEmailOpts } from './send-email.js';
7
11
  export { getSchemaVaultsMailApiKey, } from "./env/get-api-key.js";
package/dist/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  export { sendEmailRequestBodySchema, createSendEmailRequestBodySchema, } from "./send-email-request-body-schema.js";
2
2
  export { emailTemplateIdSchema } from "./validators/email-template-id-schema.js";
3
3
  export { transportIdSchema } from "./validators/transport-id-schema.js";
4
+ export { emailAttachmentSchema, emailAttachmentsSchema, MAX_ATTACHMENTS_PER_EMAIL, MAX_TOTAL_ATTACHMENT_BYTES, } from "./validators/email-attachment-schema.js";
5
+ export { createEmailAttachment } from "./create-email-attachment.js";
4
6
  export { sendEmail, sendEmail as default, } from "./send-email.js";
5
7
  export { getSchemaVaultsMailApiKey, } from "./env/get-api-key.js";
6
8
  export { getSchemaVaultsMailingListId, } from "./env/get-mailing-list-id.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,GACjC,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAE9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,EACL,SAAS,EACT,SAAS,IAAI,OAAO,GACrB,MAAM,cAAc,CAAC;AAKtB,OAAO,EACL,yBAAyB,GAC1B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,4BAA4B,GAC7B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,gBAAgB,EACjB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EACL,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,GACjC,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAE9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EACL,SAAS,EACT,SAAS,IAAI,OAAO,GACrB,MAAM,cAAc,CAAC;AAKtB,OAAO,EACL,yBAAyB,GAC1B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,4BAA4B,GAC7B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,gBAAgB,EACjB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EACL,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -21,6 +21,12 @@ export declare function createSendEmailRequestBodySchema(allow_mailing_list_ids_
21
21
  bcc: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
22
22
  dryRun: z.ZodOptional<z.ZodBoolean>;
23
23
  transport: z.ZodOptional<z.ZodString>;
24
+ attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
25
+ filename: z.ZodNonOptional<z.ZodString>;
26
+ content: z.ZodNonOptional<z.ZodBase64>;
27
+ contentType: z.ZodOptional<z.ZodString>;
28
+ contentId: z.ZodOptional<z.ZodString>;
29
+ }, z.core.$strict>>>;
24
30
  }, z.core.$strict>;
25
31
  /**
26
32
  * Default send email request body schema
@@ -45,6 +51,13 @@ export declare const sendEmailRequestBodySchema: z.ZodObject<{
45
51
  bcc: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
46
52
  dryRun: z.ZodOptional<z.ZodBoolean>;
47
53
  transport: z.ZodOptional<z.ZodString>;
54
+ attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
55
+ filename: z.ZodNonOptional<z.ZodString>;
56
+ content: z.ZodNonOptional<z.ZodBase64>;
57
+ contentType: z.ZodOptional<z.ZodString>;
58
+ contentId: z.ZodOptional<z.ZodString>;
59
+ }, z.core.$strict>>>;
48
60
  }, z.core.$strict>;
49
61
  export type SendEmailRequestBody = z.infer<typeof sendEmailRequestBodySchema>;
62
+ export type { EmailAttachment } from "./validators/email-attachment-schema.js";
50
63
  export default createSendEmailRequestBodySchema;
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { emailTemplateIdSchema } from "./validators/email-template-id-schema.js";
3
3
  import { transportIdSchema } from "./validators/transport-id-schema.js";
4
+ import { emailAttachmentsSchema } from "./validators/email-attachment-schema.js";
4
5
  const sendEmailTemplateOptions = z
5
6
  .object({
6
7
  template_id: emailTemplateIdSchema,
@@ -69,6 +70,14 @@ export function createSendEmailRequestBodySchema(allow_mailing_list_ids_as_recip
69
70
  * mail-server picks its own default transport.
70
71
  */
71
72
  transport: transportIdSchema.optional(),
73
+ /**
74
+ * Files to attach to the email. Each attachment carries its bytes as a
75
+ * base64 string (request bodies are JSON); see `createEmailAttachment`
76
+ * for encoding binary or plain-text content. Between 1 and
77
+ * `MAX_ATTACHMENTS_PER_EMAIL` files, totalling at most
78
+ * `MAX_TOTAL_ATTACHMENT_BYTES` once decoded. Omit when there are none.
79
+ */
80
+ attachments: emailAttachmentsSchema.optional(),
72
81
  })
73
82
  .required({
74
83
  to: true,
@@ -1 +1 @@
1
- {"version":3,"file":"send-email-request-body-schema.js","sourceRoot":"","sources":["../src/send-email-request-body-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,MAAM,wBAAwB,GAAG,CAAC;KAC/B,MAAM,CAAC;IACN,WAAW,E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E;QACb,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;QAC9B;;;;;WAKG;QACH,SAAS,EAAE,iBAAiB,CAAC,QAAQ,EAAE;QACvC;;;;;;WAMG;QACH,WAAW,EAAE,sBAAsB,CAAC,QAAQ,EAAE;KAC/C,CAAC;SACD,QAAQ,CAAC;QACR,EAAE,EAAE,IAAI;QACR,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,IAAI;KACd,CAAC;SACD,MAAM,EAAE,CAAC;AACd,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,gCAAgC,EAAE,CAAC;AAM7E,eAAe,gCAAgC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { type SendEmailRequestBody } from "./send-email-request-body-schema.js";
2
+ import { type EmailAttachmentInput } from "./create-email-attachment.js";
2
3
  import getSchemaVaultsMailApiKey from "./env/get-api-key.js";
3
4
  export interface ISendEmailOpts {
4
5
  body: SendEmailRequestBody;
@@ -10,6 +11,14 @@ export interface ISendEmailOpts {
10
11
  * mail-server's configured transports should deliver this email.
11
12
  */
12
13
  transport?: string;
14
+ /**
15
+ * Convenience for `body.attachments` -- files to attach to the email.
16
+ * Unlike `body.attachments`, binary content (`Uint8Array`, `Buffer`,
17
+ * `ArrayBuffer`) and plain text (`encoding: "utf8"`) are accepted here
18
+ * and base64-encoded for you; see `createEmailAttachment`. Appended after
19
+ * any attachments already present on `body`.
20
+ */
21
+ attachments?: EmailAttachmentInput[];
13
22
  }
14
23
  export { getSchemaVaultsMailApiKey };
15
24
  export declare function sendEmail({ body, ...opts }: ISendEmailOpts): Promise<void>;
@@ -1,14 +1,21 @@
1
1
  // send-email.ts
2
2
  import { createSendEmailRequestBodySchema, } from "./send-email-request-body-schema.js";
3
+ import { createEmailAttachment, } from "./create-email-attachment.js";
3
4
  import getSchemaVaultsMailApiKey from "./env/get-api-key.js";
4
5
  import parseMailServerUrlWithEnvFallback from "./parse-mail-server-url-with-env-fallback.js";
5
6
  const body_schema = createSendEmailRequestBodySchema(true);
6
7
  export { getSchemaVaultsMailApiKey };
7
8
  export async function sendEmail({ body, ...opts }) {
9
+ const { attachments: bodyAttachments, ...bodyWithoutAttachments } = body;
10
+ const attachments = [
11
+ ...(bodyAttachments ?? []),
12
+ ...(opts.attachments ?? []).map(createEmailAttachment),
13
+ ];
8
14
  const effectiveBody = {
9
- ...body,
15
+ ...bodyWithoutAttachments,
10
16
  ...(typeof opts.dryRun === "boolean" ? { dryRun: opts.dryRun } : {}),
11
17
  ...(typeof opts.transport === "string" ? { transport: opts.transport } : {}),
18
+ ...(attachments.length > 0 ? { attachments } : {}),
12
19
  };
13
20
  const parsed = await body_schema.safeParseAsync(effectiveBody);
14
21
  if (!parsed.success) {
@@ -1 +1 @@
1
- {"version":3,"file":"send-email.js","sourceRoot":"","sources":["../src/send-email.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAEhB,OAAO,EAEL,gCAAgC,GACjC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,yBAAyB,MAAM,mBAAmB,CAAC;AAC1D,OAAO,iCAAiC,MAAM,2CAA2C,CAAC;AAE1F,MAAM,WAAW,GAAG,gCAAgC,CAAC,IAAI,CAAC,CAAC;AAc3D,OAAO,EAAE,yBAAyB,EAAE,CAAC;AAErC,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,EAC9B,IAAI,EACJ,GAAG,IAAI,EACQ;IACf,MAAM,aAAa,GAAyB;QAC1C,GAAG,IAAI;QACP,GAAG,CAAC,OAAO,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACpE,GAAG,CAAC,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7E,CA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,CAAC,MAAM,CAAC,IAAmC,CAAC;QAChE,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,UAAU,WAAW,EAAE;SACvC;KACF,CAAC,CAAC;IACH,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QAC5C,IAAI,YAAY,GAAG,4CAA4C,CAAC;QAChE,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACtC,IACE,OAAO,OAAO,KAAK,QAAQ;gBAC3B,CAAC,CAAC,OAAO;gBACT,SAAS,IAAI,OAAO;gBACpB,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ,EACnC,CAAC;gBACD,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;YACjC,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,kDAAkD;QACpD,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;IAChC,CAAC;IACD,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC3C,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,CAAC,YAAY,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IACD,IAAI,CAAC,CAAC,SAAS,IAAI,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;IAED,OAAO;AACT,CAAC;AAED,eAAe,SAAS,CAAC"}
@@ -0,0 +1,64 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Maximum number of attachments accepted on a single email.
4
+ */
5
+ export declare const MAX_ATTACHMENTS_PER_EMAIL: number;
6
+ /**
7
+ * Maximum combined size, in decoded bytes, of every attachment on a single
8
+ * email (25 MiB). Most receiving mail systems reject whole messages larger
9
+ * than this, so bigger payloads would never be deliverable regardless of
10
+ * which transport the mail-server uses. The mail-server (and the platform
11
+ * it is hosted on) may enforce a lower limit of its own.
12
+ */
13
+ export declare const MAX_TOTAL_ATTACHMENT_BYTES: number;
14
+ /**
15
+ * Number of bytes a (padded, whitespace-free) base64 string decodes to,
16
+ * computed without actually decoding it.
17
+ */
18
+ export declare function base64DecodedByteLength(base64: string): number;
19
+ /**
20
+ * Name the recipient's mail client shows for the attached file. Unicode is
21
+ * allowed; path separators and control characters are not.
22
+ */
23
+ export declare const attachmentFilenameSchema: z.ZodString;
24
+ /**
25
+ * The attached file's bytes, base64-encoded (standard alphabet, padded, no
26
+ * line breaks). Request bodies are JSON, so binary content has to travel
27
+ * as text.
28
+ */
29
+ export declare const attachmentContentSchema: z.ZodBase64;
30
+ /**
31
+ * MIME type of the attachment, e.g. "application/pdf" or
32
+ * "text/csv; charset=utf-8". When omitted, the mail-server's transport
33
+ * derives it from the filename's extension.
34
+ */
35
+ export declare const attachmentContentTypeSchema: z.ZodString;
36
+ /**
37
+ * Content-ID for inline attachments. Setting it marks the attachment as
38
+ * inline so the HTML body can reference it as `<img src="cid:<contentId>">`.
39
+ * Pass the bare identifier -- without the angle brackets.
40
+ */
41
+ export declare const attachmentContentIdSchema: z.ZodString;
42
+ /**
43
+ * A single file attached to an email, in the shape accepted by the
44
+ * `@schemavaults/mail-server` `/api/send` route.
45
+ */
46
+ export declare const emailAttachmentSchema: z.ZodObject<{
47
+ filename: z.ZodNonOptional<z.ZodString>;
48
+ content: z.ZodNonOptional<z.ZodBase64>;
49
+ contentType: z.ZodOptional<z.ZodString>;
50
+ contentId: z.ZodOptional<z.ZodString>;
51
+ }, z.core.$strict>;
52
+ export type EmailAttachment = z.infer<typeof emailAttachmentSchema>;
53
+ /**
54
+ * The full list of attachments on one email: between 1 and
55
+ * {@link MAX_ATTACHMENTS_PER_EMAIL} files whose decoded sizes add up to at
56
+ * most {@link MAX_TOTAL_ATTACHMENT_BYTES}.
57
+ */
58
+ export declare const emailAttachmentsSchema: z.ZodArray<z.ZodObject<{
59
+ filename: z.ZodNonOptional<z.ZodString>;
60
+ content: z.ZodNonOptional<z.ZodBase64>;
61
+ contentType: z.ZodOptional<z.ZodString>;
62
+ contentId: z.ZodOptional<z.ZodString>;
63
+ }, z.core.$strict>>;
64
+ export default emailAttachmentSchema;
@@ -0,0 +1,120 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Maximum number of attachments accepted on a single email.
4
+ */
5
+ export const MAX_ATTACHMENTS_PER_EMAIL = 20;
6
+ /**
7
+ * Maximum combined size, in decoded bytes, of every attachment on a single
8
+ * email (25 MiB). Most receiving mail systems reject whole messages larger
9
+ * than this, so bigger payloads would never be deliverable regardless of
10
+ * which transport the mail-server uses. The mail-server (and the platform
11
+ * it is hosted on) may enforce a lower limit of its own.
12
+ */
13
+ export const MAX_TOTAL_ATTACHMENT_BYTES = 25 * 1024 * 1024;
14
+ /**
15
+ * Number of bytes a (padded, whitespace-free) base64 string decodes to,
16
+ * computed without actually decoding it.
17
+ */
18
+ export function base64DecodedByteLength(base64) {
19
+ if (base64.length === 0)
20
+ return 0;
21
+ let padding = 0;
22
+ if (base64.endsWith("=="))
23
+ padding = 2;
24
+ else if (base64.endsWith("="))
25
+ padding = 1;
26
+ return Math.floor((base64.length * 3) / 4) - padding;
27
+ }
28
+ function hasControlCharacters(value) {
29
+ for (let i = 0; i < value.length; i++) {
30
+ const code = value.charCodeAt(i);
31
+ if (code < 0x20 || code === 0x7f)
32
+ return true;
33
+ }
34
+ return false;
35
+ }
36
+ /**
37
+ * Name the recipient's mail client shows for the attached file. Unicode is
38
+ * allowed; path separators and control characters are not.
39
+ */
40
+ export const attachmentFilenameSchema = z
41
+ .string()
42
+ .min(1, "Attachment filename must be non-empty!")
43
+ .max(255, "Attachment filename must be at most 255 characters!")
44
+ .refine((name) => name !== "." && name !== "..", {
45
+ message: "Attachment filename must not be '.' or '..'!",
46
+ })
47
+ .refine((name) => !name.includes("/") && !name.includes("\\"), {
48
+ message: "Attachment filename must not contain path separators!",
49
+ })
50
+ .refine((name) => !hasControlCharacters(name), {
51
+ message: "Attachment filename must not contain control characters!",
52
+ });
53
+ /**
54
+ * The attached file's bytes, base64-encoded (standard alphabet, padded, no
55
+ * line breaks). Request bodies are JSON, so binary content has to travel
56
+ * as text.
57
+ */
58
+ export const attachmentContentSchema = z
59
+ .base64("Attachment content must be base64-encoded!")
60
+ .min(1, "Attachment content must not be empty!");
61
+ const MIME_TOKEN = "[A-Za-z0-9!#$&^_.+-]+";
62
+ /**
63
+ * MIME type of the attachment, e.g. "application/pdf" or
64
+ * "text/csv; charset=utf-8". When omitted, the mail-server's transport
65
+ * derives it from the filename's extension.
66
+ */
67
+ export const attachmentContentTypeSchema = z
68
+ .string()
69
+ .min(1, "Attachment content type must be non-empty!")
70
+ .max(255, "Attachment content type must be at most 255 characters!")
71
+ .regex(new RegExp(`^${MIME_TOKEN}\\/${MIME_TOKEN}(?:\\s*;\\s*${MIME_TOKEN}=(?:"[^"]*"|[^\\s;"]+))*$`), "Attachment content type must be a MIME type such as 'application/pdf'!");
72
+ /**
73
+ * Content-ID for inline attachments. Setting it marks the attachment as
74
+ * inline so the HTML body can reference it as `<img src="cid:<contentId>">`.
75
+ * Pass the bare identifier -- without the angle brackets.
76
+ */
77
+ export const attachmentContentIdSchema = z
78
+ .string()
79
+ .min(1, "Attachment content ID must be non-empty!")
80
+ .max(255, "Attachment content ID must be at most 255 characters!")
81
+ .regex(/^[^\s<>]+$/, "Attachment content ID must not contain whitespace or angle brackets!");
82
+ /**
83
+ * A single file attached to an email, in the shape accepted by the
84
+ * `@schemavaults/mail-server` `/api/send` route.
85
+ */
86
+ export const emailAttachmentSchema = z
87
+ .object({
88
+ filename: attachmentFilenameSchema,
89
+ content: attachmentContentSchema,
90
+ contentType: attachmentContentTypeSchema.optional(),
91
+ contentId: attachmentContentIdSchema.optional(),
92
+ })
93
+ .required({
94
+ filename: true,
95
+ content: true,
96
+ })
97
+ .strict();
98
+ /**
99
+ * The full list of attachments on one email: between 1 and
100
+ * {@link MAX_ATTACHMENTS_PER_EMAIL} files whose decoded sizes add up to at
101
+ * most {@link MAX_TOTAL_ATTACHMENT_BYTES}.
102
+ */
103
+ export const emailAttachmentsSchema = z
104
+ .array(emailAttachmentSchema)
105
+ .min(1, "Provide at least one attachment, or omit 'attachments' entirely!")
106
+ .max(MAX_ATTACHMENTS_PER_EMAIL, `An email may have at most ${MAX_ATTACHMENTS_PER_EMAIL} attachments!`)
107
+ .superRefine((attachments, ctx) => {
108
+ let totalBytes = 0;
109
+ for (const attachment of attachments) {
110
+ totalBytes += base64DecodedByteLength(attachment.content);
111
+ }
112
+ if (totalBytes > MAX_TOTAL_ATTACHMENT_BYTES) {
113
+ ctx.addIssue({
114
+ code: "custom",
115
+ message: `Attachments must total at most ${MAX_TOTAL_ATTACHMENT_BYTES} bytes (${MAX_TOTAL_ATTACHMENT_BYTES / (1024 * 1024)} MiB) once decoded; received ${totalBytes} bytes.`,
116
+ });
117
+ }
118
+ });
119
+ export default emailAttachmentSchema;
120
+ //# sourceMappingURL=email-attachment-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email-attachment-schema.js","sourceRoot":"","sources":["../../src/validators/email-attachment-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAW,EAAE,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAW,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAEnE;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAc;IACpD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAClC,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,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B,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,UAAU,IAAI,uBAAuB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC5D,CAAC;IACD,IAAI,UAAU,GAAG,0BAA0B,EAAE,CAAC;QAC5C,GAAG,CAAC,QAAQ,CAAC;YACX,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,kCAAkC,0BAA0B,WAAW,0BAA0B,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,gCAAgC,UAAU,SAAS;SAC9K,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,eAAe,qBAAqB,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@schemavaults/send-email",
3
3
  "description": "Schema defining the shape of the request body to send an email via @schemavaults/mail-server",
4
- "version": "0.3.1",
4
+ "version": "0.4.0",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
7
7
  "repository": {
@@ -51,6 +51,11 @@
51
51
  "import": "./dist/index.js",
52
52
  "require": "./dist/index.js"
53
53
  },
54
+ "./create-email-attachment-from-file": {
55
+ "types": "./dist/create-email-attachment-from-file.d.ts",
56
+ "import": "./dist/create-email-attachment-from-file.js",
57
+ "require": "./dist/create-email-attachment-from-file.js"
58
+ },
54
59
  "./*": {
55
60
  "types": "./dist/*",
56
61
  "import": "./dist/*",