hazo_notify 1.0.1 → 1.0.2
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/dist/emailer/emailer.d.ts +19 -0
- package/dist/emailer/emailer.d.ts.map +1 -0
- package/dist/emailer/emailer.js +224 -0
- package/dist/emailer/emailer.js.map +1 -0
- package/dist/emailer/index.d.ts +11 -0
- package/dist/emailer/index.d.ts.map +1 -0
- package/dist/emailer/index.js +34 -0
- package/dist/emailer/index.js.map +1 -0
- package/dist/emailer/providers/index.d.ts +15 -0
- package/dist/emailer/providers/index.d.ts.map +1 -0
- package/dist/emailer/providers/index.js +36 -0
- package/dist/emailer/providers/index.js.map +1 -0
- package/dist/emailer/providers/pop3_provider.d.ts +15 -0
- package/dist/emailer/providers/pop3_provider.d.ts.map +1 -0
- package/dist/emailer/providers/pop3_provider.js +29 -0
- package/dist/emailer/providers/pop3_provider.js.map +1 -0
- package/dist/emailer/providers/smtp_provider.d.ts +15 -0
- package/dist/emailer/providers/smtp_provider.d.ts.map +1 -0
- package/dist/emailer/providers/smtp_provider.js +29 -0
- package/dist/emailer/providers/smtp_provider.js.map +1 -0
- package/dist/emailer/providers/zeptomail_provider.d.ts +15 -0
- package/dist/emailer/providers/zeptomail_provider.d.ts.map +1 -0
- package/dist/emailer/providers/zeptomail_provider.js +255 -0
- package/dist/emailer/providers/zeptomail_provider.js.map +1 -0
- package/dist/emailer/types.d.ts +94 -0
- package/dist/emailer/types.d.ts.map +1 -0
- package/dist/emailer/types.js +6 -0
- package/dist/emailer/types.js.map +1 -0
- package/dist/emailer/utils/constants.d.ts +15 -0
- package/dist/emailer/utils/constants.d.ts.map +1 -0
- package/dist/emailer/utils/constants.js +22 -0
- package/dist/emailer/utils/constants.js.map +1 -0
- package/dist/emailer/utils/index.d.ts +8 -0
- package/dist/emailer/utils/index.d.ts.map +1 -0
- package/dist/emailer/utils/index.js +24 -0
- package/dist/emailer/utils/index.js.map +1 -0
- package/dist/emailer/utils/logger.d.ts +40 -0
- package/dist/emailer/utils/logger.d.ts.map +1 -0
- package/dist/emailer/utils/logger.js +60 -0
- package/dist/emailer/utils/logger.js.map +1 -0
- package/dist/emailer/utils/validation.d.ts +37 -0
- package/dist/emailer/utils/validation.d.ts.map +1 -0
- package/dist/emailer/utils/validation.js +81 -0
- package/dist/emailer/utils/validation.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/utils.d.ts +12 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +18 -0
- package/dist/utils.js.map +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Zeptomail API provider implementation
|
|
4
|
+
* Sends emails using the Zeptomail API
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ZeptomailProvider = void 0;
|
|
11
|
+
const validation_1 = require("../utils/validation");
|
|
12
|
+
const logger_1 = require("../utils/logger");
|
|
13
|
+
const isomorphic_dompurify_1 = __importDefault(require("isomorphic-dompurify"));
|
|
14
|
+
const constants_1 = require("../utils/constants");
|
|
15
|
+
class ZeptomailProvider {
|
|
16
|
+
/**
|
|
17
|
+
* Send email using Zeptomail API
|
|
18
|
+
* @param options - Email send options
|
|
19
|
+
* @param config - Emailer configuration
|
|
20
|
+
* @returns Promise with email send response
|
|
21
|
+
*/
|
|
22
|
+
async send_email(options, config) {
|
|
23
|
+
const filename = 'zeptomail_provider.ts';
|
|
24
|
+
const function_name = 'send_email';
|
|
25
|
+
try {
|
|
26
|
+
// Validate required configuration
|
|
27
|
+
if (!config.zeptomail_api_endpoint) {
|
|
28
|
+
throw new Error('Zeptomail API endpoint is required');
|
|
29
|
+
}
|
|
30
|
+
if (!config.zeptomail_api_key) {
|
|
31
|
+
throw new Error('Zeptomail API key is required');
|
|
32
|
+
}
|
|
33
|
+
// Prepare recipient array
|
|
34
|
+
const to_emails = Array.isArray(options.to) ? options.to : [options.to];
|
|
35
|
+
const cc_emails = options.cc
|
|
36
|
+
? Array.isArray(options.cc)
|
|
37
|
+
? options.cc
|
|
38
|
+
: [options.cc]
|
|
39
|
+
: [];
|
|
40
|
+
const bcc_emails = options.bcc
|
|
41
|
+
? Array.isArray(options.bcc)
|
|
42
|
+
? options.bcc
|
|
43
|
+
: [options.bcc]
|
|
44
|
+
: [];
|
|
45
|
+
// Prepare email data according to Zeptomail API format
|
|
46
|
+
const email_data = {
|
|
47
|
+
from: {
|
|
48
|
+
address: options.from || config.from_email,
|
|
49
|
+
name: (0, validation_1.sanitize_email_header)(options.from_name || config.from_name || 'Hazo Notify'),
|
|
50
|
+
},
|
|
51
|
+
to: to_emails.map((email) => ({
|
|
52
|
+
email_address: {
|
|
53
|
+
address: email,
|
|
54
|
+
},
|
|
55
|
+
})),
|
|
56
|
+
subject: (0, validation_1.sanitize_email_header)(options.subject),
|
|
57
|
+
};
|
|
58
|
+
// Add content (text and/or html)
|
|
59
|
+
if (options.content.text) {
|
|
60
|
+
email_data.textbody = options.content.text;
|
|
61
|
+
}
|
|
62
|
+
if (options.content.html) {
|
|
63
|
+
// Sanitize HTML content to prevent XSS attacks
|
|
64
|
+
email_data.htmlbody = isomorphic_dompurify_1.default.sanitize(options.content.html);
|
|
65
|
+
}
|
|
66
|
+
// Add reply-to if specified
|
|
67
|
+
if (options.reply_to || config.reply_to_email) {
|
|
68
|
+
email_data.reply_to = [
|
|
69
|
+
{
|
|
70
|
+
address: (0, validation_1.sanitize_email_header)(options.reply_to || config.reply_to_email || ''),
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
// Add CC if specified
|
|
75
|
+
if (cc_emails.length > 0) {
|
|
76
|
+
email_data.cc = cc_emails.map((email) => ({
|
|
77
|
+
email_address: {
|
|
78
|
+
address: email,
|
|
79
|
+
},
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
// Add BCC if specified
|
|
83
|
+
if (bcc_emails.length > 0) {
|
|
84
|
+
email_data.bcc = bcc_emails.map((email) => ({
|
|
85
|
+
email_address: {
|
|
86
|
+
address: email,
|
|
87
|
+
},
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
// Add attachments if specified
|
|
91
|
+
if (options.attachments && options.attachments.length > 0) {
|
|
92
|
+
email_data.attachments = options.attachments.map((attachment) => ({
|
|
93
|
+
name: attachment.filename,
|
|
94
|
+
content: attachment.content,
|
|
95
|
+
mime_type: attachment.mime_type,
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
// Prepare request headers
|
|
99
|
+
const api_key = config.zeptomail_api_key.trim();
|
|
100
|
+
const auth_header = api_key.startsWith('Zoho-enczapikey')
|
|
101
|
+
? api_key
|
|
102
|
+
: `Zoho-enczapikey ${api_key}`;
|
|
103
|
+
const headers = {
|
|
104
|
+
Accept: 'application/json',
|
|
105
|
+
'Content-Type': 'application/json',
|
|
106
|
+
Authorization: auth_header,
|
|
107
|
+
};
|
|
108
|
+
// Log request for debugging (mask API key in logs)
|
|
109
|
+
(0, logger_1.log_info)((0, logger_1.create_log_entry)(filename, function_name, 'Sending email via Zeptomail API', {
|
|
110
|
+
endpoint: config.zeptomail_api_endpoint,
|
|
111
|
+
method: 'POST',
|
|
112
|
+
headers: {
|
|
113
|
+
...headers,
|
|
114
|
+
Authorization: headers.Authorization ? 'Zoho-enczapikey ***' : undefined,
|
|
115
|
+
},
|
|
116
|
+
body: {
|
|
117
|
+
from: email_data.from,
|
|
118
|
+
to_count: email_data.to.length,
|
|
119
|
+
subject: email_data.subject,
|
|
120
|
+
has_text: !!email_data.textbody,
|
|
121
|
+
has_html: !!email_data.htmlbody,
|
|
122
|
+
attachments_count: email_data.attachments?.length || 0,
|
|
123
|
+
},
|
|
124
|
+
}));
|
|
125
|
+
// Set up request timeout
|
|
126
|
+
const timeout = config.request_timeout || constants_1.DEFAULT_REQUEST_TIMEOUT;
|
|
127
|
+
const controller = new AbortController();
|
|
128
|
+
const timeout_id = setTimeout(() => controller.abort(), timeout);
|
|
129
|
+
try {
|
|
130
|
+
// Make API request
|
|
131
|
+
const response = await fetch(config.zeptomail_api_endpoint, {
|
|
132
|
+
method: 'POST',
|
|
133
|
+
headers: headers,
|
|
134
|
+
body: JSON.stringify(email_data),
|
|
135
|
+
signal: controller.signal,
|
|
136
|
+
});
|
|
137
|
+
clearTimeout(timeout_id);
|
|
138
|
+
// Parse response
|
|
139
|
+
let response_data;
|
|
140
|
+
const content_type = response.headers.get('content-type') || '';
|
|
141
|
+
const response_text = await response.text();
|
|
142
|
+
if (content_type.includes('application/json')) {
|
|
143
|
+
try {
|
|
144
|
+
response_data = JSON.parse(response_text);
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
response_data = { error: 'Failed to parse JSON response', raw: response_text };
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
response_data = {
|
|
152
|
+
text: response_text,
|
|
153
|
+
error: response_text.trim() || 'Unknown error from server',
|
|
154
|
+
};
|
|
155
|
+
(0, logger_1.log_error)((0, logger_1.create_log_entry)(filename, function_name, 'Zeptomail API returned non-JSON response', {
|
|
156
|
+
status: response.status,
|
|
157
|
+
statusText: response.statusText,
|
|
158
|
+
contentType: content_type,
|
|
159
|
+
body: response_text,
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
162
|
+
const raw_response = {
|
|
163
|
+
status: response.status,
|
|
164
|
+
status_text: response.statusText,
|
|
165
|
+
headers: Object.fromEntries(response.headers.entries()),
|
|
166
|
+
body: response_data,
|
|
167
|
+
};
|
|
168
|
+
// Check if request was successful
|
|
169
|
+
if (!response.ok) {
|
|
170
|
+
const error_message = response_data.message ||
|
|
171
|
+
response_data.error ||
|
|
172
|
+
`HTTP ${response.status}: ${response.statusText}`;
|
|
173
|
+
(0, logger_1.log_error)((0, logger_1.create_log_entry)(filename, function_name, 'Zeptomail API error', {
|
|
174
|
+
status: response.status,
|
|
175
|
+
error_message,
|
|
176
|
+
response_body: response_data,
|
|
177
|
+
}));
|
|
178
|
+
const is_production = process.env.NODE_ENV === 'production';
|
|
179
|
+
return {
|
|
180
|
+
success: false,
|
|
181
|
+
error: error_message,
|
|
182
|
+
raw_response: is_production
|
|
183
|
+
? { status: response.status, status_text: response.statusText }
|
|
184
|
+
: raw_response,
|
|
185
|
+
message: error_message,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
// Return successful response
|
|
189
|
+
const data = response_data
|
|
190
|
+
.data;
|
|
191
|
+
return {
|
|
192
|
+
success: true,
|
|
193
|
+
message_id: data?.message_id ||
|
|
194
|
+
response_data.message_id ||
|
|
195
|
+
undefined,
|
|
196
|
+
message: 'Email sent successfully',
|
|
197
|
+
raw_response: raw_response,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
catch (fetch_error) {
|
|
201
|
+
clearTimeout(timeout_id);
|
|
202
|
+
// Handle timeout errors
|
|
203
|
+
if (fetch_error instanceof Error && fetch_error.name === 'AbortError') {
|
|
204
|
+
const timeout_error = `Request timeout after ${timeout}ms`;
|
|
205
|
+
(0, logger_1.log_error)((0, logger_1.create_log_entry)(filename, function_name, timeout_error, {
|
|
206
|
+
options: {
|
|
207
|
+
to: options.to,
|
|
208
|
+
subject: options.subject,
|
|
209
|
+
has_text: !!options.content.text,
|
|
210
|
+
has_html: !!options.content.html,
|
|
211
|
+
attachments_count: options.attachments?.length || 0,
|
|
212
|
+
},
|
|
213
|
+
}));
|
|
214
|
+
return {
|
|
215
|
+
success: false,
|
|
216
|
+
error: timeout_error,
|
|
217
|
+
message: timeout_error,
|
|
218
|
+
raw_response: undefined,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
throw fetch_error;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
const error_message = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
226
|
+
const error_string = error instanceof Error ? error.toString() : String(error);
|
|
227
|
+
const stack = error instanceof Error ? error.stack : undefined;
|
|
228
|
+
const is_production = process.env.NODE_ENV === 'production';
|
|
229
|
+
(0, logger_1.log_error)((0, logger_1.create_log_entry)(filename, function_name, error_message, {
|
|
230
|
+
line_number: stack || 'unknown',
|
|
231
|
+
error: error_string,
|
|
232
|
+
options: {
|
|
233
|
+
to: options.to,
|
|
234
|
+
subject: options.subject,
|
|
235
|
+
has_text: !!options.content.text,
|
|
236
|
+
has_html: !!options.content.html,
|
|
237
|
+
attachments_count: options.attachments?.length || 0,
|
|
238
|
+
},
|
|
239
|
+
}));
|
|
240
|
+
return {
|
|
241
|
+
success: false,
|
|
242
|
+
error: error_message,
|
|
243
|
+
message: error_message,
|
|
244
|
+
raw_response: is_production
|
|
245
|
+
? undefined
|
|
246
|
+
: {
|
|
247
|
+
error: error_string,
|
|
248
|
+
stack: stack,
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
exports.ZeptomailProvider = ZeptomailProvider;
|
|
255
|
+
//# sourceMappingURL=zeptomail_provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zeptomail_provider.js","sourceRoot":"","sources":["../../../src/lib/emailer/providers/zeptomail_provider.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,oDAA4D;AAC5D,4CAAwE;AACxE,gFAA6C;AAC7C,kDAA6D;AAS7D,MAAa,iBAAiB;IAC5B;;;;;OAKG;IACH,KAAK,CAAC,UAAU,CACd,OAAyB,EACzB,MAAqB;QAErB,MAAM,QAAQ,GAAG,uBAAuB,CAAC;QACzC,MAAM,aAAa,GAAG,YAAY,CAAC;QAEnC,IAAI,CAAC;YACH,kCAAkC;YACl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C,CAAC;YAC/E,MAAM,KAAK,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;YAC/D,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;YAE5D,IAAA,kBAAS,EACP,IAAA,yBAAgB,EAAC,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE;gBACvD,WAAW,EAAE,KAAK,IAAI,SAAS;gBAC/B,KAAK,EAAE,YAAY;gBACnB,OAAO,EAAE;oBACP,EAAE,EAAE,OAAO,CAAC,EAAE;oBACd,OAAO,EAAE,OAAO,CAAC,OAAO;oBACxB,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI;oBAChC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI;oBAChC,iBAAiB,EAAE,OAAO,CAAC,WAAW,EAAE,MAAM,IAAI,CAAC;iBACpD;aACF,CAAC,CACH,CAAC;YAEF,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,aAAa;gBACpB,OAAO,EAAE,aAAa;gBACtB,YAAY,EAAE,aAAa;oBACzB,CAAC,CAAC,SAAS;oBACX,CAAC,CAAC;wBACE,KAAK,EAAE,YAAY;wBACnB,KAAK,EAAE,KAAK;qBACb;aACN,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AA3RD,8CA2RC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the emailer service
|
|
3
|
+
*/
|
|
4
|
+
export type EmailerModule = 'zeptoemail_api' | 'smtp' | 'pop3';
|
|
5
|
+
export interface EmailContent {
|
|
6
|
+
text?: string;
|
|
7
|
+
html?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface EmailAttachment {
|
|
10
|
+
filename: string;
|
|
11
|
+
content: string;
|
|
12
|
+
mime_type: string;
|
|
13
|
+
}
|
|
14
|
+
export interface SendEmailOptions {
|
|
15
|
+
to: string | string[];
|
|
16
|
+
subject: string;
|
|
17
|
+
content: EmailContent;
|
|
18
|
+
attachments?: EmailAttachment[];
|
|
19
|
+
from?: string;
|
|
20
|
+
from_name?: string;
|
|
21
|
+
reply_to?: string;
|
|
22
|
+
cc?: string | string[];
|
|
23
|
+
bcc?: string | string[];
|
|
24
|
+
}
|
|
25
|
+
export interface EmailerConfig {
|
|
26
|
+
emailer_module: EmailerModule;
|
|
27
|
+
zeptomail_api_endpoint?: string;
|
|
28
|
+
zeptomail_api_key?: string;
|
|
29
|
+
from_email: string;
|
|
30
|
+
from_name: string;
|
|
31
|
+
reply_to_email?: string;
|
|
32
|
+
bounce_email?: string;
|
|
33
|
+
return_path_email?: string;
|
|
34
|
+
rate_limit_requests?: number;
|
|
35
|
+
rate_limit_window?: number;
|
|
36
|
+
max_attachment_size?: number;
|
|
37
|
+
max_attachments?: number;
|
|
38
|
+
request_timeout?: number;
|
|
39
|
+
max_subject_length?: number;
|
|
40
|
+
max_body_length?: number;
|
|
41
|
+
cors_allowed_origins?: string;
|
|
42
|
+
smtp_host?: string;
|
|
43
|
+
smtp_port?: number;
|
|
44
|
+
smtp_secure?: boolean;
|
|
45
|
+
smtp_auth_user?: string;
|
|
46
|
+
smtp_auth_pass?: string;
|
|
47
|
+
smtp_timeout?: number;
|
|
48
|
+
smtp_pool?: boolean;
|
|
49
|
+
pop3_host?: string;
|
|
50
|
+
pop3_port?: number;
|
|
51
|
+
pop3_secure?: boolean;
|
|
52
|
+
pop3_auth_user?: string;
|
|
53
|
+
pop3_auth_pass?: string;
|
|
54
|
+
pop3_timeout?: number;
|
|
55
|
+
}
|
|
56
|
+
export interface EmailSendResponse {
|
|
57
|
+
success: boolean;
|
|
58
|
+
message_id?: string;
|
|
59
|
+
message?: string;
|
|
60
|
+
raw_response?: Record<string, unknown> | string;
|
|
61
|
+
error?: string;
|
|
62
|
+
}
|
|
63
|
+
export interface ZeptomailEmailAddress {
|
|
64
|
+
address: string;
|
|
65
|
+
name?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface ZeptomailEmailAddressObject {
|
|
68
|
+
email_address: ZeptomailEmailAddress;
|
|
69
|
+
}
|
|
70
|
+
export interface ZeptomailAttachment {
|
|
71
|
+
name: string;
|
|
72
|
+
content: string;
|
|
73
|
+
mime_type: string;
|
|
74
|
+
}
|
|
75
|
+
export interface ZeptomailEmailData {
|
|
76
|
+
from: {
|
|
77
|
+
address: string;
|
|
78
|
+
name: string;
|
|
79
|
+
};
|
|
80
|
+
to: ZeptomailEmailAddressObject[];
|
|
81
|
+
subject: string;
|
|
82
|
+
textbody?: string;
|
|
83
|
+
htmlbody?: string;
|
|
84
|
+
reply_to?: Array<{
|
|
85
|
+
address: string;
|
|
86
|
+
}>;
|
|
87
|
+
cc?: ZeptomailEmailAddressObject[];
|
|
88
|
+
bcc?: ZeptomailEmailAddressObject[];
|
|
89
|
+
attachments?: ZeptomailAttachment[];
|
|
90
|
+
}
|
|
91
|
+
export interface EmailProvider {
|
|
92
|
+
send_email(options: SendEmailOptions, config: EmailerConfig): Promise<EmailSendResponse>;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/emailer/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG,MAAM,GAAG,MAAM,CAAC;AAE/D,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,GAAG,MAAM,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B,UAAU,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC1F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/lib/emailer/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constants for emailer service
|
|
3
|
+
* Centralized constants to avoid magic numbers and strings
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_RATE_LIMIT_REQUESTS = 10;
|
|
6
|
+
export declare const DEFAULT_RATE_LIMIT_WINDOW = 60;
|
|
7
|
+
export declare const DEFAULT_MAX_ATTACHMENT_SIZE: number;
|
|
8
|
+
export declare const DEFAULT_MAX_ATTACHMENTS = 10;
|
|
9
|
+
export declare const DEFAULT_REQUEST_TIMEOUT = 30000;
|
|
10
|
+
export declare const MAX_SUBJECT_LENGTH = 255;
|
|
11
|
+
export declare const MAX_BODY_LENGTH: number;
|
|
12
|
+
export declare const MAX_EMAIL_LENGTH = 254;
|
|
13
|
+
export declare const VALID_EMAILER_MODULES: readonly ["zeptoemail_api", "smtp", "pop3"];
|
|
14
|
+
export type EmailerModule = typeof VALID_EMAILER_MODULES[number];
|
|
15
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/emailer/utils/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAC9C,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAG5C,eAAO,MAAM,2BAA2B,QAAmB,CAAC;AAC5D,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAG1C,eAAO,MAAM,uBAAuB,QAAQ,CAAC;AAG7C,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,eAAe,QAAc,CAAC;AAC3C,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAGpC,eAAO,MAAM,qBAAqB,6CAA8C,CAAC;AACjF,MAAM,MAAM,aAAa,GAAG,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Constants for emailer service
|
|
4
|
+
* Centralized constants to avoid magic numbers and strings
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.VALID_EMAILER_MODULES = exports.MAX_EMAIL_LENGTH = exports.MAX_BODY_LENGTH = exports.MAX_SUBJECT_LENGTH = exports.DEFAULT_REQUEST_TIMEOUT = exports.DEFAULT_MAX_ATTACHMENTS = exports.DEFAULT_MAX_ATTACHMENT_SIZE = exports.DEFAULT_RATE_LIMIT_WINDOW = exports.DEFAULT_RATE_LIMIT_REQUESTS = void 0;
|
|
8
|
+
// Rate limiting constants
|
|
9
|
+
exports.DEFAULT_RATE_LIMIT_REQUESTS = 10; // requests per minute
|
|
10
|
+
exports.DEFAULT_RATE_LIMIT_WINDOW = 60; // seconds
|
|
11
|
+
// Attachment limits
|
|
12
|
+
exports.DEFAULT_MAX_ATTACHMENT_SIZE = 10 * 1024 * 1024; // 10MB in bytes
|
|
13
|
+
exports.DEFAULT_MAX_ATTACHMENTS = 10;
|
|
14
|
+
// Request timeout
|
|
15
|
+
exports.DEFAULT_REQUEST_TIMEOUT = 30000; // 30 seconds in milliseconds
|
|
16
|
+
// Input length limits
|
|
17
|
+
exports.MAX_SUBJECT_LENGTH = 255; // characters
|
|
18
|
+
exports.MAX_BODY_LENGTH = 1024 * 1024; // 1MB in bytes
|
|
19
|
+
exports.MAX_EMAIL_LENGTH = 254; // characters (RFC 5321)
|
|
20
|
+
// Valid emailer modules
|
|
21
|
+
exports.VALID_EMAILER_MODULES = ['zeptoemail_api', 'smtp', 'pop3'];
|
|
22
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/emailer/utils/constants.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,0BAA0B;AACb,QAAA,2BAA2B,GAAG,EAAE,CAAC,CAAC,sBAAsB;AACxD,QAAA,yBAAyB,GAAG,EAAE,CAAC,CAAC,UAAU;AAEvD,oBAAoB;AACP,QAAA,2BAA2B,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,gBAAgB;AAChE,QAAA,uBAAuB,GAAG,EAAE,CAAC;AAE1C,kBAAkB;AACL,QAAA,uBAAuB,GAAG,KAAK,CAAC,CAAC,6BAA6B;AAE3E,sBAAsB;AACT,QAAA,kBAAkB,GAAG,GAAG,CAAC,CAAC,aAAa;AACvC,QAAA,eAAe,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,eAAe;AAC9C,QAAA,gBAAgB,GAAG,GAAG,CAAC,CAAC,wBAAwB;AAE7D,wBAAwB;AACX,QAAA,qBAAqB,GAAG,CAAC,gBAAgB,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/emailer/utils/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Utility functions for emailer service
|
|
4
|
+
* Centralized exports for validation, logging, and constants
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
__exportStar(require("./constants"), exports);
|
|
22
|
+
__exportStar(require("./validation"), exports);
|
|
23
|
+
__exportStar(require("./logger"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/emailer/utils/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;AAEH,8CAA4B;AAC5B,+CAA6B;AAC7B,2CAAyB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized logging utility for emailer service
|
|
3
|
+
* Provides consistent JSON logging format across all components
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Log entry interface
|
|
7
|
+
*/
|
|
8
|
+
interface LogEntry {
|
|
9
|
+
filename: string;
|
|
10
|
+
function_name: string;
|
|
11
|
+
line_number?: string | number;
|
|
12
|
+
message: string;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Log an error message
|
|
17
|
+
* @param entry - Log entry object
|
|
18
|
+
*/
|
|
19
|
+
export declare function log_error(entry: LogEntry): void;
|
|
20
|
+
/**
|
|
21
|
+
* Log an info message
|
|
22
|
+
* @param entry - Log entry object
|
|
23
|
+
*/
|
|
24
|
+
export declare function log_info(entry: LogEntry): void;
|
|
25
|
+
/**
|
|
26
|
+
* Log a warning message
|
|
27
|
+
* @param entry - Log entry object
|
|
28
|
+
*/
|
|
29
|
+
export declare function log_warning(entry: LogEntry): void;
|
|
30
|
+
/**
|
|
31
|
+
* Create a log entry with standard fields
|
|
32
|
+
* @param filename - Name of the file
|
|
33
|
+
* @param function_name - Name of the function
|
|
34
|
+
* @param message - Log message
|
|
35
|
+
* @param additional_data - Additional data to include
|
|
36
|
+
* @returns Log entry object
|
|
37
|
+
*/
|
|
38
|
+
export declare function create_log_entry(filename: string, function_name: string, message: string, additional_data?: Record<string, unknown>): LogEntry;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/lib/emailer/utils/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,UAAU,QAAQ;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAM/C;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAM9C;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAMjD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACf,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACxC,QAAQ,CAOV"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Centralized logging utility for emailer service
|
|
4
|
+
* Provides consistent JSON logging format across all components
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.log_error = log_error;
|
|
8
|
+
exports.log_info = log_info;
|
|
9
|
+
exports.log_warning = log_warning;
|
|
10
|
+
exports.create_log_entry = create_log_entry;
|
|
11
|
+
/**
|
|
12
|
+
* Log an error message
|
|
13
|
+
* @param entry - Log entry object
|
|
14
|
+
*/
|
|
15
|
+
function log_error(entry) {
|
|
16
|
+
console.error(JSON.stringify({
|
|
17
|
+
level: 'error',
|
|
18
|
+
timestamp: new Date().toISOString(),
|
|
19
|
+
...entry,
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Log an info message
|
|
24
|
+
* @param entry - Log entry object
|
|
25
|
+
*/
|
|
26
|
+
function log_info(entry) {
|
|
27
|
+
console.log(JSON.stringify({
|
|
28
|
+
level: 'info',
|
|
29
|
+
timestamp: new Date().toISOString(),
|
|
30
|
+
...entry,
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Log a warning message
|
|
35
|
+
* @param entry - Log entry object
|
|
36
|
+
*/
|
|
37
|
+
function log_warning(entry) {
|
|
38
|
+
console.warn(JSON.stringify({
|
|
39
|
+
level: 'warning',
|
|
40
|
+
timestamp: new Date().toISOString(),
|
|
41
|
+
...entry,
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Create a log entry with standard fields
|
|
46
|
+
* @param filename - Name of the file
|
|
47
|
+
* @param function_name - Name of the function
|
|
48
|
+
* @param message - Log message
|
|
49
|
+
* @param additional_data - Additional data to include
|
|
50
|
+
* @returns Log entry object
|
|
51
|
+
*/
|
|
52
|
+
function create_log_entry(filename, function_name, message, additional_data) {
|
|
53
|
+
return {
|
|
54
|
+
filename,
|
|
55
|
+
function_name,
|
|
56
|
+
message,
|
|
57
|
+
...(additional_data || {}),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/lib/emailer/utils/logger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAiBH,8BAMC;AAMD,4BAMC;AAMD,kCAMC;AAUD,4CAYC;AAxDD;;;GAGG;AACH,SAAgB,SAAS,CAAC,KAAe;IACvC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;QAC3B,KAAK,EAAE,OAAO;QACd,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,GAAG,KAAK;KACT,CAAC,CAAC,CAAC;AACN,CAAC;AAED;;;GAGG;AACH,SAAgB,QAAQ,CAAC,KAAe;IACtC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC;QACzB,KAAK,EAAE,MAAM;QACb,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,GAAG,KAAK;KACT,CAAC,CAAC,CAAC;AACN,CAAC;AAED;;;GAGG;AACH,SAAgB,WAAW,CAAC,KAAe;IACzC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;QAC1B,KAAK,EAAE,SAAS;QAChB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,GAAG,KAAK;KACT,CAAC,CAAC,CAAC;AACN,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,gBAAgB,CAC9B,QAAgB,EAChB,aAAqB,EACrB,OAAe,EACf,eAAyC;IAEzC,OAAO;QACL,QAAQ;QACR,aAAa;QACb,OAAO;QACP,GAAG,CAAC,eAAe,IAAI,EAAE,CAAC;KAC3B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation utilities for emailer service
|
|
3
|
+
* Provides email validation, sanitization, and input validation functions
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Validate email address format
|
|
7
|
+
* @param email - Email address to validate
|
|
8
|
+
* @returns boolean indicating if email is valid
|
|
9
|
+
*/
|
|
10
|
+
export declare function validate_email_address(email: string): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Sanitize email header to prevent injection attacks
|
|
13
|
+
* Removes newlines, carriage returns, and other control characters
|
|
14
|
+
* @param value - Header value to sanitize
|
|
15
|
+
* @returns Sanitized header value
|
|
16
|
+
*/
|
|
17
|
+
export declare function sanitize_email_header(value: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Validate subject length
|
|
20
|
+
* @param subject - Email subject to validate
|
|
21
|
+
* @returns boolean indicating if subject is valid
|
|
22
|
+
*/
|
|
23
|
+
export declare function validate_subject_length(subject: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Validate body length
|
|
26
|
+
* @param body - Email body to validate
|
|
27
|
+
* @returns boolean indicating if body is valid
|
|
28
|
+
*/
|
|
29
|
+
export declare function validate_body_length(body: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Validate attachment size
|
|
32
|
+
* @param content - Base64 encoded attachment content
|
|
33
|
+
* @param max_size - Maximum size in bytes
|
|
34
|
+
* @returns boolean indicating if attachment size is valid
|
|
35
|
+
*/
|
|
36
|
+
export declare function validate_attachment_size(content: string, max_size: number): boolean;
|
|
37
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/lib/emailer/utils/validation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAO7D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAM3D;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAKhE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAO1D;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAUnF"}
|