typedmailer 2.1.0 → 2.1.1

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 (2) hide show
  1. package/dist/config.js +12 -6
  2. package/package.json +1 -1
package/dist/config.js CHANGED
@@ -1,4 +1,8 @@
1
1
  import { z } from 'zod';
2
+ const headerValueSchema = z
3
+ .string()
4
+ .refine((value) => !/[\r\n\0]/.test(value), 'Header values cannot contain line breaks or NUL.');
5
+ const headerNameSchema = z.string().regex(/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/, 'Use a valid header field name.');
2
6
  const emailSchema = z.string().email();
3
7
  const addressObjectSchema = z
4
8
  .object({
@@ -25,23 +29,25 @@ export const mailInputSchema = z
25
29
  subject: z
26
30
  .string()
27
31
  .min(1)
28
- .refine((value) => value.trim().length > 0, 'Subject cannot be blank.'),
29
- messageId: z.string().min(1).optional(),
32
+ .refine((value) => value.trim().length > 0, 'Subject cannot be blank.')
33
+ .refine((value) => !/[\r\n\0]/.test(value), 'Subject cannot contain line breaks or NUL.'),
34
+ messageId: headerValueSchema.min(1).optional(),
30
35
  text: z.string().optional(),
31
36
  html: z.string().optional(),
32
37
  replyTo: addressSchema.optional(),
33
38
  cc: z.union([addressSchema, z.array(addressSchema)]).optional(),
34
39
  bcc: z.union([addressSchema, z.array(addressSchema)]).optional(),
35
- headers: z.record(z.string(), z.string()).optional(),
40
+ headers: z.record(headerNameSchema, headerValueSchema).optional(),
36
41
  attachments: z
37
42
  .array(z.object({
38
43
  filename: z
39
44
  .string()
40
45
  .min(1)
41
- .refine((value) => value.trim().length > 0, 'Attachment filename cannot be blank.'),
46
+ .refine((value) => value.trim().length > 0, 'Attachment filename cannot be blank.')
47
+ .refine((value) => !/[\r\n\0]/.test(value), 'Attachment filename cannot contain line breaks or NUL.'),
42
48
  content: z.union([z.string(), z.instanceof(Uint8Array)]),
43
- contentType: z.string().min(1).optional(),
44
- contentId: z.string().min(1).optional(),
49
+ contentType: headerValueSchema.min(1).optional(),
50
+ contentId: headerValueSchema.min(1).optional(),
45
51
  }))
46
52
  .optional(),
47
53
  idempotencyKey: z.string().min(1).optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typedmailer",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "A type-safe Node.js email library with one API for Resend, Brevo, Postmark, SendGrid, Mailgun, Amazon SES, or SMTP.",
5
5
  "author": "Erol Senol",
6
6
  "license": "MIT",