const { z } = require("zod") const LIMITS = { MAX_LINE_LENGTH: 512, MAX_MAIL_SIZE: 10 * 1024 * 1024, TIMEOUT_MS: 30000 } function validateEmail(email) { const schema = z.string().email().max(255) const result = schema.safeParse(email) return result.success } function isLineSafe(line) { if (!line || line.length > LIMITS.MAX_LINE_LENGTH) { return false } const dangerousPattern = /[\0\b\v\f]/ return !dangerousPattern.test(line) } function sanitizePath(input) { return input.replace(/[^a-zA-Z0-9_\-]/g, "") } function createSizeChecker(maxSize = LIMITS.MAX_MAIL_SIZE) { let currentSize = 0 return function(chunkLength) { currentSize += chunkLength if (currentSize > maxSize) { return false } return true } } module.exports = { isLineSafe, sanitizePath, validateEmail, createSizeChecker }